Open
Description
CircuitPython version
9.2.1
Code/REPL
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from cycling_power_service import CyclingPowerService
from adafruit_ble import BLERadio
import time
ble_radio = BLERadio()
advertisement = ProvideServicesAdvertisement(CyclingPowerService())
ble_radio.start_advertising(advertisement)
def advertise_ble():
while True:
print(ble_radio.connections)
if len(ble_radio.connections) < 3:
if not ble_radio.advertising:
ble_radio.start_advertising(advertisement)
time.sleep(2)
advertise_ble()
from adafruit_ble.services import Service
from adafruit_ble.characteristics import Characteristic
from adafruit_ble.attributes import Attribute
from adafruit_ble.uuid import StandardUUID
class CyclingPowerService(Service):
uuid = StandardUUID(0x1818)
measurement = Characteristic(
uuid=StandardUUID(0x2A63),
properties=Characteristic.NOTIFY,
read_perm=Attribute.OPEN,
write_perm=Attribute.NO_ACCESS,
max_length=8,
fixed_length=True
)
feature = Characteristic(
uuid=StandardUUID(0x2A65),
properties=Characteristic.READ,
read_perm=Attribute.OPEN,
write_perm=Attribute.NO_ACCESS,
max_length=4,
fixed_length=True,
initial_value=bytes([
0x20 & 0xFF,
(0x20 >> 8) & 0xFF,
(0x20 >> 16) & 0xFF,
(0x20 >> 24) & 0xFF
])
)
sensor_location = Characteristic(
uuid=StandardUUID(0x2A5D),
properties=Characteristic.READ,
read_perm=Attribute.OPEN,
write_perm=Attribute.NO_ACCESS,
max_length=1,
fixed_length=True,
initial_value=(bytes([0x06]))
)
Behavior
When the first device connects everything is ok as is reported by the print. once the device starts advertising again an error is given:
(<BLEConnection object at 0x3c198930>,)
Traceback (most recent call last):
File "", line 18, in
File "", line 15, in advertise_ble
File "adafruit_ble/init.py", line 219, in start_advertising
MemoryError: Nimble out of memory
Description
No response
Additional information
No response