fix: 增加网关配网时的参数
This commit is contained in:
parent
2bfbac52fa
commit
ae176ffb6c
@ -22,17 +22,16 @@ class GatewayConfigurationWifiLogic extends BaseGetXController {
|
||||
final GatewayConfigurationWifiState state = GatewayConfigurationWifiState();
|
||||
|
||||
Future<void> gatewayDistributionNetwork() async {
|
||||
final LoginEntity entity = await ApiRepository.to
|
||||
.gatewayDistributionNetwork(
|
||||
gatewayName: state.gatewayNameTF.text,
|
||||
gatewayMac: state.gatewayModel.mac,
|
||||
serialNumber: state.gatewayModel.serialNum,
|
||||
gatewayType: 2,
|
||||
networkName: state.wifiNameTF.text,
|
||||
networkMac: state.gatewayModel.wifiMac,
|
||||
version: state.gatewayModel.gatewayVersion,
|
||||
gatewayJson: jsonDecode(state.gatewayJson),
|
||||
timeout: 60);
|
||||
final LoginEntity entity = await ApiRepository.to.gatewayDistributionNetwork(
|
||||
gatewayName: state.gatewayNameTF.text,
|
||||
gatewayMac: state.gatewayModel.mac,
|
||||
serialNumber: state.gatewayModel.serialNum,
|
||||
gatewayType: 2,
|
||||
networkName: state.wifiNameTF.text,
|
||||
networkMac: state.gatewayModel.wifiMac,
|
||||
version: state.gatewayModel.gatewayVersion,
|
||||
gatewayJson: jsonDecode(state.gatewayJson),
|
||||
timeout: 60);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast('网关添加成功'.tr, something: () {
|
||||
// eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
|
||||
@ -42,8 +41,7 @@ class GatewayConfigurationWifiLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
Future<void> getGatewayConfiguration() async {
|
||||
final GetGatewayConfigurationEntity entity =
|
||||
await ApiRepository.to.getGatewayConfiguration(timeout: 60);
|
||||
final GetGatewayConfigurationEntity entity = await ApiRepository.to.getGatewayConfiguration(timeout: 60);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
String configStr = entity.data ?? '';
|
||||
|
||||
@ -52,6 +50,7 @@ class GatewayConfigurationWifiLogic extends BaseGetXController {
|
||||
try {
|
||||
Map<String, dynamic> config = jsonDecode(configStr);
|
||||
config['timeZoneOffset'] = DateTime.now().timeZoneOffset.inSeconds;
|
||||
AppLog.log('state.config:$config');
|
||||
state.getGatewayConfigurationStr = jsonEncode(config);
|
||||
} catch (e) {
|
||||
AppLog.log('处理网关配置时区信息失败: $e');
|
||||
@ -68,9 +67,9 @@ class GatewayConfigurationWifiLogic extends BaseGetXController {
|
||||
|
||||
// 监听设备返回的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
|
||||
void _initReplySubscription() {
|
||||
_replySubscription =
|
||||
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
|
||||
// WIFI配网
|
||||
// if(reply is GatewayConfiguringWifiReply) {
|
||||
// _replySenderConfiguringWifi(reply);
|
||||
@ -112,8 +111,7 @@ class GatewayConfigurationWifiLogic extends BaseGetXController {
|
||||
cancelBlueConnetctToastTimer();
|
||||
dismissEasyLoading();
|
||||
final int secretKeyJsonLength = (reply.data[3] << 8) + reply.data[4];
|
||||
final List<int> secretKeyList =
|
||||
reply.data.sublist(5, 5 + secretKeyJsonLength);
|
||||
final List<int> secretKeyList = reply.data.sublist(5, 5 + secretKeyJsonLength);
|
||||
state.gatewayJson = utf8String(secretKeyList);
|
||||
|
||||
gatewayDistributionNetwork();
|
||||
@ -129,8 +127,7 @@ class GatewayConfigurationWifiLogic extends BaseGetXController {
|
||||
|
||||
// 点击配置wifi
|
||||
Future<void> senderConfiguringWifiAction() async {
|
||||
AppLog.log(
|
||||
'state.getGatewayConfigurationStr:${state.getGatewayConfigurationStr}');
|
||||
AppLog.log('state.getGatewayConfigurationStr:${state.getGatewayConfigurationStr}');
|
||||
if (state.wifiNameTF.text.isEmpty) {
|
||||
showToast('请输入wifi名称'.tr);
|
||||
return;
|
||||
@ -158,8 +155,7 @@ class GatewayConfigurationWifiLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
IoSenderManage.gatewayConfiguringWifiCommand(
|
||||
ssid: state.wifiNameTF.text,
|
||||
@ -178,6 +174,7 @@ class GatewayConfigurationWifiLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
final NetworkInfo _networkInfo = NetworkInfo();
|
||||
|
||||
Future<String> getWifiName() async {
|
||||
String ssid = '';
|
||||
ssid = (await _networkInfo.getWifiName())!;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user