This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

BLE profiles
#8
(14.01.2020, 07:44)admin Wrote: Try this:
Code:
fertility = x:byte(9) * 0x100 + x:byte(10)
sunlight = x:byte(4) * 0x100 + x:byte(5)
temperature = (x:byte(1) * 0x100 + x:byte(2)) / 10

log(fertility, sunlight, temperature)
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')
sock = ble.sock()
ble.settimeout(sock, 10)
res = ble.connect(sock, "80:EA:CA:89:1D:78")
if res then
  cmd = 0xA0, 0x1F
 
  x, err =  ble.sockwritereq(sock, 0x33, cmd)
log(x, err)

if x then
rx = ble.sockreadhnd(sock, 0x35)
rx = string.gsub(rx, ".", function(value) return  string.format('%02X', string.byte(value))end)
log(rx)
end
Reply


Messages In This Thread
BLE profiles - by morak - 29.01.2018, 11:37
RE: BLE profiles - by 1114752670@qq.com - 13.03.2019, 07:53
RE: BLE profiles - by Daniel - 13.03.2019, 08:48
RE: BLE profiles - by gjniewenhuijse - 13.03.2019, 11:06
RE: BLE profiles - by admin - 13.03.2019, 11:19
RE: BLE profiles - by benanderson_475 - 13.01.2020, 21:17
RE: BLE profiles - by admin - 14.01.2020, 07:44
RE: BLE profiles - by benanderson_475 - 21.04.2020, 01:00
RE: BLE profiles - by admin - 21.04.2020, 06:23
RE: BLE profiles - by benanderson_475 - 22.04.2020, 00:38
RE: BLE profiles - by admin - 22.04.2020, 10:53
RE: BLE profiles - by benanderson_475 - 12.03.2022, 10:12

Forum Jump: