Beispiel #1
0
        public override void parseTraceMessages(ExtendedTracePacket data)
        {
            // Filter on relevant OTA topics only psm[mqtt_url]=[wa.applianceconnect.net]
            if (data.ContentAsString.StartsWith("psm") && data.ContentAsString.Contains("mqtt_url"))
            {
                //MQTT data in the Trace just comes as raw hex regardless of message format, so need to convert it to ASCII to get the payload
                string[] parts = data.ContentAsString.Replace("[", "").Split('=');
                mqtt_url = "";
                for (int i = 0; i < parts[1].Length - 1; i++)
                {
                    string hs = parts[1].Substring(i, 1);
                    mqtt_url += hs;
                }
            }

            // Filter on relevant OTA topics only psm[mqtt_url]=[wa.applianceconnect.net]
            if (data.ContentAsString.StartsWith("psm") && data.ContentAsString.Contains("mqtt_org"))
            {
                //MQTT data in the Trace just comes as raw hex regardless of message format, so need to convert it to ASCII to get the payload
                string[] parts = data.ContentAsString.Replace("[", "").Split('=');
                org_id = "";
                for (int i = 0; i < parts[1].Length - 1; i++)
                {
                    string hs = parts[1].Substring(i, 1);
                    org_id += hs;
                }
            }
        }
Beispiel #2
0
        //This command does not come with Lucas's template.  You will have to add it manually.
        public override void parseTraceMessages(ExtendedTracePacket data)
        {
            //base.parseTraceMessages(data);
            if (data.ContentAsString.Contains("linkstate"))
            {
                string s = data.ContentAsString;
                try
                {
                    int linkstate  = int.Parse(s.Substring(s.IndexOf("linkstate") + 10, 1));
                    int claimstate = int.Parse(s.Substring(s.IndexOf("claimed") + 8, 1));
                    lock (lockObj)
                    {
                        iplist.FirstOrDefault(x => x.IPAddress == data.Source.ToString()).LinkState  = linkstate;
                        iplist.FirstOrDefault(x => x.IPAddress == data.Source.ToString()).ClaimState = claimstate;
                    }
                }
                catch { }
            }
            if (data.ContentAsString.StartsWith("mqtt_in_data:"))
            {
                //MQTT data in the Trace just comes as raw hex regardless of message format, so need to conver it to ASCII to get the topic string
                string[] parts = data.ContentAsString.Replace(" ", "").Split(':');
                string   sb    = "";
                for (int i = 0; i < parts[2].Length; i += 2)
                {
                    string hs = parts[2].Substring(i, 2);
                    sb += Convert.ToChar(Convert.ToUInt32(hs, 16));
                }

                //Locate the MQTT Statistics message in the Trace and grab the four wifi reset reason bytes from it
                if (sb.Contains("\"statistics\": \""))
                {
                    try
                    {
                        sb = sb.Replace("\"statistics\": \"", "@");
                        string[] stats       = sb.Split('@');
                        string[] wifireset   = stats[1].Split(',');
                        string   resetreason = "";
                        for (int j = 0; j < 4; j++)
                        {
                            resetreason += wifireset[j] + (j == 3 ? "" : ";");
                        }
                        lock (lockObj)
                        {
                            iplist.FirstOrDefault(x => x.IPAddress == data.Source.ToString()).WifiResyncStatistics = resetreason;
                        }
                    }
                    catch { }
                }
            }
        }
Beispiel #3
0
 public override void parseTraceMessages(ExtendedTracePacket data)
 {
 }