Beispiel #1
0
uint8_t glpc_unpack_meas_value(uint8_t *packed_meas, struct glp_meas* meas_val,
                               uint16_t *seq_num)
{
    uint8_t cursor = 0;

    // Flags
    meas_val->flags = packed_meas[cursor];
    cursor += 1;

    // Sequence Number
    *seq_num = co_read16p(packed_meas + cursor);
    cursor += 2;

    // Base Time
    cursor += prf_unpack_date_time(packed_meas + cursor, &(meas_val->base_time));

    //Time Offset
    if((meas_val->flags & GLP_MEAS_TIME_OFF_PRES) != 0)
    {
        meas_val->time_offset = co_read16p(packed_meas + cursor);
        cursor += 2;
    }

    // Glucose Concentration, type and location
    if((meas_val->flags & GLP_MEAS_GL_CTR_TYPE_AND_SPL_LOC_PRES) != 0)
    {
        meas_val->concentration = co_read16p(packed_meas + cursor);
        cursor += 2;

        /* type and location are 2 nibble values */
        meas_val->type = packed_meas[cursor] >> 4;
        meas_val->location = packed_meas[cursor] & 0xF;

        cursor += 1;
    }
Beispiel #2
0
void tipc_unpack_time_dst_value(struct tip_time_with_dst* p_time_dst_val, uint8_t* packed_tdst)
{
    //Date-Time
    prf_unpack_date_time(packed_tdst, &(p_time_dst_val->date_time));

    //DST Offset
    p_time_dst_val->dst_offset = packed_tdst[7];
}
Beispiel #3
0
void tipc_unpack_curr_time_value(struct tip_curr_time* p_curr_time_val, uint8_t* packed_ct)
{
    //Date-Time
    prf_unpack_date_time(packed_ct, &(p_curr_time_val->exact_time_256.day_date_time.date_time));

    //Day of Week
    p_curr_time_val->exact_time_256.day_date_time.day_of_week = packed_ct[7];

    //Fraction 256
    p_curr_time_val->exact_time_256.fraction_256 = packed_ct[8];

    //Adjust Reason
    p_curr_time_val->adjust_reason = packed_ct[9];
}
Beispiel #4
0
void blpc_unpack_meas_value(struct bps_bp_meas* pmeas_val, uint8_t* packed_bp)
{
    uint8_t cursor;

    // blood pressure measurement flags
    pmeas_val->flags = packed_bp[0];

    // Blood Pressure Measurement Compound Value - Systolic
    pmeas_val->systolic = co_read16p(&(packed_bp[1]));

    // Blood Pressure Measurement Compound Value - Diastolic (mmHg)
    pmeas_val->diastolic = co_read16p(&(packed_bp[3]));

    //  Blood Pressure Measurement Compound Value - Mean Arterial Pressure (mmHg)
    pmeas_val->mean_arterial_pressure = co_read16p(&(packed_bp[5]));

    cursor = 7;

    // time flag set
    if ((pmeas_val->flags & BPS_FLAG_TIME_STAMP_PRESENT) == BPS_FLAG_TIME_STAMP_PRESENT)
    {
        cursor += prf_unpack_date_time(packed_bp + cursor, &(pmeas_val->time_stamp));
    }

    // pulse rate flag set
    if ((pmeas_val->flags & BPS_FLAG_PULSE_RATE_PRESENT) == BPS_FLAG_PULSE_RATE_PRESENT)
    {
        pmeas_val->pulse_rate = co_read16p(&(packed_bp[cursor + 0]));
        cursor += 2;
    }

    // User ID flag set
    if ((pmeas_val->flags & BPS_FLAG_USER_ID_PRESENT) == BPS_FLAG_USER_ID_PRESENT)
    {
        pmeas_val->user_id = packed_bp[cursor + 0];
        cursor += 1;
    }

    // measurement status flag set
    if ((pmeas_val->flags & BPS_FLAG_MEAS_STATUS_PRESENT) == BPS_FLAG_MEAS_STATUS_PRESENT)
    {
        pmeas_val->meas_status = co_read16p(&(packed_bp[cursor + 0]));
        cursor += 2;
    }
}
Beispiel #5
0
void htpc_unpack_temp(struct htpc_env_tag *htpc_env, uint8_t *packed_temp,
                      uint8_t length, uint8_t flag_stable_meas)
{
    // Cursor used to read parameter in the packed temperature value
    uint8_t cursor = 0;

    // Checked the length of the received value
    if (length >= HTPC_PACKED_TEMP_MIN_LEN)
    {
        // Prepare the message to send to the application
        struct htpc_temp_ind *ind = KE_MSG_ALLOC(HTPC_TEMP_IND,
                                                 htpc_env->con_info.appid, htpc_env->con_info.prf_id,
                                                 htpc_temp_ind);

        // Connection handle
        ind->conhdl = gapc_get_conhdl(htpc_env->con_info.conidx);

        // Unpack Temp Measurement
        ind->temp_meas.flags = *(packed_temp + cursor);
        cursor += 1;

        ind->temp_meas.temp = co_read32p(packed_temp + cursor);
        cursor += 4;

        // Time Flag Set
        if ((ind->temp_meas.flags & HTPT_FLAG_TIME) == HTPT_FLAG_TIME)
        {
            cursor += prf_unpack_date_time(packed_temp+cursor, &(ind->temp_meas.time_stamp));
        }

        // Type Flag set
        if ((ind->temp_meas.flags & HTPT_FLAG_TYPE) == HTPT_FLAG_TYPE)
        {
            ind->temp_meas.type    = *(packed_temp + cursor);
        }

        // Stable or intermediary type of temperature
        ind->flag_stable_meas = flag_stable_meas;

        //Send request to ATT
        ke_msg_send(ind);
    }
}
Beispiel #6
0
/**
 ****************************************************************************************
 * @brief Handles reception of the @ref GATTC_READ_IND message.
 * Generic event received after every simple read command sent to peer server.
 * @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 gattc_read_ind_handler(ke_msg_id_t const msgid,
                                    struct gattc_read_ind const *param,
                                    ke_task_id_t const dest_id,
                                    ke_task_id_t const src_id)
{
    // Get the address of the environment
    struct tipc_env_tag *tipc_env = PRF_CLIENT_GET_ENV(dest_id, tipc);

    //Current Time Characteristic
    if (tipc_env->last_char_code == TIPC_RD_CTS_CURR_TIME)
    {
        //Build a TIPC_CT_IND message
        struct tipc_ct_ind * ind = KE_MSG_ALLOC(TIPC_CT_IND,
                                                tipc_env->con_info.appid, dest_id,
                                                tipc_ct_ind);

        // retrieve connection handle
        ind->conhdl = gapc_get_conhdl(tipc_env->con_info.conidx);
        // Unpack Current Time Value.
        tipc_unpack_curr_time_value(&(ind->ct_val), (uint8_t*) &(param->value[0]));
        //Indication Type
        ind->ind_type = TIP_RD_RSP,

        ke_msg_send(ind);
    }
    //Local Time Information Characteristic
    else if (tipc_env->last_char_code == TIPC_RD_CTS_LOCAL_TIME_INFO)
    {
        //Build a TIPC_LTI_RD_RSP message
        struct tipc_lti_rd_rsp * rsp = KE_MSG_ALLOC(TIPC_LTI_RD_RSP,
                                                    tipc_env->con_info.appid, dest_id,
                                                    tipc_lti_rd_rsp);

        // Retrieve Connection handle
        rsp->conhdl = gapc_get_conhdl(tipc_env->con_info.conidx);
        // Local Time Information Value
        rsp->lti_val.time_zone         = param->value[0];
        rsp->lti_val.dst_offset         = param->value[1];

        ke_msg_send(rsp);
    }
    //Reference Time Information Characteristic
    else if (tipc_env->last_char_code == TIPC_RD_CTS_REF_TIME_INFO)
    {
        //Build a TIPC_RTI_RD_RSP message
        struct tipc_rti_rd_rsp * rsp = KE_MSG_ALLOC(TIPC_RTI_RD_RSP,
                                                    tipc_env->con_info.appid, dest_id,
                                                    tipc_rti_rd_rsp);

        // Retrieve Connection handle
        rsp->conhdl = gapc_get_conhdl(tipc_env->con_info.conidx);
        // Reference Time Information Value
        rsp->rti_val.time_source      = param->value[0];
        rsp->rti_val.time_accuracy    = param->value[1];
        rsp->rti_val.days_update      = param->value[2];
        rsp->rti_val.hours_update     = param->value[3];

        ke_msg_send(rsp);
    }
    //Time with DST Characteristic
    else if (tipc_env->last_char_code == TIPC_RD_NDCS_TIME_WITH_DST)
    {
        //Build a TIPC_TDST_RD_RSP message
        struct tipc_tdst_rd_rsp * rsp = KE_MSG_ALLOC(TIPC_TDST_RD_RSP,
                                                     tipc_env->con_info.appid, dest_id,
                                                     tipc_tdst_rd_rsp);

        // Retrieve Connection handle
        rsp->conhdl = gapc_get_conhdl(tipc_env->con_info.conidx);
        // Time with DST Value
        prf_unpack_date_time((uint8_t*) &(param->value[0]), &(rsp->tdst_val.date_time));
        rsp->tdst_val.dst_offset        = param->value[7];

        ke_msg_send(rsp);
    }
    //Time Update State Characteristic
    else if (tipc_env->last_char_code == TIPC_RD_RTUS_TIME_UPD_STATE)
    {
        //Build a TIPC_TUS_RD_RSP message
        struct tipc_tus_rd_rsp * rsp = KE_MSG_ALLOC(TIPC_TUS_RD_RSP,
                                                    tipc_env->con_info.appid, dest_id,
                                                    tipc_tus_rd_rsp);

        // Retrieve Connection handle
        rsp->conhdl = gapc_get_conhdl(tipc_env->con_info.conidx);
        // Reference Time Information Value
        rsp->tus_val.current_state     = param->value[0];
        rsp->tus_val.result            = param->value[1];

        ke_msg_send(rsp);
    }
    //Current Time Characteristic - Client Characteristic Configuration Descriptor
    else if (tipc_env->last_char_code == TIPC_RD_CTS_CURR_TIME_CLI_CFG)
    {
        //Build a TIPC_CT_NTF_CFG_RD_RSP message
        struct tipc_ct_ntf_cfg_rd_rsp * rsp = KE_MSG_ALLOC(TIPC_CT_NTF_CFG_RD_RSP,
                                                           tipc_env->con_info.appid, dest_id,
                                                           tipc_ct_ntf_cfg_rd_rsp);

        // Retrieve Connection handle
        rsp->conhdl = gapc_get_conhdl(tipc_env->con_info.conidx);
        // Notification Configuration
        memcpy(&rsp->ntf_cfg, &param->value[0], sizeof(rsp->ntf_cfg));

        ke_msg_send(rsp);
    }

    return (KE_MSG_CONSUMED);
}