bgiori
06/17/2021, 1:03 AMFrancis Mariano
07/14/2021, 4:02 PMnative-mt
version of Coroutines was removed. The version of Coroutines in the 0.7.0 kable is 1.5.0
The readme explains about configuration and I get a bit confusing in some points:
• Can the version of coroutine on androidMain be greater than kable coroutine version?
• Can version of coroutine (native-mt) on nativeMain be greater than kable coroutine version?
• Can the line 10 be removed?
sourceSets {
val commonMain by getting {
dependencies {
implementation("com.juul.kable:core:0.7.0") // here the version of Coroutine is 1.5.0
}
}
val androidMain by getting {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1") // here the version of Coroutine is greater // line 10
}
}
val nativeMain by creating {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1-native-mt") {
version {
strictly("1.5.1-native-mt")
}
}
}
}
}
}
Francis Mariano
07/15/2021, 5:17 PMscope
.peripheral should be canceled after receiving a disconnect state?Guy-Laurent Subri
07/19/2021, 2:04 PMFrancis Mariano
08/24/2021, 9:22 PMFrancis Mariano
09/23/2021, 6:09 PMFrancis Mariano
10/01/2021, 7:07 PMval iosTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget = when {
System.getenv("SDK_NAME")?.startsWith("iphoneos") == true -> ::iosArm64
else -> ::iosX64
}
iosTarget("ios") {
binaries {
framework {
baseName = "shared"
}
}
}
Francis Mariano
10/04/2021, 7:24 PMRuyman
10/19/2021, 9:12 AMtravis
10/25/2021, 6:24 AMEric Boggs
11/14/2021, 11:29 PMEric Boggs
11/23/2021, 5:18 PMEric Boggs
11/24/2021, 10:32 PMCilan
02/13/2022, 10:32 PMcom.juul.sensortag.features.sensor.SensorActivityIntent
Eric Boggs
03/13/2022, 10:38 PMFrancis Mariano
03/16/2022, 3:58 PMA
04/19/2022, 9:08 PMimport machine
import utime
led_onboard = machine.Pin(25, machine.Pin.OUT)
uart = machine.UART(0, baudrate=9600)
while True:
led_onboard.value(1)
utime.sleep(0.05)
led_onboard.value(0)
uart.write("test")
utime.sleep(0.05)
This is my program on my Android:
@OptIn(ExperimentalCoroutinesApi::class)
fun connect(device: Device) {
connectingCoroutine = viewModelScope.launch {
try {
val scanner = Scanner {
filters = null
logging {
engine = SystemLogEngine
level = Logging.Level.Data
format = Logging.Format.Multiline
}
}
scanner.advertisements.collect {
if (it.address == device.deviceUUID) {
val p = peripheral(it)
p.connect()
dataTransferState = DataTransferState.CONNECTED(device)
val services = p.services!!
val char = services
.first { service -> service.serviceUuid == uuidFrom("0000ffe0-0000-1000-8000-00805f9b34fb") }
.characteristics
.first { char -> char.characteristicUuid == uuidFrom("0000ffe1-0000-1000-8000-00805f9b34fb") }
Log.d("TAG", "serv=${char}")
dataTransferState = DataTransferState.WAITING
p.observe(char).catch { er -> Log.d("TAG", "$er") }
.collect { data ->
dataTransferState =
DataTransferState.TRANSFERING_FROM_DEVICE
Log.d("TAG", "data1=${data.contentToString()}")
}
dataTransferState = DataTransferState.NOT_CONNECTED
Log.d("TAG", "data1=Done")
}
}
} catch (e: Exception) {
e.printStackTrace()
}
}
connectingCoroutine?.invokeOnCompletion {
connectingCoroutine = null
}
}
Francis Mariano
05/24/2022, 1:28 PMFrancis Mariano
05/25/2022, 3:54 PMpublic val identifierString: String
get() = identifier.toString()
The following code works fine in debug build , but it crash in release build 😞 I dunno more what to do .
withTimeoutOrNull(3000) {
Scanner().advertisements.filter { it.identifierString == address}.collect{ adv ->
Log.debug { "scanner - $adv" }
}
Log.debug { "scanner - completed" }
}
The exception is Uncaught Kotlin exception: kotlin.RuntimeException: Unexpected receiver type: kotlin.String
Francis Mariano
05/26/2022, 3:35 PMkable
is a great use case.
private val job = SupervisorJob(parentCoroutineContext.job)
private val scope = CoroutineScope(parentCoroutineContext + job)
private val connectionScope = CoroutineScope(scope.coroutineContext + Job(scope.coroutineContext[Job]))
Here is what I understood about the code quoted above:
scope
inherits parent's context but with new job
. That job
is a SupervisorJob
so if any child of scope
fails or is cancelled it manage each one separately (if one child fail or cancel the others child continue working and the parent also is not cancelled)
job
inherits parent's job. If parent is cancelled all the child also is cancelled.
Here is what I did not understand:
connectionScope
inherits context and job of scope
. Are they the same????Francis Mariano
07/14/2022, 7:24 PMoverride suspend fun dataOad(characteristic: Characteristic) : Flow<ByteArray> {
return peripheral.value.observe(characteristic)
.onStart { Log.debug { "AudioProcessorImpl - dataOad - onStart" } }
.onEach { Log.debug { "AudioProcessorImpl - dataOad - onEach" } }
.onCompletion { Log.debug { "AudioProcessorImpl - dataOad - onCompletion" } }
}
If I cancel the scope that calls dataOad and create it again the observe works fine. But if the peripheral close the connection and I reconnect, the observer does not work anymore 😞
It is necessary close the application and reopen it.Francis Mariano
08/03/2022, 8:06 PMScanner { filters = listOf(Filter.Service(uuidFrom("00000123-0000-1000-8000-00805F9B34FB"))) }
return only Product A
but Scanner { filters = listOf(Filter.Service(uuidFrom("00000124-0000-1000-8000-00805F9B34FB"))) }
return Product A
and Product B
Why???? Why???? I don't know more what I can do.babel
08/24/2022, 8:52 PMbabel
08/24/2022, 8:55 PMbabel
08/24/2022, 8:57 PMDaniel Gruber
09/16/2022, 2:02 PMbenkuly
01/20/2023, 4:41 PMFrancis Mariano
02/23/2023, 2:44 PMFrancis Mariano
02/23/2023, 2:55 PMFlow<Bluetooth.Availability>
. I have the following use case:
all permissions is granted, bluetooth adapter is enabled but location service is disabled.
The flow emits LocationServicesDisabled which is correct, but after I enable the LocationService, the flow could emit a new state, like Available or Unavailable(reason = Off)
What do you think about that???Francis Mariano
02/23/2023, 2:55 PMFlow<Bluetooth.Availability>
. I have the following use case:
all permissions is granted, bluetooth adapter is enabled but location service is disabled.
The flow emits LocationServicesDisabled which is correct, but after I enable the LocationService, the flow could emit a new state, like Available or Unavailable(reason = Off)
What do you think about that???travis
02/23/2023, 3:18 PMFrancis Mariano
02/23/2023, 4:01 PMprivate val locationServiceEnabledFlow: Flow<Boolean> =
broadcastReceiverFlow(IntentFilter(LocationManager.PROVIDERS_CHANGED_ACTION))
.map { isLocationEnabled }
So we can combine both flows in onelocationServiceEnabledFlow
returns if the location is enabled or disabledtravis
02/23/2023, 4:16 PM