1、添加网关获取附近WiFi协议及逻辑
2、添加添加网关协议、接口及逻辑 3、添加网关详情功能 4、添加删除网关功能
This commit is contained in:
parent
bcb7643a08
commit
6b792df101
@ -158,6 +158,7 @@ import 'mine/addLock/nearbyLock/nearbyLock_page.dart';
|
|||||||
import 'mine/addLock/saveLock/saveLock_page.dart';
|
import 'mine/addLock/saveLock/saveLock_page.dart';
|
||||||
import 'mine/addLock/selectLockType/selectLockType_page.dart';
|
import 'mine/addLock/selectLockType/selectLockType_page.dart';
|
||||||
import 'mine/gateway/addGateway/gatewayConfigurationWifi/gatewayConfigurationWifi_page.dart';
|
import 'mine/gateway/addGateway/gatewayConfigurationWifi/gatewayConfigurationWifi_page.dart';
|
||||||
|
import 'mine/gateway/addGateway/gatewayGetWifiList/gatewayGetWifiList_page.dart';
|
||||||
import 'mine/gateway/addGateway/selectGateway/selectGatewayList_page.dart';
|
import 'mine/gateway/addGateway/selectGateway/selectGatewayList_page.dart';
|
||||||
import 'mine/gateway/addGateway/selectGatewayType/selectGatewayType_page.dart';
|
import 'mine/gateway/addGateway/selectGatewayType/selectGatewayType_page.dart';
|
||||||
import 'mine/gateway/addGateway/selectGatewayTypeNextTip/selectGatewayTypeNextTip_page.dart';
|
import 'mine/gateway/addGateway/selectGatewayTypeNextTip/selectGatewayTypeNextTip_page.dart';
|
||||||
@ -344,6 +345,7 @@ abstract class Routers {
|
|||||||
static const String selectGatewayPage = '/SelectGatewayPage'; // 我的-选择网关
|
static const String selectGatewayPage = '/SelectGatewayPage'; // 我的-选择网关
|
||||||
static const String gatewayConfigurationWifiPage =
|
static const String gatewayConfigurationWifiPage =
|
||||||
'/GatewayConfigurationWifiPage'; // 我的-网关配置wifi
|
'/GatewayConfigurationWifiPage'; // 我的-网关配置wifi
|
||||||
|
static const String gatewayGetWifiListPage = '/GatewayGetWifiListPage'; // 我的-网关获取wifi列表
|
||||||
|
|
||||||
static const String messageListPage = '/MessageListPage'; // 我的-消息
|
static const String messageListPage = '/MessageListPage'; // 我的-消息
|
||||||
static const String messageDetailPage = '/MessageDetailPage'; // 我的-消息详情
|
static const String messageDetailPage = '/MessageDetailPage'; // 我的-消息详情
|
||||||
@ -1162,5 +1164,7 @@ abstract class AppRouters {
|
|||||||
name: Routers.remoteControlDetailPage, page: () => const RemoteControlDetailPage()),
|
name: Routers.remoteControlDetailPage, page: () => const RemoteControlDetailPage()),
|
||||||
GetPage<dynamic>(
|
GetPage<dynamic>(
|
||||||
name: Routers.palmDetailPage, page: () => const PalmDetailPage()),
|
name: Routers.palmDetailPage, page: () => const PalmDetailPage()),
|
||||||
|
GetPage<dynamic>(
|
||||||
|
name: Routers.gatewayGetWifiListPage, page: () => const GatewayGetWifiListPage()),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -109,6 +109,7 @@ class AppColors {
|
|||||||
static Color popMenuItemSelectedColor = const Color(0xFF063F71);
|
static Color popMenuItemSelectedColor = const Color(0xFF063F71);
|
||||||
|
|
||||||
static Color blackColor = const Color(0xFF000000);
|
static Color blackColor = const Color(0xFF000000);
|
||||||
|
static Color whiteColor = const Color(0xFFFFFFFF);
|
||||||
|
|
||||||
static Color dateSelectedBgColor = const Color(0xFF0093E5);
|
static Color dateSelectedBgColor = const Color(0xFF0093E5);
|
||||||
static Color dateSelectedTextColor = const Color(0xFFFFFFFF);
|
static Color dateSelectedTextColor = const Color(0xFFFFFFFF);
|
||||||
|
|||||||
82
lib/blue/io_protocol/io_gateway_configuringWifi.dart
Normal file
82
lib/blue/io_protocol/io_gateway_configuringWifi.dart
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
|
||||||
|
// 网关配网
|
||||||
|
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 GatewayConfiguringWifiCommand extends SenderProtocol {
|
||||||
|
|
||||||
|
GatewayConfiguringWifiCommand({
|
||||||
|
this.ssid,
|
||||||
|
this.password,
|
||||||
|
}) : super(CommandType.gatewayConfiguringWifi);
|
||||||
|
|
||||||
|
String? ssid;
|
||||||
|
String? password;
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'SenderConfiguringWifiCommand{ssid: $ssid, password: $password}';
|
||||||
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
|
||||||
|
//SSID 30
|
||||||
|
final int ssidLength = utf8.encode(ssid!).length;
|
||||||
|
subData.addAll(utf8.encode(ssid!));
|
||||||
|
subData = getFixedLengthList(subData, 30 - ssidLength);
|
||||||
|
|
||||||
|
//Password 20
|
||||||
|
final int passwordLength = utf8.encode(password!).length;
|
||||||
|
subData.addAll(utf8.encode(password!));
|
||||||
|
subData = getFixedLengthList(subData, 20 - passwordLength);
|
||||||
|
|
||||||
|
data.add(subData.length);
|
||||||
|
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);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class GatewayConfiguringWifiReply extends Reply {
|
||||||
|
GatewayConfiguringWifiReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||||
|
: super.parseData(commandType, dataDetail) {
|
||||||
|
data = dataDetail;
|
||||||
|
final int status = data[5];
|
||||||
|
errorWithStstus(status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class GatewayConfiguringWifiResultReply extends Reply {
|
||||||
|
GatewayConfiguringWifiResultReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||||
|
: super.parseData(commandType, dataDetail) {
|
||||||
|
data = dataDetail;
|
||||||
|
final int status = data[5];
|
||||||
|
errorWithStstus(status);
|
||||||
|
}
|
||||||
|
}
|
||||||
76
lib/blue/io_protocol/io_gateway_getWifiList.dart
Normal file
76
lib/blue/io_protocol/io_gateway_getWifiList.dart
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:crypto/crypto.dart' as crypto;
|
||||||
|
|
||||||
|
import '../../app_settings/app_settings.dart';
|
||||||
|
import '../io_reply.dart';
|
||||||
|
import '../io_sender.dart';
|
||||||
|
import '../io_tool/io_tool.dart';
|
||||||
|
import '../io_type.dart';
|
||||||
|
import '../sm4Encipher/sm4.dart';
|
||||||
|
|
||||||
|
class GatewayGetWifiCommand extends SenderProtocol {
|
||||||
|
|
||||||
|
GatewayGetWifiCommand({
|
||||||
|
this.userID,
|
||||||
|
}) : super(CommandType.gatewayGetWifiList);
|
||||||
|
|
||||||
|
String? userID;
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'SenderGetWifiCommand{userID: $userID}';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<int> messageDetail() {
|
||||||
|
final List<int> data = [];
|
||||||
|
List<int> subData = [];
|
||||||
|
|
||||||
|
// 指令类型
|
||||||
|
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);
|
||||||
|
|
||||||
|
|
||||||
|
//userID 20
|
||||||
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
|
subData.addAll(utf8.encode(userID!));
|
||||||
|
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||||
|
AppLog.log('ebcData: $subData');
|
||||||
|
|
||||||
|
data.add(subData.length);
|
||||||
|
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);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class GatewayGetWifiReply extends Reply {
|
||||||
|
GatewayGetWifiReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||||
|
: super.parseData(commandType, dataDetail) {
|
||||||
|
data = dataDetail;
|
||||||
|
final int status = data[2];
|
||||||
|
errorWithStstus(status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class GatewayGetWifiListReply extends Reply {
|
||||||
|
GatewayGetWifiListReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||||
|
: super.parseData(commandType, dataDetail) {
|
||||||
|
data = dataDetail;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -24,6 +24,10 @@ enum CommandType {
|
|||||||
startOATUpgrade, //OTA升级开始 0x30E0
|
startOATUpgrade, //OTA升级开始 0x30E0
|
||||||
confirmationOTAUpgrade, //OTA升级开始 0x30E2
|
confirmationOTAUpgrade, //OTA升级开始 0x30E2
|
||||||
processOTAUpgrade, //OTA升级过程 0x30E1
|
processOTAUpgrade, //OTA升级过程 0x30E1
|
||||||
|
gatewayConfiguringWifi,//网关配网 0x30F4
|
||||||
|
gatewayConfiguringWifiResult,//网关配网结果 0x30F5
|
||||||
|
gatewayGetWifiList,//网关获取附近的wifi列表 0x30F6
|
||||||
|
gatewayGetWifiListResult,//网关获取附近的wifi列表结果 0x30F7
|
||||||
|
|
||||||
generalExtendedCommond, // 通用扩展指令 = 0x3030
|
generalExtendedCommond, // 通用扩展指令 = 0x3030
|
||||||
gecChangeAdministratorPassword, // 通用扩展指令子命令-修改管理员密码 = 2
|
gecChangeAdministratorPassword, // 通用扩展指令子命令-修改管理员密码 = 2
|
||||||
@ -181,6 +185,26 @@ extension ExtensionCommandType on CommandType {
|
|||||||
type = CommandType.confirmationOTAUpgrade;
|
type = CommandType.confirmationOTAUpgrade;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 0x30F4:
|
||||||
|
{
|
||||||
|
type = CommandType.gatewayConfiguringWifi;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0x30F5:
|
||||||
|
{
|
||||||
|
type = CommandType.gatewayConfiguringWifiResult;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0x30F6:
|
||||||
|
{
|
||||||
|
type = CommandType.gatewayGetWifiList;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0x30F7:
|
||||||
|
{
|
||||||
|
type = CommandType.gatewayGetWifiListResult;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
type = CommandType.readLockStatusInfo;
|
type = CommandType.readLockStatusInfo;
|
||||||
@ -268,6 +292,18 @@ extension ExtensionCommandType on CommandType {
|
|||||||
case CommandType.confirmationOTAUpgrade:
|
case CommandType.confirmationOTAUpgrade:
|
||||||
type = 0x30E2;
|
type = 0x30E2;
|
||||||
break;
|
break;
|
||||||
|
case CommandType.gatewayConfiguringWifi:
|
||||||
|
type = 0x30F4;
|
||||||
|
break;
|
||||||
|
case CommandType.gatewayConfiguringWifiResult:
|
||||||
|
type = 0x30F5;
|
||||||
|
break;
|
||||||
|
case CommandType.gatewayGetWifiList:
|
||||||
|
type = 0x30F6;
|
||||||
|
break;
|
||||||
|
case CommandType.gatewayGetWifiListResult:
|
||||||
|
type = 0x30F7;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
type = 0x300A;
|
type = 0x300A;
|
||||||
break;
|
break;
|
||||||
@ -283,6 +319,8 @@ extension ExtensionCommandType on CommandType {
|
|||||||
switch (this) {
|
switch (this) {
|
||||||
case CommandType.getLockPublicKey:
|
case CommandType.getLockPublicKey:
|
||||||
case CommandType.processOTAUpgrade:
|
case CommandType.processOTAUpgrade:
|
||||||
|
case CommandType.gatewayGetWifiList:
|
||||||
|
case CommandType.gatewayConfiguringWifi:
|
||||||
//不加密
|
//不加密
|
||||||
type = 0x20;
|
type = 0x20;
|
||||||
break;
|
break;
|
||||||
@ -386,6 +424,18 @@ extension ExtensionCommandType on CommandType {
|
|||||||
case 0x30E1:
|
case 0x30E1:
|
||||||
t = 'oat升级过程';
|
t = 'oat升级过程';
|
||||||
break;
|
break;
|
||||||
|
case 0x30F4:
|
||||||
|
t = '网关配网';
|
||||||
|
break;
|
||||||
|
case 0x30F5:
|
||||||
|
t = '网关配网结果';
|
||||||
|
break;
|
||||||
|
case 0x30F6:
|
||||||
|
t = '网关获取wifi列表';
|
||||||
|
break;
|
||||||
|
case 0x30F7:
|
||||||
|
t = '网关获取附近的wifi列表结果';
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
t = '读星锁状态信息';
|
t = '读星锁状态信息';
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import 'package:star_lock/blue/io_protocol/io_cleanUpUsers.dart';
|
|||||||
import 'package:star_lock/blue/io_protocol/io_deletUser.dart';
|
import 'package:star_lock/blue/io_protocol/io_deletUser.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_editUser.dart';
|
import 'package:star_lock/blue/io_protocol/io_editUser.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_factoryDataReset.dart';
|
import 'package:star_lock/blue/io_protocol/io_factoryDataReset.dart';
|
||||||
|
import 'package:star_lock/blue/io_protocol/io_gateway_configuringWifi.dart';
|
||||||
|
import 'package:star_lock/blue/io_protocol/io_gateway_getWifiList.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_otaUpgrade.dart';
|
import 'package:star_lock/blue/io_protocol/io_otaUpgrade.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_processOtaUpgrade.dart';
|
import 'package:star_lock/blue/io_protocol/io_processOtaUpgrade.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_queryingFaceStatus.dart';
|
import 'package:star_lock/blue/io_protocol/io_queryingFaceStatus.dart';
|
||||||
@ -250,6 +252,26 @@ class CommandReciverManager {
|
|||||||
reply = UpdataLockSetReply.parseData(commandType, data);
|
reply = UpdataLockSetReply.parseData(commandType, data);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case CommandType.gatewayConfiguringWifi:
|
||||||
|
{
|
||||||
|
reply = GatewayConfiguringWifiReply.parseData(commandType, data);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CommandType.gatewayConfiguringWifiResult:
|
||||||
|
{
|
||||||
|
reply = GatewayConfiguringWifiResultReply.parseData(commandType, data);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CommandType.gatewayGetWifiList:
|
||||||
|
{
|
||||||
|
reply = GatewayGetWifiReply.parseData(commandType, data);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CommandType.gatewayGetWifiListResult:
|
||||||
|
{
|
||||||
|
reply = GatewayGetWifiListReply.parseData(commandType, data);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case CommandType.generalExtendedCommond:
|
case CommandType.generalExtendedCommond:
|
||||||
{
|
{
|
||||||
// 子命令类型
|
// 子命令类型
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import 'package:star_lock/blue/io_protocol/io_addFace.dart';
|
|||||||
import 'package:star_lock/blue/io_protocol/io_changeAdministratorPassword.dart';
|
import 'package:star_lock/blue/io_protocol/io_changeAdministratorPassword.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_cleanUpUsers.dart';
|
import 'package:star_lock/blue/io_protocol/io_cleanUpUsers.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_deletUser.dart';
|
import 'package:star_lock/blue/io_protocol/io_deletUser.dart';
|
||||||
|
import 'package:star_lock/blue/io_protocol/io_gateway_getWifiList.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_otaUpgrade.dart';
|
import 'package:star_lock/blue/io_protocol/io_otaUpgrade.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_processOtaUpgrade.dart';
|
import 'package:star_lock/blue/io_protocol/io_processOtaUpgrade.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_queryingFaceStatus.dart';
|
import 'package:star_lock/blue/io_protocol/io_queryingFaceStatus.dart';
|
||||||
@ -24,6 +25,7 @@ import 'io_protocol/io_checkingUserInfoCount.dart';
|
|||||||
import 'io_protocol/io_configuringWifi.dart';
|
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_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';
|
||||||
@ -1531,4 +1533,30 @@ class IoSenderManage {
|
|||||||
callBack: callBack);
|
callBack: callBack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 网关获取wifi列表
|
||||||
|
static void gatewayGetWifiCommand(
|
||||||
|
{required String? userID,
|
||||||
|
CommandSendCallBack? callBack}) {
|
||||||
|
CommandSenderManager().managerSendData(
|
||||||
|
command: GatewayGetWifiCommand(
|
||||||
|
userID: userID,
|
||||||
|
),
|
||||||
|
isBeforeAddUser: true,
|
||||||
|
callBack: callBack);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 网关配网
|
||||||
|
static void gatewayConfiguringWifiCommand({
|
||||||
|
required String? ssid,
|
||||||
|
required String? password,
|
||||||
|
CommandSendCallBack? callBack}) {
|
||||||
|
CommandSenderManager().managerSendData(
|
||||||
|
command: GatewayConfiguringWifiCommand(
|
||||||
|
ssid: ssid,
|
||||||
|
password: password
|
||||||
|
),
|
||||||
|
isBeforeAddUser: true,
|
||||||
|
callBack: callBack);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -292,6 +292,7 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
(0xff & indexList[5]) << 8 |
|
(0xff & indexList[5]) << 8 |
|
||||||
(0xFF & indexList[6]);
|
(0xFF & indexList[6]);
|
||||||
indexMap['date'] = '${time * 1000}';
|
indexMap['date'] = '${time * 1000}';
|
||||||
|
|
||||||
uploadList.add(indexMap);
|
uploadList.add(indexMap);
|
||||||
|
|
||||||
final int operateDate = time * 1000;
|
final int operateDate = time * 1000;
|
||||||
|
|||||||
@ -1,8 +1,166 @@
|
|||||||
|
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:network_info_plus/network_info_plus.dart';
|
||||||
import 'package:star_lock/tools/baseGetXController.dart';
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
|
|
||||||
|
import '../../../../blue/blue_manage.dart';
|
||||||
|
import '../../../../blue/io_protocol/io_gateway_configuringWifi.dart';
|
||||||
|
import '../../../../blue/io_reply.dart';
|
||||||
|
import '../../../../blue/io_tool/manager_event_bus.dart';
|
||||||
|
import '../../../../blue/sender_manage.dart';
|
||||||
|
import '../../../../login/login/entity/LoginEntity.dart';
|
||||||
|
import '../../../../network/api_repository.dart';
|
||||||
import 'gatewayConfigurationWifi_state.dart';
|
import 'gatewayConfigurationWifi_state.dart';
|
||||||
|
|
||||||
class GatewayConfigurationWifiLogic extends BaseGetXController {
|
class GatewayConfigurationWifiLogic extends BaseGetXController {
|
||||||
GatewayConfigurationWifiState state = GatewayConfigurationWifiState();
|
final GatewayConfigurationWifiState state = GatewayConfigurationWifiState();
|
||||||
|
|
||||||
|
Future<void> gatewayDistributionNetwork() async{
|
||||||
|
if(state.gatewayNamePasswardTF.text.isEmpty){
|
||||||
|
showToast('请输入网关名称'.tr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(state.wifiNameTF.text.isEmpty){
|
||||||
|
showToast('请输入wifi名称'.tr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(state.wifiPasswardTF.text.isEmpty){
|
||||||
|
showToast('请输入WiFi密码'.tr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
final LoginEntity entity = await ApiRepository.to.gatewayDistributionNetwork(
|
||||||
|
gatewayName: state.gatewayNamePasswardTF.text,
|
||||||
|
gatewayMac: state.macAddress,
|
||||||
|
serialNumber: DateTime.now().millisecondsSinceEpoch.toString(),
|
||||||
|
gatewayType: 2,
|
||||||
|
networkName: state.wifiNameTF.text,
|
||||||
|
networkMac: state.macAddress,
|
||||||
|
version: '1.0.0',
|
||||||
|
);
|
||||||
|
if(entity.errorCode!.codeIsSuccessful){
|
||||||
|
showToast('配网成功'.tr, something:(){
|
||||||
|
// eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
|
||||||
|
Get.close(4);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监听设备返回的数据
|
||||||
|
late StreamSubscription<Reply> _replySubscription;
|
||||||
|
void _initReplySubscription() {
|
||||||
|
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
|
||||||
|
// WIFI配网结果
|
||||||
|
if(reply is GatewayConfiguringWifiReply) {
|
||||||
|
_replySenderConfiguringWifi(reply);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// WIFI配网结果
|
||||||
|
Future<void> _replySenderConfiguringWifi(Reply reply) async {
|
||||||
|
final int status = reply.data[5];
|
||||||
|
|
||||||
|
switch(status){
|
||||||
|
case 0x00:
|
||||||
|
//成功
|
||||||
|
state.sureBtnState.value = 0;
|
||||||
|
cancelBlueConnetctToastTimer();
|
||||||
|
dismissEasyLoading();
|
||||||
|
gatewayDistributionNetwork();
|
||||||
|
break;
|
||||||
|
case 0x06:
|
||||||
|
//无权限
|
||||||
|
IoSenderManage.gatewayConfiguringWifiCommand(
|
||||||
|
ssid: state.gatewayNamePasswardTF.text,
|
||||||
|
password: state.wifiPasswardTF.text,
|
||||||
|
);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 0xff:
|
||||||
|
//失败
|
||||||
|
dismissEasyLoading();
|
||||||
|
showToast('配网失败'.tr);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
//失败
|
||||||
|
dismissEasyLoading();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 点击配置wifi
|
||||||
|
Future<void> senderConfiguringWifiAction() async {
|
||||||
|
if(state.gatewayNamePasswardTF.text.isEmpty){
|
||||||
|
showToast('请输入wifi名称'.tr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(state.sureBtnState.value == 1){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
state.sureBtnState.value = 1;
|
||||||
|
|
||||||
|
showEasyLoading();
|
||||||
|
showBlueConnetctToastTimer(action: (){
|
||||||
|
dismissEasyLoading();
|
||||||
|
state.sureBtnState.value = 0;
|
||||||
|
});
|
||||||
|
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||||
|
if (connectionState == BluetoothConnectionState.connected){
|
||||||
|
IoSenderManage.gatewayConfiguringWifiCommand(
|
||||||
|
ssid: state.wifiNameTF.text,
|
||||||
|
password: state.wifiPasswardTF.text,
|
||||||
|
);
|
||||||
|
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||||
|
dismissEasyLoading();
|
||||||
|
cancelBlueConnetctToastTimer();
|
||||||
|
state.sureBtnState.value = 0;
|
||||||
|
if(state.ifCurrentScreen.value == true){
|
||||||
|
showBlueConnetctToast();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, isAddEquipment: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
final NetworkInfo _networkInfo = NetworkInfo();
|
||||||
|
Future<String> getWifiName() async {
|
||||||
|
String ssid = '';
|
||||||
|
ssid = (await _networkInfo.getWifiName())!;
|
||||||
|
ssid = ssid ?? '';
|
||||||
|
ssid = ssid.replaceAll(r'"', '');
|
||||||
|
return ssid ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onReady() {
|
||||||
|
super.onReady();
|
||||||
|
|
||||||
|
if(state.wifiNameTF.text.isEmpty){
|
||||||
|
getWifiName().then((String value) {
|
||||||
|
state.wifiNameTF.text = value;
|
||||||
|
// update();
|
||||||
|
// AppLog.log('wifiNameTF:${state.wifiNameTF.text} value:$value');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_initReplySubscription();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onInit() {
|
||||||
|
super.onInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onClose() {
|
||||||
|
_replySubscription.cancel();
|
||||||
|
super.onClose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,9 +1,12 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
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_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
import '../../../../appRouters.dart';
|
||||||
import '../../../../app_settings/app_colors.dart';
|
import '../../../../app_settings/app_colors.dart';
|
||||||
|
import '../../../../tools/appRouteObserver.dart';
|
||||||
import '../../../../tools/commonItem.dart';
|
import '../../../../tools/commonItem.dart';
|
||||||
import '../../../../tools/submitBtn.dart';
|
import '../../../../tools/submitBtn.dart';
|
||||||
import '../../../../tools/titleAppBar.dart';
|
import '../../../../tools/titleAppBar.dart';
|
||||||
@ -18,7 +21,7 @@ class GatewayConfigurationWifiPage extends StatefulWidget {
|
|||||||
_GatewayConfigurationWifiPageState();
|
_GatewayConfigurationWifiPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _GatewayConfigurationWifiPageState extends State<GatewayConfigurationWifiPage> {
|
class _GatewayConfigurationWifiPageState extends State<GatewayConfigurationWifiPage> with RouteAware {
|
||||||
final GatewayConfigurationWifiLogic logic = Get.put(GatewayConfigurationWifiLogic());
|
final GatewayConfigurationWifiLogic logic = Get.put(GatewayConfigurationWifiLogic());
|
||||||
final GatewayConfigurationWifiState state = Get.find<GatewayConfigurationWifiLogic>().state;
|
final GatewayConfigurationWifiState state = Get.find<GatewayConfigurationWifiLogic>().state;
|
||||||
|
|
||||||
@ -46,13 +49,13 @@ class _GatewayConfigurationWifiPageState extends State<GatewayConfigurationWifiP
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
CommonItem(
|
CommonItem(
|
||||||
leftTitel: 'WiFi名称'.tr,
|
leftTitel: 'WiFi名称'.tr,
|
||||||
rightTitle: 'XinHongJia',
|
rightTitle: '',
|
||||||
allHeight: 100.h,
|
isHaveRightWidget: true,
|
||||||
|
allHeight: 80.h,
|
||||||
isHaveLine: true,
|
isHaveLine: true,
|
||||||
isHaveDirection: true,
|
rightWidget: getTFWidget(
|
||||||
action: () {
|
state.wifiNameTF,
|
||||||
// Navigator.pushNamed(context, Routers.minePersonInfoSetSafetyProblemPage);
|
'请输入wifi名称'.tr)),
|
||||||
}),
|
|
||||||
CommonItem(
|
CommonItem(
|
||||||
leftTitel: 'WiFi密码'.tr,
|
leftTitel: 'WiFi密码'.tr,
|
||||||
rightTitle: '',
|
rightTitle: '',
|
||||||
@ -77,65 +80,65 @@ class _GatewayConfigurationWifiPageState extends State<GatewayConfigurationWifiP
|
|||||||
rightTitle: '48:55:19:7d:84:7a',
|
rightTitle: '48:55:19:7d:84:7a',
|
||||||
// allHeight: 100.h,
|
// allHeight: 100.h,
|
||||||
isHaveLine: false),
|
isHaveLine: false),
|
||||||
SizedBox(
|
// SizedBox(
|
||||||
height: 10.h,
|
// height: 10.h,
|
||||||
),
|
// ),
|
||||||
Obx(() => Visibility(
|
// Obx(() => Visibility(
|
||||||
visible: state.isUseStaticIP.value,
|
// visible: state.isUseStaticIP.value,
|
||||||
child: Column(
|
// child: Column(
|
||||||
children: <Widget>[
|
// children: <Widget>[
|
||||||
CommonItem(
|
// CommonItem(
|
||||||
leftTitel: 'IP地址'.tr,
|
// leftTitel: 'IP地址'.tr,
|
||||||
// rightTitle: '192.168.1.1',
|
// // rightTitle: '192.168.1.1',
|
||||||
isHaveLine: true,
|
// isHaveLine: true,
|
||||||
isHaveRightWidget: true,
|
// isHaveRightWidget: true,
|
||||||
rightWidget: getTFWidget(state.ipAddressTF, '请输入IP地址'.tr)
|
// rightWidget: getTFWidget(state.ipAddressTF, '请输入IP地址'.tr)
|
||||||
),
|
// ),
|
||||||
CommonItem(
|
// CommonItem(
|
||||||
leftTitel: '子网掩码'.tr,
|
// leftTitel: '子网掩码'.tr,
|
||||||
// rightTitle: '255.255.255.0',
|
// // rightTitle: '255.255.255.0',
|
||||||
isHaveLine: true,
|
// isHaveLine: true,
|
||||||
isHaveRightWidget: true,
|
// isHaveRightWidget: true,
|
||||||
rightWidget: getTFWidget(state.subnetMaskTF, '请输入子网掩码'.tr)),
|
// rightWidget: getTFWidget(state.subnetMaskTF, '请输入子网掩码'.tr)),
|
||||||
CommonItem(
|
// CommonItem(
|
||||||
leftTitel: '默认网关'.tr,
|
// leftTitel: '默认网关'.tr,
|
||||||
// rightTitle: '192.168.1.1',
|
// // rightTitle: '192.168.1.1',
|
||||||
isHaveLine: true,
|
// isHaveLine: true,
|
||||||
isHaveRightWidget: true,
|
// isHaveRightWidget: true,
|
||||||
rightWidget: getTFWidget(state.defaultGatewayTF, '请输入默认网关'.tr)
|
// rightWidget: getTFWidget(state.defaultGatewayTF, '请输入默认网关'.tr)
|
||||||
),
|
// ),
|
||||||
SizedBox(height: 10.h,),
|
// SizedBox(height: 10.h,),
|
||||||
Obx(() => CommonItem(
|
// Obx(() => CommonItem(
|
||||||
leftTitel: '自动获取DNS服务器地址'.tr,
|
// leftTitel: '自动获取DNS服务器地址'.tr,
|
||||||
rightTitle: '',
|
// rightTitle: '',
|
||||||
isHaveLine: true,
|
// isHaveLine: true,
|
||||||
isHaveRightWidget: true,
|
// isHaveRightWidget: true,
|
||||||
rightWidget: SizedBox(
|
// rightWidget: SizedBox(
|
||||||
width: 60.w, height: 50.h, child: _switch()))),
|
// width: 60.w, height: 50.h, child: _switch()))),
|
||||||
Visibility(
|
// Visibility(
|
||||||
visible: !state.isAutomaticallyGetDNSServerAddress.value,
|
// visible: !state.isAutomaticallyGetDNSServerAddress.value,
|
||||||
child: Column(
|
// child: Column(
|
||||||
children: <Widget>[
|
// children: <Widget>[
|
||||||
CommonItem(
|
// CommonItem(
|
||||||
leftTitel: '首选DNS'.tr,
|
// leftTitel: '首选DNS'.tr,
|
||||||
rightTitle: '',
|
// rightTitle: '',
|
||||||
isHaveLine: true,
|
// isHaveLine: true,
|
||||||
isHaveRightWidget: true,
|
// isHaveRightWidget: true,
|
||||||
rightWidget: getTFWidget(
|
// rightWidget: getTFWidget(
|
||||||
state.firstChoiceDNSTF,
|
// state.firstChoiceDNSTF,
|
||||||
'请输入'.tr)),
|
// '请输入'.tr)),
|
||||||
CommonItem(
|
// CommonItem(
|
||||||
leftTitel: '备选DNS'.tr,
|
// leftTitel: '备选DNS'.tr,
|
||||||
rightTitle: '',
|
// rightTitle: '',
|
||||||
isHaveLine: false,
|
// isHaveLine: false,
|
||||||
isHaveRightWidget: true,
|
// isHaveRightWidget: true,
|
||||||
rightWidget: getTFWidget(
|
// rightWidget: getTFWidget(
|
||||||
state.alternativeDNSTF,
|
// state.alternativeDNSTF,
|
||||||
'请输入'.tr,)),
|
// '请输入'.tr,)),
|
||||||
],
|
// ],
|
||||||
)),
|
// )),
|
||||||
],
|
// ],
|
||||||
))),
|
// ))),
|
||||||
SizedBox(height: 50.h),
|
SizedBox(height: 50.h),
|
||||||
Container(
|
Container(
|
||||||
margin: EdgeInsets.only(left: 20.w, right: 20.w),
|
margin: EdgeInsets.only(left: 20.w, right: 20.w),
|
||||||
@ -147,6 +150,7 @@ class _GatewayConfigurationWifiPageState extends State<GatewayConfigurationWifiP
|
|||||||
padding: EdgeInsets.only(top: 15.w, bottom: 15.w),
|
padding: EdgeInsets.only(top: 15.w, bottom: 15.w),
|
||||||
onClick: () {
|
onClick: () {
|
||||||
// Navigator.pushNamed(context, Routers.selectGatewayPage);
|
// Navigator.pushNamed(context, Routers.selectGatewayPage);
|
||||||
|
logic.senderConfiguringWifiAction();
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
SizedBox(height: 10.h),
|
SizedBox(height: 10.h),
|
||||||
@ -195,11 +199,15 @@ class _GatewayConfigurationWifiPageState extends State<GatewayConfigurationWifiP
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
|
// 设置TextField font大小
|
||||||
//输入框一行
|
//输入框一行
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
controller: controller,
|
controller: controller,
|
||||||
autofocus: false,
|
autofocus: false,
|
||||||
textAlign: TextAlign.end,
|
textAlign: TextAlign.end,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 22.sp, // 设置字体大小
|
||||||
|
),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
//输入里面输入文字内边距设置
|
//输入里面输入文字内边距设置
|
||||||
hintText: tfStr,
|
hintText: tfStr,
|
||||||
@ -228,15 +236,64 @@ class _GatewayConfigurationWifiPageState extends State<GatewayConfigurationWifiP
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
CupertinoSwitch _switch() {
|
// CupertinoSwitch _switch() {
|
||||||
return CupertinoSwitch(
|
// return CupertinoSwitch(
|
||||||
activeColor: CupertinoColors.activeBlue,
|
// activeColor: CupertinoColors.activeBlue,
|
||||||
trackColor: CupertinoColors.systemGrey5,
|
// trackColor: CupertinoColors.systemGrey5,
|
||||||
thumbColor: CupertinoColors.white,
|
// thumbColor: CupertinoColors.white,
|
||||||
value: state.isAutomaticallyGetDNSServerAddress.value,
|
// value: state.isAutomaticallyGetDNSServerAddress.value,
|
||||||
onChanged: (bool value) {
|
// onChanged: (bool value) {
|
||||||
state.isAutomaticallyGetDNSServerAddress.value = !state.isAutomaticallyGetDNSServerAddress.value;
|
// state.isAutomaticallyGetDNSServerAddress.value = !state.isAutomaticallyGetDNSServerAddress.value;
|
||||||
},
|
// },
|
||||||
);
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeDependencies() {
|
||||||
|
super.didChangeDependencies();
|
||||||
|
|
||||||
|
/// 路由订阅
|
||||||
|
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
/// 取消路由订阅
|
||||||
|
AppRouteObserver().routeObserver.unsubscribe(this);
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 从上级界面进入 当前界面即将出现
|
||||||
|
@override
|
||||||
|
void didPush() {
|
||||||
|
super.didPush();
|
||||||
|
state.ifCurrentScreen.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 返回上一个界面 当前界面即将消失
|
||||||
|
@override
|
||||||
|
void didPop() {
|
||||||
|
super.didPop();
|
||||||
|
logic.cancelBlueConnetctToastTimer();
|
||||||
|
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
||||||
|
state.ifCurrentScreen.value = false;
|
||||||
|
state.sureBtnState.value = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 从下级返回 当前界面即将出现
|
||||||
|
@override
|
||||||
|
void didPopNext() {
|
||||||
|
super.didPopNext();
|
||||||
|
state.ifCurrentScreen.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 进入下级界面 当前界面即将消失
|
||||||
|
@override
|
||||||
|
void didPushNext() {
|
||||||
|
super.didPushNext();
|
||||||
|
logic.cancelBlueConnetctToastTimer();
|
||||||
|
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
||||||
|
state.ifCurrentScreen.value = false;
|
||||||
|
state.sureBtnState.value = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,21 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
class GatewayConfigurationWifiState{
|
class GatewayConfigurationWifiState{
|
||||||
|
GatewayConfigurationWifiState() {
|
||||||
|
var map = Get.arguments;
|
||||||
|
if (map['wifiName'] != null && map['wifiName'] != '') {
|
||||||
|
wifiNameTF.text = map['wifiName'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (map['macAddress'] != null && map['macAddress'] != '') {
|
||||||
|
macAddress = map['macAddress'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String macAddress = '';
|
||||||
RxBool isUseStaticIP = false.obs;
|
RxBool isUseStaticIP = false.obs;
|
||||||
|
|
||||||
|
final TextEditingController wifiNameTF = TextEditingController();
|
||||||
final TextEditingController wifiPasswardTF = TextEditingController();
|
final TextEditingController wifiPasswardTF = TextEditingController();
|
||||||
final TextEditingController gatewayNamePasswardTF = TextEditingController();
|
final TextEditingController gatewayNamePasswardTF = TextEditingController();
|
||||||
final TextEditingController ipAddressTF = TextEditingController();
|
final TextEditingController ipAddressTF = TextEditingController();
|
||||||
@ -14,5 +28,7 @@ class GatewayConfigurationWifiState{
|
|||||||
final TextEditingController firstChoiceDNSTF = TextEditingController();
|
final TextEditingController firstChoiceDNSTF = TextEditingController();
|
||||||
final TextEditingController alternativeDNSTF = TextEditingController();
|
final TextEditingController alternativeDNSTF = TextEditingController();
|
||||||
|
|
||||||
|
// RxString wifiName = '请选择WiFi'.obs;
|
||||||
|
RxBool ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||||
|
RxInt sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用)
|
||||||
}
|
}
|
||||||
@ -0,0 +1,151 @@
|
|||||||
|
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:star_lock/blue/io_protocol/io_gateway_configuringWifi.dart';
|
||||||
|
import 'package:star_lock/blue/io_protocol/io_gateway_getWifiList.dart';
|
||||||
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
|
|
||||||
|
import '../../../../../blue/io_tool/io_tool.dart';
|
||||||
|
import '../../../../blue/blue_manage.dart';
|
||||||
|
import '../../../../blue/io_reply.dart';
|
||||||
|
import '../../../../blue/io_tool/manager_event_bus.dart';
|
||||||
|
import '../../../../blue/sender_manage.dart';
|
||||||
|
import '../../../../tools/storage.dart';
|
||||||
|
import 'gatewayGetWifiList_state.dart';
|
||||||
|
|
||||||
|
class GatewayGetWifiListLogic extends BaseGetXController {
|
||||||
|
final GatewayGetWifiListState state = GatewayGetWifiListState();
|
||||||
|
|
||||||
|
// 获取解析后的数据
|
||||||
|
late StreamSubscription<Reply> _replySubscription;
|
||||||
|
void _initReplySubscription() {
|
||||||
|
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((Reply reply) {
|
||||||
|
if(reply is GatewayGetWifiReply) {
|
||||||
|
_replySendGetWifiParameters(reply);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(reply is GatewayGetWifiListReply) {
|
||||||
|
_replyGetWifiListParameters(reply);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发送获取wifi列表数据解析
|
||||||
|
Future<void> _replySendGetWifiParameters(Reply reply) async {
|
||||||
|
final int status = reply.data[2];
|
||||||
|
switch(status){
|
||||||
|
case 0x00:
|
||||||
|
//成功
|
||||||
|
showEasyLoading();
|
||||||
|
cancelBlueConnetctToastTimer();
|
||||||
|
Future.delayed(5.seconds, dismissEasyLoading);
|
||||||
|
break;
|
||||||
|
case 0x06:
|
||||||
|
// 需要鉴权
|
||||||
|
|
||||||
|
// var token = await Storage.getStringList(saveBlueToken);
|
||||||
|
// List<int> getTokenList = changeStringListToIntList(token!);
|
||||||
|
//
|
||||||
|
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
|
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
|
//
|
||||||
|
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||||
|
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||||
|
//
|
||||||
|
// IoSenderManage.getWifiListCommand(
|
||||||
|
// keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
||||||
|
// userID: await Storage.getUid(),
|
||||||
|
// token: getTokenList,
|
||||||
|
// needAuthor: 1,
|
||||||
|
// publicKey: publicKeyDataList,
|
||||||
|
// privateKey: getPrivateKeyList,
|
||||||
|
// );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置自动落锁数据解析
|
||||||
|
Future<void> _replyGetWifiListParameters(Reply reply) async {
|
||||||
|
final int status = reply.data[2];
|
||||||
|
switch(status){
|
||||||
|
case 0x00:
|
||||||
|
//成功
|
||||||
|
// showEasyLoading();
|
||||||
|
dismissEasyLoading();
|
||||||
|
state.sureBtnState.value = 0;
|
||||||
|
|
||||||
|
if (reply.data[6] > 0) {
|
||||||
|
reply.data.removeRange(0, 7);
|
||||||
|
// 把得到的数据按33位分割成数组 然后塞进一个新的数组里面
|
||||||
|
final List<List<int>> getList = splitList(reply.data, 33);
|
||||||
|
final List<Map<String, String>> uploadList = <Map<String, String>>[];
|
||||||
|
for (int i = 0; i < getList.length; i++) {
|
||||||
|
final List<int> indexList = getList[i];
|
||||||
|
final Map<String, String> indexMap = <String, String>{};
|
||||||
|
final List<int> wifiName = indexList.sublist(0, 32);
|
||||||
|
indexMap['wifiName'] = utf8String(wifiName);
|
||||||
|
indexMap['rssi'] = (indexList.last - 255).toString();
|
||||||
|
uploadList.add(indexMap);
|
||||||
|
state.wifiNameDataList.value = uploadList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取wifi列表
|
||||||
|
Future<void> senderGetWifiListWifiAction() async {
|
||||||
|
if(state.sureBtnState.value == 1){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
state.sureBtnState.value = 1;
|
||||||
|
|
||||||
|
showEasyLoading();
|
||||||
|
showBlueConnetctToastTimer(action: (){
|
||||||
|
dismissEasyLoading();
|
||||||
|
state.sureBtnState.value = 0;
|
||||||
|
});
|
||||||
|
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||||
|
if (connectionState == BluetoothConnectionState.connected){
|
||||||
|
IoSenderManage.gatewayGetWifiCommand(
|
||||||
|
userID: await Storage.getUid(),
|
||||||
|
);
|
||||||
|
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||||
|
dismissEasyLoading();
|
||||||
|
state.sureBtnState.value = 0;
|
||||||
|
cancelBlueConnetctToastTimer();
|
||||||
|
if(state.ifCurrentScreen.value == true){
|
||||||
|
showBlueConnetctToast();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, isAddEquipment: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onReady() {
|
||||||
|
super.onReady();
|
||||||
|
|
||||||
|
_initReplySubscription();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onInit() {
|
||||||
|
super.onInit();
|
||||||
|
|
||||||
|
senderGetWifiListWifiAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onClose() {
|
||||||
|
super.onClose();
|
||||||
|
_replySubscription.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,182 @@
|
|||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
import '../../../../appRouters.dart';
|
||||||
|
import '../../../../app_settings/app_colors.dart';
|
||||||
|
import '../../../../tools/appRouteObserver.dart';
|
||||||
|
import '../../../../tools/noData.dart';
|
||||||
|
import '../../../../tools/submitBtn.dart';
|
||||||
|
import '../../../../tools/titleAppBar.dart';
|
||||||
|
import 'gatewayGetWifiList_logic.dart';
|
||||||
|
import 'gatewayGetWifiList_state.dart';
|
||||||
|
|
||||||
|
class GatewayGetWifiListPage extends StatefulWidget {
|
||||||
|
const GatewayGetWifiListPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<GatewayGetWifiListPage> createState() => _GatewayGetWifiListPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _GatewayGetWifiListPageState extends State<GatewayGetWifiListPage> with RouteAware{
|
||||||
|
final GatewayGetWifiListLogic logic = Get.put(GatewayGetWifiListLogic());
|
||||||
|
final GatewayGetWifiListState state = Get.find<GatewayGetWifiListLogic>().state;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
appBar: TitleAppBar(
|
||||||
|
barTitle: 'WIFI列表'.tr,
|
||||||
|
haveBack: true,
|
||||||
|
actionsList: <Widget>[
|
||||||
|
TextButton(
|
||||||
|
child: Text(
|
||||||
|
'刷新'.tr, style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
||||||
|
),
|
||||||
|
onPressed: logic.senderGetWifiListWifiAction,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
backgroundColor: AppColors.mainColor),
|
||||||
|
body: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
child: Obx(() => state.wifiNameDataList.value.isNotEmpty ? ListView.builder(
|
||||||
|
itemCount: state.wifiNameDataList.value.length,
|
||||||
|
itemBuilder: (BuildContext c, int index) {
|
||||||
|
Map wifiNameStr = state.wifiNameDataList.value[index];
|
||||||
|
return _messageListItem(wifiNameStr['wifiName'], wifiNameStr['rssi'], () {
|
||||||
|
Get.toNamed(Routers.gatewayConfigurationWifiPage, arguments: {
|
||||||
|
'wifiName': wifiNameStr['wifiName'],
|
||||||
|
'macAddress': state.macAddress
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}) : NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 64.h)),
|
||||||
|
),
|
||||||
|
SubmitBtn(
|
||||||
|
btnName: '手动配网'.tr,
|
||||||
|
fontSize: 28.sp,
|
||||||
|
borderRadius: 20.w,
|
||||||
|
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||||
|
onClick: () {
|
||||||
|
Get.toNamed(Routers.gatewayConfigurationWifiPage, arguments: {
|
||||||
|
'wifiName': '',
|
||||||
|
'macAddress': state.macAddress
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
SizedBox(
|
||||||
|
height: 64.h,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _messageListItem(String wifiName, String rssi, Function() action) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: action,
|
||||||
|
child: Container(
|
||||||
|
height: 90.h,
|
||||||
|
width: 1.sw,
|
||||||
|
margin: EdgeInsets.only(bottom: 2.h),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(10.w),
|
||||||
|
),
|
||||||
|
child: Container(
|
||||||
|
width: 1.sw,
|
||||||
|
height: 80.h,
|
||||||
|
margin: EdgeInsets.only(left: 20.w, right: 40.w),
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
SizedBox(
|
||||||
|
height: 79.h,
|
||||||
|
width: 1.sw - 20.w*2,
|
||||||
|
child: Row(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: <Widget>[
|
||||||
|
Flexible(
|
||||||
|
child: Text(
|
||||||
|
'$wifiName(${rssi}db)',
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 22.sp, color: AppColors.blackColor),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Text(
|
||||||
|
// rssi,
|
||||||
|
// maxLines: 1,
|
||||||
|
// overflow: TextOverflow.ellipsis,
|
||||||
|
// style: TextStyle(
|
||||||
|
// fontSize: 22.sp, color: AppColors.blackColor),
|
||||||
|
// )
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
height: 1.h,
|
||||||
|
color: AppColors.greyLineColor,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeDependencies() {
|
||||||
|
super.didChangeDependencies();
|
||||||
|
|
||||||
|
/// 路由订阅
|
||||||
|
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
/// 取消路由订阅
|
||||||
|
AppRouteObserver().routeObserver.unsubscribe(this);
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 从上级界面进入 当前界面即将出现
|
||||||
|
@override
|
||||||
|
void didPush() {
|
||||||
|
super.didPush();
|
||||||
|
state.ifCurrentScreen.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 返回上一个界面 当前界面即将消失
|
||||||
|
@override
|
||||||
|
void didPop() {
|
||||||
|
super.didPop();
|
||||||
|
logic.cancelBlueConnetctToastTimer();
|
||||||
|
if (EasyLoading.isShow) {
|
||||||
|
EasyLoading.dismiss(animation: true);
|
||||||
|
}
|
||||||
|
state.ifCurrentScreen.value = false;
|
||||||
|
state.sureBtnState.value = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 从下级返回 当前界面即将出现
|
||||||
|
@override
|
||||||
|
void didPopNext() {
|
||||||
|
super.didPopNext();
|
||||||
|
state.ifCurrentScreen.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 进入下级界面 当前界面即将消失
|
||||||
|
@override
|
||||||
|
void didPushNext() {
|
||||||
|
super.didPushNext();
|
||||||
|
logic.cancelBlueConnetctToastTimer();
|
||||||
|
if (EasyLoading.isShow) {
|
||||||
|
EasyLoading.dismiss(animation: true);
|
||||||
|
}
|
||||||
|
state.ifCurrentScreen.value = false;
|
||||||
|
state.sureBtnState.value = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
class GatewayGetWifiListState{
|
||||||
|
GatewayGetWifiListState() {
|
||||||
|
var map = Get.arguments;
|
||||||
|
if (map['macAddress'] != null && map['macAddress'] != '') {
|
||||||
|
macAddress = map['macAddress'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final RxList<Map<String, String>> wifiNameDataList = <Map<String, String>>[].obs;
|
||||||
|
|
||||||
|
String macAddress = '';
|
||||||
|
RxBool ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||||
|
RxInt sureBtnState = 0.obs;
|
||||||
|
}
|
||||||
@ -32,6 +32,15 @@ class SelectGatewayListLogic extends BaseGetXController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void stopScanBlueList() {
|
||||||
|
// BlueManage().disconnect();
|
||||||
|
BlueManage().stopScan();
|
||||||
|
}
|
||||||
|
|
||||||
|
void blueDisconnect() {
|
||||||
|
BlueManage().disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> getNearByLimits() async {
|
Future<void> getNearByLimits() async {
|
||||||
if (!Platform.isIOS) {
|
if (!Platform.isIOS) {
|
||||||
final bool bluetoothRequest = await PermissionDialog.requestBluetooth();
|
final bool bluetoothRequest = await PermissionDialog.requestBluetooth();
|
||||||
@ -45,12 +54,19 @@ class SelectGatewayListLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 点击连接设备
|
// 点击连接设备
|
||||||
void connect(String deviceName) {
|
void connect(ScanResult device) {
|
||||||
BlueManage().blueSendData(deviceName, (BluetoothConnectionState state) async {
|
showEasyLoading();
|
||||||
|
showBlueConnetctToastTimer(action: () {
|
||||||
|
dismissEasyLoading();
|
||||||
|
});
|
||||||
|
BlueManage().blueSendData(device.advertisementData.advName, (BluetoothConnectionState state) async {
|
||||||
// AppLog.log('点击要添加的设备了');
|
// AppLog.log('点击要添加的设备了');
|
||||||
if (state == BluetoothConnectionState.connected) {
|
if (state == BluetoothConnectionState.connected) {
|
||||||
Get.toNamed(Routers.gatewayConfigurationWifiPage);
|
dismissEasyLoading();
|
||||||
} else if (state == BluetoothConnectionState.disconnected) {
|
Get.toNamed(Routers.gatewayGetWifiListPage, arguments: {
|
||||||
|
'macAddress':device.device.remoteId.str
|
||||||
|
});
|
||||||
|
} else{
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
}
|
}
|
||||||
}, isAddEquipment: true);
|
}, isAddEquipment: true);
|
||||||
|
|||||||
@ -1,12 +1,15 @@
|
|||||||
|
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/tools/noData.dart';
|
import 'package:star_lock/tools/noData.dart';
|
||||||
|
|
||||||
import '../../../../appRouters.dart';
|
import '../../../../appRouters.dart';
|
||||||
import '../../../../app_settings/app_colors.dart';
|
import '../../../../app_settings/app_colors.dart';
|
||||||
|
import '../../../../tools/appRouteObserver.dart';
|
||||||
import '../../../../tools/titleAppBar.dart';
|
import '../../../../tools/titleAppBar.dart';
|
||||||
import 'selectGatewayList_logic.dart';
|
import 'selectGatewayList_logic.dart';
|
||||||
import 'selectGatewayList_state.dart';
|
import 'selectGatewayList_state.dart';
|
||||||
@ -18,7 +21,7 @@ class SelectGatewayListPage extends StatefulWidget {
|
|||||||
State<SelectGatewayListPage> createState() => _SelectGatewayListPageState();
|
State<SelectGatewayListPage> createState() => _SelectGatewayListPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _SelectGatewayListPageState extends State<SelectGatewayListPage> {
|
class _SelectGatewayListPageState extends State<SelectGatewayListPage> with RouteAware {
|
||||||
final SelectGatewayListLogic logic = Get.put(SelectGatewayListLogic());
|
final SelectGatewayListLogic logic = Get.put(SelectGatewayListLogic());
|
||||||
final SelectGatewayListState state = Get.find<SelectGatewayListLogic>().state;
|
final SelectGatewayListState state = Get.find<SelectGatewayListLogic>().state;
|
||||||
|
|
||||||
@ -29,7 +32,14 @@ class _SelectGatewayListPageState extends State<SelectGatewayListPage> {
|
|||||||
appBar: TitleAppBar(
|
appBar: TitleAppBar(
|
||||||
barTitle: '选择网关'.tr,
|
barTitle: '选择网关'.tr,
|
||||||
haveBack: true,
|
haveBack: true,
|
||||||
backgroundColor: AppColors.mainColor),
|
backgroundColor: AppColors.mainColor,
|
||||||
|
actionsList: <Widget>[
|
||||||
|
CupertinoActivityIndicator(
|
||||||
|
radius: 18.w,
|
||||||
|
color: AppColors.whiteColor,
|
||||||
|
),
|
||||||
|
SizedBox(width: 30.w)
|
||||||
|
]),
|
||||||
body:
|
body:
|
||||||
// ListView.builder(
|
// ListView.builder(
|
||||||
// itemCount: 10,
|
// itemCount: 10,
|
||||||
@ -43,15 +53,14 @@ class _SelectGatewayListPageState extends State<SelectGatewayListPage> {
|
|||||||
// });
|
// });
|
||||||
// })
|
// })
|
||||||
Obx(() =>
|
Obx(() =>
|
||||||
state.devices.isNotEmpty?
|
|
||||||
ListView.builder(
|
ListView.builder(
|
||||||
itemCount: state.devices.length,
|
itemCount: state.devices.length,
|
||||||
itemBuilder: (BuildContext c, int index) {
|
itemBuilder: (BuildContext c, int index) {
|
||||||
final ScanResult device = state.devices[index];
|
final ScanResult device = state.devices[index];
|
||||||
return _selectGatewayListListItem(device, () {
|
return _selectGatewayListListItem(device, () {
|
||||||
logic.connect(device.advertisementData.advName);
|
logic.connect(device);
|
||||||
});
|
});
|
||||||
}):NoData()
|
})
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -131,4 +140,53 @@ class _SelectGatewayListPageState extends State<SelectGatewayListPage> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeDependencies() {
|
||||||
|
super.didChangeDependencies();
|
||||||
|
|
||||||
|
/// 路由订阅
|
||||||
|
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
/// 取消路由订阅
|
||||||
|
AppRouteObserver().routeObserver.unsubscribe(this);
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 从上级界面进入 当前界面即将出现
|
||||||
|
@override
|
||||||
|
void didPush() {
|
||||||
|
super.didPush();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 返回上一个界面 当前界面即将消失
|
||||||
|
@override
|
||||||
|
void didPop() {
|
||||||
|
super.didPop();
|
||||||
|
|
||||||
|
EasyLoading.isShow ? EasyLoading.dismiss() : null;
|
||||||
|
logic.cancelBlueConnetctToastTimer();
|
||||||
|
logic.blueDisconnect();
|
||||||
|
logic.stopScanBlueList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 从下级返回 当前界面即将出现
|
||||||
|
@override
|
||||||
|
void didPopNext() {
|
||||||
|
super.didPopNext();
|
||||||
|
logic.blueDisconnect();
|
||||||
|
logic.startScanBlueList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 进入下级界面 当前界面即将消失
|
||||||
|
@override
|
||||||
|
void didPushNext() {
|
||||||
|
super.didPushNext();
|
||||||
|
logic.cancelBlueConnetctToastTimer();
|
||||||
|
logic.stopScanBlueList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
23
lib/mine/gateway/gatewayDetail/gatewayDetail_logic.dart
Normal file
23
lib/mine/gateway/gatewayDetail/gatewayDetail_logic.dart
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
|
|
||||||
|
import '../../../login/login/entity/LoginEntity.dart';
|
||||||
|
import '../../../network/api_repository.dart';
|
||||||
|
import 'gatewayDetail_state.dart';
|
||||||
|
|
||||||
|
class GatewayDetailLogic extends BaseGetXController{
|
||||||
|
GatewayDetailState state = GatewayDetailState();
|
||||||
|
|
||||||
|
Future<void> deletGateway() async{
|
||||||
|
final LoginEntity entity = await ApiRepository.to.gatewayDelet(
|
||||||
|
gatewayId: state.getewayItemData.value.gatewayId ?? 0,
|
||||||
|
);
|
||||||
|
if(entity.errorCode!.codeIsSuccessful){
|
||||||
|
showToast('删除成功'.tr, something:(){
|
||||||
|
// eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
|
||||||
|
Get.back();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
@ -7,8 +8,11 @@ import '../../../appRouters.dart';
|
|||||||
import '../../../app_settings/app_colors.dart';
|
import '../../../app_settings/app_colors.dart';
|
||||||
import '../../../tools/commonItem.dart';
|
import '../../../tools/commonItem.dart';
|
||||||
import '../../../tools/showTFView.dart';
|
import '../../../tools/showTFView.dart';
|
||||||
|
import '../../../tools/showTipView.dart';
|
||||||
import '../../../tools/submitBtn.dart';
|
import '../../../tools/submitBtn.dart';
|
||||||
import '../../../tools/titleAppBar.dart';
|
import '../../../tools/titleAppBar.dart';
|
||||||
|
import 'gatewayDetail_logic.dart';
|
||||||
|
import 'gatewayDetail_state.dart';
|
||||||
|
|
||||||
class GatewayDetailPage extends StatefulWidget {
|
class GatewayDetailPage extends StatefulWidget {
|
||||||
const GatewayDetailPage({Key? key}) : super(key: key);
|
const GatewayDetailPage({Key? key}) : super(key: key);
|
||||||
@ -18,7 +22,8 @@ class GatewayDetailPage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _GatewayDetailPageState extends State<GatewayDetailPage> {
|
class _GatewayDetailPageState extends State<GatewayDetailPage> {
|
||||||
final TextEditingController _changeGatewayNameController = TextEditingController();
|
final GatewayDetailLogic logic = Get.put(GatewayDetailLogic());
|
||||||
|
final GatewayDetailState state = Get.find<GatewayDetailLogic>().state;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -28,29 +33,43 @@ class _GatewayDetailPageState extends State<GatewayDetailPage> {
|
|||||||
barTitle: '网关'.tr,
|
barTitle: '网关'.tr,
|
||||||
haveBack: true,
|
haveBack: true,
|
||||||
backgroundColor: AppColors.mainColor),
|
backgroundColor: AppColors.mainColor),
|
||||||
body: ListView(
|
body: Obx(() => ListView(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
CommonItem(
|
CommonItem(
|
||||||
leftTitel: '名称'.tr,
|
leftTitel: '名称'.tr,
|
||||||
rightTitle: '星锁网关',
|
rightTitle: state.getewayItemData.value.gatewayName,
|
||||||
isHaveLine: true,
|
isHaveLine: true,
|
||||||
isHaveDirection: true,
|
isHaveDirection: true,
|
||||||
action: () {
|
action: () {
|
||||||
showCupertinoAlertDialog(context);
|
ShowTipView().showTFViewAlertDialog(
|
||||||
|
state.changeGatewayNameController,
|
||||||
|
'请输入姓名'.tr,
|
||||||
|
'', () {
|
||||||
|
if (state.changeGatewayNameController.text.isEmpty) {
|
||||||
|
logic.showToast('请输入姓名'.tr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Get.back();
|
||||||
|
// state.typeName.value = state.changeNameController.text;
|
||||||
|
// logic.editICCardData();
|
||||||
|
}, inputFormatters: <TextInputFormatter>[
|
||||||
|
FilteringTextInputFormatter.deny('\n'),
|
||||||
|
LengthLimitingTextInputFormatter(50),
|
||||||
|
]);
|
||||||
}),
|
}),
|
||||||
CommonItem(
|
CommonItem(
|
||||||
leftTitel: '状态'.tr,
|
leftTitel: '状态'.tr,
|
||||||
rightTitle: '在线',
|
rightTitle: state.getewayItemData.value.isOnline == 1 ? '在线' : '离线',
|
||||||
isHaveLine: true,
|
isHaveLine: true,
|
||||||
isHaveDirection: false),
|
isHaveDirection: false),
|
||||||
CommonItem(
|
CommonItem(
|
||||||
leftTitel: 'WiFi名称'.tr,
|
leftTitel: 'WiFi名称'.tr,
|
||||||
rightTitle: 'XinHongJia',
|
rightTitle: state.getewayItemData.value.networkName,
|
||||||
isHaveLine: true,
|
isHaveLine: true,
|
||||||
isHaveDirection: false),
|
isHaveDirection: false),
|
||||||
CommonItem(
|
CommonItem(
|
||||||
leftTitel: '网络MAC'.tr,
|
leftTitel: '网络MAC'.tr,
|
||||||
rightTitle: '39:23:df:34:12',
|
rightTitle: state.getewayItemData.value.networkMac,
|
||||||
isHaveLine: false,
|
isHaveLine: false,
|
||||||
isHaveDirection: false),
|
isHaveDirection: false),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
@ -58,7 +77,7 @@ class _GatewayDetailPageState extends State<GatewayDetailPage> {
|
|||||||
),
|
),
|
||||||
CommonItem(
|
CommonItem(
|
||||||
leftTitel: '附近的锁'.tr,
|
leftTitel: '附近的锁'.tr,
|
||||||
rightTitle: '2',
|
rightTitle: state.getewayItemData.value.lockNum.toString(),
|
||||||
isHaveLine: true,
|
isHaveLine: true,
|
||||||
isHaveDirection: true,
|
isHaveDirection: true,
|
||||||
action: () {
|
action: () {
|
||||||
@ -80,21 +99,11 @@ class _GatewayDetailPageState extends State<GatewayDetailPage> {
|
|||||||
fontSize: 32.sp,
|
fontSize: 32.sp,
|
||||||
margin: EdgeInsets.only(left: 30.w, right: 30.w),
|
margin: EdgeInsets.only(left: 30.w, right: 30.w),
|
||||||
padding: EdgeInsets.only(top: 15.w, bottom: 15.w),
|
padding: EdgeInsets.only(top: 15.w, bottom: 15.w),
|
||||||
onClick: () {}),
|
onClick: () {
|
||||||
|
ShowTipView().showIosTipWithContentDialog('确定要删除吗?'.tr, logic.deletGateway);
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
),
|
)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改名字
|
|
||||||
void showCupertinoAlertDialog(BuildContext context) {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return ShowTFView(
|
|
||||||
title: '修改姓名'.tr,
|
|
||||||
tipTitle: '请输入'.tr,
|
|
||||||
controller: _changeGatewayNameController);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
18
lib/mine/gateway/gatewayDetail/gatewayDetail_state.dart
Normal file
18
lib/mine/gateway/gatewayDetail/gatewayDetail_state.dart
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
import '../../mineSet/transferGateway/selectGetewayList_entity.dart';
|
||||||
|
|
||||||
|
class GatewayDetailState{
|
||||||
|
GatewayDetailState() {
|
||||||
|
var map = Get.arguments;
|
||||||
|
if (map['getewayItemData'] != null && map['getewayItemData'] != '') {
|
||||||
|
getewayItemData.value = map['getewayItemData'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rx<GetewayItemData> getewayItemData = GetewayItemData().obs;
|
||||||
|
|
||||||
|
final TextEditingController changeGatewayNameController = TextEditingController();
|
||||||
|
}
|
||||||
@ -1,9 +1,11 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:star_lock/tools/noData.dart';
|
||||||
|
|
||||||
import '../../../appRouters.dart';
|
import '../../../appRouters.dart';
|
||||||
import '../../../app_settings/app_colors.dart';
|
import '../../../app_settings/app_colors.dart';
|
||||||
|
import '../../../tools/EasyRefreshTool.dart';
|
||||||
import '../../../tools/storage.dart';
|
import '../../../tools/storage.dart';
|
||||||
import '../../../tools/titleAppBar.dart';
|
import '../../../tools/titleAppBar.dart';
|
||||||
import '../../mineSet/transferGateway/selectGetewayList_entity.dart';
|
import '../../mineSet/transferGateway/selectGetewayList_entity.dart';
|
||||||
@ -50,7 +52,7 @@ class _GatewayListPageState extends State<GatewayListPage> {
|
|||||||
actionsList: <Widget>[
|
actionsList: <Widget>[
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Get.toNamed(Routers.selectGatewayTypeNextTipPage);
|
Get.toNamed(Routers.selectGatewayTypeNextTipPage)!.then((value) => getHttpData(isRefresh: true));
|
||||||
},
|
},
|
||||||
child: Image.asset(
|
child: Image.asset(
|
||||||
'images/icon_add_white.png',
|
'images/icon_add_white.png',
|
||||||
@ -62,23 +64,32 @@ class _GatewayListPageState extends State<GatewayListPage> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: ListView.separated(
|
body: EasyRefreshTool(
|
||||||
itemCount: state.getewayListData.length,
|
onRefresh: () {
|
||||||
itemBuilder: (BuildContext c, int index) {
|
getHttpData(isRefresh: true);
|
||||||
final GetewayItemData item = state.getewayListData[index];
|
},
|
||||||
return _gatewatListItem(item, () {
|
onLoad: () {
|
||||||
Get.toNamed(Routers.gatewayDetailPage);
|
getHttpData(isRefresh: false);
|
||||||
});
|
},
|
||||||
},
|
child: state.getewayListData.isNotEmpty ?ListView.separated(
|
||||||
separatorBuilder: (BuildContext context, int index) {
|
itemCount: state.getewayListData.length,
|
||||||
return Divider(
|
itemBuilder: (BuildContext c, int index) {
|
||||||
height: 1,
|
final GetewayItemData item = state.getewayListData[index];
|
||||||
color: AppColors.greyLineColor,
|
return _gatewatListItem(item, () {
|
||||||
indent: 20.w,
|
Get.toNamed(Routers.gatewayDetailPage, arguments: {
|
||||||
endIndent: 0,
|
'getewayItemData': item
|
||||||
);
|
})!.then((value) => getHttpData(isRefresh: true));
|
||||||
},
|
});
|
||||||
),
|
},
|
||||||
|
separatorBuilder: (BuildContext context, int index) {
|
||||||
|
return Divider(
|
||||||
|
height: 1,
|
||||||
|
color: AppColors.greyLineColor,
|
||||||
|
indent: 20.w,
|
||||||
|
endIndent: 0,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
):NoData()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -148,7 +148,9 @@ abstract class Api {
|
|||||||
final String transferLockURL = '/room/transfer'; // 转移智能锁
|
final String transferLockURL = '/room/transfer'; // 转移智能锁
|
||||||
final String removeBadLockURL = '/lock/removeBadLock'; // 移除坏锁
|
final String removeBadLockURL = '/lock/removeBadLock'; // 移除坏锁
|
||||||
|
|
||||||
final String gatewaykListURL = '/gateway/list'; // 转网关列表
|
final String gatewaykListURL = '/gateway/list'; // 网关列表
|
||||||
|
final String addGatewayURL = '/gateway/add'; // 添加网关
|
||||||
|
final String deletGatewayURL = '/gateway/delete'; // 删除网关
|
||||||
final String transferGatewayConfirmURL =
|
final String transferGatewayConfirmURL =
|
||||||
'/plug/transferPlugConfirm'; // 转移网关确认
|
'/plug/transferPlugConfirm'; // 转移网关确认
|
||||||
final String transferGatewayURL = '/plug/transfer'; // 转移网关
|
final String transferGatewayURL = '/plug/transfer'; // 转移网关
|
||||||
|
|||||||
@ -1720,6 +1720,36 @@ class ApiProvider extends BaseProvider {
|
|||||||
gatewaykListURL.toUrl,
|
gatewaykListURL.toUrl,
|
||||||
jsonEncode({'pageNo': pageNo, 'pageSize': pageSize}));
|
jsonEncode({'pageNo': pageNo, 'pageSize': pageSize}));
|
||||||
|
|
||||||
|
// 添加网关
|
||||||
|
Future<Response> addGatewayNetwork(
|
||||||
|
String gatewayName,
|
||||||
|
String gatewayMac,
|
||||||
|
String serialNumber,
|
||||||
|
int gatewayType,
|
||||||
|
String networkName,
|
||||||
|
String networkMac,
|
||||||
|
String version,
|
||||||
|
) => post(
|
||||||
|
addGatewayURL.toUrl,
|
||||||
|
jsonEncode({
|
||||||
|
'gatewayName': gatewayName,
|
||||||
|
'gatewayMac': gatewayMac,
|
||||||
|
'serialNumber': serialNumber,
|
||||||
|
'gatewayType': gatewayType,
|
||||||
|
'networkName': networkName,
|
||||||
|
'networkMac': networkMac,
|
||||||
|
'version': version,
|
||||||
|
}));
|
||||||
|
|
||||||
|
// 删除网关
|
||||||
|
Future<Response> deletGateway(
|
||||||
|
int gatewayId,
|
||||||
|
) => post(
|
||||||
|
deletGatewayURL.toUrl,
|
||||||
|
jsonEncode({
|
||||||
|
'gatewayId': gatewayId,
|
||||||
|
}));
|
||||||
|
|
||||||
// 转移网关确认
|
// 转移网关确认
|
||||||
Future<Response> transferGatewayConfirmInfoData(
|
Future<Response> transferGatewayConfirmInfoData(
|
||||||
String receiverUsername, String type, String countryCode) =>
|
String receiverUsername, String type, String countryCode) =>
|
||||||
|
|||||||
@ -1903,6 +1903,28 @@ class ApiRepository {
|
|||||||
return GetewayDataEntity.fromJson(res.body);
|
return GetewayDataEntity.fromJson(res.body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 添加网关
|
||||||
|
Future<LoginEntity> gatewayDistributionNetwork({
|
||||||
|
required String gatewayName,
|
||||||
|
required String gatewayMac,
|
||||||
|
required String serialNumber,
|
||||||
|
required int gatewayType,
|
||||||
|
required String networkName,
|
||||||
|
required String networkMac,
|
||||||
|
required String version,
|
||||||
|
}) async {
|
||||||
|
final res = await apiProvider.addGatewayNetwork(gatewayName, gatewayMac, serialNumber, gatewayType, networkName, networkMac, version);
|
||||||
|
return LoginEntity.fromJson(res.body);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除网关
|
||||||
|
Future<LoginEntity> gatewayDelet({
|
||||||
|
required int gatewayId,
|
||||||
|
}) async {
|
||||||
|
final res = await apiProvider.deletGateway(gatewayId);
|
||||||
|
return LoginEntity.fromJson(res.body);
|
||||||
|
}
|
||||||
|
|
||||||
// 转移网关确认
|
// 转移网关确认
|
||||||
Future<RecipientInformationEntity> transferGatewayConfirmInfoData(
|
Future<RecipientInformationEntity> transferGatewayConfirmInfoData(
|
||||||
{required String receiverUsername,
|
{required String receiverUsername,
|
||||||
|
|||||||
@ -91,8 +91,9 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||||||
# 1.0.78+2024082701:测试国际化功能
|
# 1.0.78+2024082701:测试国际化功能
|
||||||
# 1.0.79+2024083001:测试所有国家国际化功能
|
# 1.0.79+2024083001:测试所有国家国际化功能
|
||||||
# 1.0.79+2024083001:测试开完锁数据上传功能
|
# 1.0.79+2024083001:测试开完锁数据上传功能
|
||||||
|
# 1.0.80+2024091901:添加网关功能给谢敬调试
|
||||||
|
|
||||||
version: 1.0.79+2024090201
|
version: 1.0.80+2024091901
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=2.12.0 <3.0.0'
|
sdk: '>=2.12.0 <3.0.0'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user