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