修改蓝牙搜索问题
This commit is contained in:
parent
67624ac297
commit
00aa0903ac
|
|
@ -16,6 +16,10 @@
|
||||||
"customPlaygroundType" : "local",
|
"customPlaygroundType" : "local",
|
||||||
"playground" : "standard",
|
"playground" : "standard",
|
||||||
"type" : "uni-app:app-android"
|
"type" : "uni-app:app-android"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"playground" : "custom",
|
||||||
|
"type" : "uni-app:app-ios"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,10 @@ let devicesList = []
|
||||||
// 初始化蓝牙
|
// 初始化蓝牙
|
||||||
|
|
||||||
function openBluetoothAdapter() {
|
function openBluetoothAdapter() {
|
||||||
|
devicesList = []
|
||||||
let Language = $store.state.setLocale
|
let Language = $store.state.setLocale
|
||||||
let $t = messages[Language]
|
let $t = messages[Language]
|
||||||
|
clearTimeout(searchTimer);
|
||||||
uni.openBluetoothAdapter({
|
uni.openBluetoothAdapter({
|
||||||
success: e => {
|
success: e => {
|
||||||
$store.commit("changeBluetoothValue", {
|
$store.commit("changeBluetoothValue", {
|
||||||
|
|
@ -60,6 +62,9 @@ function onBluetoothDeviceFound() {
|
||||||
uni.onBluetoothDeviceFound(res => {
|
uni.onBluetoothDeviceFound(res => {
|
||||||
res.devices.forEach(device => {
|
res.devices.forEach(device => {
|
||||||
console.log("name", device.name)
|
console.log("name", device.name)
|
||||||
|
if (!device.name && !device.localName) {
|
||||||
|
return
|
||||||
|
}
|
||||||
if (device.name.toLowerCase().indexOf('pc-c06pro') != -1 ||
|
if (device.name.toLowerCase().indexOf('pc-c06pro') != -1 ||
|
||||||
device.name.toLowerCase().indexOf('pc-c02pro') != -1 ||
|
device.name.toLowerCase().indexOf('pc-c02pro') != -1 ||
|
||||||
device.name.toLowerCase().indexOf('pc-c09pro') != -1 ||
|
device.name.toLowerCase().indexOf('pc-c09pro') != -1 ||
|
||||||
|
|
@ -81,7 +86,6 @@ function onBluetoothDeviceFound() {
|
||||||
function Bluetoothfilter(device) {
|
function Bluetoothfilter(device) {
|
||||||
const foundDevices = devicesList
|
const foundDevices = devicesList
|
||||||
const idx = inArray(foundDevices, "deviceId", device.deviceId)
|
const idx = inArray(foundDevices, "deviceId", device.deviceId)
|
||||||
// console.log("2222222222", idx, device, )
|
|
||||||
if (idx === -1) {
|
if (idx === -1) {
|
||||||
devicesList.push(device);
|
devicesList.push(device);
|
||||||
handleDevType(device)
|
handleDevType(device)
|
||||||
|
|
@ -89,7 +93,6 @@ function Bluetoothfilter(device) {
|
||||||
}
|
}
|
||||||
// 排查设备
|
// 排查设备
|
||||||
function handleDevType(device) {
|
function handleDevType(device) {
|
||||||
// console.log("4444", device)
|
|
||||||
let Language = $store.state.setLocale
|
let Language = $store.state.setLocale
|
||||||
let $t = messages[Language]
|
let $t = messages[Language]
|
||||||
$model.getCheckDevice({
|
$model.getCheckDevice({
|
||||||
|
|
@ -353,7 +356,6 @@ function stopBluetoothDevicesDiscovery() {
|
||||||
export default {
|
export default {
|
||||||
ab2hex,
|
ab2hex,
|
||||||
inArray,
|
inArray,
|
||||||
handleDevType,
|
|
||||||
openBluetoothAdapter,
|
openBluetoothAdapter,
|
||||||
startBluetoothDeviceDiscovery,
|
startBluetoothDeviceDiscovery,
|
||||||
onBluetoothDeviceFound,
|
onBluetoothDeviceFound,
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -29013,8 +29013,10 @@ var devicesList = [];
|
||||||
// 初始化蓝牙
|
// 初始化蓝牙
|
||||||
|
|
||||||
function openBluetoothAdapter() {
|
function openBluetoothAdapter() {
|
||||||
|
devicesList = [];
|
||||||
var Language = _store.default.state.setLocale;
|
var Language = _store.default.state.setLocale;
|
||||||
var $t = _index.default[Language];
|
var $t = _index.default[Language];
|
||||||
|
clearTimeout(searchTimer);
|
||||||
uni.openBluetoothAdapter({
|
uni.openBluetoothAdapter({
|
||||||
success: function success(e) {
|
success: function success(e) {
|
||||||
_store.default.commit("changeBluetoothValue", {
|
_store.default.commit("changeBluetoothValue", {
|
||||||
|
|
@ -29067,6 +29069,9 @@ function onBluetoothDeviceFound() {
|
||||||
uni.onBluetoothDeviceFound(function (res) {
|
uni.onBluetoothDeviceFound(function (res) {
|
||||||
res.devices.forEach(function (device) {
|
res.devices.forEach(function (device) {
|
||||||
console.log("name", device.name);
|
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) {
|
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);
|
clearTimeout(searchTimer);
|
||||||
var bytes = new Uint8Array(device.advertisData);
|
var bytes = new Uint8Array(device.advertisData);
|
||||||
|
|
@ -29083,7 +29088,6 @@ function onBluetoothDeviceFound() {
|
||||||
function Bluetoothfilter(device) {
|
function Bluetoothfilter(device) {
|
||||||
var foundDevices = devicesList;
|
var foundDevices = devicesList;
|
||||||
var idx = inArray(foundDevices, "deviceId", device.deviceId);
|
var idx = inArray(foundDevices, "deviceId", device.deviceId);
|
||||||
// console.log("2222222222", idx, device, )
|
|
||||||
if (idx === -1) {
|
if (idx === -1) {
|
||||||
devicesList.push(device);
|
devicesList.push(device);
|
||||||
handleDevType(device);
|
handleDevType(device);
|
||||||
|
|
@ -29091,7 +29095,6 @@ function Bluetoothfilter(device) {
|
||||||
}
|
}
|
||||||
// 排查设备
|
// 排查设备
|
||||||
function handleDevType(device) {
|
function handleDevType(device) {
|
||||||
// console.log("4444", device)
|
|
||||||
var Language = _store.default.state.setLocale;
|
var Language = _store.default.state.setLocale;
|
||||||
var $t = _index.default[Language];
|
var $t = _index.default[Language];
|
||||||
_model.default.getCheckDevice({
|
_model.default.getCheckDevice({
|
||||||
|
|
@ -29342,7 +29345,6 @@ function stopBluetoothDevicesDiscovery() {
|
||||||
var _default = {
|
var _default = {
|
||||||
ab2hex: ab2hex,
|
ab2hex: ab2hex,
|
||||||
inArray: inArray,
|
inArray: inArray,
|
||||||
handleDevType: handleDevType,
|
|
||||||
openBluetoothAdapter: openBluetoothAdapter,
|
openBluetoothAdapter: openBluetoothAdapter,
|
||||||
startBluetoothDeviceDiscovery: startBluetoothDeviceDiscovery,
|
startBluetoothDeviceDiscovery: startBluetoothDeviceDiscovery,
|
||||||
onBluetoothDeviceFound: onBluetoothDeviceFound,
|
onBluetoothDeviceFound: onBluetoothDeviceFound,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue