Example #1
0
/**
 ****************************************************************************************
 * @brief Disconnection indication to ANPC.
 * @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
 * @param[in] src_id    ID of the sending task instance.
 * @return If the message was consumed or not.
 ****************************************************************************************
 */
static int gap_discon_cmp_evt_handler(ke_msg_id_t const msgid,
                                      struct gap_discon_cmp_evt const *param,
                                      ke_task_id_t const dest_id,
                                      ke_task_id_t const src_id)
{
    // Get the address of the environment
    struct cscpc_env_tag *cscpc_env = PRF_CLIENT_GET_ENV(dest_id, cscpc);

    ASSERT_ERR(cscpc_env != NULL);

    // Free the stored operation if needed
    if (cscpc_env->operation != NULL)
    {
        // Check if we were waiting for a SC Control Point indication
        if (((struct cscpc_cmd *)cscpc_env->operation)->operation == CSCPC_CTNL_PT_CFG_IND_OP_CODE)
        {
            // Stop the procedure timeout timer
            ke_timer_clear(CSCPC_TIMEOUT_TIMER_IND, dest_id);
        }

        ke_msg_free(ke_param2msg(cscpc_env->operation));
        cscpc_env->operation = NULL;
    }

    PRF_CLIENT_DISABLE_IND_SEND(cscpc_envs, dest_id, CSCPC);

    return (KE_MSG_CONSUMED);
}
Example #2
0
void rscpc_send_cmp_evt(struct rscpc_env_tag *rscpc_env, uint8_t operation, uint8_t status)
{
    // Free the stored operation if needed
    if (rscpc_env->operation != NULL)
    {
        ke_msg_free(ke_param2msg(rscpc_env->operation));
        rscpc_env->operation = NULL;
    }

    // Go back to the CONNECTED state if the state is busy
    if (ke_state_get(rscpc_env->con_info.prf_id) == RSCPC_BUSY)
    {
        ke_state_set(rscpc_env->con_info.prf_id, RSCPC_CONNECTED);
    }

    // Send the message
    struct rscpc_cmp_evt *evt = KE_MSG_ALLOC(RSCPC_CMP_EVT,
                                             rscpc_env->con_info.appid, rscpc_env->con_info.prf_id,
                                             rscpc_cmp_evt);

    evt->conhdl     = gapc_get_conhdl(rscpc_env->con_info.conidx);
    evt->operation  = operation;
    evt->status     = status;

    ke_msg_send(evt);
}
Example #3
0
void rscpc_cleanup(prf_env_struct *idx_env)
{
    struct rscpc_env_tag *env = (struct rscpc_env_tag *) idx_env;

    if(env->operation != NULL)
    {
        ke_msg_free(ke_param2msg(env->operation));
        env->operation = NULL;
    }
}
Example #4
0
/**
****************************************************************************************
* @brief After-process when one PDU has been sent.
*
****************************************************************************************
*/
void com_tx_done(void)
{
    struct ke_msg * msg;
    // Clear the event
    ke_evt_clear(1<<EVENT_UART_TX_ID);
    // Go back to IDLE state
    com_env.tx_state = COM_UART_TX_IDLE;
    //release current message (which was just sent)
    msg = (struct ke_msg *)co_list_pop_front(&com_env.queue_tx);
    // Free the kernel message space
    ke_msg_free(msg);
    // Check if there is a new message pending for transmission
    if ((msg = (struct ke_msg *)co_list_pick(&com_env.queue_tx)) != NULL)
    {
        // Forward the message to the HCI UART for immediate transmission
        com_uart_write(msg);
    }
}
Example #5
0
void app_tx_done(void)
{
    struct ke_msg * msg;
    //release current message (which was just sent)
    msg = (struct ke_msg *)co_list_pop_front(&com_env.queue_rx);
    // Free the kernel message space
    ke_msg_free(msg);
    // Check if there is a new message pending for transmission
    if ((msg = (struct ke_msg *)co_list_pick(&com_env.queue_rx)) != NULL)
    {
        // Forward the message to the HCI UART for immediate transmission
        QPRINTF("\r\n@@@app_tx_done:");
        for (uint8_t i = 0; i<msg->param_len; i++)
            QPRINTF("%c",((uint8_t *)&msg->param)[i]);
        QPRINTF("\r\n");
			
			
				uint8_t *p_data = (uint8_t *)msg->param;
				uint8_t pack_nb = msg->param_len/QPP_DATA_MAX_LEN + 1;
				uint8_t pack_divide_len =  msg->param_len%QPP_DATA_MAX_LEN;
				for (uint8_t char_idx = 0,i = 0;((app_qpps_env->char_status & (~(QPPS_VALUE_NTF_CFG << (char_idx - 1)))) && (char_idx < QPPS_VAL_CHAR_NUM));char_idx++)
				{
					if (i < (pack_nb - 1))
					{
						app_qpps_env->char_status &= ~(QPPS_VALUE_NTF_CFG << char_idx);
						app_qpps_data_send(app_qpps_env->conhdl,char_idx,QPP_DATA_MAX_LEN,(uint8_t *)p_data);
						p_data += QPP_DATA_MAX_LEN;
					}
					else
					{
						if ((pack_divide_len != 0) && (i == (pack_nb - 1)))
						{
							app_qpps_env->char_status &= ~(QPPS_VALUE_NTF_CFG << char_idx);
							app_qpps_data_send(app_qpps_env->conhdl,char_idx,pack_divide_len,(uint8_t *)p_data);
							p_data += pack_divide_len;
						}
					}
					i++;
				}
				
    }

    QPRINTF("app_tx_done\r\n");
}
Example #6
0
/**
 ****************************************************************************************
 * @brief Disconnection indication to ANPC.
 * @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
 * @param[in] src_id    ID of the sending task instance.
 * @return If the message was consumed or not.
 ****************************************************************************************
 */
static int gapc_disconnect_ind_handler(ke_msg_id_t const msgid,
                                      struct gapc_disconnect_ind const *param,
                                      ke_task_id_t const dest_id,
                                      ke_task_id_t const src_id)
{
    // Get the address of the environment
    struct anpc_env_tag *anpc_env = PRF_CLIENT_GET_ENV(dest_id, anpc);

    ASSERT_ERR(anpc_env != NULL);

    // Free the stored operation if needed
    if (anpc_env->operation != NULL)
    {
        ke_msg_free(ke_param2msg(anpc_env->operation));
        anpc_env->operation = NULL;
    }

    PRF_CLIENT_DISABLE_IND_SEND(anpc_envs, dest_id, ANPC, param->conhdl);

    return (KE_MSG_CONSUMED);
}