Code Monkey home page Code Monkey logo

blue-falcon's Introduction

blue-falcon's People

Contributors

agroninja-com avatar alex009 avatar beniamin-cazacu avatar dizyaa avatar fd86trx avatar jamesjmtaylor avatar ndipatri avatar neelratanguria avatar onooma avatar ralfvdz avatar reedyuk avatar sarahdelcastillo avatar shelaranton avatar ynoyanov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blue-falcon's Issues

GATT connection not closing (ANDROID)

Hi, during more stress test of my app, i've discovered that Android device after some time causes peripheral to stop accept connections and stops from being visible in ble scan. This is not a case for iOS.
Steps to reproduce:

  1. Transport type LE
  2. Start LE scan if peripheral MAC found, connect
  3. If onConnected emited, stop LE scan
  4. acquire all characteristics (setup notifications etc)
  5. wait a little time
  6. disconnect
  7. wait a little time
  8. repeat from point 1

After few loops, you will not be able to find peripheral MAC. Reseting peripheral or Android BT restores connectivity, removing Initializing BlueFalcon again also solves this issue. As far as i can tell, the GATT connection is held and this causes to reach maximum available connections. Good peripheral to test is Raspberry PI 3b+ with simple code using bluez.

Increase mtu size

On Android by default mtu size is 20, we should allow for the api to handle multiple sizes

Characteristic value changed to ByteArrray but writeCharacteristic() is still using String

Hi all,

I am using latest version of library ("dev.bluefalcon:library:0.6.6"),

and even after this fix

method writeCharacteristic() still accepts only String argument.

To achieve bidirectional communication only using bytes it's neccessary to either change argument type of writeCharacteristic(value:String) to writeCharacteristic(value:ByteArray) or provide dedicated method for writing raw bytes.

Byte array values are not properly converted on iOS

Describe the bug
I want to use the blue-falcon library in a Kotlin Multiplatform app. I face the following situation: I need to convert a value to a byte array, in the order of Little Endian, and send it to a sensor.
In Android, I can do this using the following method: ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putFloat(value).array()

The issue with this is that on Android we can send the value as a byte array (which has a range of values between [-128, 127]). But on iOS, the byte equivalent is UInt8 (which has a range of values between [0, 255]).

Expected behavior
The value should be converted as in the native apps. To send the value 500 to the sensor, on Android I have the following array: [0, 0, -6, 67]. On iOS, I should have it like this: [0, 0, 250, 67].

Additional context

The problem is that I can only send arrays of bytes and strings in the writeCharacteristic() method. On the Android application, it works accordingly. On iOS, I think that the array is not converted properly and it breaks the functionality.

Have you perhaps faced this situation or do you have any idea how to solve this issue?
Maybe if we convert byte array to unsigned byte array but I think for that, we should add new functionality in the library

iOS App throws "kotlin.IllegalStateException: There is no event loop. Use runBlocking { ... } to start one."

Describe the bug
After running an XCode project created with KMM I encounter the error "kotlin.IllegalStateException: There is no event loop. Use runBlocking { ... } to start one."

To Reproduce
Steps to reproduce the behavior:

  1. Launch the compiled iOS application
  2. Grant Bluetooth permissions
  3. Observe an empty UITableView.

Expected behavior
The DevicesViewController should populate with scanned devices.

Stacktrace

