Пример #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
        /// <summary>
        /// Gadgeteer Nordic NRF24L01+ module.
        /// </summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public Nordic(int socketNumber)
        {
            var socket = Socket.GetSocket(socketNumber, true, this, null);

            Api = new NRF24L01Plus();
            Api.Initialize(socket.SPIModule, socket.CpuPins[6], socket.CpuPins[4], socket.CpuPins[3]);
            Api.OnDataReceived    += OnDataReceived;
            Api.OnTransmitFailed  += OnTransmitFailed;
            Api.OnTransmitSuccess += OnTransmitSuccess;
        }
        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);
        }
        static void Main(string[] args)
        {
            SPI           SPIport = new Microsoft.SPOT.Hardware.SPI(new Microsoft.SPOT.Hardware.SPI.Configuration(Cpu.Pin.GPIO_NONE, false, 0, 0, false, true, 2000, SPI.SPI_module.SPI1));
            OutputPort    nCE     = new OutputPort(Cpu.Pin.GPIO_Pin2, true);
            InterruptPort nINT    = new InterruptPort(Cpu.Pin.GPIO_Pin4, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow);

            NRF24L01Plus n = new NRF24L01Plus();

            n.Initialize(SPIport, nCE, nINT);

            byte[] address = n.GetAddress(AddressSlot.Zero, 5);
            Console.WriteLine("First Address: " + ByteArrayToHexString(address));

            byte[] b = new byte[] { 0x04, 0x09, 0x02, 0x03, 0x04 };
            n.SetAddress(AddressSlot.Zero, b, false);

            address = n.GetAddress(AddressSlot.Zero, 5);
            Console.WriteLine("Second Address: " + ByteArrayToHexString(address));

            nCE.Dispose();
            nINT.Dispose();
        }