GATTCCharacteristics.write('value') doesn't work!
-
Re: BLE connects but connection is lost immediately
Hi,
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 examplechars[0]
is aPROP_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()
-
@kutysam Hmm ok! One of our engineers is having a look at it today so I'll keep you posted!
-
@bucknall
Hi, I have a ble device and i can confirm that Prop_write_nr works!And sorry for piggy backing, cause this issue is related to BLE GATTC too.
https://forum.pycom.io/topic/1486/reading-descriptors-of-ble-client-gattc-deviceAnyway to change the properties of a gattc manually?
writeChar.properties() --> 22
0001011000010000 Bluetooth.PROP_NOTIFY
00000100 Bluetooth.PROP_WRITE_NR
00000010 Bluetooth.PROP_READI need this to be in.
00100000 Bluetooth.PROP_INDICATE
00110110 --> 54Android, pygatt and mrsurly fork of micropython has a way to change it as such.
-
@Innocenzo Definitely sounds like a bug! I'll check this out later today!
-
@bucknall I notice that if the characteristic that I want write has a property =
PROP_WRITE
the write function doesn't work. Instead if the characteristic has a property =PROP_WRITE_NR
, the function works fine.EDIT: I have opened a issue on GitHub
-
Hi @Innocenzo,
Thanks for alerting us to this problem. Would you mind creating an issue on our GitHub repo (https://github.com/pycom/pycom-micropython-sigfox/issues) regarding your concerns?
Thanks! :)
Alex