Unknown error happened
kotlin.IllegalStateException: There is no event loop. Use runBlocking { ... } to start one.
    at 0   shared                              0x00000001044fa5f8 kfun:kotlin.Throwable#<init>(kotlin.String?){} + 96
    at 1   shared                              0x00000001044f38f4 kfun:kotlin.Exception#<init>(kotlin.String?){} + 92
    at 2   shared                              0x00000001044f3b64 kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 92
    at 3   shared                              0x00000001044f3fc0 kfun:kotlin.IllegalStateException#<init>(kotlin.String?){} + 92
    at 4   shared                              0x000000010457a5e0 kfun:kotlinx.coroutines.takeEventLoop#internal + 432
    at 5   shared                              0x000000010457a114 kfun:kotlinx.coroutines.DefaultExecutor#dispatch(kotlin.coroutines.CoroutineContext;kotlinx.coroutines.Runnable){} + 168
    at 6   shared                              0x000000010457b404 kfun:kotlinx.coroutines.NativeMainDispatcher.dispatch#internal + 236
    at 7   shared                              0x000000010456bd04 kfun:kotlinx.coroutines.internal#resumeCancellableWith__at__kotlin.coroutines.Continuation<0:0>(kotlin.Result<0:0>;kotlin.Function1<kotlin.Throwable,kotlin.Unit>?){0§<kotlin.Any?>} + 876
    at 8   shared                              0x0000000104578930 kfun:kotlinx.coroutines.intrinsics#startCoroutineCancellable__at__kotlin.coroutines.SuspendFunction1<0:0,0:1>(0:0;kotlin.coroutines.Continuation<0:1>;kotlin.Function1<kotlin.Throwable,kotlin.Unit>?){0§<kotlin.Any?>;1§<kotlin.Any?>} + 500
    at 9   shared                              0x0000000104578c00 kfun:kotlinx.coroutines.intrinsics#startCoroutineCancellable$default__at__kotlin.coroutines.SuspendFunction1<0:0,0:1>(0:0;kotlin.coroutines.Continuation<0:1>;kotlin.Function1<kotlin.Throwable,kotlin.Unit>?;kotlin.Int){0§<kotlin.Any?>;1§<kotlin.Any?>} + 264
    at 10  shared                              0x000000010454f984 kfun:kotlinx.coroutines.CoroutineStart#invoke(kotlin.coroutines.SuspendFunction1<0:0,0:1>;0:0;kotlin.coroutines.Continuation<0:1>){0§<kotlin.Any?>;1§<kotlin.Any?>} + 420
    at 11  shared                              0x0000000104543350 kfun:kotlinx.coroutines.AbstractCoroutine#start(kotlinx.coroutines.CoroutineStart;0:0;kotlin.coroutines.SuspendFunction1<0:0,1:0>){0§<kotlin.Any?>} + 148
    at 12  shared                              0x0000000104543524 kfun:kotlinx.coroutines#launch__at__kotlinx.coroutines.CoroutineScope(kotlin.coroutines.CoroutineContext;kotlinx.coroutines.CoroutineStart;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.CoroutineScope,kotlin.Unit>){}kotlinx.coroutines.Job + 436
    at 13  shared                              0x0000000104543794 kfun:kotlinx.coroutines#launch$default__at__kotlinx.coroutines.CoroutineScope(kotlin.coroutines.CoroutineContext?;kotlinx.coroutines.CoroutineStart?;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.CoroutineScope,kotlin.Unit>;kotlin.Int){}kotlinx.coroutines.Job + 436
    at 14  shared                              0x00000001045815b8 kfun:com.dxfactor.btsdk.presentation.viewmodels.devices.DevicesViewModel#scan(){} + 744
    at 15  shared                              0x00000001045f19d4 objc2kotlin.258 + 132
    at 16  OverlayIOS                          0x000000010419d06c $s10OverlayIOS21DevicesViewControllerC11viewDidLoadyyF + 612
    at 17  OverlayIOS                          0x000000010419d174 $s10OverlayIOS21DevicesViewControllerC11viewDidLoadyyFTo + 32
    at 18  UIKitCore                           0x00000001a47bee50 CC6E5AC7-8248-35F6-8B42-2E25C93DCF0A + 4623952
    at 19  UIKitCore                           0x00000001a47c3408 CC6E5AC7-8248-35F6-8B42-2E25C93DCF0A + 4641800
    at 20  UIKitCore                           0x00000001a470aa94 CC6E5AC7-8248-35F6-8B42-2E25C93DCF0A + 3885716
    at 21  UIKitCore                           0x00000001a470ad9c CC6E5AC7-8248-35F6-8B42-2E25C93DCF0A + 3886492
    at 22  UIKitCore                           0x00000001a470bc60 CC6E5AC7-8248-35F6-8B42-2E25C93DCF0A + 3890272
    at 23  UIKitCore                           0x00000001a470cfe0 CC6E5AC7-8248-35F6-8B42-2E25C93DCF0A + 3895264
    at 24  UIKitCore                           0x00000001a46efe78 CC6E5AC7-8248-35F6-8B42-2E25C93DCF0A + 3776120
    at 25  UIKitCore                           0x00000001a538e398 CC6E5AC7-8248-35F6-8B42-2E25C93DCF0A + 17007512
    at 26  QuartzCore                          0x00000001a5893df4 461501DD-204F-3516-9F5D-BDD0BA19FDA1 + 1400308
    at 27  QuartzCore                          0x00000001a589a398 461501DD-204F-3516-9F5D-BDD0BA19FDA1 + 1426328
    at 28  QuartzCore                          0x00000001a58a56e8 461501DD-204F-3516-9F5D-BDD0BA19FDA1 + 1472232
    at 29  QuartzCore                          0x00000001a57f0d7c 461501DD-204F-3516-9F5D-BDD0BA19FDA1 + 732540
