This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software:
Hi TI-team.
We would like to change the data (e.g., event no.) of the advertisement transmission.
We think we can change it when the event “BLEAPPUTIL_ADV_END” of “BLEAppUtil_EventHandler_t” occurs.
In fact, we have confirmed that the “BLEAPPUTIL_ADV_END” event occurs after each event is sent and the application process is executed (port output). (See the figure below)
However, even if we update the sent data with the following codes (both* have been tested) during the “BLEAPPUTIL_ADV_END” event, there is no change in the received data.
*API: GapAdv_loadByBuffer() or GapAdv_loadByHandle()
void Broadcaster_AdvEventHandler(uint32 event, BLEAppUtil_msgHdr_t *pMsgData) { switch(event) { case BLEAPPUTIL_ADV_START_AFTER_ENABLE: /* Null */ break; case BLEAPPUTIL_ADV_END_AFTER_DISABLE: GPIO_write(CONFIG_GPIO_1, 1); ++event_no; GPIO_write(CONFIG_GPIO_1, 0); break; case BLEAPPUTIL_ADV_SET_TERMINATED: /* Null */ break; case BLEAPPUTIL_ADV_END: GPIO_write(CONFIG_GPIO_0, 1); ++event_no; txData[15] = (char)event_no; GapAdv_loadByHandle(broadcasterAdvHandle_1, GAP_ADV_DATA_TYPE_ADV, 14, &txData[2]); GPIO_write(CONFIG_GPIO_0, 0); break; default: break; } }
void Broadcaster_AdvEventHandler(uint32 event, BLEAppUtil_msgHdr_t *pMsgData) { switch(event) { case BLEAPPUTIL_ADV_START_AFTER_ENABLE: /* Null */ break; case BLEAPPUTIL_ADV_END_AFTER_DISABLE: GPIO_write(CONFIG_GPIO_1, 1); ++event_no; GPIO_write(CONFIG_GPIO_1, 0); break; case BLEAPPUTIL_ADV_SET_TERMINATED: /* Null */ break; case BLEAPPUTIL_ADV_END: GPIO_write(CONFIG_GPIO_0, 1); ++event_no; txData[15] = (char)event_no; GapAdv_loadByBuffer(14, &txData[2]); GPIO_write(CONFIG_GPIO_0, 0); break; default: break; } }
Is there any way we can accomplish what we want to do?
We are using SDK: 7.40.
Best regards.
Translated with DeepL.com (free version)
Hey,
You need to execute: GapAdv_prepareLoadByHandle() first, before executing GapAdv_loadByHandle.
check the documentation on how to do it here:
Regards,
Marvin
Hi, Marvin.
Thanks for the reply.
I added GapAdv_prepareLoadByHandle() before executing GapAdv_loadByHandle() as you taught me. (See code below)
void Broadcaster_AdvEventHandler(uint32 event, BLEAppUtil_msgHdr_t *pMsgData) { switch(event) { case BLEAPPUTIL_ADV_START_AFTER_ENABLE: /* Null */ break; case BLEAPPUTIL_ADV_END_AFTER_DISABLE: GPIO_write(CONFIG_GPIO_1, 1); ++gu8_c_frame_no; GPIO_write(CONFIG_GPIO_1, 0); break; case BLEAPPUTIL_ADV_SET_TERMINATED: /* Null */ break; case BLEAPPUTIL_ADV_END: GPIO_write(CONFIG_GPIO_0, 1); ++gu8_c_frame_no; #if 1 /* Add Dec 9 */ GPIO_write(CONFIG_GPIO_2, 1); GapAdv_prepareLoadByBuffer(&txData[2], GAP_ADV_FREE_OPTION_ADV_DATA); GPIO_write(CONFIG_GPIO_2, 0); #endif /* Add Dec 9 */ txData[15] = (char)gu8_c_frame_no; GapAdv_loadByHandle(broadcasterAdvHandle_1, GAP_ADV_DATA_TYPE_ADV, 14, &txData[2]); // GapAdv_loadByBuffer(14, &txData[2]); GPIO_write(CONFIG_GPIO_0, 0); break; default: break; } }
However, it does not work as expected and seems to be transitioning to an infinite loop in GapAdv_prepareLoadByHandle(). (see figure below).
Am I doing something wrong?
Please let me know the correct way.
Best regards.
You are mixing things a bit here.
First of all, you don't want to input GAP_ADV_FREE_OPTION_ADV_DATA as you are still using the same buffer.
This is how it should look:
// Don't free anything since we're going to use the same buffer to reload 2 GapAdv_prepareLoadByBuffer(txData, FALSE); 3 4 // Sample buffer modification 5 txData[15] = (char)gu8_c_frame_no; 6 7 // Reload the buffer to be used by the advertisement set handles 8 GapAdv_loadByBuffer(ADV_DATA_LEN, txData);
Loading a complete new buffer would look like this:
// Free the buffer (to avoid double copying) since we're loading a new buffer 2 GapAdv_prepareLoadByHandle(advHandleLegacy, GAP_ADV_FREE_OPTION_ADV_DATA); 3 4 // Allocate new buffer (and then fill it as desired) 5 uint8_t *advertData2= ICall_malloc(ADV_DATA2_LEN); 6 7 // Load the new buffer to the advertisement set handle 8 GapAdv_loadByHandle(advHandleLegacy, GAP_ADV_DATA_TYPE_ADV, ADV_DATA2_LEN, advertData2);
advertData2 is then the new buffer and the old one is freed.
Regards,
Marvin
Hi, Marvin.
Thanks for the reply.
I checked with the code you gave me.
I want to use the same buffer, so I changed the code to the one below.
void Broadcaster_AdvEventHandler(uint32 event, BLEAppUtil_msgHdr_t *pMsgData) { switch(event) { case BLEAPPUTIL_ADV_START_AFTER_ENABLE: /* Null */ break; case BLEAPPUTIL_ADV_END_AFTER_DISABLE: GPIO_write(CONFIG_GPIO_1, 1); ++gu8_c_frame_no; GPIO_write(CONFIG_GPIO_1, 0); break; case BLEAPPUTIL_ADV_SET_TERMINATED: /* Null */ break; case BLEAPPUTIL_ADV_END: GPIO_write(CONFIG_GPIO_0, 1); ++gu8_c_frame_no; #if 1 /* Add Dec 9 */ GPIO_write(CONFIG_GPIO_2, 1); GapAdv_prepareLoadByBuffer(&txData[2], FALSE); GPIO_write(CONFIG_GPIO_2, 0); #endif /* Add Dec 9 */ txData[15] = (char)gu8_c_frame_no; GapAdv_loadByBuffer(14, &txData[2]); GPIO_write(CONFIG_GPIO_0, 0); break; default: break; } }
Then, Advertise transmission was performed, and we were able to change the transmitted data for each packet (in this case, it means a batch of 37ch, 38ch and 39ch transmission).
However, as shown in the figure below, contrary to the intention of having 5 packets sent at 100 msec intervals, the data is sent forever at abour 5.6msec intervals.
Is there anything else I should change?
Best regards.