Advertising messages and connected mode - question

8 posts / 0 new
Last post
AngelT
Offline
Last seen:1 year 2 months ago
加入:2016-03-24 12:25
Advertising messages and connected mode - question

Hello MT_dialog,

When the advertising operation is started, it can be stopped using the function app_easy_gap_advertise_stop(). When the advertising operation is really stopped the function user_app_adv_undirect_complete() will be called.

Questions:
1. When the device enters in connected mode who stops the advertising operation?
2. Why in this case the function user_app_adv_undirect_complete() is not called?

Thanks for the fast answers.

Device:
MT_dialog
Offline
Last seen:3 months 14 hours ago
工作人员
加入:2015-06-08 11:34
Hi AngelT,

Hi AngelT,

1. The stack stop the advertising procedure when there is a connection.

2. There is a callback execution, but in the SDK the status of the message is checked and the re-advertising starts if the status is GAP_ERR_CANCELED, when the advertising is stopped due to a connection the status parameter has a value of GAP_ERR_NO_ERROR (0x00), you should be able to see this if you place a breakpoint at the if(status == GAP_ERR_CANCELED).

Thanks MT_dialog

AngelT
Offline
Last seen:1 year 2 months ago
加入:2016-03-24 12:25
Hi MT_dialog,

Hi MT_dialog,

Thanks for the answers. I tested it. It works properly.
If I changed the condition to be if((status == GAP_ERR_CANCELED) || (status == GAP_ERR_NO_ERROR)), can I be sure that the status GAP_ERR_NO_ERROR will be return ONLY in this case when the advertising operation is stopped and the device enters in connected mode?

MT_dialog
Offline
Last seen:3 months 14 hours ago
工作人员
加入:2015-06-08 11:34
你好,天使,

你好,天使,

If you would like an indication that your device is connected you could know that for sure if the device goes through the .app_on_connection callback or by check the state of the APP_TASK (ke_state_get()). Although i dont think that there are going to be any other occasions where the advertising will stop and return to the application GAP_ERR_NO_ERROR other than a valid connection. I mean any other function that would stop the advertising operation would have returned a different error code, an implicit invocation of stopping the advertisement would return a GAP_ERROR_CANCELED, wrong parameters to the adv string would have returned GAP_ERR_ADV_DATA_INVALID, etc.

Thanks MT_dialog

AngelT
Offline
Last seen:1 year 2 months ago
加入:2016-03-24 12:25
Hi MT_dialog,

Hi MT_dialog,

Thanks for the answers. One additional question if is possible.

Why in all example projects there is a code to update the connection parameters periodically (e.g., every 10s) if they are not the preferred ones when the master takes the decision to accept or not these connection parameters? Is it possible if in the beginning of the connection these parameters not to be accepted, but on the next connection parameter update requests to be accepted? If I do not accept the connection parameters, why I should change my decision to accept the same parameters on the next requests?

Thanks in advance for the answer.

MT_dialog
Offline
Last seen:3 months 14 hours ago
工作人员
加入:2015-06-08 11:34
Hi AngelT,

Hi AngelT,

Please don't post additional questions on an irrelevant post, you can always create a new thread for a new question.

Regarding your question, the timer that is set during the connection for the parameter update is not reloaded anywhere, the request is sent to the master once, it doesn't send the request periodically. The request is only sent once and its up to the master if he will accept or reject the parameters indicated by the slave. When the connection starts the connection parameters are set by the master, if the slave wants to change them he has to send this kind of request, if the parameters are accepted or not or when the master will accept this kind of request depends on masters fw.

Thanks MT_dialog

AngelT
Offline
Last seen:1 year 2 months ago
加入:2016-03-24 12:25
Hi MT_dialog,

Hi MT_dialog,

Thanks for the answer. Sorry for this mistake. I will follow these recommendations for all new posts with new threads.

About your response. You are absolutely right. Only one thing if is convenient. The update of the connection parameters is done/written using a timer. The time interval can be defined/changed with the predefined symbol APP_PARAM_UPDATE_REQUEST_TO (value 1000 or 10s). Can I send the connection parameter update request directly in the function user_app_connection() without to use/start a timer and to postpone the transmission of this request?

Thanks again.

MT_dialog
Offline
Last seen:3 months 14 hours ago
工作人员
加入:2015-06-08 11:34
Hi AngelT,

Hi AngelT,

Please check the post below:

https://support.dialog-semiconductor.com/forums/post/dialog-smartbond-bl...

Thanks MT_dialog