void syn_init() { any_type = new basetype(ANY,0); PERM(any_type); dummy = new expr(DUMMY,0,0); PERM(dummy); dummy->tp = any_type; zero = new expr(ZERO,0,0); PERM(zero); }
Pname name.tdef() /* typedef "this" */ { //error('d',"tdef%n",this); Pname n = ktbl->insert(this,0); if (tp == 0) error('i',"typedef%n tp==0",this); n->base = base = TNAME; PERM(n); PERM(tp); modified_tn = new name_list(n,modified_tn); return n; }
void print_file_permissions(mode_t mode) { /* Function prints file type and permissions */ PERM(S_IFDIR, 'd'); PERM(S_IRUSR, 'r'); PERM(S_IWUSR, 'w'); PERM(S_IXUSR, 'x'); PERM(S_IRGRP, 'r'); PERM(S_IWGRP, 'w'); PERM(S_IXGRP, 'x'); PERM(S_IROTH, 'r'); PERM(S_IWOTH, 'w'); PERM(S_IXOTH, 'x'); print_char('\n'); }
void app_sample128_enable(GPIO_PORT led3_port,GPIO_PIN led3_pin,GPIO_PORT led4_port,GPIO_PIN led4_pin) //void app_sample128_enable(void) { leds_state.port_led3 = led3_port; leds_state.pin_led3 = led3_pin; leds_state.port_led4 = led4_port; leds_state.pin_led4 = led4_pin; leds_state.flag = 0; // Allocate the message struct sample128_enable_req * req = KE_MSG_ALLOC(SAMPLE128_ENABLE_REQ, TASK_SAMPLE128, TASK_APP, sample128_enable_req); req->conhdl = app_env.conhdl; req->sec_lvl = PERM(SVC, ENABLE); /// characteristic 1 value req->sample128_1_val = 0; /// characteristic 2 value req->sample128_2_val = 0; /// char 2 Ntf property status req->feature = 0; // Send the message ke_msg_send(req); }
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 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)); }
void app_batt_enable( uint8_t batt_lvl, uint8_t lvl_alert_used, GPIO_PORT led_port, GPIO_PIN led_pin) { bat_lvl_alert_used = lvl_alert_used; bat_led_port = led_port; bat_led_pin = led_pin; // Allocate the message struct bass_enable_req * req = KE_MSG_ALLOC(BASS_ENABLE_REQ, TASK_BASS, TASK_APP, bass_enable_req); // Fill in the parameter structure req->conhdl = app_env.conhdl; req->sec_lvl = PERM(SVC, ENABLE); req->con_type = PRF_CON_NORMAL; // PRF_CON_DISCOVERY; req->batt_level_ntf_cfg[0] = 0; // Notifiacation OFF by default. req->batt_level_ntf_cfg[1] = 0; req->old_batt_lvl[0] = batt_lvl; req->old_batt_lvl[1] = 0; req->current_batt_lvl[0] = batt_lvl; req->current_batt_lvl[1] = 0; struct prf_char_pres_fmt *batt_level_pres_format = req->batt_level_pres_format; batt_level_pres_format[0].unit = 0x27AD; batt_level_pres_format[0].description = 0; // FIXME CORRECT? batt_level_pres_format[0].format = 4; batt_level_pres_format[0].exponent = 0; batt_level_pres_format[0].name_space = 1; // Send the message ke_msg_send(req); }
void memptrdcl(Pname bn, Pname tn, Ptype ft, Pname n) { Pptr p = new ptr(PTR,0); p->memof = Pclass(Pbase(bn->tp)->b_name->tp); Pbase b = new basetype(TYPE,tn); PERM(p); Pfct f = Pfct(ft); Ptype t = n->tp; if (t) { p->typ = t; ltlt: switch (t->base) { case PTR: case RPTR: case VEC: if (Pptr(t)->typ == 0) { Pptr(t)->typ = b; break; } t = Pptr(t)->typ; goto ltlt; default: error('s',"P toMFT too complicated"); } } else p->typ = b; f->returns = p; n->tp = f; }
Pname name.tname(TOK csu) /* "csu" "this" seen, return typedef'd name for "this" return (TNAME,x) x: (COBJ,y) y: (NAME,z) z: (CLASS,ae); */ { //fprintf(stderr,"tname %s %d ll %d\n",string,this,lex_level); switch (base) { case TNAME: return this; case NAME: { Pname tn = ktbl->insert(this,0); //fprintf(stderr,"tname tn %s %d ll %d (mod %d)\n",tn->string,tn,tn->lex_level,modified_tn); Pname on = new name; tn->base = TNAME; tn->lex_level = lex_level; modified_tn = new name_list(tn,modified_tn); tn->n_list = n_list = 0; string = tn->string; *on = *this; switch (csu) { case ENUM: tn->tp = new basetype(EOBJ,on); on->tp = new enumdef(0); break; default: on->tp = new classdef(csu,0); Pclass(on->tp)->string = tn->string; tn->tp = new basetype(COBJ,on); Pbase(tn->tp)->b_table = Pclass(on->tp)->memtbl; } PERM(tn); PERM(tn->tp); PERM(on); PERM(on->tp); /*fprintf(stderr,"tname %s -> n (%d %d) n->tp (%d %d)\n",string,tn,tn->base,tn->tp,tn->tp->base); fflush(stderr);*/ return tn; } default: error('i',"tname(%s %d %k)",string,this,base); } }
/** **************************************************************************************** * @brief Send enable request to WPTS profile task. * * @return void. **************************************************************************************** */ void app_pru_enable(uint16_t conhdl) { // Allocate the message struct wpts_enable_req * req = KE_MSG_ALLOC(WPTS_ENABLE_REQ, TASK_WPTS, TASK_APP, wpts_enable_req); req->conhdl = conhdl; req->sec_lvl = PERM(SVC, ENABLE); // Send the message ke_msg_send(req); }
/** **************************************************************************************** * @brief Handles reception of the @ref GLPS_CREATE_DB_REQ message. * The handler adds GLS into the database using the database * configuration value given in param. * @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 glps_create_db_req_handler(ke_msg_id_t const msgid, struct glps_create_db_req const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { //Service Configuration Flag uint16_t cfg_flag = GLPS_MANDATORY_MASK; //Database Creation Status uint8_t status; //Save Profile ID glps_env.con_info.prf_id = TASK_GLPS; //Save Database Configuration if(param->meas_ctx_supported) { GLPS_SET(MEAS_CTX_SUPPORTED); } // set start handle or automatically set it when creating database (start_hdl = 0) glps_env.shdl=param->start_hdl; /*---------------------------------------------------* * Glucose Service Creation *---------------------------------------------------*/ //Set Configuration Flag Value if (GLPS_IS(MEAS_CTX_SUPPORTED)) { cfg_flag |= GLPS_MEAS_CTX_PRES_MASK; } //Add Service Into Database status = atts_svc_create_db(&glps_env.shdl, (uint8_t *)&cfg_flag, GLS_IDX_NB, NULL, dest_id, &glps_att_db[0]); //Disable GLS attsdb_svc_set_permission(glps_env.shdl, PERM(SVC, DISABLE)); //Go to Idle State if (status == ATT_ERR_NO_ERROR) { //If we are here, database has been fulfilled with success, go to idle test ke_state_set(TASK_GLPS, GLPS_IDLE); } //Send response to application struct glps_create_db_cfm * cfm = KE_MSG_ALLOC(GLPS_CREATE_DB_CFM, src_id, TASK_GLPS, glps_create_db_cfm); cfm->status = status; ke_msg_send(cfm); return (KE_MSG_CONSUMED); }
void tips_disable(struct tips_idx_env_tag *tips_idx_env, uint16_t conhdl) { // Disable CTS attmdb_svc_set_permission(tips_env.cts_shdl, PERM(SVC, DISABLE)); if (TIPS_IS_SUPPORTED(TIPS_NDCS_SUP)) { // Disable NDCS attmdb_svc_set_permission(tips_env.ndcs_shdl, PERM(SVC, DISABLE)); } if (TIPS_IS_SUPPORTED(TIPS_RTUS_SUP)) { // Disable RTUS attmdb_svc_set_permission(tips_env.rtus_shdl, PERM(SVC, DISABLE)); } // Send APP cfg every time, C may have changed it struct tips_disable_ind *ind = KE_MSG_ALLOC(TIPS_DISABLE_IND, tips_idx_env->con_info.appid, tips_idx_env->con_info.prf_id, tips_disable_ind); ind->conhdl = conhdl; if ((tips_idx_env->ntf_state & TIPS_CTS_CURRENT_TIME_CFG) == TIPS_CTS_CURRENT_TIME_CFG) { ind->current_time_ntf_en = PRF_CLI_START_NTF; //Reset notifications bit field tips_idx_env->ntf_state &= ~TIPS_CTS_CURRENT_TIME_CFG; } ke_msg_send(ind); //Go to idle state ke_state_set(tips_idx_env->con_info.prf_id, TIPS_IDLE); PRF_CLIENT_DISABLE(tips_idx_envs, KE_IDX_GET(tips_idx_env->con_info.prf_id), TIPS); }
static void hoare_select_f (float *f, int i0, int i1, int q) { float pivot = PERM(i0); int j0, j1, lim; assert (i1 - i0 > 1 && q > i0 && q < i1); for (j0 = i0, j1 = i1 ; 1 ; ) { while (j0 < j1 - 1) { j0++; if (PERM(j0) > pivot) goto endseginf; } lim = j1; break; endseginf: while (j1 - 1 > j0) { j1--; if (PERM(j1) <= pivot) goto endsegsup; } lim = j0; break; endsegsup: SWAPFLOAT (j0, j1); } assert (lim > i0); if (lim == i1) { SWAPFLOAT (i0, i1 - 1); lim = i1 - 1; } if (lim == q) return; /* mission accomplished */ if (q < lim) hoare_select_f (f, i0, lim, q); else hoare_select_f (f, lim, i1, q); }
/* order perm[i0..i1-1] such that *perm[i] <= *perm[j] forall i0<=i<q and q<=j<i1 */ static void hoare_selectp (const float **perm, int i0, int i1, int q) { float pivot = PERM(i0); int j0, j1, lim; assert (i1 - i0 > 1 && q > i0 && q < i1); for (j0 = i0, j1 = i1 ; 1 ; ) { while (j0 < j1 - 1) { j0++; if (PERM(j0) > pivot) goto endseginf; } lim = j1; break; endseginf: while (j1 - 1 > j0) { j1--; if (PERM(j1) <= pivot) goto endsegsup; } lim = j0; break; endsegsup: SWAPFPTR (j0, j1); } assert (lim > i0); if (lim == i1) { SWAPFPTR (i0, i1 - 1); lim = i1 - 1; } if (lim == q) return; else if (q < lim) hoare_selectp (perm, i0, lim, q); else hoare_selectp (perm, lim, i1, q); }
/** **************************************************************************************** * @brief Handles reception of the @ref HRPS_CREATE_DB_REQ message. * The handler adds HRS into the database using the database * configuration value given in param. * @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 hrps_create_db_req_handler(ke_msg_id_t const msgid, struct hrps_create_db_req const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { //Service Configuration Flag uint8_t cfg_flag = HRPS_MANDATORY_MASK; //Database Creation Status uint8_t status; //Save Profile ID hrps_env.con_info.prf_id = TASK_HRPS; //Save Database Configuration hrps_env.features = param->features; /*---------------------------------------------------* * Heart Rate Service Creation *---------------------------------------------------*/ //Set Configuration Flag Value if (HRPS_IS_SUPPORTED(HRPS_BODY_SENSOR_LOC_CHAR_SUP)) { cfg_flag |= HRPS_BODY_SENSOR_LOC_MASK; } if (HRPS_IS_SUPPORTED(HRPS_ENGY_EXP_FEAT_SUP)) { cfg_flag |= HRPS_HR_CTNL_PT_MASK; } //Add Service Into Database status = attm_svc_create_db(&hrps_env.shdl, (uint8_t *)&cfg_flag, HRS_IDX_NB, NULL, dest_id, &hrps_att_db[0]); //Disable HRS attmdb_svc_set_permission(hrps_env.shdl, PERM(SVC, DISABLE)); //Go to Idle State if (status == ATT_ERR_NO_ERROR) { //If we are here, database has been fulfilled with success, go to idle test ke_state_set(TASK_HRPS, HRPS_IDLE); } //Send response to application struct hrps_create_db_cfm * cfm = KE_MSG_ALLOC(HRPS_CREATE_DB_CFM, src_id, TASK_HRPS, hrps_create_db_cfm); cfm->status = status; ke_msg_send(cfm); return (KE_MSG_CONSUMED); }
void app_findt_enable(void) { // Allocate the message struct findt_enable_req * req = KE_MSG_ALLOC(FINDT_ENABLE_REQ, TASK_FINDT, TASK_APP, findt_enable_req); // Fill in the parameter structure req->conhdl = app_env.conhdl; req->sec_lvl = PERM(SVC, ENABLE); // Send the message ke_msg_send(req); }
/** **************************************************************************************** * @brief Handles reception of the @ref BLPS_CREATE_DB_REQ message. * The handler adds BPS into the database using the database * configuration value given in param. * @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 blps_create_db_req_handler(ke_msg_id_t const msgid, struct blps_create_db_req const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { //Service Configuration Flag uint16_t cfg_flag = BLPS_MANDATORY_MASK; //Database Creation Status uint8_t status; //Save Application ID blps_env.con_info.prf_id = TASK_BLPS; //Save Database Configuration blps_env.features = param->features; // automatically set start handle when creating database // blps_env.shdl=0; /*---------------------------------------------------* * Blood Pressure Service Creation *---------------------------------------------------*/ //Set Configuration Flag Value if (BLPS_IS_SUPPORTED(BLPS_INTM_CUFF_PRESS_SUP)) { cfg_flag |= BLPS_INTM_CUFF_PRESS_MASK; } //Add Service Into Database status = atts_svc_create_db(&blps_env.shdl, (uint8_t *)&cfg_flag, BPS_IDX_NB, NULL, dest_id, &blps_att_db[0]); //Disable BPS attsdb_svc_set_permission(blps_env.shdl, PERM(SVC, DISABLE)); //Go to Idle State if (status == ATT_ERR_NO_ERROR) { //If we are here, database has been fulfilled with success, go to idle test ke_state_set(TASK_BLPS, BLPS_IDLE); } //Send response to application struct blps_create_db_cfm * cfm = KE_MSG_ALLOC(BLPS_CREATE_DB_CFM, src_id, TASK_BLPS, blps_create_db_cfm); cfm->status = status; ke_msg_send(cfm); return (KE_MSG_CONSUMED); }
/** **************************************************************************************** * @brief Handles reception of the @ref STREAMDATAD_ENABLE_REQ message. * The handler enables the StreamData Device profile. * @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 streamdatad_enable_req_handler(ke_msg_id_t const msgid, struct streamdatad_enable_req const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { uint16_t disable_val = 0x00; //Save Application ID //streamdatad_env.con_info.appid = src_id; streamdatad_env.con_info.prf_id = dest_id; streamdatad_env.con_info.appid = src_id; streamdatad_env.appid = src_id; //streamdatad_env.con_info.prf_id = dest_id; // Save the connection handle associated to the profile streamdatad_env.con_info.conidx = gapc_get_conidx(param->conhdl); // Save the connection handle associated to the profile streamdatad_env.conhdl = param->conhdl; streamdatad_env.next_attribute_idx = 0; streamdatad_env.nr_enabled_attributes = 0; streamdatad_env.stream_enabled = 0; // get tx buffers available nb_buf_av = l2cm_get_nb_buffer_available() - 6; attmdb_att_set_value(STREAMDATAD_HANDLE(STREAMDATAD_IDX_ENABLE_VAL), sizeof(uint16_t), (uint8_t*) &(disable_val)); attmdb_att_set_value(STREAMDATAD_HANDLE(STREAMDATAD_IDX_STREAMDATAD_D0_EN), sizeof(uint16_t),(uint8_t*) &(disable_val)); attmdb_att_set_value(STREAMDATAD_HANDLE(STREAMDATAD_IDX_STREAMDATAD_D1_EN), sizeof(uint16_t),(uint8_t*) &(disable_val)); attmdb_att_set_value(STREAMDATAD_HANDLE(STREAMDATAD_IDX_STREAMDATAD_D2_EN), sizeof(uint16_t),(uint8_t*) &(disable_val)); attmdb_att_set_value(STREAMDATAD_HANDLE(STREAMDATAD_IDX_STREAMDATAD_D3_EN), sizeof(uint16_t),(uint8_t*) &(disable_val)); attmdb_att_set_value(STREAMDATAD_HANDLE(STREAMDATAD_IDX_STREAMDATAD_D4_EN), sizeof(uint16_t),(uint8_t*) &(disable_val)); attmdb_att_set_value(STREAMDATAD_HANDLE(STREAMDATAD_IDX_STREAMDATAD_D5_EN), sizeof(uint16_t),(uint8_t*) &(disable_val)); attmdb_att_set_value(STREAMDATAD_HANDLE(STREAMDATAD_IDX_STREAMDATAD_D6_EN), sizeof(uint16_t),(uint8_t*) &(disable_val)); attmdb_att_set_value(STREAMDATAD_HANDLE(STREAMDATAD_IDX_STREAMDATAD_D7_EN), sizeof(uint16_t),(uint8_t*) &(disable_val)); attmdb_att_set_value(STREAMDATAD_HANDLE(STREAMDATAD_IDX_STREAMDATAD_D8_EN), sizeof(uint16_t),(uint8_t*) &(disable_val)); attmdb_att_set_value(STREAMDATAD_HANDLE(STREAMDATAD_IDX_STREAMDATAD_D9_EN), sizeof(uint16_t),(uint8_t*) &(disable_val)); //Enable Service attmdb_svc_set_permission(streamdatad_env.shdl, PERM(SVC, ENABLE)); // Go to active state ke_state_set(TASK_STREAMDATAD, STREAMDATAD_ACTIVE); return (KE_MSG_CONSUMED); }
int64 do_all2all (uint64 *dst, uint64 *src, int64 len, int64 nwrd) { static char cvs_info[] = "BMKGRP $Date: $ $Revision: $ $RCSfile: all2all.c,v $ $Name: $"; int64 i, j, pe; len = len - (len % (nwrd * SIZE)); // force even multiple for (i = 0; i < len; i+=SIZE*nwrd) { shmem_barrier_all(); for (j = 0; j < SIZE; j++) { pe = PERM(SELF,SIZE,j); /* shmem_put (&dst[i + SELF*nwrd], &src[i + pe*nwrd], nwrd, pe);*/ shmem_put64 (&dst[i + SELF*nwrd], &src[i + pe*nwrd], nwrd, pe); } } return len; }
void app_sample128_enable(void) { // Allocate the message struct sample128_enable_req* req = KE_MSG_ALLOC( SAMPLE128_ENABLE_REQ, TASK_SAMPLE128, TASK_APP, sample128_enable_req ); req->conhdl = app_env.conhdl; req->sec_lvl = PERM(SVC, ENABLE); memcpy(&req->sample128_1_val,&sample128_my_new,sizeof(my_newer1_addChar)); // default //req->sample128_1_val = 0x01; // default value for sample128 characteristic 1 //req->sample128_2_val = 0xff; // default value for sample128 characteristic 2 memcpy(&req->sample128_1_val,&sample128_2_new,sizeof(my_newer2_addChar)); req->feature = 0x00; // client CFG notify/indicate disabled // Send the message ke_msg_send(req); }
void app_sample128_enable(void) { struct sample128_enable_req* req = KE_MSG_ALLOC( SAMPLE128_ENABLE_REQ, TASK_SAMPLE128, TASK_APP, sample128_enable_req ); req->conhdl = app_env.conhdl; req->sec_lvl = PERM(SVC, ENABLE); //req->sample128_1_val = 0x01; // default value for sample128 characteristic 1 memcpy(&req->sample128_1_val,&sample128_my_new,sizeof(My_new_t)); req->sample128_2_val = 0xff; // default value for sample128 characteristic 2 req->feature = 0x00; // client CFG notify/indication printf_string(" app_sample128_enable \r\n"); // send the message ke_msg_send(req); }
void app_proxr_enable(void) { // Allocate the message struct proxr_enable_req * req = KE_MSG_ALLOC(PROXR_ENABLE_REQ, TASK_PROXR, TASK_APP, proxr_enable_req); // init application alert state app_proxr_alert_stop(); // Fill in the parameter structure req->conhdl = app_env.conhdl; req->sec_lvl = PERM(SVC, ENABLE); req->lls_alert_lvl = (uint8_t) alert_state.ll_alert_lvl; req->txp_lvl = alert_state.txp_lvl; // Send the message ke_msg_send(req); }
void app_adc_notify_enable(void) { // Allocate the message struct adc_notify_enable_req* req = KE_MSG_ALLOC(ADC_NOTIFY_ENABLE_REQ, TASK_ADC_NOTIFY, TASK_APP, adc_notify_enable_req); req->conhdl = app_env.conhdl; req->sec_lvl = PERM(SVC, ENABLE); adc_init(GP_ADC_SE, ADC_POLARITY_UNSIGNED); // Single ended mode adc_enable_channel(ADC_CHANNEL_P01); // req->adc_notify_val = SWAP(adc_get_sample());//dummy value req->feature = 0x00; //client CFG notif/ind disable // Send the message ke_msg_send(req); }
/** **************************************************************************************** * @brief Handles reception of the @ref ACCEL_ENABLE_REQ message. * The handler enables the accelerometer profile. * @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 accel_enable_req_handler(ke_msg_id_t const msgid, struct accel_enable_req const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { uint16_t disable_val = 0x00; //Save Application ID accel_env.con_info.appid = src_id; accel_env.con_info.prf_id = dest_id; // Save the connection index associated to the profile accel_env.con_info.conidx = gapc_get_conidx(param->conhdl); attmdb_att_set_value(ACCEL_HANDLE(ACCEL_IDX_ENABLE_VAL), sizeof(uint8_t), (uint8_t*) &(disable_val)); attmdb_att_set_value(ACCEL_HANDLE(ACCEL_IDX_RANGE_VAL), sizeof(uint8_t), (uint8_t*) &(disable_val)); attmdb_att_set_value(ACCEL_HANDLE(ACCEL_IDX_ACCEL_X_EN), sizeof(uint16_t),(uint8_t*) &(disable_val)); attmdb_att_set_value(ACCEL_HANDLE(ACCEL_IDX_ACCEL_Y_EN), sizeof(uint16_t),(uint8_t*) &(disable_val)); attmdb_att_set_value(ACCEL_HANDLE(ACCEL_IDX_ACCEL_Z_EN), sizeof(uint16_t),(uint8_t*) &(disable_val)); { uint8_t tb; // tb = battery_get_lvl(BATT_CR2032); tb = battery_get_lvl(BATT_JPLUS);//gsx,jplus battery type. // Update the value in the attribute database attmdb_att_set_value(ACCEL_HANDLE(ACCEL_IDX_ENABLE_VAL), sizeof(uint8_t), (uint8_t*) &(tb)); } //Enable Service attmdb_svc_set_permission(accel_env.shdl, PERM(SVC, ENABLE)); // Go to active state ke_state_set(TASK_ACCEL, ACCEL_ACTIVE); return (KE_MSG_CONSUMED); }
/** **************************************************************************************** * @brief Handles reception of the @ref STREAMDATAD_CREATE_DB_REQ message. * The handler adds STREAMDATAD Service into the database using the database * configuration value given in param. * @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 streamdatad_create_db_req_handler(ke_msg_id_t const msgid, struct streamdatad_create_db_req const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { //Service Configuration Flag uint32_t cfg_flag = 0xFFFFFFFF; //Database Creation Status uint8_t status; //Save Application ID streamdatad_env.appid = src_id; // set start handle or automatically set it when creating database (start_hdl = 0) streamdatad_env.shdl=param->start_hdl; //Add Service Into Database status = attm_svc_create_db(&streamdatad_env.shdl, (uint8_t *)&cfg_flag, STREAMDATAD_IDX_NB, NULL, dest_id, &streamdatad_att_db[0]); //Disable GLS attmdb_svc_set_permission(streamdatad_env.shdl, PERM(SVC, DISABLE)); //Go to Idle State if (status == ATT_ERR_NO_ERROR) { //If we are here, database has been fulfilled with success, go to idle test ke_state_set(TASK_STREAMDATAD, STREAMDATAD_IDLE); } //Send response to application struct streamdatad_create_db_cfm * cfm = KE_MSG_ALLOC(STREAMDATAD_CREATE_DB_CFM, streamdatad_env.appid, TASK_STREAMDATAD, streamdatad_create_db_cfm); cfm->status = status; ke_msg_send(cfm); return (KE_MSG_CONSUMED); }
/** **************************************************************************************** * @brief Handles reception of the @ref FINDT_CREATE_DB_REQ message. * The handler adds IAS into the database using the database * configuration value given in param. * @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_create_db_req_handler(ke_msg_id_t const msgid, struct findt_create_db_req const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { //Service Configuration Flag uint8_t cfg_flag = FINDT_MANDATORY_MASK; //Database Creation Status uint8_t status; //Save Profile ID findt_env.con_info.prf_id = TASK_FINDT; /*---------------------------------------------------* * Immediate Alert Service Creation *---------------------------------------------------*/ //Add Service Into Database status = attm_svc_create_db(&findt_env.shdl, (uint8_t *)&cfg_flag, FINDT_IAS_IDX_NB, NULL, dest_id, &findt_att_db[0]); //Disable IAS attmdb_svc_set_permission(findt_env.shdl, PERM(SVC, DISABLE)); //Go to Idle State if (status == ATT_ERR_NO_ERROR) { //If we are here, database has been fulfilled with success, go to idle state ke_state_set(TASK_FINDT, FINDT_IDLE); } //Send CFM to application struct findt_create_db_cfm * cfm = KE_MSG_ALLOC(FINDT_CREATE_DB_CFM, src_id, TASK_FINDT, findt_create_db_cfm); cfm->status = status; ke_msg_send(cfm); return (KE_MSG_CONSUMED); }
static int diss_create_db_req_handler(ke_msg_id_t const msgid, struct diss_create_db_req const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { //Service content flag uint32_t cfg_flag; //DB Creation Statis uint8_t status = ATT_ERR_NO_ERROR; //Save profile id diss_env.con_info.prf_id = TASK_DISS; //Compute Attribute Table and save it in environment cfg_flag = diss_compute_cfg_flag(param->features); status = attm_svc_create_db(&diss_env.shdl, (uint8_t *)&cfg_flag, DIS_IDX_NB, &diss_env.att_tbl[0], dest_id, &diss_att_db[0]); if (status == ATT_ERR_NO_ERROR) { //Disable service status = attmdb_svc_set_permission(diss_env.shdl, PERM(SVC, DISABLE)); //If we are here, database has been fulfilled with success, go to idle test ke_state_set(TASK_DISS, DISS_IDLE); } //Send response to application struct diss_create_db_cfm * cfm = KE_MSG_ALLOC(DISS_CREATE_DB_CFM, src_id, TASK_DISS, diss_create_db_cfm); cfm->status = status; ke_msg_send(cfm); return (KE_MSG_CONSUMED); }
void app_hrps_enable(void) { // Allocate the message struct hrps_enable_req * req = KE_MSG_ALLOC(HRPS_ENABLE_REQ, TASK_HRPS, TASK_APP, hrps_enable_req); //结构体填充部分需要后续改善 // Fill in the parameter structure ///Connection handle req->conhdl = app_env.conhdl; /// security level: b0= nothing, b1=unauthenticated, b2=authenticated, b3=authorized; /// b1 or b2 and b3 can go together req->sec_lvl = PERM(SVC, ENABLE); ///Type of connection - will someday depend on button press length; can be CFG or DISCOVERY req->con_type = PRF_CON_NORMAL;// PRF_CON_DISCOVERY; /// Heart Rate Notification configuration req->hr_meas_ntf_en = 1;//PRF_CLI_START_NTF;//PRF_CLI_STOP_NTFIND ///Body Sensor Location req->body_sensor_loc = 1; // Send the message ke_msg_send(req); }
/** **************************************************************************************** * @brief Handles reception of the @ref HPSS_CREATE_DB_REQ message. * The handler adds HPS into the database. * @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 hpss_create_db_req_handler(ke_msg_id_t const msgid, struct hpss_create_db_req const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { //Database Creation Status uint8_t status; //Save Profile ID hpss_env.con_info.prf_id = TASK_HPSS; /*---------------------------------------------------* * HTTP Proxy Service Creation *---------------------------------------------------*/ //Add Service Into Database status = attm_svc_create_db(&hpss_env.hps_shdl, NULL, HPS_IDX_NB, NULL, dest_id, &hpss_att_db[0]); //Disable HPS attmdb_svc_set_permission(hpss_env.hps_shdl, PERM(SVC, DISABLE)); //Go to Idle State if (status == ATT_ERR_NO_ERROR) { //If we are here, database has been fulfilled with success, go to idle state ke_state_set(TASK_HPSS, HPSS_IDLE); } //Send CFM to application struct hpss_create_db_cfm * cfm = KE_MSG_ALLOC(HPSS_CREATE_DB_CFM, src_id, TASK_HPSS, hpss_create_db_cfm); cfm->status = status; ke_msg_send(cfm); return (KE_MSG_CONSUMED); }
/** **************************************************************************************** * @brief Handles reception of the @ref BEACON_CREATE_DB_REQ message. * The handler adds BAS into the database using value of the features param. * @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 beacon_create_db_req_handler(ke_msg_id_t const msgid, struct beacon_create_db_req const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { // Service content flag uint8_t cfg_flag = BEACON_CFG_FLAG_MANDATORY_MASK; // Status uint8_t status = PRF_ERR_OK; // // Counter // uint8_t i; // // Battery Level characteristic value permissions // uint16_t perm; // // Battery Level characteristic value properties // uint8_t prop; // Save profile id beacon_env.con_info.prf_id = TASK_BEACON; //beacon_env.features = param->features; status = atts_svc_create_db(&beacon_env.shdl, (uint8_t *)&cfg_flag, BEACON_IDX_NB, NULL,dest_id, &beacon_att_db[0]); //Disable service status = attsdb_svc_set_permission(beacon_env.shdl, PERM(SVC, DISABLE)); //Go to Idle State if (status == ATT_ERR_NO_ERROR) { //If we are here, database has been fulfilled with success, go to idle test ke_state_set(TASK_BEACON, BEACON_IDLE); } //Send response to application struct beacon_create_db_cfm * cfm = KE_MSG_ALLOC(BEACON_CREATE_DB_CFM, beacon_env.con_info.appid, TASK_BEACON, beacon_create_db_cfm); cfm->status = status; ke_msg_send(cfm); // // Check number of BAS instances // if (param->bas_nb <= BASS_NB_BAS_INSTANCES_MAX) // { // // Save number of BAS // bass_env.bas_nb = param->bas_nb; // for (i = 0; ((i < param->bas_nb) && (status == PRF_ERR_OK)); i++) // { // // Save database configuration // bass_env.features[i] = param->features[i]; // // Check if notifications are supported // if (bass_env.features[i] == BAS_BATT_LVL_NTF_SUP) // { // cfg_flag |= BAS_CFG_FLAG_NTF_SUP_MASK; // } // // Check if multiple instances // if (bass_env.bas_nb > 1) // { // cfg_flag |= BAS_CFG_FLAG_MTP_BAS_MASK; // } // //Create BAS in the DB // status = atts_svc_create_db(&bass_env.shdl[i], (uint8_t *)&cfg_flag, BAS_IDX_NB, NULL, // dest_id, &bas_att_db[0]); // //Disable the service and set optional features // if (status == PRF_ERR_OK) // { // //Disable service // status = attsdb_svc_set_permission(bass_env.shdl[i], PERM(SVC, DISABLE)); // //Set optional properties and permissions // if (bass_env.features[i] == BAS_BATT_LVL_NTF_SUP) // { // prop = ATT_CHAR_PROP_RD | ATT_CHAR_PROP_NTF; // perm = PERM(RD, ENABLE) | PERM(NTF, ENABLE); // attsdb_att_partial_value_update(bass_env.shdl[i] + BAS_IDX_BATT_LVL_CHAR, 0, 1, &prop); // attsdb_att_set_permission(bass_env.shdl[i] + BAS_IDX_BATT_LVL_VAL, perm); // } // } // // Reset configuration flag // cfg_flag = BAS_CFG_FLAG_MANDATORY_MASK; // } // if (status == PRF_ERR_OK) // { // //If we are here, database has been fulfilled with success, go to idle state // ke_state_set(TASK_BASS, BASS_IDLE); // } // } // else // { // status = PRF_ERR_INVALID_PARAM; // } // // Send confirmation to application // struct bass_create_db_cfm * cfm = KE_MSG_ALLOC(BASS_CREATE_DB_CFM, src_id, TASK_BASS, // bass_create_db_cfm); // cfm->status = status; // ke_msg_send(cfm); return (KE_MSG_CONSUMED); }