Example #1
0
        private void port_PDURecibida(XBeeAPIPort sender, XBeePDU pdu)
        {
            // loopback
            if (pdu.Data[0] != 0xC4)
            {
                Stats._frames_received_errors++;
                return;
            }

            Stats._frames_received++;
            Stats._pong_frames_received++;
            Stats._0_test_in_bytes_recv += pdu.Data.GetLength(0);

            // ancho de banda entrante efectivo
            var now = DateTime.Now;

            if (last_active_second != now.Second)
            {
                Stats._0_efective_incomming_bps = active_second_bytes * 8;
                active_second_bytes             = 0;
            }
            last_active_second   = now.Second;
            active_second_bytes += pdu.Data.GetLength(0);

            if (last_active_minute != now.Minute)
            {
                Stats._0_1_minute_avg_incomming_bps = active_minute_bytes * 8 / 60;
                active_minute_bytes = 0;
            }
            last_active_minute   = now.Minute;
            active_minute_bytes += pdu.Data.GetLength(0);
        }
Example #2
0
        private void port_HardwareStatus(XBeeAPIPort sender, XBeePDU pdu)
        {
            var msg = "";

            if (pdu.HWStatus == 0)
            {
                msg = String.Format("{0} Hardware Reset", DateTime.Now);
            }
            if (pdu.HWStatus == 1)
            {
                msg = String.Format("{0} Watchdog Timer Reset", DateTime.Now);
            }
            if (pdu.HWStatus == 2)
            {
                msg = String.Format("{0} Associated", DateTime.Now);
            }
            if (pdu.HWStatus == 3)
            {
                msg = String.Format("{0} Disassociated", DateTime.Now);
            }
            if (pdu.HWStatus == 4)
            {
                msg = String.Format("{0} Sync lost", DateTime.Now);
            }
            if (pdu.HWStatus == 5)
            {
                msg = String.Format("{0} Coordinator realignment", DateTime.Now);
            }
            if (pdu.HWStatus == 6)
            {
                msg = String.Format("{0} Coordinator started", DateTime.Now);
            }
            if (pdu.HWStatus > 6)
            {
                msg = "Codigo de estado de HW desconocido.";
            }
            log.Items.Insert(0, msg);
        }