State 5 is .poweredOn

Desktop (please complete the following information):

  • OS: MacOS 11.4

Smartphone (please complete the following information):

  • Device: iPhone X
  • OS: iOS 14.4.2

Method didDiscoverDevice returns Bluetooth MAC address instead of name

Steps to reproduce

In method didDiscoverDevice, bluetoothPeripherial.name contains instead of string value with device name only MAC address of that given device.

Expected
I/BlueFalcon: Discovered device : DeviceNameXY

Actual
I/BlueFalcon: Discovered device : 46:95:8F:86:74:A0

Additional info
Device - Samsung XCover Pro
OS version - Android 10
Library version - "dev.bluefalcon:library:0.7.2"

Anyone else experienced similar issue before?

Note:
This could be also an Android issue, because sometimes when I am trying to pair a new device in a place where are too many of advertising Bluetooth devices at the same time, even default system settings app couldn't read device names, and shows just MAC addresses.

Characteristic value string encoded with UTF-8 alters byte values

Currently the BT characteristic value is represented as a String, which is encoded from byte[] (Android) and NSData (iOS) with UTF-8 encoding. This is OK if the characteristic value contains byte values in the UTF-8 charset but causes problems otherwise (replaces unknown byte value with the Unicode replacement character U+FFFD "�").

Example:

Characteristic value byte[] sent by GATT server: 102,-120,51,64
Characteristic value string encoded from the byte[]: f�3@
Characteristic value byte[] decoded from the string: 102,-17,-65,-67,51,64

In this specific case our device is sending 4 byte packets with little endian ordering. The value -120 is invalid in UTF-8.

I think it would be better to use a ByteArray as the characteristic value type. Then everyone can decide in their client code if it will be converted to String or used as a ByteArray.

Would this cause any problems? Does using String as value have other reasons I'm not seeing?
If this works I'm more than happy to submit a PR.

Thanks!

Publish to cocoapods?

@shelaranton - Do you want me to setup bluefalcon so that you can consume via cocoapods? or are you using it as just a basic framework?
I can setup the code base so that it pushes to a different repo which could be consumed via cocoapods.

Interested in your point of view on this? If you dont, then it can wait.

Update to Kotlin 1.3.50

Please update library in maven repo to kotlin 1.3.50. Kotlin/Native require equals versions of libs with project's version

Adding to android project

I'm not sure how to add this library to my project without cloning the repo and manually adding it. Has this project been setup on package repository yet?

[ANDROID] OnConnected called when device is disconnected

This code listens to connection change event, it doesn't check what's new state, it always tries to "connect" to device and sends that information out. So if i'm connected and turn off external device, i get information that i'm connected :)
Didn't checked iOS (will do in upcoming weeks) yet.

override fun onConnectionStateChange(gatt: BluetoothGatt?, status: Int, newState: Int) {
            super.onConnectionStateChange(gatt, status, newState)
            log("onConnectionStateChange")
            gatt?.let { bluetoothGatt ->
                bluetoothGatt.device.let {
                    addGatt(bluetoothGatt)
                    bluetoothGatt.readRemoteRssi()
                    bluetoothGatt.discoverServices()
                    delegates.forEach {
                        it.didConnect(BluetoothPeripheral(bluetoothGatt.device))
                    }
                }
            }
        }

Android - Stop scanning does not work & potential fix

Hi,

I noticed that the stopScanning() implementation for Android does not actually stop scanning for devices.
However, adding the method call

