Example #1
0
/* Send data using the nRF radio */
void radioTask(void *pvParameters)
{
	(void) pvParameters;
	uint8_t rfData[NRF24_PAYLOAD_LEN];
	uint8_t rcvData[NRF24_PAYLOAD_LEN];
	uint8_t pktCounter = 0;
	uint8_t blinkCounter = 0;
	const portTickType blinkDelay = 250 / portTICK_RATE_MS;
	const portTickType sendDelay = 5000 / portTICK_RATE_MS;

	rfData[0] = 0xB1;
	rfData[1] = 0x3A;
	rfData[2] = 0x23;
	while(1)
	{
		if(nrf24_dataReady())
		{
			nrf24_getData(rcvData);
			// Format message for debugging
			char debugRcvString[3*6] = {0};
			for (uint8_t i=0; i < NRF24_PAYLOAD_LEN; i++)
			{
				sprintf(debugRcvString+(3*i), "%02X ", rcvData[i]);
			}
			printf("Received: %s\n", debugRcvString);
		}


		rfData[3] = pktCounter++;
		nrf24_send(rfData);
		while(nrf24_isSending());
		char debugSendString[3*6] = {0};
		for (uint8_t i = 0; i < NRF24_PAYLOAD_LEN; i++)
		{
			sprintf(debugSendString+(3*i), "%02X ", rfData[i]);
		}
		printf("Sent: %s\n", debugSendString);

		if(nrf24_lastMessageStatus())
		{
			//there was a send problem
		}else{
			//transmission was ok
		}
		for(blinkCounter = 1 + nrf24_retransmissionCount(); blinkCounter > 0; --blinkCounter)
		{
			PORTC |= _BV(PORTC3);
			vTaskDelay(blinkDelay);
			PORTC &= ~_BV(PORTC3);
			vTaskDelay(blinkDelay);

		}

		nrf24_powerUpRx();
		vTaskDelay(sendDelay);

	}
}
Example #2
0
void copy_paste()
{

	int temp;
	nrf24_config(2, 4);
	nrf24_tx_address(tx_address11);
	nrf24_rx_address(rx_address11);
	while (1) {
		//LED0 = LED_ON;

		//LED1 = LED_ON;
		//LED2 = LED_ON;
		//LED3 = LED_ON;
		//delay_loop1();
		//LED0 = LED_OFF;
		//LED1 = LED_OFF;
		//LED2 = LED_OFF;
		//LED3 = LED_OFF;
		//delay_loop1();
		//nrf24_tx_address((uint8_t*) (uartBuffer + 1));
		data_array[0] = 0x00;
		data_array[1] = 0xAA;
		data_array[2] = 0x55;
		data_array[3] = 0x22;
		/* Automatically goes to TX mode */
		nrf24_send(data_array,4);
		/* Wait for transmission to end */
		while (nrf24_isSending());
		/* Make analysis on last tranmission attempt */
		temp = nrf24_lastMessageStatus();
		if (temp == NRF24_TRANSMISSON_OK)
		{
			//Do something
		}
		else if (temp == NRF24_MESSAGE_LOST)
		{
			//Do something else
		}
		/* Retranmission count indicates the tranmission quality */
		/* Optionally, go back to RX mode ... */
		//nrf24_powerUpRx();
		/* Or you might want to power down after TX */
		// nrf24_powerDown();
		/* Wait a little ... */
		//_delay_ms(10);

	}


}
Example #3
0
/* ------------------------------------------------------------------------- */
int main()
{
    /* init the software uart */
    uart_init();

    /* init the xprintf library */
    xdev_out(uart_put_char);

    /* simple greeting message */
    xprintf("\r\n> TX device ready\r\n");
    
    /* init hardware pins */
    nrf24_init();
    
    /* Channel #2 , payload length: 4 */
    nrf24_config(2,4);

    /* Set the device addresses */
    nrf24_tx_address(tx_address);
    nrf24_rx_address(rx_address);    

    while(1)
    {                
        /* Fill the data buffer */
        data_array[0] = 0x00;
        data_array[1] = 0xAA;
        data_array[2] = 0x55;
        data_array[3] = q++;                                    

        /* Automatically goes to TX mode */
        nrf24_send(data_array);        
        
        /* Wait for transmission to end */
        while(nrf24_isSending());

        /* Make analysis on last tranmission attempt */
        temp = nrf24_lastMessageStatus();

        if(temp == NRF24_TRANSMISSON_OK)
        {                    
            xprintf("> Tranmission went OK\r\n");
        }
        else if(temp == NRF24_MESSAGE_LOST)
        {                    
            xprintf("> Message is lost ...\r\n");    
        }
        
		/* Retranmission count indicates the tranmission quality */
		temp = nrf24_retransmissionCount();
		xprintf("> Retranmission count: %d\r\n",temp);

		/* Optionally, go back to RX mode ... */
		nrf24_powerUpRx();

		/* Or you might want to power down after TX */
		// nrf24_powerDown();            

		/* Wait a little ... */
		_delay_ms(10);
    }
}