Skip to content
Snippets Groups Projects
Commit 1c6e9e61 authored by Jorge's avatar Jorge
Browse files

test script for spp

parent 1d0a47a0
No related branches found
No related tags found
No related merge requests found
--- Test bluetooth.
local TEST_SEND = 60
local rspp = require('robotito_spp')
rspp.init()
local function strToHex(s)
local bytes = {}
for i=1,s:len() do
bytes[#bytes+1] = ('%2x'):format(s:byte(i,i))
print('byte', i, '0x'..bytes[#bytes], s:sub(i,i))
end
return table.concat(bytes, ' ')
--return table.concat(bytes, '')
end
local arrived = function(s)
print("arrived", #s, 'bytes:', s)
strToHex(s)
end
local echo_line = function(s)
print("echoing line", s)
rspp.send('echo:'..s..'\n')
end
print('Start ble monitoring')
rspp.set_rcv_callback(arrived)
rspp.set_line_callback(echo_line)
for i = 1, TEST_SEND do
local m = 'tick'..tostring(i)
print ('Sending', m)
rspp.send( m..'\n' )
tmr.sleep(10)
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment