]> hydra-www.ietfng.org Git - acmetensortoys-esp-lua_core/commitdiff
Expunge cjson in favor of sjson
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Sat, 29 Jul 2017 20:29:13 +0000 (16:29 -0400)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Mon, 31 Jul 2017 11:59:13 +0000 (07:59 -0400)
init.lua
net/nwfmqtt.lua
net/nwfnet-go.lua
net/nwfnet-sntp.lua

index a232870253a573afc2954516a1e2e06e32907ad5..389b45831331d07930f255b72e676f6d4a06e75c 100644 (file)
--- a/init.lua
+++ b/init.lua
@@ -1,9 +1,6 @@
 -- DEPEND: file?, gpio, node, rtctime?, tmr ; nwfnet, nwfnet-diag, nwfnet-go, telnetd
 if rtctime then rtctime.set(0) end -- set time to 0 until someone corrects us
 
--- XXX much of this framework calls cjson as such; that should be fixed
-if not cjson then _G.cjson = sjson end
-
 -- See if there's any early startup to do.
 if file and file.exists("init-early.lua") then dofile("init-early.lua") end
 
index 917258908c9d729cf3aad03aa4c9814a45bd5018..1eeec9526171345e86c17d810f48ae5ebde2b288 100644 (file)
@@ -1,10 +1,10 @@
--- DEPENDS: cjson, file, mqtt; nwfnet
+-- DEPENDS: file, mqtt, sjson; nwfnet
 local nwfnet = require "nwfnet"
 local self = {}
 function self.mkclient(cf) -- construct a client with config from json file cf
   local c, k, u, p, l
   if file.open(cf) then
-    local conf = cjson.decode(file.read() or "")
+    local conf = sjson.decode(file.read() or "")
     if type(conf) == "table" then
       c = conf["clientid"]; k = conf["keepalive"]; u = conf["user"]; p = conf["pass"]; l = conf["clean"]
     end
@@ -24,7 +24,7 @@ end
 function self.connect(m,cf) -- make a connection with parameters from json file cf
   local broker, port, secure
   if file.open(cf) then
-    local conf = cjson.decode(file.read() or "")
+    local conf = sjson.decode(file.read() or "")
     if type(conf) == "table" then
       broker = conf["broker"]; port = conf["port"]; secure = conf["secure"]
     end
index b39582024bef60164618d818d85feffc9530759d..c073e40a08f57038dded3bfe86d771bfdcf0636a 100644 (file)
@@ -1,4 +1,4 @@
--- DEPENDS: cjson, file, mdns, net, rtctime, sntp, wifi; nwfnet, nwfnet-sntp
+-- DEPENDS: file, mdns, net, rtctime, sjson, sntp, wifi; nwfnet, nwfnet-sntp
 wifi.eventmon.register(wifi.eventmon.STA_GOT_IP, function(t)
   (require "nwfnet"):runnet("wstagoip",t)
   if mdns then mdns.register(wifi.sta.gethostname()) end
@@ -11,7 +11,7 @@ wifi.eventmon.register(wifi.eventmon.STA_DISCONNECTED, function(t) (require "nwf
 -- One-shot configuration options; useful to change many things at once
 -- at the next boot; all of these options are persisted by the ESP
 if file.open("nwfnet.conf","r") then
-  local conf = cjson.decode(file.read() or "")
+  local conf = sjson.decode(file.read() or "")
   if type(conf) == "table" then
     local essid = conf["sta_essid"]; local pw = conf["sta_pw"]
     if essid ~= nil and pw ~= nil then wifi.sta.config(essid,pw,0) end
@@ -47,7 +47,7 @@ if file.open("nwfnet.cert","r") then
 end
 
 if file.open("nwfnet.conf2","r") then
-  local conf = cjson.decode(file.read() or "")
+  local conf = sjson.decode(file.read() or "")
   if type(conf) == "table" then
     if conf["verify"] == 1 then print("Enabling certificate verification"); pcall(net.cert.verify,true) end
    else print("nwfnet.conf2 malformed")
index 4f4c82fc1aa5a1cefc733f3056e8a656c0b24244..a3373015ed890be97eb668bc54ccb38aa995e2c3 100644 (file)
@@ -2,7 +2,7 @@ local function dosntp(server)
   local nn = require "nwfnet"
   if not server then
     if file.open("nwfnet.conf2","r") then
-      local conf = cjson.decode(file.read() or "")
+      local conf = sjson.decode(file.read() or "")
       if type(conf) == "table" then
         if conf["sntp"]  then server = conf["sntp"] end
        else print("nwfnet.conf2 malformed")