Android Question BLE DataAvailable doesn't start and Setnotify error

Marco Maria Vilucchi

Active Member
Licensed User
Longtime User
Hi all,
i'm trying to implement BLE with an ESP32 chip.
I'm waiting that DataAvailable routine starts, but nothing
All characteristich are enabled for notify (see nRF screenshot)
when I try to enable notify in my app
B4X:
Try
    manager.SetNotify(S, C300_comando, True)
    Log("Notify ok "&C300_comando)
 Catch
    Log("SetNotify failed "&C300_comando)
 End Try
I always have SetNotify failed.
If I don't use try catch I have this error:
B4X:
starter_manager_connected (java line: 218)
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:322)
    at anywheresoftware.b4a.objects.BleManager2.SetNotify(BleManager2.java:311)
    at b4a.example.starter._manager_connected(starter.java:218)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
    at anywheresoftware.b4a.BA$2.run(BA.java:370)
    at android.os.Handler.handleCallback(Handler.java:790)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:7000)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)

In this thread: https://www.b4x.com/android/forum/threads/ble-setnotify.78403/
Erel says
Based on the error message the characteristic you specified doesn't support notifications.
But on nRF screenshot we can see NOTIFY
what mistake can there be?
 

Attachments

  • Screenshot_20190710-073332_nRF Connect.jpg
    Screenshot_20190710-073332_nRF Connect.jpg
    412.3 KB · Views: 158

f0raster0

Well-Known Member
Licensed User
Longtime User
dows it work using nRF connect?
liks a test, I remember that I actived notify in nRF connect then read the data with b4a app.
 
Upvote 0

Marco Maria Vilucchi

Active Member
Licensed User
Longtime User
using nrf connect i can connect device and see characteristics but I don't know how to do anything else.
But for you is better use notify or timers?
 
Upvote 0

emexes

Expert
Licensed User
With nRF Connect and a BLE pressure sensor here, the pressure reading (labelled "Unknown Characteristic") has two "icons" to read data: the single down-arrow will do a single reading (ie, equivalent to BLE2 library ReadData call) and the multiple down-arrows will enable notifications (ie, equivalent to BLE2 library SetNotify true call).

Your nRF Connect screen is not showing the multiple-down-arrows icons. I think that is a clue that perhaps the ESP32 notifications need something else to be done before they work. Perhaps they need to be given some data to send? Perhaps there are some other settings associated with notifications, like a minimum-time-between-changes or something? I do not know exactly, I am just making guesses that I hope will spur an "aha!" moment when you suddenly remember reading some cryptic note in the datasheet.

You could experiment manually with the ESP32 via RealTerm, get just one characteristic working with notifications and showing the multiple-down-arrows icon in nRF Connect. Once you have a set of ESP32 AT commands that reliably creates a notifiable characteristic, then you can duplicate those commands to create all 30 of your characteristics.

"Easy!"... (from afar, anyway)

:)

upload_2019-7-11_16-25-39.png
 
Upvote 0

f0raster0

Well-Known Member
Licensed User
Longtime User
using nrf connect i can connect device and see characteristics but I don't know how to do anything else.
But for you is better use notify or timers?
I'm not sure if it'll work, try to do that test:
start nRf connect, Connect to your module and click in the ↓↓↓ after that start your app and try to read.

also can you share more information.
 
Upvote 0
Top