예제 #1
0
        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");
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
        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");
            }
        }