多语言
This commit is contained in:
@@ -47,7 +47,7 @@ class _DeviceComponentWidgetState extends State<DeviceComponentWidget> {
|
||||
Widget build(BuildContext context) {
|
||||
Map device = {
|
||||
"name": widget.bleDevice.name,
|
||||
"mac": widget.bleDevice.mac,
|
||||
"mac".tr: widget.bleDevice.mac,
|
||||
"rssi": widget.bleDevice.scanResult.rssi,
|
||||
"bind": widget.bleDevice.bind,
|
||||
};
|
||||
@@ -74,7 +74,7 @@ class _DeviceComponentWidgetState extends State<DeviceComponentWidget> {
|
||||
),
|
||||
Obx(() {
|
||||
if (blueteethBindController.currentDeviceMac.value ==
|
||||
device['mac']) {
|
||||
device['mac'.tr]) {
|
||||
return SizedBox(
|
||||
width: 24.rpx,
|
||||
height: 24.rpx,
|
||||
@@ -185,7 +185,7 @@ class _DeviceComponentWidgetState extends State<DeviceComponentWidget> {
|
||||
blueteethBindController
|
||||
.currentDeviceMac!.value.isNotEmpty) {
|
||||
if (blueteethBindController.currentDeviceMac?.value !=
|
||||
device['mac']) {
|
||||
device['mac'.tr]) {
|
||||
showConfirmDialog(
|
||||
context, Container(), "其他设备正在绑定中,是否终止其他设备绑定?".tr,
|
||||
onConfirm: () {
|
||||
@@ -198,7 +198,7 @@ class _DeviceComponentWidgetState extends State<DeviceComponentWidget> {
|
||||
}
|
||||
|
||||
blueteethBindController.currentDeviceMac?.value =
|
||||
device['mac']!;
|
||||
device['mac'.tr]!;
|
||||
blueteethBindController.updateAll();
|
||||
|
||||
if (device['bind'] == true) {
|
||||
@@ -294,7 +294,7 @@ class _DeviceComponentWidgetState extends State<DeviceComponentWidget> {
|
||||
blueteethBindController.resumeScanning();
|
||||
},
|
||||
onCancel: () {
|
||||
print('用户点击了取消');
|
||||
print('用户点击了取消'.tr);
|
||||
blueteethBindController.currentDeviceMac.value = "";
|
||||
blueteethBindController.resumeScanning();
|
||||
blueteethBindController.updateAll();
|
||||
@@ -347,14 +347,14 @@ class _DeviceComponentWidgetState extends State<DeviceComponentWidget> {
|
||||
String queryUrl = "${serviceAddress}${serviceName}${serviceApi}";
|
||||
Map<String, dynamic> data = {
|
||||
"type": type,
|
||||
"mac": mac,
|
||||
"mac".tr: mac,
|
||||
"wifi": false,
|
||||
"celibration": false,
|
||||
"person_info": false,
|
||||
"time": DateTime.now().millisecondsSinceEpoch,
|
||||
};
|
||||
requestWithLog(
|
||||
logTitle: "更新用户绑定流程",
|
||||
logTitle: "更新用户绑定流程".tr,
|
||||
method: MyHttpMethod.put,
|
||||
queryUrl: queryUrl,
|
||||
data: data,
|
||||
@@ -505,14 +505,14 @@ class _DeviceComponentWidgetState extends State<DeviceComponentWidget> {
|
||||
await bledevice.connect();
|
||||
var res2 = bledevice.isConnected;
|
||||
if (!res2) {
|
||||
edm.EasyDartModule.logger.error("蓝牙连接失败");
|
||||
DailyLogUtils.printLog("蓝牙连接失败");
|
||||
edm.EasyDartModule.logger.error("蓝牙连接失败".tr);
|
||||
DailyLogUtils.printLog("蓝牙连接失败".tr);
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "蓝牙连接失败".tr,
|
||||
textColor: themeController.currentColor.sc9,
|
||||
);
|
||||
throw Exception("蓝牙连接失败");
|
||||
throw Exception("蓝牙连接失败".tr);
|
||||
}
|
||||
blueteethBindController.blueConnectFlag.value = 2;
|
||||
blueteethBindController.currentDevice = bledevice;
|
||||
@@ -525,11 +525,11 @@ class _DeviceComponentWidgetState extends State<DeviceComponentWidget> {
|
||||
//智能床
|
||||
macAddress = await getMacFromType2(bledevice, timeout);
|
||||
} else {
|
||||
throw Exception("不支持的设备类型");
|
||||
throw Exception("不支持的设备类型".tr);
|
||||
}
|
||||
|
||||
if (macAddress == null) {
|
||||
throw Exception("未能获取到MAC地址");
|
||||
throw Exception("未能获取到MAC地址".tr);
|
||||
}
|
||||
|
||||
// device.macA = macAddress;
|
||||
@@ -565,7 +565,7 @@ class _DeviceComponentWidgetState extends State<DeviceComponentWidget> {
|
||||
}
|
||||
|
||||
await requestWithLog(
|
||||
logTitle: "获取设备状态",
|
||||
logTitle: "获取设备状态".tr,
|
||||
method: MyHttpMethod.get,
|
||||
queryUrl: queryUrl,
|
||||
onSuccess: (res) {
|
||||
@@ -578,11 +578,11 @@ class _DeviceComponentWidgetState extends State<DeviceComponentWidget> {
|
||||
// 查找当前MAC对应的数据
|
||||
String macKey = mac.replaceAll(':', '').toUpperCase();
|
||||
for (var item in responseList) {
|
||||
if (item['mac'].toString().toUpperCase() == macKey) {
|
||||
if (item['mac'.tr].toString().toUpperCase() == macKey) {
|
||||
// 更新 bleDevice 的状态
|
||||
//如果传感器已经绑定 暂时不处理
|
||||
// bleDevice.bind = item['bind'] ?? bleDevice.bind;
|
||||
bleDevice.macA = item['mac'];
|
||||
bleDevice.macA = item['mac'.tr];
|
||||
if (item['bindMac'] != null &&
|
||||
item['bindMac'].toString().isNotEmpty) {
|
||||
bleDevice.macB = item['bindMac'];
|
||||
@@ -634,10 +634,10 @@ class _DeviceComponentWidgetState extends State<DeviceComponentWidget> {
|
||||
try {
|
||||
final mac = await completer.future.timeout(timeout);
|
||||
if (mac == null || mac.isEmpty) {
|
||||
throw Exception("获取MAC失败");
|
||||
throw Exception("获取MAC失败".tr);
|
||||
}
|
||||
if (mac == "000000000000") {
|
||||
throw Exception("获取MAC失败");
|
||||
throw Exception("获取MAC失败".tr);
|
||||
}
|
||||
await subscription.cancel();
|
||||
return mac;
|
||||
@@ -646,7 +646,7 @@ class _DeviceComponentWidgetState extends State<DeviceComponentWidget> {
|
||||
if (attempt == maxRetries - 1) rethrow;
|
||||
}
|
||||
}
|
||||
throw Exception("获取MAC超时");
|
||||
throw Exception("获取MAC超时".tr);
|
||||
}
|
||||
|
||||
Future<String> getMacFromType2(THapp bledevice, Duration timeout) async {
|
||||
@@ -685,7 +685,7 @@ class _DeviceComponentWidgetState extends State<DeviceComponentWidget> {
|
||||
ef.log("[获取设备 MAC]:失败:$e");
|
||||
}
|
||||
|
||||
throw Exception("获取MAC超时");
|
||||
throw Exception("获取MAC超时".tr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -705,18 +705,18 @@ String parseMacFromBleResponse(List<int> data) {
|
||||
.join('');
|
||||
return macAddress;
|
||||
} else {
|
||||
throw Exception("BLE返回数据格式不正确");
|
||||
throw Exception("BLE返回数据格式不正确".tr);
|
||||
}
|
||||
}
|
||||
|
||||
String parseMacFromTH2Response(List<int> data) {
|
||||
if (data.length < 17) {
|
||||
throw Exception("数据长度不足,无法解析MAC");
|
||||
throw Exception("数据长度不足,无法解析MAC".tr);
|
||||
}
|
||||
|
||||
int status = data[8];
|
||||
if (status != 0x03 && status != 0x04) {
|
||||
throw Exception("未连接心率带");
|
||||
throw Exception("未连接心率带".tr);
|
||||
}
|
||||
|
||||
// 提取9~14字节的MAC地址
|
||||
|
||||
Reference in New Issue
Block a user