My code is
Code: Select all
_ENV_OBD_UUID = bluetooth.UUID(0xffe0)
_ENV_OBD_RWN_UUID = bluetooth.UUID(0xffe1)
_ENV_OBD_RW_UUID = bluetooth.UUID(0xffee)
...
...
async with connection:
print"Connected")
try:
obd_service = await connection.service(_ENV_OBD_UUID)
obd_rwn = await obd_service.characteristic(_ENV_OBD_RWN_UUID)
obd_rw = await obd_service.characteristic(_ENV_OBD_RW_UUID)
except asyncio.TimeoutError:
print("Timeout discovering services/characteristics")
return
cmds = ["ATZ\n","ATD\n","ATE1\n","ATL1\n","ATH1\n","ATS0\n","ATSTFF\n","ATFE\n","ATSP6\n"]
for cmd in cmds:
try:
await obd_rwn.write(cmd, response=False, timeout_ms=2000) # <------------- Tried response = both True & False
print(cmd[:-1])
rtn = await obd_rwn.read(timeout_ms=2000) # <------------- returns Write command
# rtn = await obd_rwn.notified(timeout_ms=2000) # <------------- Times out
print(cmd)
utime.sleep(1)
except asyncio.TimeoutError:
print("Write timeout")
return
EDIT - Do I need to subscribe to the notify characteristic for notifications? - And, if so, how and where?