Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
Demo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
dengpeng
Demo
Commits
74394f17
Commit
74394f17
authored
1 year ago
by
linjiacheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.添加快速绑定功能及命令码支持
parent
dfcaf30b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
1 deletion
+46
-1
app/src/main/java/com/ltdigital/sdk/android/demo/activity/AuthActivity.kt
...a/com/ltdigital/sdk/android/demo/activity/AuthActivity.kt
+14
-0
app/src/main/java/com/ltdigital/sdk/android/demo/bluetooth/helper/BleProtocolOvviHelper.java
.../android/demo/bluetooth/helper/BleProtocolOvviHelper.java
+15
-0
app/src/main/java/com/ltdigital/sdk/android/demo/bluetooth/helper/DeviceAuthHelper.java
...l/sdk/android/demo/bluetooth/helper/DeviceAuthHelper.java
+11
-1
app/src/main/res/layout/activity_auth.xml
app/src/main/res/layout/activity_auth.xml
+6
-0
No files found.
app/src/main/java/com/ltdigital/sdk/android/demo/activity/AuthActivity.kt
View file @
74394f17
...
...
@@ -32,6 +32,20 @@ class AuthActivity : BaseDeviceActivity(), AuthCallback {
}
})
}
bt_quick_bind
.
setOnClickListener
{
bleDevice
?.
deviceManager
?.
authHelper
?.
requestQuickBindDevice
(
getId
(),
object
:
BaseDeviceCallback
<
Any
?>
{
override
fun
onFail
(
code
:
Int
)
{
//绑定失败
onLog
(
"快速绑定命令发送失败,原因:$code"
)
}
override
fun
onSuccess
(
data
:
Any
?)
{
//绑定成功
onLog
(
"快速绑定命令发送成功"
)
}
})
}
bt_cancel_bind
.
setOnClickListener
{
bleDevice
?.
deviceManager
?.
authHelper
?.
cancelBindDevice
(
object
:
BaseDeviceCallback
<
Any
?>
{
...
...
This diff is collapsed.
Click to expand it.
app/src/main/java/com/ltdigital/sdk/android/demo/bluetooth/helper/BleProtocolOvviHelper.java
View file @
74394f17
...
...
@@ -76,6 +76,21 @@ public class BleProtocolOvviHelper {
return
generateSendDataBean
(
data
,
optionCode
);
}
/**
* 快速绑定设备(设备端不需要确认)
*
* @param userOnlyKey 用户唯一标识
* @return 可发送的bean
*/
public
static
BleDataBean
quickBindDevice
(
@NonNull
String
userOnlyKey
)
{
byte
[]
md5
=
Utils
.
md5
(
userOnlyKey
);
byte
[]
data
=
new
byte
[
17
];
int
optionCode
=
BluetoothCommand
.
BLE_COMMAND_DEVICE_AUTH
;
data
[
0
]
=
0x07
;
System
.
arraycopy
(
md5
,
0
,
data
,
1
,
16
);
return
generateSendDataBean
(
data
,
optionCode
);
}
/**
* 取消设备绑定流程
*
...
...
This diff is collapsed.
Click to expand it.
app/src/main/java/com/ltdigital/sdk/android/demo/bluetooth/helper/DeviceAuthHelper.java
View file @
74394f17
...
...
@@ -88,10 +88,20 @@ public class DeviceAuthHelper extends BaseDeviceSyncHelper {
requestBindDevice
(
userUUID
,
false
,
callback
);
}
public
void
requestBindDevice
(
String
userUUID
,
boolean
isForce
,
BaseDeviceCallback
callback
)
{
public
void
requestBindDevice
(
String
userUUID
,
boolean
isForce
,
BaseDeviceCallback
callback
)
{
syncDataWithAckRepeatCheck
(
BleProtocolOvviHelper
.
bindDevice
(
userUUID
,
isForce
),
callback
,
false
);
}
/**
* 发起不需要设备确认的快速绑定请求
*
* @param userUUID 绑定发送至设备的UUID码
* @param callback 绑定结果回调
*/
public
void
requestQuickBindDevice
(
String
userUUID
,
BaseDeviceCallback
callback
)
{
syncDataWithAckRepeatCheck
(
BleProtocolOvviHelper
.
quickBindDevice
(
userUUID
),
callback
,
false
);
}
public
void
cancelBindDevice
(
BaseDeviceCallback
callback
)
{
enqueueDataSyncOperation
(
DataSyncOperation
.
RESULT_TYPE_DATA
,
...
...
This diff is collapsed.
Click to expand it.
app/src/main/res/layout/activity_auth.xml
View file @
74394f17
...
...
@@ -80,6 +80,12 @@
android:layout_height=
"wrap_content"
android:text=
"强制绑定"
/>
<Button
android:id=
"@+id/bt_quick_bind"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"快速绑定"
/>
</GridLayout>
</LinearLayout>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment