Skip to main content

Android SDK 1.0.0 API Reference

SDK Version: 1.0.0
Platform: Android

This is the signature index and behavior card set for customer APIs. Tables specify purpose, preconditions, defaults, results/errors, thread, cleanup, and an example link. Diagnostic facilities are not customer APIs.

Common rules

  • timeoutMs values are non-negative milliseconds. Run GATT/AT/RF/device-waiting operations off the main thread.
  • A Boolean means only the success defined by that call; asynchronous completion may still arrive through callbacks.
  • null means no valid value, failure, timeout, or unsupported operation unless stated otherwise.
  • AT, Auth, Init, file operations, and mode changes share the radio and must not overlap.
  • Remove every listener with the same instance passed to its add method.

XTalkBleClient: initialization, state, and connection

Full signaturePurpose/preconditionReturn/error/thread/lifecycleExample
setApplicationContext(context: Context?)Retain application context before initUnit; null clearsSetup
ensureInitialized(): InitResultIdempotent core/callback initContinue only for INIT_OKSetup
addListener(listener: DeviceStateCallback) / removeListener(listener)Scan/connection stateMain-thread fanout; same-instance pairScan
startScan(timeoutMs: Int = 5000, minRssiDbm: Int = -100, serviceUuids: List<String> = emptyList()): ScanStartResultPermissions/Bluetooth/InitRequest result; devices via callback; pair stopScan
stopScan(): UnitCancel scanIdempotentScan
connect(device: XTalkDevice, timeoutMs: Int = 5000, maxReconnectAttempts: Int? = null): ConnectResultSelected device; backgroundRequest outcome, not CONNECTED confirmationConnect
awaitConnected(macAddress: String? = null, timeoutMs: Long = 8000): BooleanBackgroundFalse on error/disconnect/deadline; waiter auto-removedWorkflow
ensureGattServicesOpened(forceReset: Boolean = false): UnitCONNECTED; backgroundReopen GATT services; reset bindings when trueLifecycle
awaitBleReady(timeoutMs: Long = 8000): BooleanCONNECTED; backgroundStable GATT/AT readinessConnect
disconnect(sendRemoteCommand: Boolean = true): DisconnectResultEnd session; backgroundClears cache/ready/AT; use false for broken linkCleanup
awaitDisconnected(timeoutMs: Long = 6000): BooleanBackgroundTrue only on DISCONNECTEDLifecycle
stopAutoReconnect(reason: String): BooleanStop SDK reconnectFalse if unavailable; does not replace disconnectLifecycle
forceResetDisconnected(reason: String, clearLastRequestedDevice: Boolean = true): UnitAdvanced inconsistent-state recoveryClears local tracking/ready/ATLifecycle
getConnectedDevice(): XTalkDevice?Current devicenull when disconnectedState
getConnectionState(): DeviceEventStateState snapshotImmediateState
hasActiveBleLink(): BooleanPhysical CONNECTED gateDoes not imply Auth/InitState
getDeviceLongId(): Long? / awaitDeviceLongId(timeoutMs: Long = 3000): Long?Authenticated structured DIDWait form is background; null on disconnect/deadlineAuth
isWirelessReady(): Boolean / awaitWirelessReady(timeoutMs: Long = 4000): BooleanInit stateWait form is backgroundInit
isReadyForSend(): BooleanBusiness gateCONNECTED + wireless readyWorkflow
markWirelessInitRequired(reason: String, resetAtMode: Boolean = true): UnitInvalidate stale Auth/InitClears readyAuth
setWirelessInitReady(ready: Boolean, reason: String): UnitAuth/Init integration stateBusiness code must not forge trueInit

XTalkBleClient: AT, radio, advanced state

