fix:猫眼协议调整为蓝牙发送
This commit is contained in:
parent
1c74b54cd4
commit
88af212844
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/app_settings/app_settings.dart';
|
import 'package:star_lock/app_settings/app_settings.dart';
|
||||||
import 'package:star_lock/blue/blue_manage.dart';
|
import 'package:star_lock/blue/blue_manage.dart';
|
||||||
@ -11,6 +12,8 @@ import 'package:star_lock/talk/starChart/star_chart_manage.dart';
|
|||||||
import 'package:star_lock/tools/baseGetXController.dart';
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
import 'package:star_lock/tools/storage.dart';
|
import 'package:star_lock/tools/storage.dart';
|
||||||
|
|
||||||
|
import '../../../../../blue/sender_manage.dart';
|
||||||
|
|
||||||
class CatEyeCustomModeLogic extends BaseGetXController {
|
class CatEyeCustomModeLogic extends BaseGetXController {
|
||||||
final CatEyeCustomModeState state = CatEyeCustomModeState();
|
final CatEyeCustomModeState state = CatEyeCustomModeState();
|
||||||
|
|
||||||
@ -42,16 +45,50 @@ class CatEyeCustomModeLogic extends BaseGetXController {
|
|||||||
state.catEyeConfigData.value.catEyeModeConfig!.realTimeMode == 0
|
state.catEyeConfigData.value.catEyeModeConfig!.realTimeMode == 0
|
||||||
? '发生事件时查看'.tr
|
? '发生事件时查看'.tr
|
||||||
: '实时查看'.tr;
|
: '实时查看'.tr;
|
||||||
_getConfigAndGenerateBleData();
|
await _getConfigAndGenerateBleData();
|
||||||
updateCatEyeSetConfig();
|
await updateCatEyeSetConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await _getConfigAndGenerateBleData();
|
await _getConfigAndGenerateBleData();
|
||||||
updateCatEyeSetConfig();
|
await updateCatEyeSetConfig();
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_sendBlueMessage(SetSupportFunctionsWithParametersCommand command,
|
||||||
|
List<int> config) async {
|
||||||
|
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||||
|
(BluetoothConnectionState connectionState) async {
|
||||||
|
if (connectionState == BluetoothConnectionState.connected) {
|
||||||
|
final List<String>? privateKey =
|
||||||
|
await Storage.getStringList(saveBluePrivateKey);
|
||||||
|
final List<int> getPrivateKeyList =
|
||||||
|
changeStringListToIntList(privateKey!);
|
||||||
|
|
||||||
|
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
||||||
|
final List<int> getTokenList = changeStringListToIntList(token!);
|
||||||
|
|
||||||
|
final List<String>? publicKey =
|
||||||
|
await Storage.getStringList(saveBluePublicKey);
|
||||||
|
final List<int> getPublicKeyList =
|
||||||
|
changeStringListToIntList(publicKey!);
|
||||||
|
IoSenderManage.setSupportFunctionsWithParametersCommand(
|
||||||
|
keyID: command.keyID,
|
||||||
|
userID: command.userID,
|
||||||
|
featureBit: command.featureBit,
|
||||||
|
featureParaLength: config.length,
|
||||||
|
featureData: config,
|
||||||
|
token: getTokenList,
|
||||||
|
needAuthor: 1,
|
||||||
|
publicKey: getPublicKeyList,
|
||||||
|
privateKey: getPrivateKeyList);
|
||||||
|
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||||
|
dismissEasyLoading();
|
||||||
|
cancelBlueConnetctToastTimer();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
//设置猫眼工作模式 0-有人出现时录像 1-人体侦测距离
|
//设置猫眼工作模式 0-有人出现时录像 1-人体侦测距离
|
||||||
void updateCatEyeModeConfig(int clickIndex) async {
|
void updateCatEyeModeConfig(int clickIndex) async {
|
||||||
var entity = await ApiRepository.to.updateCatEyeModeConfig(
|
var entity = await ApiRepository.to.updateCatEyeModeConfig(
|
||||||
@ -150,7 +187,7 @@ class CatEyeCustomModeLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 更新锁板上的猫眼配置
|
/// 更新锁板上的猫眼配置
|
||||||
void updateCatEyeSetConfig() async {
|
Future<void> updateCatEyeSetConfig() async {
|
||||||
final int operatingMode = state.catEyeConfig.value.catEyeMode ?? 1; // 自定义模式
|
final int operatingMode = state.catEyeConfig.value.catEyeMode ?? 1; // 自定义模式
|
||||||
final int isAllDay = state.catEyeConfig.value.recordMode ?? 1; // 是否是全天
|
final int isAllDay = state.catEyeConfig.value.recordMode ?? 1; // 是否是全天
|
||||||
final int startTime =
|
final int startTime =
|
||||||
@ -207,11 +244,14 @@ class CatEyeCustomModeLogic extends BaseGetXController {
|
|||||||
privateKey: getPrivateKeyList,
|
privateKey: getPrivateKeyList,
|
||||||
);
|
);
|
||||||
final packageData = command.packageData();
|
final packageData = command.packageData();
|
||||||
|
|
||||||
/// 发送星图
|
/// 发送星图
|
||||||
StartChartManage().sendBleMessage(
|
// StartChartManage().sendBleMessage(
|
||||||
bluetoothDeviceName: BlueManage().connectDeviceName,
|
// bluetoothDeviceName: BlueManage().connectDeviceName,
|
||||||
bleStructData: packageData,
|
// bleStructData: packageData,
|
||||||
);
|
// );
|
||||||
|
|
||||||
|
await _sendBlueMessage(command, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据提供的参数生成配置列表
|
// 根据提供的参数生成配置列表
|
||||||
|
|||||||
@ -1,9 +1,14 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/app_settings/app_settings.dart';
|
import 'package:star_lock/app_settings/app_settings.dart';
|
||||||
import 'package:star_lock/blue/blue_manage.dart';
|
import 'package:star_lock/blue/blue_manage.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_setSupportFunctionsWithParameters.dart';
|
import 'package:star_lock/blue/io_protocol/io_setSupportFunctionsWithParameters.dart';
|
||||||
|
import 'package:star_lock/blue/io_reply.dart';
|
||||||
import 'package:star_lock/blue/io_tool/io_tool.dart';
|
import 'package:star_lock/blue/io_tool/io_tool.dart';
|
||||||
|
import 'package:star_lock/blue/io_tool/manager_event_bus.dart';
|
||||||
|
import 'package:star_lock/blue/sender_manage.dart';
|
||||||
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
|
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
|
||||||
import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart';
|
import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart';
|
||||||
import 'package:star_lock/network/api_repository.dart';
|
import 'package:star_lock/network/api_repository.dart';
|
||||||
@ -17,6 +22,66 @@ import 'catEyeSet_state.dart';
|
|||||||
class CatEyeSetLogic extends BaseGetXController {
|
class CatEyeSetLogic extends BaseGetXController {
|
||||||
final CatEyeSetState state = CatEyeSetState();
|
final CatEyeSetState state = CatEyeSetState();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onInit() {
|
||||||
|
super.onInit();
|
||||||
|
_initReplySubscription();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取解析后的数据
|
||||||
|
late StreamSubscription<Reply> _replySubscription;
|
||||||
|
|
||||||
|
void _initReplySubscription() {
|
||||||
|
_replySubscription =
|
||||||
|
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) {
|
||||||
|
// 设置支持功能解析(带参数)
|
||||||
|
if (reply is SetSupportFunctionsWithParametersReply) {
|
||||||
|
_replySetSupportFunctionsWithParameters(reply);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置支持功能解析
|
||||||
|
Future<void> _replySetSupportFunctionsWithParameters(Reply reply) async {
|
||||||
|
final int status = reply.data[2];
|
||||||
|
switch (status) {
|
||||||
|
case 0x00:
|
||||||
|
//成功
|
||||||
|
cancelBlueConnetctToastTimer();
|
||||||
|
dismissEasyLoading();
|
||||||
|
switch (state.settingOptions.value) {
|
||||||
|
case 1: //自动亮屏
|
||||||
|
{
|
||||||
|
updateAutoLightScreenConfig();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2: //逗留警告
|
||||||
|
{
|
||||||
|
updateStayWarnConfig();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3: //异常警告
|
||||||
|
{
|
||||||
|
updateAbnormalWarnConfig();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 4: //设置亮屏持续时间
|
||||||
|
{
|
||||||
|
updateLightScreenTimeConfig();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0x06:
|
||||||
|
//无权限
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//设置自动亮屏
|
//设置自动亮屏
|
||||||
Future<void> updateAutoLightScreenConfig() async {
|
Future<void> updateAutoLightScreenConfig() async {
|
||||||
final VersionUndateEntity entity =
|
final VersionUndateEntity entity =
|
||||||
@ -139,14 +204,13 @@ class CatEyeSetLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await _getConfigAndGenerateBleData();
|
// 更新state中的猫眼设置
|
||||||
updateCatEyeSetConfig();
|
await _updateCatEyeSetByState();
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
_getConfigAndGenerateBleData() async {
|
// 更新state中的猫眼设置
|
||||||
// 假设 state.lockSetInfoData.value.lockSettingInfo!.catEyeConfig![0].catEyeMode 是一个整数
|
_updateCatEyeSetByState() async {
|
||||||
|
|
||||||
int originalCatEyeMode = 0;
|
int originalCatEyeMode = 0;
|
||||||
int recordMode = 0;
|
int recordMode = 0;
|
||||||
int recordStartTime = 0;
|
int recordStartTime = 0;
|
||||||
@ -226,8 +290,8 @@ class CatEyeSetLogic extends BaseGetXController {
|
|||||||
state.catEyeConfig.refresh();
|
state.catEyeConfig.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 更新锁板上的猫眼配置
|
/// 构建蓝牙设置命令
|
||||||
void updateCatEyeSetConfig() async {
|
List<int> _buildCatEyeSetBlueMessage() {
|
||||||
final int operatingMode = state.catEyeConfig.value.catEyeMode ?? 1; // 自定义模式
|
final int operatingMode = state.catEyeConfig.value.catEyeMode ?? 1; // 自定义模式
|
||||||
final int isAllDay = state.catEyeConfig.value.recordMode ?? 1; // 是否是全天
|
final int isAllDay = state.catEyeConfig.value.recordMode ?? 1; // 是否是全天
|
||||||
final int startTime =
|
final int startTime =
|
||||||
@ -261,42 +325,7 @@ class CatEyeSetLogic extends BaseGetXController {
|
|||||||
stayWarning: stayWarning,
|
stayWarning: stayWarning,
|
||||||
exceptionWarning: exceptionWarning,
|
exceptionWarning: exceptionWarning,
|
||||||
);
|
);
|
||||||
final List<String>? privateKey =
|
return config;
|
||||||
await Storage.getStringList(saveBluePrivateKey);
|
|
||||||
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
|
||||||
|
|
||||||
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
|
||||||
final List<int> getTokenList = changeStringListToIntList(token!);
|
|
||||||
|
|
||||||
final List<String>? publicKey =
|
|
||||||
await Storage.getStringList(saveBluePublicKey);
|
|
||||||
final List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
|
||||||
final userId = await Storage.getUid();
|
|
||||||
final command = SetSupportFunctionsWithParametersCommand(
|
|
||||||
keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
|
||||||
userID: userId,
|
|
||||||
featureBit: 64,
|
|
||||||
featureParaLength: config.length,
|
|
||||||
featureData: config,
|
|
||||||
token: getTokenList,
|
|
||||||
needAuthor: 1,
|
|
||||||
publicKey: getPublicKeyList,
|
|
||||||
privateKey: getPrivateKeyList,
|
|
||||||
);
|
|
||||||
final packageData = command.packageData();
|
|
||||||
|
|
||||||
// 将 List<int> 转换为十六进制字符串
|
|
||||||
String hexString = packageData
|
|
||||||
.map((byte) => byte.toRadixString(16).padLeft(2, '0'))
|
|
||||||
.join(' ');
|
|
||||||
|
|
||||||
AppLog.log('发送透传猫眼设置: $hexString');
|
|
||||||
|
|
||||||
/// 发送星图
|
|
||||||
StartChartManage().sendBleMessage(
|
|
||||||
bluetoothDeviceName: BlueManage().connectDeviceName,
|
|
||||||
bleStructData: packageData,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据提供的参数生成配置列表
|
// 根据提供的参数生成配置列表
|
||||||
@ -403,4 +432,70 @@ class CatEyeSetLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateSettingOptions(int clickIndex, value) {
|
||||||
|
switch (clickIndex) {
|
||||||
|
case 1: //自动亮屏
|
||||||
|
{
|
||||||
|
state.isAutoBright.value = value;
|
||||||
|
state.settingOptions.value = 1;
|
||||||
|
state.catEyeConfig.value.autoLightScreen = value == true ? 1 : 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2: //逗留警告
|
||||||
|
{
|
||||||
|
state.isStayWarning.value = value;
|
||||||
|
state.settingOptions.value = 2;
|
||||||
|
state.catEyeConfig.value.stayWarn = value == true ? 1 : 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3: //异常警告
|
||||||
|
{
|
||||||
|
state.isExceptionWarning.value = value;
|
||||||
|
state.settingOptions.value = 3;
|
||||||
|
state.catEyeConfig.value.abnormalWarn = value == true ? 1 : 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 4: //设置亮屏持续时间
|
||||||
|
{
|
||||||
|
state.isExceptionWarning.value = value;
|
||||||
|
state.settingOptions.value = 4;
|
||||||
|
state.catEyeConfig.value.autoLightScreenTime =
|
||||||
|
_handleGetIntNumber(state.selectBrightDuration.value);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
final message = _buildCatEyeSetBlueMessage();
|
||||||
|
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||||
|
(BluetoothConnectionState connectionState) async {
|
||||||
|
if (connectionState == BluetoothConnectionState.connected) {
|
||||||
|
final List<String>? privateKey =
|
||||||
|
await Storage.getStringList(saveBluePrivateKey);
|
||||||
|
final List<int> getPrivateKeyList =
|
||||||
|
changeStringListToIntList(privateKey!);
|
||||||
|
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
||||||
|
final List<int> getTokenList = changeStringListToIntList(token!);
|
||||||
|
final List<String>? publicKey =
|
||||||
|
await Storage.getStringList(saveBluePublicKey);
|
||||||
|
final List<int> getPublicKeyList =
|
||||||
|
changeStringListToIntList(publicKey!);
|
||||||
|
final userId = await Storage.getUid();
|
||||||
|
IoSenderManage.setSupportFunctionsWithParametersCommand(
|
||||||
|
keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
||||||
|
userID: userId,
|
||||||
|
featureBit: 64,
|
||||||
|
featureParaLength: message.length,
|
||||||
|
featureData: message,
|
||||||
|
token: getTokenList,
|
||||||
|
needAuthor: 1,
|
||||||
|
publicKey: getPublicKeyList,
|
||||||
|
privateKey: getPrivateKeyList);
|
||||||
|
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||||
|
dismissEasyLoading();
|
||||||
|
cancelBlueConnetctToastTimer();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -118,28 +118,7 @@ class _CatEyeSetPageState extends State<CatEyeSetPage> {
|
|||||||
thumbColor: CupertinoColors.white,
|
thumbColor: CupertinoColors.white,
|
||||||
value: isCheck,
|
value: isCheck,
|
||||||
onChanged: (bool value) {
|
onChanged: (bool value) {
|
||||||
switch (clickIndex) {
|
logic.updateSettingOptions(clickIndex, value);
|
||||||
case 1: //自动亮屏
|
|
||||||
{
|
|
||||||
state.isAutoBright.value = value;
|
|
||||||
logic.updateAutoLightScreenConfig();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2: //逗留警告
|
|
||||||
{
|
|
||||||
state.isStayWarning.value = value;
|
|
||||||
logic.updateStayWarnConfig();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 3: //异常警告
|
|
||||||
{
|
|
||||||
state.isExceptionWarning.value = value;
|
|
||||||
logic.updateAbnormalWarnConfig();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -156,7 +135,7 @@ class _CatEyeSetPageState extends State<CatEyeSetPage> {
|
|||||||
chooseCallback: (int value) {
|
chooseCallback: (int value) {
|
||||||
state.selectBrightDuration.value =
|
state.selectBrightDuration.value =
|
||||||
state.brightDurationTimeList[value];
|
state.brightDurationTimeList[value];
|
||||||
logic.updateLightScreenTimeConfig();
|
logic.updateSettingOptions(4, true);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:get/get_rx/get_rx.dart';
|
||||||
import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart';
|
import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart';
|
||||||
|
|
||||||
class CatEyeSetState {
|
class CatEyeSetState {
|
||||||
@ -38,6 +39,7 @@ class CatEyeSetState {
|
|||||||
RxBool isExceptionWarning = false.obs; //异常警告
|
RxBool isExceptionWarning = false.obs; //异常警告
|
||||||
Rx<LockSetInfoData> lockSetInfoData = LockSetInfoData().obs;
|
Rx<LockSetInfoData> lockSetInfoData = LockSetInfoData().obs;
|
||||||
RxString selectCatEyeWorkMode = ''.obs; //猫眼工作模式
|
RxString selectCatEyeWorkMode = ''.obs; //猫眼工作模式
|
||||||
|
RxInt settingOptions = 0.obs; // 设置项
|
||||||
final String settingSuccess = '设置成功'.tr;
|
final String settingSuccess = '设置成功'.tr;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,16 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/app_settings/app_settings.dart';
|
import 'package:star_lock/app_settings/app_settings.dart';
|
||||||
import 'package:star_lock/blue/blue_manage.dart';
|
import 'package:star_lock/blue/blue_manage.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_setSupportFunctionsWithParameters.dart';
|
import 'package:star_lock/blue/io_protocol/io_setSupportFunctionsWithParameters.dart';
|
||||||
|
import 'package:star_lock/blue/io_reply.dart';
|
||||||
import 'package:star_lock/blue/io_tool/io_tool.dart';
|
import 'package:star_lock/blue/io_tool/io_tool.dart';
|
||||||
|
import 'package:star_lock/blue/io_tool/manager_event_bus.dart';
|
||||||
import 'package:star_lock/blue/sender_manage.dart';
|
import 'package:star_lock/blue/sender_manage.dart';
|
||||||
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
|
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
|
||||||
|
import 'package:star_lock/main/lockDetail/lockSet/catEyeSet/catEyeSet/catEyeSet_logic.dart';
|
||||||
import 'package:star_lock/main/lockDetail/lockSet/catEyeSet/catEyeSet/catEyeSet_state.dart';
|
import 'package:star_lock/main/lockDetail/lockSet/catEyeSet/catEyeSet/catEyeSet_state.dart';
|
||||||
import 'package:star_lock/main/lockDetail/lockSet/catEyeSet/catEyeWorkMode/catEyeWorkMode_state.dart';
|
import 'package:star_lock/main/lockDetail/lockSet/catEyeSet/catEyeWorkMode/catEyeWorkMode_state.dart';
|
||||||
import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart';
|
import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart';
|
||||||
@ -18,6 +23,39 @@ import 'package:star_lock/versionUndate/versionUndate_entity.dart';
|
|||||||
class CatEyeWorkModeLogic extends BaseGetXController {
|
class CatEyeWorkModeLogic extends BaseGetXController {
|
||||||
final CatEyeWorkModeState state = CatEyeWorkModeState();
|
final CatEyeWorkModeState state = CatEyeWorkModeState();
|
||||||
|
|
||||||
|
final CatEyeSetState catEyeSetState = Get.find<CatEyeSetLogic>().state;
|
||||||
|
|
||||||
|
// 获取解析后的数据
|
||||||
|
late StreamSubscription<Reply> _replySubscription;
|
||||||
|
|
||||||
|
void _initReplySubscription() {
|
||||||
|
_replySubscription =
|
||||||
|
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) {
|
||||||
|
// 设置支持功能解析(带参数)
|
||||||
|
if (reply is SetSupportFunctionsWithParametersReply) {
|
||||||
|
_replySetSupportFunctionsWithParameters(reply);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置支持功能解析
|
||||||
|
Future<void> _replySetSupportFunctionsWithParameters(Reply reply) async {
|
||||||
|
final int status = reply.data[2];
|
||||||
|
switch (status) {
|
||||||
|
case 0x00:
|
||||||
|
//成功
|
||||||
|
cancelBlueConnetctToastTimer();
|
||||||
|
dismissEasyLoading();
|
||||||
|
updateCatEyeModeConfig();
|
||||||
|
break;
|
||||||
|
case 0x06:
|
||||||
|
//无权限
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//设置猫眼工作模式
|
//设置猫眼工作模式
|
||||||
Future<void> updateCatEyeModeConfig() async {
|
Future<void> updateCatEyeModeConfig() async {
|
||||||
final VersionUndateEntity entity =
|
final VersionUndateEntity entity =
|
||||||
@ -60,13 +98,12 @@ class CatEyeWorkModeLogic extends BaseGetXController {
|
|||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
showToast('设置成功'.tr);
|
showToast('设置成功'.tr);
|
||||||
getLockSettingInfoData();
|
getLockSettingInfoData();
|
||||||
|
|
||||||
updateCatEyeSetConfig();
|
updateCatEyeSetConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 处理蓝牙数据
|
void _sendBlueMessage(
|
||||||
void _handlerBleData() {
|
SetSupportFunctionsWithParametersCommand command, List<int> config) {
|
||||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||||
(BluetoothConnectionState connectionState) async {
|
(BluetoothConnectionState connectionState) async {
|
||||||
if (connectionState == BluetoothConnectionState.connected) {
|
if (connectionState == BluetoothConnectionState.connected) {
|
||||||
@ -82,15 +119,12 @@ class CatEyeWorkModeLogic extends BaseGetXController {
|
|||||||
await Storage.getStringList(saveBluePublicKey);
|
await Storage.getStringList(saveBluePublicKey);
|
||||||
final List<int> getPublicKeyList =
|
final List<int> getPublicKeyList =
|
||||||
changeStringListToIntList(publicKey!);
|
changeStringListToIntList(publicKey!);
|
||||||
|
|
||||||
List<int> featureData = [];
|
|
||||||
|
|
||||||
IoSenderManage.setSupportFunctionsWithParametersCommand(
|
IoSenderManage.setSupportFunctionsWithParametersCommand(
|
||||||
keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
keyID: command.keyID,
|
||||||
userID: await Storage.getUid(),
|
userID: command.userID,
|
||||||
featureBit: 33,
|
featureBit: command.featureBit,
|
||||||
featureParaLength: 1,
|
featureParaLength: config.length,
|
||||||
featureData: featureData,
|
featureData: config,
|
||||||
token: getTokenList,
|
token: getTokenList,
|
||||||
needAuthor: 1,
|
needAuthor: 1,
|
||||||
publicKey: getPublicKeyList,
|
publicKey: getPublicKeyList,
|
||||||
@ -102,6 +136,8 @@ class CatEyeWorkModeLogic extends BaseGetXController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 获取锁设置信息
|
// 获取锁设置信息
|
||||||
Future<void> getLockSettingInfoData() async {
|
Future<void> getLockSettingInfoData() async {
|
||||||
final LockSetInfoEntity entity =
|
final LockSetInfoEntity entity =
|
||||||
@ -256,20 +292,8 @@ class CatEyeWorkModeLogic extends BaseGetXController {
|
|||||||
publicKey: getPublicKeyList,
|
publicKey: getPublicKeyList,
|
||||||
privateKey: getPrivateKeyList,
|
privateKey: getPrivateKeyList,
|
||||||
);
|
);
|
||||||
final packageData = command.packageData();
|
|
||||||
|
|
||||||
// 将 List<int> 转换为十六进制字符串
|
_sendBlueMessage(command, config);
|
||||||
String hexString = packageData
|
|
||||||
.map((byte) => byte.toRadixString(16).padLeft(2, '0'))
|
|
||||||
.join(' ');
|
|
||||||
|
|
||||||
AppLog.log('catEye set: $hexString');
|
|
||||||
|
|
||||||
/// 发送星图
|
|
||||||
StartChartManage().sendBleMessage(
|
|
||||||
bluetoothDeviceName: BlueManage().connectDeviceName,
|
|
||||||
bleStructData: packageData,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据提供的参数生成配置列表
|
// 根据提供的参数生成配置列表
|
||||||
@ -376,4 +400,35 @@ class CatEyeWorkModeLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateCustomModeConfig() {
|
||||||
|
state.catEyeConfig.value.recordMode =
|
||||||
|
state.lockSetInfoData.value.lockSettingInfo!.catEyeConfig!.isNotEmpty
|
||||||
|
? state.catEyeConfigData.value.catEyeModeConfig?.recordMode
|
||||||
|
: 0;
|
||||||
|
state.catEyeConfig.value.recordStartTime =
|
||||||
|
state.lockSetInfoData.value.lockSettingInfo!.catEyeConfig!.isNotEmpty
|
||||||
|
? state.catEyeConfigData.value.catEyeModeConfig?.recordStartTime
|
||||||
|
: 0;
|
||||||
|
state.catEyeConfig.value.recordEndTime =
|
||||||
|
state.lockSetInfoData.value.lockSettingInfo!.catEyeConfig!.isNotEmpty
|
||||||
|
? state.catEyeConfigData.value.catEyeModeConfig?.recordEndTime
|
||||||
|
: 0;
|
||||||
|
state.catEyeConfig.value.recordTime =
|
||||||
|
state.lockSetInfoData.value.lockSettingInfo!.catEyeConfig!.isNotEmpty
|
||||||
|
? _handleGetIntNumber(
|
||||||
|
state.catEyeConfigData.value.catEyeModeConfig?.recordTime ?? '')
|
||||||
|
: 0;
|
||||||
|
state.catEyeConfig.value.detectionDistance = state
|
||||||
|
.lockSetInfoData.value.lockSettingInfo!.catEyeConfig!.isNotEmpty
|
||||||
|
? _handleDetectionDistance(
|
||||||
|
state.catEyeConfigData.value.catEyeModeConfig?.detectionDistance ??
|
||||||
|
'')
|
||||||
|
: 0;
|
||||||
|
state.catEyeConfig.value.realTimeMode =
|
||||||
|
state.lockSetInfoData.value.lockSettingInfo!.catEyeConfig!.isNotEmpty
|
||||||
|
? state.catEyeConfigData.value.catEyeModeConfig?.realTimeMode!
|
||||||
|
: 0;
|
||||||
|
updateCatEyeSetConfig();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -140,6 +140,7 @@ class _CatEyeWorkModePageState extends State<CatEyeWorkModePage> {
|
|||||||
for (int i = 0; i < state.boolList.value.length; i++) {
|
for (int i = 0; i < state.boolList.value.length; i++) {
|
||||||
if (clickIndex == i) {
|
if (clickIndex == i) {
|
||||||
state.boolList.value[clickIndex] = true;
|
state.boolList.value[clickIndex] = true;
|
||||||
|
logic.updateCustomModeConfig();
|
||||||
logic.updateCatEyeModeConfig();
|
logic.updateCatEyeModeConfig();
|
||||||
} else {
|
} else {
|
||||||
state.boolList.value[i] = false;
|
state.boolList.value[i] = false;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user