static void Main(string[] args) { var bee = new XBee {ApiType = ApiTypeValue.Enabled}; bee.SetConnection(new SerialConnection("COM4", 9600)); var request = new ATCommand(AT.ApiEnable) { FrameId = 1 }; var frame = bee.ExecuteQuery(request, 1000); var value = ((ATCommandResponse) frame).Value; Console.WriteLine(String.Format("API type: {0}", ((ATLongValue) value).Value)); request = new ATCommand(AT.BaudRate) { FrameId = 1 }; frame = bee.ExecuteQuery(request, 1000); value = ((ATCommandResponse) frame).Value; Console.WriteLine(String.Format("Baud rate: {0}", ((ATLongValue) value).Value)); request = new ATCommand(AT.MaximumPayloadLenght) { FrameId = 1 }; frame = bee.ExecuteQuery(request, 1000); value = ((ATCommandResponse) frame).Value; Console.WriteLine(String.Format("Maximum Payload is: {0}", ((ATLongValue) value).Value)); request = new ATCommand(AT.FirmwareVersion) { FrameId = 1 }; frame = bee.ExecuteQuery(request, 1000); value = ((ATCommandResponse) frame).Value; Console.WriteLine(String.Format("Firmware Version: {0:X4}", ((ATLongValue) value).Value)); request = new ATCommand(AT.NodeDiscover) { FrameId = 1 }; bee.Execute(request); while (true) { Thread.Sleep(100); } }
public void saveTelemetryPacket(XBee.Frames.ZigBeeReceivePacket packet) { byte[] newline = { (byte)'\n' }; csv.Write(packet.Data, 0, packet.Data.Length); csv.Write(newline, 0, 1); }
protected virtual void Awake() { if (!Instance) { Instance = this; } else { this.gameObject.SetActive(false); return; } radio = new XBee(); if (Spaces.LBE.MachineConfigurationManager.instance != null && portName == "UNASSIGNED") { string strikerConfigPort = Spaces.LBE.MachineConfigurationManager.instance.GetStrikerCOMPort(); if (!string.IsNullOrEmpty(strikerConfigPort)) { portName = strikerConfigPort; } } port = new SerialPort(portName, baudRate) { ReadTimeout = 2, WriteTimeout = 2 }; DebugLog.Log("inputoutput", "StrikerVRConnectionManager.Awake [Configuring Port] port: " + portName + ", rate: " + baudRate); }
public void TestXBeeConnectionAPIEnabled() { var conn = new Mock<IXBeeConnection>(); var xbee = new XBee { ApiType = ApiTypeValue.Enabled }; xbee.SetConnection(conn.Object); conn.Verify(connection => connection.SetPacketReader(It.IsAny<IPacketReader>())); }
public void TestXBeeConnectionNoAPI() { var conn = new Mock<IXBeeConnection>(); var xbee = new XBee(); xbee.SetConnection(conn.Object); conn.Verify(connection => connection.SetPacketReader(It.IsAny<IPacketReader>())); }
public void TestXBeeConnectionNoAPI() { var conn = new Mock <IXBeeConnection>(); var xbee = new XBee(); xbee.SetConnection(conn.Object); conn.Verify(connection => connection.SetPacketReader(It.IsAny <IPacketReader>())); }
public Form1() { InitializeComponent(); xb = new XBee("COM7", 57600); xb.RF_Command_Responce_Received += new XBeeComandResponceReceivedEventHandler(xb_RF_Command_Responce_Received); xb.RF_Data_Received += new XBeeDataReceivedEventHandler(xb_RF_Data_Received); Console.WriteLine("XBee open port status = " + xb.OpenPort()); }
public void TestXBeeConnectionAPIEnabled() { var conn = new Mock <IXBeeConnection>(); var xbee = new XBee { ApiType = ApiTypeValue.Enabled }; xbee.SetConnection(conn.Object); conn.Verify(connection => connection.SetPacketReader(It.IsAny <IPacketReader>())); }
static void Main(string[] args) { var bee = new XBee { ApiType = ApiTypeValue.Enabled }; bee.SetConnection(new SerialConnection("COM4", 9600)); var request = new ATCommand(AT.ApiEnable) { FrameId = 1 }; var frame = bee.ExecuteQuery(request, 1000); var value = ((ATCommandResponse)frame).Value; Console.WriteLine(String.Format("API type: {0}", ((ATLongValue)value).Value)); request = new ATCommand(AT.BaudRate) { FrameId = 1 }; frame = bee.ExecuteQuery(request, 1000); value = ((ATCommandResponse)frame).Value; Console.WriteLine(String.Format("Baud rate: {0}", ((ATLongValue)value).Value)); request = new ATCommand(AT.MaximumPayloadLenght) { FrameId = 1 }; frame = bee.ExecuteQuery(request, 1000); value = ((ATCommandResponse)frame).Value; Console.WriteLine(String.Format("Maximum Payload is: {0}", ((ATLongValue)value).Value)); request = new ATCommand(AT.FirmwareVersion) { FrameId = 1 }; frame = bee.ExecuteQuery(request, 1000); value = ((ATCommandResponse)frame).Value; Console.WriteLine(String.Format("Firmware Version: {0:X4}", ((ATLongValue)value).Value)); request = new ATCommand(AT.NodeDiscover) { FrameId = 1 }; bee.Execute(request); while (true) { Thread.Sleep(100); } }
static void RunModule2() { using (XBee xbee = new XBee("COM4", 9600, ApiType.Enabled)) { xbee.FrameReceived += new FrameReceivedEventHandler(xbee_FrameReceived); xbee.Open(); Thread.Sleep(30 * 1000); xbee.StopReceiveData(); Console.WriteLine("stopped slave"); } }
public void TestXBeeExecuteQuery() { var xbee = new XBee() { ApiType = ApiTypeValue.Enabled }; var conn = new Mock<IXBeeConnection>(); var frame = new Mock<XBeeFrame>(); conn.Setup(connection => connection.Write(It.IsAny<byte[]>())).Callback(() => xbee.FrameReceivedEvent(this, new FrameReceivedArgs(frame.Object))); xbee.SetConnection(conn.Object); var result = xbee.ExecuteQuery(new ATCommand(AT.BaudRate) { FrameId = 1 }); conn.Verify(connection => connection.SetPacketReader(It.IsAny<IPacketReader>())); Assert.That(result, Is.InstanceOf<XBeeFrame>()); }
public static void Main() { using (XBee xbee = new XBee("COM1", 9600)) { xbee.FrameReceived += new FrameReceivedEventHandler(xbee_OnPacketReceived); xbee.Open(); // read power supply xbee.Execute(new SupplyVoltageCommand()); Thread.Sleep(10 * 60 * 1000); } }
public bool SpoolMessage(MailMessage message, out string reply) { reply = null; string subject = message.Subject; if (String.IsNullOrEmpty(subject)) { reply = "Missing subject"; return(false); } string[] parts = subject.Split('|'); if (parts.Length == 0) { reply = "Missing command arguments seperator"; return(false); } if (parts[0] == "NI") { using (XBee xbee = new XBee("COM4", ApiType.Enabled)) { xbee.Open(); XBeeResponse res = xbee.Execute(new NodeIdentifierCommand()); if (res == null) { reply = "Could not execute NI command"; return(false); } AtCommandResponse atr = res as AtCommandResponse; if (atr != null) { NodeIdentifier ni = NodeIdentifier.Parse(atr); if (ni != null) { reply = "XBee module response: " + ni.GetType() + " = " + ni.Identifier; return(false); } } } } return(true); }
public virtual void Send(System.Int16 address, byte[] message) { //TODO: set up a dictionary of XBee.Address refs so we don't have to keep creating them var strikerAddress = new XBee.Address(); var addressBytes = System.BitConverter.GetBytes(address); System.Array.Reverse(addressBytes); strikerAddress.addr16 = addressBytes; var payload = XBee.TXRequest16(strikerAddress, 1, message); port.Write(payload, 0, payload.Length); }
public void TestXBeeConnectionExecute() { var conn = new Mock<IXBeeConnection>(); byte[] result = null; conn.Setup(connection => connection.Write(It.IsAny<byte[]>())).Callback((byte[] b) => result = b); var xbee = new XBee(); xbee.SetConnection(conn.Object); xbee.Execute(new ATCommand(AT.BaudRate) { FrameId = 1 }); conn.Verify(connection => connection.SetPacketReader(It.IsAny<IPacketReader>())); Assert.That(result, Is.EqualTo(new byte[] { 0x7E, 0x00, 0x04, 0x08, 0x01, 0x42, 0x44, 0x70 })); }
void ProgramStarted() { Debug.Print("Program Started"); const string serialPortName = "COM1"; const Cpu.Pin resetPin = FEZCerberus.Pin.PB0; const Cpu.Pin sleepPin = FEZCerberus.Pin.PC13; xbee = new XBee(serialPortName, resetPin, sleepPin) { DebugPrintEnabled = true }; xbee.Api.DiscoverNodes(OnNodeDiscovered); }
public string GetAddress() { if (XBee != null) { return(XBee.ToString()); } if (TCP != null) { return(TCP.ToString()); } if (UDP != null) { return(UDP.ToString()); } return("unset"); }
public void TestXBeeConnectionExecute() { var conn = new Mock <IXBeeConnection>(); byte[] result = null; conn.Setup(connection => connection.Write(It.IsAny <byte[]>())).Callback((byte[] b) => result = b); var xbee = new XBee(); xbee.SetConnection(conn.Object); xbee.Execute(new ATCommand(AT.BaudRate) { FrameId = 1 }); conn.Verify(connection => connection.SetPacketReader(It.IsAny <IPacketReader>())); Assert.That(result, Is.EqualTo(new byte[] { 0x7E, 0x00, 0x04, 0x08, 0x01, 0x42, 0x44, 0x70 })); }
public void Start() { Log($"Starting XBeeMqtt serialPortName={serialPortName} baudRate={baudRate} mqttBrokerHost={mqttBrokerHost} mqttBrokerPort={mqttBrokerPort}"); port = new SerialPort(serialPortName, baudRate); port.DataReceived += Port_DataReceived; port.Open(); bee = new XBee(); bee.setSerial(port); mqttClient = new MqttClient(mqttBrokerHost, mqttBrokerPort, false, null, null, MqttSslProtocols.None); string clientId = Guid.NewGuid().ToString(); mqttClient.Connect(clientId); mqttClient.MqttMsgPublishReceived += MqttClient_MqttMsgPublishReceived; mqttClient.Subscribe(new string[] { "/cmd/TankWaterer/#" }, new byte[] { 0 }); }
public void TestXBeeExecuteQuery() { var xbee = new XBee() { ApiType = ApiTypeValue.Enabled }; var conn = new Mock <IXBeeConnection>(); var frame = new Mock <XBeeFrame>(); conn.Setup(connection => connection.Write(It.IsAny <byte[]>())).Callback(() => xbee.FrameReceivedEvent(this, new FrameReceivedArgs(frame.Object))); xbee.SetConnection(conn.Object); var result = xbee.ExecuteQuery(new ATCommand(AT.BaudRate) { FrameId = 1 }); conn.Verify(connection => connection.SetPacketReader(It.IsAny <IPacketReader>())); Assert.That(result, Is.InstanceOf <XBeeFrame>()); }
static void RunModule1() { using (XBee xbee = new XBee("COM3", 9600, ApiType.Enabled)) { xbee.FrameReceived += new FrameReceivedEventHandler(xbee_FrameReceived); xbee.Open(); // discovering the network AtCommand at = new NodeDiscoverCommand(); xbee.Execute(at); Thread.Sleep(10 * 1000); xbee.Execute(at); Thread.Sleep(10 * 1000); xbee.StopReceiveData(); Console.WriteLine("stopped master"); } }
public void Init(string comPort, ApiType apiType = ApiType.EnabledWithEscaped) { if (m_FirstTime) { m_XBee = new XBee(comPort, m_BaudRate, apiType); m_XBee.FrameReceived += new FrameReceivedEventHandler(m_XBee_FrameReceived); m_FirstTime = false; //m_XBee2 = new XBee("COM10", m_BaudRate, apiType); //m_XBee2.FrameReceived += new FrameReceivedEventHandler(m_XBee_FrameReceived2); //m_XBee2.Open(); } }