https://kotlinlang.org logo
#kotlin-native
Title
# kotlin-native
p

p4czyk

07/23/2022, 4:15 PM
Hey! 😊 Has anybody ever tried bluetooth socket programming (RFCOMM) with Kotlin Native? 🤔 I'm trying to implement this C-example (https://people.csail.mit.edu/albert/bluez-intro/x502.html) in Kotlin Native but it doesn't work. Everything is compiling fine and executing but the socket doesn't accept any connections. 🙁
t

Trevor Stone

07/23/2022, 4:34 PM
p

p4czyk

07/23/2022, 4:46 PM
Do you know how it would work with C-Interoperability? Because I want to to use the native libbluetooth.so. 😅
n

napperley

07/24/2022, 2:56 AM
Are you trying to do Bluetooth stuff with the Linux targets?
p

p4czyk

07/27/2022, 5:58 PM
Yes, I do. The compiler runs on x64 but the target is aarch64 (Raspberry Pi 4 Model B).
n

napperley

07/28/2022, 11:27 PM
The aarch64 CPU architecture corresponds to the linuxArm64 Kotlin Native target. Kable isn't usable since it is missing support for the Linux targets.
Looks like there is a security issue with opening the socket. Is some other process using the socket?
Silly question here. Is the program running on the Rpi or on a Linux PC (desktop using a BT dongle or laptop)?
Have you considered compiling the program for the linuxX64 target, and running it on a Linux laptop?
Do you realise that accessing any port below 1024 requires superuser privileges ( https://unix.stackexchange.com/questions/16564/why-are-the-first-1024-ports-restricted-to-the-root-user-only )?
p

p4czyk

07/29/2022, 7:08 PM
I don't think that another process is using the socket because when I run the C equivalent everything works fine on the Raspberry Pi.
n

napperley

07/30/2022, 10:51 PM
Below are some questions to get a better picture on what is occurring: 1. What is being outputted to the console? 2. Are there any errors showing up? 3. What happens when you run the program as root? 4. Have you tried implementing a different BT server example? 5. Does the program work with the linuxX64 target?
7 Views