This repository was archived by the owner on Sep 16, 2024. It is now read-only.
This repository was archived by the owner on Sep 16, 2024. It is now read-only.
BLE: GATTCCharacteristics.write('value') doesn't work! #38
Open
Description
I use a WiPy 2.0
with firmware 1.7.6.b1
.
I notice that with firmware 1.7.6.b1
now the BLE connection function works fine. Now it is possible discover all services and characteristics, but the write function on a characteristic does not work. In my code example chars[0]
is a PROP_WRITE
charateristic, but when I write something on it, anything happen.
from network import Bluetooth
import ubinascii
import machine
import uos
import utime
bt = Bluetooth()
bt.start_scan(-1)
while True:
adv = bt.get_adv()
try:
if adv and bt.resolve_adv_data(adv.data, Bluetooth.ADV_NAME_CMPL) == 'X-DOM-NC':
print(adv.mac)
conn = bt.connect(adv.mac)
while not conn.isconnected():
machine.idle()
print("connected")
print(conn)
services = conn.services()
print("services")
print(services)
print(services[0].uuid())
print(services[1].uuid())
print(services[2].uuid())
chars = services[2].characteristics()
print(chars)
print(chars[0].properties())
print(chars[1].properties())
print(chars[0].uuid())
print(chars[1].uuid())
chars[0].write(b'x0f')
utime.sleep(2)
break
except:
print("Error while connecting or reading from the BLE device")
break
while True:
pass
conn.disconnect()
Instead, if chars[0]
has a property PROP_WRITE_NR
the write function works fine!