Baffled by Bluetooth - Help
Re: Baffled by Bluetooth - Help
Here is a firmware.bin file for the T-Display with MicroPython v1.16-107-g9f71a11d3 and the st7789 driver compiled with esp-idf42.
Russ
Russ
Last edited by russ_h on Tue Jul 20, 2021 8:01 pm, edited 1 time in total.
-
- Posts: 27
- Joined: Sat Jul 03, 2021 5:10 pm
Re: Baffled by Bluetooth - Help
That's awesome! Many thanks.russ_h wrote: ↑Mon Jul 19, 2021 12:02 amHere is a firmware.bin file for the T-Display with MicroPython v1.16-107-g9f71a11d3 and the st7789 driver compiled with esp-idf42.
Russ
-
- Posts: 27
- Joined: Sat Jul 03, 2021 5:10 pm
Re: Baffled by Bluetooth - Help
I'm wondering whether the lack of data coming back is something to do with notifications having to be enabled. This is the nrfConnect Mobile log: which seems to point to nrfConnect doing that.
If that is the case then I don't understand why my ESP32 emulator (based on ble_simple_peripheral.py) doesn't require notifications to be explicitly enabled
Code: Select all
Unknown Service (0000ffe0-0000-1000-8000-00805f9b34fb)
- Unknown Characteristic [N R W] (0000ffe1-0000-1000-8000-00805f9b34fb)
Client Characteristic Configuration (0x2902)
Characteristic User Description (0x2901)
- Unknown Characteristic [R W] (0000ffee-0000-1000-8000-00805f9b34fb)
Characteristic User Description (0x2901)
Unknown Descriptor (fe3cf737-79ed-f667-fdff-bfd4eeb3b7ff)
Unknown Descriptor (fe3cf737-79ed-f667-fdff-bfd4eeb3b7ff)
Unknown Descriptor (fe3cf737-79ed-f667-fdff-bfd4eeb3b7ff)
Unknown Descriptor (fe3cf737-79ed-f667-fdff-bfd4eeb3b7ff)
Unknown Descriptor (fe3cf737-79ed-f667-fdff-bfd4eeb3b7ff)
Unknown Descriptor (fe3cf737-79ed-f667-fdff-bfd4eeb3b7ff)
Unknown Descriptor (fe3cf737-79ed-f667-fdff-bfd4eeb3b7ff)
Unknown Descriptor (fe3cf737-79ed-f667-fdff-bfd4eeb3b7ff)
Unknown Descriptor (fe3cf737-79ed-f667-fdff-bfd4eeb3b7ff)
D 17:38:45.456 gatt.setCharacteristicNotification(00002a05-0000-1000-8000-00805f9b34fb, true)
D 17:38:45.459 gatt.setCharacteristicNotification(0000ffe1-0000-1000-8000-00805f9b34fb, true)
I 17:38:45.474 Connection parameters updated (interval: 45.0ms, latency: 0, timeout: 5000ms)
V 17:38:59.284 Writing request to characteristic 0000ffe1-0000-1000-8000-00805f9b34fb
D 17:38:59.284 gatt.writeCharacteristic(0000ffe1-0000-1000-8000-00805f9b34fb, value=0x41545A0D)
I 17:38:59.425 Data written to 0000ffe1-0000-1000-8000-00805f9b34fb, value: (0x) 41-54-5A-0D
If that is the case then I don't understand why my ESP32 emulator (based on ble_simple_peripheral.py) doesn't require notifications to be explicitly enabled
-
- Posts: 1
- Joined: Sat Jul 06, 2019 3:10 am
Re: Baffled by Bluetooth - Help
I note link with firmware is no longer valid. I compiling and deploying for a TTGO T-Display per your GitHub directions but but see no graphics. I would love to try your precompile.
Re: Baffled by Bluetooth - Help
I'm not sure how that happened but the link is live again: https://penfold.owt.com/tdisplay/v1.16- ... rmware.bin
-
- Posts: 27
- Joined: Sat Jul 03, 2021 5:10 pm
Re: Baffled by Bluetooth - Help
russ_h wrote: ↑Mon Jul 19, 2021 12:02 amHere is a firmware.bin file for the T-Display with MicroPython v1.16-107-g9f71a11d3 and the st7789 driver compiled with esp-idf42.
Russ
A bit cheeky, I know, but is there any chance you could upgrade your M5 Core 2 firmware as well?russ_h wrote: ↑Tue Jul 20, 2021 8:02 pmI'm not sure how that happened but the link is live again: https://penfold.owt.com/tdisplay/v1.16- ... rmware.bin
Re: Baffled by Bluetooth - Help
No problem, just updated the firmware files in the repo to v1.16.dougconran wrote: ↑Tue Jul 20, 2021 9:23 pmA bit cheeky, I know, but is there any chance you could upgrade your M5 Core 2 firmware as well?
-
- Posts: 27
- Joined: Sat Jul 03, 2021 5:10 pm
Re: Baffled by Bluetooth - Help
That is truly fantastic, thank you so much. It means that I can try out @Jimmo's aioble stuff on the larger screen. I'm really grateful, thanks - Dougruss_h wrote: ↑Wed Jul 21, 2021 2:21 amNo problem, just updated the firmware files in the repo to v1.16.dougconran wrote: ↑Tue Jul 20, 2021 9:23 pmA bit cheeky, I know, but is there any chance you could upgrade your M5 Core 2 firmware as well?
-
- Posts: 27
- Joined: Sat Jul 03, 2021 5:10 pm
Re: Baffled by Bluetooth - Help
Sadly, I think that I'm going to have to admit defeat on this and revert to Arduino
I have added code (I think) to enable notificationsthis returnsHowever, I still get nothing back from the OBDII reader.
One further issue that I have is that whilst both 16 bit and 128 bit service uuids are recognised I get a 'Failed to find uart service.' error message if I use 128 bit uuids for the characteristics. I suspect that this is the root of the problem and that neither 16 bit nor 128 bit uuids are being recognised.
This is all very frustrating because MP ESP32 to MP ESP32 works fine and nrfConnect Mobile to OBDII works fine, it is just MP ESP32 to OBDII (and my lack of knowledge ) that seems to be the problem.
I have added code (I think) to enable notifications
Code: Select all
elif event == _IRQ_GATTC_CHARACTERISTIC_DONE:
# Characteristic query complete.
if self._tx_handle is not None and self._rx_handle is not None:
# We've finished connecting and discovering device, fire the connect callback.
self._ble.gattc_discover_descriptors(
self._conn_handle, self._start_handle, self._end_handle
)
if self._conn_callback:
self._conn_callback()
else:
print("Failed to find uart rx characteristic.")
elif event == _IRQ_GATTC_DESCRIPTOR_RESULT:
# Called for each descriptor found by gattc_discover_descriptors().
conn_handle, dsc_handle, uuid = data
if _UART_CCCD_UUID == uuid: # _UART_CCCD_UUID = 0x2902
print("Descr details : ",data)
self._ble.gattc_write(self._conn_handle, dsc_handle, b'\x01\x00',1)
elif event == _IRQ_GATTC_DESCRIPTOR_DONE:
# Called once service discovery is complete.
# Note: Status will be zero on success, implementation-specific value otherwise.
conn_handle, status = data
print("descr sts : ",data)
Code: Select all
Service done : 35
characteristic : UUID(0xffe1) - props : 26
characteristic : UUID(0xffee) - props : 10
Connected
Descr details : (0, 38, UUID(0x2902))
TX complete (0, 38, 0)
descr sts : (0, 0)
One further issue that I have is that whilst both 16 bit and 128 bit service uuids are recognised I get a 'Failed to find uart service.' error message if I use 128 bit uuids for the characteristics. I suspect that this is the root of the problem and that neither 16 bit nor 128 bit uuids are being recognised.
This is all very frustrating because MP ESP32 to MP ESP32 works fine and nrfConnect Mobile to OBDII works fine, it is just MP ESP32 to OBDII (and my lack of knowledge ) that seems to be the problem.
-
- Posts: 27
- Joined: Sat Jul 03, 2021 5:10 pm
Re: Baffled by Bluetooth - Help
After a lot of trial and error using both aioble and basic ubluetooth I have had sufficient success for my purposes.
The main problem I experienced (and still experience to an extent) is the processing of multiple notifications. Fundamentally, aioble is not fast enough and basic ble is - just. One particular OBD command gets 9 14 byte notifications returned at a speed that Android/iOS can handle but MP on an ESP32 struggles with. However I found that as long as the notification callback did nothing more than just add the returned data to a bytearray for processing once all notifications had been received (assumed after a set period of time) this was reasonably foolproof and, where there were dropped notifications, it was possible, because of the format of the data, to cover this.
As far as the problems I was having with characteristics, this was easily dealt with by just ignoring them and searching for name instead.
In conclusion I would say that aioble makes life a lot easier but at the cost (I think) of additional processing which may adversely affect the robustness of the app being developed.
The main problem I experienced (and still experience to an extent) is the processing of multiple notifications. Fundamentally, aioble is not fast enough and basic ble is - just. One particular OBD command gets 9 14 byte notifications returned at a speed that Android/iOS can handle but MP on an ESP32 struggles with. However I found that as long as the notification callback did nothing more than just add the returned data to a bytearray for processing once all notifications had been received (assumed after a set period of time) this was reasonably foolproof and, where there were dropped notifications, it was possible, because of the format of the data, to cover this.
As far as the problems I was having with characteristics, this was easily dealt with by just ignoring them and searching for name instead.
In conclusion I would say that aioble makes life a lot easier but at the cost (I think) of additional processing which may adversely affect the robustness of the app being developed.