https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
juul-libraries
  • b

    bgiori

    06/17/2021, 1:03 AM
    Hey folks. Long time see. 👋
    👋 4
    t
    n
    • 3
    • 4
  • f

    Francis Mariano

    07/14/2021, 4:02 PM
    Hello folks. In the 0.7.0 kable release the dependency on
    native-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")
                        }
                    }
                }
            }
        }
    }
    t
    • 2
    • 28
  • f

    Francis Mariano

    07/15/2021, 5:17 PM
    Hello again 😆 One question: the
    scope
    .peripheral should be canceled after receiving a disconnect state?
    👋 1
    t
    • 2
    • 5
  • g

    Guy-Laurent Subri

    07/19/2021, 2:04 PM
    Hi guys, I am making an android app to control a LED from my phone through BLE. This is my first time using Kable and I would appreciate having your opinion on the way I am using it. I have prepared a small gist where you can see my implementation: https://gist.github.com/glsubri/ac280b594d0c68b3dc1b3bcfdc7b7b7b. I also had a small question: is it normal that it takes something like a minute to connect to my Bluetooth device ? Am I missing something with kable or is it my micro-controller ? Thanks!
    t
    • 2
    • 3
  • f

    Francis Mariano

    08/24/2021, 9:22 PM
    Hey folks. I'm starting a new project with Kable. And I'm doing some tests to better use the library. I thought about making a bluetooth repository called BluetoothService and this repository is a singleton as it will be used by several screens of the app. This repository will have its own scope and this scope will be linked to the lifecycle of the main activity of the application. I'm at the beginning and would like your opinion. This BluetoothService is in common code and will be used by iOS and Android. Code on the thread.
    t
    • 2
    • 11
  • f

    Francis Mariano

    09/23/2021, 6:09 PM
    Hello folks> The minSdk to logging-android module is 24. Is it possible to remove this requirement?
    t
    c
    • 3
    • 3
  • f

    Francis Mariano

    10/01/2021, 7:07 PM
    I am here again 😀 Hope all you are fine!!!! I wonder why kable does not works with :
    val iosTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget = when {
        System.getenv("SDK_NAME")?.startsWith("iphoneos") == true -> ::iosArm64
        else -> ::iosX64
    }
    
    iosTarget("ios") {
        binaries {
            framework {
                baseName = "shared"
            }
        }
    }
    t
    • 2
    • 5
  • f

    Francis Mariano

    10/04/2021, 7:24 PM
    Hi everyone. Is there some sample of tullbox:logging on iOS platform?
    t
    c
    • 3
    • 16
  • r

    Ruyman

    10/19/2021, 9:12 AM
    hi guys! I can't find a way for getting notified (maybe in the connection state) when the OS request a pairing process with a bluetooth device, do you know if it's possible? I have a bluetooth module with encryption enabled and before to handle any communication, I need to do a pair with the device.
    t
    • 2
    • 5
  • t

    travis

    10/25/2021, 6:24 AM
    @gregorbg re: https://github.com/JuulLabs/kable/issues/179, let me know when you're available to try some debugging.
    g
    • 2
    • 3
  • e

    Eric Boggs

    11/14/2021, 11:29 PM
    I'm very new to bluetooth, so forgive my ignorance. So far, this library has been very helpful but I'm trying to understand peripheral state. So far, peripheral.connect seems to enable the firing of the OS pair dialog if a device hasn't been paired. However, if you never click to accept the pair, State.Connected will still be reported. So, it seems like State.Connected doesn't actually concern itself with the status of pairing. So, is there a common way that people check if a device has been paired? Sorry if I'm misunderstanding the basics.
    t
    r
    • 3
    • 13
  • e

    Eric Boggs

    11/23/2021, 5:18 PM
    Hey, another question. I'm following the sensortag example of creating a scanner for my android project. However, instead of collect, I want to use .first(). I noticed that when using .onCompletion, instead of the cause being null, it's actually an AbortFlowException: No more elements needed. It looks like there were a few tickets about this, but I'm unsure if this is expected behavior. I'm on 0.10.3
    t
    • 2
    • 7
  • e

    Eric Boggs

    11/24/2021, 10:32 PM
    Are there any plans to support writes of uByteArrays, per chance?
    t
    • 2
    • 4
  • c

    Cilan

    02/13/2022, 10:32 PM
    Hello! I believe a file is missing or this file is outdated from line referencing
    com.juul.sensortag.features.sensor.SensorActivityIntent
    t
    • 2
    • 5
  • e

    Eric Boggs

    03/13/2022, 10:38 PM
    This isn't specifically related to Kable but does anyone have any advice on automated testing of Bluetooth functionality in an Android app? Are there any common practices to test things like Bluetooth provisioning or other Bluetooth commands being sent to a device through an Android app?
    t
    • 2
    • 1
  • f

    Francis Mariano

    03/16/2022, 3:58 PM
    Hello everyone. Kable is compatible with M1 Mac processors??
    t
    • 2
    • 5
  • a

    A

    04/19/2022, 9:08 PM
    This is my program on my Raspberry pi pico:
    import 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
            }
        }
    t
    • 2
    • 2
  • f

    Francis Mariano

    05/24/2022, 1:28 PM
    hello. I hope you all are doing well. I am trying to understand why you used delegation in SensorTag class. Can you give me some insight about that???
    t
    • 2
    • 2
  • f

    Francis Mariano

    05/25/2022, 3:54 PM
    Hello everyone. I really need your help, please save me :) I added a new method in appleMain/Adversiment class
    public 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
    t
    • 2
    • 6
  • f

    Francis Mariano

    05/26/2022, 3:35 PM
    Sorry for more one question but I am trying understand more about coroutine and
    kable
    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????
    t
    • 2
    • 6
  • f

    Francis Mariano

    07/14/2022, 7:24 PM
    Hello everyone. How are you?? Please, can you give me some idea about the following trouble???
    override 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.
    t
    • 2
    • 6
  • f

    Francis Mariano

    08/03/2022, 8:06 PM
    Hello everyone. I have a question which is not related to kable. But I think you guys can give me any idea. I have two products with different UUID Service: Product A : 00000123-0000-1000-8000-00805F9B34FB Product B : 00000124-0000-1000-8000-00805F9B34FB
    Scanner { 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.
    t
    • 2
    • 5
  • b

    babel

    08/24/2022, 8:52 PM
    Trying to make a custom parceler for exercise, but wondering if this link to Parceler is actually broken? https://github.com/JuulLabs/exercise#parcelers
  • b

    babel

    08/24/2022, 8:55 PM
    maybe that was written before 1.4.20?
  • b

    babel

    08/24/2022, 8:57 PM
    I can PR the new link to https://developer.android.com/kotlin/parcelize if that would help?
    t
    • 2
    • 1
  • d

    Daniel Gruber

    09/16/2022, 2:02 PM
    Hey Everyone 🙂 We found your library kable on Github, is there a plan to support Java as well or is it for now iOS, macOS and Android only? So Java for Windows and Linux
    t
    • 2
    • 2
  • b

    benkuly

    01/20/2023, 4:41 PM
    It is really cool to have https://github.com/JuulLabs/indexeddb - but sometimes it is a bit too restrictive: https://github.com/JuulLabs/indexeddb/issues/90 Maybe it could make sense to expose the internal used IDB js-externals so one can workaround such issues?
    t
    • 2
    • 2
  • f

    Francis Mariano

    02/23/2023, 2:44 PM
    hello everyone, after a while I came back to work with android and specially with kable. I noted it has a lot of improvements. Congrats to all, it is incredible.
  • 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
Powered by Linen
Title
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???
Sorry, I saw comment in thread https://github.com/JuulLabs/kable/pull/335#issue-1257820206 "Unfortunately, could not find a way to monitor changes to location services status, so only the initial emission of status is provided."
t

travis

02/23/2023, 3:18 PM
Ya, an unfortunate limitation on Android. If you discover a way to monitor for changes (without continually checking on an interval), then let me know.
f

Francis Mariano

02/23/2023, 4:01 PM
@travis Look that
private val locationServiceEnabledFlow: Flow<Boolean> =
    broadcastReceiverFlow(IntentFilter(LocationManager.PROVIDERS_CHANGED_ACTION))
        .map { isLocationEnabled }
So we can combine both flows in one
locationServiceEnabledFlow
returns if the location is enabled or disabled
t

travis

02/23/2023, 4:16 PM
Nice. I'll look into it. Thanks!!
View count: 2