Bug in NRF52832 BLE Driver


#1

Hi there, i found what seems to be a bug in the NRF52832 BLE driver.
Could someone from the Zerynth support please leave a comment on how long it could take to review this and to create an update? I really need this for work project ASAP.

Here is the issue:
When creating a characteristics the size of the characteristic value that is defined here:

class Characteristic(uuid, permission, size, descriptor, type=NUMBER)

doesn’t change the size of the payload that is transmitted for the NRF52, while it does when using the ESP32.
Also adding multiple characteristics to a service doesn’t seem to work on the NRF52 while it is working on the ESP32.

I did verify this issue by running the same code on both ESP32 and NRF52 (only changing the driver) and checking the results with the NRF connect app on Android.

Here is the code for the NRF

from nordic.nrf52_ble import nrf52_ble as bledrv
from wireless import ble

# initialize NRF52 driver
bledrv.init()

# Set GAP name
ble.gap("NRF52BLE")

# Indoor positioning Service
s = ble.Service(0x1821)

# Create a GATT Characteristic: Analog
c1 = ble.Characteristic( 0x2A58,ble.NOTIFY | ble.READ, 16,"Analog", ble.NUMBER)
s.add_characteristic(c1)

# Create a GATT Characteristic: String 
c2 = ble.Characteristic( 0x2A3D,ble.NOTIFY | ble.READ, 16,"String", ble.BYTES)
s.add_characteristic(c2)


# Add the Service to ble instance
ble.add_service(s)


# Start the BLE stack
ble.start()

# Begin advertising
ble.start_advertising()


while True:
    c1.set_value(9999)
    sleep(100)          

and this is the code for the ESP32

from espressif.esp32ble import esp32ble as bledrv
from wireless import ble

# initialize ESP32 BLE driver
bledrv.init()

# Set GAP name
ble.gap("ESP32BLE")

# Indoor positioning Service
s = ble.Service(0x1821)

# Create and add GATT Characteristic: Analog 
c1 = ble.Characteristic( 0x2A58,ble.NOTIFY | ble.READ, 16,"Analog", ble.NUMBER)
s.add_characteristic(c1)

# Create and add GATT Characteristic: String 
c2 = ble.Characteristic( 0x2A3D,ble.NOTIFY | ble.READ, 16,"String", ble.BYTES)
s.add_characteristic(c2)


# Add the Service
ble.add_service(s)


# Start the BLE stack
ble.start()

# Begin advertising
ble.start_advertising()


while True:
    c1.set_value(9999)
    sleep(100)     

I am creating two services one for Analog as that one has an unsigned 16 bit integer and another one for a string, i am only updating the characteristics for the analog as the second characteristics is only there to show the issue with the NRF52 not creating a second characteristics. On the screenshots from the NRF connect app you seen that both characteristics only appear for theESP32 but not for the NRF52. You can also see that the ESP32 creates a 16byte value output for the Analog characteristic while the NRF52 only creates a 1byte value, while both code bases are the same and for both there should be a 16byte value

Screenshot_2019-01-29-16-46-12-45 Screenshot_2019-01-29-16-46-36-06


#2

Hello @sebastian,

thank you for reporting this issue with such a detailed description.
We are working on the update of the NRF52832 driver which will be released by the end of February and this will surely help.