static int disc_enable_cfm_handler(ke_msg_id_t const msgid, struct disc_enable_cfm const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { switch(param->status) { case PRF_ERR_OK: break; case PRF_ERR_STOP_DISC_CHAR_MISSING: arch_puts("DIS-C: Missing characteristic!\r\n"); break; case PRF_ERR_MULTIPLE_SVC: arch_puts("DIS-C: Multiple services!\r\n"); break; default: break; } if(param->status != PRF_ERR_OK) { // Go to the idle state ke_state_set(dest_id, APP_DISC_IDLE); } else { // Go to the connected state ke_state_set(dest_id, APP_DISC_CONNECTED); // Keep read values somewhere dis = param->dis; } return (KE_MSG_CONSUMED); }
void htpc_enable_cfm_send(struct htpc_env_tag *htpc_env, struct prf_con_info *con_info, uint8_t status) { // Inform the APP about the status of the enabling of the Health Thermometer Profile Collector role 5awk struct htpc_enable_cfm *cfm = KE_MSG_ALLOC(HTPC_ENABLE_CFM, con_info->appid, con_info->prf_id, htpc_enable_cfm); // Connection Handle cfm->conhdl = gapc_get_conhdl(con_info->conidx); // Status cfm->status = status; // If status is PRF_ERR_OK, hts is non NULL if (status == PRF_ERR_OK) { // Attributes discovered in the peer device database cfm->hts = htpc_env->hts; // Register the profile task in GATT in order to receive notifications/indications prf_register_atthdl2gatt(con_info, &htpc_env->hts.svc); // Go to connected state ke_state_set(con_info->prf_id, HTPC_CONNECTED); } else { PRF_CLIENT_ENABLE_ERROR(htpc_envs, con_info->prf_id, HTPC); } // Send the confirmation to the application ke_msg_send(cfm); }
static int htpt_create_db_cfm_handler(ke_msg_id_t const msgid, struct htpt_create_db_cfm const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { if (ke_state_get(dest_id) == APP_HT_DISABLED) { if (param->status == PRF_ERR_OK) { // Go to Idle state ke_state_set(TASK_APP_HT, APP_HT_IDLE); } // Inform the Application Manager struct app_module_init_cmp_evt *cfm = KE_MSG_ALLOC(APP_MODULE_INIT_CMP_EVT, TASK_APP, TASK_APP_HT, app_module_init_cmp_evt); cfm->status = param->status; ke_msg_send(cfm); } return (KE_MSG_CONSUMED); }
void pasps_disable(struct pasps_idx_env_tag *idx_env) { // Disable PAS service attsdb_svc_set_permission(pasps_env.pass_shdl, PERM(SVC, DISABLE)); struct pasps_disable_ind *ind = KE_MSG_ALLOC(PASPS_DISABLE_IND, idx_env->con_info.appid, idx_env->con_info.prf_id, pasps_disable_ind); memset(ind, 0x00, sizeof(struct pasps_disable_ind)); ind->conhdl = idx_env->con_info.conhdl; if (PASPS_IS_NTF_ENABLED(idx_env, PASPS_FLAG_ALERT_STATUS_CFG)) { ind->alert_status_ntf_cfg = PRF_CLI_START_NTF; } if (PASPS_IS_NTF_ENABLED(idx_env, PASPS_FLAG_RINGER_SETTING_CFG)) { ind->ringer_setting_ntf_cfg = PRF_CLI_START_NTF; } ke_msg_send(ind); // Go to idle state ke_state_set(idx_env->con_info.prf_id, PASPS_IDLE); // Free the environment allocated for this connection prf_client_disable((prf_env_struct ***)&pasps_idx_envs, KE_IDX_GET(idx_env->con_info.prf_id)); }
/** **************************************************************************************** * @brief Enable the Sample128 role, used after connection. * @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 sample128_enable_req_handler(ke_msg_id_t const msgid, struct sample128_enable_req const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { // Keep source of message, to respond to it further on sample128_env.con_info.appid = src_id; // Store the connection handle for which this profile is enabled sample128_env.con_info.conidx = gapc_get_conidx(param->conhdl); // Check if the provided connection exist if (sample128_env.con_info.conidx == GAP_INVALID_CONIDX) { // The connection doesn't exist, request disallowed prf_server_error_ind_send((prf_env_struct *)&sample128_env, PRF_ERR_REQ_DISALLOWED, SAMPLE128_ERROR_IND, SAMPLE128_ENABLE_REQ); } else { // Sample128 1 attmdb_svc_set_permission(sample128_env.sample128_1_shdl, param->sec_lvl); //Set LLS Alert Level to specified value attmdb_att_set_value(sample128_env.sample128_1_shdl + SAMPLE128_1_IDX_VAL, sizeof(uint8_t), (uint8_t *)¶m->sample128_1_val); // Go to Connected state ke_state_set(TASK_SAMPLE128, SAMPLE128_CONNECTED); } return (KE_MSG_CONSUMED); }
static int udss_create_db_req_handler(ke_msg_id_t const msgid, struct udss_create_db_req const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { //DB Creation Statis uint8_t status = ATT_ERR_NO_ERROR; //Save profile id udss_env.con_info.prf_id = TASK_UDSS; status = attm_svc_create_db(&udss_env.shdl, NULL, UDS_IDX_NB, &udss_env.att_tbl[0], dest_id, &udss_att_db[0]); if (status == ATT_ERR_NO_ERROR) { //Disable service status = attmdb_svc_set_permission(udss_env.shdl, PERM(SVC, DISABLE)); //If we are here, database has been fulfilled with success, go to idle test ke_state_set(TASK_UDSS, UDSS_IDLE); } //Send response to application struct udss_create_db_cfm * cfm = KE_MSG_ALLOC(UDSS_CREATE_DB_CFM, src_id, TASK_UDSS, udss_create_db_cfm); cfm->status = status; ke_msg_send(cfm); return (KE_MSG_CONSUMED); }
void prf_client_reset(prf_env_struct ***p_envs, ke_task_id_t task_type, ke_state_t state, struct ke_task_desc const * p_task_desc) { // Index uint8_t conidx; // Check if the provided pool of environments exists if (*p_envs != NULL) { // Remove all existing environments for (conidx = 0; conidx < jump_table_struct[nb_links_user]; conidx++) { prf_client_env_free(p_envs, conidx); } // Remove the pool of environments prf_client_pool_envs_free(p_envs); } // Create task ke_task_create(task_type, p_task_desc); // Set the state to IDLE for each task instance for (conidx = 0; conidx < jump_table_struct[nb_links_user]; conidx++) { // Go to IDLE state ke_state_set(KE_BUILD_ID(task_type, conidx), state); } }
void wptc_enable_cfm_send(struct wptc_env_tag *wptc_env, struct prf_con_info *con_info, uint8_t status) { //format response to app struct wptc_enable_cfm * cfm = KE_MSG_ALLOC(WPTC_ENABLE_CFM, con_info->appid, con_info->prf_id, wptc_enable_cfm); cfm->conhdl = gapc_get_conhdl(con_info->conidx); cfm->status = status; if (status == PRF_ERR_OK) { cfm->wpts = wptc_env->wpts; // Register WPT Client task in gatt for indication/notifications prf_register_atthdl2gatt(&wptc_env->con_info, &wptc_env->wpts.svc); // Go to connected state ke_state_set(con_info->prf_id, WPTC_CONNECTED); } else { PRF_CLIENT_ENABLE_ERROR(wptc_envs, con_info->prf_id, WPTC); } ke_msg_send(cfm); }
void scppc_enable_cfm_send(struct scppc_env_tag *scppc_env, struct prf_con_info *con_info, uint8_t status) { //send APP the details of the discovered attributes on SCPPC struct scppc_enable_cfm * rsp = KE_MSG_ALLOC(SCPPC_ENABLE_CFM, con_info->appid, con_info->prf_id, scppc_enable_cfm); rsp->conhdl = gapc_get_conhdl(con_info->conidx); rsp->status = status; if (status == PRF_ERR_OK) { rsp->scps = scppc_env->scps; // Go to connected state ke_state_set(con_info->prf_id, SCPPC_CONNECTED); // If Scan Refresh Char. has been discovered if (scppc_env->scps.chars[SCPPC_CHAR_SCAN_REFRESH].char_hdl != ATT_INVALID_HANDLE) { // Register SCPPC task in gatt for notifications prf_register_atthdl2gatt(con_info, &scppc_env->scps.svc); } } else { PRF_CLIENT_ENABLE_ERROR(scppc_envs, con_info->prf_id, SCPPC); } ke_msg_send(rsp); }
void proxm_enable_cfm_send(struct proxm_env_tag *proxm_env, struct prf_con_info *con_info, uint8_t status) { //format response to app struct proxm_enable_cfm * cfm = KE_MSG_ALLOC(PROXM_ENABLE_CFM, con_info->appid, con_info->prf_id, proxm_enable_cfm); cfm->conhdl = gapc_get_conhdl(con_info->conidx); cfm->status = status; if (status == PRF_ERR_OK) { cfm->ias = proxm_env->ias; cfm->lls = proxm_env->lls; cfm->txps = proxm_env->txps; // Go to connected state ke_state_set(con_info->prf_id, PROXM_CONNECTED); } else { PRF_CLIENT_ENABLE_ERROR(proxm_envs, con_info->prf_id, PROXM); } ke_msg_send(cfm); }
void blpc_enable_cfm_send(struct blpc_env_tag *blpc_env, struct prf_con_info *con_info, uint8_t status) { // Send to APP the details of the discovered attributes on BLPS struct blpc_enable_cfm * rsp = KE_MSG_ALLOC(BLPC_ENABLE_CFM, con_info->appid, con_info->prf_id, blpc_enable_cfm); rsp->conhdl = gapc_get_conhdl(con_info->conidx); rsp->status = status; if (status == PRF_ERR_OK) { rsp->bps = blpc_env->bps; prf_register_atthdl2gatt(&blpc_env->con_info, &blpc_env->bps.svc); // Go to connected state ke_state_set(blpc_env->con_info.prf_id, BLPC_CONNECTED); } else { PRF_CLIENT_ENABLE_ERROR(blpc_envs, con_info->prf_id, BLPC); } ke_msg_send(rsp); }
void streamdatah_enable_cfm_send(struct streamdatah_env_tag *streamdatah_env, struct prf_con_info *con_info, uint8_t status) { //format response to app struct streamdatah_enable_cfm * cfm = KE_MSG_ALLOC(STREAMDATAH_ENABLE_CFM, con_info->appid, con_info->prf_id, streamdatah_enable_cfm); cfm->conhdl = gapc_get_conhdl(con_info->conidx); cfm->status = status; if (status == PRF_ERR_OK) { cfm->streamdatah = streamdatah_env->streamdatah; // Register STREAMDATAH task in gatt for indication/notifications prf_register_atthdl2gatt(&streamdatah_env->con_info, &streamdatah_env->streamdatah.svc); // Go to connected state ke_state_set(con_info->prf_id, STREAMDATAH_CONNECTED); } else { PRF_CLIENT_ENABLE_ERROR(streamdatah_envs, con_info->prf_id, STREAMDATAH); } ke_msg_send(cfm); }
void wechat_disable(void) { att_size_t length; uint8_t *alert_lvl; // Disable service in database attmdb_svc_set_permission(wechat_env.wechat_shdl, PERM_RIGHT_DISABLE); struct wechat_disable_ind *ind = KE_MSG_ALLOC(WECHAT_DISABLE_IND, wechat_env.con_info.appid, TASK_WECHAT, wechat_disable_ind); //Get value stored in DB attmdb_att_get_value(wechat_env.wechat_shdl + WECHAT_1_IDX_VAL, &length, &alert_lvl); // Fill in the parameter structure ind->conhdl = gapc_get_conhdl(wechat_env.con_info.conidx); // Send the message ke_msg_send(ind); // Go to idle state ke_state_set(TASK_WECHAT, WECHAT_IDLE); }
/** **************************************************************************************** * @brief Enable the StreamData client role, used after connection. * @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 sps_client_enable_req_handler(ke_msg_id_t const msgid, struct sps_client_enable_req const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { // Status uint8_t status; // Device Information Service Client Role Task Environment struct sps_client_env_tag *sps_client_env; // Connection Information struct prf_con_info con_info; // Fill the Connection Information structure con_info.conidx = gapc_get_conidx(param->conhdl); con_info.prf_id = dest_id; con_info.appid = src_id; // Add an environment for the provided device status = PRF_CLIENT_ENABLE(con_info, param, sps_client); if (status == PRF_ERR_FEATURE_NOT_SUPPORTED) { // The message has been forwarded to another task id. return (KE_MSG_NO_FREE); } else if (status == PRF_ERR_OK) { sps_client_env = PRF_CLIENT_GET_ENV(dest_id, sps_client); // Discovery connection if (param->con_type == PRF_CON_DISCOVERY) { // Start discovering LLS on peer uint8_t sps_data_service_uuid[]=SPS_SERVICE_UUID; sps_client_env->last_uuid_req = ATT_DECL_PRIMARY_SERVICE; memcpy(sps_client_env->last_svc_req, sps_data_service_uuid, ATT_UUID_128_LEN); prf_disc_svc_send_128(&sps_client_env->con_info, sps_client_env->last_svc_req); // Set state to discovering ke_state_set(dest_id, SPS_CLIENT_DISCOVERING); } else { //copy over data that has been stored sps_client_env->sps_server = param->sps_server; //send confirmation of enable request to application sps_client_enable_cfm_send(sps_client_env, &con_info, PRF_ERR_OK); } } else { sps_client_enable_cfm_send(NULL, &con_info, status); } // message is consumed return (KE_MSG_CONSUMED); }
/** **************************************************************************************** * @brief Handles GAP controller command complete events. * * @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_cmp_evt_handler(ke_msg_id_t const msgid, struct gapc_cmp_evt const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { switch(param->operation) { // reset completed case GAPC_UPDATE_PARAMS: if (ke_state_get(dest_id) == APP_PARAM_UPD) { if ((param->status != CO_ERROR_NO_ERROR)) { // it's application specific what to do when the Param Upd request is rejected app_update_params_rejected_func(param->status); } else { // Go to Connected State ke_state_set(dest_id, APP_CONNECTED); // if state is APP_CONNECTED then the request was accepted app_update_params_complete_func(); } } break; default: if(param->status != GAP_ERR_NO_ERROR) { ASSERT_ERR(0); // unexpected error } break; } return (KE_MSG_CONSUMED); }
void hogpd_disable(void) { // HIDS instance counter uint8_t hids_nb; // Report Char. instance counter uint8_t report_nb; struct hogpd_disable_ind *ind = KE_MSG_ALLOC(HOGPD_DISABLE_IND, hogpd_env.con_info.appid, TASK_HOGPD, hogpd_disable_ind); ind->conhdl = hogpd_env.con_info.conhdl; for (hids_nb = 0; hids_nb < hogpd_env.hids_nb; hids_nb++) { // Disable HIDS in database attsdb_svc_set_permission(hogpd_env.shdl[hids_nb], PERM_RIGHT_DISABLE); // Save Boot Keyboard Input Report Char. Ntf Cfg if (hogpd_env.att_tbl[hids_nb][HOGPD_BOOT_KB_IN_REPORT_CHAR] != 0x00) { if ((hogpd_env.features[hids_nb].svc_features & HOGPD_BOOT_KB_IN_NTF_CFG_MASK) == HOGPD_BOOT_KB_IN_NTF_CFG_MASK) { ind->ntf_cfg[hids_nb].boot_kb_in_report_ntf_en = PRF_CLI_START_NTF; } } // Save Boot Mouse Input Report Char. Ntf Cfg if (hogpd_env.att_tbl[hids_nb][HOGPD_BOOT_MOUSE_IN_REPORT_CHAR] != 0x00) { if ((hogpd_env.features[hids_nb].svc_features & HOGPD_BOOT_MOUSE_IN_NTF_CFG_MASK) == HOGPD_BOOT_MOUSE_IN_NTF_CFG_MASK) { ind->ntf_cfg[hids_nb].boot_mouse_in_report_ntf_en = PRF_CLI_START_NTF; } } //Reset notifications bit field hogpd_env.features[hids_nb].svc_features &= ~(HOGPD_BOOT_KB_IN_NTF_CFG_MASK | HOGPD_BOOT_MOUSE_IN_NTF_CFG_MASK); // Save Report Char. Ntf Cfg for (report_nb = 0; report_nb < hogpd_env.features[hids_nb].report_nb; report_nb++) { if ((hogpd_env.features[hids_nb].report_char_cfg[report_nb] & HOGPD_REPORT_NTF_CFG_MASK) == HOGPD_REPORT_NTF_CFG_MASK) { ind->ntf_cfg[hids_nb].report_ntf_en[report_nb] = PRF_CLI_START_NTF; } //Reset notifications bit field hogpd_env.features[hids_nb].report_char_cfg[report_nb] &= ~HOGPD_REPORT_NTF_CFG_MASK; } } ke_msg_send(ind); //Go to idle state ke_state_set(TASK_HOGPD, HOGPD_IDLE); }
void basc_enable_cfm_send(struct basc_env_tag *basc_env, struct prf_con_info *con_info, uint8_t status) { // Counter uint8_t svc_inst; // Send APP the details of the discovered attributes on BASC struct basc_enable_cfm * rsp = KE_MSG_ALLOC(BASC_ENABLE_CFM, con_info->appid, con_info->prf_id, basc_enable_cfm); rsp->conhdl = con_info->conhdl; rsp->status = status; if (status == PRF_ERR_OK) { rsp->bas_nb = basc_env->bas_nb; for (svc_inst = 0; svc_inst < basc_env->bas_nb; svc_inst++) { rsp->bas[svc_inst] = basc_env->bas[svc_inst]; // Register BASC task in gatt for indication/notifications prf_register_atthdl2gatt(&basc_env->con_info, &basc_env->bas[svc_inst].svc); } // Go to connected state ke_state_set(con_info->prf_id, BASC_CONNECTED); } else { PRF_CLIENT_ENABLE_ERROR(basc_envs, con_info->prf_id, BASC); } ke_msg_send(rsp); }
/** **************************************************************************************** * @brief Handles reception of the @ref FINDT_ENABLE_REQ message. * The handler enables the Find Me profile - target Role. * @param[in] msgid Id of the message received (probably unused). * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance (probably unused). * @param[in] src_id ID of the sending task instance. * @return If the message was consumed or not. **************************************************************************************** */ static int findt_enable_req_handler(ke_msg_id_t const msgid, struct findt_enable_req const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { // Save the application task id findt_env.con_info.appid = src_id; // Save the connection index associated to the profile findt_env.con_info.conidx = gapc_get_conidx(param->conhdl); // Check if the provided connection exist if (findt_env.con_info.conidx == GAP_INVALID_CONIDX) { // The connection doesn't exist, request disallowed prf_server_error_ind_send((prf_env_struct *)&findt_env, PRF_ERR_REQ_DISALLOWED, FINDT_ERROR_IND, FINDT_ENABLE_REQ); } else { // Enable Service + Set Security Level attmdb_svc_set_permission(findt_env.shdl, param->sec_lvl); // Go to connected state ke_state_set(TASK_FINDT, FINDT_CONNECTED); } return (KE_MSG_CONSUMED); }
void prf_client_disable_ind_send(prf_env_struct ***p_envs, ke_msg_id_t msg_id, ke_task_id_t task_id, uint8_t state, uint16_t conhdl) { // retrieve current state uint8_t cur_state = ke_state_get(task_id); // prevent doing freeing structure if state already of profile is already free. if(cur_state != state) { // Get the address of the environment prf_env_struct *env = prf_client_get_env(*p_envs, task_id); ASSERT_WARN(env != NULL); if (env != NULL) { struct prf_client_disable_ind *ind = KE_MSG_ALLOC(msg_id, env->con_info.appid, env->con_info.prf_id, prf_client_disable_ind); ind->conhdl = conhdl; ind->status = prf_client_disable(p_envs, KE_IDX_GET(env->con_info.prf_id)); // Send the message ke_msg_send(ind); // Go to idle state ke_state_set(task_id, state); } } }
void tipc_enable_cfm_send(struct tipc_env_tag *tipc_env, struct prf_con_info *con_info, uint8_t status) { // Send to APP the details of the discovered attributes on TIPS struct tipc_enable_cfm * rsp = KE_MSG_ALLOC(TIPC_ENABLE_CFM, con_info->appid, con_info->prf_id, tipc_enable_cfm); rsp->conhdl = con_info->conhdl; rsp->status = status; if (status == PRF_ERR_OK) { rsp->cts = tipc_env->cts; rsp->ndcs = tipc_env->ndcs; rsp->rtus = tipc_env->rtus; //register TIPC task in gatt for indication/notifications prf_register_atthdl2gatt(&tipc_env->con_info, &tipc_env->cts.svc); // Go to connected state ke_state_set(tipc_env->con_info.prf_id, TIPC_CONNECTED); } else { PRF_CLIENT_ENABLE_ERROR(tipc_envs, con_info->prf_id, TIPC); } ke_msg_send(rsp); }
void scpps_disable(void) { //Disable SCPS in database attsdb_svc_set_permission(scpps_env.shdl, PERM_RIGHT_DISABLE); //Send current configuration to the application struct scpps_disable_ind *ind = KE_MSG_ALLOC(SCPPS_DISABLE_IND, scpps_env.con_info.appid, TASK_SCPPS, scpps_disable_ind); ind->conhdl = scpps_env.con_info.conhdl; if (scpps_env.scan_refresh_ntf_cfg == PRF_CLI_START_NTF) { ind->scan_refresh_ntf_en = PRF_CLI_START_NTF; } ke_msg_send(ind); // Reset saved NTF cfg value scpps_env.scan_refresh_ntf_cfg = 0; // Go to Idle state ke_state_set(TASK_SCPPS, SCPPS_IDLE); }
void app_neb_init(void) { #if (NVDS_SUPPORT) uint8_t length = NVDS_LEN_NEB_ID; #endif // NVDS_SUPPORT // Reset the environment memset(&app_neb_env, 0, sizeof(app_neb_env)); #if (NVDS_SUPPORT) // Get the current nebulizer ID from the storage if (nvds_get(NVDS_TAG_NEB_ID, &length, (uint8_t *)&app_neb_env.curr_neb_id) != NVDS_OK) #endif // NVDS_SUPPORT { // Initialize Nebulizer ID to 0 app_neb_env.curr_neb_id = 0; } // Create APP task ke_task_create(TASK_APP_NEB, &TASK_DESC_APP_NEB); // Go to Disabled state ke_state_set(TASK_APP_NEB, APP_NEB_DISABLED); }
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 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; }
/** **************************************************************************************** * @brief Enable the Proximity Monitor role, used after connection. * @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 proxm_enable_req_handler(ke_msg_id_t const msgid, struct proxm_enable_req const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { // Status uint8_t status; // Device Information Service Client Role Task Environment struct proxm_env_tag *proxm_env; // Connection Information struct prf_con_info con_info; // Fill the Connection Information structure con_info.conidx = gapc_get_conidx(param->conhdl); con_info.prf_id = dest_id; con_info.appid = src_id; // Add an environment for the provided device status = PRF_CLIENT_ENABLE(con_info, param, proxm); if (status == PRF_ERR_FEATURE_NOT_SUPPORTED) { // The message has been forwarded to another task id. return (KE_MSG_NO_FREE); } else if (status == PRF_ERR_OK) { proxm_env = PRF_CLIENT_GET_ENV(dest_id, proxm); // Discovery connection if (param->con_type == PRF_CON_DISCOVERY) { // Start discovering LLS on peer prf_disc_svc_send(&proxm_env->con_info, ATT_SVC_LINK_LOSS); proxm_env->last_uuid_req = ATT_SVC_LINK_LOSS; proxm_env->last_svc_req = ATT_SVC_LINK_LOSS; // Set state to discovering ke_state_set(dest_id, PROXM_DISCOVERING); } else { //copy over data that has been stored proxm_env->ias = param->ias; proxm_env->lls = param->lls; proxm_env->txps = param->txps; //send confirmation of enable request to application proxm_enable_cfm_send(proxm_env, &con_info, PRF_ERR_OK); } } else { proxm_enable_cfm_send(NULL, &con_info, status); } // message is consumed return (KE_MSG_CONSUMED); }
void qppc_enable_cfm_send(struct qppc_env_tag *qppc_env, struct prf_con_info *con_info, uint8_t status) { //send APP the details of the discovered attributes on QPPC struct qppc_enable_cfm * rsp = KE_MSG_ALLOC(QPPC_ENABLE_CFM, con_info->appid, con_info->prf_id, qppc_enable_cfm); rsp->conhdl = con_info->conhdl; rsp->status = status; if (status == PRF_ERR_OK) { rsp->qpps = qppc_env->qpps; rsp->nb_ntf_char = qppc_env->nb_char - 1; // exclude one RX characteristic //register HRPC task in gatt for indication/notifications prf_register_atthdl2gatt(&qppc_env->con_info, &qppc_env->qpps.svc); // Go to connected state ke_state_set(qppc_env->con_info.prf_id, QPPC_CONNECTED); } else { PRF_CLIENT_ENABLE_ERROR(qppc_env, con_info->prf_id, QPPC); } ke_msg_send(rsp); }
void cscps_disable(void) { // Disable CSCS in database attsdb_svc_set_permission(cscps_env.shdl, PERM_RIGHT_DISABLE); //Send current configuration to APP struct cscps_disable_ind* ind = KE_MSG_ALLOC(CSCPS_DISABLE_IND, cscps_env.con_info.appid, cscps_env.con_info.prf_id, cscps_disable_ind); ind->conhdl = cscps_env.con_info.conhdl; // CSC Measurement Char. - Client Characteristic Configuration Descriptor ind->csc_meas_ntf_cfg = CSCPS_IS_NTFIND_ENABLED(CSCP_PRF_CFG_FLAG_CSC_MEAS_NTF) ? PRF_CLI_START_NTF : PRF_CLI_STOP_NTFIND; // SC Control Point Char. - Client Characteristic Configuration Descriptor if (cscps_env.hdl_offset[CSCP_CSCS_SC_CTNL_PT_CHAR] != 0) { ind->sc_ctnl_pt_ntf_cfg = CSCPS_IS_NTFIND_ENABLED(CSCP_PRF_CFG_FLAG_SC_CTNL_PT_IND) ? PRF_CLI_START_IND : PRF_CLI_STOP_NTFIND; } // Total wheel revolutions ind->wheel_revol = cscps_env.wheel_revol; ke_msg_send(ind); // Reset the notification/indication status cscps_env.prf_cfg &= CSCP_FEAT_ALL_SUPP; // Go to idle state ke_state_set(TASK_CSCPS, CSCPS_IDLE); }
void glpc_enable_cfm_send(struct glpc_env_tag *glpc_env, struct prf_con_info *con_info, uint8_t status) { // Send to APP the details of the discovered attributes on GLPS struct glpc_enable_cfm * rsp = KE_MSG_ALLOC(GLPC_ENABLE_CFM, con_info->appid, con_info->prf_id, glpc_enable_cfm); rsp->conhdl = gapc_get_conhdl(con_info->conidx); rsp->status = status; if (status == PRF_ERR_OK) { rsp->gls = glpc_env->gls; // Register GLPC task in gatt for indication/notifications prf_register_atthdl2gatt(&glpc_env->con_info, &glpc_env->gls.svc); // Go to connected state ke_state_set(con_info->prf_id, GLPC_CONNECTED); } else { PRF_CLIENT_ENABLE_ERROR(glpc_envs, con_info->prf_id, GLPC); } ke_msg_send(rsp); }
/** **************************************************************************************** * @brief Handles reception of the @ref TIPC_ENABLE_REQ message. * The handler enables the Time Profile Client Role. * @param[in] msgid Id of the message received (probably unused). * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance (probably unused). * @param[in] src_id ID of the sending task instance. * @return If the message was consumed or not. **************************************************************************************** */ static int tipc_enable_req_handler(ke_msg_id_t const msgid, struct tipc_enable_req const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { // Status uint8_t status; // Battery Service Client Role Task Environment struct tipc_env_tag *tipc_env; // Connection Information struct prf_con_info con_info; // Fill the Connection Information structure con_info.conidx = gapc_get_conidx(param->conhdl); con_info.prf_id = dest_id; con_info.appid = src_id; // Add an environment for the provided device status = PRF_CLIENT_ENABLE(con_info, param, tipc); if (status == PRF_ERR_FEATURE_NOT_SUPPORTED) { // The message has been forwarded to another task id. return (KE_MSG_NO_FREE); } else if (status == PRF_ERR_OK) { tipc_env = PRF_CLIENT_GET_ENV(dest_id, tipc); //config connection, start discovering if(param->con_type == PRF_CON_DISCOVERY) { //start discovering CTS on peer prf_disc_svc_send(&(tipc_env->con_info), ATT_SVC_CURRENT_TIME); tipc_env->last_uuid_req = ATT_SVC_CURRENT_TIME; tipc_env->last_svc_req = ATT_SVC_CURRENT_TIME; // Go to DISCOVERING state ke_state_set(dest_id, TIPC_DISCOVERING); } //normal connection, get saved att details else { tipc_env->cts = param->cts; tipc_env->ndcs = param->ndcs; tipc_env->rtus = param->rtus; //send APP confirmation that can start normal connection tipc_enable_cfm_send(tipc_env, &con_info, PRF_ERR_OK); } } else { // Send confirmation that can start normal connection tipc_enable_cfm_send(NULL, &con_info, status); } return (KE_MSG_CONSUMED); }
void hogpbh_enable_cfm_send(struct hogpbh_env_tag *hogpbh_env, struct prf_con_info *con_info, uint8_t status) { // Counter uint8_t i; // Send APP the details of the discovered attributes on HOGPBH struct hogpbh_enable_cfm * rsp = KE_MSG_ALLOC(HOGPBH_ENABLE_CFM, con_info->appid, con_info->prf_id, hogpbh_enable_cfm); rsp->conhdl = gapc_get_conhdl(con_info->conidx); rsp->status = status; if (status == PRF_ERR_OK) { rsp->hids_nb = hogpbh_env->hids_nb; for (i = 0; i < hogpbh_env->hids_nb; i++) { rsp->hids[i] = hogpbh_env->hids[i]; // Register HOGPBH task in gatt for indication/notifications prf_register_atthdl2gatt(&hogpbh_env->con_info, &hogpbh_env->hids[i].svc); } // Go to connected state ke_state_set(con_info->prf_id, HOGPBH_CONNECTED); } else { PRF_CLIENT_ENABLE_ERROR(hogpbh_envs, con_info->prf_id, HOGPBH); } ke_msg_send(rsp); }