修改真实userId、lockId

This commit is contained in:
魏少阳 2023-08-30 10:56:18 +08:00
parent e91e45d71a
commit ca513ac732
12 changed files with 193 additions and 45 deletions

View File

@ -163,7 +163,7 @@
"end":"结束",
"allDay":"全天",
"save":"保存",
"normallyOpenModeTip":"在设置的常开时间内,锁打开后将一直处于打开的状态,直到被手动关闭",
"normallyOpenModeTip":"在设置的常开时间内,锁打开后将一直处于打开的状态,直到被手动关闭",
"pleaseSeletLockVolume":"请选择锁音量",
"lockSoundTip":"功能开启后,你将可以听到智能锁的提示音。包括电量过低,密码错误等提示。",
"low":"低",

View File

@ -20,6 +20,16 @@ PODS:
- fluttertoast (0.0.2):
- Flutter
- Toast
- geocoding_ios (1.0.5):
- Flutter
- google_maps_flutter_ios (0.0.1):
- Flutter
- GoogleMaps (< 8.0)
- GoogleMaps (5.2.0):
- GoogleMaps/Maps (= 5.2.0)
- GoogleMaps/Base (5.2.0)
- GoogleMaps/Maps (5.2.0):
- GoogleMaps/Base
- image_picker_ios (0.0.1):
- Flutter
- package_info_plus (0.4.5):
@ -50,6 +60,8 @@ DEPENDENCIES:
- Flutter (from `Flutter`)
- flutter_native_contact_picker (from `.symlinks/plugins/flutter_native_contact_picker/ios`)
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
- geocoding_ios (from `.symlinks/plugins/geocoding_ios/ios`)
- google_maps_flutter_ios (from `.symlinks/plugins/google_maps_flutter_ios/ios`)
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
@ -63,6 +75,7 @@ SPEC REPOS:
- AMap3DMap
- AMapFoundation
- AMapLocation
- GoogleMaps
- Protobuf
- SwiftProtobuf
- Toast
@ -82,6 +95,10 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_native_contact_picker/ios"
fluttertoast:
:path: ".symlinks/plugins/fluttertoast/ios"
geocoding_ios:
:path: ".symlinks/plugins/geocoding_ios/ios"
google_maps_flutter_ios:
:path: ".symlinks/plugins/google_maps_flutter_ios/ios"
image_picker_ios:
:path: ".symlinks/plugins/image_picker_ios/ios"
package_info_plus:
@ -108,6 +125,9 @@ SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
flutter_native_contact_picker: bd430ba0fbf82768bb50c2c52a69a65759a8f907
fluttertoast: fafc4fa4d01a6a9e4f772ecd190ffa525e9e2d9c
geocoding_ios: a389ea40f6f548de6e63006a2e31bf66ff80769a
google_maps_flutter_ios: abdac20d6ce8931f6ebc5f46616df241bfaa2cfd
GoogleMaps: 025272d5876d3b32604e5c080dc25eaf68764693
image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5
package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943

View File

