diff --git a/apps/examples/ble_rmc/ble_rmc_main.c b/apps/examples/ble_rmc/ble_rmc_main.c index cee5e8228d..c4d199bb2d 100644 --- a/apps/examples/ble_rmc/ble_rmc_main.c +++ b/apps/examples/ble_rmc/ble_rmc_main.c @@ -192,14 +192,16 @@ void restart_server(void) { RMC_LOG(RMC_SERVER_TAG, "Start adv ... ok\n"); } -static void ble_server_connected_cb(ble_conn_handle con_handle, ble_server_connection_type_e conn_type, uint8_t mac[BLE_BD_ADDR_MAX_LEN]) +static void ble_server_connected_cb(ble_conn_handle con_handle, ble_server_connection_type_e conn_type, uint8_t mac[BLE_BD_ADDR_MAX_LEN], uint8_t adv_handle) { RMC_LOG(RMC_SERVER_TAG, "'%s' is called\n", __FUNCTION__); RMC_LOG(RMC_SERVER_TAG, "conn : %d / conn_type : %d\n", con_handle, conn_type); RMC_LOG(RMC_SERVER_TAG, "conn mac : %02x:%02x:%02x:%02x:%02x:%02x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + RMC_LOG(RMC_SERVER_TAG, "adv_handle : %d\n", adv_handle); if (conn_type == BLE_SERVER_DISCONNECTED) { restart_server(); } + adv_handle = 0xff; return; } diff --git a/framework/include/ble_manager/ble_server.h b/framework/include/ble_manager/ble_server.h index 9c61b1f8b6..2dd015b669 100644 --- a/framework/include/ble_manager/ble_server.h +++ b/framework/include/ble_manager/ble_server.h @@ -110,7 +110,7 @@ typedef struct { void* arg; } ble_server_gatt_t; -typedef void (*ble_server_connected_t)(ble_conn_handle con_handle, ble_server_connection_type_e conn_type, uint8_t mac[BLE_BD_ADDR_MAX_LEN]); +typedef void (*ble_server_connected_t)(ble_conn_handle con_handle, ble_server_connection_type_e conn_type, uint8_t mac[BLE_BD_ADDR_MAX_LEN], uint8_t adv_handle); typedef void (*ble_server_disconnected_t)(ble_conn_handle con_handle, uint16_t cause); typedef void (*ble_server_mtu_update_t)(ble_conn_handle con_handle, uint16_t mtu_size); diff --git a/os/board/rtl8720e/src/component/bluetooth/example/ble_scatternet/scatternet.c b/os/board/rtl8720e/src/component/bluetooth/example/ble_scatternet/scatternet.c index d482469083..7e0a84bb75 100644 --- a/os/board/rtl8720e/src/component/bluetooth/example/ble_scatternet/scatternet.c +++ b/os/board/rtl8720e/src/component/bluetooth/example/ble_scatternet/scatternet.c @@ -222,7 +222,7 @@ static rtk_bt_evt_cb_ret_t ble_tizenrt_scatternet_gap_app_callback(uint8_t evt_c ble_client_connect_is_running = 0; }else if (RTK_BT_LE_ROLE_SLAVE == conn_ind->role) { - server_init_parm.connected_cb(conn_ind->conn_handle, TRBLE_SERVER_LL_CONNECTED, conn_ind->peer_addr.addr_val); + server_init_parm.connected_cb(conn_ind->conn_handle, TRBLE_SERVER_LL_CONNECTED, conn_ind->peer_addr.addr_val, 0xff);// the last field 0xff is a dummy value for adv handle which is for AI-Lite only } } else { @@ -413,7 +413,7 @@ static rtk_bt_evt_cb_ret_t ble_tizenrt_scatternet_gap_app_callback(uint8_t evt_c client_init_parm->trble_device_connected_cb(&connected_dev); }else if(RTK_BT_LE_ROLE_SLAVE == ble_tizenrt_scatternet_conn_ind->role) { - server_init_parm.connected_cb(auth_cplt_ind->conn_handle, TRBLE_SERVER_SM_CONNECTED, ble_tizenrt_scatternet_conn_ind->peer_addr.addr_val); + server_init_parm.connected_cb(auth_cplt_ind->conn_handle, TRBLE_SERVER_SM_CONNECTED, ble_tizenrt_scatternet_conn_ind->peer_addr.addr_val, 0xff);// the last field 0xff is a dummy value for adv handle which is for AI-Lite only } } break; diff --git a/os/board/rtl8721csm/src/component/common/bluetooth/realtek/sdk/example/ble_peripheral/ble_tizenrt_app.c b/os/board/rtl8721csm/src/component/common/bluetooth/realtek/sdk/example/ble_peripheral/ble_tizenrt_app.c index 8c2ad8366c..caf1fd50de 100644 --- a/os/board/rtl8721csm/src/component/common/bluetooth/realtek/sdk/example/ble_peripheral/ble_tizenrt_app.c +++ b/os/board/rtl8721csm/src/component/common/bluetooth/realtek/sdk/example/ble_peripheral/ble_tizenrt_app.c @@ -220,7 +220,7 @@ void ble_tizenrt_handle_callback_msg(T_TIZENRT_APP_CALLBACK_MSG callback_msg) connected->remote_bd[0], connected->remote_bd[1], connected->remote_bd[2], connected->remote_bd[3], connected->remote_bd[4], connected->remote_bd[5]); trble_server_connected_t p_func = server_init_parm.connected_cb; - p_func(connected->conn_id, connected->conn_type, connected->remote_bd); + p_func(connected->conn_id, connected->conn_type, connected->remote_bd, 0xff);// the last field 0xff is a dummy value for adv handle which is for AI-Lite only #if defined(CONFIG_BLE_INDICATION) if(connected->conn_type == TRBLE_SERVER_DISCONNECTED){ if(ble_tizenrt_indicate_sem != NULL) diff --git a/os/board/rtl8721csm/src/component/common/bluetooth/realtek/sdk/example/ble_scatternet/ble_tizenrt_scatternet_app.c b/os/board/rtl8721csm/src/component/common/bluetooth/realtek/sdk/example/ble_scatternet/ble_tizenrt_scatternet_app.c index 5750ae20a1..08e9d2f8fd 100644 --- a/os/board/rtl8721csm/src/component/common/bluetooth/realtek/sdk/example/ble_scatternet/ble_tizenrt_scatternet_app.c +++ b/os/board/rtl8721csm/src/component/common/bluetooth/realtek/sdk/example/ble_scatternet/ble_tizenrt_scatternet_app.c @@ -240,7 +240,7 @@ void ble_tizenrt_scatternet_handle_callback_msg(T_TIZENRT_APP_CALLBACK_MSG callb connected->remote_bd[0], connected->remote_bd[1], connected->remote_bd[2], connected->remote_bd[3], connected->remote_bd[4], connected->remote_bd[5]); trble_server_connected_t p_func = server_init_parm.connected_cb; - p_func(connected->conn_id, connected->conn_type, connected->remote_bd); + p_func(connected->conn_id, connected->conn_type, connected->remote_bd, 0xff);// the last field 0xff is a dummy value for adv handle which is for AI-Lite only #if defined(CONFIG_BLE_INDICATION) if(connected->conn_type == TRBLE_SERVER_DISCONNECTED) diff --git a/os/board/rtl8730e/src/component/bluetooth/api/rtk_bt_le_gap.c b/os/board/rtl8730e/src/component/bluetooth/api/rtk_bt_le_gap.c index d71f5d30ea..4b548edc85 100755 --- a/os/board/rtl8730e/src/component/bluetooth/api/rtk_bt_le_gap.c +++ b/os/board/rtl8730e/src/component/bluetooth/api/rtk_bt_le_gap.c @@ -384,6 +384,19 @@ uint16_t rtk_bt_le_gap_remove_ext_adv(uint8_t adv_handle) return ret; } + +uint16_t rtk_bt_le_gap_get_ext_adv_handle_by_conn_handle(uint16_t conn_handle, uint8_t *adv_handle) +{ + uint16_t ret = 0; + rtk_bt_le_get_eadv_by_conn_handle_param_t get_adv_hdl = { + .conn_handle = conn_handle, + .adv_handle = adv_handle, + }; + + ret = rtk_bt_send_cmd(RTK_BT_LE_GP_GAP, RTK_BT_LE_GAP_ACT_GET_EXT_ADV_HANDLE_BY_CONN_HANDLE, &get_adv_hdl, sizeof(get_adv_hdl)); + return ret; +} + #endif /* RTK_BLE_5_0_AE_ADV_SUPPORT */ #if (defined(RTK_BLE_5_0_AE_ADV_SUPPORT) && RTK_BLE_5_0_AE_ADV_SUPPORT) || (defined(RTK_BLE_5_0_AE_SCAN_SUPPORT) && RTK_BLE_5_0_AE_SCAN_SUPPORT) diff --git a/os/board/rtl8730e/src/component/bluetooth/api/rtk_stack/rtk_stack_le_gap.c b/os/board/rtl8730e/src/component/bluetooth/api/rtk_stack/rtk_stack_le_gap.c index f989797943..d522b1e857 100755 --- a/os/board/rtl8730e/src/component/bluetooth/api/rtk_stack/rtk_stack_le_gap.c +++ b/os/board/rtl8730e/src/component/bluetooth/api/rtk_stack/rtk_stack_le_gap.c @@ -2324,6 +2324,24 @@ static uint16_t bt_stack_le_gap_remove_ext_adv(void *param) return 0; #endif } + +static uint16_t bt_stack_le_gap_get_ext_adv_handle_by_conn_handle(void *param) +{ +#if defined(RTK_BLE_MGR_LIB_EADV) && RTK_BLE_MGR_LIB_EADV + (void)param; + return RTK_BT_ERR_UNSUPPORTED; +#else + rtk_bt_le_get_eadv_by_conn_handle_param_t *get_eadv_hdl = (rtk_bt_le_get_eadv_by_conn_handle_param_t *)param; + uint8_t conn_id = 0; + + if (!le_get_conn_id_by_handle(get_eadv_hdl->conn_handle, &conn_id)) { + return RTK_BT_ERR_NO_CONNECTION; + } + *(get_eadv_hdl->adv_handle) = le_ext_adv_get_adv_handle_by_conn_id(conn_id); + + return 0; +#endif +} #endif /* RTK_BLE_5_0_AE_ADV_SUPPORT && F_BT_LE_5_0_AE_ADV_SUPPORT */ #if (defined(RTK_BLE_5_0_AE_ADV_SUPPORT) && RTK_BLE_5_0_AE_ADV_SUPPORT) || (defined(RTK_BLE_5_0_AE_SCAN_SUPPORT) && RTK_BLE_5_0_AE_SCAN_SUPPORT) @@ -4351,6 +4369,10 @@ uint16_t bt_stack_le_gap_act_handle(rtk_bt_cmd_t *p_cmd) API_PRINT("RTK_BT_LE_GAP_ACT_REMOVE_EXT_ADV \r\n"); ret = bt_stack_le_gap_remove_ext_adv(p_cmd->param); break; + case RTK_BT_LE_GAP_ACT_GET_EXT_ADV_HANDLE_BY_CONN_HANDLE: + API_PRINT("RTK_BT_LE_GAP_ACT_GET_EXT_ADV_HANDLE_BY_CONN_HANDLE \r\n"); + ret = bt_stack_le_gap_get_ext_adv_handle_by_conn_handle(p_cmd->param); + break; #endif #if (defined(RTK_BLE_5_0_AE_ADV_SUPPORT) && RTK_BLE_5_0_AE_ADV_SUPPORT) || (defined(RTK_BLE_5_0_AE_SCAN_SUPPORT) && RTK_BLE_5_0_AE_SCAN_SUPPORT) case RTK_BT_LE_GAP_ACT_EXT_CONN: diff --git a/os/board/rtl8730e/src/component/bluetooth/example/ble_scatternet/scatternet.c b/os/board/rtl8730e/src/component/bluetooth/example/ble_scatternet/scatternet.c index eccf643f7b..2170bd1a66 100644 --- a/os/board/rtl8730e/src/component/bluetooth/example/ble_scatternet/scatternet.c +++ b/os/board/rtl8730e/src/component/bluetooth/example/ble_scatternet/scatternet.c @@ -372,7 +372,13 @@ static rtk_bt_evt_cb_ret_t ble_tizenrt_scatternet_gap_app_callback(uint8_t evt_c ble_client_connect_is_running = 0; }else if (RTK_BT_LE_ROLE_SLAVE == conn_ind->role) { - server_init_parm.connected_cb(conn_ind->conn_handle, TRBLE_SERVER_LL_CONNECTED, conn_ind->peer_addr.addr_val); + uint8_t adv_handle = 0xff; +#if defined (RTK_BLE_5_0_AE_ADV_SUPPORT) && RTK_BLE_5_0_AE_ADV_SUPPORT + if(RTK_BT_OK != rtk_bt_le_gap_get_ext_adv_handle_by_conn_handle(conn_ind->conn_handle, &adv_handle)){ + dbg("[APP] Get adv handle failed \r\n"); + } +#endif + server_init_parm.connected_cb(conn_ind->conn_handle, TRBLE_SERVER_LL_CONNECTED, conn_ind->peer_addr.addr_val, adv_handle); } } else { @@ -562,10 +568,15 @@ static rtk_bt_evt_cb_ret_t ble_tizenrt_scatternet_gap_app_callback(uint8_t evt_c connected_dev.conn_info.is_secured_connect = is_secured; connected_dev.conn_info.mtu = mtu_size; client_init_parm->trble_device_connected_cb(&connected_dev); - }else if(RTK_BT_LE_ROLE_SLAVE == ble_tizenrt_scatternet_conn_ind->role) - { - server_init_parm.connected_cb(auth_cplt_ind->conn_handle, TRBLE_SERVER_SM_CONNECTED, ble_tizenrt_scatternet_conn_ind->peer_addr.addr_val); - } + }else if(RTK_BT_LE_ROLE_SLAVE == ble_tizenrt_scatternet_conn_ind->role){ + uint8_t adv_handle = 0xff; +#if defined (RTK_BLE_5_0_AE_ADV_SUPPORT) && RTK_BLE_5_0_AE_ADV_SUPPORT + if(RTK_BT_OK != rtk_bt_le_gap_get_ext_adv_handle_by_conn_handle(auth_cplt_ind->conn_handle, &adv_handle)){ + dbg("[APP] Get adv handle failed \r\n"); + } +#endif + server_init_parm.connected_cb(auth_cplt_ind->conn_handle, TRBLE_SERVER_SM_CONNECTED, ble_tizenrt_scatternet_conn_ind->peer_addr.addr_val, adv_handle); + } } break; } diff --git a/os/board/rtl8730e/src/component/bluetooth/inc/rtk_bt_common.h b/os/board/rtl8730e/src/component/bluetooth/inc/rtk_bt_common.h index 275f6ff85c..6bdbd6b3fe 100644 --- a/os/board/rtl8730e/src/component/bluetooth/inc/rtk_bt_common.h +++ b/os/board/rtl8730e/src/component/bluetooth/inc/rtk_bt_common.h @@ -271,6 +271,7 @@ typedef enum { RTK_BT_LE_GAP_ACT_START_EXT_ADV, RTK_BT_LE_GAP_ACT_STOP_EXT_ADV, RTK_BT_LE_GAP_ACT_REMOVE_EXT_ADV, + RTK_BT_LE_GAP_ACT_GET_EXT_ADV_HANDLE_BY_CONN_HANDLE, RTK_BT_LE_GAP_ACT_EXT_SCAN_SET_PARAM, RTK_BT_LE_GAP_ACT_EXT_SCAN_START, RTK_BT_LE_GAP_ACT_EXT_SCAN_STOP, diff --git a/os/board/rtl8730e/src/component/bluetooth/inc/rtk_bt_le_gap.h b/os/board/rtl8730e/src/component/bluetooth/inc/rtk_bt_le_gap.h index 7fd820ed77..6746b121a5 100644 --- a/os/board/rtl8730e/src/component/bluetooth/inc/rtk_bt_le_gap.h +++ b/os/board/rtl8730e/src/component/bluetooth/inc/rtk_bt_le_gap.h @@ -1890,7 +1890,12 @@ typedef struct { uint16_t *p_tx_pending_num; } rtk_bt_le_get_tx_pending_num_param_t; - +#if defined(RTK_BLE_5_0_AE_ADV_SUPPORT) && RTK_BLE_5_0_AE_ADV_SUPPORT +typedef struct { + uint16_t conn_handle; + uint8_t *adv_handle; +} rtk_bt_le_get_eadv_by_conn_handle_param_t; +#endif /********************************* Functions Declaration *******************************/ /** * @defgroup bt_le_gap BT LE GAP APIs diff --git a/os/include/tinyara/net/if/ble.h b/os/include/tinyara/net/if/ble.h index 95a1a2c612..b0f66a5aad 100644 --- a/os/include/tinyara/net/if/ble.h +++ b/os/include/tinyara/net/if/ble.h @@ -315,7 +315,7 @@ typedef enum { TRBLE_SERVER_DISCONNECTED, } trble_server_connection_type_e; -typedef void (*trble_server_connected_t)(trble_conn_handle con_handle, trble_server_connection_type_e conn_type, uint8_t mac[TRBLE_BD_ADDR_MAX_LEN]); +typedef void (*trble_server_connected_t)(trble_conn_handle con_handle, trble_server_connection_type_e conn_type, uint8_t mac[TRBLE_BD_ADDR_MAX_LEN], uint8_t adv_handle); typedef void (*trble_server_disconnected_t)(trble_conn_handle con_handle, uint16_t cause); typedef void (*trble_server_mtu_update_t)(trble_conn_handle con_handle, uint16_t mtu_size); typedef void (*trble_server_oneshot_adv_t)(uint16_t adv_ret);