Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os/board/rtl8730e: include ADV handle in BLE connection callback #6603

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion apps/examples/ble_rmc/ble_rmc_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion framework/include/ble_manager/ble_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static rtk_bt_evt_cb_ret_t ble_tizenrt_peripheral_gap_app_callback(uint8_t evt_c
role = conn_ind->role ? "slave" : "master";
dbg("[APP] Connected, handle: %d, role: %s, remote device: %s\r\n",
conn_ind->conn_handle, role, le_addr);
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 {
dbg("[APP] Connection establish failed(err: 0x%x), remote device: %s\r\n",
conn_ind->err, le_addr);
Expand All @@ -148,7 +148,7 @@ static rtk_bt_evt_cb_ret_t ble_tizenrt_peripheral_gap_app_callback(uint8_t evt_c
role = disconn_ind->role ? "slave" : "master";
dbg("[APP] Disconnected, reason: 0x%x, handle: %d, role: %s, remote device: %s\r\n",
disconn_ind->reason, disconn_ind->conn_handle, role, le_addr);
server_init_parm.connected_cb(disconn_ind->conn_handle, TRBLE_SERVER_DISCONNECTED, disconn_ind->peer_addr.addr_val);
server_init_parm.connected_cb(disconn_ind->conn_handle, TRBLE_SERVER_DISCONNECTED, disconn_ind->peer_addr.addr_val, 0xff);// the last field 0xff is a dummy value for adv handle which is for AI-Lite only
//rtk_bt_le_gap_start_adv(&adv_param);
break;
}
Expand Down Expand Up @@ -281,7 +281,7 @@ static rtk_bt_evt_cb_ret_t ble_tizenrt_peripheral_gap_app_callback(uint8_t evt_c
dbg("[APP] Get conn info failed! \r\n");
break;
}
server_init_parm.connected_cb(auth_cplt_ind->conn_handle, TRBLE_SERVER_SM_CONNECTED, conn_info.remote.addr_val);
server_init_parm.connected_cb(auth_cplt_ind->conn_handle, TRBLE_SERVER_SM_CONNECTED, conn_info.remote.addr_val, 0xff);// the last field 0xff is a dummy value for adv handle which is for AI-Lite only
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions os/board/rtl8730e/src/component/bluetooth/api/rtk_bt_le_gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion os/include/tinyara/net/if/ble.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down