BLE profiles - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Gateway (https://forum.logicmachine.net/forumdisplay.php?fid=10) +--- Thread: BLE profiles (/showthread.php?tid=1199) |
BLE profiles - morak - 29.01.2018 Hi I thought that I will share with you all the BLE profiles I collected up to know. If you have some other feel free to add them here. Have fun RE: BLE profiles - 1114752670@qq.com - 13.03.2019 why these are not LUA RE: BLE profiles - Daniel - 13.03.2019 (13.03.2019, 07:53)1114752670@qq.com Wrote: why these are not LUA yes, they are RE: BLE profiles - gjniewenhuijse - 13.03.2019 Is there also a profile for: MIPOW Playbulb https://www.mipow.com/collections/playbulb/products/playbulb-solar Or how to make a profile? RE: BLE profiles - admin - 13.03.2019 Creating profiles can range from very easy to virtually impossible BLE does not specify data exchange formats so each manufacturer can do whatever they like including custom authentication/encryption. There are mobile apps that can connect to BLE devices and show available services. Best case scenario that you can find color/brightness control service number and there's no special pairing procedure required. Have a look at awox-aromalightcolor.lua which is an RGB LED lamp with BLE. RE: BLE profiles - benanderson_475 - 13.01.2020 Im working on a BLE profile for the xiaome Mi Flora Flower care sensor, this is as far as i have got, i can read the data but not sure how to extract the data i want from the bytes, there is available, light level, soil moisture level and temperature, the location of the data is as per the link below. https://www.open-homeautomation.com/2016/08/23/reverse-engineering-the-mi-plant-sensor/ require('ble') ble.up() sock = ble.sock() ble.settimeout(sock, 30) res = ble.connect(sock, "80:EA:CA:88:E5:63") log(res) if res then cmd = 0xA0, 0x1F --0x03 -- name re, er = ble.sockwritecmd(sock, 0x33, cmd) -- send the magic to allow us to read the data log(re, er) os.sleep(0.1) x = ble.sockreadhnd(sock,0x35) or '' a = x:byte(1) b = x:byte(2) c = x:byte(3) d = x:byte(4) e = x:byte(5) f = x:byte(6) g = x:byte(7) h = x:byte(8) log(x,a,b,c,d,e,f,g,h) end RE: BLE profiles - admin - 14.01.2020 Try this: Code: fertility = x:byte(9) * 0x100 + x:byte(10) RE: BLE profiles - benanderson_475 - 21.04.2020 (14.01.2020, 07:44)admin Wrote: Try this:I am having trouble receiving the correct data from lua code, when i use gatttool all works as below although i need to be fast to send the --char-read request before i get disconnected otherwise response is AA BB CC DD EE FF 99 88 77 66 00 00 00 00 00 00 gatttool --device=80:EA:CA:89:1D:78 --char-write-req -a 0x33 -n A01F gatttool --device=80:EA:CA:89:1D:78 --char-read -a 0x35 response is 03 01 00 4a 03 00 00 00 00 00 02 3c 00 fb 34 9b this is example of expected response from my lua script, result in rx is always AA BB CC DD EE FF 99 88 77 66 00 00 00 00 00 00 i think im not sending the ble.sockreadhnd(sock, 0x35) command fast enough? or sending it before the ble.sockwritereq(sock, 0x33, cmd) has returned or maybe there is something else wrong? The result from log(x, err) is *arg 1 number: 4 * arg: 2* number: 114 is there any documentation for these codes? or for the ble.sockwritereq() commands? Many Thanks Code: require('ble') RE: BLE profiles - admin - 21.04.2020 This line is incorrect (only 0xA0 is assigned to cmd): Code: cmd = 0xA0, 0x1F It should be: Code: cmd1, cmd2 = 0xA0, 0x1F You might need to swap cmd1 and cmd2 if it still does not work. You can also use loghex() instead of log() to convert binary data to hex. RE: BLE profiles - benanderson_475 - 22.04.2020 (21.04.2020, 06:23)admin Wrote: This line is incorrect (only 0xA0 is assigned to cmd): RE: BLE profiles - admin - 22.04.2020 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: 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 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/ RE: BLE profiles - benanderson_475 - 12.03.2022 (22.04.2020, 10:53)admin Wrote: You can use a scheduled script or create a profile. See raiing-temperature.lua for a similar device.Hi admin, working on this some more after long testing time... I am wondering if you can help me with the BLE code below (running in scheduled script every 10min), some times i get fail to read the data from the sensor, are you able to tell me if there is some obvious error in my lua code or is it more likely hardware related i have 2x flora plant sensor BLE, but if i am successful with no errors i might add 5 or 6 more of these sensors. Many Thanks, Code: local devices = {"80:EA:CA:88:xx:xx", "80:EA:CA:89:xx:xx"} |