Exemple #1
0
 public Leds()
 {
     ledRed = new Led(CC2420Pins.GPIO_PORT_LED_RED);
     ledGreen = new Led(CC2420Pins.GPIO_PORT_LED_GREEN);
     ledBlue = new Led(CC2420Pins.GPIO_PORT_LED_BLUE);
 }
Exemple #2
0
        public void Run(AutoResetEvent stopEvent)
        {
            UInt64 extAddr;
            _net.GetDeviceAddress(out extAddr);
            _monitor.Print("Device address is 0x" + HexConverter.ConvertUint64ToHex(extAddr, 16));

            _monitor.Print("Frame structure: mtu=" + _mtu +
                ", head=" + _head +
                ", tail=" + _tail);

            UInt16 panId = 0x6366;

            AutoResetEvent callback = new AutoResetEvent(false);
            bool started = false;
            UInt16 shortAddr = 0;
            Byte logicalChannel = 0;
            Byte channelPage = 0;

#if MICROFRAMEWORK
            Led led = new Led((Cpu.Pin)47); // VK_MENU - pin = MC9328MXL_GPIO::c_Port_B_15;
            led.enabled = true;
#endif

#if MICROFRAMEWORK
            _coordinator = false;
#else
            _coordinator = true;
#endif

            _monitor.Print("attempting to start network layer");
            while (!started)
            {
                if (_coordinator)
                {
                    _monitor.Print("StartRequest for PanId=0x" + HexConverter.ConvertUint64ToHex(panId, 4));
                    _net.StartRequest(panId, delegate(
                        object sender,
                        Status status,
                        UInt16 _shortAddr,
                        Byte _logicalChannel,
                        Byte _channelPage)
                    {
                        _monitor.Print("StartConfirm: " + status.ToString());
                        if (status == Status.Success)
                        {
                            shortAddr = _shortAddr;
                            logicalChannel = _logicalChannel;
                            channelPage = _channelPage;
                            started = true;
                        }

                        callback.Set();
                    });
                }
                else
                {
                    _monitor.Print("JoinRequest for PanId=0x" + HexConverter.ConvertUint64ToHex(panId, 4));
                    _net.JoinRequest(panId, delegate(
                        object sender,
                        Status status,
                        UInt16 _shortAddr,
                        Byte _logicalChannel,
                        Byte _channelPage)
                    {
                        _monitor.Print("JoinConfirm: " + status.ToString());
                        if (status == Status.Success)
                        {
                            shortAddr = _shortAddr;
                            logicalChannel = _logicalChannel;
                            channelPage = _channelPage;
                            started = true;
                        }

                        callback.Set();
                    });
                }

                callback.WaitOne();
            }

            _monitor.Print("network is running, logicalChannel=" + logicalChannel +
                ", channelPage=" + channelPage +
                ", shortAddr=0x" + HexConverter.ConvertUintToHex(shortAddr, 4));
#if MICROFRAMEWORK
            led.enabled = false;
#endif
            _testMode = true;

            StartSink();
            if (_coordinator)
                StartSource();

            if (stopEvent != null)
            {
                stopEvent.WaitOne();
            }
            else
            {
                for (; ; )
                {
                    Thread.Sleep(60 * 1000);
                }
            }

            StopSource();
            StopSink();
        }
Exemple #3
0
 public Leds()
 {
     ledRed   = new Led(CC2420Pins.GPIO_PORT_LED_RED);
     ledGreen = new Led(CC2420Pins.GPIO_PORT_LED_GREEN);
     ledBlue  = new Led(CC2420Pins.GPIO_PORT_LED_BLUE);
 }