コード例 #1
0
ファイル: arch_main.c プロジェクト: Sunshine2012/SmartLight
/**
****************************************************************************************
* @brief Function called to send a message through UART.
*
* @param[in]  msgid   U16 message id from ke_msg.
* @param[in] *param   Pointer to parameters of the message in ke_msg.
* @param[in]  dest_id Destination task id.
* @param[in]  src_id  Source task ID.
*
* @return             Kernel message state, must be KE_MSG_NO_FREE.
*****************************************************************************************
*/
static int my_gtl_msg_send_handler (ke_msg_id_t const msgid,
                          void *param,
                          ke_task_id_t const dest_id,
                          ke_task_id_t const src_id)
{
     //extract the ke_msg pointer from the param passed and push it in GTL queue
    struct ke_msg *msg = ke_param2msg(param);

    // Check if there is no transmission ongoing
    if (ke_state_get(TASK_GTL) != GTL_TX_IDLE)
    {
        if(gtl_env.tx_queue.tx_data_packet > MAX_GTL_PENDING_PACKETS_ADV)
        {
            if(msgid == GAPM_ADV_REPORT_IND || gtl_env.tx_queue.tx_data_packet > MAX_GTL_PENDING_PACKETS)
                return KE_MSG_CONSUMED;
        }
        co_list_push_back(&gtl_env.tx_queue, &(msg->hdr));
    }
    else
    {
        // send the message
        gtl_send_msg(msg);

        // Set GTL task to TX ONGOING state
        ke_state_set(TASK_GTL, GTL_TX_ONGOING);
    }

    //return NO_FREE always since gtl_eif_write handles the freeing
    return KE_MSG_NO_FREE;
}
コード例 #2
0
ファイル: app_com.c プロジェクト: haby77/fireble_passthrough
void app_push(struct ke_msg *msg)
{
    // Push the message into the list of messages pending for transmission
    co_list_push_back(&com_env.queue_rx, &msg->hdr);
    QPRINTF("\r\n@@@app_push:");
    for (uint8_t i = 0; i<msg->param_len; i++)
        QPRINTF("%c",((uint8_t *)&msg->param)[i]);
    QPRINTF("\r\n");
	
		//only send in the first push.
		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++;
		}
}
コード例 #3
0
ファイル: app_com.c プロジェクト: haby77/fireble_passthrough
// Push msg into eaci tx queue
static void com_push(struct ke_msg *msg)
{
    // Push the message into the list of messages pending for transmission
    co_list_push_back(&com_env.queue_tx, &msg->hdr);

    // Check if there is no transmission ongoing
    if (com_env.tx_state == COM_UART_TX_IDLE)
        // Forward the message to the HCI UART for immediate transmission
        com_uart_write(msg);
}