Full signatureContract/result/threadExample
isAtXorEnabled(): BooleanCurrent connection encodingEncoding
setAtXorEnabledForConnection(enabled: Boolean, reason: String): UnitAdvanced Auth adapter; resets on connect/disconnectEncoding
chooseAtXorModeByFreqProbeResult(timeoutMs: Long = 1500, log: Boolean = true): AtXorModeProbeResult?Background probe; null on unavailable/deadlineEncoding
withWirelessOpLock(block: () -> T): TBackground serialization; propagates block exception; no recursive waitingRaw AT
runAtCommand(command: String, timeoutMs: Long = 3000, log: Boolean = true, errorPolicy: BleAtErrorPolicy = FAIL_FAST, stopWhen: ((List<String>) -> Boolean)? = null, drainResponseTailAfterStop: Boolean = false): List<String>Exclusive/background; link/service/send/error/deadline may throwRaw AT
sendAtCommand(command: String): SendResultSubmission result, no linesRaw AT
sendAtCommandNoWait(command: String): BooleanSubmission onlyRaw AT
sendEncryptedAt(bytes: ByteArray): BooleanAdvanced pre-encoded bytes; submission onlyRaw AT
setPassthroughListener(listener: ((ByteArray) -> Unit)?): UnitAdvanced single owner; null releases; conflicts with AT transactionsRaw AT
restoreTextPttDefaults(defaultRateMode: Int = 7, defaultAddtl: Int = 1, defaultWorkMode: Int = 21): BooleanBackground; true only if all AT commands succeedRadio
setRateMode(rateMode: Int): BooleanCoerces 0..255; backgroundRadio
setChannelFrequency(freqHz: Long, timeoutMs: Long = 3000): BooleanCallback-based channel config; backgroundRadio
setFrequencyHz(freqHz: Long, timeoutMs: Long = 3000): BooleanAT sets four slots; backgroundRadio
setRealtimeWorkModeOverride(workMode: Int?): Unit / getRealtimeWorkModeOverride(): Int?Session override; null clearsVoice

AtXorModeProbeResult has useXor and normalFreqAccepted. BleAtErrorPolicy is FAIL_FAST or COLLECT_UNTIL_COMPLETE.

XTalkBleClient: business, media, and device

Full signatureReturn/lifecycleExample
sendBinaryFrame(data: ByteArray): SendResultNormal binary; backgroundBinary
sendRfPayloadAndWaitSendFinish(rawPayload: ByteArray, timeoutMs: Long): BooleanCompletion wait; false on error/deadlineRF
sendRfPayloadNoWait(rawPayload: ByteArray): BooleanRealtime submission; caller rate-limitsRF
sendText(text: String): SendResultReceive through text listenerText
sendFile(fileBytes: ByteArray): SendResultCompletion through FileSend callbackFile
cancelFileSend(): SendResult / cancelFileReceive(): SendResultCancellation requestFile
startPttVoiceCapture(enablePcmCallback: Boolean = true): CaptureStartResult / stopPttVoiceCapture(): CaptureStopResultRecording permission; lifecycle pairVoice
startRealtimeVoiceCapture(peopleCount: Int = 2, mute: Int = 0): CaptureStartResult / stopRealtimeVoiceCapture(): CaptureStopResultRecording permission; lifecycle pairVoice
stopVoiceCaptureLocal(): CaptureStopResultLocal abnormal cleanupVoice
startVoicePlayback(pcm: ByteArray): PlaybackStartResult / stopVoicePlayback(): PlaybackStopResultDelivered PCM format; lifecycle pairPlayback
transcodeImage(imageBytes: ByteArray, targetTier: ImageTargetTier, inputFormat: ImageInputFormat? = null): ImageTranscodeResultOffline; large input off-mainImage
setCryptoKey16(key16: ByteArray): BooleanExactly 16 bytesKey
getHardwareVersion(timeoutMs: Long = 2000): String?Background/cache/null failureQueries
getFirmwareVersion(timeoutMs: Long = 2000): String?SameQueries
getBatteryLevel(timeoutMs: Long = 4000): Int?Background/cache/null failure/unsupportedQueries

Listener pairs

Add/removeCallback/thread/data rule
addDataListener / removeDataListenerbytes/len/SNR/RSSI; I/O thread; consume only len
addDeviceManageListener / removeDeviceManageListenertype/value; main-thread fanout
addTextListener / removeTextListenersource/text/metrics; main-thread fanout
addVoiceListener / removeVoiceListenerremote PCM; realtime thread
addVoiceCaptureListener / removeVoiceCaptureListenerlocal PCM; main-thread fanout
addFileSendListener / removeFileSendListenersend progress; main-thread fanout
addFileReceiveListener / removeFileReceiveListenerreceive progress/final bytes; main-thread fanout

Top-level BLE utilities

requiredBluetoothPermissions, requiredStartupPermissions, hasBluetoothPermissions, hasStartupPermissions, sanitizeBleDeviceName, isSupportedBleDeviceName, isSupportedBleDevice, bleDeviceDisplayName, mergeBleDeviceIdentity, and XTALK_SCAN_UUID_5632G are fully described in Setup and BLE Connection.

Other modules

Errors and FAQ