Android Device Auth SDK
The current repository does not yet contain a standalone DeviceAuthenticator.kt. BLE authentication is still mostly embedded in XTalkBleClient.authenticateAndInitializeDefaults(...), while UART authentication is mainly implemented in XTalkMeshUiApp.kt. This page defines what belongs to the authentication layer and maps it to the current code.
Current implementation location
BLE authentication
apps/android-ui/app/src/main/java/com/xtalk/mesh/uimock/ble/XTalkBleClient.ktauthenticateAndInitializeDefaults(...)AT+CHALLENGE- challenge parsing / signature verification
- DID wait/read
UART authentication
apps/android-ui/app/src/main/java/com/xtalk/mesh/uimock/XTalkMeshUiApp.ktAT+CHALLENGE=<hex>AT+EFUSESN?- fallback
AT+SN?
What the Auth SDK should own
- challenge generation for
AT+CHALLENGE=<hex> - challenge send
- challenge response parsing
- signature verification
- DID read
- a structured authentication result
What the Auth SDK should not own
- BLE scan/connect
AT+ADDTL / AT+FREQ / AT+RATE / AT+BCNID / AT+WORKMODE- UART vendor configuration such as
AT+RFSW / AT+OEM / AT+TXP - mesh business orchestration
- UI prompts and page state
Authentication semantics confirmed by current code
BLE
In the current XTalkBleClient.kt implementation:
- the code waits for BLE readiness
- sends
AT+CHALLENGE - parses and verifies the challenge response
- waits for DID
- then continues to write default parameters
So the current BLE path is still a mixed “authentication + initialization” implementation, not a pure Auth SDK.
UART
In the current XTalkMeshUiApp.kt implementation:
AT+CHALLENGEis sent first- then
AT+EFUSESN?is queried - then
AT+SN?is used as a fallback - and after that
AT+ADDTL=1andAT+RFSW=1,6,1,1continue running
So the current UART path is also a mixed “authentication + partial initialization” implementation.
Recommended extracted API
object DeviceAuthenticator {
fun authenticateBleAndReadDidExclusive(
timeoutMs: Long = 30_000L,
forceReauth: Boolean = false,
): Boolean
fun authenticateUartAndReadDid(
transport: AtCommandTransport,
challengeTimeoutMs: Long = 10_000L,
didTimeoutMs: Long = 6_000L,
): Result
}
Recommended result shape:
data class Result(
val ok: Boolean,
val deviceLongId: Long?,
val reason: String,
)
Recommended success boundary
The authentication layer should succeed only when:
AT+CHALLENGE=<hex>has been sent- the device returns a parseable challenge response
- signature verification succeeds
- DID read succeeds
The following should not be folded into auth success:
- frequency write success
RATE / BCN / ADDTL / WORKMODEsuccess- vendor hardware configuration success
Those belong to the Init SDK.
Recommended call order
BLE
XTalkBleClient.connect(...)DeviceAuthenticator.authenticateBleAndReadDidExclusive(...)DeviceInitializer.initializeBleWirelessDefaults(...)
UART
XTalkUartClient.open(...)DeviceAuthenticator.authenticateUartAndReadDid(...)DeviceInitializer.initializeUartDefaultsAfterAuth(...)DeviceInitializer.initializeUartVendorConfigAfterAuth(...)
Target module location
Recommended extraction target:
- Gradle module:
apps/android-ui/device-auth-sdk - package:
com.xtalk.mesh.sdk.auth
These do not exist in the repository yet.