Readvertise ble

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hello, im trying to disconnect the ble of the client side from the server side.

cy_ble_disable/cy_ble_stop are working but i can't readvertise afterward.

Ive tried using cy_ble_start/cy_ble_enable following the previous api's but its still not working.

Is it possiable to do it some how?

Thanks

0 Likes
1 Solution
ajays_86
Employee
Employee
First like received

Hi,

To disconnect the BLE client (say Phone) from the server side (PSoC 6) use Cy_BLE_GAP_Disconnect() API.

cy_stc_ble_gap_disconnect_info_t param =

    {

        .bdHandle = /* BD Handle */

        .reason  = CY_BLE_HCI_ERROR_OTHER_END_TERMINATED_USER

    };

Cy_BLE_GAP_Disconnect(&param);

On disconnection, the following events are generated in order.

CY_BLE_EVT_GATT_DISCONNECT_IND

CY_BLE_EVT_GAP_DEVICE_DISCONNECTED

After the CY_BLE_EVT_GATT_DISCONNECT_IND and CY_BLE_EVT_GAP_DEVICE_DISCONNECTED events you can use Cy_BLE_GAPP_StartAdvertisement() to restart the advertisement.

Thanks,

Ajay

View solution in original post

0 Likes
3 Replies
himam_31
Employee
Employee
50 likes received 25 likes received 10 likes received

Hello,

Can you please attach your project.

Thanks,

Hima

0 Likes
ajays_86
Employee
Employee
First like received

Hi,

To disconnect the BLE client (say Phone) from the server side (PSoC 6) use Cy_BLE_GAP_Disconnect() API.

cy_stc_ble_gap_disconnect_info_t param =

    {

        .bdHandle = /* BD Handle */

        .reason  = CY_BLE_HCI_ERROR_OTHER_END_TERMINATED_USER

    };

Cy_BLE_GAP_Disconnect(&param);

On disconnection, the following events are generated in order.

CY_BLE_EVT_GATT_DISCONNECT_IND

CY_BLE_EVT_GAP_DEVICE_DISCONNECTED

After the CY_BLE_EVT_GATT_DISCONNECT_IND and CY_BLE_EVT_GAP_DEVICE_DISCONNECTED events you can use Cy_BLE_GAPP_StartAdvertisement() to restart the advertisement.

Thanks,

Ajay

0 Likes
MeenakshiR_71
Employee
Employee
100 likes received 50 likes received 25 likes received

You need to make sure you have received "CY_BLE_EVT_STACK_SHUTDOWN_COMPLETE" before calling Cy_BLE_Start() API. Note that you do not have to call Cy_BLE_Enable as Start calls it automatically.

Also make sure the Cy_BLE_Stop() and Start() return CY_BLE_SUCCESS, otherwise post the error you are getting in the thread. After receiving CY_BLE_SUCCESS from the API calls, you need to call Cy_BLE_ProcessEvents to process the commands through the stack till you receive CY_BLE_EVT_STACK_SHUTDOWN_COMPLETE event for Stop and CY_BLE_EVT_STACK_ON event for Start.

Regards,

Meenakshi Sundaram R

0 Likes