https://kotlinlang.org logo
Join SlackCommunities
Powered by
# juul-libraries
  • f

    Francis Mariano

    02/23/2023, 2:55 PM
    I would like to discuss one thing related to
    Flow<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???
    t
    • 2
    • 5
  • c

    Cristian MG

    06/12/2023, 8:28 AM
    Hiii, I'm using kabble for ios and I'm receiving this error
  • c

    Cristian MG

    06/12/2023, 8:28 AM
    V/Kable/Observation: 39d79ee2-1ef7-0ac0-b8be-4c500c92cbf9 Suppressed failure: com.juul.kable.NotReadyException
    t
    • 2
    • 28
  • c

    Cristian MG

    06/12/2023, 8:29 AM
    Any idea?
  • c

    Cristian MG

    06/12/2023, 8:29 AM
    I updated the version to the last version 0.24
    t
    • 2
    • 1
  • c

    Cristian MG

    06/12/2023, 8:48 AM
    I think that the connection is not prepared to notify changes, but this has no sense because the connection is in fact properly connected
  • c

    Cristian MG

    07/13/2023, 12:02 PM
    Hi. I'm currently facing some issues when writing characteristics above 512 bytes. The device disconnects without any apparent reason, and I'm receiving a DeadObjectException. I have also tested this in the app of Nordic Semiconductors and encountered the same problem. While searching the internet, I came across this topic on Stack Overflow: https://stackoverflow.com/questions/73772158/bluetoothgattcharacteristic-write-crashes-with-android-13 It appears to discuss the inability to write characteristics above 512 bytes starting from Android 12. However, I couldn't find much more information on this. Can anyone help me understand the reason behind this problem? The provider of hardware tell me that the split must be done at the bluetooth socket with the mtu size, but I can't any library provide support to this. Thanksss
    t
    • 2
    • 10
  • n

    nikunjsakhrelia

    08/03/2023, 8:33 AM
    Whats the best way to transfer 2mb or more data using BLE, currently we facing issue with the transfer speed and we not sure is that a firmware on device issue or on android app.
    t
    • 2
    • 4
  • n

    nikunjsakhrelia

    08/03/2023, 8:34 AM
    if any one can help or have some tips or articles.
    s
    • 2
    • 1
  • c

    Cristian MG

    09/07/2023, 10:05 AM
    Hi @travis, I'm trying to test the bonding feature. I'm sorry, but the device is proprietary, and I don't have permission to share it with anyone. I'm attempting to test a device that only has some bonding capabilities. Perhaps I can emulate the device using the nrf connect client. I have successfully implemented the main feature, which is receiving and parsing the state properly. Inside the "AndroidPeripheral" class, you can find the "awaitBond" function, which is working correctly on my device. However, I need to test reading a characteristic that returns an "insufficient authentication" error, and that's the problem I'm currently facing.
  • c

    Cristian MG

    09/07/2023, 11:43 AM
    Ok It seems that the code is affected in Android 13 with this bug https://issuetracker.google.com/issues/245384106
  • c

    Cristian MG

    09/07/2023, 11:43 AM
    Android 12 seems to work fine
  • c

    Cristian MG

    09/07/2023, 11:45 AM
    I have a pixel in my home I will test in it because Pixel have the most updated builds, I will update with the result of tests
  • c

    Cristian MG

    09/07/2023, 11:51 AM
    Thats the response in Android 13 and call is stuck
    Copy code
    9C:9C:1F:CD:F3:02 read
    service: 4f4a4554-4520-4341-4c4f-520001000000
    characteristic: 4f4a4554-4520-4341-4c4f-520001000001
    onConnectionUpdated() - Device=9C9C1F_2 interval=30 latency=0 timeout=600 status=0
  • c

    Cristian MG

    09/07/2023, 11:58 AM
    The same in Android 12
  • c

    Cristian MG

    09/07/2023, 12:00 PM
    Copy code
    onScannerRegistered() - status=0 scannerId=7 mScannerId=0
    9C:9C:1F:CD:F3:02 onCharacteristicRead
    service: 4f4a4554-4520-4341-4c4f-520001000000
    characteristic: 4f4a4554-4520-4341-4c4f-520001000001
    status: GATT_SUCCESS(0)
    As you can see the function onCharacteristicRead is firing automatically after pairing and not fire with the error event
    Copy code
    GATT_AUTH_FAIL
    GATT_INSUFFICIENT_AUTHENTICATION
    GATT_INSUFFICIENT_ENCRYPTION
  • t

    travis

    09/07/2023, 5:14 PM
    Thanks for all the info @Cristian MG, it has been a while since I worked on that branch. Let me take some time to look over the code and see if I can make sense of what is going on. I’ll follow up soon.
  • c

    Cristian MG

    10/06/2023, 12:41 PM
    Hii, Any news about this topic? I created my own fork with the changes, because I need to deploy in production @travis
    t
    • 2
    • 4
  • j

    Jim Schultz

    10/26/2023, 6:28 PM
    Hello I am trying to get some help with the juul libs on Android, i have posted a discussion topic here: https://github.com/JuulLabs/kable/discussions/592 but i was also told this channel was a good resource for these types of questions. The gist of my question is how do i tell the BLE peripheral to stop notifying me of changes using kable?
    t
    • 2
    • 3
  • c

    Cristian MG

    02/14/2024, 7:46 AM
    Hello everyone. I have a query regarding the BLE Kabble library. Could someone provide guidance on how to extract the Scan Response data using this library? Thank you in advance!
    t
    • 2
    • 1
  • c

    Cristian MG

    02/14/2024, 7:47 AM
    @travis
  • i

    Ivan Harnastaeu

    05/02/2024, 8:32 AM
    Hey there! I need some help with the kable library (or maybe with Kotlin concepts). I'm an iOS developer and pretty new to KMP and Kotlin in general. There's a custom KMP library that uses kable for managing Bluetooth connections, and I'm struggling with exception handling on the iOS client side. I marked the output function of the custom library with
    Throws(Exception::class)
    . Here's how it looks:
    Copy code
    @Throws(Exception::class) 
        fun deviceFlow(): Flow<BLEDevice> {
                 return scanner.advertisements
                    .filter { !it.name.isNullOrBlank() }
                    .map {
                        BLEDevice(
                            name = it.name.orEmpty(),
                            advertisement = it
                        )
                    }
            } 
        }
    If I just throw an Exception in the body of this function, it works fine. But if I run it on a device without Bluetooth usage permission, the function
    awaitPoweredOn()
    throws an exception and crashes the app and does not propagate this exception further. And I would like to handle such exceptions on the client side. Thanks in advance!
    t
    • 2
    • 3
  • l

    Linus Närkling

    05/29/2024, 7:28 AM
    Heya! I'm trying to use JuulLabs/indexeddb in my Compose Multiplatform project with the Wasm target but having some trouble getting it to work. My main struggle is to find where to define the dependency as I think that is my issue, but I'm not sure. First of all, I've defined it in the
    libs.versions.toml
    file like so:
    Copy code
    [versions]
    indexeddb = "0.7.1"
    
    [libraries]
    indexeddb = { group = "com.juul.indexeddb", name = "core", version.ref = "indexeddb" }
    So first I'm unsure if the dependency should be defined in
    shared/build.gradle.kts
    or
    composeApp/build.gradle.kts
    . I think the latter, but I've tried both. For
    shared/build.gradle.kts
    , I've added this under `kotlin > sourceSets`:
    Copy code
    sourceSets {
        commonMain.dependencies {
            // put your Multiplatform dependencies here
        }
        
        wasmJsMain.dependencies {
            implementation(libs.indexeddb)
        }
    }
    Full file: https://gist.github.com/VapidLinus/efb65c7ed1311a3af066b6d8f0d763b4 And for
    composeApp/build.gradle.kts
    I've added this under `kotlin > sourceSets`:
    Copy code
    sourceSets {
        val desktopMain by getting
    
        androidMain.dependencies {
            ...
        }
        commonMain.dependencies {
            ...
        }
        desktopMain.dependencies {
            implementation(compose.desktop.currentOs)
        }
        wasmJsMain.dependencies {
            implementation(libs.indexeddb)
        }
    }
    Full file: https://gist.github.com/VapidLinus/0a4efe8588af8f7fbf2b8faf837522d4 Then I do a Gradle sync and expect the dependency should work, but it seems not. To test I have a file
    composeApp/src/wasmJsMain/kotlin/App.wasmJs.kt
    where I try to open a database:
    Copy code
    import kotlin.random.Random
    
    import com.juul.indexeddb.openDatabase
    
    actual fun databaseTest() {
        val database = openDatabase("test.db", 1)
    }
    But I get the errors:
    Copy code
    Unresolved reference: com :3
    Unresolved reference: openDatabase: 5
    If I look under "External Libraries" in the Project window in Android Studio I do not see
    com.juul.indexeddb
    listed so I think the dependency isn't getting added. I've also tried replacing
    implementation(libs.indexeddb)
    with
    implementation("com.juul.indexeddb:core:0.7.1")
    just in case it is a config issue, but that does not help either. Does anyone have any advice or know what I'm doing wrong to add indexeddb as a dependency to my wasm module? Much appreciated
    t
    • 2
    • 3
  • y

    ykws

    09/23/2024, 8:21 AM
    Is Kable's pronounce [keɪbl] ? https://github.com/JuulLabs/kable
    t
    • 2
    • 2
  • c

    Cristian MG

    10/02/2024, 7:00 AM
    Hello @travis, I am using the library for project production, and last time I created a fork to address the fact that this feature has not been merged yet. However, my fork is now out of date, and I don't like keeping forks that are not maintained. What are the possibilities of having this pull request merged? I understand that you don't have any devices to test this pull request. From my perspective, we have two possibilities to test this feature: 1. I can test the pull request myself because I have a device that requires bonding from the initial connection. Unfortunately, it's a proprietary device, so I can't share it with you for that reason. 2. We can develop a small BLE software for an Arduino and set up a test scenario using Arduino hardware. I believe this is the best option because it would give you a solid test environment for future use. I'd be happy to assist with the software; I have some experience with this kind of hardware testing. Thanks for the support, and best regards.
    t
    • 2
    • 1
  • b

    Brendan Weinstein

    12/22/2024, 11:02 PM
    Any reason more recent versions of kable haven't published to maven?
    t
    • 2
    • 9
  • s

    S K

    12/24/2024, 9:58 AM
    Hi, Can anyone guide me how to use this lib in ios swift classes for ble functionality
    t
    • 2
    • 1
  • g

    Guoqiang.Li

    01/27/2025, 2:37 PM
    Hi everyone In my code kable cann't scan BLE, I always get timeout cause, my code refer example sensortag, below show my code:
    Copy code
    fun start() {
        if (_status.value == BluetoothStatus.Scanning) return
        _status.value = BluetoothStatus.Scanning
        scanScope.launch {
            withTimeoutOrNull(ScanDurationMillts) {
                bluetoothScanner
                    .advertisements
                    .catch { cause -> _status.value = BluetoothStatus.Failed(cause.message?:"Unknown error") }
                    .onCompletion { cause ->
                        if(cause == null || cause is CancellationException) {
                            _status.value = BluetoothStatus.ScanStoped
                        }
                    }
                    .collect { advertisement ->
                        found = found.plus(advertisement)
                        _advertisements.value = found.toList()
                    }
            }
        }
    }
    val bluetoothScanner = Scanner {
        logging {
            level = Logging.Level.Events
        }
        filters {
            match {
                services = listOf(SERVICE_UUID)
    //            name = Filter.Name.Prefix("ED719M")
            }
    
        }
    }
    t
    • 2
    • 4
  • g

    Guoqiang.Li

    01/31/2025, 4:10 PM
    I'm having another issue where when I change scan filter=null I can get serviceUuid show like the screenshot, But actually the serviceUuid is "000000F4-0000-1000-8000-00805F9B34FB" than "000000FF-0000-1000-8000-00805F9B34FB".
    t
    • 2
    • 6
  • g

    Giorgi

    05/08/2025, 12:56 PM
    Hi. Huge thanks for kable library, works perfectly 📌 probably unrelated but not sure where else to ask. There is a ble device which iOS connects to it and they both communicate. Some events from ble device are important and should be sent to server. The issue is that when app goes to background then it has no internet at all. Did you guys had to send http requests to server when app is in background? There is not much docs about this. I was able to find some posts on stackoverflow but all of them talk on very high level, for example this https://stackoverflow.com/questions/63016680/sending-network-request-after-bluetooth-update-while-ios-app-is-in-background It seems to be possible but for 1 week I have almost no progress. Any ideas? or maybe you guys have some sample code?
    t
    • 2
    • 2