1、添加获取网关状态协议及逻辑

2、添加更新网关信息功能
This commit is contained in:
魏少阳 2024-10-07 14:17:46 +08:00
parent d947ffeeb2
commit c3d9667458
20 changed files with 354 additions and 106 deletions

View File

@ -6,8 +6,8 @@ import '../io_reply.dart';
import '../io_sender.dart'; import '../io_sender.dart';
import '../io_tool/io_tool.dart'; import '../io_tool/io_tool.dart';
import '../io_type.dart'; import '../io_type.dart';
import '../sm4Encipher/sm4.dart'; // import '../sm4Encipher/sm4.dart';
import 'package:crypto/crypto.dart' as crypto; // import 'package:crypto/crypto.dart' as crypto;
class GatewayConfiguringWifiCommand extends SenderProtocol { class GatewayConfiguringWifiCommand extends SenderProtocol {
@ -51,13 +51,6 @@ class GatewayConfiguringWifiCommand extends SenderProtocol {
data.add(subData.length); data.add(subData.length);
data.addAll(subData); data.addAll(subData);
// if ((data.length % 16) != 0) {
// final int add = 16 - data.length % 16;
// for (int i = 0; i < add; i++) {
// data.add(0);
// }
// }
printLog(data); printLog(data);
return data; return data;
} }

View File

@ -0,0 +1,65 @@
//
import 'dart:convert';
import '../io_reply.dart';
import '../io_sender.dart';
import '../io_tool/io_tool.dart';
import '../io_type.dart';
// import '../sm4Encipher/sm4.dart';
// import 'package:crypto/crypto.dart' as crypto;
class GatewayGetStatusCommand extends SenderProtocol {
GatewayGetStatusCommand({
this.lockID,
this.userID,
}) : super(CommandType.gatewayGetStatus);
String? lockID;
String? userID;
@override
String toString() {
return 'GatewayGetStatusCommand{lockID: $lockID, userID: $userID}';
}
@override
List<int> messageDetail() {
final List<int> data = <int>[];
List<int> subData = <int>[];
//
final int type = commandType!.typeValue;
final double typeDouble = type / 256;
final int type1 = typeDouble.toInt();
final int type2 = type % 256;
data.add(type1);
data.add(type2);
//lockID 40
final int ssidLength = utf8.encode(lockID!).length;
subData.addAll(utf8.encode(lockID!));
subData = getFixedLengthList(subData, 40 - ssidLength);
//userID 20
final int passwordLength = utf8.encode(userID!).length;
subData.addAll(utf8.encode(userID!));
subData = getFixedLengthList(subData, 20 - passwordLength);
data.add(subData.length);
data.addAll(subData);
printLog(data);
return data;
}
}
class GatewayGetStatusReply extends Reply {
GatewayGetStatusReply.parseData(CommandType commandType, List<int> dataDetail)
: super.parseData(commandType, dataDetail) {
data = dataDetail;
final int status = data[2];
errorWithStstus(status);
}
}

View File

@ -1,14 +1,14 @@
import 'dart:convert'; import 'dart:convert';
import 'package:crypto/crypto.dart' as crypto; // import 'package:crypto/crypto.dart' as crypto;
import '../../app_settings/app_settings.dart'; import '../../app_settings/app_settings.dart';
import '../io_reply.dart'; import '../io_reply.dart';
import '../io_sender.dart'; import '../io_sender.dart';
import '../io_tool/io_tool.dart'; import '../io_tool/io_tool.dart';
import '../io_type.dart'; import '../io_type.dart';
import '../sm4Encipher/sm4.dart'; // import '../sm4Encipher/sm4.dart';
class GatewayGetWifiCommand extends SenderProtocol { class GatewayGetWifiCommand extends SenderProtocol {
@ -47,13 +47,6 @@ class GatewayGetWifiCommand extends SenderProtocol {
data.add(subData.length); data.add(subData.length);
data.addAll(subData); data.addAll(subData);
// if ((data.length % 16) != 0) {
// final int add = 16 - data.length % 16;
// for (int i = 0; i < add; i++) {
// data.add(0);
// }
// }
printLog(data); printLog(data);
return data; return data;
} }

View File

@ -24,6 +24,7 @@ enum CommandType {
startOATUpgrade, //OTA升级开始 0x30E0 startOATUpgrade, //OTA升级开始 0x30E0
confirmationOTAUpgrade, //OTA升级开始 0x30E2 confirmationOTAUpgrade, //OTA升级开始 0x30E2
processOTAUpgrade, //OTA升级过程 0x30E1 processOTAUpgrade, //OTA升级过程 0x30E1
gatewayGetStatus,// 0x30F8
gatewayConfiguringWifi,// 0x30F4 gatewayConfiguringWifi,// 0x30F4
gatewayConfiguringWifiResult,// 0x30F5 gatewayConfiguringWifiResult,// 0x30F5
gatewayGetWifiList,//wifi列表 0x30F6 gatewayGetWifiList,//wifi列表 0x30F6
@ -205,6 +206,11 @@ extension ExtensionCommandType on CommandType {
type = CommandType.gatewayGetWifiListResult; type = CommandType.gatewayGetWifiListResult;
} }
break; break;
case 0x30F8:
{
type = CommandType.gatewayGetStatus;
}
break;
default: default:
{ {
type = CommandType.readLockStatusInfo; type = CommandType.readLockStatusInfo;
@ -304,6 +310,9 @@ extension ExtensionCommandType on CommandType {
case CommandType.gatewayGetWifiListResult: case CommandType.gatewayGetWifiListResult:
type = 0x30F7; type = 0x30F7;
break; break;
case CommandType.gatewayGetStatus:
type = 0x30F8;
break;
default: default:
type = 0x300A; type = 0x300A;
break; break;
@ -321,6 +330,7 @@ extension ExtensionCommandType on CommandType {
case CommandType.processOTAUpgrade: case CommandType.processOTAUpgrade:
case CommandType.gatewayGetWifiList: case CommandType.gatewayGetWifiList:
case CommandType.gatewayConfiguringWifi: case CommandType.gatewayConfiguringWifi:
case CommandType.gatewayGetStatus:
// //
type = 0x20; type = 0x20;
break; break;
@ -436,6 +446,9 @@ extension ExtensionCommandType on CommandType {
case 0x30F7: case 0x30F7:
t = '网关获取附近的wifi列表结果'; t = '网关获取附近的wifi列表结果';
break; break;
case 0x30F8:
t = '获取网关状态';
break;
default: default:
t = '读星锁状态信息'; t = '读星锁状态信息';
break; break;

View File

@ -33,6 +33,7 @@ import 'io_protocol/io_addUser.dart';
import 'io_protocol/io_checkingCardStatus.dart'; import 'io_protocol/io_checkingCardStatus.dart';
import 'io_protocol/io_checkingUserInfoCount.dart'; import 'io_protocol/io_checkingUserInfoCount.dart';
import 'io_protocol/io_configuringWifi.dart'; import 'io_protocol/io_configuringWifi.dart';
import 'io_protocol/io_gateway_getStatus.dart';
import 'io_protocol/io_getPrivateKey.dart'; import 'io_protocol/io_getPrivateKey.dart';
import 'io_protocol/io_getPublicKey.dart'; import 'io_protocol/io_getPublicKey.dart';
import 'io_protocol/io_getStarLockStatusInfo.dart'; import 'io_protocol/io_getStarLockStatusInfo.dart';
@ -272,6 +273,11 @@ class CommandReciverManager {
reply = GatewayGetWifiListReply.parseData(commandType, data); reply = GatewayGetWifiListReply.parseData(commandType, data);
} }
break; break;
case CommandType.gatewayGetStatus:
{
reply = GatewayGetStatusReply.parseData(commandType, data);
}
break;
case CommandType.generalExtendedCommond: case CommandType.generalExtendedCommond:
{ {
// //

View File

@ -26,6 +26,7 @@ import 'io_protocol/io_configuringWifi.dart';
import 'io_protocol/io_editUser.dart'; import 'io_protocol/io_editUser.dart';
import 'io_protocol/io_factoryDataReset.dart'; import 'io_protocol/io_factoryDataReset.dart';
import 'io_protocol/io_gateway_configuringWifi.dart'; import 'io_protocol/io_gateway_configuringWifi.dart';
import 'io_protocol/io_gateway_getStatus.dart';
import 'io_protocol/io_getPrivateKey.dart'; import 'io_protocol/io_getPrivateKey.dart';
import 'io_protocol/io_getPublicKey.dart'; import 'io_protocol/io_getPublicKey.dart';
import 'io_protocol/io_getStarLockStatusInfo.dart'; import 'io_protocol/io_getStarLockStatusInfo.dart';
@ -52,7 +53,7 @@ import 'io_protocol/io_updataLockSet.dart';
import 'sender_data.dart'; import 'sender_data.dart';
class IoSenderManage { class IoSenderManage {
//todo: //
static void getPublicKey({String? lockId, CommandSendCallBack? callBack}) { static void getPublicKey({String? lockId, CommandSendCallBack? callBack}) {
CommandSenderManager().managerSendData( CommandSenderManager().managerSendData(
command: GetPublicKeyCommand( command: GetPublicKeyCommand(
@ -62,7 +63,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo: //
static void getPrivateKey( static void getPrivateKey(
{String? lockId, {String? lockId,
String? keyID, // ID String? keyID, // ID
@ -84,7 +85,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo: //
static void senderAddUser( static void senderAddUser(
{String? lockID, {String? lockID,
String? authUserID, String? authUserID,
@ -136,7 +137,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo: //
static void senderEditUser( static void senderEditUser(
{String? lockID, {String? lockID,
String? authUserID, String? authUserID,
@ -172,7 +173,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo: //
static void deletUser( static void deletUser(
{String? lockID, {String? lockID,
String? authUserID, String? authUserID,
@ -196,7 +197,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo: //
static void senderOpenLock( static void senderOpenLock(
{String? lockID, {String? lockID,
String? userID, String? userID,
@ -223,7 +224,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo: //
// static void senderGetLockStatu( // static void senderGetLockStatu(
// {String? lockID, // {String? lockID,
// String? userID, // String? userID,
@ -238,7 +239,7 @@ class IoSenderManage {
// callBack: callBack); // callBack: callBack);
// } // }
//todo: //
static void senderGetStarLockStatuInfo( static void senderGetStarLockStatuInfo(
{required String? lockID, {required String? lockID,
required String? userID, required String? userID,
@ -259,7 +260,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo: //
static void senderTransferPermissions( static void senderTransferPermissions(
{required String? lockID, {required String? lockID,
required String? authUserID, required String? authUserID,
@ -285,7 +286,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo: //
static void sendTransferSmartLockCommand( static void sendTransferSmartLockCommand(
{required String? lockID, {required String? lockID,
required String? userID, required String? userID,
@ -307,7 +308,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo: //
static void senderFactoryDataReset( static void senderFactoryDataReset(
{required String? lockID, {required String? lockID,
required String? userID, required String? userID,
@ -329,7 +330,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo: //
static void senderCustomPasswordsCommand( static void senderCustomPasswordsCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
@ -366,7 +367,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo: //
static void changeAdministratorPasswordCommand( static void changeAdministratorPasswordCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
@ -399,7 +400,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo: //
static void senderResetPasswordsCommand( static void senderResetPasswordsCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
@ -422,7 +423,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo: //
// static void senderAddFingerprintCommand( // static void senderAddFingerprintCommand(
// {required String? keyID, // {required String? keyID,
// required String? userID, // required String? userID,
@ -451,7 +452,7 @@ class IoSenderManage {
// callBack: callBack); // callBack: callBack);
// } // }
//todo:(...) // (...)
static void senderAddFingerprintWithTimeCycleCoercionCommand( static void senderAddFingerprintWithTimeCycleCoercionCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
@ -496,7 +497,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo: //
static void senderCancelAddFingerprintCommand( static void senderCancelAddFingerprintCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
@ -517,7 +518,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo: //
// static void senderAddICCardCommand( // static void senderAddICCardCommand(
// {required String? keyID, // {required String? keyID,
// required String? userID, // required String? userID,
@ -546,7 +547,7 @@ class IoSenderManage {
// callBack: callBack); // callBack: callBack);
// } // }
//todo:(...) // (...)
static void senderAddCardWithTimeCycleCoercionCommand( static void senderAddCardWithTimeCycleCoercionCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
@ -591,7 +592,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo: //
static void senderCancelAddCardCommand( static void senderCancelAddCardCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
@ -612,7 +613,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo:(...) // (...)
static void senderAddRemoteControlWithTimeCycleCoercionCommand( static void senderAddRemoteControlWithTimeCycleCoercionCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
@ -657,7 +658,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo: //
static void senderCancelAddRemoteControlCommand( static void senderCancelAddRemoteControlCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
@ -678,7 +679,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo: //
static void senderAddFaceCommand( static void senderAddFaceCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
@ -723,7 +724,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo: //
static void senderCancelAddFaceCommand( static void senderCancelAddFaceCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
@ -744,7 +745,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo:(...) // (...)
static void senderAddPalmWithTimeCycleCoercionCommand( static void senderAddPalmWithTimeCycleCoercionCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
@ -789,7 +790,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo: //
static void senderCancelAddPalmCommand( static void senderCancelAddPalmCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
@ -810,7 +811,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo: //
static void senderTimingCommand( static void senderTimingCommand(
{required String? lockID, {required String? lockID,
required String? userID, required String? userID,
@ -833,7 +834,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo: - // -
// static void senderAutomaticPadlockCommand({ // static void senderAutomaticPadlockCommand({
// required String? lockID, // required String? lockID,
// required String? userID, // required String? userID,
@ -855,7 +856,7 @@ class IoSenderManage {
// ), callBack:callBack); // ), callBack:callBack);
// } // }
//todo:() // ()
static void senderReferEventRecordNumberCommand( static void senderReferEventRecordNumberCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
@ -880,7 +881,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo:() // ()
static void senderReferEventRecordTimeCommand( static void senderReferEventRecordTimeCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
@ -907,7 +908,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo: //
static void senderQueryingFingerprintStatusCommand( static void senderQueryingFingerprintStatusCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
@ -934,7 +935,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo: //
static void senderCheckingCardStatusCommand( static void senderCheckingCardStatusCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
@ -961,7 +962,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo: //
static void senderQueryingFaceStatusCommand( static void senderQueryingFaceStatusCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
@ -988,7 +989,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo:() // ()
static void senderCheckingUserInfoCountCommand( static void senderCheckingUserInfoCountCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
@ -1013,7 +1014,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo:wifi列表 // wifi列表
static void getWifiListCommand( static void getWifiListCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
@ -1034,7 +1035,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo:wifi // wifi
static void senderConfiguringWifiCommand( static void senderConfiguringWifiCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
@ -1067,7 +1068,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo: //
// static void senderAddStressFingerprintCommand( // static void senderAddStressFingerprintCommand(
// {required String? keyID, // {required String? keyID,
// required String? userID, // required String? userID,
@ -1099,7 +1100,7 @@ class IoSenderManage {
// callBack: callBack); // callBack: callBack);
// } // }
//todo: //
// static void senderAddStressICCardCommand( // static void senderAddStressICCardCommand(
// {required String? keyID, // {required String? keyID,
// required String? userID, // required String? userID,
@ -1131,7 +1132,7 @@ class IoSenderManage {
// callBack: callBack); // callBack: callBack);
// } // }
//todo: //
static void senderAddStressPasswordCommand( static void senderAddStressPasswordCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
@ -1160,7 +1161,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo:()/ // ()/
static void readSupportFunctionsNoParametersCommand( static void readSupportFunctionsNoParametersCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
@ -1183,7 +1184,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo:()/ // ()/
static void setSupportFunctionsNoParametersCommand( static void setSupportFunctionsNoParametersCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
@ -1208,7 +1209,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo:()/ // ()/
static void readSupportFunctionsWithParametersCommand( static void readSupportFunctionsWithParametersCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
@ -1231,7 +1232,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo:()/ // ()/
static void setSupportFunctionsWithParametersCommand( static void setSupportFunctionsWithParametersCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
@ -1258,7 +1259,7 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//todo: //
static void senderReadAdminPasswordCommand( static void senderReadAdminPasswordCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
@ -1559,4 +1560,18 @@ class IoSenderManage {
callBack: callBack); callBack: callBack);
} }
//
static void gatewayGetStatusCommand({
required String? lockID,
required String? userID,
CommandSendCallBack? callBack}) {
CommandSenderManager().managerSendData(
command: GatewayGetStatusCommand(
lockID: lockID,
userID: userID
),
isBeforeAddUser: true,
callBack: callBack);
}
} }

View File

@ -21,12 +21,12 @@ class GatewayConfigurationWifiLogic extends BaseGetXController {
Future<void> gatewayDistributionNetwork() async{ Future<void> gatewayDistributionNetwork() async{
final LoginEntity entity = await ApiRepository.to.gatewayDistributionNetwork( final LoginEntity entity = await ApiRepository.to.gatewayDistributionNetwork(
gatewayName: state.gatewayNamePasswardTF.text, gatewayName: state.gatewayNamePasswardTF.text,
gatewayMac: state.macAddress.value, gatewayMac: state.gatewayModel.mac,
serialNumber: DateTime.now().millisecondsSinceEpoch.toString(), serialNumber:state.gatewayModel.serialNum,
gatewayType: 2, gatewayType: 2,
networkName: state.wifiNameTF.text, networkName: state.wifiNameTF.text,
networkMac: state.macAddress.value, networkMac: state.gatewayModel.wifiMac,
version: '1.0.0', version: state.gatewayModel.gatewayVersion,
); );
if(entity.errorCode!.codeIsSuccessful){ if(entity.errorCode!.codeIsSuccessful){
showToast('配网成功'.tr, something:(){ showToast('配网成功'.tr, something:(){

View File

@ -1,4 +1,4 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -75,11 +75,11 @@ class _GatewayConfigurationWifiPageState extends State<GatewayConfigurationWifiP
SizedBox( SizedBox(
height: 10.h, height: 10.h,
), ),
Obx(() => CommonItem( CommonItem(
leftTitel: '网络MAC'.tr, leftTitel: '网络MAC'.tr,
rightTitle: state.macAddress.value, rightTitle: state.gatewayModel.wifiMac,
// allHeight: 100.h, // allHeight: 100.h,
isHaveLine: false)), isHaveLine: false),
// SizedBox( // SizedBox(
// height: 10.h, // height: 10.h,
// ), // ),

View File

@ -1,6 +1,9 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_settings.dart';
import '../selectGateway/getGatewayInfo_model.dart';
class GatewayConfigurationWifiState{ class GatewayConfigurationWifiState{
GatewayConfigurationWifiState() { GatewayConfigurationWifiState() {
@ -9,12 +12,12 @@ class GatewayConfigurationWifiState{
wifiNameTF.text = map['wifiName']; wifiNameTF.text = map['wifiName'];
} }
if (map['macAddress'] != null && map['macAddress'] != '') { if (map['gatewayModel'] != null && map['gatewayModel'] != '') {
macAddress = map['macAddress']; gatewayModel = map['gatewayModel'];
} }
} }
RxString macAddress = ''.obs; GetGatewayInfoModel gatewayModel = GetGatewayInfoModel();
RxBool isUseStaticIP = false.obs; RxBool isUseStaticIP = false.obs;
final TextEditingController wifiNameTF = TextEditingController(); final TextEditingController wifiNameTF = TextEditingController();

View File

@ -50,7 +50,7 @@ class _GatewayGetWifiListPageState extends State<GatewayGetWifiListPage> with Ro
return _messageListItem(wifiNameStr['wifiName'], wifiNameStr['rssi'], () { return _messageListItem(wifiNameStr['wifiName'], wifiNameStr['rssi'], () {
Get.toNamed(Routers.gatewayConfigurationWifiPage, arguments: { Get.toNamed(Routers.gatewayConfigurationWifiPage, arguments: {
'wifiName': wifiNameStr['wifiName'], 'wifiName': wifiNameStr['wifiName'],
'macAddress': state.macAddress 'gatewayModel': state.gatewayModel
}); });
}); });
}) : NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 64.h)), }) : NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 64.h)),
@ -63,7 +63,7 @@ class _GatewayGetWifiListPageState extends State<GatewayGetWifiListPage> with Ro
onClick: () { onClick: () {
Get.toNamed(Routers.gatewayConfigurationWifiPage, arguments: { Get.toNamed(Routers.gatewayConfigurationWifiPage, arguments: {
'wifiName': '', 'wifiName': '',
'macAddress': state.macAddress 'gatewayModel': state.gatewayModel
}); });
}), }),
SizedBox( SizedBox(

View File

@ -2,17 +2,19 @@
import 'package:get/get.dart'; import 'package:get/get.dart';
import '../selectGateway/getGatewayInfo_model.dart';
class GatewayGetWifiListState{ class GatewayGetWifiListState{
GatewayGetWifiListState() { GatewayGetWifiListState() {
var map = Get.arguments; var map = Get.arguments;
if (map['macAddress'] != null && map['macAddress'] != '') { if (map['gatewayModel'] != null && map['gatewayModel'] != '') {
macAddress = map['macAddress']; gatewayModel = map['gatewayModel'];
} }
} }
final RxList<Map<String, String>> wifiNameDataList = <Map<String, String>>[].obs; final RxList<Map<String, String>> wifiNameDataList = <Map<String, String>>[].obs;
String macAddress = ''; GetGatewayInfoModel gatewayModel = GetGatewayInfoModel();
RxBool ifCurrentScreen = true.obs; // , RxBool ifCurrentScreen = true.obs; // ,
RxInt sureBtnState = 0.obs; RxInt sureBtnState = 0.obs;
} }

View File

@ -0,0 +1,7 @@
class GetGatewayInfoModel{
late String mac;
late String serialNum;
late String gatewayVersion;
late String wifiMac;
}

View File

@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:flutter_blue_plus/flutter_blue_plus.dart';
@ -9,12 +10,87 @@ import 'package:star_lock/tools/baseGetXController.dart';
import '../../../../appRouters.dart'; import '../../../../appRouters.dart';
import '../../../../app_settings/app_settings.dart'; import '../../../../app_settings/app_settings.dart';
import '../../../../blue/blue_manage.dart'; import '../../../../blue/blue_manage.dart';
import '../../../../blue/io_protocol/io_gateway_getStatus.dart';
import '../../../../blue/io_reply.dart';
import '../../../../blue/io_tool/io_tool.dart';
import '../../../../blue/io_tool/manager_event_bus.dart';
import '../../../../blue/sender_manage.dart';
import '../../../../tools/storage.dart';
import '../../../../widget/permission/permission_dialog.dart'; import '../../../../widget/permission/permission_dialog.dart';
import 'getGatewayInfo_model.dart';
import 'selectGatewayList_state.dart'; import 'selectGatewayList_state.dart';
class SelectGatewayListLogic extends BaseGetXController { class SelectGatewayListLogic extends BaseGetXController {
SelectGatewayListState state = SelectGatewayListState(); SelectGatewayListState state = SelectGatewayListState();
//
late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() {
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
//
if(reply is GatewayGetStatusReply) {
_replyGatewayGetStatusReply(reply);
}
});
}
// WIFI配网结果
Future<void> _replyGatewayGetStatusReply(Reply reply) async {
final int status = reply.data[2];
switch(status){
case 0x00:
//
// state.sureBtnState.value = 0;
cancelBlueConnetctToastTimer();
dismissEasyLoading();
final GetGatewayInfoModel gatewayModel = GetGatewayInfoModel();
// MAC地址
int index = 3;
final List<int> macList = reply.data.sublist(index, index + 20);
final String macStr = utf8String(macList);
// lockInfo['mac'] = macStr;
gatewayModel.mac = macStr;
index = index + 20;
AppLog.log('网关MAC地址 macList:$macList macStr:$macStr');
//
final List<int> serialNum = reply.data.sublist(index, index + 20);
final String serialNumStr = utf8String(serialNum);
// lockInfo['serialNum'] = serialNumStr;
gatewayModel.serialNum = serialNumStr;
index = index + 20;
AppLog.log('网关序列号 serialNum:$serialNum serialNumStr:$serialNumStr');
//
final List<int> gatewayVersion = reply.data.sublist(index, index + 20);
final String gatewayVersionStr = utf8String(gatewayVersion);
// lockInfo['gatewayVersion'] = gatewayVersionStr;
gatewayModel.gatewayVersion = gatewayVersionStr;
index = index + 20;
AppLog.log('软件版本 gatewayVersion:$gatewayVersion gatewayVersionStr:$gatewayVersionStr');
//
final List<int> wifiMac = reply.data.sublist(index, index + 20);
final String wifiMacStr = utf8String(wifiMac);
// lockInfo['wifiMac'] = wifiMacStr;
gatewayModel.wifiMac = wifiMacStr;
index = index + 20;
Get.toNamed(Routers.gatewayGetWifiListPage, arguments: {
'gatewayModel':gatewayModel,
});
break;
default:
//
dismissEasyLoading();
showToast('配网失败'.tr);
break;
}
}
void startScanBlueList() { void startScanBlueList() {
BlueManage().startScan(2000, (List<ScanResult> list) { BlueManage().startScan(2000, (List<ScanResult> list) {
state.devices.clear(); state.devices.clear();
@ -53,6 +129,28 @@ class SelectGatewayListLogic extends BaseGetXController {
startScanBlueList(); startScanBlueList();
} }
//
Future<void> senderGatewayGetStatusAction() async {
showEasyLoading();
showBlueConnetctToastTimer(action: (){
dismissEasyLoading();
});
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected){
IoSenderManage.gatewayGetStatusCommand(
lockID: BlueManage().connectDeviceName,
userID: await Storage.getUid(),
);
} else if (connectionState == BluetoothConnectionState.disconnected) {
dismissEasyLoading();
cancelBlueConnetctToastTimer();
if(state.ifCurrentScreen.value == true){
showBlueConnetctToast();
}
}
}, isAddEquipment: true);
}
// //
void connect(ScanResult device) { void connect(ScanResult device) {
showEasyLoading(); showEasyLoading();
@ -60,21 +158,32 @@ class SelectGatewayListLogic extends BaseGetXController {
dismissEasyLoading(); dismissEasyLoading();
}); });
BlueManage().blueSendData(device.advertisementData.advName, (BluetoothConnectionState state) async { BlueManage().blueSendData(device.advertisementData.advName, (BluetoothConnectionState state) async {
// AppLog.log('点击要添加的设备了'); // AppLog.log('点击要添加的设备了');
if (state == BluetoothConnectionState.connected) { if (state == BluetoothConnectionState.connected) {
dismissEasyLoading(); dismissEasyLoading();
Get.toNamed(Routers.gatewayGetWifiListPage, arguments: {
'macAddress':device.device.remoteId.str //
}); // final GetGatewayInfoModel gatewayModel = GetGatewayInfoModel();
} else{ // gatewayModel.mac = 'C1:1E:0D:E0:0C:A9';
dismissEasyLoading(); // gatewayModel.serialNum = DateTime.now().millisecondsSinceEpoch.toString();
} // gatewayModel.gatewayVersion = '1.0.1';
}, isAddEquipment: true); // gatewayModel.wifiMac = 'C1:1E:0D:E0:0C:A9';
// Get.toNamed(Routers.gatewayGetWifiListPage, arguments: {
// 'gatewayModel':gatewayModel,
// });
senderGatewayGetStatusAction();
} else{
dismissEasyLoading();
}
}, isAddEquipment: true);
} }
@override @override
void onInit() { void onInit() {
super.onInit(); super.onInit();
_initReplySubscription();
} }
@override @override
@ -82,4 +191,10 @@ class SelectGatewayListLogic extends BaseGetXController {
super.onReady(); super.onReady();
getNearByLimits(); getNearByLimits();
} }
@override
void dispose() {
super.dispose();
_replySubscription.cancel();
}
} }

View File

@ -4,4 +4,6 @@ import 'package:get/get.dart';
class SelectGatewayListState{ class SelectGatewayListState{
RxList<ScanResult> devices = <ScanResult>[].obs; RxList<ScanResult> devices = <ScanResult>[].obs;
RxBool ifCurrentScreen = true.obs; // ,
} }

View File

@ -20,4 +20,17 @@ class GatewayDetailLogic extends BaseGetXController{
}); });
} }
} }
Future<void> updateGateway(String gatewayName) async{
final LoginEntity entity = await ApiRepository.to.gatewayUpdate(
gatewayId: state.getewayItemData.value.gatewayId ?? 0,
gatewayName:gatewayName
);
if(entity.errorCode!.codeIsSuccessful){
showToast('修改成功'.tr, something:(){
// eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
Get.back();
});
}
}
} }

View File

@ -44,14 +44,13 @@ class _GatewayDetailPageState extends State<GatewayDetailPage> {
ShowTipView().showTFViewAlertDialog( ShowTipView().showTFViewAlertDialog(
state.changeGatewayNameController, state.changeGatewayNameController,
'请输入姓名'.tr, '请输入姓名'.tr,
'', () { '请输入姓名'.tr, () {
if (state.changeGatewayNameController.text.isEmpty) { if (state.changeGatewayNameController.text.isEmpty) {
logic.showToast('请输入姓名'.tr); logic.showToast('请输入姓名'.tr);
return; return;
} }
// Get.back(); Get.back();
// state.typeName.value = state.changeNameController.text; logic.updateGateway(state.changeGatewayNameController.text);
// logic.editICCardData();
}, inputFormatters: <TextInputFormatter>[ }, inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.deny('\n'), FilteringTextInputFormatter.deny('\n'),
LengthLimitingTextInputFormatter(50), LengthLimitingTextInputFormatter(50),
@ -75,20 +74,20 @@ class _GatewayDetailPageState extends State<GatewayDetailPage> {
SizedBox( SizedBox(
height: 10.h, height: 10.h,
), ),
CommonItem( // CommonItem(
leftTitel: '附近的锁'.tr, // leftTitel: '附近的锁'.tr,
rightTitle: state.getewayItemData.value.lockNum.toString(), // rightTitle: state.getewayItemData.value.lockNum.toString(),
isHaveLine: true, // isHaveLine: true,
isHaveDirection: true, // isHaveDirection: true,
action: () { // action: () {
Navigator.pushNamed(context, Routers.gatewayConnectionLockPage); // Navigator.pushNamed(context, Routers.gatewayConnectionLockPage);
}), // }),
CommonItem( // CommonItem(
leftTitel: '网关升级'.tr, // leftTitel: '网关升级'.tr,
rightTitle: '', // rightTitle: '',
isHaveLine: false, // isHaveLine: false,
isHaveDirection: true, // isHaveDirection: true,
action: () {}), // action: () {}),
SizedBox( SizedBox(
height: 80.h, height: 80.h,
), ),

View File

@ -9,6 +9,7 @@ class GatewayDetailState{
var map = Get.arguments; var map = Get.arguments;
if (map['getewayItemData'] != null && map['getewayItemData'] != '') { if (map['getewayItemData'] != null && map['getewayItemData'] != '') {
getewayItemData.value = map['getewayItemData']; getewayItemData.value = map['getewayItemData'];
changeGatewayNameController.text = getewayItemData.value.gatewayName!;
} }
} }

View File

@ -154,6 +154,7 @@ abstract class Api {
final String transferGatewayConfirmURL = final String transferGatewayConfirmURL =
'/plug/transferPlugConfirm'; // '/plug/transferPlugConfirm'; //
final String transferGatewayURL = '/plug/transfer'; // final String transferGatewayURL = '/plug/transfer'; //
final String updateGatewayURL = '/gateway/update'; //
final String getKeyDetailURL = '/key/get'; // final String getKeyDetailURL = '/key/get'; //
final String lockUserListURL = '/keyUser/listKeyUser'; // final String lockUserListURL = '/keyUser/listKeyUser'; //

View File

@ -1750,6 +1750,17 @@ class ApiProvider extends BaseProvider {
'gatewayId': gatewayId, 'gatewayId': gatewayId,
})); }));
//
Future<Response> gatewayUpdate(
int gatewayId,
String gatewayName,
) => post(
updateGatewayURL.toUrl,
jsonEncode({
'gatewayId': gatewayId,
'gatewayName': gatewayName,
}));
// //
Future<Response> transferGatewayConfirmInfoData( Future<Response> transferGatewayConfirmInfoData(
String receiverUsername, String type, String countryCode) => String receiverUsername, String type, String countryCode) =>

View File

@ -1925,6 +1925,15 @@ class ApiRepository {
return LoginEntity.fromJson(res.body); return LoginEntity.fromJson(res.body);
} }
//
Future<LoginEntity> gatewayUpdate({
required int gatewayId,
required String gatewayName,
}) async {
final res = await apiProvider.gatewayUpdate(gatewayId, gatewayName);
return LoginEntity.fromJson(res.body);
}
// //
Future<RecipientInformationEntity> transferGatewayConfirmInfoData( Future<RecipientInformationEntity> transferGatewayConfirmInfoData(
{required String receiverUsername, {required String receiverUsername,