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

Updating the advertisement Scan Response data

Hello

I would like to receive data from the TWIS driver and then update my scan response data with the received data.  My code is below.   Ideally, I would like to turn on the BLE module, wait for the receive data from the TWIS driver to complete and then start the advertisement. The problem is I've tried several times to accomplish this in the NRFX_TWIS_EVT_WRITE_DONE event below but I cannot get the advertisements to update. 

Through debugging, my data arrives and is stored in the m_rxbuff array. I now need to update the advertisement data and am having a lot of trouble.  Also, after initializing and starting advertising within main(), I can see my advertisements in nRf Connect.

static void twis_event_handler(nrfx_twis_evt_t const * const p_event)
{


if ( (p_event->type) == NRFX_TWIS_EVT_WRITE_REQ) 
{
(void)nrfx_twis_rx_prepare(&instance, m_rxbuff, sizeof(m_rxbuff));
}

if ( (p_event->type) == NRFX_TWIS_EVT_READ_ERROR)
{
NRF_LOG_INFO("Error Occured.");
}

if ( (p_event->type) == NRFX_TWIS_EVT_WRITE_ERROR)
{
NRF_LOG_INFO("Error Occured.");
}

if ( (p_event->type) == NRFX_TWIS_EVT_GENERAL_ERROR)
{
NRF_LOG_INFO("Error Occured.");
}

if ( (p_event->type) == NRFX_TWIS_EVT_WRITE_DONE) // Process received data
{

// Need to update scan response data here???  Is this possible?  Do I first need to stop advertising and then restart?

}

}

Related