22.04.2020, 00:38
(21.04.2020, 06:23)admin Wrote: This line is incorrect (only 0xA0 is assigned to cmd):
Code:cmd = 0xA0, 0x1F
Thanks, i have it working correctly now (in resident script with 0 delay) and returning the correct values as below,
but if i put a longer delay than 0 on the resident script the correct values are not returned,
what could be the reason for this?
how should this code run, in a ble profile? or it is ok in resident script?
also i want to only ask this device what its values are every 15 min or so, as it is a battery operated device...
should i do a scheduled script every x minutes?
Code:require('ble')
sock = ble.sock()
ble.settimeout(sock, 10)
res = ble.connect(sock, "80:EA:CA:89:1D:78")
if res then
cmd1, cmd2 = 0xA0, 0x1F
x, err = ble.sockwritereq(sock, 0x33, cmd1, cmd2)
log(x, err)
rx = ble.sockreadhnd(sock, 0x35)
loghex(rx)
temperature = (rx:byte(2) + rx:byte(1)) / 10
log(temperature)
end