feat: 1,绑定星图配置接口对接及逻辑处理
2,获取个人信息新增星图配置相关未绑定成功校验处理
This commit is contained in:
parent
165f9dd080
commit
c6be67cc46
@ -37,7 +37,7 @@ class _StarLockLoginPageState extends State<StarLockLoginPage> {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
AppFirstEnterHandle().getAppFirstEnter(isAgreePrivacy);
|
||||
});
|
||||
StartChartManage().init();
|
||||
// StartChartManage().init();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -235,21 +235,21 @@ class _StarLockLoginPageState extends State<StarLockLoginPage> {
|
||||
}
|
||||
}
|
||||
: null)),
|
||||
SubmitBtn(
|
||||
btnName: '发送回声测试消息',
|
||||
onClick: () {
|
||||
StartChartManage().sendEchoMessage(
|
||||
ToPeerId: '3phX8Ng2cZHz5NtP8xAf6nYy2z1BYytoejgjoHrWMGhH');
|
||||
},
|
||||
),
|
||||
SubmitBtn(
|
||||
btnName: '发送对讲请求1',
|
||||
onClick: () {
|
||||
StartChartManage().sendCallRequestMessage(
|
||||
ToPeerId: 'CqKJUADeUZsHrSD4SEVnPBr73fbsHNUXCEq9kyCtE3wp',
|
||||
);
|
||||
},
|
||||
),
|
||||
// SubmitBtn(
|
||||
// btnName: '发送回声测试消息',
|
||||
// onClick: () {
|
||||
// StartChartManage().sendEchoMessage(
|
||||
// ToPeerId: '3phX8Ng2cZHz5NtP8xAf6nYy2z1BYytoejgjoHrWMGhH');
|
||||
// },
|
||||
// ),
|
||||
// SubmitBtn(
|
||||
// btnName: '发送对讲请求1',
|
||||
// onClick: () {
|
||||
// StartChartManage().sendCallRequestMessage(
|
||||
// ToPeerId: 'CqKJUADeUZsHrSD4SEVnPBr73fbsHNUXCEq9kyCtE3wp',
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
SizedBox(height: 50.w),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
|
||||
@ -140,7 +140,6 @@ class LockMainLogic extends BaseGetXController {
|
||||
return !connectResults.contains(ConnectivityResult.none);
|
||||
}
|
||||
|
||||
|
||||
/// 设置网络切换监听
|
||||
// Future<void> connectListener() async {
|
||||
// Connectivity().onConnectivityChanged.listen((ConnectivityResult result) {
|
||||
@ -304,6 +303,9 @@ class LockMainLogic extends BaseGetXController {
|
||||
@override
|
||||
Future<void> onReady() async {
|
||||
super.onReady();
|
||||
//初始化星图服务并绑定配置
|
||||
await StartChartManage().init();
|
||||
|
||||
// 初始化JPush服务并绑定设备ID
|
||||
final XSJPushProvider jpushProvider = XSJPushProvider();
|
||||
await jpushProvider.initJPushService();
|
||||
@ -313,7 +315,6 @@ class LockMainLogic extends BaseGetXController {
|
||||
// AppLog.log('onReady() LockMainLogic');
|
||||
UdpHelp().openUDP();
|
||||
BlueManage();
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@ -7,6 +7,7 @@ import 'package:star_lock/main/lockMian/lockMain/lockMain_page.dart';
|
||||
import 'package:star_lock/main/lockMian/lockMain/xhj/lockMain_xhj_state.dart';
|
||||
import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_entity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/talk/startChart/start_chart_manage.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/push/xs_jPhush.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
@ -39,7 +40,12 @@ class LockMainXHJLogic extends BaseGetXController {
|
||||
Storage.setBool(saveIsVip, entity.data!.isVip == 1);
|
||||
if (entity.data!.deviceId != null) {
|
||||
if (entity.data!.deviceId!.isEmpty) {
|
||||
bindDevice();
|
||||
bindPushDevice();
|
||||
}
|
||||
}
|
||||
if (entity.data!.starchart != null) {
|
||||
if (entity.data!.starchart!.starchartId!.isEmpty) {
|
||||
bindStarChart();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -68,18 +74,24 @@ class LockMainXHJLogic extends BaseGetXController {
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> bindDevice() async {
|
||||
Future<void> bindPushDevice() async {
|
||||
// 初始化JPush服务并绑定设备ID
|
||||
final XSJPushProvider jpushProvider = XSJPushProvider();
|
||||
await jpushProvider.initJPushService();
|
||||
await jpushProvider.initLocalNotification(isCancelLocalPush: false);
|
||||
}
|
||||
|
||||
//绑定星图
|
||||
Future<void> bindStarChart() async {
|
||||
//初始化星图服务并绑定配置
|
||||
await StartChartManage().init();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onReady() async {
|
||||
super.onReady();
|
||||
|
||||
bindDevice();
|
||||
bindPushDevice();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@ -41,7 +41,8 @@ class MinePersonInfoData {
|
||||
this.deviceId,
|
||||
this.lang,
|
||||
this.amazonAlexa,
|
||||
this.googleHome});
|
||||
this.googleHome,
|
||||
this.starchart});
|
||||
|
||||
MinePersonInfoData.fromJson(Map<String, dynamic> json) {
|
||||
mobile = json['mobile'];
|
||||
@ -62,6 +63,9 @@ class MinePersonInfoData {
|
||||
googleHome = json['googleHome'] != null
|
||||
? GoogleHome.fromJson(json['googleHome'])
|
||||
: null;
|
||||
starchart = json['starchart'] != null
|
||||
? Starchart.fromJson(json['starchart'])
|
||||
: null;
|
||||
}
|
||||
String? mobile;
|
||||
int? uid;
|
||||
@ -77,6 +81,7 @@ class MinePersonInfoData {
|
||||
String? lang;
|
||||
AmazonAlexa? amazonAlexa;
|
||||
GoogleHome? googleHome;
|
||||
Starchart? starchart;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
@ -98,6 +103,9 @@ class MinePersonInfoData {
|
||||
if (googleHome != null) {
|
||||
data['googleHome'] = googleHome!.toJson();
|
||||
}
|
||||
if (starchart != null) {
|
||||
data['starchart'] = starchart!.toJson();
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
@ -138,3 +146,28 @@ class GoogleHome {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Starchart {
|
||||
String? starchartId;
|
||||
String? starchartPeerPublicKey;
|
||||
String? starchartPeerPrivateKey;
|
||||
|
||||
Starchart(
|
||||
{this.starchartId,
|
||||
this.starchartPeerPublicKey,
|
||||
this.starchartPeerPrivateKey});
|
||||
|
||||
Starchart.fromJson(Map<String, dynamic> json) {
|
||||
starchartId = json['starchartId'];
|
||||
starchartPeerPublicKey = json['starchartPeerPublicKey'];
|
||||
starchartPeerPrivateKey = json['starchartPeerPrivateKey'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = Map<String, dynamic>();
|
||||
data['starchartId'] = this.starchartId;
|
||||
data['starchartPeerPublicKey'] = this.starchartPeerPublicKey;
|
||||
data['starchartPeerPrivateKey'] = this.starchartPeerPrivateKey;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@ -284,12 +284,11 @@ abstract class Api {
|
||||
final String updateZoneOffsetsAndLanguagesURL =
|
||||
'/cloudUser/updateSettings'; //更新云用户时区偏移与语言
|
||||
|
||||
final String starChartRegisterNodeURL =
|
||||
'/SL-A-1.0/peer/register'; // 星图--注册节点
|
||||
final String relayQueryInfoURL =
|
||||
'/SL-A-1.0/relay/query'; // 星图--中继查询
|
||||
final String reportInformationDataURL =
|
||||
'/SL-A-1.0/peer/login'; // 星图--信息上报
|
||||
final String starChartRegisterNodeURL = '/SL-A-1.0/peer/register'; // 星图--注册节点
|
||||
final String relayQueryInfoURL = '/SL-A-1.0/relay/query'; // 星图--中继查询
|
||||
final String reportInformationDataURL = '/SL-A-1.0/peer/login'; // 星图--信息上报
|
||||
final String analyzeInformationOtherEndURL =
|
||||
'/SL-A-1.0/peer/nslookup'; // 星图--解析对端信息
|
||||
final String bindUserStarchartURL =
|
||||
'/userStarchart/bindUserStarchart'; // 绑定星图配置
|
||||
}
|
||||
|
||||
@ -801,13 +801,12 @@ class ApiProvider extends BaseProvider {
|
||||
}));
|
||||
|
||||
// 电机扭力设置
|
||||
Future<Response> setMotorPowerData(int lockId, int motorTorsion) =>
|
||||
post(
|
||||
updateLockSettingUrl.toUrl,
|
||||
jsonEncode({
|
||||
'lockId': lockId,
|
||||
'motorTorsion': motorTorsion,
|
||||
}));
|
||||
Future<Response> setMotorPowerData(int lockId, int motorTorsion) => post(
|
||||
updateLockSettingUrl.toUrl,
|
||||
jsonEncode({
|
||||
'lockId': lockId,
|
||||
'motorTorsion': motorTorsion,
|
||||
}));
|
||||
|
||||
// 远程开锁
|
||||
Future<Response> remoteUnlockingOpenOrCloseLoadData(
|
||||
@ -2693,6 +2692,21 @@ class ApiProvider extends BaseProvider {
|
||||
// 'language': language,
|
||||
}),
|
||||
isUnShowLoading: true);
|
||||
|
||||
// 绑定星图配置
|
||||
Future<Response> bindUserStarchart(
|
||||
String starchartId,
|
||||
String starchartPeerPublicKey,
|
||||
String starchartPeerPrivateKey,
|
||||
) =>
|
||||
post(
|
||||
bindUserStarchartURL.toUrl,
|
||||
jsonEncode(<String, dynamic>{
|
||||
'starchartId': starchartId,
|
||||
'starchartPeerPublicKey': starchartPeerPublicKey,
|
||||
'starchartPeerPrivateKey': starchartPeerPrivateKey,
|
||||
}),
|
||||
isUnShowLoading: true);
|
||||
}
|
||||
|
||||
extension ExtensionString on String {
|
||||
|
||||
@ -2685,4 +2685,16 @@ class ApiRepository {
|
||||
);
|
||||
return LoginEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
// 绑定星图配置
|
||||
Future<LoginEntity> bindUserStarchart({
|
||||
required String starchartId,
|
||||
required String starchartPeerPublicKey,
|
||||
required String starchartPeerPrivateKey,
|
||||
}) async {
|
||||
final Response res = await apiProvider.bindUserStarchart(
|
||||
starchartId, starchartPeerPublicKey, starchartPeerPrivateKey);
|
||||
|
||||
return LoginEntity.fromJson(res.body);
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,8 @@ import 'package:get/get.dart';
|
||||
import 'package:pointycastle/export.dart' as pc;
|
||||
import 'package:star_lock/app_settings/app_settings.dart';
|
||||
import 'package:star_lock/flavors.dart';
|
||||
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/network/start_chart_api.dart';
|
||||
import 'package:star_lock/talk/startChart/command/message_command.dart';
|
||||
import 'package:star_lock/talk/startChart/constant/ip_constant.dart';
|
||||
@ -22,6 +24,7 @@ import 'package:star_lock/talk/startChart/handle/scp_message_handle.dart';
|
||||
import 'package:star_lock/talk/startChart/handle/scp_message_handler_factory.dart';
|
||||
import 'package:star_lock/talk/startChart/proto/talk_expect.pb.dart';
|
||||
import 'package:star_lock/talk/startChart/start_chart_talk_status.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/deviceInfo_utils.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
@ -93,6 +96,9 @@ class StartChartManage {
|
||||
await _onlineRelayService();
|
||||
// 上报
|
||||
await reportInformation();
|
||||
|
||||
//测试
|
||||
sendEchoMessage(ToPeerId: ToPeerId);
|
||||
}
|
||||
|
||||
/// 客户端注册
|
||||
@ -109,6 +115,28 @@ class StartChartManage {
|
||||
await _saveStarChartRegisterNodeToStorage(requestStarChartRegisterNode);
|
||||
FromPeerId = requestStarChartRegisterNode.peer!.id ?? '';
|
||||
}
|
||||
bindUserStarchart();
|
||||
}
|
||||
|
||||
//绑定星图配置
|
||||
Future<void> bindUserStarchart() async {
|
||||
try {
|
||||
final StarChartRegisterNodeEntity? registerNodeEntity =
|
||||
await Storage.getStarChartRegisterNodeInfo();
|
||||
|
||||
final LoginEntity entity = await ApiRepository.to.bindUserStarchart(
|
||||
starchartId: registerNodeEntity?.peer?.id ?? '',
|
||||
starchartPeerPublicKey: registerNodeEntity?.peer?.publicKey ?? '',
|
||||
starchartPeerPrivateKey: registerNodeEntity?.peer?.privateKey ?? '',
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
AppLog.log('绑定成功');
|
||||
} else {
|
||||
AppLog.log('绑定失败');
|
||||
}
|
||||
} catch (e) {
|
||||
AppLog.log('Error bindUserStarchart: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// 中继查询
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user