更新ios蓝牙权限
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:EasyDartModule/EasyDartModule.dart' as edm;
|
||||
import 'package:easydevice/easydevice.dart';
|
||||
@@ -17,6 +18,7 @@ import 'package:vbvs_app/controller/user_info_controller.dart';
|
||||
import 'package:vbvs_app/model/WebSocketMessage.dart';
|
||||
import 'package:vbvs_app/pages/main_bottom/component/main_page_b_bottom_change.dart';
|
||||
import 'package:vbvs_app/pages/mh_page/device/controller/mht_bluetooth_controller.dart';
|
||||
import 'package:vbvs_app/pages/mh_page/device/mht_blueteeth_device_page.dart';
|
||||
import 'package:vbvs_app/pages/mh_page/homepage/component/HomeDeviceStausWidget.dart';
|
||||
import 'package:vbvs_app/pages/mh_page/homepage/controller/mht_home_controller.dart';
|
||||
|
||||
@@ -68,16 +70,60 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
|
||||
final devices = args1.devices as Map<String, dynamic>;
|
||||
final mac = args2 as String;
|
||||
|
||||
// 找出对应设备
|
||||
final device = devices[mac];
|
||||
|
||||
if (device != null) {
|
||||
ef.log('Minibleapp connected: $mac -> $device');
|
||||
// Android: key 就是 mac,直接找
|
||||
if (devices.containsKey(mac)) {
|
||||
final device = devices[mac];
|
||||
ef.log('Minibleapp connected(Android): $mac -> $device');
|
||||
return device;
|
||||
} else {
|
||||
ef.log('Minibleapp connected: $mac not found in devices');
|
||||
return null;
|
||||
}
|
||||
|
||||
// iOS: 遍历所有设备,解析 manufacturerData 拿真实 deviceId(mac)
|
||||
for (final entry in devices.entries) {
|
||||
final manufacturerData = entry.value.manufacturerData;
|
||||
String? deviceId;
|
||||
|
||||
if (manufacturerData != null) {
|
||||
manufacturerData.forEach((key, data) {
|
||||
if (data.isEmpty) return;
|
||||
|
||||
if (key == 65517) {
|
||||
List<int> a = [0, 0, ...data];
|
||||
final d = {};
|
||||
advertisDataFormatter(a, d);
|
||||
if (d['adData']?['deviceId'] != null) {
|
||||
deviceId = d['adData']['deviceId'];
|
||||
}
|
||||
} else if (key == 11125 && data.length == 8) {
|
||||
deviceId = ab2str(data.sublist(2, 8)).toUpperCase();
|
||||
} else if (data.length == 8 &&
|
||||
isQuanShiDevice(entry.value.name)) {
|
||||
deviceId = ab2str(data.sublist(2, 8)).toUpperCase();
|
||||
} else if ((data.length == 4 || data.length == 6) &&
|
||||
isMHTSWES(entry.value.name)) {
|
||||
List<int> a;
|
||||
if (data.length == 4) {
|
||||
ByteData bd = ByteData(2);
|
||||
bd.setUint16(0, key, Endian.little);
|
||||
a = [bd.getUint8(0), bd.getUint8(1), ...data];
|
||||
} else {
|
||||
a = [...data];
|
||||
}
|
||||
deviceId = ab2str(a).toUpperCase();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
final normalizedMac = mac.replaceAll(":", "").toUpperCase();
|
||||
|
||||
if (deviceId != null &&
|
||||
deviceId!.toUpperCase() == normalizedMac) {
|
||||
return entry.value; // 返回匹配的设备
|
||||
}
|
||||
}
|
||||
|
||||
ef.log('Minibleapp connected: $mac not found in devices');
|
||||
return null;
|
||||
},
|
||||
);
|
||||
// ef.kvroot.devicelist.listen((x) {});
|
||||
|
||||
Reference in New Issue
Block a user