0
0
mirror of https://github.com/Doodle3D/doodle3d-firmware.git synced 2024-12-22 11:03:48 +01:00

Skipping signin when already running

This commit is contained in:
peteruithoven 2013-10-28 13:51:56 +01:00
parent f8825896d8
commit 80dda36421

View File

@ -5,12 +5,32 @@ local iwinfo = require('iwinfo')
local settings = require('util.settings')
local wifi = require("network.wlanconfig")
local urlcode = require('util.urlcode')
local status = require('util.status')
local M = {}
local STATUS_FILE = "signinstatus"
local IDLE_STATUS = 1
local SIGNING_IN_STATUS = 2
--- Signin to connect.doodle3d.com server
--
function M.signin()
--log:debug("signin:signin");
local code, msg = M.getStatus()
--log:debug(" status: "..utils.dump(code).." "..utils.dump(msg));
-- if we are already signin in, skip
if(code == SIGNING_IN_STATUS) then
log:debug(" skipping signin")
return
end
M.setStatus(SIGNING_IN_STATUS,"signing in")
local baseurl = "http://connect.doodle3d.com/api/signin.php"
local localip = wifi.getLocalIP();
@ -26,7 +46,18 @@ function M.signin()
local output = utils.captureCommandOutput(cmd);
log:info("signin: "..output)
M.setStatus(IDLE_STATUS,"idle")
return string.len(output) > 0, output
end
function M.getStatus()
return status.get(STATUS_FILE);
end
function M.setStatus(code,msg)
log:info("signin:setStatus: "..code.." | "..msg)
status.set(STATUS_FILE,code,msg);
end
return M