bluetoothManager.adapter?.bluetoothLeScanner?.stopScan(mBluetoothScanCallBack)

to the Android implementation of the stopScanning method works.
Is there a reason why this call is not being made in that method? I have only tested this in my app, but wouldn't mind doing a pull request for it. Being new to Bluetooth, I'm not 100% sure what else I would need to test to make sure the potential fix is ok.

Android not calling close() method on BluetoothGatt when disconnecting

It is propably only android issue

When calling connect and disconnect device several times during one app session GattCallbacks are aggregated and I get multiplied callbacks about characteristic changed.

This happens because in BluetoothGatt.connect (it is called by BluetoothDevice.connectGatt in BlueFalcon.connect) callback is registered. But BlueFalcon.disconnect method calling only BluetoothGatt.disconnect and should also call BluetoothGatt.close (in close() method callback is unregistered).

Setup CI

Setup ci to build deploy to nexus repositories.

Windows 10 platform support

There is no a working solution to use Windows Bluetooth Api in Java/Kotlin desktop app. The only was is to switch to Linux or to C#
Is it possible to port windows to use in kotlin somehow?
Do you mind to schedule such feature?

Help with ios BluetoothUnknownException

First, thank you for upgrading library to latest Kotlin version.
Now i'm trying to use it with iphone.
I've empty project, added
Privacy - Bluetooth Always Usage Description
Privacy - Bluetooth Peripheral Usage Description
into Info.plist
and after running scan i've got
BluetoothUnknownException - Unknown error happened
Initialization of library is done like in sample: LibraryBlueFalcon(context: UIView(), serviceUUID: nil)
To be honest, i've no idea how to debug it or what is wrong with it :)

Update to Kotlin v1.4.21

Describe the bug
Library currently can't be used in the newest MPP projects using Kotlin 1.4.21. Specifically fails on the Kotlin/Native side.

To Reproduce
Attempt to build a project using Kotlin 1.4.21 and this library.

Expected behavior
Build succeeds

Actual behavior
Build fails with following error message:

Incompatible Kotlin/Native libraries
There is a third-party library attached to the project that was compiled with an older Kotlin/Native compiler and cant be read in IDE:
Gradle: dev.bluefalcon:library-iosx64:klib:0.7.0
Please edit Gradle buildfile(s) and specify library a version compatible with Kotlin/Native 1.4.21. Then re-import the project in IDE.

Library not working on Kotlin 1.4.x

Library only works on Kotlin 1.37.2 but not on version 1.4.x

Error
e: Could not find "/Users/xxxxxx/.gradle/caches/modules-2/files-2.1/dev.bluefalcon/library-iosx64/0.7.2/a144ef7bdbb2b135d54d02993a459c6f89e4e643/library.klib" in [/Users/xxxxxx/AndroidStudioProjects/kmm-demo, /Users/xxxxxx/.konan/klib, /Users/marc.forn/.konan/kotlin-native-prebuilt-macos-1.4.10/klib/common, /Users/xxxxxx/.konan/kotlin-native-prebuilt-macos-1.4.10/klib/platform/ios_x64].
Daemon vm is shutting down... The daemon has exited normally or was terminated in response to a user interrupt.

This will be fixed by pointing library to newer version of Kotlin.

Looking forward and update :)

[FEATURE REQUEST] Support for RaspberryPi

Well, i've been thinking about some future projects and one of them is related to Kotlin application on RPI. And i noticed that there is no good Bluetooth library for RPI with Java/Kotlin. What do you think about that?

iOS build issues

If i include blue falcon in my multiplatform project in section iosMain, adding

implementation("dev.bluefalcon:library-iosx64:0.5.4")
implementation("dev.bluefalcon:library-iosarm64:0.5.4")

Results in (while building from Xcode) error

