You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using circuitpython 9.2.4 on an M5stack Atom S3 lite.
installed libs:
neopixel
adafruit_requests
adafruit_connection_manager
bluepad32
adafruit_esp32spi
adafruit_bus_device
adafruit_ble
I'm trying to connect to Lego WEDO brick to send commands (haven't got there yet).
Also first version of code (with a more generalized approach: start_scan(Advertisement)) worked for scanning, but returned too little information - no device names (usually use it to find the device to connect).
Current (problematic) code is as follows:
importtimeimportboardfromdigitalioimportDigitalInOut, Direction, Pullimportneopixelfromadafruit_bleimportBLERadiofromadafruit_ble.advertising.standardimportProvideServicesAdvertisementfromadafruit_ble.uuidimportUUID, VendorUUID# Init buttonbtn=DigitalInOut(board.BTN)
btn.direction=Direction.INPUTbtn.pull=Pull.UP# Init LEDled=neopixel.NeoPixel(board.NEOPIXEL, 1)
led.brightness=0.1values= (
(255, 0, 0),
(128, 128, 0),
(0, 255, 0), # Green
(0, 128, 128), # cyan
(0, 0, 255), # Blue
(128, 0, 128), # Purple
)
INDEX=0# Init BLE# Adapter = Adapter()#_bleio.start_scan(extended=True, timeout=10, interval=1.2)found=set()
scan_responses=set()
ble=BLERadio()
connection=Noneprint("scanning")
led[0] = (0,128,128)
WEDO_SERVICE_ID=VendorUUID('00001523-1212-efde-1523-785feabcd123')
WEDO_SERVICE=Noneforadvertisementinble.start_scan(ProvideServicesAdvertisement):
ifadvertisement.services:
ifWEDO_SERVICE_IDinadvertisement.services:
WEDO_SERVICE=list(advertisement.services)[0]
led[0] = (0, 255, 0)
ble.stop_scan()
connection=ble.connect(advertisement.address)
connection.connection_interval=11.5break#t: UUID('00001523-1212-efde-1523-785feabcd123')> >ifconnection:
print(dir(connection))
#connection.pair() ## <-- Wedo doesn't seem to pair (it just hangs here indefinetely)print(connection.paired)
# print('Service:', connection[WEDO_SERVICE]) ## <-- Uncommenting this line causes crash# print('Service:', connection[WEDO_SERVICE_ID]) ## <-- This one also crashesprint('Con:\t\t', connection)
print('List:\t\t', list(connection)) ## <-- This one returns AttributeError: 'int' object has no attribute 'bleio_uuid'print('Con dict: \t', connection.__dict__)
#print('Con _dr: \t', connection._discover_remote(connection)) ## also crash#print('Con drs: \t', connection._bleio_connection.discover_remote_services()) ## and here too.whileTrue:
ifnotbtn.value:
INDEX=0ifINDEX>4elseINDEX+1else:
passtime.sleep(0.1) # sleep for debounceled[0] =values[INDEX] # Redtime.sleep(0.5)
The result in serial is:
Con: <BLEConnection object at 0x3fcdca20>
Con dict: {'_constructed_services': {}, '_bleio_connection': <Connection>, '_discovered_bleio_services': {}}
Traceback (most recent call last):
---- Closed serial port COM16 due to disconnection from the machine ----
---- Reopened serial port COM16 ----
Auto-reload is off.
Running in safe mode! Not running saved code.
You are in safe mode because:
CircuitPython core code crashed hard. Whoops!
Hard fault: memory access or instruction error.
Cant even figure out where traceback tried to point.
Started to rework BLE part to pure _bleio, but I start suspecting that won't help.
The text was updated successfully, but these errors were encountered:
Using circuitpython 9.2.4 on an M5stack Atom S3 lite.
installed libs:
I'm trying to connect to Lego WEDO brick to send commands (haven't got there yet).
Also first version of code (with a more generalized approach:
start_scan(Advertisement)
) worked for scanning, but returned too little information - no device names (usually use it to find the device to connect).Current (problematic) code is as follows:
The result in serial is:
Cant even figure out where traceback tried to point.
Started to rework BLE part to pure
_bleio
, but I start suspecting that won't help.The text was updated successfully, but these errors were encountered: