static int gatt_write_cmd_ind_handler(ke_msg_id_t const msgid, struct gatt_write_cmd_ind const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { //uint8_t char_code = PROXR_ERR_CHAR; uint8_t status = PRF_APP_ERROR; if (param->conhdl == beacon_env.con_info.conhdl) { if (param->handle == beacon_env.shdl + BEACON_IDX_LVL_VAL) { //Save value in DB attsdb_att_set_value(param->handle, sizeof(uint8_t), (uint8_t *)¶m->value[0]); #if QN_NVDS_WRITE if (NVDS_OK == nvds_put(NVDS_TAG_MEASURED_POWER, sizeof(param->value[0]), (uint8_t *)¶m->value[0])) { status = PRF_ERR_OK; } #else status = PRF_ERR_OK; #endif //Response atts_write_rsp_send(beacon_env.con_info.conhdl, param->handle, status); } } return (KE_MSG_CONSUMED); }
void app_neb_msg_rx_start(struct app_neb_msg_start* msg) { uint8_t status = NEB_ERR_SUCCESS; // Check parameters switch (msg->reason) { case NEB_MSG_START_REASON_START: { // Increment nebulizer ID app_neb_env.curr_neb_id++; #if (NVDS_SUPPORT) // Put the current nebulizer ID into storage nvds_put(NVDS_TAG_NEB_ID, NVDS_LEN_NEB_ID, (uint8_t *)&app_neb_env.curr_neb_id); #endif // NVDS_SUPPORT // Clear record ID app_neb_env.next_rec_id = 0; } break; case NEB_MSG_START_REASON_RESTART: break; default: { status = NEB_ERR_INVALID_PARAMS; } break; } if ((status == NEB_ERR_SUCCESS) && (ke_state_get(TASK_APP_NEB) == APP_NEB_CONNECTED)) { // Allocate message to profile struct nbps_neb_record_send_req *req = KE_MSG_ALLOC(NBPS_NEB_RECORD_SEND_REQ, TASK_NBPS, TASK_APP_NEB, nbps_neb_record_send_req); req->conhdl = app_neb_env.conhdl; req->neb_rec.neb_id = app_neb_env.curr_neb_id; req->neb_rec.rec_id = app_neb_env.next_rec_id; req->neb_rec.flags = NEB_REC_START_FLAG; // Parameters req->neb_rec.reason = msg->reason; // Get absolute time stamp app_neb_insert_abs_time(req); ke_msg_send(req); // Increment record ID app_neb_env.next_rec_id++; } // Confirm the message app_neb_msg_tx_confirm_basic(NEB_MSG_ID_START, status); }