This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

advertising packets received using radio receiver example

hi

i am using nrf51822. i used the radio tranceiver example and it works well. I am planning to advertise the received packets so that the range can also be increased and viewed in nRF connect android app

int main(void)

{

uint32_t err_code = NRF_SUCCESS;

clock_initialization();
APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL);

err_code = NRF_LOG_INIT(NULL);
APP_ERROR_CHECK(err_code);
err_code = bsp_init(BSP_INIT_LED, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL);
APP_ERROR_CHECK(err_code);

radio_configure();
NRF_RADIO->PACKETPTR = (uint32_t)&packet;

err_code = bsp_indication_set(BSP_INDICATE_USER_STATE_OFF);
NRF_LOG_INFO("Wait for first packet\r\n");
APP_ERROR_CHECK(err_code);
NRF_LOG_FLUSH();    

    uint32_t received = read_packet();

    err_code = bsp_indication_set(BSP_INDICATE_RCV_OK);
    NRF_LOG_INFO("Packet was received\r\n");
    APP_ERROR_CHECK(err_code);

    NRF_LOG_INFO("The contents of the package is %u\r\n", (unsigned int)received);
    NRF_LOG_FLUSH();uint32_t err_code;
bool erase_bonds;

timers_init();
buttons_leds_init(&erase_bonds);
ble_stack_init();
gap_params_init();
advertising_init();
conn_params_init();

err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
APP_ERROR_CHECK(err_code);

for (;;)
{
    power_manage();
}

}

i tried this code but doesnt seem to work

  • i used the example\peripheral\radio\receiver in SDK12.2. I find that the read_packet() function initializes the radio and disables the events before returning the packet. only after these lines i initialize my stack and adv block still i dont find my device advertising.

    kindly help me with this issue :)

  • If your goal is to receive advertisement packets, and send them again (relaying) (BLE Central and Peripheral role simultaneously), then I strongly recommend taking a look at the BLE Relay Example.

  • hi sir... sorry for the delay

    could you please help me with this part..

    I used the timeslot tutorial from the devzone and the radio receiver example

    case NRF_RADIO_CALLBACK_SIGNAL_TYPE_START:

            //Start of the timeslot - set up timer interrupt
    
            signal_callback_return_param.params.request.p_next = NULL;
    

    signal_callback_return_param.callback_action =NRF_RADIO_SIGNAL_CALLBACK_ACTION_NONE;

    					radio_configure();
    
    					NRF_RADIO->PACKETPTR = (uint32_t)&pack;
    
    					packet[0] = read_packet();
    
    					if(packet[0] >= 10)
    					{
    						str[0] = (packet[0] / 10) + 48;
    						str[1] = (packet[0] % 10) + 48;
    						str[2] = '\0';
    					}
    			else
    			{
    				str[0] = packet[0] + 48;
    				str[1] = '\0';
    			}
    					nrf_gpio_pin_toggle(21);
            NRF_TIMER0->INTENSET = TIMER_INTENSET_COMPARE0_Msk;
            NRF_TIMER0->CC[0] = m_slot_length - 1000;
            NVIC_EnableIRQ(TIMER0_IRQn); 			
    					
            break;
    

    Is this correct declaration? How should i handle the read_packet() function..how to handle the CALLBACK signal..

    the IF condition is to convert the integer value i receive to character type

Related