public override void Parse() { FrameId = (byte) parser.ReadByte(); Source = new XBeeNode { Address64 = parser.ReadAddress64(), Address16 = parser.ReadAddress16() }; Command = parser.ReadATCommand(); CommandStatus = (CommandStatusType) parser.ReadByte(); if (Command == AT.NodeDiscover) ParseNetworkDiscovery(); var type = ((ATAttribute)Command.GetAttr()).ValueType; if ((type != ATValueType.None) && parser.HasMoreData()) { switch (type) { case ATValueType.Number: var vData = parser.ReadData(); Value = new ATLongValue().FromByteArray(vData); break; case ATValueType.HexString: var hexData = parser.ReadData(); Value = new ATStringValue(ByteUtils.ToBase16(hexData)); break; case ATValueType.String: var str = parser.ReadData(); Value = new ATStringValue(Encoding.UTF8.GetString(str)); break; } } }
public void TestTransmitDataRequestBroadcastRadius() { var broadcast = new XBeeNode { Address16 = XBeeAddress16.ZNET_BROADCAST, Address64 = XBeeAddress64.BROADCAST }; var frame = new TransmitDataRequest(broadcast) { BroadcastRadius = 2 }; Assert.AreEqual(new byte[] { 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFE, 0x02, 0x00 }, frame.ToByteArray()); }
public CreateSourceRoute(XBeeNode destination) { CommandId = XBeeAPICommandId.CREATE_SOURCE_ROUTE; this.destination = destination; RouteOptions = 0x00; FrameId = 0x00; }
public void TestRemoteATCommandNodeDiscovery() { var broadcast = new XBeeNode { Address16 = XBeeAddress16.ZNET_BROADCAST, Address64 = XBeeAddress64.BROADCAST }; var cmd = new RemoteATCommand(AT.NodeDiscover, broadcast) { FrameId = 1 }; Assert.AreEqual(new byte[] { 0x17, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, (byte) 'N', (byte) 'D' }, cmd.ToByteArray()); }
public override void Parse() { Source = new XBeeNode { Address64 = parser.ReadAddress64(), Address16 = parser.ReadAddress16() }; ReceiveOptions = (ReceiveOptionsType) parser.ReadByte(); BootloaderMessage = (BootloaderMessageType) parser.ReadByte(); BlockNumber = parser.ReadByte(); Target = parser.ReadAddress64(); }
public void TestCreateSourceRoute() { var dest = new XBeeNode { Address16 = new XBeeAddress16(0x3344), Address64 = new XBeeAddress64(0x0013A20040401122) }; var addrList = new List<XBeeAddress16> { new XBeeAddress16(0xEEFF), new XBeeAddress16(0xCCDD), new XBeeAddress16(0xAABB) }; var frame = new CreateSourceRoute(dest) { Hops = addrList }; Assert.That(frame.ToByteArray(), Is.EqualTo(new byte[] { 0x21, 0x00, 0x00, 0x13, 0xA2, 0x00, 0x40, 0x40, 0x11, 0x22, 0x33, 0x44, 0x00, 0x03, 0xEE, 0xFF, 0xCC, 0xDD, 0xAA, 0xBB })); }
public void TestRemoteATCommandDestinationHigh() { var broadcast = new XBeeNode { Address16 = XBeeAddress16.ZNET_BROADCAST, Address64 = XBeeAddress64.BROADCAST }; var cmd = new RemoteATCommand(AT.DestinationHigh, broadcast) { FrameId = 1 }; var v = new ATLongValue(0x11223300); cmd.SetValue(v); Assert.AreEqual(new byte[] { 0x17, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, (byte) 'D', (byte) 'H', 0x11, 0x22, 0x33, 0x00 }, cmd.ToByteArray()); }
public override void Parse() { Source = new XBeeNode { Address64 = parser.ReadAddress64(), Address16 = parser.ReadAddress16() }; ReceiveOptions = (ReceiveOptionsType) parser.ReadByte(); Sensors = (SensorType) parser.ReadByte(); for (var i = 0; i < 4; i++) { ADValues[i] = parser.ReadUInt16(); } Temperature = parser.ReadUInt16(); }
public override void Parse() { Source = new XBeeNode { Address64 = parser.ReadAddress64(), Address16 = parser.ReadAddress16() }; SourceEndpoint = (byte?) parser.ReadByte(); DestinationEndpoint = (byte?) parser.ReadByte(); ClusterId = parser.ReadUInt16(); ProfileId = parser.ReadUInt16(); ReceiveOptions = (ReceiveOptionsType) parser.ReadByte(); Data = parser.ReadData(); }
public void TestTransmitDataRequestBroadcastRadiusOptions() { var broadcast = new XBeeNode { Address16 = XBeeAddress16.ZNET_BROADCAST, Address64 = XBeeAddress64.BROADCAST }; var frame = new TransmitDataRequest(broadcast) { BroadcastRadius = 2, Options = TransmitDataRequest.OptionValues.DisableAck | TransmitDataRequest.OptionValues.ExtendedTimeout }; Assert.AreEqual(new byte[] { 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFE, 0x02, 0x41 }, frame.ToByteArray()); }
public override void Parse() { Source = new XBeeNode { Address64 = parser.ReadAddress64(), Address16 = parser.ReadAddress16() }; ReceiveOptions = (ReceiveOptionsType)parser.ReadByte(); NumberOfHops = parser.ReadByte(); var list = new List<XBeeAddress16>(); for (var i = 0; i < NumberOfHops; i++) { var hop = parser.ReadAddress16(); list.Add(hop); } Addresses = list; }
public override void Parse() { FrameId = (byte) parser.ReadByte(); Destination = new XBeeNode { Address64 = parser.ReadAddress64(), Address16 = parser.ReadAddress16() }; RemoteOptions = (byte) parser.ReadByte(); Command = parser.ReadATCommand(); if (parser.HasMoreData()) { Console.WriteLine("TODO: has data!"); } }
public ExplicitAddressingTransmit(XBeeNode destination) { CommandId = XBeeAPICommandId.EXPLICIT_ADDR_REQUEST; this.destination = destination; BroadcastRadius = 0; Options = 0; SourceEndpoint = null; DestinationEndpoint = null; ClusterId = null; ProfileId = null; rfData = null; }
public void TestExplicitAddressingRequestBroadcastRadiusOptions() { var broadcast = new XBeeNode { Address16 = XBeeAddress16.ZNET_BROADCAST, Address64 = XBeeAddress64.BROADCAST }; var frame = new ExplicitAddressingTransmit(broadcast) { FrameId = 1, BroadcastRadius = 2, Options = ExplicitAddressingTransmit.OptionValues.DisableAck | ExplicitAddressingTransmit.OptionValues.ExtendedTimeout, SourceEndpoint = 0xA0, DestinationEndpoint = 0xA1, ClusterId = 0x1554, ProfileId = 0xC105 }; Assert.AreEqual(new byte[] { 0x11, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFE, 0xA0, 0xA1, 0x15, 0x54, 0xC1, 0x05, 0x02, 0x41 }, frame.ToByteArray()); }
public override void Parse() { FrameId = (byte)parser.ReadByte(); Source = new XBeeNode { Address64 = parser.ReadAddress64(), Address16 = parser.ReadAddress16() }; Command = parser.ReadATCommand(); CommandStatus = (CommandStatusType)parser.ReadByte(); if (Command == AT.NodeDiscover) { ParseNetworkDiscovery(); } var type = ((ATAttribute)Command.GetAttr()).ValueType; if ((type != ATValueType.None) && parser.HasMoreData()) { switch (type) { case ATValueType.Number: var vData = parser.ReadData(); Value = new ATLongValue().FromByteArray(vData); break; case ATValueType.HexString: var hexData = parser.ReadData(); Value = new ATStringValue(ByteUtils.ToBase16(hexData)); break; case ATValueType.String: var str = parser.ReadData(); Value = new ATStringValue(Encoding.UTF8.GetString(str)); break; } } }
public void TestExplicitAddressingRequestMissingProfile() { var broadcast = new XBeeNode { Address16 = XBeeAddress16.ZNET_BROADCAST, Address64 = XBeeAddress64.BROADCAST }; var frame = new ExplicitAddressingTransmit(broadcast) { FrameId = 1, BroadcastRadius = 2, Options = ExplicitAddressingTransmit.OptionValues.DisableAck | ExplicitAddressingTransmit.OptionValues.ExtendedTimeout, SourceEndpoint = 0xA0, DestinationEndpoint = 0xA1, ClusterId = 0x1554 }; frame.SetRFData(new byte[] { 0x11, 0x22, 0x33, 0x00 }); Assert.AreEqual(new byte[] { 0x11, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFE, 0xA0, 0xA1, 0x15, 0x54, 0xC1, 0x05, 0x02, 0x41, 0x11, 0x22, 0x33, 0x00 }, frame.ToByteArray()); }
public override void Parse() { destination = new XBeeNode { Address64 = parser.ReadAddress64(), Address16 = parser.ReadAddress16() }; }
public RemoteATCommand(AT command, XBeeNode destination) { CommandId = XBeeAPICommandId.REMOTE_AT_COMMAND_REQUEST; Command = command; Destination = destination; }
public TimerCallbackObject(XBee.XBee bee, XBeeNode node) { this.bee = bee; this.node = node; }
public void MainForm_NodeComesDown(XBeeAPIPort sender, XBeeNode node) { var d = Devices.i().Find(node.IMEI()); RemoveDevice(d); }
public override void Parse() { Source = new XBeeNode { Address64 = parser.ReadAddress64(), Address16 = parser.ReadAddress16() }; ReceiveOptions = (ReceiveOptionsType) parser.ReadByte(); Data = parser.ReadData(); }
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; }
public override void Parse() { FrameId = (byte) parser.ReadByte(); destination = new XBeeNode { Address64 = parser.ReadAddress64(), Address16 = parser.ReadAddress16() }; SourceEndpoint = (byte?) parser.ReadByte(); DestinationEndpoint = (byte?) parser.ReadByte(); ClusterId = parser.ReadUInt16(); ProfileId = parser.ReadUInt16(); BroadcastRadius = (byte) parser.ReadByte(); Options = (OptionValues) parser.ReadByte(); if (parser.HasMoreData()) { Console.WriteLine("TODO: has data!"); } }
public override void Parse() { Source = new XBeeNode {Address64 = parser.ReadAddress64(), Address16 = parser.ReadAddress16()}; reserved = parser.ReadByte(); }