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); }
/** **************************************************************************************** * @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); }
/** **************************************************************************************** * @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(>l_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; }
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; } }
/** **************************************************************************************** * @brief EACI send PDU * **************************************************************************************** */ void com_pdu_send(uint8_t len, uint8_t *par) { // Allocate one msg for EACI tx uint8_t *msg_param = (uint8_t*)ke_msg_alloc(0, 0, 0, len); // Save the PDU in the MSG memcpy(msg_param, par, len); //extract the ke_msg pointer from the param passed and push it in HCI queue com_push(ke_param2msg(msg_param)); }
void dev_send_to_app(struct app_uart_data_ind *param) { uint8_t *buf_20; int16_t len = param->len; int16_t send_len = 0; uint8_t packet_len = get_bit_num(app_qpps_env->char_status)*20; #ifdef CATCH_LOG QPRINTF("\r\n@@@len %d\r\n@@@data\r\n",len); for(uint8_t j = 0; j<len; j++) QPRINTF("%c",param->data[j]); QPRINTF("\r\n"); #endif if(app_qpps_env->char_status) { for(uint8_t i =0; send_len < len; i++) { if (len > packet_len) //Split data into package when len longger than 20 { if (len - send_len > packet_len) { buf_20 = (uint8_t*)ke_msg_alloc(0, 0, 0, packet_len); if(buf_20 != NULL) { memcpy(buf_20,param->data+send_len,packet_len); send_len+=packet_len; } } else { buf_20 = (uint8_t *)ke_msg_alloc(0,0,0,len-send_len); if (buf_20 != NULL) { memcpy(buf_20,param->data+send_len,len-send_len); send_len = len; } } } else //not longger ther 20 send data directely { buf_20 = (uint8_t *)ke_msg_alloc(0,0,0,len); if (buf_20 != NULL) { memcpy(buf_20,param->data,len); send_len = len; } //app_qpps_data_send(app_qpps_env->conhdl,0,len,param->data); } //push the package to kernel queue. app_push(ke_param2msg(buf_20)); } } }
/** **************************************************************************************** * @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); }