修改蓝牙搜索问题

This commit is contained in:
qcl_123 2026-02-10 15:59:50 +08:00
parent 67624ac297
commit 00aa0903ac
5 changed files with 16 additions and 8 deletions

View File

@ -16,6 +16,10 @@
"customPlaygroundType" : "local",
"playground" : "standard",
"type" : "uni-app:app-android"
},
{
"playground" : "custom",
"type" : "uni-app:app-ios"
}
]
}

View File

@ -7,8 +7,10 @@ let devicesList = []
// 初始化蓝牙
function openBluetoothAdapter() {
devicesList = []
let Language = $store.state.setLocale
let $t = messages[Language]
clearTimeout(searchTimer);
uni.openBluetoothAdapter({
success: e => {
$store.commit("changeBluetoothValue", {
@ -60,6 +62,9 @@ function onBluetoothDeviceFound() {
uni.onBluetoothDeviceFound(res => {
res.devices.forEach(device => {
console.log("name", device.name)
if (!device.name && !device.localName) {
return
}
if (device.name.toLowerCase().indexOf('pc-c06pro') != -1 ||
device.name.toLowerCase().indexOf('pc-c02pro') != -1 ||
device.name.toLowerCase().indexOf('pc-c09pro') != -1 ||
@ -81,7 +86,6 @@ function onBluetoothDeviceFound() {
function Bluetoothfilter(device) {
const foundDevices = devicesList
const idx = inArray(foundDevices, "deviceId", device.deviceId)
// console.log("2222222222", idx, device, )
if (idx === -1) {
devicesList.push(device);
handleDevType(device)
@ -89,7 +93,6 @@ function Bluetoothfilter(device) {
}
// 排查设备
function handleDevType(device) {
// console.log("4444", device)
let Language = $store.state.setLocale
let $t = messages[Language]
$model.getCheckDevice({
@ -353,7 +356,6 @@ function stopBluetoothDevicesDiscovery() {
export default {
ab2hex,
inArray,
handleDevType,
openBluetoothAdapter,
startBluetoothDeviceDiscovery,
onBluetoothDeviceFound,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -29013,8 +29013,10 @@ var devicesList = [];
// 初始化蓝牙
function openBluetoothAdapter() {
devicesList = [];
var Language = _store.default.state.setLocale;
var $t = _index.default[Language];
clearTimeout(searchTimer);
uni.openBluetoothAdapter({
success: function success(e) {
_store.default.commit("changeBluetoothValue", {
@ -29067,6 +29069,9 @@ function onBluetoothDeviceFound() {
uni.onBluetoothDeviceFound(function (res) {
res.devices.forEach(function (device) {
console.log("name", device.name);
if (!device.name && !device.localName) {
return;
}
if (device.name.toLowerCase().indexOf('pc-c06pro') != -1 || device.name.toLowerCase().indexOf('pc-c02pro') != -1 || device.name.toLowerCase().indexOf('pc-c09pro') != -1 || device.localName && device.localName.toLowerCase().indexOf('pc-c06pro') != -1 || device.localName && device.localName.toLowerCase().indexOf('pc-c02pro') != -1 || device.localName && device.localName.toLowerCase().indexOf('pc-c09pro') != -1) {
clearTimeout(searchTimer);
var bytes = new Uint8Array(device.advertisData);
@ -29083,7 +29088,6 @@ function onBluetoothDeviceFound() {
function Bluetoothfilter(device) {
var foundDevices = devicesList;
var idx = inArray(foundDevices, "deviceId", device.deviceId);
// console.log("2222222222", idx, device, )
if (idx === -1) {
devicesList.push(device);
handleDevType(device);
@ -29091,7 +29095,6 @@ function Bluetoothfilter(device) {
}
// 排查设备
function handleDevType(device) {
// console.log("4444", device)
var Language = _store.default.state.setLocale;
var $t = _index.default[Language];
_model.default.getCheckDevice({
@ -29342,7 +29345,6 @@ function stopBluetoothDevicesDiscovery() {
var _default = {
ab2hex: ab2hex,
inArray: inArray,
handleDevType: handleDevType,
openBluetoothAdapter: openBluetoothAdapter,
startBluetoothDeviceDiscovery: startBluetoothDeviceDiscovery,
onBluetoothDeviceFound: onBluetoothDeviceFound,