EspressifApp / EspBlufiForAndroid

EspBlufi is based on the BLUFI protocol, which connect with IOT devices for BLE data communication, realizes device config network, and custom data transmission and reception. EspBlufi is developed and maintained by Espressif Corp.
Other
322 stars 124 forks source link

java.lang.IllegalArgumentException: Paramater specified as non-null is null #23

Open bonesyblue opened 4 years ago

bonesyblue commented 4 years ago

Hi Espressif 👋🏼 I receive the following stack trace, when attempting to perform a connect with the BlufiClient class. In both cases, a new client instance is created and the callback onServicesDiscovered is invocated.

Stack trace:

D/AndroidRuntime(21812): Shutting down VM
E/AndroidRuntime(21812): FATAL EXCEPTION: main
E/AndroidRuntime(21812): Process: com.example.severin_smart_control, PID: 21812
E/AndroidRuntime(21812): java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter service
E/AndroidRuntime(21812):    at de.nuuk.severin.ebbq.severin_ebbq_plugin.SeverinEbbqPlugin$BlufiCallbackMain.onGattPrepared(Unknown Source:12)
E/AndroidRuntime(21812):    at blufi.espressif.BlufiClientImpl$InnerGattCallback.lambda$onServicesDiscovered$0$BlufiClientImpl$InnerGattCallback(BlufiClientImpl.java:1210)
E/AndroidRuntime(21812):    at blufi.espressif.-$$Lambda$BlufiClientImpl$InnerGattCallback$qPjo5mhKgJ_bnJKk3XqrSwssJ8o.run(Unknown Source:10)
E/AndroidRuntime(21812):    at android.os.Handler.handleCallback(Handler.java:873)
E/AndroidRuntime(21812):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(21812):    at android.os.Looper.loop(Looper.java:193)
E/AndroidRuntime(21812):    at android.app.ActivityThread.main(ActivityThread.java:6718)
E/AndroidRuntime(21812):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(21812):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/AndroidRuntime(21812):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

From what I understand reading the BlufiClientImpl.java file, getService is potentially returning null and this is not checked before being provided as an argument to onGattPrepared.

https://github.com/EspressifApp/EspBlufiForAndroid/blob/fc691bb549b83036d3e3fe9e93a0d0be8a28e2c4/blufilibrary/src/main/java/blufi/espressif/BlufiClientImpl.java#L1188

I would be very grateful for your feedback on this issue!