Skip to content

Setting the name property on an adafruit_ble.BLERadio instance doesn't work on ESP32-S3 #9333

Open
@ashirvadz

Description

@ashirvadz

CircuitPython version

Adafruit CircuitPython 9.1.0-beta.3 on 2024-05-22; FeatherS3 with ESP32S3

Code/REPL

import time
from adafruit_ble import BLERadio
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.nordic import UARTService
from adafruit_ble.uuid import StandardUUID
from adafruit_ble.services import Service
from adafruit_ble.characteristics import Characteristic
from adafruit_ble.characteristics.string import StringCharacteristic

# Define a custom service and characteristic
class CustomService(Service):
    uuid = StandardUUID(0x181C)  # Custom service UUID
    custom_characteristic = StringCharacteristic(
        uuid=StandardUUID(0x2A58),  # Custom characteristic UUID
        properties=(Characteristic.READ | Characteristic.WRITE),
        initial_value=b"Hello BLE!",
    )

# Initialize the BLE radio
ble = BLERadio()
ble.name = "MyBLEDevice"

# Create the custom service instance
custom_service = CustomService()

# Create the advertisement
advertisement = ProvideServicesAdvertisement(custom_service)
advertisement.complete_name = "MyBLEDeviceAdv"

# Start advertising
ble.start_advertising(advertisement)
print("Advertising Custom Service...")

while not ble.connected:
    time.sleep(0.1)

print("Device Connected")

while ble.connected:
    # Perform tasks while connected
    pass

print("Device Disconnected")

# Stop advertising when disconnected
ble.stop_advertising()

Behavior

The device name shows as "CIRCUITPY", and the name property show as "Local Name" on a BLE scanner app such as Bluefruit Connect:
IMG_E08AFBE3F529-1

Description

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions