コード例 #1
0
 private static void InitializeRadio()
 {
     _radio = new NRF24L01Plus();
     _radio.Initialize(Spi, ChipSelectPin, ChipEnablePin, InterruptPin);
     _radio.Configure(Encoding.UTF8.GetBytes(Address), Channel);
     _radio.Enable();
 }
コード例 #2
0
        public void Start()
        {
            /* This code assumes a pin configuration as follows:
             *
             * nRF24    ->  Netduino 2  Purpose
             * --------     ----------  --------------
             *  1 (GND) ->  GND         Ground
             *  2 (VCC) ->  3V3         3v Power
             *  3 (CE)  ->  D9          Chip Enable
             *  4 (CSN) ->  D10         Chip Select
             *  5 (SCK) ->  D13         SPI Serial Clock (SCLK)
             *  6 (MOSI)->  D11         SPI Transmit (MOSI)
             *  7 (MISO)->  D12         SPI Recieve (MISO)
             *  8 (IRQ) ->  D8          Interupt              *
             */

            // Initialize the radio on our pins
            _radio.Initialize(SPI_Devices.SPI1, Pins.GPIO_PIN_D10, Pins.GPIO_PIN_D9, Pins.GPIO_PIN_D8);
            _radio.Configure(new byte[] { 0xF5, 0xF0, 0xF0, 0xF0, 0xF2 }, 76, NRFDataRate.DR1Mbps);
            _radio.OnDataReceived += _radio_OnDataReceived;
            _radio.Enable();

            Debug.Print("Listening on: " +
                        ByteArrayToHexString(_radio.GetAddress(AddressSlot.Zero, 5)) + " | " +
                        ByteArrayToHexString(_radio.GetAddress(AddressSlot.One, 5)) + " | " +
                        ByteArrayToHexString(_radio.GetAddress(AddressSlot.Two, 5)) + " | " +
                        ByteArrayToHexString(_radio.GetAddress(AddressSlot.Three, 5)) + " | " +
                        ByteArrayToHexString(_radio.GetAddress(AddressSlot.Four, 5)) + " | " +
                        ByteArrayToHexString(_radio.GetAddress(AddressSlot.Five, 5)));

            _timer = new Timer(TimerFire, null, new TimeSpan(0, 0, 0, 10), new TimeSpan(0, 0, 0, 3));
        }
コード例 #3
0
 private static void InitializeRadio()
 {
     Debug.Print("Initializing radio...");
     _radio = new NRF24L01Plus();
     _radio.Initialize(Spi, ChipSelectPin, ChipEnablePin, InterruptPin);
     _radio.Configure(Encoding.UTF8.GetBytes(Address), Channel);
     _radio.OnDataReceived += data => _bootloader.Process(data);
     _radio.Enable();
 }
コード例 #4
0
        public static void Main()
        {
            count = 0;

            oled.Inital();
            Thread.Sleep(100);
            oled.DisplayString("***");
            globalSPIDevice.Config = nrf24L01PConfig;



            _radio.Initialize();

//TX
            //    _radio.Configure(new byte[] { 138, 138, 138 }, 76, NRFDataRate.DR1Mbps);
            //   _radio.SetAddress(AddressSlot.One, new  byte[] { 0, 0, 1 });

//RX
            _radio.Configure(new byte[] { 0xF0, 0xF0, 0xE1 }, 76, NRFDataRate.DR1Mbps);
            _radio.SetAddress(AddressSlot.One, new byte[] { 0, 0, 2 });
            _radio.OnDataReceived += _radio_OnDataReceived;
            _radio.Enable();



            string outputinfo = "Listening on: " +
                                ByteArrayToHexString(_radio.GetAddress(AddressSlot.Zero, 3)) + " | " +
                                ByteArrayToHexString(_radio.GetAddress(AddressSlot.One, 3)) + " | " +
                                ByteArrayToHexString(_radio.GetAddress(AddressSlot.Two, 3)) + " | " +
                                ByteArrayToHexString(_radio.GetAddress(AddressSlot.Three, 3)) + " | " +
                                ByteArrayToHexString(_radio.GetAddress(AddressSlot.Four, 3)) + " | " +
                                ByteArrayToHexString(_radio.GetAddress(AddressSlot.Five, 3));

            Debug.Print(outputinfo);


            //TX
            //     _timer = new Timer(TimerFire, null, new TimeSpan(0, 0, 0, 2), new TimeSpan(0, 0, 0,5));


            globalSPIDevice.Config = oledSpiConfig;
            oled.DisplayString(outputinfo);
            Thread.Sleep(50);
            globalSPIDevice.Config = nrf24L01PConfig;



            Thread.Sleep(Timeout.Infinite);

            /*
             *
             *          globalSPIDevice.Config = oledSpiConfig;
             *          oled.DisplayString("Receiving ---");
             *          Thread.Sleep(100);
             *          globalSPIDevice.Config = nrf24L01PConfig;
             */
        }
コード例 #5
0
        public void Run()
        {
            // Configure the nRF24 hardware
            radio.OnDataReceived    += OnReceive;
            radio.OnTransmitFailed  += OnSendFailure;
            radio.OnTransmitSuccess += OnSendSuccess;

            radio.Initialize(SPI.SPI_module.SPI1, Pins.GPIO_PIN_D7, Pins.GPIO_PIN_D3, Pins.GPIO_PIN_D2);
            radio.Configure(nRF24ClientAddress, nRF24Channel, nRF24DataRate);
            radio.Enable();

            // Setup the device unique identifer, in this case the hardware MacAddress
            deviceIdentifier = NetworkInterface.GetAllNetworkInterfaces()[0].PhysicalAddress;
            Debug.Print(" Device Identifier : " + BytesToHexString(deviceIdentifier));

            Timer humidityAndtemperatureUpdates = new Timer(HumidityAndTemperatureTimerProc, null, 15000, 15000);

            Thread.Sleep(Timeout.Infinite);
        }