Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
423f307f97
@ -1,49 +1,49 @@
|
||||
{
|
||||
{
|
||||
"config": {
|
||||
"emas.appKey":"333904040",
|
||||
"emas.appSecret":"c316965fe0a74fc9a481a5c44a535dc2",
|
||||
"emas.packageName":"cn.starlock.lock",
|
||||
"hotfix.idSecret":"333904040-1",
|
||||
"hotfix.rsaSecret":"MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCTjeqT4cX/VTcInnWLLxo2f+0W1vKfPLwpHr9rYeW1pELlySFFeDusdaV8vBBYRE2A4Mti6wuVRCw67YIif7gK+ZLipALWob/cPxC4pcbqJ0S5QznM8qPW2nheWhvuZA9SenO5OyNnQvhBeSMK0VaGBnCBrznm52Mq7yb1cQDlosGtTwDgezt5073xDJFhefYg7BzurAlCgmS4BRX0l1i5GWsv+R5hWLWyhO+dI2deArgbYiW0575f5L1zywJ4BJ/3qOgsJoSflLgtTVLlmbAXI1Xo023UWtfnnowH71avDn+SQ5agqZepp6pkoXiFhC7DN9gLTknHTb03mDHODOW1AgMBAAECggEADrs5c0A0M1S/pNWlKJswQ8ar1f7pxCodIwHV3JOuil726tgUwUnKs2Iffn+MJjPThQ1sYNjUlDd1LwDtYCJeLoJSPtxfCCyn6gZF1hl+7Xu0Kcbja2nCH746DDl01m0Y9oQRL6oO081k2ayNahQSTlkwPFJRNpNdXDj6K8D3dPWPCBw7ECFKYpoDmPt+lNwqPPIWlVwYFRwhhCRuSPZsejO+a65gWZhm6uWDkh/EtPzdCIkrpfxbfqSnM6t+WHKmA3Gmm6AiwNLrzUGJ5lIsLXNuvaXFpsjBpVq7x9Ff86Cj0vJ7wdIRn7sP1Wlw6SosKZZwn9+zDLQU0Prge0Mn9QKBgQDKFXnzWqdmG6PxykyHJrXeLvQyMBdy6x91lmNSYGxYYEG2Tr1LR+P5r1oL/VRmuT43qWxubL7gEMqMGOVEMwKN6cEBTFDIOyqpNgR5Nnt0DrYMDhca3Wxc1/SkzuaVsRPHAKn8bChWGtq58/VuuZIY8SRVTWLgRWrnXFWCbKq0QwKBgQC67AVJwymxxIYt7UVRxtihd84SIGhRluEXG3O8PzK7Je5qDgBkLc+khnTvnGQyG7AJwtMpIbzmzJyu76pjiga1XJnYCO1QXhayMRlieSkrk2C4u9hnmeni24iGDUkV7yCnwsTjFaQ3lq1XtrJJKB9rUeBndXwuN06lTIqokSuapwKBgQCYCEpEHCqediMEMDcc4rGmo1qSO34Yte1oEKlOez5nypsFZf2hmkdYPGUZahBKbAjz5WGvPd7oQZmwhrZNdbbxPzA2Is0Ppvu0a/A3pRaBvOOW9C7LxlPVEZ97MjFl4t/HMqewQUqjZPazOWenUrMoUpsMFflSUsdXoi6uvcQ7cwKBgGNS1tyDH7yeOM5erd7uUl46Uv2+yq/QBHtK0wzMaCCZ3z3rgrm4vgUmjSxlZbhajgghxiKtErtxLjCmmVubFEV6lyT8WV3DITw+asawqvfEsDh5WFx0pJsvHDRfCt7k2e1KyWQBM+l131Ykdkf5Ufis4RkYjIviR5/+NA+uVAUxAoGAEIrRsaTDij9AX3/wD0XpDavFJdHzkvX259b6v0aASVoYlzAfj5bh1fZI90ex+MDibx3UyhHOVS2kk6q/TPAoevVlfS6IDfV0VJJZvie52qumfhttBpvH302rzrdEiZEhRd2UuKkBw7hsW+NlJEmoV0tj3xiP2vLLPnsaua9F3/g=",
|
||||
"httpdns.accountId":"125761",
|
||||
"httpdns.secretKey":"f77f39c6f0e66d7c169aa7e8d87dfe13",
|
||||
"appmonitor.tlog.rsaSecret":"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCEYcyLDY/8H6714r5FuRuv94oWLod90sa5dwcJ5l8GmRMscFPxMXt9cNiKwL7zqPCWws+ApSfHczFnRgvZQX/p/t0U1nPNdotLqkLuzXNBim+TpfNnCvIoiVujAGXwdIGo7oaxci9+VV/1TFs5lm9M1wsreT2u+62cCqi/h16ZkQIDAQAB",
|
||||
"appmonitor.rsaSecret":"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCEYcyLDY/8H6714r5FuRuv94oWLod90sa5dwcJ5l8GmRMscFPxMXt9cNiKwL7zqPCWws+ApSfHczFnRgvZQX/p/t0U1nPNdotLqkLuzXNBim+TpfNnCvIoiVujAGXwdIGo7oaxci9+VV/1TFs5lm9M1wsreT2u+62cCqi/h16ZkQIDAQAB"
|
||||
},
|
||||
"emas.appKey":"334068743",
|
||||
"emas.appSecret":"64de537f14984159a66ada10e54c6b63",
|
||||
"emas.packageName":"com.skychip.lock",
|
||||
"hotfix.idSecret":"334068743-1",
|
||||
"hotfix.rsaSecret":"MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCrcYP7FeYbeYakUMBa2Z5PtVh7LsuS+CfAM6GUjNUDByktVz2lFmZatFvMHn7xuxg6rgsRMrZ9IFziLC4xGltwHhSsCkr6cNoVZODAIXpowq+/Uwg3Gdbw/SOOT5dV70h5Dt3ztORVlobghCb5D74jgn6pqQVmhpSbrS+7zZTzcyKhsvRbQEx3tLa98uCDdIOjym4Jk0+dANCpVOTCPYbQtxewUKZv4ZcpIF0vwqVmAmNjjK04Bp6rhpM1pSxfIo3k6jwng9E+9iwmQkjk7NsexqyzXGmBywUBpSqFBo4bLLrGByqN/kAMAXpchRCBpx9Q311RHJb1T98n0wRimT5HAgMBAAECggEAClNE2ptgB2mTRVQjsZUHps9KK+kOk6RkaHvzkEnHDm6g+T0W1ll6Ap54JNv1U0OsWuRegEOon/KSBYEZqxVmSmNVZWMdTuX7DGzN6GRbxfFruj8a8I6a1lq4iHqcp61IlRnjHilX0xvEtcLfwgJDtknGrRsj2x/h1Vph1JK2FM9RqupT7O7Jy0ehkpVeyGWYLHcFKFThECRPFLHqAwBIY3aU6wp1G8NxkDRxj+C2cF4/cIEHFa7ZsEmVpNOI01qjntlFylNumuR+Ehz6DBKKT72eeVz+gMpnHs+ILGe0ov54soMobBTisw2dFdP9StHnnjoRwOH/KZx3iySerCqK6QKBgQD8cYrCvGlNl0x/fen1Er0Lfks5yVoYQ1ilMag82W8odNjBlcRFwZ+tCjowh55sA2tlQ+cYJxIhQXa7ukk/ILCz9DIHgmwJy4xDRrXonuUKRIkG7859H2/cA2hFAIgNIl6GxJXhGucnWarwbtgX5I7fdLgWAQrAAPjYgET9E4fJfQKBgQCt29cQp63keXKaV2NPVr+axwyOpF0wBQ5frdUVEsBE0hvtkymWThmdnAMuhFJA9+qb4LPxYUFS/MGPl01KhNoU/t2nJdMIWqGPt5eFf+lvzfyk/Jmr7YzpvcpKgfj0orrlIz5gZO5QajGwjlPYtxcu7FLdh7w46uT+P4J+28ySEwKBgQCn9JcAt0BMalRwIoMNFdmHExDTsp5ptCz/Q4mOao/lV9B7A7zhOFCXXU2XyjNh4+iJKGNRk3UhgR+RCQEAqixGnjrG+kQNREre2+XdjhIPAcg1QEmev9K5i97MwezC6FIB0jtx2Gdgq+zqKKVHSD6yd0KfCTRwyHTH/pdn1Z2rNQKBgHeF/nmdvUeoUqhW0ZhWvAztMO3Tg5kisLoIaMg/Bt2JUNfoZxvE/4lCG1HceCvgBHM7bJnSUbV6vJs52lITuVXbzYg+0bEZlZ6XCd0mjdZmV30Zh5ASFOEQsES+y+drBG/I5fYhDVFNYHHPt0bywEZrA6D20uiSW/GKuez6sM3vAoGATm3cLmUCauphKbaVjUB8bh6w9fvgFJnU5c12wytCy9D6TyxtHO6vL1r/KN51ejp5Ht6MuqOBTJztDcXjLbQMBvmw/SRSqQfeiBzAnUDt9MTy2c8GH135jlhBxgSF6JpeQ56uIXc4/rdM5XH5M5qmM7HJtKcLjlC7GCDIhWEvZM0=",
|
||||
"httpdns.accountId":"100674",
|
||||
"httpdns.secretKey":"6cd4984095d53f6f311424cc9299257b",
|
||||
"appmonitor.tlog.rsaSecret":"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCW084k+HG1OOaSY2B2N6aj4AOz8RhInqlaFr7BbQrqmPwzHC2Co0N/jmbBbxGP7oPsy7yF9zn/hJiuvzlQfjtK85IXAYUKj7IcLashQUT5lrGYlObCznH2qOPkw8OP+cboP51uWIeXFMYatwXRR05vtWVLEeUhaFE1onzQtcG0YwIDAQAB",
|
||||
"appmonitor.rsaSecret":"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCW084k+HG1OOaSY2B2N6aj4AOz8RhInqlaFr7BbQrqmPwzHC2Co0N/jmbBbxGP7oPsy7yF9zn/hJiuvzlQfjtK85IXAYUKj7IcLashQUT5lrGYlObCznH2qOPkw8OP+cboP51uWIeXFMYatwXRR05vtWVLEeUhaFE1onzQtcG0YwIDAQAB"
|
||||
},
|
||||
"services": {
|
||||
"hotfix_service":{
|
||||
"status":0,
|
||||
"version":"3.3.9"
|
||||
"status":1,
|
||||
"version":"3.4.0"
|
||||
},
|
||||
"ha-adapter_service":{
|
||||
"status":0,
|
||||
"status":1,
|
||||
"version":"1.2.3.0-open"
|
||||
},
|
||||
"feedback_service":{
|
||||
"status":0,
|
||||
"status":1,
|
||||
"version":"3.4.2"
|
||||
},
|
||||
"tlog_service":{
|
||||
"status":0,
|
||||
"status":1,
|
||||
"version":"1.1.7.0-open"
|
||||
},
|
||||
"httpdns_service":{
|
||||
"status":0,
|
||||
"version":"2.3.3"
|
||||
"status":1,
|
||||
"version":"2.3.5"
|
||||
},
|
||||
"apm_service":{
|
||||
"status":0,
|
||||
"status":1,
|
||||
"version":"1.1.3.0-open"
|
||||
},
|
||||
"man_service":{
|
||||
"status":0,
|
||||
"status":1,
|
||||
"version":"1.2.7"
|
||||
},
|
||||
"cps_service":{
|
||||
"status":1,
|
||||
"version":"3.8.8.1"
|
||||
}
|
||||
},
|
||||
"use_maven":true,
|
||||
"proguard_keeplist":"\n#httpdns\n-keep class com.taobao.** {*;}\n-keep class com.alibaba.** {*;}\n-keep class com.ta.**{*;}\n-keep class com.ut.**{*;}\n-dontwarn com.taobao.**\n-dontwarn com.alibaba.**\n-dontwarn com.ta.**\n-dontwarn com.ut.**\n\n#cps\n-keep class com.taobao.** {*;}\n-keep class com.alibaba.** {*;}\n-keep class com.ta.**{*;}\n-keep class com.ut.**{*;}\n-dontwarn com.taobao.**\n-dontwarn com.alibaba.**\n-dontwarn com.ta.**\n-dontwarn com.ut.**\n-keepclasseswithmembernames class ** {\nnative <methods>;\n}\n-keepattributes Signature\n-keep class sun.misc.Unsafe { *; }\n-keep class com.alipay.** {*;}\n-dontwarn com.alipay.**\n-keep class anet.**{*;}\n-keep class org.android.spdy.**{*;}\n-keep class org.android.agoo.**{*;}\n-dontwarn anet.**\n-dontwarn org.android.spdy.**\n-dontwarn org.android.agoo.**\n\n#hotfix\n#基线包使用,生成mapping.txt\n-printmapping mapping.txt\n#生成的mapping.txt在app/buidl/outputs/mapping/release路径下,移动到/app路径下\n#修复后的项目使用,保证混淆结果一致\n#-applymapping mapping.txt\n#hotfix\n-keep class com.taobao.sophix.**{*;}\n-keep class com.ta.utdid2.device.**{*;}\n#防止inline\n-dontoptimize\n\n#man\n-keep class com.taobao.** {*;}\n-keep class com.alibaba.** {*;}\n-keep class com.ta.**{*;}\n-keep class com.ut.**{*;}\n-dontwarn com.taobao.**\n-dontwarn com.alibaba.**\n-dontwarn com.ta.**\n-dontwarn com.ut.**\n\n#feedback\n-keep class com.taobao.** {*;}\n-keep class com.alibaba.** {*;}\n-keep class com.ta.**{*;}\n-keep class com.ut.**{*;}\n-dontwarn com.taobao.**\n-dontwarn com.alibaba.**\n-dontwarn com.ta.**\n-dontwarn com.ut.**\n"
|
||||
},
|
||||
"use_maven":true,
|
||||
"proguard_keeplist":"\n#httpdns\n-keep class com.taobao.** {*;}\n-keep class com.alibaba.** {*;}\n-keep class com.ta.**{*;}\n-keep class com.ut.**{*;}\n-dontwarn com.taobao.**\n-dontwarn com.alibaba.**\n-dontwarn com.ta.**\n-dontwarn com.ut.**\n\n#cps\n-keep class com.taobao.** {*;}\n-keep class com.alibaba.** {*;}\n-keep class com.ta.**{*;}\n-keep class com.ut.**{*;}\n-dontwarn com.taobao.**\n-dontwarn com.alibaba.**\n-dontwarn com.ta.**\n-dontwarn com.ut.**\n-keepclasseswithmembernames class ** {\nnative <methods>;\n}\n-keepattributes Signature\n-keep class sun.misc.Unsafe { *; }\n-keep class com.alipay.** {*;}\n-dontwarn com.alipay.**\n-keep class anet.**{*;}\n-keep class org.android.spdy.**{*;}\n-keep class org.android.agoo.**{*;}\n-dontwarn anet.**\n-dontwarn org.android.spdy.**\n-dontwarn org.android.agoo.**\n\n#hotfix\n#基线包使用,生成mapping.txt\n-printmapping mapping.txt\n#生成的mapping.txt在app/buidl/outputs/mapping/release路径下,移动到/app路径下\n#修复后的项目使用,保证混淆结果一致\n#-applymapping mapping.txt\n#hotfix\n-keep class com.taobao.sophix.**{*;}\n-keep class com.ta.utdid2.device.**{*;}\n#防止inline\n-dontoptimize\n\n#man\n-keep class com.taobao.** {*;}\n-keep class com.alibaba.** {*;}\n-keep class com.ta.**{*;}\n-keep class com.ut.**{*;}\n-dontwarn com.taobao.**\n-dontwarn com.alibaba.**\n-dontwarn com.ta.**\n-dontwarn com.ut.**\n\n#feedback\n-keep class com.taobao.** {*;}\n-keep class com.alibaba.** {*;}\n-keep class com.ta.**{*;}\n-keep class com.ut.**{*;}\n-dontwarn com.taobao.**\n-dontwarn com.alibaba.**\n-dontwarn com.ta.**\n-dontwarn com.ut.**\n"
|
||||
}
|
||||
@ -163,5 +163,7 @@ dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation('com.amap.api:location:5.6.0')
|
||||
implementation('com.amap.api:3dmap:8.1.0')
|
||||
implementation 'com.aliyun.ams:alicloud-android-push:3.1.9.1'
|
||||
implementation 'com.aliyun.ams:alicloud-android-push:3.8.7'
|
||||
//小米依赖
|
||||
implementation 'com.aliyun.ams:alicloud-android-third-push-xiaomi:3.8.7'
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
<application android:label="@string/app_name" android:name="${applicationName}" android:icon="@mipmap/ic_launcher">
|
||||
<!-- 配置定位Service -->
|
||||
<service android:name="com.amap.api.location.APSService"/>
|
||||
<activity android:name="cn.starlock.lock.MainActivity" android:exported="true" android:screenOrientation="portrait" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
|
||||
<activity android:name="com.skychip.lock.MainActivity" android:exported="true" android:screenOrientation="portrait" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
|
||||
<!-- Specifies an Android theme to apply to this Activity as soon as
|
||||
the Android process has started. This theme is visible to the user
|
||||
while the Flutter UI initializes. After that, this theme continues
|
||||
@ -54,9 +54,9 @@
|
||||
<meta-data android:name="flutterEmbedding" android:value="2"/>
|
||||
<meta-data android:name="com.amap.api.v2.apikey" android:value="11d49b3f4fc09c04a02bbb7500925ba2"></meta-data>
|
||||
<!-- 请填写你自己的- appKey -->
|
||||
<meta-data android:name="com.alibaba.app.appkey" android:value="333904040"/>
|
||||
<meta-data android:name="com.alibaba.app.appkey" android:value="334068743"/>
|
||||
<!-- 请填写你自己的appSecret -->
|
||||
<meta-data android:name="com.alibaba.app.appsecret" android:value="c316965fe0a74fc9a481a5c44a535dc2"/>
|
||||
<meta-data android:name="com.alibaba.app.appsecret" android:value="64de537f14984159a66ada10e54c6b63"/>
|
||||
<!-- 华为通道的参数appid -->
|
||||
<meta-data android:name="com.huawei.hms.client.appid" android:value="appid=xxxxx"/>
|
||||
<!-- vivo通道的参数api_key为appkey -->
|
||||
@ -68,8 +68,8 @@
|
||||
<meta-data android:name="com.oppo.push.key" android:value=""/>
|
||||
<meta-data android:name="com.oppo.push.secret" android:value=""/>
|
||||
<!-- 小米-->
|
||||
<meta-data android:name="com.xiaomi.push.id" android:value="id=2222222222222222222"/>
|
||||
<meta-data android:name="com.xiaomi.push.key" android:value="id=5555555555555"/>
|
||||
<meta-data android:name="com.xiaomi.push.id" android:value="id=2882303761520287291"/>
|
||||
<meta-data android:name="com.xiaomi.push.key" android:value="id=5352028744291"/>
|
||||
<!-- 魅族-->
|
||||
<meta-data android:name="com.meizu.push.id" android:value=""/>
|
||||
<meta-data android:name="com.meizu.push.key" android:value=""/>
|
||||
@ -79,7 +79,7 @@
|
||||
<meta-data android:name="com.gcm.push.projectid" android:value=""/>
|
||||
<meta-data android:name="com.gcm.push.api.key" android:value=""/>
|
||||
<!-- 消息接收监听器 (用户可自主扩展) -->
|
||||
<receiver android:name="cn.starlock.lock.MyMessageReceiver" android:exported="false">
|
||||
<receiver android:name="com.skychip.lock.MyMessageReceiver" android:exported="false">
|
||||
<!-- 为保证receiver安全,建议设置不可导出,如需对其他应用开放可通过android:permission进行限制 -->
|
||||
<intent-filter>
|
||||
<action android:name="com.alibaba.sdk.android.push.intent.MESSAGE"/>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package cn.starlock.lock
|
||||
package com.skychip.lock
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
@ -11,12 +11,15 @@ import io.flutter.plugin.common.MethodChannel
|
||||
import io.flutter.embedding.engine.FlutterEngine;
|
||||
import io.flutter.plugins.GeneratedPluginRegistrant
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import com.alibaba.sdk.android.push.register.MiPushRegister
|
||||
|
||||
class MainActivity: FlutterActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
initAliyunPushService()
|
||||
|
||||
MiPushRegister.register(applicationContext, "2882303761520287291", "5352028744291");
|
||||
|
||||
GeneratedPluginRegistrant.registerWith(flutterEngine!!)
|
||||
MethodChannel(flutterEngine?.dartExecutor!!.binaryMessenger, "starLockFlutterSend").setMethodCallHandler { call, result ->
|
||||
if (call.method == "loadNativeShare") {
|
||||
@ -1,4 +1,4 @@
|
||||
package cn.starlock.lock
|
||||
package com.skychip.lock
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
@ -0,0 +1,25 @@
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import com.alibaba.sdk.android.push.AndroidPopupActivity
|
||||
|
||||
class PopupPushActivity : AndroidPopupActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
|
||||
/**
|
||||
* 实现通知打开回调方法,获取通知相关信息
|
||||
* @param title 标题
|
||||
* @param summary 内容
|
||||
* @param extMap 额外参数
|
||||
*/
|
||||
override fun onSysNoticeOpened(title: String, summary: String, extMap: Map<String, String>) {
|
||||
Log.e(
|
||||
"PopupPushActivity",
|
||||
"OnMiPushSysNoticeOpened, title: $title, content: $summary, extMap: $extMap"
|
||||
) }
|
||||
|
||||
companion object {
|
||||
const val TAG = "PopupPushActivity"
|
||||
}
|
||||
}
|
||||
@ -1,3 +1,4 @@
|
||||
import 'package:aliyun_push/aliyun_push.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
@ -7,6 +8,8 @@ import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:star_lock/flavors.dart';
|
||||
import 'package:star_lock/tools/app_manager.dart';
|
||||
import 'package:star_lock/tools/bindings/app_binding.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
import 'package:star_lock/tools/xs_aliyunPush.dart';
|
||||
|
||||
import 'package:star_lock/translations/app_dept.dart';
|
||||
import 'package:star_lock/translations/trans_lib.dart';
|
||||
@ -16,8 +19,6 @@ import 'baseWidget.dart';
|
||||
import 'tools/appRouteObserver.dart';
|
||||
import 'dart:io';
|
||||
|
||||
import 'versionUndate/versionUndateTool.dart';
|
||||
|
||||
class MyApp extends StatefulWidget {
|
||||
const MyApp({GlobalKey? key}) : super(key: key);
|
||||
|
||||
@ -100,7 +101,7 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver, BaseWidget {
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
|
||||
initFlutterAliyunPush();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -145,3 +146,26 @@ Future<bool> getMicrophonePermission() async {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//初始化阿里云推送
|
||||
Future<void> initFlutterAliyunPush() async {
|
||||
final data = await Storage.getString(saveUserLoginData);
|
||||
if (data != null) {
|
||||
final aliyunPush = AliyunPush();
|
||||
XSAliyunPushProvider().init(aliyunPush);
|
||||
XSAliyunPushProvider().initAliyunPush();
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
XSAliyunPushProvider().initAliyunThirdPush();
|
||||
}
|
||||
|
||||
//暂使用DeviceID推送
|
||||
aliyunPush.getDeviceId().then((deviceId) async {
|
||||
print('得到的DeviceId$deviceId');
|
||||
if (deviceId.isNotEmpty) {
|
||||
XSAliyunPushProvider()
|
||||
.pushBindDeviceID(deviceId, Platform.isAndroid ? 10 : 20);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,52 +1,67 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'io_tool/io_model.dart';
|
||||
import 'io_tool/io_tool.dart';
|
||||
import 'io_tool/manager_event_bus.dart';
|
||||
import 'reciver_data.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
|
||||
//连接状态回调
|
||||
typedef ConnectStateCallBack = Function(DeviceConnectionState connectionState);
|
||||
typedef ConnectStateCallBack = Function(BluetoothConnectionState connectionState);
|
||||
typedef ScanDevicesCallBack = Function(List<ScanResult>);
|
||||
|
||||
class BlueManage {
|
||||
FlutterReactiveBle? _flutterReactiveBle;
|
||||
final List<DiscoveredDevice> scanDevices = [];
|
||||
final List<ScanResult> scanDevices = [];
|
||||
|
||||
// 用来写入的服务id
|
||||
final Uuid _serviceIdConnect = Uuid.parse("fff0");
|
||||
final Guid _serviceIdConnect = Guid("fff0");
|
||||
// 用来写入的服务id
|
||||
final Uuid _serviceIdWrite = Uuid.parse('0000FFF0-0000-1000-8000-00805F9B34FB');
|
||||
final Guid _serviceIdWrite = Guid('0000FFF0-0000-1000-8000-00805F9B34FB');
|
||||
// 用来订阅的特征id
|
||||
final Uuid _characteristicIdSubscription = Uuid.parse("fff1");
|
||||
final Guid _characteristicIdSubscription = Guid("fff1");
|
||||
// 用来写入的特征id
|
||||
final Uuid _characteristicIdWrite = Uuid.parse("fff2");
|
||||
final Guid _characteristicIdWrite = Guid("fff2");
|
||||
|
||||
// 监听发送事件
|
||||
StreamSubscription<EventSendModel>? _sendStreamSubscription;
|
||||
// 监听蓝牙扫描的事件
|
||||
StreamSubscription? _scanSubscription;
|
||||
// StreamSubscription? _scanSubscription;
|
||||
// 监听蓝牙连接的事件
|
||||
StreamSubscription<dynamic>? _currentConnectionStream;
|
||||
// StreamSubscription<dynamic>? _currentConnectionStream;
|
||||
|
||||
// StreamSubscription<List<ScanResult>>? _scanResultsSubscription;
|
||||
StreamSubscription<BluetoothConnectionState>? _connectionStateSubscription;
|
||||
|
||||
StreamSubscription<int>? _mtuSubscription;
|
||||
int? _mtuSize = 20;
|
||||
|
||||
// 当前连接设备的名字
|
||||
String connectDeviceName = "";
|
||||
// 当前连接设备的mac地址
|
||||
String connectDeviceMacAddress = "";
|
||||
// 当前连接的设备
|
||||
BluetoothDevice? bluetoothConnectDevice;
|
||||
// 当前扫描到结果要连接设备
|
||||
ScanResult? scanResult;
|
||||
// 监听蓝牙连接状态
|
||||
DeviceConnectionState? deviceConnectionState = DeviceConnectionState.disconnected;
|
||||
BluetoothConnectionState? bluetoothConnectionState = BluetoothConnectionState.disconnected;
|
||||
|
||||
BluetoothAdapterState? _adapterState = BluetoothAdapterState.unknown;
|
||||
StreamSubscription<BluetoothAdapterState>? _adapterStateStateSubscription;
|
||||
|
||||
static BlueManage? _manager;
|
||||
BlueManage._init(){
|
||||
// _initBlue();
|
||||
_initBlue();
|
||||
}
|
||||
|
||||
static BlueManage? shareManager() {
|
||||
_manager ??= BlueManage._init();
|
||||
_manager!._initBlue();
|
||||
// _manager!._initBlue();
|
||||
return _manager;
|
||||
}
|
||||
|
||||
@ -54,21 +69,94 @@ class BlueManage {
|
||||
BlueManage? get manager => shareManager();
|
||||
|
||||
void _initBlue(){
|
||||
// print("蓝牙功能初始化了");
|
||||
_flutterReactiveBle ??= FlutterReactiveBle();
|
||||
print("蓝牙功能初始化监听");
|
||||
_initSendStreamSubscription();
|
||||
_initAdapterStateStateSubscription();
|
||||
// _initListenscanResults();
|
||||
// _initListenConnectionState();
|
||||
}
|
||||
|
||||
void _initGetMtuSubscription() {
|
||||
_mtuSubscription ??= bluetoothConnectDevice!.mtu.listen((value) {
|
||||
_mtuSize = value - 3;
|
||||
print('mtuSize:$_mtuSize');
|
||||
});
|
||||
}
|
||||
|
||||
void _initAdapterStateStateSubscription() {
|
||||
_adapterStateStateSubscription ??= FlutterBluePlus.adapterState.listen((state) {
|
||||
_adapterState = state;
|
||||
});
|
||||
}
|
||||
|
||||
// void _initListenscanResults() {
|
||||
// var subscription = FlutterBluePlus.scanResults.listen((results) {
|
||||
// scanDevices.clear();
|
||||
// for (var scanResult in results) {
|
||||
// // 判断名字为空的直接剔除
|
||||
// // if (scanResult.device.advName.isEmpty) {
|
||||
// // return;
|
||||
// // }
|
||||
// print("scanResult.device.advName:${scanResult.device.advName}"
|
||||
// " scanResult.advertisementData.serviceUuids:${scanResult.advertisementData.serviceUuids}"
|
||||
// " rssi:${scanResult.rssi}");
|
||||
// if (((scanResult.advertisementData.serviceUuids.isNotEmpty ? scanResult.advertisementData.serviceUuids[0] : "").toString().contains("758824")) && (scanResult.rssi >= -100)) {
|
||||
// // 查询id相同的元素
|
||||
// final knownDeviceIndex = scanDevices.indexWhere((d) => d.advertisementData.advName == scanResult.advertisementData.advName);
|
||||
// // 不存在的时候返回-1
|
||||
// if (knownDeviceIndex >= 0) {
|
||||
// scanDevices[knownDeviceIndex] = scanResult;
|
||||
// } else {
|
||||
// scanDevices.add(scanResult);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// EventBusManager().eventBusFir(scanDevices);
|
||||
// // FlutterBluePlus.stopScan();
|
||||
// }, onError: (e) {
|
||||
// print("Scan Error:$e", );
|
||||
// });
|
||||
//
|
||||
// FlutterBluePlus.cancelWhenScanComplete(subscription);
|
||||
|
||||
// FlutterBluePlus.isScanning.listen((state) {
|
||||
// if (state) {
|
||||
// print('Scanning');
|
||||
// } else {
|
||||
// print('Not scanning');
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
void _initListenConnectionState() {
|
||||
_connectionStateSubscription?.cancel();
|
||||
_connectionStateSubscription = null;
|
||||
|
||||
_connectionStateSubscription = bluetoothConnectDevice!.connectionState.listen((state) async {
|
||||
bluetoothConnectionState = state;
|
||||
Get.log("蓝牙连接状态:$state");
|
||||
});
|
||||
}
|
||||
|
||||
void _initSendStreamSubscription() {
|
||||
_sendStreamSubscription ??= EventBusManager().eventBus!.on<EventSendModel>().listen((EventSendModel model) {
|
||||
if (model.sendChannel == DataChannel.ble) {
|
||||
// managerAppWriteData(model.data);
|
||||
_flutterReactiveBle!.statusStream.listen((status) {
|
||||
if (status == BleStatus.ready) {
|
||||
// 蓝牙已开启,可以进行蓝牙操作
|
||||
writeCharacteristicWithResponse(model.data);
|
||||
}else{
|
||||
Get.log("写入数据 蓝牙未开启,不能进行蓝牙操作");
|
||||
FlutterBluePlus.isSupported.then((isAvailable) async {
|
||||
if (isAvailable) {
|
||||
if (_adapterState == BluetoothAdapterState.on) {
|
||||
// 蓝牙已开启,可以进行蓝牙操作
|
||||
writeCharacteristicWithResponse(model.data);
|
||||
} else {
|
||||
try {
|
||||
if (Platform.isAndroid) {
|
||||
await FlutterBluePlus.turnOn();
|
||||
}
|
||||
} catch (e) {
|
||||
Get.log("Error Turning On:");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Get.log("写入数据 蓝牙不可用,不能进行蓝牙操作");
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -76,164 +164,196 @@ class BlueManage {
|
||||
}
|
||||
|
||||
/// 开始扫描蓝牙设备
|
||||
void startScan({List<Uuid>? idList}) {
|
||||
// List<Service>? list = _flutterReactiveBle!.getDiscoveredServices("deviceId").then((value));
|
||||
_flutterReactiveBle!.statusStream.listen((status) {
|
||||
if (status == BleStatus.ready) {
|
||||
// 蓝牙已开启,可以进行蓝牙操作
|
||||
scanDevices.clear();
|
||||
_scanSubscription = _flutterReactiveBle!.scanForDevices(withServices:[]).listen((device) {
|
||||
// 判断名字为空的直接剔除
|
||||
if (device.name.isEmpty) {
|
||||
return;
|
||||
}
|
||||
print("startScanDevice:$device");
|
||||
if (((device.serviceUuids.isNotEmpty ? device.serviceUuids[0] : "").toString().contains("758824")) && (device.rssi >= -100)) {
|
||||
// 查询id相同的元素
|
||||
final knownDeviceIndex = scanDevices.indexWhere((d) => d.id == device.id);
|
||||
// 不存在的时候返回-1
|
||||
if (knownDeviceIndex >= 0) {
|
||||
scanDevices[knownDeviceIndex] = device;
|
||||
} else {
|
||||
scanDevices.add(device);
|
||||
Future<void> startScan(int timeout, ScanDevicesCallBack scanDevicesCallBack, {List<Guid>? idList}) async {
|
||||
FlutterBluePlus.isSupported.then((isAvailable) async {
|
||||
if (isAvailable) {
|
||||
if (_adapterState == BluetoothAdapterState.on) {
|
||||
try {
|
||||
FlutterBluePlus.startScan(timeout: Duration(seconds: timeout));
|
||||
|
||||
var subscription = FlutterBluePlus.scanResults.listen((results) {
|
||||
scanDevices.clear();
|
||||
for (var scanResult in results) {
|
||||
// 判断名字为空的直接剔除
|
||||
// if (scanResult.device.advName.isEmpty) {
|
||||
// return;
|
||||
// }
|
||||
Get.log("scanResult.device.advName:${scanResult.device.advName}"
|
||||
" scanResult.advertisementData.serviceUuids:${scanResult.advertisementData.serviceUuids}"
|
||||
" rssi:${scanResult.rssi}");
|
||||
if (((scanResult.advertisementData.serviceUuids.isNotEmpty ? scanResult.advertisementData.serviceUuids[0] : "").toString().contains("758824")) && (scanResult.rssi >= -100)) {
|
||||
// 查询id相同的元素
|
||||
final knownDeviceIndex = scanDevices.indexWhere((d) => d.advertisementData.advName == scanResult.advertisementData.advName);
|
||||
// 不存在的时候返回-1
|
||||
if (knownDeviceIndex >= 0) {
|
||||
scanDevices[knownDeviceIndex] = scanResult;
|
||||
} else {
|
||||
scanDevices.add(scanResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
scanDevicesCallBack(scanDevices);
|
||||
// EventBusManager().eventBusFir(scanDevices);
|
||||
// FlutterBluePlus.stopScan();
|
||||
}, onError: (e) {
|
||||
print("Scan Error:$e", );
|
||||
});
|
||||
|
||||
FlutterBluePlus.cancelWhenScanComplete(subscription);
|
||||
} catch (e) {
|
||||
Get.log("扫描失败");
|
||||
}
|
||||
EventBusManager().eventBusFir(scanDevices);
|
||||
}
|
||||
}, onError: (Object e) {
|
||||
print('Device scan fails with error: $e');
|
||||
});
|
||||
}else{
|
||||
Get.log("开始扫描 蓝牙未开启,不能进行蓝牙操作");
|
||||
} else {
|
||||
try {
|
||||
if (Platform.isAndroid) {
|
||||
await FlutterBluePlus.turnOn();
|
||||
}
|
||||
} catch (e) {
|
||||
Get.log("Error Turning On:");
|
||||
}
|
||||
};
|
||||
} else {
|
||||
Get.log("开始扫描 蓝牙不可用,不能进行蓝牙操作");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// 调用发送数据
|
||||
Future<void> bludSendData(String deviceName, ConnectStateCallBack stateCallBack, {bool isAddEquipment = false}) async {
|
||||
_flutterReactiveBle!.statusStream.listen((status) {
|
||||
Get.log("_flutterReactiveBle.status:$status");
|
||||
if(deviceName.isEmpty) {
|
||||
Get.log("deviceName为空");
|
||||
return;
|
||||
}
|
||||
if (status == BleStatus.ready) {
|
||||
// 蓝牙已开启,可以进行蓝牙操作
|
||||
if(deviceConnectionState != DeviceConnectionState.connected){
|
||||
if(isAddEquipment == false){
|
||||
// print("666666666");
|
||||
startScan();
|
||||
FlutterBluePlus.isSupported.then((isAvailable) async {
|
||||
if (isAvailable) {
|
||||
if (_adapterState == BluetoothAdapterState.on) {
|
||||
// 蓝牙已开启,可以进行蓝牙操作
|
||||
if(bluetoothConnectionState != BluetoothConnectionState.connected){
|
||||
_connect(deviceName, (state){
|
||||
// if(bluetoothConnectionState != BluetoothConnectionState.connected){
|
||||
// stateCallBack(bluetoothConnectionState!);
|
||||
// }else{
|
||||
// stateCallBack(bluetoothConnectionState!);
|
||||
// }
|
||||
stateCallBack(bluetoothConnectionState!);
|
||||
}, isAddEquipment: isAddEquipment);
|
||||
}else{
|
||||
stateCallBack(bluetoothConnectionState!);
|
||||
}
|
||||
|
||||
_connect(deviceName, (state){
|
||||
stateCallBack(deviceConnectionState!);
|
||||
});
|
||||
}else{
|
||||
// stopScan();
|
||||
stateCallBack(deviceConnectionState!);
|
||||
}
|
||||
}else{
|
||||
Get.log("调用发送数据 蓝牙未开启,不能进行蓝牙操作");
|
||||
} else {
|
||||
try {
|
||||
if (Platform.isAndroid) {
|
||||
await FlutterBluePlus.turnOn();
|
||||
}
|
||||
} catch (e) {
|
||||
Get.log("Error Turning On:");
|
||||
}
|
||||
};
|
||||
} else {
|
||||
Get.log("开始扫描 蓝牙不可用,不能进行蓝牙操作");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// 连接监听状态
|
||||
Future<void> _connect(String deviceName, ConnectStateCallBack connectStateCallBack) async {
|
||||
/// 连接
|
||||
Future<void> _connect(String deviceName, ConnectStateCallBack connectStateCallBack, {bool isAddEquipment = false}) async {
|
||||
connectDeviceName = deviceName;
|
||||
List<ScanResult> devicesList = scanDevices;
|
||||
if(isAddEquipment == false){
|
||||
startScan(10, (List<ScanResult> scanDevices){
|
||||
print("扫描到的设备:$scanDevices");
|
||||
devicesList = scanDevices;
|
||||
_connectDevice(devicesList, deviceName, connectStateCallBack, isAddEquipment: isAddEquipment);
|
||||
});
|
||||
}else{
|
||||
_connectDevice(devicesList, deviceName, connectStateCallBack, isAddEquipment: isAddEquipment);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _connectDevice( List<ScanResult> devicesList, String deviceName, ConnectStateCallBack connectStateCallBack, {bool isAddEquipment = false}) async {
|
||||
// 判断数组列表里面是否有这个设备
|
||||
final knownDeviceIndex = scanDevices.indexWhere((d) => d.name == deviceName);
|
||||
print("devicesList:$devicesList");
|
||||
final knownDeviceIndex = devicesList.indexWhere((d) => d.advertisementData.advName == deviceName);
|
||||
if (knownDeviceIndex >= 0) {
|
||||
// 存在的时候赋值
|
||||
connectDeviceMacAddress = scanDevices[knownDeviceIndex].id;
|
||||
} else {
|
||||
// 不存在的时候返回-1 然后循环5秒
|
||||
var index = 0;
|
||||
Completer? completer = Completer();
|
||||
Timer.periodic(const Duration(seconds: 1), (timer) async {
|
||||
///定时任务
|
||||
// print("timer index0:$index");
|
||||
if(index >= 9){
|
||||
// 当超过5秒的时候取消定时任务 弹窗显示连接失败
|
||||
connectDeviceMacAddress = "";
|
||||
connectStateCallBack(DeviceConnectionState.disconnected);
|
||||
completer.complete();
|
||||
stopScan();
|
||||
timer.cancel();
|
||||
// deviceConnectionState = DeviceConnectionState.disconnected;
|
||||
// print("timer index1:$index");
|
||||
}else{
|
||||
// 每秒判断数组列表里面是否有这个设备
|
||||
final knownDeviceIndex = scanDevices.indexWhere((d) => d.name == deviceName);
|
||||
connectDeviceMacAddress = devicesList[knownDeviceIndex].advertisementData.advName;
|
||||
|
||||
if (knownDeviceIndex >= 0) {
|
||||
// 存在的时候销毁定时器,赋值
|
||||
connectDeviceMacAddress = scanDevices[knownDeviceIndex].id;
|
||||
stopScan();
|
||||
completer.complete();
|
||||
timer.cancel();
|
||||
// print("timer index2:$index");
|
||||
bluetoothConnectDevice = devicesList[knownDeviceIndex].device;
|
||||
print('bluetoothConnectDevice: $bluetoothConnectDevice');
|
||||
scanResult = devicesList[knownDeviceIndex];
|
||||
|
||||
// var uuidStr = (scanDevices[knownDeviceIndex].serviceUuids.isNotEmpty ? scanDevices[knownDeviceIndex].serviceUuids[0] : "").toString();
|
||||
// if(uuidStr[31] == "0"){
|
||||
// // 未配对 表示这把锁已被强制初始化 处于可添加状态 不再连接
|
||||
// EasyLoading.showToast("当前设备已被清除配对,请删除后重新添加", duration: 2000.milliseconds);
|
||||
// Future.delayed(2100.milliseconds);
|
||||
// connectStateCallBack(DeviceConnectionState.disconnected);
|
||||
// return;
|
||||
// }
|
||||
} else {
|
||||
// 不存在的时候返回-1 然后循环5秒
|
||||
index++;
|
||||
print("index:$index");
|
||||
}
|
||||
}
|
||||
});
|
||||
// 等待Completer完成
|
||||
await completer.future;
|
||||
_initGetMtuSubscription();
|
||||
_initListenConnectionState();
|
||||
}
|
||||
print("1 connectDeviceId:$connectDeviceMacAddress connectDeviceName:$connectDeviceName");
|
||||
// stopScan();
|
||||
if (connectDeviceMacAddress.isEmpty) {
|
||||
// connectStateCallBack(BluetoothConnectionState.disconnected!);
|
||||
return;
|
||||
}
|
||||
|
||||
/// 用来判断是否返回了连接结果 还是放了一段时间后蓝牙主动断开的
|
||||
var isReturnedConnectResults = false;
|
||||
_currentConnectionStream = _flutterReactiveBle!.connectToDevice(id: connectDeviceMacAddress, connectionTimeout: const Duration(seconds: 5)).listen((connectionStateUpdate) async {
|
||||
// 获取状态
|
||||
deviceConnectionState = connectionStateUpdate.connectionState;
|
||||
stopScan();
|
||||
print('2 deviceConnectionState:$deviceConnectionState connectionStateUpdate.connectionState:${connectionStateUpdate.connectionState}');
|
||||
if (connectionStateUpdate.connectionState == DeviceConnectionState.connected) {
|
||||
isReturnedConnectResults = true;
|
||||
// 如果状态是连接的开始发现服务
|
||||
try {
|
||||
_subScribeToCharacteristic(QualifiedCharacteristic(characteristicId: _characteristicIdSubscription, serviceId: _serviceIdConnect, deviceId: connectDeviceMacAddress));
|
||||
print('Discovering services finished');
|
||||
Get.log("调用了停止扫描的方法");
|
||||
await stopScan();
|
||||
|
||||
deviceConnectionState = connectionStateUpdate.connectionState;
|
||||
connectStateCallBack(deviceConnectionState!);
|
||||
} on Exception catch (e) {
|
||||
deviceConnectionState = DeviceConnectionState.disconnected;
|
||||
connectStateCallBack(deviceConnectionState!);
|
||||
print('Error occurred when discovering services: $e');
|
||||
rethrow;
|
||||
}
|
||||
} else if (connectionStateUpdate.connectionState == DeviceConnectionState.disconnected) {
|
||||
// 如果状态是断开的
|
||||
deviceConnectionState = connectionStateUpdate.connectionState;
|
||||
if(isReturnedConnectResults == false){
|
||||
isReturnedConnectResults = true;
|
||||
// 如果是在连接中断开的
|
||||
connectStateCallBack(deviceConnectionState!);
|
||||
if ((scanResult!.advertisementData.serviceUuids[0].toString()[31] == "0") && isAddEquipment == false) {
|
||||
connectStateCallBack(BluetoothConnectionState.disconnected!);
|
||||
EasyLoading.showToast("该锁已被重置", duration: 2000.milliseconds);
|
||||
return;
|
||||
}
|
||||
|
||||
// 重连三次
|
||||
int maxAttempts = 3;
|
||||
int attempt = 0;
|
||||
while (attempt < maxAttempts) {
|
||||
try {
|
||||
await bluetoothConnectDevice!.connect(timeout: 5.seconds);
|
||||
break; // If the connection is successful, break the loop
|
||||
} catch (e) {
|
||||
Get.log('Failed to connect: $e');
|
||||
attempt++; // Increase the attempt count
|
||||
if (attempt < maxAttempts) {
|
||||
Get.log('Retrying connection...');
|
||||
}
|
||||
}
|
||||
print('ConnectionState for device $connectDeviceMacAddress : ${connectionStateUpdate.connectionState}');
|
||||
}, onError: (Object e) {
|
||||
deviceConnectionState = DeviceConnectionState.disconnected;
|
||||
connectStateCallBack(deviceConnectionState!);
|
||||
print('Connecting to device $connectDeviceMacAddress resulted in error $e');
|
||||
});
|
||||
}
|
||||
|
||||
if (attempt >= maxAttempts) {
|
||||
Get.log('Failed to connect after $maxAttempts attempts.');
|
||||
connectStateCallBack(BluetoothConnectionState.disconnected!);
|
||||
}
|
||||
|
||||
// await bluetoothConnectDevice!.connect();
|
||||
print("5555555:回调状态:$bluetoothConnectionState");
|
||||
if (bluetoothConnectionState == BluetoothConnectionState.connected) {
|
||||
try {
|
||||
bluetoothConnectDevice!.discoverServices().then((services) {
|
||||
print("333333333");
|
||||
for (BluetoothService service in services) {
|
||||
// print("11111service.remoteId:${service.remoteId}"
|
||||
// " service.uuid:${service.uuid}"
|
||||
// " service.characteristics:${service.characteristics}"
|
||||
// " service.includedServices:${service.includedServices}");
|
||||
if(service.uuid == _serviceIdConnect){
|
||||
for (BluetoothCharacteristic characteristic in service.characteristics) {
|
||||
// print("22222characteristic.remoteId:${characteristic.remoteId}"
|
||||
// " characteristic.uuid:${characteristic.uuid}"
|
||||
// " characteristic.secondaryServiceUuid:${characteristic.secondaryServiceUuid}"
|
||||
// " characteristic.characteristicUuid:${characteristic.characteristicUuid}");
|
||||
if (characteristic.characteristicUuid == _characteristicIdSubscription) {
|
||||
print("44444444");
|
||||
_subScribeToCharacteristic(characteristic);
|
||||
print('Discovering services finished');
|
||||
bluetoothConnectionState = BluetoothConnectionState.connected;
|
||||
connectStateCallBack(bluetoothConnectionState!);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} on Exception catch (e) {
|
||||
bluetoothConnectionState = BluetoothConnectionState.disconnected;
|
||||
Get.log("5555 回调状态:$bluetoothConnectionState");
|
||||
connectStateCallBack(bluetoothConnectionState!);
|
||||
print('Error occurred when discovering services: $e');
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 听上报来的数据,参数来自前面扫描到的结果
|
||||
@ -241,9 +361,11 @@ class BlueManage {
|
||||
// 保存上一次的数据,用来判断是否收到重复的数据
|
||||
var lastTimeData = <int>[];
|
||||
int? dataLen;
|
||||
_subScribeToCharacteristic(QualifiedCharacteristic characteristic) {
|
||||
_flutterReactiveBle!.subscribeToCharacteristic(characteristic).listen((data) {
|
||||
if(data == lastTimeData){
|
||||
_subScribeToCharacteristic(BluetoothCharacteristic characteristic) async {
|
||||
final subscription = characteristic.onValueReceived.listen((data) {
|
||||
print("启动对特性的通知。当特性的值发生变化时,设备会发送一个通知");
|
||||
print("订阅获取的数据:$data");
|
||||
if(data == lastTimeData || data.isEmpty){
|
||||
return;
|
||||
}else{
|
||||
lastTimeData = data;
|
||||
@ -279,97 +401,179 @@ class BlueManage {
|
||||
allData = <int>[];
|
||||
}
|
||||
}
|
||||
}, onError: (dynamic error) {
|
||||
EasyLoading.dismiss();
|
||||
print("subscribeToCharacteristic error:$error");
|
||||
});
|
||||
|
||||
// cleanup: cancel subscription when disconnected
|
||||
bluetoothConnectDevice!.cancelWhenDisconnected(subscription);
|
||||
|
||||
// enable notifications
|
||||
await characteristic.setNotifyValue(true);
|
||||
|
||||
// characteristic.setNotifyValue(true).then((_) {
|
||||
// print("启动对特性的通知。当特性的值发生变化时,设备会发送一个通知");
|
||||
// characteristic.lastValueStream.listen((data) {
|
||||
// print("订阅获取的数据:$data");
|
||||
// // do something with new value
|
||||
// if(data == lastTimeData || data.isEmpty){
|
||||
// return;
|
||||
// }else{
|
||||
// lastTimeData = data;
|
||||
// }
|
||||
// // code to handle incoming data
|
||||
// // print("subscribeToCharacteristic: deviceId = ${characteristic.deviceId} characteristicId =${characteristic.characteristicId}---上报来的数据data = $data");
|
||||
// if ((data[0] == 0xEF) && (data[1] == 0x01) && (data[2] == 0xEE) && (data[3] == 0x02)) {
|
||||
// // 当包有头时
|
||||
// // 判断是否需要分包
|
||||
// dataLen = data[8] * 256 + data[9]; // 高16位用来指示后面数据块内容的长度
|
||||
// // print("dataLen1111:$dataLen getDataLength:${data.length}");
|
||||
// if (dataLen! + 12 > data.length) {
|
||||
// // 当前包的长度小于实际的包时 分包添加 不解析
|
||||
// allData.addAll(data);
|
||||
// } else {
|
||||
// // 当前包的长度小于实际的包时 不分包 解析
|
||||
// allData.addAll(data);
|
||||
// // print("dataLen2222:$dataLen getDataLength:${data.length}");
|
||||
// CommandReciverManager.appDataReceive(allData);
|
||||
// // 发送完解析初始化数组
|
||||
// allData = <int>[];
|
||||
// }
|
||||
// } else {
|
||||
// // 当包没有头时 是分包的包 直接添加
|
||||
// allData.addAll(data);
|
||||
// // var len = allData[8] * 256 + allData[9];
|
||||
// // print("dataLen3333:$dataLen");
|
||||
// if ((dataLen! + 14) <= allData.length) {
|
||||
// // print("44444数据被解析了");
|
||||
// // 当长度小于等于当前包的数据时 直接解析数据
|
||||
// CommandReciverManager.appDataReceive(allData);
|
||||
// // 发送完解析初始化数组
|
||||
// allData = <int>[];
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
}
|
||||
|
||||
// 写入
|
||||
Future<void> writeCharacteristicWithResponse(List<int> value) async {
|
||||
QualifiedCharacteristic characteristic = QualifiedCharacteristic(characteristicId: _characteristicIdWrite, serviceId: _serviceIdWrite, deviceId: connectDeviceMacAddress);
|
||||
int mtuLength = await _flutterReactiveBle!.requestMtu(deviceId: characteristic.deviceId, mtu: 512);
|
||||
print("mtuLength:$mtuLength");
|
||||
try {
|
||||
List<int> valueList = value;
|
||||
List subData = splitList(valueList, mtuLength);
|
||||
print('得到的分割数据:$subData');
|
||||
bluetoothConnectDevice!.discoverServices().then((services) async {
|
||||
for (BluetoothService service in services) {
|
||||
// print("33333 service.remoteId:${service.remoteId}"
|
||||
// " service.uuid:${service.uuid}\n\n"
|
||||
// " service.characteristics:${service.characteristics}\n\n"
|
||||
// " service.includedServices:${service.includedServices}");
|
||||
if (service.uuid == _serviceIdConnect) {
|
||||
for (BluetoothCharacteristic characteristic in service
|
||||
.characteristics) {
|
||||
// print("44444 characteristic.remoteId:${characteristic.remoteId}"
|
||||
// " characteristic.uuid:${characteristic.uuid}\n\n"
|
||||
// " characteristic.secondaryServiceUuid:${characteristic
|
||||
// .secondaryServiceUuid}\n\n"
|
||||
// " characteristic.characteristicUuid:${characteristic
|
||||
// .characteristicUuid}");
|
||||
if (characteristic.characteristicUuid == _characteristicIdWrite) {
|
||||
try {
|
||||
List<int> valueList = value;
|
||||
List subData = splitList(valueList, _mtuSize!);
|
||||
print(
|
||||
'writeCharacteristicWithResponse 得到的分割数据:$subData');
|
||||
|
||||
for (int i = 0; i < subData.length; i++) {
|
||||
await _flutterReactiveBle!
|
||||
.writeCharacteristicWithResponse(characteristic, value: subData[i])
|
||||
.then((value) async {
|
||||
await Future.delayed(const Duration(milliseconds: 1))
|
||||
.then((value) async {
|
||||
print('分包发送成功了');
|
||||
});
|
||||
});
|
||||
for (int i = 0; i < subData.length; i++) {
|
||||
await characteristic.write(subData[i]).then((value) async {
|
||||
await Future.delayed(const Duration(milliseconds: 1)).then((
|
||||
value) async {
|
||||
print('分包发送成功了');
|
||||
});
|
||||
});
|
||||
}
|
||||
} on Exception catch (e, s) {
|
||||
print('Error occurred when writing: $e');
|
||||
print(s);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} on Exception catch (e, s) {
|
||||
print('Error occurred when writing: $e');
|
||||
// ignore: avoid_print
|
||||
print(s);
|
||||
rethrow;
|
||||
}
|
||||
});
|
||||
// List<BluetoothService> services = await bluetoothConnectDevice!.discoverServices();
|
||||
// BluetoothCharacteristic characteristic = services
|
||||
// .firstWhere((service) => service.uuid == _serviceIdWrite)
|
||||
// .characteristics
|
||||
// .firstWhere((char) => char.uuid == _characteristicIdWrite);
|
||||
// try {
|
||||
// List<int> valueList = value;
|
||||
// List subData = splitList(valueList, _mtuSize!);
|
||||
// print('writeCharacteristicWithResponse 得到的分割数据:$subData');
|
||||
//
|
||||
// for (int i = 0; i < subData.length; i++) {
|
||||
// await characteristic.write(subData[i]).then((value) async {
|
||||
// await Future.delayed(const Duration(milliseconds: 1)).then((value) async {
|
||||
// print('分包发送成功了');
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// } on Exception catch (e, s) {
|
||||
// print('Error occurred when writing: $e');
|
||||
// print(s);
|
||||
// rethrow;
|
||||
// }
|
||||
}
|
||||
|
||||
// 读取
|
||||
Future<List<int>> _readCharacteristic(QualifiedCharacteristic characteristic) async {
|
||||
try {
|
||||
final result =
|
||||
await _flutterReactiveBle!.readCharacteristic(characteristic);
|
||||
print("readListresult$result");
|
||||
return result;
|
||||
} on Exception catch (e, s) {
|
||||
print(
|
||||
'Error occurred when reading ${characteristic.characteristicId} : $e',
|
||||
);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
// Future<List<int>> _readCharacteristic(QualifiedCharacteristic characteristic) async {
|
||||
// try {
|
||||
// final result =
|
||||
// await _flutterReactiveBle!.readCharacteristic(characteristic);
|
||||
// print("readListresult$result");
|
||||
// return result;
|
||||
// } on Exception catch (e, s) {
|
||||
// print(
|
||||
// 'Error occurred when reading ${characteristic.characteristicId} : $e',
|
||||
// );
|
||||
// rethrow;
|
||||
// }
|
||||
// }
|
||||
|
||||
Future<void> writeCharacteristicWithoutResponse(
|
||||
QualifiedCharacteristic characteristic, List<int> value) async {
|
||||
try {
|
||||
await _flutterReactiveBle!
|
||||
.writeCharacteristicWithoutResponse(characteristic, value: value);
|
||||
} on Exception catch (e, s) {
|
||||
// ignore: avoid_print
|
||||
print(s);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
// Future<void> writeCharacteristicWithoutResponse(
|
||||
// QualifiedCharacteristic characteristic, List<int> value) async {
|
||||
// try {
|
||||
// await _flutterReactiveBle!
|
||||
// .writeCharacteristicWithoutResponse(characteristic, value: value);
|
||||
// } on Exception catch (e, s) {
|
||||
// // ignore: avoid_print
|
||||
// print(s);
|
||||
// rethrow;
|
||||
// }
|
||||
// }
|
||||
|
||||
// 停止扫描蓝牙设备
|
||||
void stopScan() {
|
||||
// print("444444444");
|
||||
if(_scanSubscription != null){
|
||||
// print("555555555555");
|
||||
_scanSubscription?.cancel();
|
||||
_scanSubscription = null;
|
||||
Future<void> stopScan() async {
|
||||
try {
|
||||
await FlutterBluePlus.stopScan();
|
||||
} catch (e) {
|
||||
Get.log("停止扫描失败");
|
||||
}
|
||||
}
|
||||
|
||||
// 断开连接
|
||||
Future<void> disconnect(String deviceMAC) async {
|
||||
Future<void> disconnect() async {
|
||||
try {
|
||||
connectDeviceMacAddress = "";
|
||||
// if(_currentConnectionStream != null){
|
||||
_currentConnectionStream?.cancel();
|
||||
_currentConnectionStream = null;
|
||||
// }
|
||||
|
||||
print('disconnecting to device: $connectDeviceName');
|
||||
connectDeviceMacAddress = "";
|
||||
await bluetoothConnectDevice!.disconnect();
|
||||
Get.log("断开连接成功");
|
||||
} on Exception catch (e, _) {
|
||||
print("Error disconnecting from a device: $e");
|
||||
} finally {
|
||||
deviceConnectionState = DeviceConnectionState.disconnected;
|
||||
bluetoothConnectionState = BluetoothConnectionState.disconnected;
|
||||
}
|
||||
}
|
||||
|
||||
disposed() {
|
||||
_sendStreamSubscription?.cancel();
|
||||
_currentConnectionStream?.cancel();
|
||||
_scanSubscription?.cancel();
|
||||
_mtuSubscription!.cancel();
|
||||
// _scanResultsSubscription!.cancel();
|
||||
_adapterStateStateSubscription!.cancel();
|
||||
_connectionStateSubscription!.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,8 +10,6 @@ import 'app_settings/app_settings.dart';
|
||||
import 'tools/store_service.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'versionUndate/versionUndateTool.dart';
|
||||
|
||||
// 该文件不可作为编译入口,请查看 flavorizr.yaml 中的说明
|
||||
FutureOr<void> main() async {
|
||||
await _setCommonServices();
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/appRouters.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
@ -162,8 +163,8 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
||||
// 转移权限
|
||||
Future<void> transferPermissionsAction() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
(DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
(BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
|
||||
@ -119,7 +119,6 @@ class _AddCardPageState extends State<AddCardPage> {
|
||||
String titleStr, String rightTitle, TextEditingController controller) {
|
||||
return Column(
|
||||
children: [
|
||||
Container(height: 10.h),
|
||||
CommonItem(
|
||||
leftTitel: titleStr,
|
||||
rightTitle: "",
|
||||
@ -142,16 +141,12 @@ class _AddCardPageState extends State<AddCardPage> {
|
||||
action: () async {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
setState(() {
|
||||
state.beginTime.value =
|
||||
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
|
||||
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
|
||||
state.beginTimeTimestamp.value =
|
||||
DateTime.parse(state.beginTime.value)
|
||||
.millisecondsSinceEpoch
|
||||
.toString();
|
||||
});
|
||||
});
|
||||
});
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
@ -161,16 +156,12 @@ class _AddCardPageState extends State<AddCardPage> {
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
setState(() {
|
||||
state.endTime.value =
|
||||
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
|
||||
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
|
||||
state.endTimeTimestamp.value =
|
||||
DateTime.parse(state.endTime.value)
|
||||
.millisecondsSinceEpoch
|
||||
.toString();
|
||||
});
|
||||
});
|
||||
});
|
||||
})),
|
||||
Container(height: 10.h),
|
||||
@ -181,21 +172,21 @@ class _AddCardPageState extends State<AddCardPage> {
|
||||
Widget keyBottomWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
CommonItem(
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: "是否是管理员",
|
||||
rightTitle: "",
|
||||
isTipsImg: false,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w, height: 50.h, child: _isAdmin())),
|
||||
width: 60.w, height: 50.h, child: _isAdmin()))),
|
||||
SizedBox(height: 10.h),
|
||||
CommonItem(
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.stressCard!.tr,
|
||||
rightTitle: "",
|
||||
isTipsImg: false,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w, height: 50.h, child: _isStressFingerprint())),
|
||||
width: 60.w, height: 50.h, child: _isStressFingerprint()))),
|
||||
SizedBox(height: 30.h),
|
||||
SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.next!.tr,
|
||||
@ -359,9 +350,7 @@ class _AddCardPageState extends State<AddCardPage> {
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: state.isStressFingerprint.value,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
state.isStressFingerprint.value = value;
|
||||
});
|
||||
state.isStressFingerprint.value = value;
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -374,9 +363,7 @@ class _AddCardPageState extends State<AddCardPage> {
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: state.isAdministrator.value,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
state.isAdministrator.value = value;
|
||||
});
|
||||
state.isAdministrator.value = value;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
@ -221,8 +222,8 @@ class AddICCardLogic extends BaseGetXController{
|
||||
print("没有任何响应");
|
||||
Get.close(1);
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
cancelBlueConnetctToastTimer();
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
@ -248,7 +249,7 @@ class AddICCardLogic extends BaseGetXController{
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected){
|
||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected){
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
@ -260,8 +261,8 @@ class AddICCardLogic extends BaseGetXController{
|
||||
|
||||
// 添加胁迫卡片
|
||||
Future<void> senderAddStressICCard() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
@ -99,8 +100,8 @@ class CardDetailLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
@ -124,7 +125,7 @@ class CardDetailLogic extends BaseGetXController{
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
@ -206,8 +207,8 @@ class CardListLogic extends BaseGetXController {
|
||||
|
||||
// 查询卡片状态
|
||||
Future<void> senderCheckingCardStatus() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -234,8 +235,8 @@ class CardListLogic extends BaseGetXController {
|
||||
|
||||
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
||||
Future<void> senderCheckingUserInfoCount() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -265,8 +266,8 @@ class CardListLogic extends BaseGetXController {
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
@ -289,7 +290,7 @@ class CardListLogic extends BaseGetXController {
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
|
||||
@ -2,8 +2,9 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart';
|
||||
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_state.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart';
|
||||
@ -160,8 +161,8 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
// 查询事件记录(时间查询)
|
||||
Future<void> senderReferEventRecordTime(int time) async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
(DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
(BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_addFace.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
@ -190,8 +191,8 @@ class AddFaceLogic extends BaseGetXController {
|
||||
Get.close(1);
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
(DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected) {
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
cancelBlueConnetctToastTimer();
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
@ -209,7 +210,7 @@ class AddFaceLogic extends BaseGetXController {
|
||||
IoSenderManage.senderAddFaceCommand(
|
||||
keyID: "1",
|
||||
userID: await Storage.getUid(),
|
||||
faceNo: 1,
|
||||
faceNo: state.isAdministrator.value == true ? 254 : 1,
|
||||
useCountLimit: 0xff,
|
||||
// startTime:0x11223344,
|
||||
// endTime:0x11223344,
|
||||
@ -220,7 +221,7 @@ class AddFaceLogic extends BaseGetXController {
|
||||
privateKey: getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||
if (state.ifCurrentScreen.value == true) {
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_addFace.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
@ -100,8 +101,8 @@ class FaceDetailLogic extends BaseGetXController {
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
(DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected) {
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
@ -125,7 +126,7 @@ class FaceDetailLogic extends BaseGetXController {
|
||||
privateKey: getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_addFace.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_queryingFaceStatus.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
@ -244,8 +245,8 @@ class FaceListLogic extends BaseGetXController {
|
||||
// 获取人脸状态
|
||||
Future<void> senderQueryingFaceStatus() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
(DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
(BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -273,8 +274,8 @@ class FaceListLogic extends BaseGetXController {
|
||||
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
||||
Future<void> senderCheckingUserInfoCount() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
(DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
(BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -305,8 +306,8 @@ class FaceListLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
(DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected) {
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
@ -328,7 +329,7 @@ class FaceListLogic extends BaseGetXController {
|
||||
privateKey: getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
if (state.ifCurrentScreen.value == true) {
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
|
||||
@ -264,8 +265,8 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
Get.close(1);
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
cancelBlueConnetctToastTimer();
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
@ -291,7 +292,7 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
}else if (deviceConnectionState == DeviceConnectionState.disconnected){
|
||||
}else if (deviceConnectionState == BluetoothConnectionState.disconnected){
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
@ -303,8 +304,8 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
|
||||
// 添加胁迫指纹
|
||||
Future<void> senderAddStressFingerprint() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
|
||||
@ -119,7 +119,6 @@ class _AddFingerprintTypePageState extends State<AddFingerprintTypePage> {
|
||||
String titleStr, String rightTitle, TextEditingController controller) {
|
||||
return Column(
|
||||
children: [
|
||||
Container(height: 10.h),
|
||||
CommonItem(
|
||||
leftTitel: titleStr,
|
||||
rightTitle: "",
|
||||
@ -142,16 +141,12 @@ class _AddFingerprintTypePageState extends State<AddFingerprintTypePage> {
|
||||
action: () async {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
setState(() {
|
||||
state.beginTime.value =
|
||||
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
|
||||
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
|
||||
state.beginTimeTimestamp.value =
|
||||
DateTime.parse(state.beginTime.value)
|
||||
.millisecondsSinceEpoch
|
||||
.toString();
|
||||
});
|
||||
});
|
||||
});
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
@ -161,16 +156,12 @@ class _AddFingerprintTypePageState extends State<AddFingerprintTypePage> {
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
setState(() {
|
||||
state.endTime.value =
|
||||
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
|
||||
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
|
||||
state.endTimeTimestamp.value =
|
||||
DateTime.parse(state.endTime.value)
|
||||
.millisecondsSinceEpoch
|
||||
.toString();
|
||||
});
|
||||
});
|
||||
});
|
||||
})),
|
||||
Container(height: 10.h),
|
||||
@ -181,21 +172,21 @@ class _AddFingerprintTypePageState extends State<AddFingerprintTypePage> {
|
||||
Widget keyBottomWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
CommonItem(
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: "是否是管理员",
|
||||
rightTitle: "",
|
||||
isTipsImg: false,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w, height: 50.h, child: _isAdmin())),
|
||||
width: 60.w, height: 50.h, child: _isAdmin()))),
|
||||
SizedBox(height: 10.h),
|
||||
CommonItem(
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.stressFingerprint!.tr,
|
||||
rightTitle: "",
|
||||
isTipsImg: false,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w, height: 50.h, child: _isStressFingerprint())),
|
||||
width: 60.w, height: 50.h, child: _isStressFingerprint()))),
|
||||
SizedBox(height: 30.h),
|
||||
SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.next!.tr,
|
||||
@ -339,9 +330,7 @@ class _AddFingerprintTypePageState extends State<AddFingerprintTypePage> {
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: state.isStressFingerprint.value,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
state.isStressFingerprint.value = value;
|
||||
});
|
||||
state.isStressFingerprint.value = value;
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -354,9 +343,7 @@ class _AddFingerprintTypePageState extends State<AddFingerprintTypePage> {
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: state.isAdministrator.value,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
state.isAdministrator.value = value;
|
||||
});
|
||||
state.isAdministrator.value = value;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
@ -100,8 +101,8 @@ class FingerprintDetailLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
@ -125,7 +126,7 @@ class FingerprintDetailLogic extends BaseGetXController{
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
@ -239,8 +240,8 @@ class FingerprintListLogic extends BaseGetXController{
|
||||
}
|
||||
// 获取指纹状态
|
||||
Future<void> senderQueryingFingerprintStatus() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,(DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,(BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -267,8 +268,8 @@ class FingerprintListLogic extends BaseGetXController{
|
||||
|
||||
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
||||
Future<void> senderCheckingUserInfoCount() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -298,8 +299,8 @@ class FingerprintListLogic extends BaseGetXController{
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
@ -321,7 +322,7 @@ class FingerprintListLogic extends BaseGetXController{
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
@ -92,6 +93,8 @@ class LockDetailLogic extends BaseGetXController {
|
||||
getLockRecordLastUploadDataTime();
|
||||
state.openLockBtnState.value = 0;
|
||||
|
||||
|
||||
|
||||
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
||||
break;
|
||||
case 0x06:
|
||||
@ -270,6 +273,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
}
|
||||
lockRecordUploadData(uploadList);
|
||||
// print("reply.data:${reply.data} getList:$getList}");
|
||||
await BlueManage().disconnect();
|
||||
}
|
||||
break;
|
||||
case 0x06:
|
||||
@ -375,10 +379,9 @@ class LockDetailLogic extends BaseGetXController {
|
||||
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
||||
});
|
||||
|
||||
BlueManage()
|
||||
.bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!,
|
||||
(DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected) {
|
||||
BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
// 私钥
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
@ -408,7 +411,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
publicKey: publicKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: getTokenList);
|
||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||
cancelBlueConnetctToastTimer();
|
||||
if (state.ifCurrentScreen.value == true) {
|
||||
showBlueConnetctToast();
|
||||
@ -436,7 +439,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
print("调用了开锁事件 openDoorTokenPubToken:$getTokenList getPrivateKeyList:$getPrivateKeyList");
|
||||
// print("调用了开锁事件 openDoorTokenPubToken:$getTokenList getPrivateKeyList:$getPrivateKeyList");
|
||||
// List<int>listData = await IoSenderManage.senderOpenLock(
|
||||
// keyID: BlueManage().connectDeviceName,
|
||||
// userID: await Storage.getUid(),
|
||||
@ -450,8 +453,8 @@ class LockDetailLogic extends BaseGetXController {
|
||||
// );
|
||||
BlueManage()
|
||||
.bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!,
|
||||
(DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected) {
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
IoSenderManage.senderOpenLock(
|
||||
keyID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
@ -463,7 +466,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
);
|
||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||
cancelBlueConnetctToastTimer();
|
||||
if (state.ifCurrentScreen.value == true) {
|
||||
showBlueConnetctToast();
|
||||
@ -564,8 +567,8 @@ class LockDetailLogic extends BaseGetXController {
|
||||
// 查询事件记录(时间查询)
|
||||
Future<void> senderReferEventRecordTime(int time) async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
(DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
(BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
|
||||
@ -850,9 +850,9 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
||||
}
|
||||
|
||||
startOpenLock() {
|
||||
print("11111111");
|
||||
// print("11111111");
|
||||
// checkBlueIsOpen((){
|
||||
print("33333333");
|
||||
// print("33333333");
|
||||
if (state.openLockBtnState.value == 1) {
|
||||
return;
|
||||
}
|
||||
@ -911,9 +911,10 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
||||
AppRouteObserver().routeObserver.unsubscribe(this);
|
||||
state.closedUnlockSuccessfulTimer?.cancel();
|
||||
_lockRefreshLockDetailInfoDataEvent?.cancel();
|
||||
|
||||
if (state.animationController != null) {
|
||||
state.animationController!.dispose();
|
||||
// state.animationController = null;
|
||||
state.animationController = null;
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
@ -934,7 +935,7 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
||||
state.ifCurrentScreen.value = false;
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
BlueManage().stopScan();
|
||||
BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
|
||||
BlueManage().disconnect();
|
||||
state.openLockBtnState.value = 0;
|
||||
|
||||
// if(state.animationController != null){
|
||||
@ -962,9 +963,9 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
||||
BlueManage().stopScan();
|
||||
state.openLockBtnState.value = 0;
|
||||
|
||||
if (state.animationController!.isAnimating) {
|
||||
state.animationController!.stop();
|
||||
}
|
||||
// if (state.animationController!.isAnimating) {
|
||||
// state.animationController!.stop();
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart';
|
||||
|
||||
import '../../../blue/blue_manage.dart';
|
||||
@ -156,8 +157,8 @@ class LockOperatingRecordLogic extends BaseGetXController {
|
||||
// 查询事件记录(时间查询)
|
||||
Future<void> senderReferEventRecordTime(int time) async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
(DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
(BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_setSupportFunctionsWithParameters.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
@ -133,32 +134,6 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 读取支持功能-带参数
|
||||
// Future<void> _readSupportFunctionsWithParameters() async {
|
||||
// BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
// if (connectionState == DeviceConnectionState.connected) {
|
||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
//
|
||||
// var token = await Storage.getStringList(saveBlueToken);
|
||||
// List<int> getTokenList = changeStringListToIntList(token!);
|
||||
//
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
//
|
||||
// IoSenderManage.readSupportFunctionsWithParametersCommand(
|
||||
// keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
||||
// userID: await Storage.getUid(),
|
||||
// featureBit: 29,
|
||||
// token: getTokenList,
|
||||
// needAuthor: 1,
|
||||
// publicKey: getPublicKeyList,
|
||||
// privateKey: getPrivateKeyList
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// 设置支持功能(带参数)
|
||||
Future<void> sendAutoLock() async {
|
||||
if(state.sureBtnState.value == 1){
|
||||
@ -171,8 +146,8 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -203,7 +178,7 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList);
|
||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
||||
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
|
||||
import '../../../../../blue/blue_manage.dart';
|
||||
@ -180,8 +181,8 @@ class AdminOpenLockPasswordLogic extends BaseGetXController{
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -202,7 +203,7 @@ class AdminOpenLockPasswordLogic extends BaseGetXController{
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList
|
||||
);
|
||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
||||
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
@ -224,8 +225,8 @@ class AdminOpenLockPasswordLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected) {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
@ -248,7 +249,7 @@ class AdminOpenLockPasswordLogic extends BaseGetXController{
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: getTokenList);
|
||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||
state.sureBtnState.value = 0;
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
|
||||
@ -9,34 +9,6 @@ import 'basicInformation_state.dart';
|
||||
class BasicInformationLogic extends BaseGetXController{
|
||||
final BasicInformationState state = BasicInformationState();
|
||||
|
||||
// 读取支持功能-带参数
|
||||
// Future<void> _readAdminPassword() async {
|
||||
// BlueManage().bludSendData(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
// if (connectionState == DeviceConnectionState.connected) {
|
||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
//
|
||||
// var token = await Storage.getStringList(saveBlueToken);
|
||||
// List<int> getTokenList = changeStringListToIntList(token!);
|
||||
//
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
//
|
||||
// IoSenderManage.senderReadAdminPasswordCommand(
|
||||
// keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
||||
// userID: await Storage.getUid(),
|
||||
// role:0xff,
|
||||
// pwdNum:5,
|
||||
// pwdNo: 0,
|
||||
// token: getTokenList,
|
||||
// needAuthor: 1,
|
||||
// publicKey: getPublicKeyList,
|
||||
// privateKey: getPrivateKeyList
|
||||
// );
|
||||
// }
|
||||
// }, isShowLoading: true);
|
||||
// }
|
||||
|
||||
// 下级界面修改成功后传递数据
|
||||
StreamSubscription? _passCurrentLockInformationEvent;
|
||||
void initLoadDataAction(BlockSetStateCallback blockSetStateCallback) {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart';
|
||||
|
||||
import '../../../../../blue/blue_manage.dart';
|
||||
@ -47,8 +48,8 @@ class UploadElectricQuantityLogic extends BaseGetXController {
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
(DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected) {
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
dismissEasyLoading();
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
@ -57,7 +58,7 @@ class UploadElectricQuantityLogic extends BaseGetXController {
|
||||
userID: await Storage.getUid(),
|
||||
privateKey: getPrivateKeyList,
|
||||
);
|
||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_setSupportFunctionsNoParameters.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
@ -114,32 +115,6 @@ class BurglarAlarmLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 读取支持功能-带参数
|
||||
// Future<void> _readSupportFunctionsNoParameters() async {
|
||||
// BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
// if (connectionState == DeviceConnectionState.connected) {
|
||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
//
|
||||
// var token = await Storage.getStringList(saveBlueToken);
|
||||
// List<int> getTokenList = changeStringListToIntList(token!);
|
||||
//
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
//
|
||||
// IoSenderManage.readSupportFunctionsNoParametersCommand(
|
||||
// keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
||||
// userID: await Storage.getUid(),
|
||||
// featureBit: 30,
|
||||
// token: getTokenList,
|
||||
// needAuthor: 1,
|
||||
// publicKey: getPublicKeyList,
|
||||
// privateKey: getPrivateKeyList
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// 设置支持功能(带参数)
|
||||
Future<void> sendBurglarAlarm() async {
|
||||
if(state.sureBtnState.value == 1){
|
||||
@ -152,8 +127,8 @@ class BurglarAlarmLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -172,7 +147,7 @@ class BurglarAlarmLogic extends BaseGetXController{
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList);
|
||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
||||
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
@ -183,31 +158,31 @@ class BurglarAlarmLogic extends BaseGetXController{
|
||||
});
|
||||
}
|
||||
|
||||
Timer? _timer;
|
||||
// CancelableOperation? _operation;
|
||||
void showBlueConnetctToastTimer({bool isShowBlueConnetctToast = true, Function? action}) {
|
||||
if (_timer != null && _timer!.isActive) {
|
||||
_timer!.cancel();
|
||||
_timer = null;
|
||||
}
|
||||
_timer = Timer.periodic(15.seconds, (timer) {
|
||||
if (action != null) {
|
||||
action();
|
||||
}
|
||||
cancelBlueConnetctToastTimer();
|
||||
if (isShowBlueConnetctToast == true) {
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
});
|
||||
}
|
||||
// Timer? _timer;
|
||||
// // CancelableOperation? _operation;
|
||||
// void showBlueConnetctToastTimer({bool isShowBlueConnetctToast = true, Function? action}) {
|
||||
// if (_timer != null && _timer!.isActive) {
|
||||
// _timer!.cancel();
|
||||
// _timer = null;
|
||||
// }
|
||||
// _timer = Timer.periodic(15.seconds, (timer) {
|
||||
// if (action != null) {
|
||||
// action();
|
||||
// }
|
||||
// cancelBlueConnetctToastTimer();
|
||||
// if (isShowBlueConnetctToast == true) {
|
||||
// showBlueConnetctToast();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
void cancelBlueConnetctToastTimer() {
|
||||
Get.log('cancelBlueConnetctToastTimer');
|
||||
if (_timer != null && _timer!.isActive) {
|
||||
_timer!.cancel();
|
||||
_timer = null;
|
||||
}
|
||||
}
|
||||
// void cancelBlueConnetctToastTimer() {
|
||||
// Get.log('cancelBlueConnetctToastTimer');
|
||||
// if (_timer != null && _timer!.isActive) {
|
||||
// _timer!.cancel();
|
||||
// _timer = null;
|
||||
// }
|
||||
// }
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
|
||||
@ -2,7 +2,8 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:network_info_plus/network_info_plus.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
@ -150,8 +151,8 @@ class ConfiguringWifiLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected){
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected){
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -204,7 +205,7 @@ class ConfiguringWifiLogic extends BaseGetXController{
|
||||
publicKey: publicKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
);
|
||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
||||
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_getWifiList.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
@ -97,8 +98,8 @@ class WifiListLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected){
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected){
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
print("openDoorTokenPubToken:$getTokenList");
|
||||
@ -117,7 +118,7 @@ class WifiListLogic extends BaseGetXController {
|
||||
publicKey: publicKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
);
|
||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
||||
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
cancelBlueConnetctToastTimer();
|
||||
|
||||
@ -3,7 +3,9 @@ import 'dart:async';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_deletUser.dart';
|
||||
@ -317,8 +319,8 @@ class LockSetLogic extends BaseGetXController {
|
||||
print("333333");
|
||||
showDeletAlertTipDialog();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -336,7 +338,7 @@ class LockSetLogic extends BaseGetXController {
|
||||
publicKey: publicKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: getTokenList);
|
||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
||||
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
print("444444");
|
||||
@ -379,8 +381,8 @@ class LockSetLogic extends BaseGetXController {
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -415,7 +417,7 @@ class LockSetLogic extends BaseGetXController {
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList);
|
||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
||||
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
@ -522,16 +524,16 @@ class LockSetLogic extends BaseGetXController {
|
||||
});
|
||||
}
|
||||
|
||||
late StreamSubscription<List<DiscoveredDevice>>_scanListDiscoveredDeviceSubscription;
|
||||
void _scanListDiscoveredDeviceSubscriptionAction() {
|
||||
_scanListDiscoveredDeviceSubscription = EventBusManager().eventBus!.on<List<DiscoveredDevice>>().listen((List<DiscoveredDevice> list) {
|
||||
final knownDeviceIndex = list.indexWhere((d) => d.name == BlueManage().connectDeviceName);
|
||||
if (knownDeviceIndex >= 0) {
|
||||
// 存在的时候赋值
|
||||
state.currentDeviceUUid.value = (list[knownDeviceIndex].serviceUuids.isNotEmpty ? list[knownDeviceIndex].serviceUuids[0] : "").toString();
|
||||
}
|
||||
});
|
||||
}
|
||||
// late StreamSubscription<List<DiscoveredDevice>>_scanListDiscoveredDeviceSubscription;
|
||||
// void _scanListDiscoveredDeviceSubscriptionAction() {
|
||||
// _scanListDiscoveredDeviceSubscription = EventBusManager().eventBus!.on<List<DiscoveredDevice>>().listen((List<DiscoveredDevice> list) {
|
||||
// final knownDeviceIndex = list.indexWhere((d) => d.name == BlueManage().connectDeviceName);
|
||||
// if (knownDeviceIndex >= 0) {
|
||||
// // 存在的时候赋值
|
||||
// state.currentDeviceUUid.value = (list[knownDeviceIndex].serviceUuids.isNotEmpty ? list[knownDeviceIndex].serviceUuids[0] : "").toString();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
void showDeletAlertTipDialog({String? showContent = ""}) {
|
||||
// bool isContains = BlueManage().connectDeviceName!.contains("T9A");
|
||||
@ -643,7 +645,14 @@ class LockSetLogic extends BaseGetXController {
|
||||
|
||||
void showDeletPasswordAlertDialog(BuildContext context) {
|
||||
// 点击删除 开始扫描
|
||||
BlueManage().startScan();
|
||||
// BlueManage().startScan(20, (List<ScanResult> list) async {
|
||||
// final knownDeviceIndex = list.indexWhere((d) => d.advertisementData.advName == BlueManage().connectDeviceName);
|
||||
// if (knownDeviceIndex >= 0) {
|
||||
// // 存在的时候赋值
|
||||
// state.currentDeviceUUid.value = (list[knownDeviceIndex].advertisementData.serviceUuids.isNotEmpty ? list[knownDeviceIndex].advertisementData.serviceUuids[0] : "").toString();
|
||||
// await BlueManage().stopScan();
|
||||
// }
|
||||
// });
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
@ -661,7 +670,7 @@ class LockSetLogic extends BaseGetXController {
|
||||
},
|
||||
cancelClick: () {
|
||||
// 取消的时候停止扫描
|
||||
BlueManage().stopScan();
|
||||
// BlueManage().stopScan();
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
@ -724,7 +733,9 @@ class LockSetLogic extends BaseGetXController {
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
Get.back();
|
||||
|
||||
if(BlueManage().deviceConnectionState == DeviceConnectionState.connected){
|
||||
factoryDataResetAction();
|
||||
|
||||
// if(BlueManage().bluetoothConnectionState == BluetoothConnectionState.connected){
|
||||
// 如果是已连接状态 直接调用协议
|
||||
// 已配对 表示这把锁未被初始化,还处于被添加状态
|
||||
// if (state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == 1) {
|
||||
@ -740,86 +751,86 @@ class LockSetLogic extends BaseGetXController {
|
||||
// deletKeyData();
|
||||
// }
|
||||
// }
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.currentDeviceUUid.value.isNotEmpty) {
|
||||
// 已经扫描到了当前设备 停止扫描,直接删除锁
|
||||
BlueManage().stopScan();
|
||||
deletLockLogic();
|
||||
} else {
|
||||
// 未扫描到 然后循环5秒扫秒
|
||||
var index = 0;
|
||||
showEasyLoading();
|
||||
state.deletWaitScanCompleter = Completer();
|
||||
state.deletWaitScanTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||
//定时任务
|
||||
if(index >= 7){
|
||||
// 当超过10秒的时候还是没有搜索到,完成任务,关闭扫描,取消定时器,弹窗提示
|
||||
if (state.deletWaitScanTimer != null && state.deletWaitScanTimer!.isActive) {
|
||||
state.deletWaitScanTimer!.cancel();
|
||||
state.deletWaitScanTimer = null;
|
||||
}
|
||||
if(state.deletWaitScanCompleter != null){
|
||||
state.deletWaitScanCompleter!.complete();
|
||||
}
|
||||
BlueManage().stopScan();
|
||||
dismissEasyLoading();
|
||||
print("555555");
|
||||
showDeletAlertTipDialog();
|
||||
}else{
|
||||
// 每秒判断获取是否搜到了当前设备
|
||||
if (state.currentDeviceUUid.isNotEmpty) {
|
||||
BlueManage().stopScan();
|
||||
// 存在的时候销毁定时器,赋值
|
||||
if (state.deletWaitScanTimer != null && state.deletWaitScanTimer!.isActive) {
|
||||
state.deletWaitScanTimer!.cancel();
|
||||
state.deletWaitScanTimer = null;
|
||||
}
|
||||
if(state.deletWaitScanCompleter != null){
|
||||
state.deletWaitScanCompleter!.complete();
|
||||
}
|
||||
dismissEasyLoading();
|
||||
|
||||
deletLockLogic();
|
||||
} else {
|
||||
// 不存在的时候返回-1 然后循环5秒
|
||||
index++;
|
||||
// print("index:$index");
|
||||
}
|
||||
}
|
||||
});
|
||||
// 等待Completer完成
|
||||
await state.deletWaitScanCompleter!.future;
|
||||
}
|
||||
// return;
|
||||
// }
|
||||
// print("state.currentDeviceUUid.value:${state.currentDeviceUUid.value}");
|
||||
// if (state.currentDeviceUUid.value.isNotEmpty) {
|
||||
// // 已经扫描到了当前设备 停止扫描,直接删除锁
|
||||
// // BlueManage().stopScan();
|
||||
// deletLockLogic();
|
||||
// } else {
|
||||
// // 未扫描到 然后循环5秒扫秒
|
||||
// var index = 0;
|
||||
// showEasyLoading();
|
||||
// state.deletWaitScanCompleter = Completer();
|
||||
// state.deletWaitScanTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||
// //定时任务
|
||||
// if(index >= 7){
|
||||
// // 当超过10秒的时候还是没有搜索到,完成任务,关闭扫描,取消定时器,弹窗提示
|
||||
// if (state.deletWaitScanTimer != null && state.deletWaitScanTimer!.isActive) {
|
||||
// state.deletWaitScanTimer!.cancel();
|
||||
// state.deletWaitScanTimer = null;
|
||||
// }
|
||||
// if(state.deletWaitScanCompleter != null){
|
||||
// state.deletWaitScanCompleter!.complete();
|
||||
// }
|
||||
// // BlueManage().stopScan();
|
||||
// dismissEasyLoading();
|
||||
// print("555555");
|
||||
// showDeletAlertTipDialog();
|
||||
// }else{
|
||||
// // 每秒判断获取是否搜到了当前设备
|
||||
// if (state.currentDeviceUUid.isNotEmpty) {
|
||||
// // BlueManage().stopScan();
|
||||
// // 存在的时候销毁定时器,赋值
|
||||
// if (state.deletWaitScanTimer != null && state.deletWaitScanTimer!.isActive) {
|
||||
// state.deletWaitScanTimer!.cancel();
|
||||
// state.deletWaitScanTimer = null;
|
||||
// }
|
||||
// if(state.deletWaitScanCompleter != null){
|
||||
// state.deletWaitScanCompleter!.complete();
|
||||
// }
|
||||
// dismissEasyLoading();
|
||||
//
|
||||
// deletLockLogic();
|
||||
// } else {
|
||||
// // 不存在的时候返回-1 然后循环5秒
|
||||
// index++;
|
||||
// // print("index:$index");
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// // 等待Completer完成
|
||||
// await state.deletWaitScanCompleter!.future;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
// 已经扫描到了当前设备 停止扫描,直接调用删除锁逻辑
|
||||
void deletLockLogic() {
|
||||
// 当扫描的数组里面是否有当前设备
|
||||
if(state.currentDeviceUUid.value[31] == "1"){
|
||||
// 已配对 表示这把锁未被初始化,还处于被添加状态
|
||||
// if (state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == 1) {
|
||||
// 如果是锁拥有者直接删除锁,调用初始化协议
|
||||
factoryDataResetAction();
|
||||
// } else {
|
||||
// // 不是锁拥有者
|
||||
// if(state.lockSetInfoData.value.lockBasicInfo!.lockUserNo != 0){
|
||||
// // 如果已经创建了用户调用协议删除
|
||||
// deletUserAction();
|
||||
// }else{
|
||||
// // 如果没有创建用户 调用接口删除
|
||||
// deletKeyData();
|
||||
// }
|
||||
// }
|
||||
}else if(state.currentDeviceUUid.value[31] == "0"){
|
||||
// 未配对 表示这把锁已被强制初始化 处于可添加状态 直接弹窗删除即可
|
||||
print("666666");
|
||||
// showDeletAlertTipDialog(showContent:"当前锁已被强制初始化,可直接添加。");
|
||||
deletLockInfoData();
|
||||
}
|
||||
}
|
||||
// void deletLockLogic() {
|
||||
// // 当扫描的数组里面是否有当前设备
|
||||
// if(state.currentDeviceUUid.value[31] == "1"){
|
||||
// // 已配对 表示这把锁未被初始化,还处于被添加状态
|
||||
// // if (state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == 1) {
|
||||
// // 如果是锁拥有者直接删除锁,调用初始化协议
|
||||
// factoryDataResetAction();
|
||||
// // } else {
|
||||
// // // 不是锁拥有者
|
||||
// // if(state.lockSetInfoData.value.lockBasicInfo!.lockUserNo != 0){
|
||||
// // // 如果已经创建了用户调用协议删除
|
||||
// // deletUserAction();
|
||||
// // }else{
|
||||
// // // 如果没有创建用户 调用接口删除
|
||||
// // deletKeyData();
|
||||
// // }
|
||||
// // }
|
||||
// }else if(state.currentDeviceUUid.value[31] == "0"){
|
||||
// // 未配对 表示这把锁已被强制初始化 处于可添加状态 直接弹窗删除即可
|
||||
// print("666666");
|
||||
// // showDeletAlertTipDialog(showContent:"当前锁已被强制初始化,可直接添加。");
|
||||
// deletLockInfoData();
|
||||
// }
|
||||
// }
|
||||
|
||||
// 当是锁拥有者的时候,删除锁
|
||||
void deletLockInfoData() async {
|
||||
@ -837,7 +848,7 @@ class LockSetLogic extends BaseGetXController {
|
||||
});
|
||||
}else{
|
||||
Future.delayed(const Duration(milliseconds: 200)).then((e) {
|
||||
Get.close(2);
|
||||
Get.back();
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -874,7 +885,7 @@ class LockSetLogic extends BaseGetXController {
|
||||
super.onReady();
|
||||
|
||||
_initReplySubscription();
|
||||
_scanListDiscoveredDeviceSubscriptionAction();
|
||||
// _scanListDiscoveredDeviceSubscriptionAction();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -889,6 +900,6 @@ class LockSetLogic extends BaseGetXController {
|
||||
|
||||
_replySubscription.cancel();
|
||||
_passCurrentLockInformationEvent!.cancel();
|
||||
_scanListDiscoveredDeviceSubscription.cancel();
|
||||
// _scanListDiscoveredDeviceSubscription.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@ -778,7 +778,7 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
!state.deletWaitScanCompleter!.isCompleted) {
|
||||
state.deletWaitScanCompleter!.complete();
|
||||
}
|
||||
BlueManage().stopScan();
|
||||
// BlueManage().stopScan();
|
||||
state.ifCurrentScreen.value = false;
|
||||
}
|
||||
|
||||
@ -805,7 +805,7 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
!state.deletWaitScanCompleter!.isCompleted) {
|
||||
state.deletWaitScanCompleter!.complete();
|
||||
}
|
||||
BlueManage().stopScan();
|
||||
// BlueManage().stopScan();
|
||||
state.ifCurrentScreen.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ class LockSetState {
|
||||
|
||||
var isOnlyOneData = false.obs;
|
||||
var isAttendance = 0.obs;// 是否开启考勤
|
||||
var currentDeviceUUid = "".obs;// 当前设备的uuid
|
||||
// var currentDeviceUUid = "".obs;// 当前设备的uuid
|
||||
var isOpenLockNeedOnline = 0.obs;// APP开锁时是否需联网
|
||||
|
||||
var isLockPickingReminder = 0.obs;// 是否开启开锁提醒
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
@ -120,32 +121,6 @@ class LockSoundSetLogic extends BaseGetXController {
|
||||
}
|
||||
}
|
||||
|
||||
// 读取支持功能-带参数
|
||||
// Future<void> _readSupportFunctionsWithParameters() async {
|
||||
// BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
// if (connectionState == DeviceConnectionState.connected) {
|
||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
//
|
||||
// var token = await Storage.getStringList(saveBlueToken);
|
||||
// List<int> getTokenList = changeStringListToIntList(token!);
|
||||
//
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
//
|
||||
// IoSenderManage.readSupportFunctionsWithParametersCommand(
|
||||
// keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
||||
// userID: await Storage.getUid(),
|
||||
// featureBit: 33,
|
||||
// token: getTokenList,
|
||||
// needAuthor: 1,
|
||||
// publicKey: getPublicKeyList,
|
||||
// privateKey: getPrivateKeyList
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// 设置支持功能(带参数)
|
||||
Future<void> sendLockSound() async {
|
||||
if(state.sureBtnState.value == 1){
|
||||
@ -158,8 +133,8 @@ class LockSoundSetLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -187,7 +162,7 @@ class LockSoundSetLogic extends BaseGetXController {
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList);
|
||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
||||
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_timing.dart';
|
||||
@ -126,22 +127,6 @@ class LockTimeLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 获取锁状态
|
||||
// Future<void> _getLockStatus() async {
|
||||
// // 进来之后首先连接
|
||||
// BlueManage().bludSendData(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:await Storage.getUid(),
|
||||
// privateKey:getPrivateKeyList,
|
||||
// );
|
||||
// }
|
||||
// }, isShowLoading: false);
|
||||
// }
|
||||
|
||||
// 校验时间
|
||||
Future<void> sendTiming() async {
|
||||
if(state.sureBtnState.value == 1){
|
||||
@ -154,8 +139,8 @@ class LockTimeLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -174,7 +159,7 @@ class LockTimeLogic extends BaseGetXController{
|
||||
signKey:getSignKeyList,
|
||||
privateKey:getPrivateKeyList,
|
||||
);
|
||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
||||
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_setSupportFunctionsNoParameters.dart';
|
||||
@ -109,8 +111,8 @@ class MotorPowerLogic extends BaseGetXController {
|
||||
|
||||
// 读取支持功能-带参数
|
||||
Future<void> _readSupportFunctionsNoParameters() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -135,8 +137,8 @@ class MotorPowerLogic extends BaseGetXController {
|
||||
|
||||
// 设置支持功能(带参数)
|
||||
Future<void> sendOpenDoorDirection() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
@ -139,32 +139,6 @@ class NormallyOpenModeLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 读取支持功能-带参数
|
||||
// Future<void> _readSupportFunctionsWithParameters() async {
|
||||
// BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
// if (connectionState == DeviceConnectionState.connected) {
|
||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
//
|
||||
// var token = await Storage.getStringList(saveBlueToken);
|
||||
// List<int> getTokenList = changeStringListToIntList(token!);
|
||||
//
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
//
|
||||
// IoSenderManage.readSupportFunctionsWithParametersCommand(
|
||||
// keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
||||
// userID: await Storage.getUid(),
|
||||
// featureBit: 50,
|
||||
// token: getTokenList,
|
||||
// needAuthor: 1,
|
||||
// publicKey: getPublicKeyList,
|
||||
// privateKey: getPrivateKeyList
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// 设置支持功能(带参数)
|
||||
Future<void> sendAutoLock() async {
|
||||
if(state.sureBtnState.value == 1){
|
||||
@ -177,8 +151,8 @@ class NormallyOpenModeLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -230,7 +204,7 @@ class NormallyOpenModeLogic extends BaseGetXController{
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList);
|
||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
||||
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_setSupportFunctionsNoParameters.dart';
|
||||
@ -109,38 +111,12 @@ class OpenDoorDirectionLogic extends BaseGetXController {
|
||||
}
|
||||
}
|
||||
|
||||
// 读取支持功能-带参数
|
||||
// Future<void> _readSupportFunctionsNoParameters() async {
|
||||
// BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
// if (connectionState == DeviceConnectionState.connected) {
|
||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
//
|
||||
// var token = await Storage.getStringList(saveBlueToken);
|
||||
// List<int> getTokenList = changeStringListToIntList(token!);
|
||||
//
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
//
|
||||
// IoSenderManage.readSupportFunctionsNoParametersCommand(
|
||||
// keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
||||
// userID: await Storage.getUid(),
|
||||
// featureBit: 41,
|
||||
// token: getTokenList,
|
||||
// needAuthor: 1,
|
||||
// publicKey: getPublicKeyList,
|
||||
// privateKey: getPrivateKeyList
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// 设置支持功能(带参数)
|
||||
Future<void> sendOpenDoorDirection() async {
|
||||
showEasyLoading();
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
dismissEasyLoading();
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -159,7 +135,7 @@ class OpenDoorDirectionLogic extends BaseGetXController {
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList);
|
||||
}else if (connectionState == DeviceConnectionState.disconnected) {
|
||||
}else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
@ -111,32 +112,6 @@ class RemoteUnlockingLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 读取支持功能-带参数
|
||||
// Future<void> _readSupportFunctionsNoParameters() async {
|
||||
// BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
// if (connectionState == DeviceConnectionState.connected) {
|
||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
//
|
||||
// var token = await Storage.getStringList(saveBlueToken);
|
||||
// List<int> getTokenList = changeStringListToIntList(token!);
|
||||
//
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
//
|
||||
// IoSenderManage.readSupportFunctionsNoParametersCommand(
|
||||
// keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
||||
// userID: await Storage.getUid(),
|
||||
// featureBit: 28,
|
||||
// token: getTokenList,
|
||||
// needAuthor: 1,
|
||||
// publicKey: getPublicKeyList,
|
||||
// privateKey: getPrivateKeyList
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// 设置支持功能(带参数) 远程开锁
|
||||
Future<void> sendBurglarAlarm() async {
|
||||
if(state.sureBtnState.value == 1){
|
||||
@ -149,8 +124,8 @@ class RemoteUnlockingLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -169,7 +144,7 @@ class RemoteUnlockingLogic extends BaseGetXController{
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList);
|
||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
||||
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:star_lock/main/lockDetail/lockSet/resetButton/resetButton_state.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
@ -112,32 +113,6 @@ class ResetButtonLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 读取支持功能-带参数
|
||||
// Future<void> _readSupportFunctionsNoParameters() async {
|
||||
// BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
// if (connectionState == DeviceConnectionState.connected) {
|
||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
//
|
||||
// var token = await Storage.getStringList(saveBlueToken);
|
||||
// List<int> getTokenList = changeStringListToIntList(token!);
|
||||
//
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
//
|
||||
// IoSenderManage.readSupportFunctionsNoParametersCommand(
|
||||
// keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
||||
// userID: await Storage.getUid(),
|
||||
// featureBit: 31,
|
||||
// token: getTokenList,
|
||||
// needAuthor: 1,
|
||||
// publicKey: getPublicKeyList,
|
||||
// privateKey: getPrivateKeyList
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// 设置支持功能(带参数)
|
||||
Future<void> sendBurglarAlarm() async {
|
||||
if(state.sureBtnState.value == 1){
|
||||
@ -150,8 +125,8 @@ class ResetButtonLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -170,7 +145,7 @@ class ResetButtonLogic extends BaseGetXController{
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList);
|
||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
||||
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
@ -246,8 +247,8 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected) {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
@ -261,8 +262,8 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
|
||||
IoSenderManage.senderCustomPasswordsCommand(
|
||||
keyID: "1",
|
||||
userID: await Storage.getUid(),
|
||||
pwdNo: 1,
|
||||
pwd:state.pwdController.text,
|
||||
pwdNo: state.isAdministrator.value == true ? 254 : 1,
|
||||
pwd: state.pwdController.text,
|
||||
useCountLimit: 0xff,
|
||||
startTime: 0x11223344,
|
||||
endTime: 0x11223344,
|
||||
@ -270,7 +271,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: getTokenList);
|
||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
|
||||
@ -76,6 +76,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(
|
||||
false,
|
||||
TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
||||
state.nameController),
|
||||
@ -90,6 +91,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
|
||||
children: [
|
||||
keyTimeLimitWidget(),
|
||||
perpetualKeyWidget(
|
||||
false,
|
||||
TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
||||
state.nameController),
|
||||
@ -103,6 +105,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(
|
||||
false,
|
||||
TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
||||
state.nameController),
|
||||
@ -120,11 +123,16 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
|
||||
? keyTimeLimitWidget()
|
||||
: Container(),
|
||||
perpetualKeyWidget(
|
||||
false,
|
||||
TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
||||
state.nameController),
|
||||
perpetualKeyWidget(TranslationLoader.lanKeys!.password!.tr,
|
||||
"请输入6-9位数字", state.pwdController),
|
||||
perpetualKeyWidget(
|
||||
false,
|
||||
TranslationLoader.lanKeys!.password!.tr,
|
||||
"请输入6-9位数字", state.pwdController
|
||||
),
|
||||
keyIfAdministratorWidget(),
|
||||
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip4!.tr)
|
||||
],
|
||||
);
|
||||
@ -136,6 +144,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
|
||||
children: [
|
||||
keyCirculationWidget(),
|
||||
perpetualKeyWidget(
|
||||
true,
|
||||
TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
||||
state.nameController),
|
||||
@ -149,6 +158,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(
|
||||
false,
|
||||
TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
||||
state.nameController),
|
||||
@ -164,10 +174,10 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
|
||||
|
||||
// 密码命名输入框
|
||||
Widget perpetualKeyWidget(
|
||||
String titleStr, String rightTitle, TextEditingController controller) {
|
||||
bool isTopHeight, String titleStr, String rightTitle, TextEditingController controller) {
|
||||
return Column(
|
||||
children: [
|
||||
SizedBox(height: 10.h),
|
||||
isTopHeight ? SizedBox(height: 10.h) : Container(),
|
||||
CommonItem(
|
||||
leftTitel: titleStr,
|
||||
rightTitle: "",
|
||||
@ -243,8 +253,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
|
||||
leftTitel: TranslationLoader.lanKeys!.permanent!.tr,
|
||||
rightTitle: "",
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch()),
|
||||
action: () {}),
|
||||
rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch())),
|
||||
state.isPermanent.value == true
|
||||
? Container(height: 10.h)
|
||||
: Container(height: 1.h),
|
||||
@ -252,6 +261,23 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
|
||||
);
|
||||
}
|
||||
|
||||
// 自定义是否永久
|
||||
Widget keyIfAdministratorWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
// SizedBox(height: 10.h),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: "是否是管理员",
|
||||
rightTitle: "",
|
||||
isTipsImg: false,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w, height: 50.h, child: _isAdministrator()))),
|
||||
SizedBox(height: 10.h),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 循环
|
||||
Widget keyCirculationWidget() {
|
||||
return Column(
|
||||
@ -591,6 +617,19 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
|
||||
);
|
||||
}
|
||||
|
||||
// 是否是管理员
|
||||
CupertinoSwitch _isAdministrator() {
|
||||
return CupertinoSwitch(
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: state.isAdministrator.value,
|
||||
onChanged: (value) {
|
||||
state.isAdministrator.value = value;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
String intToStr(int v) {
|
||||
return (v < 10) ? "0$v" : "$v";
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ class PasswordKeyPerpetualState {
|
||||
final isPermanent = true.obs; //是否永久
|
||||
var getPwdStr = ''.obs;
|
||||
var pwdNameStr = '';
|
||||
final isAdministrator = false.obs;// 是否是管理员
|
||||
|
||||
final effectiveDateTime = DateTime.now().obs;
|
||||
final failureDateTime = DateTime.now().obs;
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
import 'dart:async';
|
||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
|
||||
import '../../../blue/blue_manage.dart';
|
||||
import '../../../network/api_repository.dart';
|
||||
import '../../../talk/udp/udp_help.dart';
|
||||
import '../../../tools/baseGetXController.dart';
|
||||
@ -85,6 +86,8 @@ class LockMainLogic extends BaseGetXController {
|
||||
|
||||
// 开启UDP
|
||||
UdpHelp().openUDP();
|
||||
|
||||
BlueManage();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@ -1,7 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:aliyun_push/aliyun_push.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
@ -9,7 +6,6 @@ import 'package:get/get.dart';
|
||||
import 'package:star_lock/app_settings/app_colors.dart';
|
||||
import 'package:star_lock/tools/noData.dart';
|
||||
import 'package:star_lock/tools/submitBtn.dart';
|
||||
import 'package:star_lock/tools/xs_aliyunPush.dart';
|
||||
|
||||
import '../../../appRouters.dart';
|
||||
import '../../../baseWidget.dart';
|
||||
@ -53,7 +49,6 @@ class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget {
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
getHttpData();
|
||||
});
|
||||
initAliyunPush();
|
||||
|
||||
_initLoadDataAction();
|
||||
}
|
||||
@ -146,12 +141,14 @@ class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget {
|
||||
Storage.setBool(ifIsDemoModeOrNot, false);
|
||||
returnWidget = LockDetailPage(
|
||||
isOnlyOneData: true,
|
||||
lockListInfoItemEntity: state.lockListInfoEntity.value.data!.groupList![0].lockList![0]);
|
||||
lockListInfoItemEntity: state
|
||||
.lockListInfoEntity.value.data!.groupList![0].lockList![0]);
|
||||
break;
|
||||
case 2:
|
||||
// 有多条数据
|
||||
Storage.setBool(ifIsDemoModeOrNot, false);
|
||||
returnWidget = LockListPage(lockListInfoGroupEntity: state.lockListInfoEntity.value.data!);
|
||||
returnWidget = LockListPage(
|
||||
lockListInfoGroupEntity: state.lockListInfoEntity.value.data!);
|
||||
break;
|
||||
default:
|
||||
returnWidget = NoData();
|
||||
@ -236,27 +233,6 @@ class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget {
|
||||
|
||||
void onHide() {}
|
||||
|
||||
//初始化阿里云推送
|
||||
void initAliyunPush() {
|
||||
final aliyunPush = AliyunPush();
|
||||
XSAliyunPushProvider().init(aliyunPush);
|
||||
XSAliyunPushProvider().initAliyunPush();
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
XSAliyunPushProvider().initAliyunThirdPush();
|
||||
}
|
||||
|
||||
//暂使用DeviceID推送
|
||||
aliyunPush.getDeviceId().then((deviceId) async {
|
||||
// print('得到的DeviceId$deviceId');
|
||||
final data = await Storage.getString(saveUserLoginData);
|
||||
if (data!.isNotEmpty && deviceId.isNotEmpty) {
|
||||
XSAliyunPushProvider()
|
||||
.pushBindDeviceID(deviceId, Platform.isAndroid ? 10 : 20);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
late StreamSubscription _teamEvent;
|
||||
void _initLoadDataAction() {
|
||||
_teamEvent = eventBus.on<RefreshLockListInfoDataEvent>().listen((event) {
|
||||
|
||||
@ -386,7 +386,7 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage> with RouteA
|
||||
AppRouteObserver().routeObserver.unsubscribe(this);
|
||||
super.dispose();
|
||||
|
||||
BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
|
||||
BlueManage().disconnect();
|
||||
|
||||
location.stopLocation();
|
||||
location.destroy();
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_getPrivateKey.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_getPublicKey.dart';
|
||||
@ -22,10 +23,10 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
// 点击连接设备
|
||||
void connect(String deviceName){
|
||||
showEasyLoading();
|
||||
BlueManage().bludSendData(deviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
BlueManage().bludSendData(deviceName, (BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
IoSenderManage.getPublicKey(lockId: deviceName);
|
||||
}else if (state == DeviceConnectionState.disconnected) {
|
||||
}else if (state == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
// showBlueConnetctToast();
|
||||
}
|
||||
@ -175,9 +176,9 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
// 厂商序列号
|
||||
var serialNum0 = reply.data.sublist(84, 100);
|
||||
var serialNum0Str = utf8String(serialNum0);
|
||||
// state.lockInfo["serialNum0"] = serialNum0Str;
|
||||
state.lockInfo["serialNum0"] = "${DateTime.now().millisecondsSinceEpoch ~/ 10}";
|
||||
// print("serialNum0Str:$serialNum0Str serialNum0Str:${serialNum0Str.length}");
|
||||
state.lockInfo["serialNum0"] = serialNum0Str;
|
||||
// state.lockInfo["serialNum0"] = "${DateTime.now().millisecondsSinceEpoch ~/ 10}";
|
||||
print("serialNum0Str:$serialNum0Str serialNum0Str:${serialNum0Str.length}");
|
||||
|
||||
// 成品商序列号
|
||||
var serialNum1 = reply.data.sublist(100, 116);
|
||||
@ -239,6 +240,11 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
var featureValueLength = reply.data[173];
|
||||
// 锁特征值说明(本机能支持的功能)
|
||||
// 获取到锁给的字符数组
|
||||
var featureNetxLength = index + featureValueLength + 1;
|
||||
if(reply.data.length < featureNetxLength){
|
||||
showToast("锁特征值数据获取失败,请重新点击获取");
|
||||
return;
|
||||
}
|
||||
var featureValue = reply.data.sublist(index + 1, index + featureValueLength + 1);
|
||||
String featureValueStr = asciiString(featureValue);
|
||||
state.featureValue = featureValueStr;
|
||||
@ -249,6 +255,11 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
// 使能特征值字符串长度
|
||||
var featureEnValLength = reply.data[index];
|
||||
// 使能锁特征值说明(本机启用的功能)
|
||||
var featureEnNextLength = index + featureEnValLength + 1;
|
||||
if(reply.data.length < featureEnNextLength){
|
||||
showToast("锁使能特征值数据获取失败,请重新点击获取");
|
||||
return;
|
||||
}
|
||||
var featureEnVal = reply.data.sublist(index + 1, index + featureEnValLength + 1);
|
||||
String featureEnValStr = asciiString(featureEnVal);
|
||||
state.featureSettingValue = featureEnValStr;
|
||||
@ -315,8 +326,8 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
Future<void> _getStarLockStatus() async {
|
||||
// print("connectDeviceMacAddress:${BlueManage().connectDeviceMacAddress} connectDeviceName:${BlueManage().connectDeviceName}");
|
||||
// 进来之后首先连接
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
dismissEasyLoading();
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
@ -330,31 +341,39 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
userID: await Storage.getUid(),
|
||||
privateKey: getPrivateKeyList,
|
||||
);
|
||||
} else if (state == DeviceConnectionState.disconnected) {
|
||||
} else if (state == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
}
|
||||
}, isAddEquipment: true);
|
||||
}
|
||||
|
||||
late StreamSubscription<List<DiscoveredDevice>>_scanListDiscoveredDeviceSubscription;
|
||||
void _scanListDiscoveredDeviceSubscriptionAction() {
|
||||
_scanListDiscoveredDeviceSubscription = EventBusManager().eventBus!.on<List<DiscoveredDevice>>().listen((List<DiscoveredDevice> list) {
|
||||
// late StreamSubscription<List<ScanResult>>_scanListDiscoveredDeviceSubscription;
|
||||
// void _scanListDiscoveredDeviceSubscriptionAction() {
|
||||
// _scanListDiscoveredDeviceSubscription = EventBusManager().eventBus!.on<List<ScanResult>>().listen((List<ScanResult> list) {
|
||||
// state.devices.clear();
|
||||
// for (int i = 0; i < list.length; i++) {
|
||||
// ScanResult device = list[i];
|
||||
// if (((device.advertisementData.serviceUuids.isNotEmpty ? device.advertisementData.serviceUuids[0] : "").toString()[31] != "1")) {
|
||||
// state.devices.add(list[i]);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
void startScanBlueList(){
|
||||
BlueManage().startScan(2000, (List<ScanResult> list){
|
||||
state.devices.clear();
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
DiscoveredDevice device = list[i];
|
||||
if (((device.serviceUuids.isNotEmpty ? device.serviceUuids[0] : "").toString()[31] != "1")) {
|
||||
ScanResult device = list[i];
|
||||
if (((device.advertisementData.serviceUuids.isNotEmpty ? device.advertisementData.serviceUuids[0] : "").toString()[31] != "1")) {
|
||||
state.devices.add(list[i]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void startScanBlueList(){
|
||||
BlueManage().startScan();
|
||||
}
|
||||
|
||||
void stopScanBlueList(){
|
||||
BlueManage().disconnect("state.selectLockName.value");
|
||||
BlueManage().disconnect();
|
||||
BlueManage().stopScan();
|
||||
}
|
||||
|
||||
@ -365,9 +384,10 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
print("NearbyLockLogic onReady()");
|
||||
|
||||
_initReplySubscription();
|
||||
_scanListDiscoveredDeviceSubscriptionAction();
|
||||
// _scanListDiscoveredDeviceSubscriptionAction();
|
||||
|
||||
state.ifCurrentScreen.value = true;
|
||||
|
||||
startScanBlueList();
|
||||
}
|
||||
|
||||
@ -383,6 +403,6 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
_replySubscription.cancel();
|
||||
_scanListDiscoveredDeviceSubscription.cancel();
|
||||
// _scanListDiscoveredDeviceSubscription.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,12 +4,14 @@ import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../../../appRouters.dart';
|
||||
import '../../../app_settings/app_colors.dart';
|
||||
import '../../../blue/blue_manage.dart';
|
||||
import '../../../tools/appRouteObserver.dart';
|
||||
import '../../../tools/titleAppBar.dart';
|
||||
import '../../../translations/trans_lib.dart';
|
||||
@ -55,9 +57,9 @@ class _NearbyLockPageState extends State<NearbyLockPage> with RouteAware {
|
||||
return nearbyLockItem('images/icon_lockGroup_item.png', state.devices[index], () {
|
||||
// Navigator.pushNamed(context, Routers.lockAddressPage);
|
||||
// logic.getPublicKey(state.devices[index].serviceUuids[0].toString());
|
||||
state.selectLockName.value = state.devices[index].name;
|
||||
state.selectLockName.value = state.devices[index].advertisementData.advName;
|
||||
// print("connect-lockId:${state.devices[index].id} deviceName:${state.devices[index].name}");
|
||||
logic.connect(state.devices[index].name);
|
||||
logic.connect(state.devices[index].advertisementData.advName);
|
||||
// Get.toNamed(Routers.lockAddressGaoDePage);
|
||||
});
|
||||
},
|
||||
@ -74,9 +76,9 @@ class _NearbyLockPageState extends State<NearbyLockPage> with RouteAware {
|
||||
);
|
||||
}
|
||||
|
||||
Widget nearbyLockItem(String lockTypeIcon, DiscoveredDevice discoveredDevice, Function() action ) {
|
||||
Widget nearbyLockItem(String lockTypeIcon, ScanResult scanResult, Function() action ) {
|
||||
return GestureDetector(
|
||||
onTap: ((discoveredDevice.serviceUuids.isNotEmpty ? discoveredDevice.serviceUuids[0] : "").toString()[33] == "1") ? action : null,
|
||||
onTap: ((scanResult.advertisementData.serviceUuids.isNotEmpty ? scanResult.advertisementData.serviceUuids[0] : "").toString()[33] == "1") ? action : null,
|
||||
child: Column(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
@ -98,7 +100,7 @@ class _NearbyLockPageState extends State<NearbyLockPage> with RouteAware {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 第32、33两位00 表示休眠, 01表示唤醒
|
||||
Text(discoveredDevice.name, style: TextStyle(fontSize: 20.sp, color: ((discoveredDevice.serviceUuids.isNotEmpty ? discoveredDevice.serviceUuids[0] : "").toString()[33] == "1") ? AppColors.blackColor : Colors.grey)),
|
||||
Text(scanResult.advertisementData.advName, style: TextStyle(fontSize: 20.sp, color: ((scanResult.advertisementData.serviceUuids.isNotEmpty ? scanResult.advertisementData.serviceUuids[0] : "").toString()[33] == "1") ? AppColors.blackColor : Colors.grey)),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
@ -163,6 +165,7 @@ class _NearbyLockPageState extends State<NearbyLockPage> with RouteAware {
|
||||
state.ifCurrentScreen.value = false;
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
logic.stopScanBlueList();
|
||||
BlueManage().disconnect();
|
||||
}
|
||||
|
||||
/// 从下级返回 当前界面即将出现
|
||||
@ -184,6 +187,7 @@ class _NearbyLockPageState extends State<NearbyLockPage> with RouteAware {
|
||||
state.ifCurrentScreen.value = false;
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
logic.stopScanBlueList();
|
||||
BlueManage().disconnect();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class NearbyLockState {
|
||||
|
||||
RxList<DiscoveredDevice> devices = <DiscoveredDevice>[].obs;
|
||||
RxList<ScanResult> devices = <ScanResult>[].obs;
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
var selectLockName = "".obs;
|
||||
|
||||
|
||||
@ -3,7 +3,8 @@ import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_changeAdministratorPassword.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_senderCustomPasswords.dart';
|
||||
@ -234,9 +235,9 @@ class SaveLockLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
state.saveBtnIsUsable.value = true;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
// print("222222");
|
||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
// print("333333");
|
||||
// 私钥
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
@ -267,7 +268,7 @@ class SaveLockLogic extends BaseGetXController {
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList
|
||||
);
|
||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||
print("444444");
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
@ -285,8 +286,8 @@ class SaveLockLogic extends BaseGetXController {
|
||||
var number = rng.nextInt(900000) + 100000; // 生成 100000 到 999999 之间的随机整数
|
||||
state.adminPassword = number.toString();
|
||||
state.adminPasswordTF.text = number.toString();
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected) {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
@ -319,8 +320,8 @@ class SaveLockLogic extends BaseGetXController {
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected) {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
@ -343,7 +344,7 @@ class SaveLockLogic extends BaseGetXController {
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: getTokenList);
|
||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||
print("444444");
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
@ -459,7 +460,7 @@ class SaveLockLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
void backAction(){
|
||||
BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
|
||||
BlueManage().disconnect();
|
||||
Get.close(state.isFromMap == 1 ? 6 : 7);
|
||||
}
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ class MineSetLogic extends BaseGetXController {
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
UdpHelp().closeUDP();
|
||||
logOut();
|
||||
BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
|
||||
BlueManage().disconnect();
|
||||
Get.offNamedUntil(Routers.starLockLoginPage, (route) => false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ import 'package:star_lock/login/login/starLock_login_page.dart';
|
||||
import 'package:star_lock/tools/appFirstEnterHandle.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
|
||||
import '../blue/blue_manage.dart';
|
||||
import '../main/lockMian/lockMain/lockMain_page.dart';
|
||||
|
||||
class StarLockApplication extends StatefulWidget {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:aliyun_push/aliyun_push.dart';
|
||||
import 'package:star_lock/flavors.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
@ -71,12 +72,23 @@ class XSAliyunPushProvider {
|
||||
Future<void> initAliyunPush() async {
|
||||
String appKey;
|
||||
String appSecret;
|
||||
|
||||
if (Platform.isIOS) {
|
||||
appKey = "333904046";
|
||||
appSecret = "3eead09a7fc7416cb4082319aa6f48c6";
|
||||
if (F.appFlavor == Flavor.sky) {
|
||||
appKey = "334068745";
|
||||
appSecret = "bee9c200835e4951a85dc8709c319560";
|
||||
} else {
|
||||
appKey = "333904046";
|
||||
appSecret = "3eead09a7fc7416cb4082319aa6f48c6";
|
||||
}
|
||||
} else {
|
||||
appKey = "333904040";
|
||||
appSecret = "c316965fe0a74fc9a481a5c44a535dc2";
|
||||
if (F.appFlavor == Flavor.sky) {
|
||||
appKey = "334068743";
|
||||
appSecret = "64de537f14984159a66ada10e54c6b63";
|
||||
} else {
|
||||
appKey = "333904040";
|
||||
appSecret = "c316965fe0a74fc9a481a5c44a535dc2";
|
||||
}
|
||||
}
|
||||
|
||||
_aliyunPush
|
||||
|
||||
@ -76,7 +76,8 @@ dependencies:
|
||||
#跳转到外部
|
||||
url_launcher: ^6.1.10
|
||||
#蓝牙
|
||||
flutter_reactive_ble: ^5.1.1
|
||||
# flutter_reactive_ble: ^5.1.1
|
||||
flutter_blue_plus: ^1.31.16
|
||||
#
|
||||
event_bus: ^2.0.0
|
||||
#菊花
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user