22.04.2020, 10:53
You can use a scheduled script or create a profile. See raiing-temperature.lua for a similar device.
I'm not sure that this conversion is correct:
The temperature value is probably two bytes, so you need to shift one byte with multiply by 256. Try both ways as byte order is not known.
All write functions like ble.sockwritereq return two values:
1. number of bytes written, -1 = error
2. last error number (errno), applicable only when first value is -1, see this for errno number description: https://www.thegeekstuff.com/2010/10/linux-error-codes/
I'm not sure that this conversion is correct:
Code:
temperature = (rx:byte(2) + rx:byte(1)) / 10
The temperature value is probably two bytes, so you need to shift one byte with multiply by 256. Try both ways as byte order is not known.
Code:
temperature = (rx:byte(2) * 256 + rx:byte(1)) / 10
temperature = (rx:byte(2) + rx:byte(1) * 256) / 10
All write functions like ble.sockwritereq return two values:
1. number of bytes written, -1 = error
2. last error number (errno), applicable only when first value is -1, see this for errno number description: https://www.thegeekstuff.com/2010/10/linux-error-codes/