Example #3
0
        internal void PDURecibida(XBeeAPIPort uart, XBeePDU pdu)
        {
            STrace.Debug(typeof(XBeeRadioLinkProtocol).FullName, String.Format("XBEE-PDU: code={0:X}", pdu.Data[0]));
            switch (pdu.Data[0])
            {
            case (byte)FrameType.STATUS_REPORT:
            {
                var pos  = 1;
                var node = XBeeAPIPort.FindNode(pdu.Address);
                if (node == null)
                {
                    var addr = String.Format("{0:X}", pdu.Address);
                    var nd   = Devices.I().FindByXbeeAddr(addr);
                    if (nd == null)
                    {
                        return;
                    }
                    var nn = new XBeeNode
                    {
                        Address = pdu.Address,
                        Id      = String.Format("D:{0}", nd.Imei)
                    };
                    nn.Trace("NODO DETECTADO EN CALIENTE:");
                    node = nn;
                }
                XBeeAPIPort.UpdateNode(node);
                var d = Devices.I().FindByImei(node.IMEI());
                if (d == null)
                {
                    STrace.Debug(typeof(XBeeRadioLinkProtocol).FullName, String.Format("XBEERLP: device imei={0} no encontrado.", node.IMEI()));
                    return;
                }

                d.XBeeSession.Report.RadioLinkState     = (XBeeReport.DeviceXbeeMachineStates)UrbetrackCodec.DecodeByte(pdu.Data, ref pos);
                d.XBeeSession.Report.CommCoreState      = (XBeeReport.DeviceSessionMachineStates)UrbetrackCodec.DecodeByte(pdu.Data, ref pos);
                d.XBeeSession.Report.NetworkConnections = UrbetrackCodec.DecodeByte(pdu.Data, ref pos);
                d.XBeeSession.Report.QueryState         = (XBeeReport.QueryStates)UrbetrackCodec.DecodeByte(pdu.Data, ref pos);

                d.XBeeSession.Report.QueryStartSample = UrbetrackCodec.DecodeInteger(pdu.Data, ref pos);
                d.XBeeSession.Report.QueryEndSample   = UrbetrackCodec.DecodeInteger(pdu.Data, ref pos);
                d.XBeeSession.Report.CursorSample     = UrbetrackCodec.DecodeInteger(pdu.Data, ref pos);
                d.XBeeSession.Report.OldestSample     = UrbetrackCodec.DecodeInteger(pdu.Data, ref pos);

                d.XBeeSession.Report.OldestTrackingSample = UrbetrackCodec.DecodeInteger(pdu.Data, ref pos);
                d.XBeeSession.Report.Processed            = UrbetrackCodec.DecodeInteger(pdu.Data, ref pos);
                d.XBeeSession.Report.Empty    = UrbetrackCodec.DecodeInteger(pdu.Data, ref pos);
                d.XBeeSession.Report.Tracking = UrbetrackCodec.DecodeInteger(pdu.Data, ref pos);

                d.XBeeSession.Report.Detailed    = UrbetrackCodec.DecodeInteger(pdu.Data, ref pos);
                d.XBeeSession.Report.Sent        = UrbetrackCodec.DecodeInteger(pdu.Data, ref pos);
                d.XBeeSession.Report.SessionSent = UrbetrackCodec.DecodeInteger(pdu.Data, ref pos);
                d.XBeeSession.Report.Pendings    = UrbetrackCodec.DecodeInteger(pdu.Data, ref pos);

                d.Destino.XBee = new XBeeAddress {
                    Addr = pdu.Address
                };
                STrace.Debug(typeof(XBeeRadioLinkProtocol).FullName, String.Format("XBEERLP: device imei={0} actualizando. {1}/{2}/{3}", node.IMEI(), d.XBeeSession.Report.RadioLinkState, d.XBeeSession.Report.NetworkConnections, d.XBeeSession.Report.QueryState));
                TransporteXBEE.DoReceiveReport(d);
                return;
            }

            case (byte)FrameType.USER_PART:
            {
                var data_size       = pdu.Data.GetLength(0) - 1;
                var instance_buffer = new byte[data_size];
                Array.Copy(pdu.Data, 1, instance_buffer, 0, data_size);
                var node = XBeeAPIPort.FindNode(pdu.Address);
                if (node == null)
                {
                    STrace.Debug(typeof(XBeeRadioLinkProtocol).FullName, String.Format("XBEERLP IGNORANDO NODO {0}", pdu.Address));
                    return;
                }
                XBeeAPIPort.UpdateNode(node);
                var instance_addr = new XBeeAddress {
                    Addr = pdu.Address
                };
                TransporteXBEE.Receive(instance_buffer, data_size, instance_addr);
                return;
            }

            case (byte)FrameType.DISABLE_LINK_RESPONSE:
            {
                var node = XBeeAPIPort.FindNode(pdu.Address);
                if (node == null)
                {
                    return;
                }
                XBeeAPIPort.UpdateNode(node);
                var d = Devices.I().FindByImei(node.IMEI());
                d.XBeeSession.GoesInactive();
                TransporteXBEE.DoReceiveReport(d);
                RemoveTransaction(d);
                break;
            }

            case (byte)FrameType.ENABLE_LINK_RESPONSE:
            {
                var node = XBeeAPIPort.FindNode(pdu.Address);
                if (node == null)
                {
                    return;
                }
                XBeeAPIPort.UpdateNode(node);
                var d = Devices.I().FindByImei(node.IMEI());
                if (!FoundTransaction(d))
                {
                    break;
                }
                d.XBeeSession.GoesActive();
                TransporteXBEE.DoReceiveReport(d);
                RemoveTransaction(d);
                break;
            }

            default:
                STrace.Debug(typeof(XBeeRadioLinkProtocol).FullName, "@@@");
                break;
            }
            return;
        }
Example #4
0
 internal static void HardwareStatus(XBeeAPIPort uart, XBeePDU pdu)
 {
     STrace.Debug(typeof(XBeeRadioLinkProtocol).FullName, "XBEE RLP: Hardware Status Received.");
 }