2 posts / 0 new
Last post
wangzexing
Offline
Last seen: 15 hours 10 min ago
Joined: 2018-07-30 03:24
一主多从连接 从机偶尔无法回连

测试及现象:我在用DA14585开发一主多从的时候出现,当主机连上三个从机后,若对其中一个从机反复上下电测试回连的情况,有一定概率回连不上主机,已连接的另外两个设备仍在连接中。而此刻该从机的广播能用安卓平板搜索到,此时若用平板对该从机进行反复连接然后断开操作,有可能该从机又能自动回连上我的585从机。
分析:我的分析,出现上诉现象时,通过抓主机log发现主机在发起连接时进入到app_easy_gap_start_connection_to函数后,主机底层未返回到gapc_connection_req_ind_handler中。
请问这会是什么问题呢?
SDK代码如下:
void app_easy_gap_start_connection_to(void)
{
arch_printf("app_easy_gap_start_connection_to()\r\n");
struct gapm_start_connection_cmd* msg;
msg = app_easy_gap_start_connection_to_msg_create();
app_connect_start_msg_send((void *) msg);
start_connection_cmd = NULL;
}
//////////////////////////////////////////
static int gapc_connection_req_ind_handler(ke_msg_id_t const msgid,
struct gapc_connection_req_ind const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
arch_printf("gapc_connection_req_ind_handler()\r\n");
uint8_t conidx = KE_IDX_GET(src_id);
uint8_t current_state = ke_state_get(KE_BUILD_ID(KE_TYPE_GET(dest_id), conidx));
ASSERT_WARNING(conidx < APP_EASY_MAX_ACTIVE_CONNECTION);
// Connection Index
if (current_state == APP_CONNECTABLE)
{
arch_printf("current_state == APP_CONNECTABLE\r\n");
ASSERT_WARNING(conidx < APP_EASY_MAX_ACTIVE_CONNECTION);
app_env[conidx].conidx = conidx;

if (conidx != GAP_INVALID_CONIDX)
{
app_env[conidx].connection_active = true;
ke_state_set(KE_BUILD_ID(KE_TYPE_GET(dest_id), conidx), APP_CONNECTED);
// Retrieve the connection info from the parameters
app_env[conidx].conhdl = param->conhdl;
app_env[conidx].peer_addr_type = param->peer_addr_type;
memcpy(app_env[conidx].peer_addr.addr, param->peer_addr.addr, BD_ADDR_LEN);
#if (BLE_APP_SEC)
// send connection confirmation
app_easy_gap_confirm(conidx, (enum gap_auth) app_sec_env[conidx].auth, 1);
#else
app_easy_gap_confirm(conidx, GAP_AUTH_REQ_NO_MITM_NO_BOND, 1);
#endif
}
CALLBACK_ARGS_2(user_app_callbacks.app_on_connection, conidx, param)
}
else
{
// APP_CONNECTABLE state is used to wait the GAP_LE_CREATE_CONN_REQ_CMP_EVT message
// ASSERT_ERROR(0);
arch_printf("current_state != APP_CONNECTABLE\r\n");
conidx = GAP_INVALID_CONIDX;
CALLBACK_ARGS_2(user_app_callbacks.app_on_connection, conidx, param)
}
return (KE_MSG_CONSUMED);
}

Device: 
CYibin
Offline
Last seen: 11 hours 37 min ago
Staff
Joined: 2017-12-14 02:48
你好,

你好,

是不是 connect_event 参数设置有问题?