* What went wrong:
Could not determine the dependencies of task ':knlib:linkDebugFrameworkIos'.
> Could not resolve all task dependencies for configuration ':knlib:iosCompileKlibraries'.
   > Could not resolve dev.bluefalcon:library-iosarm64:0.5.4.
     Required by:
         project :knlib
      > Unable to find a matching variant of dev.bluefalcon:library-iosarm64:0.5.4:
          - Variant 'iosArm64-api' capability dev.bluefalcon:library-iosarm64:0.5.4:
              - Incompatible attribute:
                  - Required org.jetbrains.kotlin.native.target 'ios_x64' and found incompatible value 'ios_arm64'.
              - Other attributes:
                  - Found org.gradle.status 'release' but wasn't required.
                  - Required org.gradle.usage 'kotlin-api' and found compatible value 'kotlin-api'.
                  - Required org.jetbrains.kotlin.platform.type 'native' and found compatible value 'native'.
          - Variant 'metadata-api' capability dev.bluefalcon:library-iosarm64:0.5.4:
              - Incompatible attribute:
                  - Required org.jetbrains.kotlin.platform.type 'native' and found incompatible value 'common'.
              - Other attributes:
                  - Found org.gradle.status 'release' but wasn't required.
                  - Required org.gradle.usage 'kotlin-api' and found compatible value 'kotlin-api'.
                  - Required org.jetbrains.kotlin.native.target 'ios_x64' but no value provided.

Providing just

implementation("dev.bluefalcon:library-iosx64:0.5.4") or implementation("dev.bluefalcon:library-ios:0.5.1”)

Results with:

> Task :knlib:cinteropFirebaseCoreIos FAILED
w: skipping /Users/lynx/.gradle/caches/modules-2/files-2.1/dev.bluefalcon/library-iosx64/0.5.4/b8e445b4bb7b3fa076afa9d68c3619fbb226f7fa/library.klib. The abi versions don't match. Expected '[17]', found '14'
w: The compiler versions don't match either. Expected '[]', found '1.3.50-release-11850'
e: Could not find "/Users/lynx/.gradle/caches/modules-2/files-2.1/dev.bluefalcon/library-iosx64/0.5.4/b8e445b4bb7b3fa076afa9d68c3619fbb226f7fa/library.klib" in [/Users/lynx/Workspaces/ios/KNProject/Pods, /Users/lynx/.konan/klib, /Users/lynx/.konan/kotlin-native-macos-1.3.61/klib/common, /Users/lynx/.konan/kotlin-native-macos-1.3.61/klib/platform/ios_x64].

FAILURE: Build failed with an exception.

Also there is no "library-ios:0.5.4" when building with jcenter, only 0.5.1 version.

My architecture is

  • Android app which contains k/n library which have dependencies on blue falcon for Android/iOS
  • iOS app which is pointing to my k/n library via cocoapods plugin

I'm using latest Xcode and latest Android Studio (stable). My kotlin version is 1.3.61

Cannot build KotlinMP example

Describe the bug
It is not possible to build the KotlinMP example in XCode.
Error message:

The Kotlin source set androidAndroidTestRelease was configured but not added to any Kotlin compilation. You can add a source set to a target's compilation by connecting it with the compilation's default source set using 'dependsOn'.
See https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#connecting-source-sets
w: Skipping "/Users/lneumann/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-core-iosarm64/1.3.8/ab1f410af27e33b328b0e7b3b75875953822e9eb/kotlinx-coroutines-core.klib" as it is a pre 1.4 library
e: Could not find "/Users/lneumann/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-core-iosarm64/1.3.8/ab1f410af27e33b328b0e7b3b75875953822e9eb/kotlinx-coroutines-core.klib" in [/Users/lneumann/Projekte/SteigtUm/blue-falcon/examples/KotlinMP/iosApp, /Users/lneumann/.konan/klib, /Users/lneumann/.konan/kotlin-native-prebuilt-macos-1.4.10/klib/common, /Users/lneumann/.konan/kotlin-native-prebuilt-macos-1.4.10/klib/platform/ios_arm64].
Daemon vm is shutting down... The daemon has exited normally or was terminated in response to a user interrupt.
----- End of the daemon log -----


FAILURE: Build failed with an exception.

* What went wrong:
Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.launcher.daemon.client.DaemonDisappearedException: Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)
	at org.gradle.launcher.daemon.client.DaemonClient.handleDaemonDisappearance(DaemonClient.java:250)
	at org.gradle.launcher.daemon.client.DaemonClient.monitorBuild(DaemonClient.java:223)
	at org.gradle.launcher.daemon.client.DaemonClient.executeBuild(DaemonClient.java:185)
	at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:148)
	at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:99)
	at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:56)
	at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:212)
	at org.gradle.launcher.cli.DefaultCommandLineActionFactory$ParseAndBuildAction.execute(DefaultCommandLineActionFactory.java:294)
	at org.gradle.launcher.cli.DefaultCommandLineActionFactory$ParseAndBuildAction.execute(DefaultCommandLineActionFactory.java:266)
	at org.gradle.launcher.cli.DebugLoggerWarningAction.execute(DebugLoggerWarningAction.java:82)
	at org.gradle.launcher.cli.DebugLoggerWarningAction.execute(DebugLoggerWarningAction.java:30)
	at org.gradle.launcher.cli.WelcomeMessageAction.execute(WelcomeMessageAction.java:92)
	at org.gradle.launcher.cli.WelcomeMessageAction.execute(WelcomeMessageAction.java:38)
	at org.gradle.launcher.cli.NativeServicesInitializingAction.execute(NativeServicesInitializingAction.java:44)
	at org.gradle.launcher.cli.NativeServicesInitializingAction.execute(NativeServicesInitializingAction.java:26)
	at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:41)
	at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:26)
	at org.gradle.launcher.cli.DefaultCommandLineActionFactory$WithLogging.execute(DefaultCommandLineActionFactory.java:259)
	at org.gradle.launcher.Main.doAction(Main.java:35)
	at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:50)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60)
	at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)
	at org.gradle.launcher.GradleMain.main(GradleMain.java:31)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:31)
	at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:108)
	at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:63)