@ -68,6 +68,7 @@ class DeletUserCommand extends SenderProtocol {
data.addAll(utf8.encode(delUserID!));
data = getFixedLengthList(data, 20 - delUserIDLength);
// token
data.addAll(token!);
if(needAuthor == 0){

View File

@ -39,6 +39,7 @@ class LockSetLogic extends BaseGetXController{
Storage.setStringList(saveBlueToken, saveStrList);
int status = reply.data[6];
print("status:$status");
switch(status){
case 0x00:
//
@ -56,10 +57,10 @@ class LockSetLogic extends BaseGetXController{
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
IoSenderManage.deletUser(
lockID:BlueManage().connectDeviceName,
authUserID:"100001",
lockID:state.getKeyInfosData.value.bluetooth!.bluetoothDeviceName,
authUserID:await Storage.getUserId(),
keyID:"1",
delUserID:"100001",
delUserID:await Storage.getUserId(),
needAuthor:1,
publicKey:publicKeyDataList,
privateKey:getPrivateKeyList,
@ -87,8 +88,8 @@ class LockSetLogic extends BaseGetXController{
}
Future<void> deletUserAction() async {
BlueManage().judgeReconnect("AD01447A-30B5-A780-E778-DED3BDCB613E", "TMH_c3570480da8d", (DeviceConnectionState state) async {
if (state == DeviceConnectionState.connected){
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
if (connectionState == DeviceConnectionState.connected){
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
@ -98,9 +99,9 @@ class LockSetLogic extends BaseGetXController{
var token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!);
print("openDoorTokenPubToken:$getTokenList");
print("state.getKeyInfosData.value.bluetooth!.bluetoothDeviceName:${state.getKeyInfosData.value.bluetooth!.bluetoothDeviceName}");
IoSenderManage.deletUser(
lockID:BlueManage().connectDeviceName,
lockID:state.getKeyInfosData.value.bluetooth!.bluetoothDeviceName,
authUserID:"100001",
keyID:"1",
delUserID:"100001",

View File

@ -16,6 +16,7 @@ import '../../../blue/io_tool/io_tool.dart';
import '../../../blue/io_tool/manager_event_bus.dart';
import '../../../blue/sender_manage.dart';
import '../../../login/login/entity/LoginData.dart';
import '../../../login/login/entity/LoginEntity.dart';
import '../../../tools/baseGetXController.dart';
import '../../../tools/storage.dart';
import 'lockDetail_state.dart';
@ -77,11 +78,17 @@ class LockDetailLogic extends BaseGetXController{
case 0x06:
//
print("${reply.commandType}需要鉴权");
String? userId = '';
final data = await Storage.getString('userLoginData');
if (data != null && data.isNotEmpty) {
userId = LoginEntity.fromJson(jsonDecode(data)).data!.userid.toString();
}
IoSenderManage.senderOpenLock(
keyID: "1",
userID: "100001",
userID: await Storage.getUserId(),
openMode: 1,
openTime: 0x11223344,
openTime: DateTime.now().millisecondsSinceEpoch,
token: tokenData,
needAuthor: 1,
signKey: signKeyDataList,
@ -207,9 +214,9 @@ class LockDetailLogic extends BaseGetXController{
IoSenderManage.senderEditUser(
lockID:BlueManage().connectDeviceName,
authUserID:"100001",
authUserID:await Storage.getUserId(),
keyID:"1",
userID:"100001",
userID:await Storage.getUserId(),
openMode:1,
keyType:1,
startDate:0x11223344,
@ -270,7 +277,7 @@ class LockDetailLogic extends BaseGetXController{
IoSenderManage.senderFactoryDataReset(
lockID:BlueManage().connectDeviceName,
userID:"100001",
userID:await Storage.getUserId(),
keyID:"1",
needAuthor:1,
publicKey:publicKeyDataList,
@ -298,7 +305,7 @@ class LockDetailLogic extends BaseGetXController{
//
Future<void> openDoorAction() async {
BlueManage().judgeReconnect("AD01447A-30B5-A780-E778-DED3BDCB613E", "TMH_c3570480da8d", (DeviceConnectionState state) async {
BlueManage().judgeReconnect(state.keyInfos.value.bluetooth!.bluetoothDeviceId!, state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (DeviceConnectionState state) async {
if (state == DeviceConnectionState.connected){
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
@ -310,16 +317,15 @@ class LockDetailLogic extends BaseGetXController{
List<int> getTokenList = changeStringListToIntList(token!);
print("openDoorTokenPubToken:$getTokenList");
// var userId = "";
// String? userId = '';
// final data = await Storage.getString('userLoginData');
// print("getLoginData:$data");
// if (data != null && data.isNotEmpty) {
// userId = LoginData.fromJson(jsonDecode(data)).userid as String;
// userId = LoginEntity.fromJson(jsonDecode(data)).data!.userid.toString();
// }
// print("userId:$userId");
IoSenderManage.senderOpenLock(
keyID: "1",
userID: "10001",
userID: await Storage.getUserId(),
openMode: 1,
openTime: DateTime.now().millisecondsSinceEpoch,
token: getTokenList,
@ -333,7 +339,7 @@ class LockDetailLogic extends BaseGetXController{
//
Future<void> editLockUserAction() async {
BlueManage().judgeReconnect("AD01447A-30B5-A780-E778-DED3BDCB613E", "TMH_c3570480da8d", (DeviceConnectionState state) async {
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
if (state == DeviceConnectionState.connected){
var publicKey = await Storage.getStringList(saveBluePublicKey);
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
@ -348,9 +354,9 @@ class LockDetailLogic extends BaseGetXController{
print("privateKey:$privateKey token:$token");
IoSenderManage.senderEditUser(
lockID:BlueManage().connectDeviceName,
authUserID:"100001",
authUserID:await Storage.getUserId(),
keyID:"1",
userID:"100001",
userID:await Storage.getUserId(),
openMode:1,
keyType:1,
startDate:0x11223344,
@ -368,7 +374,7 @@ class LockDetailLogic extends BaseGetXController{
//
Future<void> transferPermissionsAction() async {
BlueManage().judgeReconnect("AD01447A-30B5-A780-E778-DED3BDCB613E", "TMH_c3570480da8d", (DeviceConnectionState state) async {
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
if (state == DeviceConnectionState.connected){
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
@ -382,9 +388,9 @@ class LockDetailLogic extends BaseGetXController{
IoSenderManage.senderTransferPermissions(
lockID:BlueManage().connectDeviceName,
authUserID:"100001",
authUserID:await Storage.getUserId(),
keyID:"1",
oldUserID:"100001",
oldUserID:await Storage.getUserId(),
newUserID:"100002",
needAuthor:1,
publicKey:publicKeyDataList,
@ -397,7 +403,7 @@ class LockDetailLogic extends BaseGetXController{
//
Future<void> factoryDataResetAction() async {
BlueManage().judgeReconnect("AD01447A-30B5-A780-E778-DED3BDCB613E", "TMH_c3570480da8d", (DeviceConnectionState state) async {
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
if (state == DeviceConnectionState.connected){
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
@ -410,7 +416,7 @@ class LockDetailLogic extends BaseGetXController{
IoSenderManage.senderFactoryDataReset(
lockID:BlueManage().connectDeviceName,
userID:"100001",
userID:await Storage.getUserId(),
keyID:"1",
needAuthor:1,
publicKey:publicKeyDataList,
@ -424,13 +430,13 @@ class LockDetailLogic extends BaseGetXController{
//
Future<void> connectBlue() async {
//
BlueManage().connect("AD01447A-30B5-A780-E778-DED3BDCB613E", "TMH_c3570480da8d", connectStateCallBack: (DeviceConnectionState state) async {
BlueManage().connect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, connectStateCallBack: (DeviceConnectionState state) async {
if (state == DeviceConnectionState.connected){
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
IoSenderManage.senderGetLockStatu(
lockID:BlueManage().connectDeviceName,
userID:"100001",
userID:await Storage.getUserId(),
privateKey:getPrivateKeyList,
);
}
@ -455,8 +461,11 @@ class LockDetailLogic extends BaseGetXController{
super.onInit();
print("lockDetail_onInit()");
BlueManage().connectDeviceName = "TMH_c3570480da8d";
BlueManage().connectDeviceMacAddress = "AD01447A-30B5-A780-E778-DED3BDCB613E";
// BlueManage().connectDeviceName = "TMH_c3570480da8d";
// BlueManage().connectDeviceMacAddress = "AD01447A-30B5-A780-E778-DED3BDCB613E";
// BlueManage().connectDeviceName = state.keyInfos.value.bluetooth!.bluetoothDeviceName!;
// BlueManage().connectDeviceMacAddress = state.keyInfos.value.bluetooth!.bluetoothDeviceId!;
//
// connectBlue();

View File

@ -4,6 +4,7 @@ import 'package:get/get.dart';
import '../../../appRouters.dart';
import '../../../app_settings/app_colors.dart';
import '../../../blue/blue_manage.dart';
import '../../../translations/trans_lib.dart';
import '../../lockMian/entity/lockInfoEntity.dart';
import 'lockDetail_logic.dart';
@ -24,8 +25,19 @@ class _LockDetailPageState extends State<LockDetailPage> {
final logic = Get.put(LockDetailLogic());
final state = Get.find<LockDetailLogic>().state;
@override
void initState() {
// TODO: implement initState
super.initState();
state.keyInfos.value = widget.keyInfo;
BlueManage().connectDeviceName = state.keyInfos.value.bluetooth!.bluetoothDeviceName!;
BlueManage().connectDeviceMacAddress = state.keyInfos.value.bluetooth!.bluetoothDeviceId!;
}
@override
Widget build(BuildContext context) {
return Container(
width: 1.sw,
height: 1.sh - ScreenUtil().statusBarHeight*2,
@ -40,7 +52,7 @@ class _LockDetailPageState extends State<LockDetailPage> {
}
Widget topWidget() {
KeyInfos keyInfo = widget.lockMainEntity.data!.keyInfos![0];
// KeyInfos keyInfo = widget.lockMainEntity.data!.keyInfos![0];
return Column(
children: [
SizedBox(height: 30.h),
@ -50,7 +62,7 @@ class _LockDetailPageState extends State<LockDetailPage> {
Align(
alignment: Alignment.center,
child: Text(
keyInfo.lockAlias!,
widget.keyInfo.lockAlias!,
style:
TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w400),
)),

View File

@ -1,5 +1,10 @@
import 'package:get/get.dart';
import '../../lockMian/entity/lockInfoEntity.dart';
class LockDetailState {
Rx<KeyInfos> keyInfos = KeyInfos().obs;
}

View File

@ -232,6 +232,7 @@ class KeyInfos {
int? doubleVerification;
String? keyName;
LockVersion? lockVersion;
Bluetooth? bluetooth;
String? lockName;
int? monitorFlag;
Null? bondPassword;
@ -315,7 +316,8 @@ class KeyInfos {
this.lockMac,
this.wirelessKeypadFeatureValue,
this.autoLockTime,
this.tamperAlert});
this.tamperAlert,
this.bluetooth});
KeyInfos.fromJson(Map<String, dynamic> json) {
lightingTime = json['lightingTime'];
@ -373,6 +375,9 @@ class KeyInfos {
wirelessKeypadFeatureValue = json['wirelessKeypadFeatureValue'];
autoLockTime = json['autoLockTime'];
tamperAlert = json['tamperAlert'];
bluetooth = json['bluetooth'] != null
? Bluetooth.fromJson(json['bluetooth'])
: null;
}
Map<String, dynamic> toJson() {
@ -432,6 +437,9 @@ class KeyInfos {
data['wirelessKeypadFeatureValue'] = wirelessKeypadFeatureValue;
data['autoLockTime'] = autoLockTime;
data['tamperAlert'] = tamperAlert;
if (bluetooth != null) {
data['bluetooth'] = bluetooth!.toJson();
}
return data;
}
}
@ -475,4 +483,33 @@ class LockVersion {
data['groupId'] = groupId;
return data;
}
}
}
class Bluetooth {
String? bluetoothDeviceId;
String? bluetoothDeviceName;
List<dynamic>? publicKey;
List<dynamic>? privateKey;
Bluetooth(
{this.bluetoothDeviceId,
this.bluetoothDeviceName,
this.publicKey,
this.privateKey});
Bluetooth.fromJson(Map<String, dynamic> json) {
bluetoothDeviceId = json['bluetoothDeviceId'];
bluetoothDeviceName = json['bluetoothDeviceName'];
publicKey = json['publicKey'];
privateKey = json['publicKey'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['bluetoothDeviceId'] = bluetoothDeviceId;
data['bluetoothDeviceName'] = bluetoothDeviceName;
data['publicKey'] = publicKey;
data['privateKey'] = privateKey;
return data;
}
}

View File

@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
// import 'package:google_maps_flutter/google_maps_flutter.dart';
class LockAddressGooglePage extends StatefulWidget {
const LockAddressGooglePage({Key? key}) : super(key: key);
@ -9,6 +11,50 @@ class LockAddressGooglePage extends StatefulWidget {
}
class _LockAddressGooglePageState extends State<LockAddressGooglePage> {
var deviceFindData = Get.arguments['data'];
var source;
var result;
// LatLng _kMapCenter;
// CameraPosition _kInitialPosition;
var _markers;
var setmarkers;
var restaurantMarker;
bool isSetupReady = false;
String? currentAddress;
@override
void initState() {
super.initState();
// doSetup();
}
//
// doSetup() async {
// List<Placemark> placemarks = await placemarkFromCoordinates(deviceFindData.latitude, deviceFindData.longitude);
// Placemark place1 = placemarks[0];
// currentAddress = "${place1.country} ${place1.administrativeArea} ${place1.locality} ${place1.subLocality} ${place1.name}";
// // print("objectfasdfasdfasdfasdf:${placemarks}fasdfasdf${place1} ${currentAddress}");
//
// restaurantMarker = await BitmapDescriptor.fromAssetImage(
// ImageConfiguration(size: Size(w(27), h(31))), Platform.isIOS ? R.assetsImgsDeviceFindDeviceIcon : R.assetsImgsDeviceFindDeviceAndroidIcon);
// _markers = [
// Marker(
// markerId: MarkerId("marker_2"),
// infoWindow: InfoWindow(title: currentAddress),
// icon: restaurantMarker,
// // position:_kMapCenter,
// ),
// ];
// setmarkers = _markers.toSet();
// setState(() {
// isSetupReady = true;
// });
// }
@override
Widget build(BuildContext context) {
return const Placeholder();

View File

@ -68,9 +68,9 @@ class SaveLockLogic extends BaseGetXController {
IoSenderManage.senderAddUser(
lockID:BlueManage().connectDeviceName,
authUserID:"100001",
authUserID:await Storage.getUserId(),
keyID:"1",
userID:"100001",
userID:await Storage.getUserId(),
openMode:1,
keyType:1,
startDate:0x11223344,
@ -182,7 +182,7 @@ class SaveLockLogic extends BaseGetXController {
//
Future<void> addUserConnectBlue() async {
//
BlueManage().judgeReconnect("AD01447A-30B5-A780-E778-DED3BDCB613E", "TMH_c3570480da8d", (DeviceConnectionState state) async {
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
if (state == DeviceConnectionState.connected){
//
var privateKey = await Storage.getStringList(saveBluePrivateKey);
@ -198,11 +198,10 @@ class SaveLockLogic extends BaseGetXController {
}
IoSenderManage.senderAddUser(
// lockID:BlueManage().connectDeviceName,
lockID: "TMH_c3570480da8d",
authUserID:"100001",
lockID: BlueManage().connectDeviceName,
authUserID:await Storage.getUserId(),
keyID:"1",
userID:"100001",
userID:await Storage.getUserId(),
openMode:1,
keyType:1,
startDate:0x11223344,
@ -264,13 +263,13 @@ class SaveLockLogic extends BaseGetXController {
//
Future<void> _getLockStatus() async {
//
BlueManage().judgeReconnect("AD01447A-30B5-A780-E778-DED3BDCB613E", "TMH_c3570480da8d", (DeviceConnectionState state) async {
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
if (state == DeviceConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
IoSenderManage.senderGetLockStatu(
lockID:BlueManage().connectDeviceName,
userID:"100001",
userID:await Storage.getUserId(),
privateKey:getPrivateKeyList,
);
}

View File

@ -1,8 +1,12 @@
/*
*
* */
import 'dart:convert';
import 'package:shared_preferences/shared_preferences.dart';
import '../login/login/entity/LoginEntity.dart';
class Storage {
Storage._internal();
@ -113,4 +117,15 @@ class Storage {
SharedPreferences sp = await SharedPreferences.getInstance();
sp.clear();
}
static Future<String?> getUserId() async {
String? userId = '';
final data = await Storage.getString('userLoginData');
if (data != null && data.isNotEmpty) {
userId = LoginEntity.fromJson(jsonDecode(data)).data!.userid.toString();
}
return userId;
}
}

View File

@ -73,7 +73,6 @@ dependencies:
url_launcher: ^6.1.12
#蓝牙
flutter_reactive_ble: ^5.1.1
# flutter_blue_plus: ^1.10.5
#
event_bus: ^2.0.0
#菊花
@ -99,6 +98,10 @@ dependencies:
#高德地图地图
amap_flutter_map: ^3.0.0
# 谷歌地图
google_maps_flutter: ^2.2.5
geocoding: ^2.1.0
dev_dependencies:
flutter_test:
sdk: flutter