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

[nRF52] Timeslot ESB in PRX/PTX mode and Bluetooth connetion

Hi everyone ;)

I have a problem with timeslot ESB library with Bluetooth LE. In my application i need do somethingh like that:

Bluetooth and ESB PRX works excelent, but I need to send some brodcast data ( without ACK ) in period 30ms via ESB PTX. 

Is this possibile?

I'l try something like that, but without success:

esbDisabled();
esbInitTxRx(ESB_PTX);

txMasterPayload.data[0] = counterrr++;
txMasterPayload.data[1] = 0x02;
txMasterPayload.data[2] = 0x03;
txMasterPayload.noack 	= true;
txMasterPayload.pipe  	= 1;
txMasterPayload.length  = 3;
nrf_esb_write_payload( &txMasterPayload );
nrf_esb_start_tx();	

// after ~20 ms 
esbDisabled();
esbInitTxRx(ESB_PRX);



void esbDisabled( void )
{
	uint32_t err_code;
	
	esbMode = false;
	ESB_TIMESLOT_DEBUG_PIN_SET(ESB_TIMESLOT_DBG_PIN_DISABLE);

	/* Timeslot is about to end: stop UESB. */
	if (m_state == STATE_RX)
	{  
			err_code= nrf_esb_stop_rx();
		//	PIN_RESET(LED);
	}

	err_code= nrf_esb_flush_tx();
	APP_ERROR_CHECK(err_code);

	err_code= nrf_esb_flush_rx();
	APP_ERROR_CHECK(err_code);

	err_code= nrf_esb_disable();
	APP_ERROR_CHECK(err_code);

	m_total_timeslot_length = 0;
	m_state                 = STATE_IDLE;

	ESB_TIMESLOT_DEBUG_PIN_CLEAR(ESB_TIMESLOT_DBG_PIN_DISABLE);
	ESB_TIMESLOT_DEBUG_PIN_CLEAR(ESB_TIMESLOT_DBG_PIN_RADIO_TIMESLOT);
}


void esbInitTxRx( uint8_t mode )
{
	uint32_t err_code;
	
	if ( mode == ESB_PTX )
	{
		nrf_esb_config.mode = NRF_ESB_MODE_PTX;
	}
	else
	{
		nrf_esb_config.mode = NRF_ESB_MODE_PRX;
	}
	
	err_code = nrf_esb_init(&nrf_esb_config);
	APP_ERROR_CHECK(err_code);

	err_code = nrf_esb_set_base_address_0(base_addr_0);
	APP_ERROR_CHECK(err_code);

	err_code = nrf_esb_set_base_address_1(base_addr_1);
	APP_ERROR_CHECK(err_code);

	err_code = nrf_esb_set_prefixes(addr_prefix, 8);
	APP_ERROR_CHECK(err_code);

	
	if ( mode == ESB_PTX )
	{	
		nrf_esb_set_rf_channel(8);	
	}
	else
	{
		nrf_esb_set_rf_channel(radio_channel);	
	}	
}



// ESB CONFIG:
nrf_esb_config.payload_length           = 10;
nrf_esb_config.protocol                 = NRF_ESB_PROTOCOL_ESB_DPL;
nrf_esb_config.bitrate                  = NRF_ESB_BITRATE_250KBPS;
nrf_esb_config.mode                     = NRF_ESB_MODE_PRX;
nrf_esb_config.event_handler            = nrf_esb_event_handler;  
//nrf_esb_config.radio_irq_priority       = 0;
nrf_esb_config.selective_auto_ack       = false; // Bylo na true nie wiem czemu ?
nrf_esb_config.crc                      = NRF_ESB_CRC_8BIT;
nrf_esb_config.retransmit_count         = 15;
nrf_esb_config.retransmit_delay         = 500;
nrf_esb_config.tx_mode                  = NRF_ESB_TXMODE_MANUAL;
nrf_esb_config.tx_output_power          = NRF_ESB_TX_POWER_4DBM;

	



How to quickly switch from PRX mode to PTX mode, send some data, and return to PRX mode?

Parents
  • OK, I'll got it works ;)

    Few things for the people with will have similar problem in future:
    1. When You send something in timeslot ESB You have to use:
    esb_timeslot_send_str(data,17);
    not
    nrf_esb_write_payload( &txMasterPayload );

    2. In timeslot, every ESB TX operation are in the beginning of timeslot. So if You want to increase TX framerate, You should use smaller advertising interval or connection interval.

    3. You dont have to reinit ESB to perform TX operation. Just set PTX mode.

Reply
  • OK, I'll got it works ;)

    Few things for the people with will have similar problem in future:
    1. When You send something in timeslot ESB You have to use:
    esb_timeslot_send_str(data,17);
    not
    nrf_esb_write_payload( &txMasterPayload );

    2. In timeslot, every ESB TX operation are in the beginning of timeslot. So if You want to increase TX framerate, You should use smaller advertising interval or connection interval.

    3. You dont have to reinit ESB to perform TX operation. Just set PTX mode.

Children
No Data
Related