mirror of
https://github.com/aljazceru/Android-nRF-Toolbox.git
synced 2025-12-22 00:44:26 +01:00
Change logging for nRF Toolbox
This commit is contained in:
@@ -11,6 +11,7 @@ internal const val LOG_TAG = "nRF Toolbox"
|
|||||||
|
|
||||||
class ToolboxLogger(
|
class ToolboxLogger(
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
|
private val profile: String,
|
||||||
private val key: String,
|
private val key: String,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ class ToolboxLogger(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getLogger(): LogSession? {
|
private fun getLogger(): LogSession? {
|
||||||
logSession = logSession ?: Logger.newSession(context, key, LOG_TAG)
|
logSession = logSession ?: Logger.newSession(context, profile, key, LOG_TAG)
|
||||||
return logSession
|
return logSession
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ internal class BPSRepository @Inject constructor(
|
|||||||
|
|
||||||
fun downloadData(device: BluetoothDevice): Flow<BleManagerResult<BPSData>> = callbackFlow {
|
fun downloadData(device: BluetoothDevice): Flow<BleManagerResult<BPSData>> = callbackFlow {
|
||||||
val scope = this
|
val scope = this
|
||||||
val manager = BPSManager(context, scope, ToolboxLogger(context, "BPS"))
|
val manager = BPSManager(context, scope, ToolboxLogger(context, "BPS", device.address))
|
||||||
|
|
||||||
manager.dataHolder.status.onEach {
|
manager.dataHolder.status.onEach {
|
||||||
trySend(it)
|
trySend(it)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class CGMRepository @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun start(device: BluetoothDevice, scope: CoroutineScope) {
|
fun start(device: BluetoothDevice, scope: CoroutineScope) {
|
||||||
val manager = CGMManager(context, scope, ToolboxLogger(context, "CGMS"))
|
val manager = CGMManager(context, scope, ToolboxLogger(context, "CGMS", device.address))
|
||||||
this.manager = manager
|
this.manager = manager
|
||||||
|
|
||||||
manager.dataHolder.status.onEach {
|
manager.dataHolder.status.onEach {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class CSCRepository @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun start(device: BluetoothDevice, scope: CoroutineScope) {
|
fun start(device: BluetoothDevice, scope: CoroutineScope) {
|
||||||
val manager = CSCManager(context, scope, ToolboxLogger(context, "CSC"))
|
val manager = CSCManager(context, scope, ToolboxLogger(context, "CSC", device.address))
|
||||||
this.manager = manager
|
this.manager = manager
|
||||||
|
|
||||||
manager.dataHolder.status.onEach {
|
manager.dataHolder.status.onEach {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ internal class GLSRepository @Inject constructor(
|
|||||||
|
|
||||||
fun downloadData(device: BluetoothDevice): Flow<BleManagerResult<GLSData>> = callbackFlow {
|
fun downloadData(device: BluetoothDevice): Flow<BleManagerResult<GLSData>> = callbackFlow {
|
||||||
val scope = this
|
val scope = this
|
||||||
val managerInstance = manager ?: GLSManager(context, scope, ToolboxLogger(context, "GLS")).apply {
|
val managerInstance = manager ?: GLSManager(context, scope, ToolboxLogger(context, "GLS", device.address)).apply {
|
||||||
try {
|
try {
|
||||||
connect(device)
|
connect(device)
|
||||||
.useAutoConnect(false)
|
.useAutoConnect(false)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class HRSRepository @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun start(device: BluetoothDevice, scope: CoroutineScope) {
|
fun start(device: BluetoothDevice, scope: CoroutineScope) {
|
||||||
val manager = HRSManager(context, scope, ToolboxLogger(context, "HRS"))
|
val manager = HRSManager(context, scope, ToolboxLogger(context, "HRS", device.address))
|
||||||
this.manager = manager
|
this.manager = manager
|
||||||
|
|
||||||
manager.dataHolder.status.onEach {
|
manager.dataHolder.status.onEach {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class HTSRepository @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun start(device: BluetoothDevice, scope: CoroutineScope) {
|
fun start(device: BluetoothDevice, scope: CoroutineScope) {
|
||||||
val manager = HTSManager(context, scope, ToolboxLogger(context, "HTS"))
|
val manager = HTSManager(context, scope, ToolboxLogger(context, "HTS", device.address))
|
||||||
this.manager = manager
|
this.manager = manager
|
||||||
|
|
||||||
manager.dataHolder.status.onEach {
|
manager.dataHolder.status.onEach {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class PRXRepository @Inject internal constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun start(device: BluetoothDevice, scope: CoroutineScope) {
|
fun start(device: BluetoothDevice, scope: CoroutineScope) {
|
||||||
val manager = PRXManager(context, scope, ToolboxLogger(context, "PRX"))
|
val manager = PRXManager(context, scope, ToolboxLogger(context, "PRX", device.address))
|
||||||
this.manager = manager
|
this.manager = manager
|
||||||
manager.useServer(proximityServerManager)
|
manager.useServer(proximityServerManager)
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class RSCSRepository @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun start(device: BluetoothDevice, scope: CoroutineScope) {
|
fun start(device: BluetoothDevice, scope: CoroutineScope) {
|
||||||
val manager = RSCSManager(context, scope, ToolboxLogger(context, "RSCS"))
|
val manager = RSCSManager(context, scope, ToolboxLogger(context, "RSCS", device.address))
|
||||||
this.manager = manager
|
this.manager = manager
|
||||||
|
|
||||||
manager.dataHolder.status.onEach {
|
manager.dataHolder.status.onEach {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class UARTRepository @Inject internal constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun start(device: BluetoothDevice, scope: CoroutineScope) {
|
fun start(device: BluetoothDevice, scope: CoroutineScope) {
|
||||||
val manager = UARTManager(context, scope, ToolboxLogger(context, "UART"))
|
val manager = UARTManager(context, scope, ToolboxLogger(context, "UART", device.address))
|
||||||
this.manager = manager
|
this.manager = manager
|
||||||
|
|
||||||
manager.dataHolder.status.onEach {
|
manager.dataHolder.status.onEach {
|
||||||
|
|||||||
Reference in New Issue
Block a user