Search code examples
bluetooth-lowenergyadafruitadafruit-circuitpython

Changing advertisement ID in adafruit_ble for Circuit Playground Bluefruit


Not sure how esoteric this question is, but I'm trying to do some basic Bluetooth communications from an Adafruit Circuit Playground Bluefruit using Circuit Python.

The basic use case is to use UART to transmit data to/from a computer for a demonstration, however the issue is that there are going to be about 30 devices in close proximity, so nobody is going to know "which" is their device.

Is there a way to change the display name / advertising ID in Bluetooth of the device? I've seen references in an example here or there for a short_name or complete_name, however trying those out seems to do nothing most of the time.

Here's the basic example - I was trying to look through the source of the library but I can't really find anything relating to an advertising name. I had thought this would be trivial, though I can't seem to find anywhere to change it.

from adafruit_ble import BLERadio
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.nordic import UARTService

ble = BLERadio()
uart = UARTService()
advertisement = ProvideServicesAdvertisement(uart)
advertisement.complete_name = "custom name" # had hoped this would work

ble.start_advertising(advertisement)
while True:
    # Normally other work would be done here after connecting.
    pass        

Solution

  • All you need to do is set ble.name = "new advertising ID", c/o John Park: https://www.youtube.com/watch?v=nS10NxHRrXE