Ca marche presque :-)
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
-- les conditions pour toutes les heures la journée
|
-- les conditions pour toutes les heures la journée
|
||||||
-- Source: https://github.com/nodemcu/nodemcu-firmware/blob/master/lua_examples/sjson-streaming.lua
|
-- Source: https://github.com/nodemcu/nodemcu-firmware/blob/master/lua_examples/sjson-streaming.lua
|
||||||
|
|
||||||
print("\n a_meteo2-tests.lua zf190304.1703 \n")
|
print("\n a_meteo2-tests.lua zf190304.1832 \n")
|
||||||
|
|
||||||
dofile("a_meteo3-tests.lua")
|
dofile("a_meteo3-tests.lua")
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ dofile("a_meteo3-tests.lua")
|
|||||||
--zport=80
|
--zport=80
|
||||||
--zpath="/services/json/lausanne"
|
--zpath="/services/json/lausanne"
|
||||||
|
|
||||||
zhost="192.168.0.154"
|
zhost="192.168.0.152"
|
||||||
zport=8080
|
zport=8080
|
||||||
zpath="/meteo.lausanne.190302.1231.json"
|
zpath="/meteo.lausanne.190302.1231.json"
|
||||||
|
|
||||||
@@ -29,6 +29,9 @@ end)
|
|||||||
zcmpt=1
|
zcmpt=1
|
||||||
s:on("receive", function(sck, c)
|
s:on("receive", function(sck, c)
|
||||||
print("zcmpt: ",zcmpt,string.len(c),string.sub(c,1,100))
|
print("zcmpt: ",zcmpt,string.len(c),string.sub(c,1,100))
|
||||||
|
print(node.heap())
|
||||||
|
print("len3: "..string.len(zjson))
|
||||||
|
print("zjson3: ",string.sub(zjson,1,100))
|
||||||
ztoto(c)
|
ztoto(c)
|
||||||
zcmpt=zcmpt+1
|
zcmpt=zcmpt+1
|
||||||
end)
|
end)
|
||||||
|
|||||||
+24
-19
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
-- Source: https://github.com/nodemcu/nodemcu-firmware/blob/master/lua_examples/sjson-streaming.lua
|
-- Source: https://github.com/nodemcu/nodemcu-firmware/blob/master/lua_examples/sjson-streaming.lua
|
||||||
|
|
||||||
print("\n a_meteo3-tests.lua zf190304.1431 \n")
|
print("\n a_meteo3-tests.lua zf190304.1832 \n")
|
||||||
|
|
||||||
function set_json()
|
function set_json()
|
||||||
zjson=[[
|
zjson=[[
|
||||||
@@ -29,40 +29,45 @@ function zget_json_key()
|
|||||||
print("len1: "..string.len(zjson))
|
print("len1: "..string.len(zjson))
|
||||||
zjson_key='"'..zh..'H00":{'
|
zjson_key='"'..zh..'H00":{'
|
||||||
print("zjson_key: "..zjson_key)
|
print("zjson_key: "..zjson_key)
|
||||||
p1=string.find(zjson, zjson_key)
|
p1=0 p1=string.find(zjson, zjson_key)
|
||||||
print("p1: "..p1)
|
print("p1: ",p1)
|
||||||
zjson=string.sub(zjson,p1)
|
if p1~=nil then
|
||||||
print("zjson: ",string.sub(zjson,1,100))
|
zjson=string.sub(zjson,p1)
|
||||||
p1,p2=string.find(zjson, '"CONDITION_KEY":"')
|
print("zjson: ",string.sub(zjson,1,100))
|
||||||
print(p1,p2)
|
p1,p2=string.find(zjson, '"CONDITION_KEY":"')
|
||||||
p3=string.find(zjson, '","',p2)
|
print(p1,p2)
|
||||||
print(p3)
|
p3=string.find(zjson, '","',p2)
|
||||||
ztoto=string.sub(zjson,p2,p3)
|
print(p3)
|
||||||
print(ztoto)
|
ztutu=string.sub(zjson,p2,p3)
|
||||||
print("len2: "..string.len(zjson))
|
print(ztutu)
|
||||||
|
print("len2: "..string.len(zjson))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
zh=0
|
zhmin=7
|
||||||
|
zhmax=19
|
||||||
|
zh=zhmin
|
||||||
zjson_stat=1
|
zjson_stat=1
|
||||||
zjson=""
|
zjson=""
|
||||||
|
|
||||||
function ztoto(c)
|
function ztoto(c1)
|
||||||
print("coucou")
|
print("coucou")
|
||||||
if zjson=="" then
|
if zjson=="" then
|
||||||
zjson=c
|
zjson=c1
|
||||||
else
|
else
|
||||||
zjson=zjson..c
|
zjson=zjson..c1
|
||||||
end
|
end
|
||||||
print("zh: ",zh,"len(zjson",string.len(zjson))
|
print("zh: ",zh,"len(zjson)",string.len(zjson))
|
||||||
while zh<=5 and string.len(zjson)>500 do
|
while zh<=zhmax and string.len(zjson)>500 do
|
||||||
zget_json_key()
|
zget_json_key()
|
||||||
zh=zh+1
|
zh=zh+1
|
||||||
end
|
end
|
||||||
if zh>5 then
|
if zh>zhmax then
|
||||||
zjson=""
|
zjson=""
|
||||||
end
|
end
|
||||||
|
print("coucou3")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user