* Get more help at https://help.gradle.org

> Task :app:compileKotlinIos
Command PhaseScriptExecution failed with a nonzero exit code

To Reproduce
Steps to reproduce the behavior:

  1. Clone repo
  2. Open XCode project inside KotlinMP exmaple
  3. Build

Expected behavior
Build completes without errors.

Desktop (please complete the following information):

  • OS: macOS 10.15.7

Smartphone (please complete the following information):

  • Device: iPad Mini
  • OS: iOS 13

Lack of TRANSPORT_LE for Android prevents from working with BLE UART connections

In Android when you use connectGatt you can pass TRANSPORT_LE as last parameter which might be required for some devices. Same thing can be done via changing characteristic descriptor parameter via gatt. Currently if i create gatt uart server on Raspberry Pi, i can connect to it and discover services/characteristics but read/writes are not working. This is not a case for iOS which works.

Describe the solution you'd like
Add parameter to enable TRANSPORT_LE or expose descriptor change for characteristic

Additional context
https://scribles.net/creating-ble-gatt-server-uart-service-on-raspberry-pi/ <-- sample code for raspberry pi 3
https://stackoverflow.com/questions/46273499/trouble-connecting-android-app-to-raspberry-pi-3-over-ble <-- some explanation

Non-null service UUID constructor parameter removes all scan results for iOS

Describe the bug
Non-null service UUID constructor parameter removes all scan results for iOS, even those that match.

To Reproduce
Steps to reproduce the behavior:

  1. Update the AppDelegate method in the iOS project to pass a service UUID string in the initialization of the BlueFalcon singleton.

Expected behavior
Only devices that match that service should be shown.

Desktop (please complete the following information):

  • OS: MacOS 11.4

Smartphone (please complete the following information):

  • Device: iPhone X
  • OS: iOS 14.4.2

