void prox_app_task_msg_hdl(ke_msg_id_t const msgid, void const *param)
{
    switch(msgid)
    {
#if BLE_PROX_MONITOR
        case PROXM_ENABLE_CFM:
        {
            // Enable confirmation
            uint8_t pdu[] = {EACI_MSG_TYPE_DATA_IND, EACI_MSG_DATA_IND_PROXM_ENABLE, 3, 0x03, 0x18, 0};
            pdu[5] = ((struct proxm_enable_cfm *)param)->status;
            eaci_pdu_send(sizeof(pdu), pdu);
        }
            break;

        case PROXM_RD_CHAR_RSP:
        {
            /// read data rsp
            uint8_t pdu[] = {EACI_MSG_TYPE_DATA_IND, 0, 3, 0x04, 0x18, 0};
            pdu[1] =  EACI_MSG_DATA_IND_PROXM_TX_POWER;
            pdu[5] = ((struct proxm_rd_char_rsp *)param)->val;
            eaci_pdu_send(sizeof(pdu), pdu);
        }
            break;
#endif

#if BLE_PROX_REPORTER
        case PROXR_ALERT_IND:
        {
            // Alert Indication
            uint8_t pdu[] = {EACI_MSG_TYPE_DATA_IND, 0, 3, 0, 0, 0};
            if (((struct proxr_alert_ind *)param)->char_code == PROXR_IAS_CHAR)
            {
                pdu[1] =  EACI_MSG_DATA_IND_PROXR_ALERT;
                pdu[3] = (uint8_t)(ATT_SVC_TX_POWER & 0x00FF);
                pdu[4] = (uint8_t)(ATT_SVC_TX_POWER >> 8);
            }
            else
            {
                pdu[1] =  EACI_MSG_DATA_IND_PROXR_LINK_LOST;
                pdu[3] = (uint8_t)(ATT_SVC_LINK_LOSS & 0x00FF);
                pdu[4] = (uint8_t)(ATT_SVC_LINK_LOSS >> 8);
            }
            // Alter Level
            pdu[5] = ((struct proxr_alert_ind *)param)->alert_lvl;
            eaci_pdu_send(sizeof(pdu), pdu);
        }
Beispiel #2
0
void dis_app_task_msg_hdl(ke_msg_id_t const msgid, void const *param)
{
    switch(msgid)
    {
#if BLE_DIS_CLIENT
        case DISC_ENABLE_CFM:
            {
                uint8_t pdu[] = {EACI_MSG_TYPE_DATA_IND, 0, 3, 0, 0, 0};
                pdu[1] =  EACI_MSG_DATA_IND_DISC_ENABLE;
                pdu[3] = (uint8_t)(ATT_SVC_DEVICE_INFO);
                pdu[4] = (uint8_t)(ATT_SVC_DEVICE_INFO >> 8);
                pdu[5] = ((struct disc_enable_cfm *)param)->status;
                eaci_pdu_send(sizeof(pdu), pdu);
            }
            break;

        case DISC_RD_CHAR_RSP:
            {
                uint8_t datalen = ((struct disc_rd_char_rsp *)param)->val_length;
                uint8_t *pdu;
                pdu = (uint8_t *)malloc(6 + datalen);
                if (pdu != NULL)
                {
                    memset(pdu,0,datalen+6);
                    pdu[0] = EACI_MSG_TYPE_DATA_IND;
                    pdu[1] = EACI_MSG_DATA_IND_DISC_CHAR_RD;
                    pdu[2] = 3 + datalen;
                    pdu[3] = (uint8_t)(ATT_SVC_DEVICE_INFO);
                    pdu[4] = (uint8_t)(ATT_SVC_DEVICE_INFO >> 8);
                    pdu[5] = ((struct disc_rd_char_rsp *)param)->status;
                    memcpy((pdu + 6), ((struct disc_rd_char_rsp *)param)->val, datalen);
                    eaci_pdu_send((6 + datalen), pdu);
                    free(pdu);
                    pdu = NULL;
                }
            }
            break;
#endif
        default:
            break;
    }
void ht_app_task_msg_hdl(ke_msg_id_t const msgid, void const *param)
{
    switch(msgid)
    {
#if BLE_HT_COLLECTOR
        case HTPC_ENABLE_CFM:
        {
            // Enable confirmation
            uint8_t pdu[] = {EACI_MSG_TYPE_DATA_IND, EACI_MSG_DATA_IND_HT_ENABLE, 3, 0x09, 0x18, 0};
            pdu[5] = ((struct htpc_enable_cfm *)param)->status;
            eaci_pdu_send(sizeof(pdu), pdu);
        }
            break;

        case HTPC_RD_CHAR_RSP:
        {
            uint8_t pdu[8];
            pdu[0] = EACI_MSG_TYPE_DATA_IND;
            pdu[1] = EACI_MSG_DATA_IND_HT_RD_CHAR_RSP;
            pdu[2] = 5;
            pdu[3] = (uint8_t)(ATT_SVC_HEALTH_THERMOM);
            pdu[4] = (uint8_t)(ATT_SVC_HEALTH_THERMOM >> 8);
            pdu[5] = ((struct htpc_rd_char_rsp *)param)->status;
            pdu[6] = ((struct htpc_rd_char_rsp *)param)->data.data[0];
            pdu[7] = ((struct htpc_rd_char_rsp *)param)->data.data[1];
            eaci_pdu_send(sizeof(pdu), pdu);
        }
            break;

        case HTPC_WR_CHAR_RSP:
        {
            // Write Status
            uint8_t pdu[] = {EACI_MSG_TYPE_DATA_IND, EACI_MSG_DATA_IND_HT_WR_RSP, 3, 0x09, 0x18, 0};
            pdu[5] = ((struct htpc_wr_char_rsp *)param)->status;
            eaci_pdu_send(sizeof(pdu), pdu);
        }
            break;

        case HTPC_TEMP_IND:
        {
            uint8_t pdu[] = {EACI_MSG_TYPE_DATA_IND, 0, 0x08, 0x09, 0x18, 0, 0, 0, 0, 0, 0};
            pdu[1] =  EACI_MSG_DATA_IND_HT_TEM_MEA;
            pdu[5] = ((struct htpc_temp_ind *)param)->flag_stable_meas;
            pdu[6] = (((struct htpc_temp_ind *)param)->temp_meas.flags) & 0x01;
            pdu[7] = (uint8_t)((((struct htpc_temp_ind *)param)->temp_meas.temp));
            pdu[8] = (uint8_t)((((struct htpc_temp_ind *)param)->temp_meas.temp) >> 8);
            pdu[9] = (uint8_t)((((struct htpc_temp_ind *)param)->temp_meas.temp) >> 16);
            pdu[10] = (uint8_t)((((struct htpc_temp_ind *)param)->temp_meas.temp) >> 24);
            eaci_pdu_send(sizeof(pdu), pdu);
        }
            break;

        case HTPC_MEAS_INTV_IND:
        {
            uint8_t pdu[] = {EACI_MSG_TYPE_DATA_IND, 0, 4, 0x09, 0x18, 0, 0};
            pdu[1] =  EACI_MSG_DATA_IND_HT_MEAS_INTE;
            pdu[5] = (uint8_t)(((struct htpc_meas_intv_ind *)param)->intv);
            pdu[6] = (uint8_t)((((struct htpc_meas_intv_ind *)param)->intv) >> 8);
            eaci_pdu_send(sizeof(pdu), pdu);
        }
            break;
#endif

#if BLE_HT_THERMOM
        case HTPT_MEAS_INTV_CHG_IND:
        {
            uint8_t pdu[] = {EACI_MSG_TYPE_DATA_IND, 0, 4, 0x09, 0x18, 0, 0};
            pdu[1] =  EACI_MSG_DATA_IND_HT_TH_TEM_MEA;
            pdu[5] = (uint8_t)(((struct htpt_meas_intv_chg_ind *)param)->intv);
            pdu[6] = (uint8_t)((((struct htpt_meas_intv_chg_ind *)param)->intv) >> 8);
            eaci_pdu_send(sizeof(pdu), pdu);
        }
            break;

        case HTPT_CFG_INDNTF_IND:
        {
            uint8_t pdu[] = {EACI_MSG_TYPE_DATA_IND, 0, 4, 0x09, 0x18, 0, 0};
            pdu[1] =  EACI_MSG_DATA_IND_HT_TH_CFG_IND;
            pdu[5] = (uint8_t)(((struct htpt_cfg_indntf_ind *)param)->cfg_val);
            pdu[6] = (uint8_t)((((struct htpt_cfg_indntf_ind *)param)->cfg_val) >> 8);
            eaci_pdu_send(sizeof(pdu), pdu);
        }
            break;
#endif
        default:
            break;
    }
}
Beispiel #4
0
void batt_app_task_msg_hdl(ke_msg_id_t const msgid, void const *param)
{
    switch(msgid)
    {
#if BLE_BATT_CLIENT
        case BASC_ENABLE_CFM:
            {
                uint8_t pdu[] = {EACI_MSG_TYPE_DATA_IND, 0, 3, 0, 0, 0};
                pdu[1] =  EACI_MSG_DATA_IND_BATT_ENABLE;
                pdu[3] = (uint8_t)(ATT_SVC_BATTERY_SERVICE);
                pdu[4] = (uint8_t)(ATT_SVC_BATTERY_SERVICE >> 8);
                pdu[5] = ((struct basc_enable_cfm *)param)->status;
                eaci_pdu_send(sizeof(pdu), pdu);
            }
            break;

        case BASC_WR_CHAR_RSP:
            {
                uint8_t pdu[] = {EACI_MSG_TYPE_DATA_IND, 0, 3, 0, 0, 0};
                pdu[1] =  EACI_MSG_DATA_IND_BATT_WR_RSP;
                pdu[3] = (uint8_t)(ATT_SVC_BATTERY_SERVICE);
                pdu[4] = (uint8_t)(ATT_SVC_BATTERY_SERVICE >> 8);
                pdu[5] = (uint8_t)(((struct basc_wr_char_rsp *)param)->status);
                eaci_pdu_send(sizeof(pdu), pdu);
            }
            break;

        case BASC_BATT_LEVEL_IND:
            {
                uint8_t pdu[] = {EACI_MSG_TYPE_DATA_IND, 0, 3, 0, 0, 0};
                pdu[1] =  EACI_MSG_DATA_IND_BATT_LEVEL;
                pdu[3] = (uint8_t)(ATT_SVC_BATTERY_SERVICE);
                pdu[4] = (uint8_t)(ATT_SVC_BATTERY_SERVICE >> 8);
                pdu[5] = (uint8_t)(((struct basc_batt_level_ind *)param)->batt_level);
                eaci_pdu_send(sizeof(pdu), pdu);
            }
            break;

        case BASC_BATT_LEVEL_NTF_CFG_RD_RSP:
            {
                uint8_t pdu[] = {EACI_MSG_TYPE_DATA_IND, 0, 4, 0, 0, 0, 0};
                pdu[1] =  EACI_MSG_DATA_IND_BATT_RD_CFG;
                pdu[3] = (uint8_t)(ATT_SVC_BATTERY_SERVICE);
                pdu[4] = (uint8_t)(ATT_SVC_BATTERY_SERVICE >> 8);
                pdu[5] = (uint8_t)(((struct basc_batt_level_ntf_cfg_rd_rsp *)param)->ntf_cfg);
                pdu[6] = (uint8_t)((((struct basc_batt_level_ntf_cfg_rd_rsp *)param)->ntf_cfg) >> 8);
                eaci_pdu_send(sizeof(pdu), pdu);
            }
            break;
#endif

#if BLE_BATT_SERVER
        case BASS_BATT_LEVEL_UPD_CFM:
            {
                uint8_t pdu[] = {EACI_MSG_TYPE_DATA_IND, 0, 3, 0, 0, 0};
                pdu[1] =  EACI_MSG_DATA_IND_BASS_BATT_UPD_CFM;
                pdu[3] = (uint8_t)(ATT_SVC_BATTERY_SERVICE);
                pdu[4] = (uint8_t)(ATT_SVC_BATTERY_SERVICE >> 8);
                pdu[5] = ((struct bass_batt_level_upd_cfm *)param)->status;
                eaci_pdu_send(sizeof(pdu), pdu);
            }
            break;
#endif
        default:
            break;
    }
}
Beispiel #5
0
void gl_app_task_msg_hdl(ke_msg_id_t const msgid, void const *param)
{
    switch(msgid)
    {
#if BLE_GL_COLLECTOR
        case GLPC_ENABLE_CFM:
        {
            uint8_t pdu[] = {EACI_MSG_TYPE_DATA_IND, 0, 3, 0, 0, 0};
            pdu[1] = EACI_MSG_DATA_IND_GL_ENABLE;
            pdu[3] = (uint8_t)(ATT_SVC_GLUCOSE);
            pdu[4] = (uint8_t)(ATT_SVC_GLUCOSE >> 8);
            pdu[5] = ((struct glpc_enable_cfm *)param)->status;
            eaci_pdu_send(sizeof(pdu), pdu);
        }
            break;

        case GLPC_REGISTER_CFM:
        {
            uint8_t pdu[] = {EACI_MSG_TYPE_DATA_IND, 0, 3, 0, 0, 0};
            pdu[1] = EACI_MSG_DATA_IND_GL_REGISTER;
            pdu[3] = (uint8_t)(ATT_SVC_GLUCOSE);
            pdu[4] = (uint8_t)(ATT_SVC_GLUCOSE >> 8);
            pdu[5] = ((struct glpc_register_cfm *)param)->status;
            eaci_pdu_send(sizeof(pdu), pdu);
        }
            break;

        case GLPC_READ_FEATURES_RSP:
        {
            uint8_t pdu[] = {EACI_MSG_TYPE_DATA_IND, 0, 5, 0, 0, 0, 0, 0};
            pdu[1] = EACI_MSG_DATA_IND_GL_FEATURES_RD;
            pdu[3] = (uint8_t)(ATT_SVC_GLUCOSE);
            pdu[4] = (uint8_t)(ATT_SVC_GLUCOSE >> 8);
            pdu[5] = ((struct glpc_read_features_rsp *)param)->status;
            pdu[6] = (uint8_t)(((struct glpc_read_features_rsp *)param)->features);
            pdu[7] = (uint8_t)((((struct glpc_read_features_rsp *)param)->features) >> 8);
            eaci_pdu_send(sizeof(pdu), pdu);
        }
            break;

        case GLPC_MEAS_IND:
        {
            uint8_t Flags = 0;
            uint8_t cursor = 15;

            Flags = ((struct glpc_meas_ind *)param)->meas_val.flags;

            if ((Flags & GLP_MEAS_TIME_OFF_PRES) != 0)
            {
                cursor += 2;
            }

            if ((Flags & GLP_MEAS_GL_CTR_TYPE_AND_SPL_LOC_PRES) != 0)
            {
                cursor += 4;
            }

            // Sensor Status Annunciation
            if((Flags & GLP_MEAS_SENS_STAT_ANNUN_PRES) != 0)
            {
                cursor += 2;
            }

            uint8_t pdu[cursor];

            pdu[0] = EACI_MSG_TYPE_DATA_IND;
            pdu[1] = EACI_MSG_DATA_IND_GL_MEAS;
            pdu[2] = cursor - 3;
            pdu[3] = (uint8_t)(ATT_SVC_GLUCOSE);
            pdu[4] = (uint8_t)(ATT_SVC_GLUCOSE >> 8);
            pdu[5] = ((struct glpc_meas_ind *)param)->meas_val.flags;
            pdu[6] = (uint8_t)(((struct glpc_meas_ind *)param)->seq_num);
            pdu[7] = (uint8_t)((((struct glpc_meas_ind *)param)->seq_num) >> 8);
            pdu[8] = (uint8_t)(((struct glpc_meas_ind *)param)->meas_val.base_time.year);
            pdu[9] = (uint8_t)((((struct glpc_meas_ind *)param)->meas_val.base_time.year) >> 8);
            pdu[10] = ((struct glpc_meas_ind *)param)->meas_val.base_time.month;
            pdu[11] = ((struct glpc_meas_ind *)param)->meas_val.base_time.day;
            pdu[12] = ((struct glpc_meas_ind *)param)->meas_val.base_time.hour;
            pdu[13] = ((struct glpc_meas_ind *)param)->meas_val.base_time.min;
            pdu[14] = ((struct glpc_meas_ind *)param)->meas_val.base_time.sec;
            cursor = 15;

            //Time Offset
            if ((Flags & GLP_MEAS_TIME_OFF_PRES) != 0)
            {
                pdu[cursor] = (uint8_t)(((struct glpc_meas_ind *)param)->meas_val.time_offset);
                pdu[cursor + 1] =(uint8_t)((((struct glpc_meas_ind *)param)->meas_val.time_offset) >> 8);
                cursor += 2;
            }

            // Glucose Concentration, type and location
            if ((Flags & GLP_MEAS_GL_CTR_TYPE_AND_SPL_LOC_PRES) != 0)
            {
                pdu[cursor] = (uint8_t)(((struct glpc_meas_ind *)param)->meas_val.concentration);
                pdu[cursor + 1] = (uint8_t)((((struct glpc_meas_ind *)param)->meas_val.concentration) >> 8);
                pdu[cursor + 2] = ((struct glpc_meas_ind *)param)->meas_val.type;
                pdu[cursor + 3] = ((struct glpc_meas_ind *)param)->meas_val.location;
                cursor += 4;
            }

            // Sensor Status Annunciation
            if((Flags & GLP_MEAS_SENS_STAT_ANNUN_PRES) != 0)
            {
                pdu[cursor] = (uint8_t)(((struct glpc_meas_ind *)param)->meas_val.status);
                pdu[cursor + 1] = (uint8_t)((((struct glpc_meas_ind *)param)->meas_val.status) >> 8); 
                cursor += 2;
            }