I'm using an nRF52 (PRX) to communicate with with an nRF24L01+ (PTX) using ESB. As part of a pairing routine they need to switch channel and addresses. I've confirmed that the nRF52 is receiving the correct frequency and address, but it still fails to change over correctly. It will work sometimes, but seemingly at random.
Could I get a quick code snippet showing how to properly change address and channel when the nRF52 is currently communicating? My current code looks like this
nrf_esb_disable(); tx_payload.length = 32; uint32_t err_code; nrf_esb_config_t nrf_esb_config = NRF_ESB_LEGACY_CONFIG; nrf_esb_config.payload_length = 32; nrf_esb_config.protocol = NRF_ESB_PROTOCOL_ESB_DPL; nrf_esb_config.bitrate = NRF_ESB_BITRATE_2MBPS; nrf_esb_config.crc = NRF_ESB_CRC_16BIT; nrf_esb_config.mode = NRF_ESB_MODE_PRX; nrf_esb_config.event_handler = nrf_esb_event_handler; nrf_esb_config.selective_auto_ack = false; err_code = nrf_esb_init(&nrf_esb_config); VERIFY_SUCCESS(err_code); nrf_esb_stop_rx(); while(!nrf_esb_is_idle()); //Set frequency err_code = nrf_esb_set_rf_channel(freq); VERIFY_SUCCESS(err_code); //Set rest of address err_code = nrf_esb_set_base_address_0(base_addr_0); VERIFY_SUCCESS(err_code); //Set first byte of address err_code = nrf_esb_set_prefixes(addr_prefix, 1); VERIFY_SUCCESS(err_code); //Check that we switched to the right frequency uint32_t channel_data[6]; nrf_esb_get_rf_channel(channel_data); err_code = nrf_esb_start_rx(); VERIFY_SUCCESS(err_code);