I'm trying to write several times the same characteristic,. However after eight times, my script is still writing but the device is not receiving anything. Even more, I can disconnect and connect again, but when I try to write, the device is not receiving.
Now, if I disconnect and I use a mobile app, the mobile app is able to connect, to write and the device is receiving.
Below my code
scanner = btle.Scanner().withDelegate(ScanDelegate())
devices = scanner.scan(10.0)
string="0444000000000448A20000000448A20000000448A20000000448A20000000448A20000000448A20000000448A20000000448A200000004474E0000000448A20000000448A200000004469C0000000448A20000000448A20000000448A20000000446BA0000000446DC0000000448A20000000448A200000004460A0000000448A20000000448A20000000448A20000000448A20000000448A20000000448A20000000448A20000000448A20000000447820000000448A20000000448A20000000448A20000000448A20000000448A20000000448A20000000446FA0000000447180000000447C400000004463C0000000448A20000000448A20000000448A20000000448A20000000448A20000000448A20000000448A20000000448A20000000448A20000000448A20000000448A20000000448"
def chunkstring(string, length):
return (string[0+i:length+i] for i in range(0, len(string), length))
for dev in devices:
print "Device %s (%s), RSSI=%d dB" % (dev.addr, dev.addrType, dev.rssi)
for (adtype, desc, value) in dev.getScanData():
print " %s = %s" % (desc, value)
if desc == "Complete Local Name" and value == "Device name":
print "FOUND Device"
p = btle.Peripheral(dev.addr)
svc = p.getServiceByUUID(service_uuid)
print(svc)
ch= svc.getCharacteristics(char_uuid)[0]
print(ch)
for chunk in chunkstring(string, 20):
chunk
print valueToWrite
ch.write(valueToWrite,True)
print(chunk)
break
I'm trying to write several times the same characteristic,. However after eight times, my script is still writing but the device is not receiving anything. Even more, I can disconnect and connect again, but when I try to write, the device is not receiving.
Now, if I disconnect and I use a mobile app, the mobile app is able to connect, to write and the device is receiving.
Below my code
Any idea about what could be happening?