Imported from sub4ikgg/alertoid-connect (
core/ble/src/androidMain/AGENTS.md). Install upstream withnpx skills add sub4ikgg/alertoid-connect --skill androidMain. Copyright stays with the author.
core:ble · androidMain
Purpose
Android actual implementations of all BLE interfaces. Uses Android BLE APIs directly. All classes here fulfill expect declarations from commonMain.
Key Files
| File | Description |
|---|---|
BleContext.kt |
Holds Context reference for BLE operations; must be initialised before BLE singletons are used |
getBlePermissions.android.kt |
Returns BLUETOOTH_SCAN, BLUETOOTH_CONNECT, ACCESS_FINE_LOCATION (pre-12) |
isBlePermissionsGranted.android.kt |
Checks runtime BLE permission grants |
| scanner/ | |
AndroidAlertoidScanner.kt |
Scans for devices filtering by service UUID; uses coroutines + Android BLE scan callbacks |
provideScanner.android.kt |
actual fun provideScanner() — returns singleton AndroidAlertoidScanner |
| connector/ | |
AndroidAlertoidConnector.kt |
Manages GATT connection lifecycle; auto-reconnects up to 3× with 5 s timeout; emits AlertoidConnectorStatus |
provideAlertoidConnector.android.kt |
actual fun provideAlertoidConnector() |
| shared/ | |
SharedBle.kt |
Utility: awaitCharacteristicRead(uuid) — suspends using CompletableDeferred until GATT read callback fires |
| util/ | |
WriteCharacteristicCompat.kt |
Compat wrapper for GATT characteristic writes (API 33+ vs older API) |
| configurator/wifi/ | |
AndroidAlertoidWifiConfigurator.kt |
Writes SSID + passphrase to device via GATT characteristic write |
provideAlertoidWifiConfigurator.android.kt |
actual fun |
| configurator/url/ | |
AndroidAlertoidUrlConfigurator.kt |
Writes URL config to device via GATT write |
AndroidAlertoidUrlConfigurationReader.kt |
Reads current URL config via SharedBle.awaitCharacteristicRead() |
provideAlertoidUrlConfigurator.android.kt / provideAlertoidUrlConfigurationReader.android.kt |
actual fun factories |
For AI Agents
BleContextmust be initialised inMainActivity.onCreate()before any BLE singleton is usedAndroidAlertoidConnectormust beregister()-ed inonCreateandunregister()-ed inonDestroy- Never use
runBlockingon the main thread for GATT operations — usescope.launch+SharedBle.awaitCharacteristicRead() WriteCharacteristicCompathandles the API-level difference forwriteCharacteristic; always use it instead of calling the method directly