Là, enfin cela commence à fonctionner, mais il y a encore beaucoup trop de code de debug
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
-- les conditions pour toutes les heures la journée
|
||||
-- Source: https://github.com/nodemcu/nodemcu-firmware/blob/master/lua_examples/sjson-streaming.lua
|
||||
|
||||
print("\n a_meteo2-tests.lua zf190304.1832 \n")
|
||||
print("\n a_meteo2-tests.lua zf190306.1505 \n")
|
||||
|
||||
dofile("a_meteo3-tests.lua")
|
||||
|
||||
@@ -13,7 +13,7 @@ dofile("a_meteo3-tests.lua")
|
||||
--zport=80
|
||||
--zpath="/services/json/lausanne"
|
||||
|
||||
zhost="192.168.0.152"
|
||||
zhost="192.168.0.153"
|
||||
zport=8080
|
||||
zpath="/meteo.lausanne.190302.1231.json"
|
||||
|
||||
@@ -27,8 +27,11 @@ s:on("connection", function(sck, c)
|
||||
end)
|
||||
|
||||
zcmpt=1
|
||||
zsum=0
|
||||
s:on("receive", function(sck, c)
|
||||
print("...zcmpt: ",zcmpt,string.len(c),string.sub(c,1,100))
|
||||
zlen=string.len(c)
|
||||
zsum=zsum+zlen
|
||||
print("...zcmpt, zsum, zlen: ",zcmpt,zsum,zlen,string.sub(c,1,100))
|
||||
-- print(node.heap())
|
||||
-- print("len3: "..string.len(zjson))
|
||||
-- print("zjson3: ",string.sub(zjson,1,100))
|
||||
@@ -36,11 +39,15 @@ s:on("receive", function(sck, c)
|
||||
zcmpt=zcmpt+1
|
||||
end)
|
||||
|
||||
local function getresult()
|
||||
print(node.heap())
|
||||
local function zdisconnection()
|
||||
print("disconnect",node.heap())
|
||||
end
|
||||
|
||||
s:on("disconnection", getresult)
|
||||
s:on("reconnection", getresult)
|
||||
local function zreconnection()
|
||||
print("reconnect",node.heap())
|
||||
end
|
||||
|
||||
s:on("disconnection", zdisconnection)
|
||||
s:on("reconnection", zreconnection)
|
||||
s:connect(zport, zhost)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
-- Source: https://github.com/nodemcu/nodemcu-firmware/blob/master/lua_examples/sjson-streaming.lua
|
||||
|
||||
print("\n a_meteo3-tests.lua zf190304.1832 \n")
|
||||
print("\n a_meteo3-tests.lua zf190306.1427 \n")
|
||||
|
||||
function set_json()
|
||||
zjson=[[
|
||||
@@ -11,14 +11,14 @@ function set_json()
|
||||
end
|
||||
|
||||
function zget_json_key()
|
||||
print("coucou2",zjson_stat)
|
||||
print("zget_json_key entrée...",zjson_stat)
|
||||
if zjson_stat==1 then
|
||||
p1=string.find(zjson, [["hourly_data":{]])
|
||||
if p1~=nil then
|
||||
print("JSON header: ",p1)
|
||||
print("trouvé le header: ",p1)
|
||||
zjson=string.sub(zjson,p1)
|
||||
print(string.sub(zjson,1,100))
|
||||
print("\n\ngo go go...\n\n")
|
||||
print("go go go...")
|
||||
zjson_stat=2
|
||||
end
|
||||
end
|
||||
@@ -44,6 +44,7 @@ function zget_json_key()
|
||||
end
|
||||
end
|
||||
end
|
||||
print("zget_json_key sortie...",zjson_stat)
|
||||
end
|
||||
|
||||
|
||||
@@ -54,27 +55,29 @@ zjson_stat=1
|
||||
zjson=""
|
||||
|
||||
function ztoto(c1)
|
||||
print("coucou")
|
||||
print("ztoto entrée...")
|
||||
if zjson=="" then
|
||||
zjson=c1
|
||||
else
|
||||
zjson=zjson..c1
|
||||
end
|
||||
print("zh: ",zh,"len(zjson): ",string.len(zjson))
|
||||
while zh<=zhmax and string.len(zjson)>500 do
|
||||
while zh<=zhmax do
|
||||
zget_json_key()
|
||||
if p1~=nil then
|
||||
zh=zh+1
|
||||
else
|
||||
print("ouille ouille ouille, pas trouvé...")
|
||||
zjson=string.sub(zjson,string.len(zjson)-20)
|
||||
if string.len(zjson)>510 then
|
||||
zjson=string.sub(zjson,string.len(zjson)-500)
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
if zh>zhmax then
|
||||
zjson=""
|
||||
end
|
||||
print("coucou3")
|
||||
print("ztoto sortie...")
|
||||
end
|
||||
|
||||
|
||||
@@ -99,6 +102,11 @@ for i=0, 5 do
|
||||
zh=zh+1
|
||||
end
|
||||
|
||||
set_json()
|
||||
print("len1: "..string.len(zjson))
|
||||
zjson=string.sub(zjson,string.len(zjson)-500)
|
||||
print("len2: "..string.len(zjson))
|
||||
print("zjson1: ",string.sub(zjson,1,100))
|
||||
]]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user