修改清除用户协议
This commit is contained in:
parent
e429dd96b3
commit
d38e56bd84
@ -20,6 +20,7 @@ import 'io_protocol/io_addUser.dart';
|
||||
import 'io_reply.dart';
|
||||
import 'io_tool/io_tool.dart';
|
||||
import 'io_tool/manager_event_bus.dart';
|
||||
import 'sender_data.dart';
|
||||
|
||||
class SenderBeforeDataManage {
|
||||
static SenderBeforeDataManage? _manager;
|
||||
@ -50,8 +51,9 @@ class SenderBeforeDataManage {
|
||||
if (reply is AddUserReply) {
|
||||
_replyAddUserKey(reply);
|
||||
}
|
||||
if(reply is CleanUpUsersReply){
|
||||
|
||||
if(reply is CleanUpUsersReply){
|
||||
_cleanUpUsersReply(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -93,8 +95,7 @@ class SenderBeforeDataManage {
|
||||
// publicKey: publicKeyDataList,
|
||||
// privateKey: getPrivateKeyList,
|
||||
// token: token);
|
||||
LockListInfoItemEntity currentKeyInfo =
|
||||
CommonDataManage().currentKeyInfo;
|
||||
LockListInfoItemEntity currentKeyInfo = CommonDataManage().currentKeyInfo;
|
||||
AppLog.log(
|
||||
"startDate111:${currentKeyInfo.startDate} endDate:${currentKeyInfo.endDate}");
|
||||
DateTime startTime = DateTime.fromMillisecondsSinceEpoch(
|
||||
@ -148,17 +149,30 @@ class SenderBeforeDataManage {
|
||||
List<int> tokenList = changeStringListToIntList(tokenKey!);
|
||||
AppLog.log('---> ${entity.data?.userNos}');
|
||||
|
||||
IoSenderManage.senderCleanUpUsersCommand(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
authUserID:
|
||||
CommonDataManage().currentKeyInfo.senderUserId!.toString(),
|
||||
keyID: CommonDataManage().currentKeyInfo.keyId.toString(),
|
||||
userID: await Storage.getUid(),
|
||||
userNoList: entity.data!.userNos!,
|
||||
needAuthor: 1,
|
||||
publicKey: publicKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: tokenList);
|
||||
var cleanUpUsersData = CleanUpUsersCommand(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
authUserID: CommonDataManage().currentKeyInfo.senderUserId!.toString(),
|
||||
keyID: CommonDataManage().currentKeyInfo.keyId.toString(),
|
||||
userID: await Storage.getUid(),
|
||||
needAuthor: 1,
|
||||
publicKey: publicKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
userNoList: entity.data!.userNos!,
|
||||
token: tokenList,
|
||||
).packageData();
|
||||
CommandSenderManager().sendNormalData(cleanUpUsersData);
|
||||
|
||||
// IoSenderManage.senderCleanUpUsersCommand(
|
||||
// lockID: BlueManage().connectDeviceName,
|
||||
// authUserID:
|
||||
// CommonDataManage().currentKeyInfo.senderUserId!.toString(),
|
||||
// keyID: CommonDataManage().currentKeyInfo.keyId.toString(),
|
||||
// userID: await Storage.getUid(),
|
||||
// userNoList: entity.data!.userNos!,
|
||||
// needAuthor: 1,
|
||||
// publicKey: publicKeyDataList,
|
||||
// privateKey: getPrivateKeyList,
|
||||
// token: tokenList);
|
||||
|
||||
break;
|
||||
default:
|
||||
@ -167,18 +181,47 @@ class SenderBeforeDataManage {
|
||||
}
|
||||
}
|
||||
|
||||
// 清理用户
|
||||
Future<void> _cleanUpUsersReply(Reply reply) async {
|
||||
int status = reply.data[6];
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var token = reply.data.sublist(42, 46);
|
||||
List<String> strTokenList = changeIntListToStringList(token);
|
||||
Storage.setStringList(saveBlueToken, strTokenList);
|
||||
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<int>> getAddUserKeyData() async {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
LockListInfoItemEntity currentKeyInfo = CommonDataManage().currentKeyInfo;
|
||||
DateTime startTime =
|
||||
DateTime.fromMillisecondsSinceEpoch(currentKeyInfo.startDate! ~/ 1000);
|
||||
DateTime endTime =
|
||||
DateTime.fromMillisecondsSinceEpoch(currentKeyInfo.endDate! ~/ 1000);
|
||||
DateTime startTime = DateTime.fromMillisecondsSinceEpoch(currentKeyInfo.startDate! ~/ 1000);
|
||||
DateTime endTime = DateTime.fromMillisecondsSinceEpoch(currentKeyInfo.endDate! ~/ 1000);
|
||||
bool isRound = currentKeyInfo.keyType == 2;
|
||||
|
||||
var addUserData = AddUserCommand(
|
||||
|
||||
@ -32,12 +32,11 @@ class CommandSenderManager {
|
||||
|
||||
void initLockAddUserSucceedEvent() {
|
||||
// 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus
|
||||
_passCurrentLockInformationEvent =
|
||||
eventBus.on<LockAddUserSucceedEvent>().listen((event) {
|
||||
_passCurrentLockInformationEvent = eventBus.on<LockAddUserSucceedEvent>().listen((event) {
|
||||
if (event.type == 0) {
|
||||
_sendNormalData(dataBeforeAddTheUser);
|
||||
sendNormalData(dataBeforeAddTheUser);
|
||||
} else {
|
||||
_sendNormalData(event.dataList);
|
||||
sendNormalData(event.dataList);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -58,21 +57,22 @@ class CommandSenderManager {
|
||||
|
||||
List<int> value = command.packageData();
|
||||
if (isBeforeAddUser == true) {
|
||||
_sendNormalData(value);
|
||||
// 如果是添加用户之前调用协议 直接发送
|
||||
sendNormalData(value);
|
||||
} else {
|
||||
// 添加用户之后调用协议就要判断是否添加用户
|
||||
if (CommonDataManage().currentLockUserNo == 0) {
|
||||
// 先添加用户
|
||||
// 如果LockUserNo为0,先添加用户
|
||||
var entity = await SenderBeforeDataManage().getAddUserKeyData();
|
||||
_sendNormalData(entity);
|
||||
sendNormalData(entity);
|
||||
dataBeforeAddTheUser = value;
|
||||
return;
|
||||
} else {
|
||||
_sendNormalData(value);
|
||||
sendNormalData(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _sendNormalData(List<int> data) async {
|
||||
void sendNormalData(List<int> data) async {
|
||||
if (data.isNotEmpty) {
|
||||
EventBusManager().eventBusFir(
|
||||
EventSendModel(data: data, sendChannel: DataChannel.ble));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user