GATTCCharacteristics.write('value') doesn't work!
I notice that with firmware
1.7.6.b1now 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
PROP_WRITEcharateristic, 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.uuid()) print(services.uuid()) print(services.uuid()) chars = services.characteristics() print(chars) print(chars.properties()) print(chars.properties()) print(chars.uuid()) print(chars.uuid()) chars.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!
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.
Anyway to change the properties of a gattc manually?
writeChar.properties() --> 22
I need this to be in.
00110110 --> 54
Android, 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_WRITEthe 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
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?