When you are connected to a peer device the user_app_adv_undirect_complete() will be triggered (the stack will cancel the advertising), and the completion status will have a value 0x00. So, I would suggest you to modify the check in the “if” argument as follow: if(status == GAP_ERR_CANCELED || status == 0x00 ). By this way, when you are connected, you will be still able to advertise. But you should take care of the state of the application, for example, when the device is disconnected from a peer device, the SDK will send a GAPC_DISCONNECT_IND and then the gapc_disconnect_ind_handler() will be triggered. Although, the state should been changed from APP_CONNECTED to APP_CONNECTABLE (since you have started advertising after the connection).
Hi Gavin Sun,
When you are connected to a peer device the user_app_adv_undirect_complete() will be triggered (the stack will cancel the advertising), and the completion status will have a value 0x00. So, I would suggest you to modify the check in the “if” argument as follow: if(status == GAP_ERR_CANCELED || status == 0x00 ). By this way, when you are connected, you will be still able to advertise. But you should take care of the state of the application, for example, when the device is disconnected from a peer device, the SDK will send a GAPC_DISCONNECT_IND and then the gapc_disconnect_ind_handler() will be triggered. Although, the state should been changed from APP_CONNECTED to APP_CONNECTABLE (since you have started advertising after the connection).
Thanks, PM_Dialog