diff --git a/lib/modules/meeting/controllers/meeting_connect_controller.dart b/lib/modules/meeting/controllers/meeting_connect_controller.dart index 34fedb289..f6d16e214 100644 --- a/lib/modules/meeting/controllers/meeting_connect_controller.dart +++ b/lib/modules/meeting/controllers/meeting_connect_controller.dart @@ -18,6 +18,9 @@ class MeetingConnectController extends GetxController { late BluetoothCharacteristic? _writeCharacteristic; late StreamSubscription>? _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 data) { + final passwordData = data.sublist(3, data.length - 2); + final decodedBytes = passwordData.map((byte) => byte ^ 0xFF).toList(); + return String.fromCharCodes(decodedBytes); + } } diff --git a/lib/modules/meeting/views/meeting_connect_view.dart b/lib/modules/meeting/views/meeting_connect_view.dart index 66dd589c6..e8e86fad4 100644 --- a/lib/modules/meeting/views/meeting_connect_view.dart +++ b/lib/modules/meeting/views/meeting_connect_view.dart @@ -81,7 +81,10 @@ class MeetingConnectView extends GetView { ? 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(),