I am trying to use the setnotify service on a connected arduino. I am able to make a connection, send and receive data but when I try to use setNotify I get the below error and the program crashes. I have the characteristic set up with notify enabled I am using the correct service and characteristic UUIDs. Any help is appreciated.
arduino:
BLECharacteristic firstChar(MY_UUID("0001"), BLERead | BLEWrite, 40 | BLENotify);
B4A Code:
Sub Manager_Connected (services As List)
Log("Connected")
connected = True
'ConnectedServices = services
Sleep(1000)
169 - manager.SetNotify(strBcSvcUUID,strBcChrUUID,True)
StateChanged
End Sub
error:
connecting
Discovering services.
Discovering services.
Connected
Connected
Error occurred on line: 169 (B4XLoadingIndicator)
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.bluetooth.BluetoothGattDescriptor.setValue(byte[])' on a null object reference
at anywheresoftware.b4a.objects.BleManager2.setNotify(BleManager2.java:343)
at anywheresoftware.b4a.objects.BleManager2.SetNotify(BleManager2.java:332)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:146)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:22)
at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1716)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8751)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)