BLE multiple characteristics in a service



  • I seem to be having trouble getting more than one characteristic working inside of a BLE service. The below simple example is based on what is shown in the class documentation. There is not much more to help understand programming a BLE peripheral with Micropython on the wipy2/lopy boards.

    As mentioned in an email to support and in another post. I will be willing to pay for prompt support and resolution of this.

    Any help would be appreciated.

    https://docs.pycom.io/pycom_esp32/library/network.Bluetooth.html
    https://docs.pycom.io/pycom_esp32/pycom_esp32/tutorial/includes/bluetooth.html

    >>> from network import Bluetooth
    >>> ble = Bluetooth()
    BTDM CONTROLLER VERSION: 010101
    btip start
    copy .data from 4000d890 to 3ffae6e0, len 00001830
    set .bss 0x0 from 3ffb8000 to 3ffbff70, len 00007f70
    BTDM ROM VERSION 0101
    BD_ADDR: 24:0A:C4:00:6B:EC
    NVDS MAGIC FAILED
    RF Init OK with coex
    >>> ble.advertise(True)
    >>> ble.set_advertisement(name='bleep', service_uuid=b'1234567890123456', manufacturer_data=None, service_data=None)
    >>> serv = ble.service(uuid=b'1234567890123456', isprimary=True)
    >>> char1 = serv.characteristic(uuid=b'2234567890123456', value=1)
    >>> char2 = serv.characteristic(uuid=b'3234567890123456', value=2)
    


  • I know this is an old topic I started but it seems like there is even less documentation now on this topic of using the BLE device as a peripheral. It would be nice if the documentation better represented common functionality and how the functionality is intended to be used with this device.

    I tried to use those links that had reference to using the BLE device as a peripheral but the link was broken.



  • @jmarcelino Is there a maximum to how many characteristics a service can have?



  • Thanks for the prompt help. This makes sense, just wish the documentation was better at describing typical use cases, especially when there is frequent firmware updates.



  • @TravisT said in BLE multiple characteristics in a service:

    serv = ble.service(uuid=b'1234567890123456', isprimary=True)

    You need to use the nbr_chars parameter when you create a service.
    For your example, with two characteristics, that would be:

    serv = ble.service(uuid=b'1234567890123456', isprimary=True,nbr_chars=2)

    This was added in 1.5.0.b1



Pycom on Twitter