Additional context
I recommend the following fix to iosMain/.../BlueFalcon.kt (I would create a branch and open a PR, but I don't have sufficient rights to do so):
Screen Shot 2021-06-05 at 6 12 54 PM

Characteristic indication

Would it be possible to add characteristic indication capability beside notification? Our specific usecase and GATT server device requires that we set indication on a characteristic.

Thanks in advance!

The characteristic value change delegate never fire

** Describe the bug **
I'm trying to run the recording event without response and listening to the characteristic value change, but the delegate never notify the characteristic value change, but on my peripheral, I can see that it received the recording event.

Reproduce
Steps to reproduce the behavior:

  1. Set to notify characteristic value change
  2. Write about an unanswered feature
  3. It should get notification of value changes, but it's not working properly.

Expected behavior
Receive notification about the change in the value of entered features.

** Smartphone (fill in the following information): **

  • Device: iPhone 12 Max Pro
  • OS: iOS 15

KMM example doesn't work on android 10+

Describe the bug
When running the KMM example on a device with android 10+, the scan fails and the following error appears in logcat:
BluetoothUtils: Permission denial: Need ACCESS_FINE_LOCATION permission to get scan results
For scanning BLE devices on android 10+, app needs to access ACCESS_FINE_LOCATION instead of ACCESS_COURSE_LOCATION as stated in the android developers blog.

To Reproduce
Steps to reproduce the behavior:

  1. Run KMM example on android 10+ device.
  2. Give the permission
  3. No device will found
  4. Take a look into logcat, you will see the permission error

Expected behavior
I expect to see the list of devices that available.

Smartphone (please complete the following information):

  • Device: Google pixel 4a
  • OS: Android 11

Additional context
Add any other context about the problem here.

Writing characteristic not working after reconnect.

Issue created with #45 fix.
After disconnect by calling disconnect method and reconnect again with device within same BlueFalcon instance, we won’t be able to write to gatt characteristic.

It is because when we close the gatt connection in disconnect method, the method onConnectionStateChange from BluetoothGattCallback will never be called and as a result removeGatt method won’t be called. Thus the item in the Gatt list is not removed. In such cases when trying to write a characteristic we take an old object which is not currently connected to the device.

In my opinion there are two solutions
add additional call of removeGatt in disconnect method
moving close() method from disconnect to onConnectionStateChange in BluetoothGattCallback so gatt will be closed after remove.

First solution should work properly but it is not that clean and neat.
Second is better but You need to check if moving close method won’t be an issue in disconnect scenarios and in that case You need to remove delegates.forEach { it.didDisconnect(bluetoothPeripheral) } from disconnect method to avoid calling it twice. This solution need to be tested very carefully.

changeMTU() method does not work as expected

When requesting a change of the MTU, the peripheral returned by the callback does not contain services and characteristics. Yet, if you keep a reference of previous characteristics, one cannot write or read on it anymore.

The problem seems to lie in the fact that the MTU change request should appear between the connection and the discovery of services. Yet BlueFalcon abstracts this layer by calling directly the discovery of services as soon as the peripheral is connected.

It could be interesting to add an MTU request within the connect method for instance.

[Android] Exposing autoConnect flag

Hi all,

In BlueFalcon Android actual class , method connectGatt is called with flag autoconnect set to false by default.

I understand this is for a reason - in iOS there's no such thing as autoConnect flag (autoConnect on iOS is implicit - correct me if I'm wrong).

But IMO there is still need to expose this autoConnect flag to the developer, so connection initiated by Android stack will be possible, when device comes into range.

So my sugestion would be - add optional parameter to connect method, e.g.

connect(bluetoothPeripheral: BluetoothPeripheral, autoConnect:Boolean = false).

On platforms that do not offer setting explicit autoConnect flag(such as iOS, MacOS), this argument would be ignored.

Any comments / different ideas how to approach this ?

Thanks

Unresolved reference - BlueFalcon

Hi all,

I am experiencing following issue:

Inside commonMain package Android Studio reports that import dev.bluefalcon.* cannot be resolved, but when I try to build & run project - the app builds and works as expected. Only problem is that all BlueFalcon related methods / imports are not resolved and code readability is bad, since all unresolved objects are highlited in red.

Anyone else experienced this issue ?

Which version of Kotlin/ BlueFalcon / Android Studio do you use ?

I'm using:
Android Studio 3.6.1
Kotlin version 1.3.71
BlueFalcon 0.7.2

Library metadata is missing for kotlin MP

Hi,

I'm trying to use the latest version of the library (0.7.0 and 0.7.1) and experience some problems with the dependencies in Kotlin multiplatform project.
I was able to reproduce the issue using the Kotlin-MP sample.

The issue

When using the latest version of the library in the kotlin-multiplatform project, the dependencies in commonMain can't be resolved.

Steps to reproduce

  1. Open the Kotlin-MP sample from this repository.
  2. Sync the project
  3. Open commonMain -> DevicesViewModel.kt
  4. Check that all dependencies resolved
  5. Change BlueFalcon version from 0.6.6 to 0.7.1 (in gradle.properties)
  6. Open commonMain -> DevicesViewModel.kt

Expected behavior

Dependencies remain resolved

Actual behavior

dev.bluefalcon can't be found.
Screenshot 2020-07-27 at 17 40 56

Notes

I have done some research around the issue and compared dependencies for both versions (0.6.6 which works and 0.7.0-0.7.1 which doesn't)

In 0.6.6 version you have a package library-metadata
Screenshot 2020-07-27 at 17 41 13
0.6.6

In 0.7.1 it disappered
Screenshot 2020-07-27 at 17 40 35
0.7.1

I guess it might be some issue with packaging the library, but not sure. Would be glad to share any additional info needed to help to solve the issue.

BluetoothGatt: android.os.DeadObjectException

Expected
For creating a connection, I am using method connect() with autoConnect flag set to true. This is setup once and it is expected that after setting up this "autoConnect", there is no other action required and Android OS BLE stack will notify the app, once remote device becomes available, and this call will never time out.

Actual
Sometimes, I can reproduce following behavior:
App is capable of connecting to device, but when app attempts to write bytes, it results in following exception: "BluetoothGatt: android.os.DeadObjectException"

To Reproduce
Steps to reproduce the behavior:

  1. call connect method with autoConnect flag set to true
  2. Wait a few hours
  3. After reconnection, writing to device will always result in "BluetoothGatt: android.os.DeadObjectException"

Note: Even restarting the BT module will not solve the issue. What will solve the issue is reinitialising BlueFalcon library.

Smartphone (please complete the following information):

  • Device: [Samsung Galaxy A5]
  • OS: [Android 7]
  • BlueFalcon version: [0.7.2]

iOS 13.5 Error while requested connection to device

Hi, after invoking "falcon.connect(device)" on iOS 13.5 i get this in didDiscoverServices call
2020-06-24 07:56:19.182475+0200 App[6530:4475232] [CoreBluetooth] API MISUSE: Discovering characteristic descriptors for peripheral <CBPeripheral: 0x2802d0960, identifier = 2BF80158-F03A-AEEE-0FD4-598964BCA682, name = RPIDevice, state = connected> while delegate is either nil or does not implement peripheral:didDiscoverDescriptorsForCharacteristic:error:

Add support for manufacturerSpecificData (Android) and kCBAdvDataManufacturerData (iOS)

I've been looking into the library for use in my companies BLE apps. It seems very simple to use and I look forward to being able to add this to our toolkit. One feature we use a lot is embedding information into the advertising data. Is it possible to add ScanRecord.manufacturerSpecificData (for Android) and kCBAdvDataManufacturerData (for iOS) into the BluetoothPeripheral class? I'm an Android developer and could help with that side.

Characteristic updates after device reconnection

Hi all,

I am currently experiencing following issue:

BlueFalcon version - 0.6.6
Device - Samsung Galaxy XCover 4, Android 9

Expected:

  1. Init delegate class for BLE device ✅
  2. Connect to peripherial (successful connection, characteristic discovery and call notifyCharacteristic) ✅
  3. writeCharacteristic & didCharacteristicValueChanged methods work as expected ✅
  4. Disconnect from peripherial ✅
  5. Connect to peripherial (successful connection, characteristic discovery and notifyCharacteristic call) ✅
  6. writeCharacteristic & didCharacteristicValueChanged methods work as expected ✅

Actual:

  1. Init delegate class for BLE device ✅
  2. Connect to peripherial (successful connection, characteristic discovery and call notifyCharacteristic) ✅
  3. writeCharacteristic & didCharacteristicValueChanged methods work as expected✅
  4. Disconnect from peripherial ✅
  5. Connect to peripherial (successful connection, characteristic discovery and notifyCharacteristic call) ✅
  6. writeCharacteristic & didCharacteristicValueChanged methods DO NOT work as expected: writeCharacteristic is called but has no effect, didCharacteristicValueChanged is not called at all - in conclusion no data are passed back & forth ❌

Looks like after device reconnection, there is some state held by BleAndroid / BlueFalcon library that prevents the app from sending/receiving updates. When I reinitialize BleAndroid object, all starts to work as expected again.

Anyone else have noticed problems after device reconnection ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.