16 lines
431 B
Lua
16 lines
431 B
Lua
local _C = {
|
|
TAG = "【上报数据】"
|
|
}
|
|
|
|
function _C.upload(v)
|
|
log.info(COSO, _C.TAG, json.encode(v))
|
|
local code, _, body = http.request("POST", "http://miot.xaxi.cn/app/device/data/", nil, json.encode(v), { timeout = cfg.get_t_o() }).wait()
|
|
log.debug(COSO, _C.TAG, code, body)
|
|
if code ~= 200 then return 1 end
|
|
body = json.decode(body)
|
|
if body.code ~= 0 then return 2 end
|
|
return 0
|
|
end
|
|
|
|
return _C
|