From 36322f53ed42811a775a99119bfbe549123bb356 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Sat, 29 Jul 2017 16:29:13 -0400 Subject: [PATCH] Expunge cjson in favor of sjson --- init.lua | 3 --- net/nwfmqtt.lua | 6 +++--- net/nwfnet-go.lua | 6 +++--- net/nwfnet-sntp.lua | 2 +- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/init.lua b/init.lua index a232870..389b458 100644 --- 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 diff --git a/net/nwfmqtt.lua b/net/nwfmqtt.lua index 9172589..1eeec95 100644 --- a/net/nwfmqtt.lua +++ b/net/nwfmqtt.lua @@ -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 diff --git a/net/nwfnet-go.lua b/net/nwfnet-go.lua index b395820..c073e40 100644 --- a/net/nwfnet-go.lua +++ b/net/nwfnet-go.lua @@ -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") diff --git a/net/nwfnet-sntp.lua b/net/nwfnet-sntp.lua index 4f4c82f..a337301 100644 --- a/net/nwfnet-sntp.lua +++ b/net/nwfnet-sntp.lua @@ -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") -- 2.50.1