You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I created an iOS app peripheral and I am trying to create a java/kotlin cli app write data to the peripheral. The kotlin cli app can see the iOS app as a peripheral but whenever I call manager.getCharacteristicGovernor(url) the characteristic is never ready. Would you be able to look at my code and see if I am missing something?
import org.sputnikdev.bluetooth.manager.CharacteristicGovernor
import org.sputnikdev.bluetooth.manager.impl.BluetoothManagerBuilder
object BmSendTest {
private val serviceId = "56a7c54d-fd39-4efe-9e10-4d832fa64b6f".toUpperCase()
private val characteristic = "3348f88a-4972-4125-a6fb-6c70ef459e4d".toUpperCase()
private val SEND_VALUE = "43966666".encodeToByteArray()
@JvmStatic
private fun sendValue(governor: CharacteristicGovernor): Boolean {
println("sending: $SEND_VALUE")
return governor.write(SEND_VALUE)
}
@Throws(Exception::class)
@JvmStatic
fun main(args: Array<String>) {
println("Starting BLE Requests")
val manager = BluetoothManagerBuilder()
.withTinyBTransport(true)
.withBlueGigaTransport("^*.$")
.withIgnoreTransportInitErrors(true)
.withDiscovering(true)
.withRediscover(true)
.build()
manager.addDeviceDiscoveryListener { discoveredDevice ->
if (discoveredDevice.displayName == "iOS Peripheral") {
val d = manager.getDeviceGovernor(discoveredDevice.url)
d.connectionControl = true
println(
"=== Device: ${d.displayName}," +
" isOnline: ${d.isOnline}," +
" isAuthenticated: ${d.isAuthenticated}," +
" isBleEnabled: ${d.isBleEnabled}," +
" isBlocked: ${d.isBlocked}," +
" isConnected: ${d.isConnected}," +
" isServicesResolved: ${d.isServicesResolved}," +
" isReady:${d.isReady}"
)
val url = discoveredDevice.url.copyWith(serviceId, characteristic)
println(url)
// ISSUE: characteristic is never ready.
manager.getCharacteristicGovernor(url).whenReady(BmSendTest::sendValue)
}
}
manager.start(true)
}
}
I created an iOS app peripheral and I am trying to create a java/kotlin cli app write data to the peripheral. The kotlin cli app can see the iOS app as a peripheral but whenever I call
manager.getCharacteristicGovernor(url)
the characteristic is never ready. Would you be able to look at my code and see if I am missing something?Console output:
I'm running this on manjaro and eventually raspbian.
Changes I've tried to resolve the issue:
I was able to perform a test write to the peripheral using LightBlue https://punchthrough.com/lightblue/
Thanks for your help.
The text was updated successfully, but these errors were encountered: