public static XBeeAddress64 Read(XBeeApi sender, XBeeAddress remoteXbee) { var sh = sender.Send(AtCmd.SerialNumberHigh).To(remoteXbee).GetResponse(); var sl = sender.Send(AtCmd.SerialNumberLow).To(remoteXbee).GetResponse(); return(Parse((AtResponse)sl, (AtResponse)sh)); }
protected void NotifyDataReceived(byte[] payload, XBeeAddress sender) { if (DataReceived != null) { DataReceived(this, payload, sender); } }
public static void Write(XBeeApi sender, XBeeAddress remoteXbee, ApiModes mode) { var request = sender.Send(AtCmd.ApiEnable, new[] {(byte) mode}).To(remoteXbee); var response = (AtResponse) request.GetResponse(); if (!response.IsOk) throw new XBeeException("Failed to write api mode"); }
public static void Write(XBeeApi sender, XBeeAddress remoteXbee, string nodeIdentifier) { var value = Arrays.ToByteArray(nodeIdentifier, 0, MaxNodeIdentifierLength); var request = sender.Send(AtCmd.NodeIdentifier, value).To(remoteXbee); var response = (AtResponse) request.GetResponse(); if (!response.IsOk) throw new XBeeException("Failed to write node identifier"); }
public static void Write(XBeeApi sender, XBeeAddress remoteXbee, ApiModes mode) { var request = sender.Send(AtCmd.ApiEnable, new[] { (byte)mode }).To(remoteXbee); var response = (AtResponse)request.GetResponse(); if (!response.IsOk) { throw new XBeeException("Failed to write api mode"); } }
public static void Write(XBeeApi sender, XBeeAddress remoteXbee, string nodeIdentifier) { var value = Arrays.ToByteArray(nodeIdentifier, 0, MaxNodeIdentifierLength); var request = sender.Send(AtCmd.NodeIdentifier, value).To(remoteXbee); var response = (AtResponse)request.GetResponse(); if (!response.IsOk) { throw new XBeeException("Failed to write node identifier"); } }
protected XBeeAddress16 GetNetworkAddress(XBeeAddress serialAddress) { if (!(serialAddress is XBeeAddress64)) { throw new ArgumentException(); } return(_addressLookupEnabled && AddressLookup.Contains(serialAddress) ? (XBeeAddress16)AddressLookup[serialAddress] : XBeeAddress16.Unknown); }
/// <summary> /// Reads remote module basic information /// </summary> /// <param name="sender">XBee module that will send AT command to remote target</param> /// <param name="remoteXbee">XBee module which infomation will be retrieved</param> /// <returns>Remote XBee basic infomation</returns> public static XBeeConfiguration Read(XBeeApi sender, XBeeAddress remoteXbee) { return new XBeeConfiguration(sender, remoteXbee) { ApiMode = Common.ApiMode.Read(sender, remoteXbee), HardwareVersion = Common.HardwareVersion.Read(sender, remoteXbee), Firmware = Common.Firmware.Read(sender, remoteXbee), SerialNumber = Common.SerialNumber.Read(sender, remoteXbee), NodeIdentifier = Common.NodeIdentifier.Read(sender, remoteXbee) }; }
public RemoteAtCommand CreateRequest(ushort atCommand, XBeeAddress destination, params byte[] value) { if (destination is XBeeAddress16) { throw new ArgumentException("64 bit address expected", "destination"); } return(new RemoteAtCommand(atCommand, (XBeeAddress64)destination, GetNetworkAddress(destination), value) { FrameId = _idGenerator.GetNext() }); }
public TxRequest(XBeeAddress destination, byte[] payload) : this(payload) { if (destination is XBeeAddress16) { DestinationSerial = XBeeAddress64.Broadcast; DestinationAddress = (XBeeAddress16)destination; } else { DestinationSerial = (XBeeAddress64)destination; DestinationAddress = XBeeAddress16.Unknown; } }
public ExplicitTxRequest(XBeeAddress destination, byte[] payload, byte srcEndpoint, byte destEndpoint, ushort clusterId, ushort profileId) : this(payload, srcEndpoint, destEndpoint, clusterId, profileId) { if (destination is XBeeAddress16) { DestinationSerial = XBeeAddress64.Broadcast; DestinationAddress = (XBeeAddress16)destination; } else { DestinationSerial = (XBeeAddress64)destination; DestinationAddress = XBeeAddress16.Unknown; } }
public TxRequest(XBeeAddress destination, byte[] payload) : this(payload) { if (destination is XBeeAddress16) { DestinationSerial = XBeeAddress64.Broadcast; DestinationAddress = (XBeeAddress16) destination; } else { DestinationSerial = (XBeeAddress64) destination; DestinationAddress = XBeeAddress16.Unknown; } }
private static void OnDataReceived(XBeeApi receiver, byte[] data, XBeeAddress sender) { var dataStr = new string(Encoding.UTF8.GetChars(data)); switch (dataStr) { case Ping: receiver.Send(Pong).To(sender).NoResponse(); break; case Pong: Debug.Print("Received Pong from " + sender); break; } }
private static void OnDataReceived(XBeeApi receiver, byte[] data, XBeeAddress sender) { var dataStr = new string(Encoding.UTF8.GetChars(data)); switch (dataStr) { case Ping: receiver.Send(Pong).To(sender).NoResponse(); break; case Pong: Debug.Print("Received Pong from " + sender); break; } }
public XBeeRequest CreateRequest(byte[] payload, XBeeAddress destination) { if (Config.IsSeries1()) { return new TxRequest(destination, payload) { FrameId = _idGenerator.GetNext() } } ; if (!(destination is XBeeAddress64) || destination == null) { throw new ArgumentException("64 bit address expected", "destination"); } return(new Api.Zigbee.TxRequest((XBeeAddress64)destination, GetNetworkAddress(destination), payload) { FrameId = _idGenerator.GetNext() }); }
public static string Read(XBeeApi sender, XBeeAddress remoteXbee) { var request = sender.Send(AtCmd.NodeIdentifier).To(remoteXbee); return Parse((AtResponse) request.GetResponse()); }
public IRequest To(ushort networkAddress) { DestinationAddress = new XBeeAddress16(networkAddress); return this; }
// Creating requests public XBeeRequest CreateRequest(string payload, XBeeAddress destination) { return(CreateRequest(Arrays.ToByteArray(payload), destination)); }
public static ApiModes Read(XBeeApi sender, XBeeAddress remoteXbee) { var request = sender.Send(AtCmd.ApiEnable).To(remoteXbee); return Parse((AtResponse) request.GetResponse()); }
public IRequest To(ulong serialNumber) { DestinationAddress = new XBeeAddress64(serialNumber); return this; }
public IRequest To(XBeeAddress destination) { DestinationAddress = destination; return this; }
/// <summary> /// TODO: Update Comments /// /// </summary> /// <param name="sender" type="NETMF.OpenSource.XBee.Api.XBee"> /// <para> /// /// </para> /// </param> /// <param name="remoteXbee" type="NETMF.OpenSource.XBee.Api.XBeeAddress"> /// <para> /// /// </para> /// </param> public static void Write(XBeeApi sender, XBeeAddress remoteXbee) { var request = sender.Send(AtCmd.Write).To(remoteXbee); Parse((AtResponse) request.GetResponse()); }
public static ApiModes Read(XBeeApi sender, XBeeAddress remoteXbee) { var request = sender.Send(AtCmd.ApiEnable).To(remoteXbee); return(Parse((AtResponse)request.GetResponse())); }
public TxRequest(XBeeAddress destination, byte[] payload, Options option = Options.Unicast) { Destination = destination; Payload = payload; Option = option; }
public static XBeeAddress64 Read(XBeeApi sender, XBeeAddress remoteXbee) { var sh = sender.Send(AtCmd.SerialNumberHigh).To(remoteXbee).GetResponse(); var sl = sender.Send(AtCmd.SerialNumberLow).To(remoteXbee).GetResponse(); return Parse((AtResponse)sl, (AtResponse)sh); }
public IRequest ToAll() { DestinationAddress = XBeeAddress64.Broadcast; return this; }
public TxRequest(XBeeAddress destination, byte[] payload, Options option = Options.Unicast) { Destination = destination; Payload = payload; Option = option; }
private XBeeConfiguration(XBeeApi xbee, XBeeAddress remoteXbee = null) { _xbee = xbee; _remoteXbee = remoteXbee; }
protected void Init() { ExpectedResponse = Response.Single; TimeoutValue = PacketParser.DefaultParseTimeout; DestinationAddress = null; DestinationNode = null; Filter = null; }
public static HardwareVersions Read(XBeeApi sender, XBeeAddress remoteXBee) { var request = sender.Send(AtCmd.HardwareVersion).To(remoteXBee); return(Parse((AtResponse)request.GetResponse())); }
protected XBeeAddress16 GetNetworkAddress(XBeeAddress serialAddress) { if (!(serialAddress is XBeeAddress64)) throw new ArgumentException(); return _addressLookupEnabled && AddressLookup.Contains(serialAddress) ? (XBeeAddress16)AddressLookup[serialAddress] : XBeeAddress16.Unknown; }
protected void NotifyDataReceived(byte[] payload, XBeeAddress sender) { if (DataReceived != null) DataReceived(this, payload, sender); }
/// <summary> /// TODO: Update Comments /// /// </summary> /// <param name="sender" type="NETMF.OpenSource.XBee.Api.XBee"> /// <para> /// /// </para> /// </param> /// <param name="remoteXbee" type="NETMF.OpenSource.XBee.Api.XBeeAddress"> /// <para> /// /// </para> /// </param> public static void Write(XBeeApi sender, XBeeAddress remoteXbee) { var request = sender.Send(AtCmd.Write).To(remoteXbee); Parse((AtResponse)request.GetResponse()); }
// Creating requests public XBeeRequest CreateRequest(string payload, XBeeAddress destination) { return CreateRequest(Arrays.ToByteArray(payload), destination); }
public XBeeRequest CreateRequest(byte[] payload, XBeeAddress destination) { if (Config.IsSeries1()) return new TxRequest(destination, payload) {FrameId = _idGenerator.GetNext()}; if (!(destination is XBeeAddress64) || destination == null) throw new ArgumentException("64 bit address expected", "destination"); return new Api.Zigbee.TxRequest((XBeeAddress64)destination, GetNetworkAddress(destination), payload) { FrameId = _idGenerator.GetNext() }; }
public static string Read(XBeeApi sender, XBeeAddress remoteXbee) { var request = sender.Send(AtCmd.NodeIdentifier).To(remoteXbee); return(Parse((AtResponse)request.GetResponse())); }
public RemoteAtCommand CreateRequest(ushort atCommand, XBeeAddress destination, params byte[] value) { if (destination is XBeeAddress16) throw new ArgumentException("64 bit address expected", "destination"); return new RemoteAtCommand(atCommand, (XBeeAddress64) destination, GetNetworkAddress(destination), value) { FrameId = _idGenerator.GetNext() }; }
public static string Read(XBeeApi sender, XBeeAddress remoteXbee) { var request = sender.Send(AtCmd.FirmwareVersion).To(remoteXbee); return Parse((AtResponse) request.GetResponse()); }
public void Receive(byte[] source_buffer, int size, XBeeAddress addr) { try { var ret = Codes.DecodeErrors.NoError; var instance_buffer = new byte[size]; Array.Copy(source_buffer, instance_buffer, size); var pdu = CODEC.Decode(instance_buffer, ref ret); if (pdu == null || ret != Codes.DecodeErrors.NoError) { STrace.Debug(GetType().FullName, String.Format("XBEE: Error la PDU no se pudo decodificar reason={0}", ret)); return; } pdu.Transporte = this; pdu.Destino = new Destino { XBee = addr }; var d = Devices.I().FindById(pdu.IdDispositivo); var devlog = (d != null ? d.LogId : "?"); var myData = Thread.GetNamedDataSlot("device"); Thread.SetData(myData, d); STrace.Debug(GetType().FullName, pdu.Trace("")); if (d != null) { d.Trace(); } if (d != null && d.State == DeviceTypes.States.ONNET) { d.Transporte = this; d.Touch(pdu.Destino); } else if (d != null) { if ((Codes.HighCommand)pdu.CH != Codes.HighCommand.LoginRequest) { // si el dispositivo no esta registrado, entonces enviamos // mensaje de registracion requerida. STrace.Debug(GetType().FullName, String.Format("DEVICE[{0}]/XBEE: Enviando Login requerido", devlog)); var rta = new PDU { IdDispositivo = pdu.IdDispositivo, Seq = pdu.Seq, Options = pdu.Options, Destino = pdu.Destino, CH = ((byte)Codes.HighCommand.LoginRequerido), CL = 0x00 }; Send(rta); Thread.SetData(myData, null); return; } } var t = ObtenerTransaccion(pdu.IdTransaccion); if (t == null) { if (pdu.CH < 0x80) { STrace.Debug(GetType().FullName, String.Format("DEVICE[{0}]/XBEE: Nueva Transaccion Entrante CH={1} Seq={2}", devlog, pdu.CH, pdu.Seq)); var mrs = new MRS(pdu, this, TransactionUser); if (d != null && d.HackBugXBEEv99) { d.Transporte = this; } NuevaTransaccion(mrs, pdu); mrs.Start(); } else { STrace.Debug(GetType().FullName, String.Format("DEVICE[{0}]/XBEE: RTA HUERFANA CH={1}", devlog, pdu.CH)); } } else { STrace.Debug(GetType().FullName, String.Format("DEVICE[{0}]/XBEE: Recivo Retransmision CH={1} Seq={2}", devlog, pdu.CH, pdu.Seq)); t.RecibePDU(pdu); } } catch (Exception e) { STrace.Exception(GetType().FullName, e); } }