优化蓝牙功能
This commit is contained in:
parent
55ea66a535
commit
13ad3117c1
@ -73,7 +73,7 @@ class BlueManage{
|
||||
if(device.name.isEmpty){
|
||||
return;
|
||||
}
|
||||
print("startScanDevice:${device}");
|
||||
// print("startScanDevice:${device}");
|
||||
// 判断是否
|
||||
if(isScanAll == true){
|
||||
if (((device.serviceUuids.isNotEmpty ? device.serviceUuids[0] : "").toString().contains("758824"))&& (device.rssi >= -100)) {
|
||||
|
||||
@ -53,6 +53,7 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
// 基本信息
|
||||
CommonItem(
|
||||
leftTitel:
|
||||
TranslationLoader.lanKeys!.basicInformation!.tr,
|
||||
@ -65,18 +66,20 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
});
|
||||
}),
|
||||
SizedBox(height: 10.h,),
|
||||
// 门磁
|
||||
Visibility(
|
||||
visible: true,
|
||||
child:CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.doorMagnetic!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.toNamed(Routers.doorMagneticPage);
|
||||
// Toast.show(msg: "功能暂未开放");
|
||||
})
|
||||
leftTitel: TranslationLoader.lanKeys!.doorMagnetic!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
// Get.toNamed(Routers.doorMagneticPage);
|
||||
Toast.show(msg: "功能暂未开放");
|
||||
})
|
||||
),
|
||||
// 无线键盘
|
||||
Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
@ -86,11 +89,12 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
isHaveLine: false,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.toNamed(Routers.wirelessKeyboardPage);
|
||||
// Toast.show(msg: "功能暂未开放");
|
||||
// Get.toNamed(Routers.wirelessKeyboardPage);
|
||||
Toast.show(msg: "功能暂未开放");
|
||||
})
|
||||
),
|
||||
SizedBox(height: 10.h),
|
||||
// 自动闭锁
|
||||
Obx(() => Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
@ -106,6 +110,7 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
arguments: state.getKeyInfosData.value);
|
||||
}))
|
||||
),
|
||||
// 锁声音
|
||||
Obx(() {
|
||||
var titleStr = "";
|
||||
if (state.getKeyInfosData.value.lockSound == 1) {
|
||||
@ -142,6 +147,7 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
})
|
||||
);
|
||||
}),
|
||||
// 防撬报警
|
||||
Obx(() => Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
@ -156,6 +162,7 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
arguments: state.getKeyInfosData.value);
|
||||
}))),
|
||||
SizedBox(height: 10.h),
|
||||
// 常开模式
|
||||
Obx(() => Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
@ -171,6 +178,7 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
arguments: state.getKeyInfosData.value);
|
||||
}))
|
||||
),
|
||||
// 远程开锁
|
||||
Obx(() => Visibility(
|
||||
visible:true,
|
||||
child: CommonItem(
|
||||
@ -185,6 +193,7 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
arguments: state.getKeyInfosData.value);
|
||||
}))
|
||||
),
|
||||
// 重置键
|
||||
Obx(() => Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
@ -210,16 +219,19 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget:
|
||||
SizedBox(width: 60.w, child: _openCheckInSwitch()))),
|
||||
SizedBox(width: 60.w, child: _otherUnHaveDoneSwitch()))),
|
||||
// ),
|
||||
// Obx(() =>
|
||||
Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel: '感应距离',
|
||||
rightTitle: "远",
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel: '感应距离',
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Toast.show(msg: "功能暂未开放");
|
||||
}
|
||||
)),
|
||||
// ),
|
||||
// Obx(() =>
|
||||
@ -231,7 +243,7 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget:
|
||||
SizedBox(width: 60.w, child: _openCheckInSwitch()))),
|
||||
SizedBox(width: 60.w, child: _otherUnHaveDoneSwitch()))),
|
||||
// ),
|
||||
// Obx(() =>
|
||||
Visibility(
|
||||
@ -242,7 +254,7 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget:
|
||||
SizedBox(width: 60.w, child: _openCheckInSwitch()))),
|
||||
SizedBox(width: 60.w, child: _otherUnHaveDoneSwitch()))),
|
||||
// ),
|
||||
// Obx(() =>
|
||||
Visibility(
|
||||
@ -253,26 +265,32 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget:
|
||||
SizedBox(width: 60.w, child: _openCheckInSwitch()))),
|
||||
SizedBox(width: 60.w, child: _otherUnHaveDoneSwitch()))),
|
||||
// ),
|
||||
// Obx(() =>
|
||||
Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel: '开门方向设置',
|
||||
rightTitle: "右开",
|
||||
rightTitle: "",
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () {
|
||||
Toast.show(msg: "功能暂未开放");
|
||||
}
|
||||
)),
|
||||
// ),
|
||||
// Obx(() =>
|
||||
Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel: '电机功率设置',
|
||||
rightTitle: "大",
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
leftTitel: '电机功率设置',
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Toast.show(msg: "功能暂未开放");
|
||||
}
|
||||
)),
|
||||
// ),
|
||||
SizedBox(height: 10.h),
|
||||
@ -459,6 +477,18 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
);
|
||||
}
|
||||
|
||||
CupertinoSwitch _otherUnHaveDoneSwitch() {
|
||||
return CupertinoSwitch(
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: false,
|
||||
onChanged: (value) {
|
||||
Toast.show(msg: "功能暂未开放");
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void showCupertinoAlertDialog(
|
||||
BuildContext context,
|
||||
) {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:date_format/date_format.dart';
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
@ -53,8 +54,11 @@ class LockTimeLogic extends BaseGetXController{
|
||||
(0xff & lockTime[2]) << 8 |
|
||||
(0xFF & lockTime[3]));
|
||||
|
||||
String dataEime = DateTool().dateToYMDHNSString("${value}");
|
||||
String dataEime = DateTool().dateToYMDHNSString("$value");
|
||||
state.dateTime.value = dataEime;
|
||||
|
||||
// String dataEime = DateTool().dateToYMDHNSString("${value}");
|
||||
// state.dateTime.value = dataEime;
|
||||
print("lockTime:$lockTime value:$value dataEime:$dataEime");
|
||||
break;
|
||||
case 0x06:
|
||||
@ -87,6 +91,17 @@ class LockTimeLogic extends BaseGetXController{
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
// var lockTime = reply.data.sublist(4, 8);
|
||||
//
|
||||
// int value = (
|
||||
// (0xff & lockTime[(0)]) << 24 |
|
||||
// (0xff & lockTime[1]) << 16 |
|
||||
// (0xff & lockTime[2]) << 8 |
|
||||
// (0xFF & lockTime[3]));
|
||||
//
|
||||
// String dataEime = DateTool().dateToYMDHNSString("$value");
|
||||
// state.dateTime.value = dataEime;
|
||||
|
||||
// _getLockStatus();
|
||||
Toast.show(msg:"锁时间更新成功");
|
||||
break;
|
||||
@ -155,7 +170,7 @@ class LockTimeLogic extends BaseGetXController{
|
||||
});
|
||||
}
|
||||
|
||||
// 获取锁的常开模式设置
|
||||
// 从网关获取时间
|
||||
void getLockTimeFromGateway() async{
|
||||
var entity = await ApiRepository.to.getLockTimeFromGateway(
|
||||
lockId: state.getKeyInfosData.value.lockId.toString(),
|
||||
@ -165,13 +180,13 @@ class LockTimeLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 获取锁的常开模式设置
|
||||
// 从服务器获取锁的时间
|
||||
void getServerDatetime() async{
|
||||
var entity = await ApiRepository.to.getServerDatetimeData(
|
||||
lockId: state.getKeyInfosData.value.lockId.toString(),
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
String dataEime = DateTool().dateToYMDHNSString("${int.parse(entity.data!.date.toString())~/1000}");
|
||||
String dataEime = DateTool().dateToYMDHNSString("${int.parse(entity.data!.date!)}");
|
||||
state.dateTime.value = dataEime;
|
||||
sendTiming();
|
||||
}
|
||||
@ -184,7 +199,8 @@ class LockTimeLogic extends BaseGetXController{
|
||||
print("onReady()");
|
||||
|
||||
_initReplySubscription();
|
||||
getLockTimeFromGateway();
|
||||
// getLockTimeFromGateway();
|
||||
getServerDatetime();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -193,7 +209,7 @@ class LockTimeLogic extends BaseGetXController{
|
||||
super.onInit();
|
||||
print("onInit()");
|
||||
|
||||
_getLockStatus();
|
||||
// _getLockStatus();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@ -3,6 +3,7 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:permission_handler/permission_handler.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_getLockStatu.dart';
|
||||
@ -500,17 +501,18 @@ class LockDetailLogic extends BaseGetXController{
|
||||
privateKey:getPrivateKeyList,
|
||||
);
|
||||
}
|
||||
}, isShowLoading: false);
|
||||
}, isShowLoading: true);
|
||||
}
|
||||
|
||||
void startScanAction(){
|
||||
BlueManage().startScan(true, (v){
|
||||
// print("startScanAllDevice:${v}");
|
||||
print("startScanAllDevice:${v}");
|
||||
final knownDeviceIndex = v.indexWhere((d) => d.name == state.keyInfos.value.bluetooth!.bluetoothDeviceName!);
|
||||
// 当扫描到的时候
|
||||
if (knownDeviceIndex >= 0) {
|
||||
connectBlue(v[knownDeviceIndex].id, state.keyInfos.value.bluetooth!.bluetoothDeviceName!);
|
||||
BlueManage().connectDeviceMacAddress = v[knownDeviceIndex].id;
|
||||
connectBlue(v[knownDeviceIndex].id, state.keyInfos.value.bluetooth!.bluetoothDeviceName!);
|
||||
BlueManage().stopScan();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -521,8 +523,16 @@ class LockDetailLogic extends BaseGetXController{
|
||||
super.onReady();
|
||||
print("onReady()");
|
||||
_initReplySubscription();
|
||||
|
||||
startScanAction();
|
||||
getMicrophonePermission()
|
||||
.then((value) {
|
||||
if (value) {
|
||||
// 有权限
|
||||
startScanAction();
|
||||
}else{
|
||||
//没有权限
|
||||
openAppSettings();//打开app系统设置
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@ -541,4 +551,23 @@ class LockDetailLogic extends BaseGetXController{
|
||||
// TODO: implement onClose
|
||||
_replySubscription.cancel();
|
||||
}
|
||||
|
||||
///请求录音相机权限
|
||||
Future<bool> getMicrophonePermission() async {
|
||||
// You can request multiple permissions at once.
|
||||
Map<Permission, PermissionStatus> statuses = await [
|
||||
Permission.bluetoothScan,
|
||||
Permission.bluetoothConnect,
|
||||
Permission.location,
|
||||
].request();
|
||||
|
||||
//granted 通过,denied 被拒绝,permanentlyDenied 拒绝且不在提示
|
||||
if (statuses[Permission.bluetoothScan]!.isGranted &&
|
||||
statuses[Permission.bluetoothConnect]!.isGranted &&
|
||||
statuses[Permission.location]!.isGranted) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@ -61,6 +61,9 @@ class _LockDetailPageState extends State<LockDetailPage> with RouteAware {
|
||||
state.keyInfos.value.bluetooth!.signKey!.cast<int>();
|
||||
var saveSignKeyList = changeIntListToStringList(signKeyData);
|
||||
Storage.setStringList(saveBlueSignKey, saveSignKeyList);
|
||||
|
||||
// token
|
||||
Storage.setStringList(saveBlueToken, ["0", "0", "0", "0"]);
|
||||
// print("publicKeyData:$publicKeyData saveStrList:$saveStrList privateKeyData:$privateKeyData savePrivateKeyList:$savePrivateKeyList");
|
||||
|
||||
// logic.startScanAction();
|
||||
|
||||
@ -386,7 +386,7 @@ class SaveLockLogic extends BaseGetXController {
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
bluetooth['signKey'] = signKeyDataList;
|
||||
|
||||
print("addUser:publicKeyDataList$publicKeyDataList getPrivateKeyList:$getPrivateKeyList signKeyDataList:$signKeyDataList");
|
||||
// print("addUser:publicKeyDataList$publicKeyDataList getPrivateKeyList:$getPrivateKeyList signKeyDataList:$signKeyDataList");
|
||||
|
||||
var entity = await ApiRepository.to.bindingBlueAdmin(
|
||||
bindingDate:DateTime.now().millisecondsSinceEpoch.toString(),
|
||||
|
||||
@ -27,9 +27,7 @@ class DateTool {
|
||||
String dateToYMDHNSString(String timeDate){
|
||||
int time = int.parse(timeDate);
|
||||
DateTime nowDate = DateTime.fromMillisecondsSinceEpoch(time);
|
||||
|
||||
String appointmentDate = formatDate(nowDate, [yyyy,'.',mm,'.',dd,' ',HH,':',nn ,':',ss]);
|
||||
|
||||
return appointmentDate;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user