Browse Source

修改会议助手ble获取Wi-Fi

newdev_shunjiawei
tanlongsheng 1 year ago
parent
commit
ba63b7e5a6
  1. 28
      lib/modules/meeting/controllers/meeting_connect_controller.dart
  2. 5
      lib/modules/meeting/views/meeting_connect_view.dart

28
lib/modules/meeting/controllers/meeting_connect_controller.dart

@ -18,6 +18,9 @@ class MeetingConnectController extends GetxController {
late BluetoothCharacteristic? _writeCharacteristic;
late StreamSubscription<List<int>>? _valueReceivedSubscription;
String _wifiSSID = '';
String _wifiPassword = '';
@override
void onInit() {
super.onInit();
@ -135,9 +138,32 @@ class MeetingConnectController extends GetxController {
}
break;
case 0x87: // Wi-Fi 开启/关闭
if (value[2] == 0x01) {}
if (value[3] == 0x01 && value[4] == 0x01) {
sendData([0x5a, 0x01, 0x0b]);
sendData([0x5a, 0x01, 0x0c]);
}
break;
case 0x0b: // WiFi 热点 SSID
_wifiSSID = String.fromCharCodes(value.sublist(3, value.length - 2));
if (_wifiSSID.isNotEmpty && _wifiPassword.isNotEmpty) {
_connectWifi();
}
break;
case 0x0c: // WiFi 热点密码
_wifiPassword = _decodePassword(value);
if (_wifiSSID.isNotEmpty && _wifiPassword.isNotEmpty) {
_connectWifi();
}
break;
default:
}
}
void _connectWifi() {}
String _decodePassword(List<int> data) {
final passwordData = data.sublist(3, data.length - 2);
final decodedBytes = passwordData.map((byte) => byte ^ 0xFF).toList();
return String.fromCharCodes(decodedBytes);
}
}

5
lib/modules/meeting/views/meeting_connect_view.dart

@ -81,7 +81,10 @@ class MeetingConnectView extends GetView<MeetingConnectController> {
? Padding(
padding: EdgeInsets.symmetric(vertical: 10.w),
child: _button('导入文件', Icons.file_download, onTap: () {
controller.sendData([0x5a, 0x01, 0x0d]);
controller.stateStr.value = '正在开启Wi-Fi...';
controller.importedFilesStr.value = '';
controller.isImportedFiles.value = false;
controller.sendData([0x5a, 0x02, 0x87, 0x01]);
}),
)
: const SizedBox(),

Loading…
Cancel
Save