完善添加锁流程,添加长按闭锁功能
This commit is contained in:
parent
b8278db9ef
commit
8c2fdf6d8a
@ -61,7 +61,14 @@ class BlueManage {
|
|||||||
_sendStreamSubscription ??= EventBusManager().eventBus!.on<EventSendModel>().listen((EventSendModel model) {
|
_sendStreamSubscription ??= EventBusManager().eventBus!.on<EventSendModel>().listen((EventSendModel model) {
|
||||||
if (model.sendChannel == DataChannel.ble) {
|
if (model.sendChannel == DataChannel.ble) {
|
||||||
// managerAppWriteData(model.data);
|
// managerAppWriteData(model.data);
|
||||||
writeCharacteristicWithResponse(model.data);
|
_flutterReactiveBle!.statusStream.listen((status) {
|
||||||
|
if (status == BleStatus.ready) {
|
||||||
|
// 蓝牙已开启,可以进行蓝牙操作
|
||||||
|
writeCharacteristicWithResponse(model.data);
|
||||||
|
}else{
|
||||||
|
Get.log("写入数据 蓝牙未开启,不能进行蓝牙操作");
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -69,43 +76,57 @@ class BlueManage {
|
|||||||
/// 开始扫描蓝牙设备
|
/// 开始扫描蓝牙设备
|
||||||
void startScan({List<Uuid>? idList}) {
|
void startScan({List<Uuid>? idList}) {
|
||||||
// List<Service>? list = _flutterReactiveBle!.getDiscoveredServices("deviceId").then((value));
|
// List<Service>? list = _flutterReactiveBle!.getDiscoveredServices("deviceId").then((value));
|
||||||
|
_flutterReactiveBle!.statusStream.listen((status) {
|
||||||
scanDevices.clear();
|
if (status == BleStatus.ready) {
|
||||||
_scanSubscription = _flutterReactiveBle!.scanForDevices(withServices:[]).listen((device) {
|
// 蓝牙已开启,可以进行蓝牙操作
|
||||||
// 判断名字为空的直接剔除
|
scanDevices.clear();
|
||||||
if (device.name.isEmpty) {
|
_scanSubscription = _flutterReactiveBle!.scanForDevices(withServices:[]).listen((device) {
|
||||||
return;
|
// 判断名字为空的直接剔除
|
||||||
|
if (device.name.isEmpty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
print("startScanDevice:$device");
|
||||||
|
if (((device.serviceUuids.isNotEmpty ? device.serviceUuids[0] : "").toString().contains("758824")) && (device.rssi >= -100)) {
|
||||||
|
// 查询id相同的元素
|
||||||
|
final knownDeviceIndex = scanDevices.indexWhere((d) => d.id == device.id);
|
||||||
|
// 不存在的时候返回-1
|
||||||
|
if (knownDeviceIndex >= 0) {
|
||||||
|
scanDevices[knownDeviceIndex] = device;
|
||||||
|
} else {
|
||||||
|
scanDevices.add(device);
|
||||||
|
}
|
||||||
|
EventBusManager().eventBusFir(scanDevices);
|
||||||
|
}
|
||||||
|
}, onError: (Object e) {
|
||||||
|
print('Device scan fails with error: $e');
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
Get.log("开始扫描 蓝牙未开启,不能进行蓝牙操作");
|
||||||
}
|
}
|
||||||
print("startScanDevice:$device");
|
|
||||||
if (((device.serviceUuids.isNotEmpty ? device.serviceUuids[0] : "").toString().contains("758824")) && (device.rssi >= -100)) {
|
|
||||||
// 查询id相同的元素
|
|
||||||
final knownDeviceIndex = scanDevices.indexWhere((d) => d.id == device.id);
|
|
||||||
// 不存在的时候返回-1
|
|
||||||
if (knownDeviceIndex >= 0) {
|
|
||||||
scanDevices[knownDeviceIndex] = device;
|
|
||||||
} else {
|
|
||||||
scanDevices.add(device);
|
|
||||||
}
|
|
||||||
EventBusManager().eventBusFir(scanDevices);
|
|
||||||
}
|
|
||||||
}, onError: (Object e) {
|
|
||||||
print('Device scan fails with error: $e');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 调用发送数据
|
/// 调用发送数据
|
||||||
Future<void> bludSendData(String deviceName, ConnectStateCallBack stateCallBack, {bool isAddEquipment = false}) async {
|
Future<void> bludSendData(String deviceName, ConnectStateCallBack stateCallBack, {bool isAddEquipment = false}) async {
|
||||||
if(deviceConnectionState != DeviceConnectionState.connected){
|
_flutterReactiveBle!.statusStream.listen((status) {
|
||||||
if(isAddEquipment == false){
|
if (status == BleStatus.ready) {
|
||||||
startScan();
|
// 蓝牙已开启,可以进行蓝牙操作
|
||||||
}
|
if(deviceConnectionState != DeviceConnectionState.connected){
|
||||||
|
if(isAddEquipment == false){
|
||||||
|
startScan();
|
||||||
|
}
|
||||||
|
|
||||||
_connect(deviceName, (state){
|
_connect(deviceName, (state){
|
||||||
stateCallBack(deviceConnectionState!);
|
stateCallBack(deviceConnectionState!);
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
stateCallBack(deviceConnectionState!);
|
stateCallBack(deviceConnectionState!);
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
Get.log("调用发送数据 蓝牙未开启,不能进行蓝牙操作");
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 连接监听状态
|
/// 连接监听状态
|
||||||
|
|||||||
@ -501,18 +501,18 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
Get.back();
|
Get.back();
|
||||||
|
|
||||||
if(BlueManage().deviceConnectionState == DeviceConnectionState.connected){
|
// if(BlueManage().deviceConnectionState == DeviceConnectionState.connected){
|
||||||
// 如果是已连接状态 直接调用协议
|
// // 如果是已连接状态 直接调用协议
|
||||||
// 已配对 表示这把锁未被初始化,还处于被添加状态
|
// // 已配对 表示这把锁未被初始化,还处于被添加状态
|
||||||
if (state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == 1) {
|
// if (state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == 1) {
|
||||||
// 如果是锁拥有者直接删除锁,调用初始化协议
|
// // 如果是锁拥有者直接删除锁,调用初始化协议
|
||||||
factoryDataResetAction();
|
// factoryDataResetAction();
|
||||||
} else {
|
// } else {
|
||||||
// 不是锁拥有者,调用删除钥匙协议
|
// // 不是锁拥有者,调用删除钥匙协议
|
||||||
deletUserAction();
|
// deletUserAction();
|
||||||
}
|
// }
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (state.currentDeviceUUid.value.isNotEmpty) {
|
if (state.currentDeviceUUid.value.isNotEmpty) {
|
||||||
// 已经扫描到了当前设备 停止扫描,直接删除锁
|
// 已经扫描到了当前设备 停止扫描,直接删除锁
|
||||||
@ -539,6 +539,7 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
}else{
|
}else{
|
||||||
// 每秒判断获取是否搜到了当前设备
|
// 每秒判断获取是否搜到了当前设备
|
||||||
if (state.currentDeviceUUid.isNotEmpty) {
|
if (state.currentDeviceUUid.isNotEmpty) {
|
||||||
|
BlueManage().stopScan();
|
||||||
// 存在的时候销毁定时器,赋值
|
// 存在的时候销毁定时器,赋值
|
||||||
if(state.deletWaitScanTimer != null){
|
if(state.deletWaitScanTimer != null){
|
||||||
state.deletWaitScanTimer!.cancel();
|
state.deletWaitScanTimer!.cancel();
|
||||||
@ -546,7 +547,6 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
if(state.deletWaitScanCompleter != null){
|
if(state.deletWaitScanCompleter != null){
|
||||||
state.deletWaitScanCompleter!.complete();
|
state.deletWaitScanCompleter!.complete();
|
||||||
}
|
}
|
||||||
BlueManage().stopScan();
|
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
|
|
||||||
deletLockLogic();
|
deletLockLogic();
|
||||||
|
|||||||
@ -306,7 +306,7 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
// updateLockUserNo();
|
// updateLockUserNo();
|
||||||
|
|
||||||
if (state.isOpenLockNeedOnline.value == 0) {
|
if (state.isOpenLockNeedOnline.value == 0) {
|
||||||
openDoorAction();
|
openDoorAction(1);
|
||||||
} else {
|
} else {
|
||||||
getLockNetToken();
|
getLockNetToken();
|
||||||
}
|
}
|
||||||
@ -407,7 +407,7 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 点击开门事件
|
// 点击开门事件
|
||||||
Future<void> openDoorAction() async {
|
Future<void> openDoorAction(int openMode) async {
|
||||||
showBlueConnetctToastTimer(action:() {
|
showBlueConnetctToastTimer(action:() {
|
||||||
state.openLockBtnState.value = 0;
|
state.openLockBtnState.value = 0;
|
||||||
// state.animationController.reset();
|
// state.animationController.reset();
|
||||||
@ -428,7 +428,7 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
IoSenderManage.senderOpenLock(
|
IoSenderManage.senderOpenLock(
|
||||||
keyID: BlueManage().connectDeviceName,
|
keyID: BlueManage().connectDeviceName,
|
||||||
userID: await Storage.getUid(),
|
userID: await Storage.getUid(),
|
||||||
openMode: 1,
|
openMode: openMode,
|
||||||
openTime: DateTime.now().millisecondsSinceEpoch ~/ 1000,
|
openTime: DateTime.now().millisecondsSinceEpoch ~/ 1000,
|
||||||
onlineToken: state.lockNetToken,
|
onlineToken: state.lockNetToken,
|
||||||
token: getTokenList,
|
token: getTokenList,
|
||||||
@ -542,6 +542,7 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
if(state.openLockBtnState.value == 1){
|
if(state.openLockBtnState.value == 1){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
state.iSOpenLock.value = true;
|
||||||
state.iSClosedUnlockSuccessfulPopup.value = false;
|
state.iSClosedUnlockSuccessfulPopup.value = false;
|
||||||
state.openLockBtnState.value = 1;
|
state.openLockBtnState.value = 1;
|
||||||
state.animationController.forward();
|
state.animationController.forward();
|
||||||
@ -552,7 +553,7 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
} else {
|
} else {
|
||||||
if (state.isOpenLockNeedOnline.value == 0) {
|
if (state.isOpenLockNeedOnline.value == 0) {
|
||||||
// 不需要联网
|
// 不需要联网
|
||||||
openDoorAction();
|
openDoorAction(1);
|
||||||
} else {
|
} else {
|
||||||
// 需要联网
|
// 需要联网
|
||||||
getLockNetToken();
|
getLockNetToken();
|
||||||
@ -560,6 +561,23 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
startUnLock() {
|
||||||
|
if(state.openLockBtnState.value == 1){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
state.iSOpenLock.value = false;
|
||||||
|
state.iSClosedUnlockSuccessfulPopup.value = false;
|
||||||
|
state.openLockBtnState.value = 1;
|
||||||
|
state.animationController.forward();
|
||||||
|
|
||||||
|
if (state.lockUserNo == 0) {
|
||||||
|
// 电子钥匙lockUserNo为0 要先添加用户
|
||||||
|
addUserConnectBlue();
|
||||||
|
} else {
|
||||||
|
openDoorAction(32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
longPressCloseDoor(){
|
longPressCloseDoor(){
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -571,7 +589,7 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
state.lockNetToken = entity.data!.token!;
|
state.lockNetToken = entity.data!.token!;
|
||||||
print("state.lockNetToken:${state.lockNetToken}");
|
print("state.lockNetToken:${state.lockNetToken}");
|
||||||
openDoorAction();
|
openDoorAction(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -582,7 +600,7 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
lockUserNo: state.lockUserNo.toString());
|
lockUserNo: state.lockUserNo.toString());
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
if (state.isOpenLockNeedOnline.value == 0) {
|
if (state.isOpenLockNeedOnline.value == 0) {
|
||||||
openDoorAction();
|
openDoorAction(1);
|
||||||
} else {
|
} else {
|
||||||
getLockNetToken();
|
getLockNetToken();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,32 +76,37 @@ class _LockDetailPageState extends State<LockDetailPage>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Stack(children: [
|
return ListView(
|
||||||
Container(
|
children: [
|
||||||
width: 1.sw,
|
Stack(children: [
|
||||||
height: 1.sh - ScreenUtil().statusBarHeight * 2,
|
Container(
|
||||||
color: Colors.white,
|
width: 1.sw,
|
||||||
child: Column(
|
height: 1.sh - ScreenUtil().statusBarHeight * 2,
|
||||||
children: [
|
color: Colors.white,
|
||||||
topWidget(),
|
child: Column(
|
||||||
Expanded(child: Obx(() => bottomWidget())),
|
children: [
|
||||||
],
|
topWidget(),
|
||||||
),
|
Expanded(child: Obx(() => bottomWidget())),
|
||||||
),
|
],
|
||||||
Obx(() => Visibility(
|
|
||||||
visible: state.iSClosedUnlockSuccessfulPopup.value,
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
state.iSClosedUnlockSuccessfulPopup.value = false;
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
width: 1.sw,
|
|
||||||
height: 1.sh,
|
|
||||||
color: Colors.black.withOpacity(0.3),
|
|
||||||
child: _unlockSuccessWidget()),
|
|
||||||
),
|
),
|
||||||
))
|
),
|
||||||
]);
|
Obx(() => Visibility(
|
||||||
|
visible: state.iSClosedUnlockSuccessfulPopup.value,
|
||||||
|
// visible: true,
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
state.iSClosedUnlockSuccessfulPopup.value = false;
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
width: 1.sw,
|
||||||
|
height: 1.sh - ScreenUtil().statusBarHeight * 2,
|
||||||
|
color: Colors.black.withOpacity(0.3),
|
||||||
|
child: _unlockSuccessWidget()),
|
||||||
|
),
|
||||||
|
))
|
||||||
|
]),
|
||||||
|
],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget topWidget() {
|
Widget topWidget() {
|
||||||
@ -170,8 +175,8 @@ class _LockDetailPageState extends State<LockDetailPage>
|
|||||||
logic.startOpenLock();
|
logic.startOpenLock();
|
||||||
},
|
},
|
||||||
onLongPressStart: (details) {
|
onLongPressStart: (details) {
|
||||||
Get.log("长按开锁");
|
Get.log("长按闭锁");
|
||||||
// logic.startConnect();
|
logic.startUnLock();
|
||||||
},
|
},
|
||||||
)),
|
)),
|
||||||
],
|
],
|
||||||
@ -556,12 +561,12 @@ class _LockDetailPageState extends State<LockDetailPage>
|
|||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
children: [
|
children: [
|
||||||
Image.asset(
|
Image.asset(
|
||||||
'images/main/unlocked_bg.png',
|
state.iSOpenLock.value == true ? 'images/main/unlocked_bg.png' : 'images/main/locked_bg.png',
|
||||||
width: 358.w,
|
width: 358.w,
|
||||||
height: 348.h,
|
height: 348.h,
|
||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
top: 1.sh / 2 - 70.h,
|
top: (1.sh - ScreenUtil().statusBarHeight * 2)/ 2,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
|
|||||||
@ -30,6 +30,7 @@ class LockDetailState {
|
|||||||
|
|
||||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||||
var iSClosedUnlockSuccessfulPopup = false.obs; // 是否关闭了开锁成功弹窗
|
var iSClosedUnlockSuccessfulPopup = false.obs; // 是否关闭了开锁成功弹窗
|
||||||
|
var iSOpenLock = true.obs; // 是开锁还是关锁
|
||||||
Timer? closedUnlockSuccessfulTimer;
|
Timer? closedUnlockSuccessfulTimer;
|
||||||
|
|
||||||
//过渡动画控制器
|
//过渡动画控制器
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import 'package:get/get.dart';
|
|||||||
import 'package:star_lock/talk/call/callTalk.dart';
|
import 'package:star_lock/talk/call/callTalk.dart';
|
||||||
|
|
||||||
import '../../../../app_settings/app_colors.dart';
|
import '../../../../app_settings/app_colors.dart';
|
||||||
|
import '../../../../login/seletCountryRegion/common/index.dart';
|
||||||
import '../../../../talk/udp/udp_manage.dart';
|
import '../../../../talk/udp/udp_manage.dart';
|
||||||
import '../../../../talk/udp/udp_senderManage.dart';
|
import '../../../../talk/udp/udp_senderManage.dart';
|
||||||
import '../../../../tools/showTFView.dart';
|
import '../../../../tools/showTFView.dart';
|
||||||
@ -157,8 +158,7 @@ class _LockMonitoringPageState extends State<LockMonitoringPage> {
|
|||||||
Widget bottomBottomBtnWidget() {
|
Widget bottomBottomBtnWidget() {
|
||||||
return Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
|
return Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
|
||||||
// 接听
|
// 接听
|
||||||
Obx(() => bottomBtnItemWidget(
|
Obx(() => bottomBtnItemWidget(getAnswerBtnImg(), getAnswerBtnName(), Colors.white, () async {
|
||||||
getAnswerBtnImg(), getAnswerBtnName(), Colors.white, () async {
|
|
||||||
//获取麦克风权限
|
//获取麦克风权限
|
||||||
await logic.getPermissionStatus().then((value) async {
|
await logic.getPermissionStatus().then((value) async {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
@ -274,8 +274,17 @@ class _LockMonitoringPageState extends State<LockMonitoringPage> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<int> numbers = state.passwordTF.text.split('').map((char) => int.parse(char)).toList();
|
// List<int> numbers = state.passwordTF.text.split('').map((char) => int.parse(char)).toList();
|
||||||
// 开锁
|
// 开锁
|
||||||
|
// lockID
|
||||||
|
List<int> numbers = [];
|
||||||
|
List<int> lockIDData = utf8.encode(state.passwordTF.text);
|
||||||
|
numbers.addAll(lockIDData);
|
||||||
|
// topBytes = getFixedLengthList(lockIDData, 20 - lockIDData.length);
|
||||||
|
for (int i = 0; i < 6 - lockIDData.length; i++) {
|
||||||
|
numbers.add(0);
|
||||||
|
}
|
||||||
|
print("numbersnumbersnumbers:$numbers");
|
||||||
logic.udpOpenDoorAction(numbers);
|
logic.udpOpenDoorAction(numbers);
|
||||||
},
|
},
|
||||||
cancelClick: () {
|
cancelClick: () {
|
||||||
|
|||||||
@ -116,15 +116,17 @@ class LockMainLogic extends BaseGetXController {
|
|||||||
|
|
||||||
if (connectResult == ConnectivityResult.mobile) {
|
if (connectResult == ConnectivityResult.mobile) {
|
||||||
// _netType = "4G";
|
// _netType = "4G";
|
||||||
print("4G 4G 4G 4G 4G");
|
state.networkConnectionStatus.value = 1;
|
||||||
|
// print("4G 4G 4G 4G 4G");
|
||||||
} else if (connectResult == ConnectivityResult.wifi) {
|
} else if (connectResult == ConnectivityResult.wifi) {
|
||||||
// _netType = "wifi";
|
// _netType = "wifi";
|
||||||
print("wifi wifi wifi wifi wifi");
|
state.networkConnectionStatus.value = 1;
|
||||||
|
// print("wifi wifi wifi wifi wifi");
|
||||||
} else {
|
} else {
|
||||||
// _netType = "未连接";
|
// _netType = "未连接";
|
||||||
print("未连接 未连接 未连接 未连接 未连接");
|
state.networkConnectionStatus.value = 0;
|
||||||
|
// print("未连接 未连接 未连接 未连接 未连接");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 判断网络是否连接
|
/// 判断网络是否连接
|
||||||
@ -137,6 +139,11 @@ class LockMainLogic extends BaseGetXController {
|
|||||||
connectListener() async {
|
connectListener() async {
|
||||||
Connectivity().onConnectivityChanged.listen((ConnectivityResult result) {
|
Connectivity().onConnectivityChanged.listen((ConnectivityResult result) {
|
||||||
print("设置网络切换监听:$result");
|
print("设置网络切换监听:$result");
|
||||||
|
if(state.networkConnectionStatus.value == 0 && result != ConnectivityResult.none){
|
||||||
|
// 从无网络到有网络
|
||||||
|
state.networkConnectionStatus.value = 1;
|
||||||
|
getStarLockInfo();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,9 +167,9 @@ class LockMainLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// getLockInfo();
|
// getLockInfo();
|
||||||
// 设置网络变化监听
|
// 设置网络变化监听
|
||||||
// connectListener();
|
connectListener();
|
||||||
// 获取网络连接状态
|
// 获取网络连接状态
|
||||||
// getConnectType();
|
getConnectType();
|
||||||
|
|
||||||
getStarLockInfo();
|
getStarLockInfo();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,5 +10,8 @@ class LockMainState {
|
|||||||
var dataLength = 100.obs;
|
var dataLength = 100.obs;
|
||||||
var lockListInfoEntity = LockListInfoEntity().obs;
|
var lockListInfoEntity = LockListInfoEntity().obs;
|
||||||
|
|
||||||
|
// 网络连接状态 0没有网络 1有网络
|
||||||
|
var networkConnectionStatus = 0.obs;
|
||||||
|
|
||||||
// late Timer timer;
|
// late Timer timer;
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ class _AbountPageState extends State<AbountPage> {
|
|||||||
),
|
),
|
||||||
SizedBox(height: 20.h),
|
SizedBox(height: 20.h),
|
||||||
Text(
|
Text(
|
||||||
"星锁 1.0.0.03(preRelease-20240108)",
|
"星锁 1.0.0.04(preRelease-20240108-1)",
|
||||||
style: TextStyle(fontSize: 24.sp, color: AppColors.blackColor),
|
style: TextStyle(fontSize: 24.sp, color: AppColors.blackColor),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
|
|||||||
@ -131,6 +131,7 @@ class _AddLockSeletCountryPageState extends State<AddLockSeletCountryPage> {
|
|||||||
"featureValue": state.featureValue,
|
"featureValue": state.featureValue,
|
||||||
"featureSettingValue": state.featureSettingValue,
|
"featureSettingValue": state.featureSettingValue,
|
||||||
"featureSettingParams": state.featureSettingParams,
|
"featureSettingParams": state.featureSettingParams,
|
||||||
|
"isFromMap": 0,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -152,6 +153,7 @@ class _AddLockSeletCountryPageState extends State<AddLockSeletCountryPage> {
|
|||||||
"featureValue": state.featureValue,
|
"featureValue": state.featureValue,
|
||||||
"featureSettingValue": state.featureSettingValue,
|
"featureSettingValue": state.featureSettingValue,
|
||||||
"featureSettingParams": state.featureSettingParams,
|
"featureSettingParams": state.featureSettingParams,
|
||||||
|
"isFromMap": 0,
|
||||||
});
|
});
|
||||||
// Navigator.pushNamed(context, Routers.saveLockPage);
|
// Navigator.pushNamed(context, Routers.saveLockPage);
|
||||||
},
|
},
|
||||||
|
|||||||
@ -50,6 +50,10 @@ class LockAddressGaoDeLogic extends BaseGetXController{
|
|||||||
// ..startLocation();
|
// ..startLocation();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
void pushAddAction(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onReady() {
|
void onReady() {
|
||||||
// TODO: implement onReady
|
// TODO: implement onReady
|
||||||
|
|||||||
@ -67,14 +67,18 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage> with RouteA
|
|||||||
final status = await Permission.location.request();
|
final status = await Permission.location.request();
|
||||||
print("Permission.location.request()=status:$status");
|
print("Permission.location.request()=status:$status");
|
||||||
permissionStatus = status;
|
permissionStatus = status;
|
||||||
|
if(Platform.isIOS){
|
||||||
|
_setLocationOption();
|
||||||
|
requestIOSLocation();
|
||||||
|
}
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case PermissionStatus.denied:
|
case PermissionStatus.denied:
|
||||||
print("拒绝");
|
print("拒绝");
|
||||||
break;
|
break;
|
||||||
case PermissionStatus.granted:
|
case PermissionStatus.granted:
|
||||||
if(Platform.isIOS){
|
if(Platform.isIOS){
|
||||||
_setLocationOption();
|
// _setLocationOption();
|
||||||
requestIOSLocation();
|
// requestIOSLocation();
|
||||||
}else{
|
}else{
|
||||||
requestAndroidLocation();
|
requestAndroidLocation();
|
||||||
location.startLocation();
|
location.startLocation();
|
||||||
@ -83,6 +87,12 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage> with RouteA
|
|||||||
case PermissionStatus.limited:
|
case PermissionStatus.limited:
|
||||||
print("限制");
|
print("限制");
|
||||||
break;
|
break;
|
||||||
|
case PermissionStatus.permanentlyDenied:
|
||||||
|
print("永久的否认");
|
||||||
|
break;
|
||||||
|
case PermissionStatus.provisional:
|
||||||
|
print("临时");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
print("其他状态");
|
print("其他状态");
|
||||||
// requestLocation();
|
// requestLocation();
|
||||||
@ -264,6 +274,7 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage> with RouteA
|
|||||||
"featureValue": state.featureValue,
|
"featureValue": state.featureValue,
|
||||||
"featureSettingValue": state.featureSettingValue,
|
"featureSettingValue": state.featureSettingValue,
|
||||||
"featureSettingParams": state.featureSettingParams,
|
"featureSettingParams": state.featureSettingParams,
|
||||||
|
"isFromMap": 1,
|
||||||
});
|
});
|
||||||
// Navigator.pushNamed(context, Routers.saveLockPage);
|
// Navigator.pushNamed(context, Routers.saveLockPage);
|
||||||
},
|
},
|
||||||
|
|||||||
@ -373,13 +373,16 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
|
|
||||||
_initReplySubscription();
|
_initReplySubscription();
|
||||||
_scanListDiscoveredDeviceSubscriptionAction();
|
_scanListDiscoveredDeviceSubscriptionAction();
|
||||||
|
|
||||||
|
state.ifCurrentScreen.value = true;
|
||||||
|
startScanBlueList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
// TODO: implement onInit
|
// TODO: implement onInit
|
||||||
super.onInit();
|
|
||||||
print("NearbyLockLogic onInit()");
|
print("NearbyLockLogic onInit()");
|
||||||
|
super.onInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@ -145,14 +145,17 @@ class _NearbyLockPageState extends State<NearbyLockPage> with RouteAware {
|
|||||||
@override
|
@override
|
||||||
void didPush() {
|
void didPush() {
|
||||||
super.didPush();
|
super.didPush();
|
||||||
state.ifCurrentScreen.value = true;
|
Get.log("NearbyLockLogic didPush()");
|
||||||
logic.startScanBlueList();
|
|
||||||
|
// state.ifCurrentScreen.value = true;
|
||||||
|
// logic.startScanBlueList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 返回上一个界面 当前界面即将消失
|
/// 返回上一个界面 当前界面即将消失
|
||||||
@override
|
@override
|
||||||
void didPop() {
|
void didPop() {
|
||||||
super.didPop();
|
super.didPop();
|
||||||
|
Get.log("NearbyLockLogic didPop()");
|
||||||
|
|
||||||
state.ifCurrentScreen.value = false;
|
state.ifCurrentScreen.value = false;
|
||||||
logic.cancelBlueConnetctToastTimer();
|
logic.cancelBlueConnetctToastTimer();
|
||||||
@ -163,6 +166,7 @@ class _NearbyLockPageState extends State<NearbyLockPage> with RouteAware {
|
|||||||
@override
|
@override
|
||||||
void didPopNext() {
|
void didPopNext() {
|
||||||
super.didPopNext();
|
super.didPopNext();
|
||||||
|
Get.log("NearbyLockLogic didPopNext()");
|
||||||
|
|
||||||
state.ifCurrentScreen.value = true;
|
state.ifCurrentScreen.value = true;
|
||||||
logic.startScanBlueList();
|
logic.startScanBlueList();
|
||||||
@ -172,6 +176,7 @@ class _NearbyLockPageState extends State<NearbyLockPage> with RouteAware {
|
|||||||
@override
|
@override
|
||||||
void didPushNext() {
|
void didPushNext() {
|
||||||
super.didPushNext();
|
super.didPushNext();
|
||||||
|
Get.log("NearbyLockLogic didPushNext()");
|
||||||
|
|
||||||
state.ifCurrentScreen.value = false;
|
state.ifCurrentScreen.value = false;
|
||||||
logic.cancelBlueConnetctToastTimer();
|
logic.cancelBlueConnetctToastTimer();
|
||||||
|
|||||||
@ -155,7 +155,7 @@ class SaveLockLogic extends BaseGetXController {
|
|||||||
showBlueConnetctToast();
|
showBlueConnetctToast();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}, isAddEquipment: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ class SaveLockLogic extends BaseGetXController {
|
|||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
|
BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
|
||||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||||
Get.close(5);
|
Get.close(state.isFromMap == 1 ? 5 : 6);
|
||||||
// Future.delayed(const Duration(milliseconds: 200), () {
|
// Future.delayed(const Duration(milliseconds: 200), () {
|
||||||
// Get.offAllNamed(Routers.starLockMain);
|
// Get.offAllNamed(Routers.starLockMain);
|
||||||
// });
|
// });
|
||||||
@ -231,6 +231,7 @@ class SaveLockLogic extends BaseGetXController {
|
|||||||
void onClose() {
|
void onClose() {
|
||||||
// TODO: implement onClose
|
// TODO: implement onClose
|
||||||
_replySubscription.cancel();
|
_replySubscription.cancel();
|
||||||
|
BlueManage().stopScan();
|
||||||
super.onClose();
|
super.onClose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,7 @@ class SaveLockState {
|
|||||||
var featureValue = '';
|
var featureValue = '';
|
||||||
var featureSettingValue = '';
|
var featureSettingValue = '';
|
||||||
var featureSettingParams = [];
|
var featureSettingParams = [];
|
||||||
|
var isFromMap = 0; // 0:不是从地图界面进入 1:从地图界面进入
|
||||||
|
|
||||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||||
var saveBtnIsUsable = true.obs; // 保存按钮是否可用
|
var saveBtnIsUsable = true.obs; // 保存按钮是否可用
|
||||||
@ -31,6 +32,7 @@ class SaveLockState {
|
|||||||
featureValue = map["featureValue"];
|
featureValue = map["featureValue"];
|
||||||
featureSettingValue = map["featureSettingValue"];
|
featureSettingValue = map["featureSettingValue"];
|
||||||
featureSettingParams = map["featureSettingParams"];
|
featureSettingParams = map["featureSettingParams"];
|
||||||
|
isFromMap = map["isFromMap"];
|
||||||
}
|
}
|
||||||
|
|
||||||
void onClose() {
|
void onClose() {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
abstract class Api {
|
abstract class Api {
|
||||||
// static String baseAddress = "https://pre.lock.star-lock.cn:8093"; //预发布环境
|
static String baseAddress = "https://pre.lock.star-lock.cn:8093"; //预发布环境
|
||||||
static String baseAddress = "http://192.168.56.101:8099"; //联调环境
|
// static String baseAddress = "http://192.168.56.101:8099"; //联调环境
|
||||||
// static String baseAddress = "http://192.168.1.15:8022"; //谢总本地
|
// static String baseAddress = "http://192.168.1.15:8022"; //谢总本地
|
||||||
|
|
||||||
final String baseUrl = "$baseAddress/api";
|
final String baseUrl = "$baseAddress/api";
|
||||||
|
|||||||
@ -71,7 +71,7 @@ class CallTalk {
|
|||||||
// 获取帧序号 63
|
// 获取帧序号 63
|
||||||
int getIframeIndex =
|
int getIframeIndex =
|
||||||
bb[POS_iframe_index] + bb[POS_iframe_index + 1] * 256;
|
bb[POS_iframe_index] + bb[POS_iframe_index + 1] * 256;
|
||||||
print('获取帧序号 getIframeIndex:$getIframeIndex');
|
// print('获取帧序号 getIframeIndex:$getIframeIndex');
|
||||||
|
|
||||||
// 获取帧长度 65
|
// 获取帧长度 65
|
||||||
// int alen = bb[POS_alen] & 0xff;
|
// int alen = bb[POS_alen] & 0xff;
|
||||||
@ -84,10 +84,10 @@ class CallTalk {
|
|||||||
|
|
||||||
// 当前包号 71
|
// 当前包号 71
|
||||||
int getBagIndex = bb[POS_bag_index] & 0xff;
|
int getBagIndex = bb[POS_bag_index] & 0xff;
|
||||||
print('当前包号 getBagIndex:$getBagIndex');
|
// print('当前包号 getBagIndex:$getBagIndex');
|
||||||
// 总包数 69
|
// 总包数 69
|
||||||
int getBagNum = bb[POS_bag_num] & 0xff;
|
int getBagNum = bb[POS_bag_num] & 0xff;
|
||||||
print('总包数 getBagNum:$getBagNum');
|
// print('总包数 getBagNum:$getBagNum');
|
||||||
// 数据长度 73
|
// 数据长度 73
|
||||||
int blen = bb[POS_blen] + bb[POS_blen + 1] * 256;
|
int blen = bb[POS_blen] + bb[POS_blen + 1] * 256;
|
||||||
// print('数据长度 blen:$blen');
|
// print('数据长度 blen:$blen');
|
||||||
|
|||||||
@ -63,7 +63,7 @@ class BaseGetXController extends GetxController{
|
|||||||
action();
|
action();
|
||||||
}
|
}
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
if(isShowBlueConnetctToast == false){
|
if(isShowBlueConnetctToast == true){
|
||||||
showBlueConnetctToast();
|
showBlueConnetctToast();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user