Enabling and disabling advertising after advertising string modificaiton

10 posts / 0 new
Last post
asalhuv
Offline
Last seen:2 years 8 months ago
Joined:2015-10-22 09:49
Enabling and disabling advertising after advertising string modificaiton

Hi
I am using an external processor in order to control the DA14580 (based on the SPS device code), the external processor program the DA14580 and then need to modify the advertise string while running.
After i gather the data via the UART port, I am trying to cancel the advertise using the "app_adv_stop()", then calling the "app_adv_start()" and modifying the data to *cmd pointer .the problem is that the advertise is not starting again.
If I am calling the app_adv_stop() at the start of the data reception instead of in the end, the advertise does stop and start again, but the data is left unchanged (the transmitted data- in cmd->data i see that data does changed).

My question if there is something else needs to be modified, or there is another way to change the advertise string.

BTW: I have changed the length in "cmd->info.host.adv_data_len" to my data length and set in comment this procedure so the length will be fine:

我f (device_name_avail_space > 0)
{
// Get the Device Name to add in the Advertising Data (Default one or NVDS one)
#if (NVDS_SUPPORT)
device_name_length = NVDS_LEN_DEVICE_NAME;
我f (nvds_get(NVDS_TAG_DEVICE_NAME, &device_name_length, &device_name_temp_buf[0]) != NVDS_OK)
#endif //(NVDS_SUPPORT)
{
// Get default Device Name (No name if not enough space)
device_name_length = strlen(APP_DFLT_DEVICE_NAME);
memcpy(&device_name_temp_buf[0], APP_DFLT_DEVICE_NAME, device_name_length);
}

我f(device_name_length > 0)
{
// Check available space
device_name_length = co_min(device_name_length, device_name_avail_space);

// Fill Length
cmd->info.host.adv_data[cmd->info.host.adv_data_len] = device_name_length + 1;
// Fill Device Name Flag
cmd->info.host.adv_data[cmd->info.host.adv_data_len + 1] = '\x09';
// Copy device name
memcpy(&cmd->info.host.adv_data[cmd->info.host.adv_data_len + 2], device_name_temp_buf, device_name_length);
// Update Advertising Data Length
cmd->info.host.adv_data_len += (device_name_length + 2);
}
}

Device:
MT_dialog
Offline
Last seen:1 month 3 weeks ago
Staff
Joined:2015-06-08 11:34
Hi asalhuv,

Hi asalhuv,

There is no other function to modify for the advertising. You can debug the function to check what is the value that goes in the device_name_temp_buf. I cant see anything in the code that will change the value of the device_name_temp_buf array. If you use NVDS then will load the name from NVDS else it will load the default name.

Thanks MT_dialog

asalhuv
Offline
Last seen:2 years 8 months ago
Joined:2015-10-22 09:49
Hi and thanks, maybe I didn't

Hi and thanks, maybe I didn't explain my question well, so I try to ask it in a different way:
when I call the function "app_adv_stop()", how long do I need to wait until the kernel consume the message.
the same question goes for "app_adv_start()" . The reason I am asking is because I need to do quick changes in the advertise string following a MCU message, but if call the function "app_adv_stop()" and then immediately call "app_adv_start()" it wont start the advertising again. only if I am calling the app_adv_stop() in an earlier procedure. (when getting a last byte of a string at UART port). Also if I am calling the function "app_adv_start()" right after i'm sending a byte using the "uart_txdata_setf()" function ,the advertising string will be not updated ( I am calling the advertise start function and updating the "&cmd->info.host.adv_data[6]".
thanks

MT_dialog
Offline
Last seen:1 month 3 weeks ago
Staff
Joined:2015-06-08 11:34
Hi asalhuv,

Hi asalhuv,

很难知道在多少时间内核will execute the stop advertise command, it depends on what the os is doing at the moment. What you can do is to issue the stop advertise command and then catch the complete handler of the stop advertise request. In the complete request you can change the advertising string and restart advertise. Please have a look at the beacon ref design in the app_adv_undirect_complete_function().

Thanks MT_dialog

asalhuv
Offline
Last seen:2 years 8 months ago
Joined:2015-10-22 09:49
Hi and thanks for your reply,

Hi and thanks for your reply, do you mean "app_adv_undirect_complete(uint8_t status)" right?
The flag indication is (status == GAP_ERR_CANCELED)? this is indicating that the advertising has stop?

I must say that very hard to understand the flow of the OS, seems like if trying to modify the state machine it has many issues. do you have a suggestion of a document which describe the state machine of the OS?

thanks

MT_dialog
Offline
Last seen:1 month 3 weeks ago
Staff
Joined:2015-06-08 11:34
Hi asalhuv,

Hi asalhuv,

Thats right, the handler is executed whenever you stop the advertising. What do you mean with OS state machine ? What is the part of code that you refer to ?

Thanks MT_dialog

asalhuv
Offline
Last seen:2 years 8 months ago
Joined:2015-10-22 09:49
Hi , thanks for your reply, I

Hi , thanks for your reply, I meant the kernel tasks. I don't know how to follow the flow of the system. for example: after connection, which handles are called? what is the routine of the kernel.
Another two questions regarding the SPS project:
1. There is an SDK for the SPS android/IOS app, I would to implement something similar in a new app.
2. How can I modify the local device name in advertising mode, i see that if I am setting a beacon string there is no room left for the device name, is it possible to add it somehow?
thanks

MT_dialog
Offline
Last seen:1 month 3 weeks ago
Staff
Joined:2015-06-08 11:34
Hi asalhuv,

Hi asalhuv,

The handlers that are called after connection are depended on the message you get from the host and eventually from the ble stack, for instance if you receive a connection request from the master the gapc_connection_req_ind_handler() callback should be called. You can have an idea about the messages exchanged in connection procedures by checking out the RW_BLE_GAP_IS. The kernel just schedules the messages it receives from the stack and from the application task.

1) I am not sure i undestand your question but there is no SDK for developing especially the android or iOS app for the DSPS but if you are interested we can provide the source code for the android/iOS DSPS application.

2) The advertising string is limited to 31 bytes and 3 of the bytes are allready reserved, but i suppose that you can change the beacon advertising mode and issue scan responses, and place the devices name in the scan response string.

Thanks MT_dialog

asalhuv
Offline
Last seen:2 years 8 months ago
Joined:2015-10-22 09:49
Hi and thanks for your

Hi and thanks for your answers
1) Yes, I meant the source code for the App (Android and IOS), where can I get this ?
2) Will do , thanks

MT_dialog
Offline
Last seen:1 month 3 weeks ago
Staff
Joined:2015-06-08 11:34
Hi asalhuv,

Hi asalhuv,

Mail sent.

Thanks MT_dialog