Open operator000 opened 3 weeks ago
write_gatt_char()
is also an async
method that must be awaited, which means that also your write_something
method must be declared as async
:
# write
async def write_something(self):
try:
await self.client.write_gatt_char('beb5483e-36e1-4688-b7f5-ea07361b26a8', b'hello')
except Exception as e:
self.print_data(str(e))
Edit: not awaiting an async method just issues a Warning (RuntimeWarning: coroutine '... ' was never awaited
) but not an Exception. This is probably why your code doesn't report an error.
That's really the problem. Thank you very much!
promlem:
I met another problem. I'm writing an app on android to commuincate with esp32. I made changes on the example code. But "write_gatt_char" can't work and there's no errors presented.
details:
part of the code:
and the output on phone :
(there's no errors collected) esp32 is expected to return a value by serial, like
and I used Bluetooth LE Explorer to test it, and it worked: esp32 also got themessage. Then I used a WeChat applet to test it again. it also worked. What's going wrong? I sincerely hope to get your help.