Merge remote-tracking branch 'origin/develop_sky_liyi' into develop_sky_liyi

This commit is contained in:
liyi 2025-08-22 09:57:07 +08:00
commit 8a5e997262
8 changed files with 260 additions and 11 deletions

View File

@ -0,0 +1,54 @@
import 'dart:convert';
import 'dart:typed_data';
import 'package:crypto/crypto.dart' as crypto;
import '../io_reply.dart';
import '../io_sender.dart';
import '../io_tool/io_tool.dart';
import '../io_type.dart';
import '../sm4Encipher/sm4.dart';
//oat升级
class ReadLockCurrentVoicePacket extends SenderProtocol {
ReadLockCurrentVoicePacket({
this.lockID,
}) : super(CommandType.readLockCurrentVoicePacket);
String? lockID;
@override
String toString() {
return 'ReadLockCurrentVoicePacket{lockID: $lockID}';
}
@override
List<int> messageDetail() {
List<int> data = <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);
// id 40
final int lockIDLength = utf8.encode(lockID!).length;
data.addAll(utf8.encode(lockID!));
data = getFixedLengthList(data, 40 - lockIDLength);
printLog(data);
return data;
}
}
class ReadLockCurrentVoicePacketReply extends Reply {
ReadLockCurrentVoicePacketReply.parseData(
CommandType commandType, List<int> dataDetail)
: super.parseData(commandType, dataDetail) {
data = dataDetail;
status = data[6];
errorWithStstus(status);
}
}

View File

@ -0,0 +1,61 @@
import 'dart:convert';
import 'dart:typed_data';
import 'package:crypto/crypto.dart' as crypto;
import '../io_reply.dart';
import '../io_sender.dart';
import '../io_tool/io_tool.dart';
import '../io_type.dart';
import '../sm4Encipher/sm4.dart';
//oat升级
class SetVoicePackageFinalResult extends SenderProtocol {
SetVoicePackageFinalResult({
this.lockID,
this.languageCode,
}) : super(CommandType.setLockCurrentVoicePacket);
String? lockID;
String? languageCode;
@override
String toString() {
return 'SetVoicePackageFinalResult{lockID: $lockID, languageCode: $languageCode}';
}
@override
List<int> messageDetail() {
List<int> data = <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);
// id 40
final int lockIDLength = utf8.encode(lockID!).length;
data.addAll(utf8.encode(lockID!));
data = getFixedLengthList(data, 40 - lockIDLength);
//languageCode 20
final int languageCodeLength = utf8.encode(languageCode!).length;
data.addAll(utf8.encode(languageCode!));
data = getFixedLengthList(data, 20 - languageCodeLength);
printLog(data);
return data;
}
}
class SetVoicePackageFinalResultReply extends Reply {
SetVoicePackageFinalResultReply.parseData(
CommandType commandType, List<int> dataDetail)
: super.parseData(commandType, dataDetail) {
data = dataDetail;
status = data[6];
errorWithStstus(status);
}
}

View File

@ -44,7 +44,9 @@ enum CommandType {
startVoicePackageConfigure, // 0x30A1 startVoicePackageConfigure, // 0x30A1
voicePackageConfigureProcess, // 0x30A2 voicePackageConfigureProcess, // 0x30A2
voicePackageConfigureConfirmation, // 0x30A3 voicePackageConfigureConfirmation, // 0x30A3
getDeviceModel, // 0x30A4 readLockCurrentVoicePacket, // 0x30A4
setLockCurrentVoicePacket, // 0x30A5
getDeviceModel, // 0x30A4
gatewayConfiguringWifi, // 0x30F4 gatewayConfiguringWifi, // 0x30F4
gatewayConfiguringWifiResult, // 0x30F5 gatewayConfiguringWifiResult, // 0x30F5
@ -210,7 +212,12 @@ extension ExtensionCommandType on CommandType {
break; break;
case 0x30A4: case 0x30A4:
{ {
type = CommandType.getDeviceModel; type = CommandType.readLockCurrentVoicePacket;
}
break;
case 0x30A5:
{
type = CommandType.setLockCurrentVoicePacket;
} }
break; break;
case 0x30F4: case 0x30F4:
@ -340,9 +347,12 @@ extension ExtensionCommandType on CommandType {
case CommandType.voicePackageConfigureConfirmation: case CommandType.voicePackageConfigureConfirmation:
type = 0x30A3; type = 0x30A3;
break; break;
case CommandType.getDeviceModel: case CommandType.readLockCurrentVoicePacket:
type = 0x30A4; type = 0x30A4;
break; break;
case CommandType.setLockCurrentVoicePacket:
type = 0x30A5;
break;
default: default:
type = 0x300A; type = 0x300A;
break; break;
@ -362,7 +372,8 @@ extension ExtensionCommandType on CommandType {
case CommandType.gatewayGetWifiList: case CommandType.gatewayGetWifiList:
case CommandType.gatewayConfiguringWifi: case CommandType.gatewayConfiguringWifi:
case CommandType.gatewayGetStatus: case CommandType.gatewayGetStatus:
case CommandType.getDeviceModel: case CommandType.readLockCurrentVoicePacket:
case CommandType.setLockCurrentVoicePacket:
// //
type = 0x20; type = 0x20;
break; break;
@ -476,7 +487,10 @@ extension ExtensionCommandType on CommandType {
t = '语音包配置确认'; t = '语音包配置确认';
break; break;
case 0x30A4: case 0x30A4:
t = '获取设备型号'; t = '读取锁当前语音包';
break;
case 0x30A5:
t = '设置锁当前语音包';
break; break;
default: default:
t = '读星锁状态信息'; t = '读星锁状态信息';

View File

@ -12,6 +12,7 @@ import 'package:star_lock/blue/blue_manage.dart';
import 'package:star_lock/blue/io_protocol/io_getDeviceModel.dart'; import 'package:star_lock/blue/io_protocol/io_getDeviceModel.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_setVoicePackageFinalResult.dart';
import 'package:star_lock/blue/io_protocol/io_voicePackageConfigure.dart'; import 'package:star_lock/blue/io_protocol/io_voicePackageConfigure.dart';
import 'package:star_lock/blue/io_protocol/io_voicePackageConfigureProcess.dart'; import 'package:star_lock/blue/io_protocol/io_voicePackageConfigureProcess.dart';
import 'package:star_lock/blue/io_reply.dart'; import 'package:star_lock/blue/io_reply.dart';
@ -52,6 +53,8 @@ class SpeechLanguageSettingsLogic extends BaseGetXController {
_handlerVoicePackageConfigureProcess(reply); _handlerVoicePackageConfigureProcess(reply);
} else if (reply is VoicePackageConfigureConfirmationReply) { } else if (reply is VoicePackageConfigureConfirmationReply) {
handleVoiceConfigureThrottled(reply); handleVoiceConfigureThrottled(reply);
} else if (reply is SetVoicePackageFinalResultReply) {
handleSetResult(reply);
} }
}); });
await initList(); await initList();
@ -93,7 +96,7 @@ class SpeechLanguageSettingsLogic extends BaseGetXController {
final passthroughItem = PassthroughItem( final passthroughItem = PassthroughItem(
lang: element.lang, lang: element.lang,
timbres: element.timbres, timbres: element.timbres,
langText: '简体中文'.tr + '(中国台湾)'.tr+'Simplified Chinese TW', langText: '简体中文'.tr + '(中国台湾)'.tr + 'Simplified Chinese TW',
name: element.name, name: element.name,
); );
state.languages.add(passthroughItem); state.languages.add(passthroughItem);
@ -432,6 +435,33 @@ class SpeechLanguageSettingsLogic extends BaseGetXController {
_handlerVoicePackageConfigureConfirmation( _handlerVoicePackageConfigureConfirmation(
VoicePackageConfigureConfirmationReply reply, VoicePackageConfigureConfirmationReply reply,
) async { ) async {
final int status = reply.data[2];
switch (status) {
case 0x00:
await BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) {
await BlueManage().writeCharacteristicWithResponse(
SetVoicePackageFinalResult(
lockID: BlueManage().connectDeviceName,
languageCode: state.tempLangStr.value,
).packageData(),
);
} else if (deviceConnectionState ==
BluetoothConnectionState.disconnected) {
dismissEasyLoading();
cancelBlueConnetctToastTimer();
showBlueConnetctToast();
}
});
break;
default:
showToast('设置'.tr + '失败'.tr);
break;
}
}
void handleSetResult(SetVoicePackageFinalResultReply reply) async {
final int status = reply.data[2]; final int status = reply.data[2];
switch (status) { switch (status) {
case 0x00: case 0x00:

View File

@ -11,6 +11,7 @@ import 'package:star_lock/appRouters.dart';
import 'package:star_lock/app_settings/app_colors.dart'; import 'package:star_lock/app_settings/app_colors.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_getDeviceModel.dart'; import 'package:star_lock/blue/io_protocol/io_getDeviceModel.dart';
import 'package:star_lock/blue/io_protocol/io_readVoicePackageFinalResult.dart';
import 'package:star_lock/blue/io_protocol/io_voicePackageConfigure.dart'; import 'package:star_lock/blue/io_protocol/io_voicePackageConfigure.dart';
import 'package:star_lock/blue/io_protocol/io_voicePackageConfigureProcess.dart'; import 'package:star_lock/blue/io_protocol/io_voicePackageConfigureProcess.dart';
import 'package:star_lock/blue/io_reply.dart'; import 'package:star_lock/blue/io_reply.dart';
@ -50,9 +51,12 @@ class LockVoiceSettingLogic extends BaseGetXController {
_handlerVoicePackageConfigureProcess(reply); _handlerVoicePackageConfigureProcess(reply);
} else if (reply is VoicePackageConfigureConfirmationReply) { } else if (reply is VoicePackageConfigureConfirmationReply) {
handleVoiceConfigureThrottled(reply); handleVoiceConfigureThrottled(reply);
} else if (reply is ReadLockCurrentVoicePacketReply) {
handleLockCurrentVoicePacketResult(reply);
} }
}); });
initList(); initList();
readLockLanguage();
} }
void handleVoiceConfigureThrottled( void handleVoiceConfigureThrottled(
@ -197,7 +201,7 @@ class LockVoiceSettingLogic extends BaseGetXController {
// //
void _handlerStartVoicePackageConfigure( void _handlerStartVoicePackageConfigure(
VoicePackageConfigureReply reply) async { VoicePackageConfigureReply reply) async {
final int status = reply.data[6]; final int status = reply.data[3];
switch (status) { switch (status) {
case 0x00: case 0x00:
// //
@ -403,4 +407,71 @@ class LockVoiceSettingLogic extends BaseGetXController {
state.data = null; state.data = null;
super.onClose(); super.onClose();
} }
void readLockLanguage() async {
await BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) {
await BlueManage().writeCharacteristicWithResponse(
ReadLockCurrentVoicePacket(
lockID: BlueManage().connectDeviceName,
).packageData(),
);
} else if (deviceConnectionState ==
BluetoothConnectionState.disconnected) {
dismissEasyLoading();
cancelBlueConnetctToastTimer();
showBlueConnetctToast();
}
});
}
void handleLockCurrentVoicePacketResult(
ReadLockCurrentVoicePacketReply reply) {
final int status = reply.data[6];
switch (status) {
case 0x00:
//
cancelBlueConnetctToastTimer();
// 1. LanguageCode
// CmdID (2 bytes) + Status (1 byte) = 3 bytes -> LanguageCode 3
const int languageCodeStartIndex = 3;
const int languageCodeLength = 20;
const int languageCodeEndIndex =
languageCodeStartIndex + languageCodeLength; // 23
// 2.
if (reply.data.length < languageCodeEndIndex) {
throw Exception(
'Reply data is too short to contain LanguageCode. Expected at least $languageCodeEndIndex bytes, got ${reply.data.length}');
}
// 3. LanguageCode
List<int> languageCodeBytes =
reply.data.sublist(languageCodeStartIndex, languageCodeEndIndex);
// 4.
// UTF-8 ASCII
String languageCode = String.fromCharCodes(languageCodeBytes);
// 5. () '\0'
// 20 '\0'
languageCode = languageCode.trim(); //
languageCode =
languageCode.replaceAll('\u0000', ''); // (null bytes)
// 6. 使 languageCode
print('LanguageCode: $languageCode'); // : zh_CN, en_US
break;
case 0x06:
//
final List<int> token = reply.data.sublist(2, 6);
if (state.data != null) {
sendFileToDevice(state.data!, token);
}
break;
default:
break;
}
}
} }

View File

@ -95,6 +95,12 @@ class _LockVoiceSettingState extends State<LockVoiceSetting> {
final soundType = state.soundTypeList.value[index]; final soundType = state.soundTypeList.value[index];
return CommonItem( return CommonItem(
leftTitel: soundType, leftTitel: soundType,
leftTitleStyle: TextStyle(
fontSize: 22.sp,
fontWeight: state.selectSoundTypeIndex.value == index
? FontWeight.bold
: null,
),
rightTitle: '', rightTitle: '',
isHaveLine: !isLastItem, isHaveLine: !isLastItem,
isHaveDirection: false, isHaveDirection: false,
@ -135,6 +141,13 @@ class _LockVoiceSettingState extends State<LockVoiceSetting> {
final item = state.languages[index]; final item = state.languages[index];
return CommonItem( return CommonItem(
leftTitel: item.langText, leftTitel: item.langText,
leftTitleStyle: TextStyle(
fontSize: 22.sp,
fontWeight:
state.selectPassthroughListIndex.value == index
? FontWeight.bold
: null,
),
rightTitle: '', rightTitle: '',
isHaveLine: true, isHaveLine: true,
isHaveDirection: false, isHaveDirection: false,

View File

@ -98,12 +98,16 @@ class TalkViewNativeDecodeLogic extends BaseGetXController {
state.isLoading.value = true; state.isLoading.value = true;
// //
final config = VideoDecoderConfig( final config = VideoDecoderConfig(
width: 864, width: StartChartManage().videoWidth,
// //
height: 480, height: StartChartManage().videoHeight,
codecType: 'h264', codecType: 'h264',
); );
// textureId // textureId
AppLog.log('StartChartManage().videoWidth:${StartChartManage()
.videoWidth}');
AppLog.log('StartChartManage().videoHeight:${StartChartManage()
.videoHeight}');
final textureId = await VideoDecodePlugin.initDecoder(config); final textureId = await VideoDecodePlugin.initDecoder(config);
if (textureId != null) { if (textureId != null) {
Future.microtask(() => state.textureId.value = textureId); Future.microtask(() => state.textureId.value = textureId);

View File

@ -20,7 +20,8 @@ class CommonItem extends StatelessWidget {
this.rightWidget, this.rightWidget,
this.isTipsImg, this.isTipsImg,
this.action, this.action,
this.leftTitleMaxWidth, // this.leftTitleMaxWidth, //
this.leftTitleStyle, //
this.tipsImgAction}) this.tipsImgAction})
: super(key: key); : super(key: key);
String? leftTitel; String? leftTitel;
@ -35,6 +36,7 @@ class CommonItem extends StatelessWidget {
bool? setHeight; bool? setHeight;
bool? isTipsImg; bool? isTipsImg;
bool? isPadding; bool? isPadding;
TextStyle? leftTitleStyle; //
final double? leftTitleMaxWidth; // final double? leftTitleMaxWidth; //
@override @override
@ -65,7 +67,7 @@ class CommonItem extends StatelessWidget {
), ),
child: Text( child: Text(
leftTitel!, leftTitel!,
style: TextStyle(fontSize: 22.sp), style: leftTitleStyle ?? TextStyle(fontSize: 22.sp),
overflow: TextOverflow.ellipsis, // overflow: TextOverflow.ellipsis, //
maxLines: 3, // 2 maxLines: 3, // 2
), ),