Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
Dim job As HttpJob
job.Tag = "thethingsnetwork.json"
job.Initialize("getjson", Me)
job.Download("http://thethingsnetwork.org/api/v0/nodes/02015512/?format=json")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub JobDone(Job As HttpJob)
ProgressDialogHide
If Job.Success Then
If Job.JobName = "getjson" Then
Dim out As OutputStream
out = File.OpenOutput(File.DirRootExternal,Job.Tag,False )
File.Copy2(Job.GetInputStream, out)
out.Close
Log($"The file ${Job.Tag} is written to DirRootExternal"$)
ParseJSON(Job.GetString)
End If
Else
Log( Job.ErrorMessage)
End If
Job.Release
End Sub
Sub ParseJSON(jsonstring As String)
Dim parser As JSONParser
parser.Initialize(jsonstring)
Dim root As List = parser.NextArray
For Each colroot As Map In root
Dim rssi As Int = colroot.Get("rssi")
Dim data_raw As String = colroot.Get("data_raw")
Dim data As String = colroot.Get("data")
Dim snr As Double = colroot.Get("snr")
Dim node_eui As String = colroot.Get("node_eui")
Dim datarate As String = colroot.Get("datarate")
Dim time As String = colroot.Get("time")
Dim gateway_eui As String = colroot.Get("gateway_eui")
Dim frequency As Double = colroot.Get("frequency")
Log($"RSSI=${rssi}
data_raw=${data_raw}
snr=${snr}
node_eui=${node_eui}
datarate=${datarate}
time=${time}
gateway_eui=${gateway_eui}
frequency=${frequency}
=====================
"$)
Next
End Sub