board/rtl8721csm/bluetooth: Check active conn before read/write/notify
@@ -331,7 +331,7 @@ trble_result_e rtw_ble_client_disconnect(trble_conn_handle conn_handle)
uint32_t conn_id = conn_handle;
if(GAP_CONN_STATE_CONNECTED == ble_app_link_table[conn_handle].conn_state)
{
- if(ble_tizenrt_client_send_msg(BLE_TIZENRT_DISCONNECT, (void *)conn_id))
+ if(ble_tizenrt_client_send_msg(BLE_TIZENRT_DISCONNECT, (void *)conn_id) == false)
{
debug_print("\r\n[%s] msg send fail", __FUNCTION__);
return TRBLE_FAIL;
@@ -380,6 +380,12 @@ trble_result_e rtw_ble_client_operation_read(trble_operation_handle* handle, trb
return TRBLE_FAIL;
}
+ if(!le_get_active_link_num())
+ {
+ debug_print("\r\n[%s] No active connection", __FUNCTION__);
+ return TRBLE_FAIL;
+ }
+
BLE_TIZENRT_READ_PARAM *param = os_mem_alloc(0, sizeof(BLE_TIZENRT_READ_PARAM));
if(param == NULL)
{
@@ -429,6 +435,12 @@ trble_result_e rtw_ble_client_operation_write(trble_operation_handle* handle, tr
return TRBLE_FAIL;
}
+ if(!le_get_active_link_num())
+ {
+ debug_print("\r\n[%s] No active connection", __FUNCTION__);
+ return TRBLE_FAIL;
+ }
+
if(ble_tizenrt_write_sem == NULL)
{
if(false == os_mutex_create(&ble_tizenrt_write_sem))
@@ -481,6 +493,12 @@ trble_result_e rtw_ble_client_operation_write_no_response(trble_operation_handle
return TRBLE_FAIL;
}
+ if(!le_get_active_link_num())
+ {
+ debug_print("\r\n[%s] No active connection", __FUNCTION__);
+ return TRBLE_FAIL;
+ }
+
if(ble_tizenrt_write_no_rsp_sem == NULL)
{
if(false == os_mutex_create(&ble_tizenrt_write_no_rsp_sem))
@@ -533,6 +551,12 @@ trble_result_e rtw_ble_client_operation_enable_notification(trble_operation_hand
return TRBLE_FAIL;
}
+ if(!le_get_active_link_num())
+ {
+ debug_print("\r\n[%s] No active connection", __FUNCTION__);
+ return TRBLE_FAIL;
+ }
+
if (client_init_parm == NULL || client_init_parm->trble_operation_notification_cb == NULL)
{
return TRBLE_FAIL;
