forked from Tank/braga
add tests
This commit is contained in:
parent
0ad07a1ad6
commit
f69bd423c8
28
tests/client.lua
Normal file
28
tests/client.lua
Normal file
@ -0,0 +1,28 @@
|
||||
local host, port = "ulgrad.ru", 4999
|
||||
local json = require('cjson.safe')
|
||||
local base64 = require('base64')
|
||||
local socket = require("socket")
|
||||
local tcp = assert(socket.tcp())
|
||||
|
||||
tcp:connect(host, port);
|
||||
|
||||
local pack = {}
|
||||
pack['id'] = 'test'
|
||||
pack['bme'] = {['temp'] = 10,['press'] = 100,['alt'] = 300}
|
||||
pack['dht'] = {['temp'] = 12,['humi'] = 67}
|
||||
pack['uf'] = 5
|
||||
|
||||
|
||||
-- eyJibWUiOnsiYWx0IjozMDAsInRlbXAiOjEwLCJwcmVzcyI6MTAwfSwiZGh0Ijp7Imh1bWkiOjY3LCJ0ZW1wIjoxMn0sInVmIjo1LCJpZCI6InRlc3QifQ==
|
||||
|
||||
|
||||
tcp:send(base64.encode(json.encode(pack)))
|
||||
print(base64.encode(json.encode(pack)))
|
||||
|
||||
while true do
|
||||
local s, status, partial = tcp:receive()
|
||||
print(s or partial)
|
||||
print(status)
|
||||
if status == "closed" then break end
|
||||
end
|
||||
tcp:close()
|
||||
2
tests/tcp.test
Normal file
2
tests/tcp.test
Normal file
@ -0,0 +1,2 @@
|
||||
nc meteo.ulgrad.ru 4999
|
||||
nc 5.187.7.142 4999
|
||||
Loading…
x
Reference in New Issue
Block a user