Exemplo n.º 1
0
/**
 ****************************************************************************************
 * @brief Handles connection complete event from the GAP. Will enable profile.
 *
 * @param[in] msgid     Id of the message received.
 * @param[in] param     Pointer to the parameters of the message.
 * @param[in] dest_id   ID of the receiving task instance (TASK_GAP).
 * @param[in] src_id    ID of the sending task instance.
 *
 * @return If the message was consumed or not.
 ****************************************************************************************
 */
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)
{
		// Connection Index
		if (ke_state_get(dest_id) == APP_CONNECTABLE)
		{
				app_env.conidx = KE_IDX_GET(src_id);
				
				if (app_env.conidx != GAP_INVALID_CONIDX)
				{
						//Disable timer of the establishment of the connection
						ke_timer_clear(APP_CONN_TIMER, TASK_APP);
						
						ke_state_set(dest_id, APP_CONNECTED);
						
						app_connection_func(param);
						
						// Retrieve the connection info from the parameters
						app_env.conhdl = param->conhdl;
						
						app_env.peer_addr_type = param->peer_addr_type;
						memcpy(app_env.peer_addr.addr, param->peer_addr.addr, BD_ADDR_LEN);
             
						// send connection confirmation    // 发送连接确认aiwesky 20151004
						app_connect_confirm(GAP_AUTH_REQ_NO_MITM_NO_BOND);            
						
						// Start param update
						app_param_update_start();         // 此时,就可以进行profile读取了  aiwesky 20151004
				}
				else
				{
						// No connection has been establish, restart advertising
						app_adv_start();    // 如果没有连接,则继续进行广播 aiwesky 20151005
				}        
				
		}
		else
		{
				// APP_CONNECTABLE state is used to wait the GAP_LE_CREATE_CONN_REQ_CMP_EVT message
				ASSERT_ERR(0);
    }

    return (KE_MSG_CONSUMED);
}
Exemplo n.º 2
0
/**
 ****************************************************************************************
 * @brief Handles connection complete event from the GAP. Will enable profile.
 *
 * @param[in] msgid     Id of the message received.
 * @param[in] param     Pointer to the parameters of the message.
 * @param[in] dest_id   ID of the receiving task instance (TASK_GAP).
 * @param[in] src_id    ID of the sending task instance.
 *
 * @return If the message was consumed or not.
 ****************************************************************************************
 */
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)
{
    // Connection Index
    if (ke_state_get(dest_id) == APP_CONNECTABLE) {
        app_env.conidx = KE_IDX_GET(src_id);
        app_connection_func(param);
    }
    else {
        // APP_CONNECTABLE state is used to wait the GAP_LE_CREATE_CONN_REQ_CMP_EVT message
        ASSERT_ERR(0);
    }

    return (KE_MSG_CONSUMED);
}