RadioInterfaceService

@Singleton
class RadioInterfaceService @Inject constructor(context: Application, dispatchers: CoroutineDispatchers, bluetoothRepository: BluetoothRepository, networkRepository: NetworkRepository, processLifecycle: Lifecycle, radioPrefs: RadioPrefs, interfaceFactory: InterfaceFactory) : Logging

Handles the bluetooth link with a mesh radio device. Does not cache any device state, just does bluetooth comms etc...

This service is not exposed outside of this process.

Note - this class intentionally dumb. It doesn't understand protobuf framing etc... It is designed to be simple so it can be stubbed out with a simulated version as needed.

Constructors

Link copied to clipboard
@Inject
constructor(context: Application, dispatchers: CoroutineDispatchers, bluetoothRepository: BluetoothRepository, networkRepository: NetworkRepository, processLifecycle: Lifecycle, radioPrefs: RadioPrefs, interfaceFactory: InterfaceFactory)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val meshActivity: SharedFlow<MeshActivity>
Link copied to clipboard
Link copied to clipboard
val receivedData: SharedFlow<ByteArray>
Link copied to clipboard
var serviceScope: CoroutineScope

We recreate this scope each time we stop an interface

Functions

Link copied to clipboard
fun connect()

If the service is not currently connected to the radio, try to connect now. At boot the radio interface service will not connect to a radio until this call is received.

Link copied to clipboard

Like getDeviceAddress, but filtered to return only devices we are currently bonded with

Link copied to clipboard

Return the device we are configured to use, or null for none device address strings are of the form:

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun keepAlive(now: Long = System.currentTimeMillis())
Link copied to clipboard
fun onConnect()
Link copied to clipboard
fun onDisconnect(isPermanent: Boolean)
Link copied to clipboard
Link copied to clipboard
fun setDeviceAddress(deviceAddr: String?): Boolean
Link copied to clipboard
fun toInterfaceAddress(interfaceId: InterfaceId, rest: String): String

Constructs a full radio address for the specific interface type.