Ejemplo n.º 1
0
/*
 ****************************************************************************************
 * @brief Handles the command complete event from the PASPS.      *//**
 *
 * @param[in] msgid     PASPS_CMP_EVT
 * @param[in] param     Pointer to the struct pasps_cmp_evt
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_PASPS
 *
 * @return If the message was consumed or not.
 * @description
 * This handler is used to inform the sender of a command that the procedure is over and
 * contains the status of the procedure.
 ****************************************************************************************
 */
int app_pasps_cmp_evt_handler(ke_msg_id_t const msgid,
                              struct pasps_cmp_evt *param,
                              ke_task_id_t const dest_id,
                              ke_task_id_t const src_id)
{
    switch (param->operation)
    {
        case PASPS_CREATE_DB_OP_CODE:
            if (param->status == ATT_ERR_NO_ERROR)
            {
                app_clear_local_service_flag(BLE_PASP_SERVER_BIT);
            }
            break;
        case PASPS_ENABLE_OP_CODE:
            break;
        case PASPS_UPD_ALERT_STATUS_OP_CODE:
            app_pasps_env->ntf_sending |= PASPS_FLAG_ALERT_STATUS_CFG;
            break;
        case PASPS_UPD_RINGER_SETTING_OP_CODE:
            app_pasps_env->ntf_sending |= PASPS_FLAG_RINGER_SETTING_CFG;
            break;
        default:
            break;
    }
    app_task_msg_hdl(msgid, param);

    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 2
0
/*
 ****************************************************************************************
 * @brief Handles the complete event from TASK_RSCPC. *//**
 *
 * @param[in] msgid     RSCPC_CMP_EVT
 * @param[in] param     Pointer to struct rscpc_cmp_evt
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_RSCPC
 * @return If the message was consumed or not.
 * @description
 *
 * This handler is used to inform the sender of a command that the procedure is over and 
 * contains the status of the procedure.
 *
 ****************************************************************************************
 */
int app_rscpc_cmp_evt_handler(ke_msg_id_t const msgid,
                              struct rscpc_cmp_evt *param,
                              ke_task_id_t const dest_id,
                              ke_task_id_t const src_id)
{
    switch (param->operation)
    {
        case RSCPC_ENABLE_OP_CODE:
            if (param->status == PRF_ERR_OK)
            {
                QPRINTF("Enable complete\r\n");
            }
            else
            {
                QPRINTF("Enable failed %d\r\n", param->status);
            }
            break;
        case RSCPC_READ_OP_CODE:
            QPRINTF("Read procedure complete, result is %d\r\n", param->status);
            break;
        case RSCPC_CFG_NTF_IND_OP_CODE:
            QPRINTF("Configure procedure complete, result is %d\r\n", param->status);
            break;
        case RSCPC_CTNL_PT_CFG_WR_OP_CODE:
            QPRINTF("Ctrl procedure complete, result is %d\r\n", param->status);
            break;
        default:
            break;
    }
    app_task_msg_hdl(msgid, param);

    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 3
0
/*
 ****************************************************************************************
 * @brief Received Current Time value sent to APP (Read Response or Notification). *//**
 *
 * @param[in] msgid     TIPC_CT_IND
 * @param[in] param     Pointer to struct tipc_ct_ind
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_TIPC
 * @return If the message was consumed or not.
 * @description
 *
 *  This API is used by the Client role to inform the Application of a received current time 
 *  value. The ind_type parameter informs the application if the value has been notified by the 
 *  Time Client or if it has been received as a read response. 
 *
 ****************************************************************************************
 */
int app_tipc_ct_ind_handler(ke_msg_id_t const msgid,
                      struct tipc_ct_ind *param,
                      ke_task_id_t const dest_id,
                      ke_task_id_t const src_id)
{
    QPRINTF("TIPC Current Time indication(%d): Adjust Reason: %d, Fraction: %d, Day/Week: %d.\r\n", 
        param->ind_type,
        param->ct_val.adjust_reason,
        param->ct_val.exact_time_256.fraction_256,    ///n * (1/256th) of a second
        param->ct_val.exact_time_256.day_date_time.day_of_week
        );

#if QN_DBG_TRACE_MORE
    QPRINTF("Date: %04d:%02d:%02d Time: %02d:%02d:%02d\r\n", 
        param->ct_val.exact_time_256.day_date_time.date_time.year,
        param->ct_val.exact_time_256.day_date_time.date_time.month,
        param->ct_val.exact_time_256.day_date_time.date_time.day,
        param->ct_val.exact_time_256.day_date_time.date_time.hour,
        param->ct_val.exact_time_256.day_date_time.date_time.min,
        param->ct_val.exact_time_256.day_date_time.date_time.sec
        );
#endif
    app_task_msg_hdl(msgid, param);

    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 4
0
/*
 ****************************************************************************************
 * @brief Handles Indicate that an attribute value has been received either upon notification
 *        or read response. *//**
 *
 * @param[in] msgid     PASPC_VALUE_IND
 * @param[in] param     Pointer to struct paspc_value_ind
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_PASPC
 * @return If the message was consumed or not.
 * @description
 *
 * This handler is sent to the application once an attribute value has been received from
 * the peer device upon a notification or a read response message. The content of the value
 * parameter depends of the attribute code value which defines the attribute that has been
 * updated
 *
 ****************************************************************************************
 */
int app_paspc_val_ind_handler(ke_msg_id_t const msgid,
                              struct paspc_value_ind *param,
                              ke_task_id_t const dest_id,
                              ke_task_id_t const src_id)
{
    uint8_t att_code = param->att_code;
    switch (att_code)
    {
        case PASPC_RD_ALERT_STATUS:
            QPRINTF("Alert Status characteristic value: %d%.\r\n",
                     param->value.alert_status);
            break;

        case PASPC_RD_RINGER_SETTING:
            QPRINTF("PAS Ringer Setting: %d%.\r\n",
                     param->value.ringer_setting);
            break;

        case PASPC_RD_WR_ALERT_STATUS_CFG:
            QPRINTF("PAS Alert Status Client Characteristic Configuration Descriptor: %d%.\r\n",
                     param->value.alert_status_ntf_cfg);
            break;

        case PASPC_RD_WR_RINGER_SETTING_CFG:
            QPRINTF("PAS Ringer Setting Client Characteristic Configuration Descriptor: %d%.\r\n",
                     param->value.ringer_setting_ntf_cfg);
            break;

        default:
            break;
    }
    app_task_msg_hdl(msgid, param);
    
    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 5
0
/*
 ****************************************************************************************
 * @brief Handles the written characteristic indication from the PASPS.      *//**
 *
 * @param[in] msgid     PASPS_WRITTEN_CHAR_VAL_IND
 * @param[in] param     Pointer to the struct pasps_written_char_val_ind
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_PASPS
 *
 * @return If the message was consumed or not.
 * @description
 * This handler is used to inform the Application that the value of one of the writable
 * attribute has been successfully written by the peer device.
 *
 ****************************************************************************************
 */
int app_pasps_written_char_val_ind_handler(ke_msg_id_t const msgid,
                                           struct pasps_written_char_val_ind *param,
                                           ke_task_id_t const dest_id,
                                           ke_task_id_t const src_id)
{
    switch (param->att_code)
    {
        case PASPS_RINGER_CTNL_PT_CHAR_VAL:
            break;
        case PASPS_ALERT_STATUS_NTF_CFG:
            if (param->value.alert_status_ntf_cfg == PRF_CLI_START_NTF)
                app_pasps_env->app_cfg |= PASPS_FLAG_ALERT_STATUS_CFG;
            else
                app_pasps_env->app_cfg &= ~PASPS_FLAG_ALERT_STATUS_CFG;
            break;
        case PASPS_RINGER_SETTING_NTF_CFG:
            if (param->value.ringer_setting_ntf_cfg == PRF_CLI_START_NTF)
                app_pasps_env->app_cfg |= PASPS_FLAG_RINGER_SETTING_CFG;
            else
                app_pasps_env->app_cfg &= ~PASPS_FLAG_RINGER_SETTING_CFG;
            break;
    }

    app_task_msg_hdl(msgid, param);

    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 6
0
/*
 ****************************************************************************************
 * @brief Handle OTAS_TRANSIMIT_STATUS_IND msg fro OTA  *//**
 *
 * @param[in] msgid     OTAS_TRANSIMIT_STATUS_IND
 * @param[in] param     Pointer to struct otas_transimit_status_ind
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_OTA
 *
 * @return If the message was consumed or not.
 * @description
 *
 * This handler is used to inform the application of the ota transimition status now 
 ****************************************************************************************
 */
int app_otas_start_handler(ke_msg_id_t const msgid, struct otas_transimit_status_ind const * param,
                           ke_task_id_t const dest_id, ke_task_id_t const src_id)
{
    app_task_msg_hdl(msgid, param);
    
    return (KE_MSG_CONSUMED);    
}
Ejemplo n.º 7
0
/*
 ****************************************************************************************
 * @brief Handles the generic message for read responses for APP. *//**
 *
 * @param[in] msgid     HTPC_RD_CHAR_RSP
 * @param[in] param     Pointer to struct htpc_rd_char_rsp
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_HTPC
 * @return If the message was consumed or not.
 * @description
 *
 *  This API is used by the Collector role to inform the Application of a 
 *  received read response. The status and the data from the read response are passed directly to  
 *  Application, which must interpret them based on the request it made.
 *
 ****************************************************************************************
 */
int app_htpc_rd_char_rsp_handler(ke_msg_id_t const msgid,
                      struct htpc_rd_char_rsp *param,
                      ke_task_id_t const dest_id,
                      ke_task_id_t const src_id)
{
    QPRINTF("HTPC read char response status: 0x%x code: 0x%X.\r\n",
        param->status,
        param->att_code);

    if (param->att_code == HTPC_CHAR_HTS_MEAS_INTV)
    {
        QPRINTF("MEAS INTV: ");
        if (param->data.len == 0)
        {
            QPRINTF("NULL");
        }
        else
        {
            for (uint8_t i = 0; i < param->data.len; i++)
                QPRINTF("%x", param->data.data[param->data.len-i-1]);
        }
        QPRINTF("s\r\n");
    }
    app_task_msg_hdl(msgid, param);

    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 8
0
/*
 ****************************************************************************************
 * @brief Handles the configure ind/ntf indication from the HTPT.       *//**
 *
 * @param[in] msgid     HTPT_CFG_INDNTF_IND
 * @param[in] param     Pointer to the struct htpt_cfg_indntf_ind
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_HTPT
 *
 * @return If the message was consumed or not.
 * @description
 * This handler is used to inform the Application of a new value set in one of the 3
 * Client Characteristic Configuration Descriptors in HTS. It allows the application to be aware of
 * its current settings for HTS and to alter its behavior accordingly if the implementation desires
 * it.
 ****************************************************************************************
 */
int app_htpt_cfg_indntf_ind_handler(ke_msg_id_t const msgid,
                                    struct htpt_cfg_indntf_ind *param,
                                    ke_task_id_t const dest_id,
                                    ke_task_id_t const src_id)
{
    app_task_msg_hdl(msgid, param);
    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 9
0
/*
 ****************************************************************************************
 * @brief Handles the control point indication from the CSCPS.      *//**
 *
 * @param[in] msgid     CSCPS_SC_CTNL_PT_REQ_IND
 * @param[in] param     Pointer to the struct cscps_sc_ctnl_pt_req_ind
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_CSCPS
 *
 * @return If the message was consumed or not.
 * @description
 * This handler is used to inform the Application of the control point characteristic is
 * written by the peer device.
 ****************************************************************************************
 */
int app_cscps_ctnl_pt_req_ind_handler(ke_msg_id_t const msgid,
                                      struct cscps_sc_ctnl_pt_req_ind *param,
                                      ke_task_id_t const dest_id,
                                      ke_task_id_t const src_id)
{
    app_task_msg_hdl(msgid, param);

    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 10
0
/*
 ****************************************************************************************
 * @brief Handles the register to Glucose sensor notifications - confirmation. *//**
 *
 * @param[in] msgid     GLPC_REGISTER_CFM
 * @param[in] param     Pointer to the struct glpc_register_cfm
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_GLPC
 *
 * @return If the message was consumed or not.
 * @description
 *
 *  This API is used by the Collector role to inform the Application about Glucose sensor event 
 *  registration status.
 *
 ****************************************************************************************
 */
int app_glpc_register_cfm_handler(ke_msg_id_t const msgid,
                      struct glpc_register_cfm *param,
                      ke_task_id_t const dest_id,
                      ke_task_id_t const src_id)
{
    QPRINTF("GLPC register confirmation status: 0x%x.\r\n", param->status);
    app_task_msg_hdl(msgid, param);

    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 11
0
/*
 ****************************************************************************************
 * @brief Read Current Time Notification Configuration sent to APP. *//**
 *
 * @param[in] msgid     TIPC_CT_NTF_CFG_RD_RSP
 * @param[in] param     Pointer to struct tipc_ct_ntf_cfg_rd_rsp
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_TIPC
 * @return If the message was consumed or not.
 * @description
 *
 *  This API is used by the Client role to inform the application that the notification 
 *  configuration value for the Current Time characteristic has been successfully read and to 
 *  provide this value.
 *
 ****************************************************************************************
 */
int app_tipc_ct_ntf_cfg_rd_rsp_handler(ke_msg_id_t const msgid,
                      struct tipc_ct_ntf_cfg_rd_rsp *param,
                      ke_task_id_t const dest_id,
                      ke_task_id_t const src_id)
{
    QPRINTF("TIPC Read Current Time Notification Configuration: 0x%04X.\r\n", param->ntf_cfg);
    app_task_msg_hdl(msgid, param);

    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 12
0
/*
 ****************************************************************************************
 * @brief Generic message for writing characteristic response status to APP. *//**
 *
 * @param[in] msgid     TIPC_WR_CHAR_RSP
 * @param[in] param     Pointer to struct tipc_wr_char_rsp
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_TIPC
 * @return If the message was consumed or not.
 * @description
 *
 *  This API is used by the Client role to inform the Application of a 
 *  received write response. The status and the data from the write response are passed directly 
 *  to Application, which must interpret them based on the request it made. 
 *
 ****************************************************************************************
 */
int app_tipc_wr_char_rsp_handler(ke_msg_id_t const msgid,
                      struct tipc_wr_char_rsp *param,
                      ke_task_id_t const dest_id,
                      ke_task_id_t const src_id)
{
    QPRINTF("TIPC write char response status: 0x%X.\r\n", param->status);
    app_task_msg_hdl(msgid, param);

    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 13
0
/*
 ****************************************************************************************
 * @brief Read Time Update State value sent to APP. *//**
 *
 * @param[in] msgid     TIPC_TUS_RD_RSP
 * @param[in] param     Pointer to struct tipc_tus_rd_rsp
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_TIPC
 * @return If the message was consumed or not.
 * @description
 *
 *  This API is used by the Client role to inform the application that the TUS characteristic
 *  value has been successfully read and to provide this value.
 * @note
 *
 *  Time Update State Characteristic Structure - UUID: 0x2A17
 *
 *  The Time Update Status Characteristic exposes the status of the time update
 *  process and the result of the last update in the server. 
 *
 *  Current State
 *  Min value: 0, Max value = 1
 *  0 = Idle
 *  1 = Update Pending
 *
 *  Result
 *  Min value: 0, Max Value: 5
 *  0 = Successful
 *  1 = Canceled
 *  2 = No Connection To Reference
 *  3 = Reference responded with an error
 *  4 = Timeout
 *  5 = Update not attempted after reset
 *
 ****************************************************************************************
 */
int app_tipc_tus_rd_rsp_handler(ke_msg_id_t const msgid,
                      struct tipc_tus_rd_rsp *param,
                      ke_task_id_t const dest_id,
                      ke_task_id_t const src_id)
{

    QPRINTF("TIPC Read Time Update State value, State(%d): , Result(%d).\r\n", 
        param->tus_val.current_state,
        param->tus_val.result
        );

#if QN_DBG_TRACE_MORE   
    QPRINTF("State: ");
    switch (param->tus_val.current_state)
    {
    case TIPS_TIME_UPD_STATE_IDLE:
        QPRINTF("Idle, ");
        break;
    case TIPS_TIME_UPD_STATE_PENDING:
        QPRINTF("Update Pending, ");
        break;
    default:
        QPRINTF("Error, ");
        break;
    }
    QPRINTF("Result: ");
    switch (param->tus_val.result)
    {
    case TIPS_TIME_UPD_RESULT_SUCCESS:
        QPRINTF("Successful.\r\n");
        break;
    case TIPS_TIME_UPD_RESULT_CANCELED:
        QPRINTF("Canceled.\r\n");
        break;
    case TIPS_TIME_UPD_RESULT_NO_CONN:
        QPRINTF("No Connection To Reference.\r\n");
        break;
    case TIPS_TIME_UPD_RESULT_ERROR_RSP:
        QPRINTF("Reference responded with an error.\r\n");
        break;
    case TIPS_TIME_UPD_RESULT_TIMEOUT:
        QPRINTF("Timeout.\r\n");
        break;
    case TIPS_TIME_UPD_NOT_ATTEMPTED:
        QPRINTF("Update not attempted after reset.\r\n");
        break;
    default:
        QPRINTF("Error.\r\n");
        break;
    }
#endif
    app_task_msg_hdl(msgid, param);

    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 14
0
/*
 ****************************************************************************************
 * @brief Handles the disable service indication from the HTPT.      *//**
 *
 * @param[in] msgid     HTPT_DISABLE_IND
 * @param[in] param     Pointer to the struct htpt_disable_ind
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_HTPT
 *
 * @return If the message was consumed or not.
 * @description
 * This handler is used to inform the Application of a correct disable. The configuration 
 * that the collector has set in HTS attributes must be conserved and the 4 values that are
 * important are sent back to the application for safe keeping until the next time this 
 * profile role is enabled.
 ****************************************************************************************
 */
int app_htpt_disable_ind_handler(ke_msg_id_t const msgid,
                                 struct htpt_disable_ind *param,
                                 ke_task_id_t const dest_id,
                                 ke_task_id_t const src_id)
{
    app_htpt_env->conhdl = 0xffff;
    app_htpt_env->enabled = false;
    app_task_msg_hdl(msgid, param);

    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 15
0
/*
 ****************************************************************************************
 * @brief Handles the measurement interval value indication to APP. *//**
 *
 * @param[in] msgid     HTPC_MEAS_INTV_IND
 * @param[in] param     Pointer to struct htpc_meas_intv_ind
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_HTPC
 * @return If the message was consumed or not.
 * @description
 *
 *  This API is used by the Collector role to inform the Application of a 
 *  received Measurement Interval Char. Indication and the value it indicates. This value should be 
 *  used by the Application as seen fit. No response is necessary (the GATT sends the necessary 
 *  confirmation to the Indication PDU).
 *
 ****************************************************************************************
 */
int app_htpc_meas_intv_ind_handler(ke_msg_id_t const msgid,
                      struct htpc_meas_intv_ind *param,
                      ke_task_id_t const dest_id,
                      ke_task_id_t const src_id)
{
    QPRINTF("HTPC measurement interval value indication interval: 0x%02X.\r\n", 
        param->intv);
    app_task_msg_hdl(msgid, param);

    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 16
0
/*
 ****************************************************************************************
 * @brief Handles the time update control indication message from the TIPS.     *//**
 *
 * @param[in] msgid     TIPS_TIME_UPD_CTNL_PT_IND
 * @param[in] param     Pointer to the struct tips_time_upd_ctnl_pt_ind
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_TIPS
 *
 * @return If the message was consumed or not.
 * @description
 * This handler is used to inform the application about a modification of the Time Update
 * Control Point Characteristic value.
 ****************************************************************************************
 */
int app_tips_time_upd_ctnl_pt_ind_handler(ke_msg_id_t const msgid,
                                          struct tips_time_upd_ctnl_pt_ind *param,
                                          ke_task_id_t const dest_id,
                                          ke_task_id_t const src_id)
{
    if (app_tips_env->features & TIPS_RTUS_SUP)
    {
        app_task_msg_hdl(msgid, param);
    }    

    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 17
0
/*
 ****************************************************************************************
 * @brief Handles the disable service indication from the TIPS.     *//**
 *
 * @param[in] msgid     TIPS_DISABLE_IND
 * @param[in] param     Pointer to the struct tips_disable_ind
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_TIPS
 *
 * @return If the message was consumed or not.
 * @description
 * This handler is used to inform the application of a correct disable.
 * The current notification configuration value for the Current Time characteristic is included in
 * the parameters so that the higher application may safely keep the configuration until the next
 * time the profile role is enabled.
 ****************************************************************************************
 */
int app_tips_disable_ind_handler(ke_msg_id_t const msgid,
                                 struct tips_disable_ind *param,
                                 ke_task_id_t const dest_id,
                                 ke_task_id_t const src_id)
{
    app_tips_env->conhdl = 0xFFFF;
    app_tips_env->enabled = false;
    app_tips_env->ntf_sending = false;
    app_task_msg_hdl(msgid, param);
    
    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 18
0
/*
 ****************************************************************************************
 * @brief Handles the generic message for read responses for APP. *//**
 *
 * @param[in] msgid     BLPC_RD_CHAR_RSP
 * @param[in] param     Pointer to struct blpc_rd_char_rsp
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_BLPC
 * @return If the message was consumed or not.
 * @description
 *
 *  This API is used by the Collector role to inform the Application of a received read response. The 
 *  status and the data from the read response are passed directly to Application, which must interpret them based on 
 *  the request it made.
 ****************************************************************************************
 */
int app_blpc_rd_char_rsp_handler(ke_msg_id_t const msgid,
                      struct blpc_rd_char_rsp *param,
                      ke_task_id_t const dest_id,
                      ke_task_id_t const src_id)
{
    QPRINTF("BLPC read char response status: 0x%x.\r\n", param->status);
    QTRACE(param->data.data, param->data.len, 1, 2);
    QPRINTF("\r\n");
    app_task_msg_hdl(msgid, param);

    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 19
0
/*
 ****************************************************************************************
 * @brief Handles the disable service indication from the RSCPS.      *//**
 *
 * @param[in] msgid     RSCPS_DISABLE_IND
 * @param[in] param     Pointer to the struct rscps_disable_ind
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_RSCPS
 *
 * @return If the message was consumed or not.
 * @description
 * This handler is used to inform the Application of a correct disable. The current notification
 * configuration values for the Measurement characteristic and the SC control point characteristic
 * are included in the parameters so that the higher application may safely keep the
 * configuration until the next time the profile role is enabled.
 ****************************************************************************************
 */
int app_rscps_disable_ind_handler(ke_msg_id_t const msgid,
                                  struct rscps_disable_ind *param,
                                  ke_task_id_t const dest_id,
                                  ke_task_id_t const src_id)
{
    app_rscps_env->conhdl = 0xffff;
    app_rscps_env->enabled = false;
    app_rscps_env->app_cfg |= (param->rsc_meas_ntf_cfg == PRF_CLI_START_NTF) ? RSCP_PRF_CFG_FLAG_RSC_MEAS_NTF : 0;
    app_rscps_env->app_cfg |= (param->sc_ctnl_pt_ntf_cfg == PRF_CLI_START_IND) ? RSCP_PRF_CFG_FLAG_SC_CTNL_PT_IND : 0;
    app_rscps_env->ntf_sending = false;
    app_task_msg_hdl(msgid, param);

    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 20
0
/*
 ****************************************************************************************
 * @brief Handles the disable service indication from the PASPS.      *//**
 *
 * @param[in] msgid     PASPS_DISABLE_IND
 * @param[in] param     Pointer to the struct pasps_disable_ind
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_PASPS
 *
 * @return If the message was consumed or not.
 * @description
 * This handler is used to inform the Application of a correct disable. The current notification
 * configuration values for the Alert status characteristic and the Ringer Setting characteristic
 * are included in the parameters so that the higher application may safely keep the
 * configuration until the next time the profile role is enabled.
 ****************************************************************************************
 */
int app_pasps_disable_ind_handler(ke_msg_id_t const msgid,
                                  struct pasps_disable_ind *param,
                                  ke_task_id_t const dest_id,
                                  ke_task_id_t const src_id)
{
    app_pasps_env->conhdl = 0xffff;
    app_pasps_env->enabled = false;
    app_pasps_env->app_cfg |= (param->alert_status_ntf_cfg == PRF_CLI_START_NTF) ? PASPS_FLAG_ALERT_STATUS_CFG : 0;
    app_pasps_env->app_cfg |= (param->ringer_setting_ntf_cfg == PRF_CLI_START_IND) ? PASPS_FLAG_RINGER_SETTING_CFG : 0;
    app_pasps_env->ntf_sending = 0;
    app_task_msg_hdl(msgid, param);

    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 21
0
/*
 ****************************************************************************************
 * @brief Read Local Time Info value sent to APP. *//**
 *
 * @param[in] msgid     TIPC_LTI_RD_RSP
 * @param[in] param     Pointer to struct tipc_lti_rd_rsp
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_TIPC
 * @return If the message was consumed or not.
 * @description
 *
 *  This API is used by the Client role to inform the application that the LTI characteristic
 *  value has been successfully read and to provide this value.
 * @note
 *
 *  Time Zone Characteristic  UUID: 0x2A0E
 *  Min value : -48 (UTC-12:00), Max value : 56 (UTC+14:00)
 *  -128 : Time zone offset is not known
 *
 *  DST Offset Characteristic  UUID: 0x2A2D
 *  Min value : 0, Max value : 8
 *  255 = DST is not known
 *
 ****************************************************************************************
 */
int app_tipc_lti_rd_rsp_handler(ke_msg_id_t const msgid,
                      struct tipc_lti_rd_rsp *param,
                      ke_task_id_t const dest_id,
                      ke_task_id_t const src_id)
{
    QPRINTF("TIPC Read Local Time Info, Time Zone(%+d): UTC%d:00, DST Offset: %d.\r\n",
       param->lti_val.time_zone,
       param->lti_val.time_zone/4,
       param->lti_val.dst_offset
       );
    app_task_msg_hdl(msgid, param);

    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 22
0
/*
 ****************************************************************************************
 * @brief Handles the generic message for read responses for APP. *//**
 *
 * @param[in] msgid     HRPC_RD_CHAR_RSP
 * @param[in] param     Pointer to struct hrpc_rd_char_rsp
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_HRPC
 * @return If the message was consumed or not.
 * @description
 *
 *  This API is used by the Collector role to inform the Application of a received read response. The 
 *  status and the data from the read response are passed directly to Application, which must interpret them based on 
 *  the request it made. 
 * @note 
 * Response for read Body Sensor Location and Heart Rate Measurement Client Cfg.Desc
 *
 ****************************************************************************************
 */
int app_hrpc_rd_char_rsp_handler(ke_msg_id_t const msgid,
                      struct hrpc_rd_char_rsp *param,
                      ke_task_id_t const dest_id,
                      ke_task_id_t const src_id)
{
    uint8_t idx = KE_IDX_GET(src_id);

    QPRINTF("HRPC read char response status: 0x%x.\r\n",
        param->status);

    switch (app_hrpc_env[idx].cur_code)
    {
    case 1:
 #if QN_DBG_TRACE_MORE 
        QPRINTF("HRPC Body Sensor Location is ");
        switch (param->data.data[0])
        {
        case HRS_LOC_CHEST:
            QPRINTF("Chest.\r\n");
            break;
        case HRS_LOC_WRIST:
            QPRINTF("Wrist.\r\n");
            break;
        case HRS_LOC_FINGER:
            QPRINTF("Finger.\r\n");
            break;
        case HRS_LOC_HAND:
            QPRINTF("Hand.\r\n");
            break;
        case HRS_LOC_EAR_LOBE:
            QPRINTF("Ear Lobe.\r\n");
            break;
        case HRS_LOC_FOOT:
            QPRINTF("Foot.\r\n");
            break;
        case HRS_LOC_OTHER:
        default:
            QPRINTF("Other.\r\n");
            break;
        }
#endif
        break;
    default:
        break;
    }
    app_task_msg_hdl(msgid, param);

    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 23
0
/*
 ****************************************************************************************
 * @brief Handles the send measurement interval indication from the HTPT.       *//**
 *
 * @param[in] msgid     HTPT_MEAS_INTV_CHG_IND
 * @param[in] param     Pointer to the struct htpt_meas_intv_chg_ind
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_HTPT
 *
 * @return If the message was consumed or not.
 * @description
 * This handler is used to inform the application that the measurement interval value has changed.
 * The application uses the new value to either decide to stop periodic measurements if the 
 * value of the interval has changed from non 0 to 0, or the opposite, to start periodic 
 * measurements using the interval value, if the value has changed from 0 to non 0.
 * This handler will only be triggered if the new value that the Collector is trying to write is valid
 * (within the Valid Range descriptor minimum and maximum values). If the value is not within
 * range, this handler is never be triggered by the application because the HTPT will send an Error
 * Response to the Collector with the 'Out of Range' code 0x80 and the new value will never be
 * set.
 ****************************************************************************************
 */
int app_htpt_meas_intv_chg_ind_handler(ke_msg_id_t const msgid,
                                       struct htpt_meas_intv_chg_ind *param,
                                       ke_task_id_t const dest_id,
                                       ke_task_id_t const src_id)
{
    // We need check the valid range of interval
    if (param->intv >= HTPT_MEAS_INTV_DFLT_MIN &&
        param->intv <= HTPT_MEAS_INTV_DFLT_MAX)
    {
        app_htpt_env->meas_intv = param->intv;
        QPRINTF("HTPT interval change indication.\r\n");
        app_task_msg_hdl(msgid, param);
    }
    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 24
0
/*
 ****************************************************************************************
 * @brief Handles the generic message for read responses for APP. *//**
 *
 * @param[in] msgid     QPPC_RD_CHAR_RSP
 * @param[in] param     Pointer to struct qppc_rd_char_rsp
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_QPPC
 * @return If the message was consumed or not.
 * @description
 * This API is used by the Client role to inform the Application of a received read response. The 
 * status and the data from the read response are passed directly to Application, which must interpret 
 * them based on the request it made.
 *
 ****************************************************************************************
 */
int app_qppc_rd_char_rsp_handler(ke_msg_id_t const msgid,
                                 struct qppc_rd_char_rsp *param,
                                 ke_task_id_t const dest_id,
                                 ke_task_id_t const src_id)
{
    uint8_t idx = KE_IDX_GET(src_id);

    if (app_qppc_env[idx].cur_code == QPPC_QPPS_RX_CHAR_VALUE_USER_DESP)
    {
        app_qppc_cfg_indntf_req(PRF_CLI_START_NTF, app_qppc_env[idx].conhdl, QPPC_QPPS_FIRST_TX_VALUE_CLI_CFG);
        app_qppc_env[idx].cur_code = QPPC_QPPS_FIRST_TX_VALUE_CLI_CFG;
    }
    app_task_msg_hdl(msgid, param);

    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 25
0
/*
 ****************************************************************************************
 * @brief Handles the enable confirmation from the TIPC. *//**
 *
 * @param[in] msgid     TIPC_ENABLE_CFM
 * @param[in] param     Pointer to struct tipc_enable_cfm
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_TIPC
 * @return If the message was consumed or not.
 * @description
 *
 *  This API is used by the Client to either send the discovery results of CTS, NDCS or 
 *  RTUS and confirm enabling of the Client role (status = PRF_ERR_OK), or to simply confirm 
 *  enabling of Client role if it is a normal connection and the attribute details are already known 
 *  (status = PRF_ERR_OK), or to inform the application that the discovery process has been 
 *  stopped because of a missing attribute (status = PRF_ERR_STOP_DISC_CHAR_MISSING).
 *
 ****************************************************************************************
 */
int app_tipc_enable_cfm_handler(ke_msg_id_t const msgid,
                      struct tipc_enable_cfm *param,
                      ke_task_id_t const dest_id,
                      ke_task_id_t const src_id)
{
    QPRINTF("TIPC enable confirmation status: 0x%X.\r\n", param->status);
    if (param->status == CO_ERROR_NO_ERROR)
    {
        uint8_t idx = KE_IDX_GET(src_id);
        app_tipc_env[idx].conhdl = param->conhdl;
        app_tipc_env[idx].enabled = true;
    }
    app_task_msg_hdl(msgid, param);

    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 26
0
int app_qppc_data_ind_handler(ke_msg_id_t const msgid,
                              struct qppc_data_ind *param,
                              ke_task_id_t const dest_id,
                              ke_task_id_t const src_id)
{
    uint8_t idx = KE_IDX_GET(src_id);

    if ((data_pack%200) == 0 && (data_pack != 0))
    {
        QPRINTF("(%d)Received %d bytes data[%02X] from characteristic %d\r\n", idx, param->length, param->data[0], param->char_code);
    }
    app_task_msg_hdl(msgid, param);
    data_pack ++;

    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 27
0
/*
 ****************************************************************************************
 * @brief Read Reference Time Info value sent to APP. *//**
 *
 * @param[in] msgid     TIPC_RTI_RD_RSP
 * @param[in] param     Pointer to struct tipc_rti_rd_rsp
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_TIPC
 * @return If the message was consumed or not.
 * @description
 *
 *  This API is used by the Client role to inform the application that the RTI characteristic 
 *  value has been successfully read and to provide this value.
 * @note
 *
 *  Time Source Characteristic  UUID: 0x2A13
 *  Min value : 0, Max value : 6
 *  0 = Unknown
 *  1 = Network Time Protocol
 *  2 = GPS
 *  3 = Radio Time Signal
 *  4 = Manual
 *  5 = Atomic Clock
 *  6 = Cellular Network
 *
 *  Time Accuracy Characteristic  UUID: 0x2A12
 *  Accuracy(drift) of time information in steps of 1/8 of a second(125ms) compared 
 *  to a reference time source. Valid range is from 0 to 253 (0s to 31.5s). A value of
 *  254 means Accuracy is out of range(> 31.5s). A value of 255 means Accuracy is unknown.
 *
 *  Days since last update about Reference Source
 *  Min value: 0, Max value: 254
 *  255 = 255 or more days
 *
 *  Hours since update about Reference Source
 *  Min value: 0, Mac value: 23
 *  255 = 255 or more days (If Days Since Update = 255, then Hours Since Update shall also be set to 255)
 *
 ****************************************************************************************
 */
int app_tipc_rti_rd_rsp_handler(ke_msg_id_t const msgid,
                      struct tipc_rti_rd_rsp *param,
                      ke_task_id_t const dest_id,
                      ke_task_id_t const src_id)
{
    
    QPRINTF("TIPC Read Reference Time Info, Source(%d): ",
        param->rti_val.time_source);
	
#if QN_DBG_TRACE_MORE
	switch (param->rti_val.time_source)
    {
    case 1:
        QPRINTF("Network Time Protocol.\r\n");
        break;
    case 2:
        QPRINTF("GPS.\r\n");
        break;
    case 3:
        QPRINTF("Radio Time Signal.\r\n");
        break;
    case 4:
        QPRINTF("Manual.\r\n");
        break;
    case 5:
        QPRINTF("Atomic Clock.\r\n");
        break;
    case 6:
        QPRINTF("Cellular Network.\r\n");
        break;
    case 0:
    default:
        QPRINTF("Unknown.\r\n");
        break;
    }
    
    QPRINTF("Accuracy: %d, Days Update: %d, Hours Update: %d.\r\n",
        param->rti_val.time_accuracy,
        param->rti_val.days_update,
        param->rti_val.hours_update
    );
#endif

    app_task_msg_hdl(msgid, param);

    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 28
0
/*
 ****************************************************************************************
 * @brief Handles the current time CCC indication message from the TIPS.    *//**
 *
 * @param[in] msgid     TIPS_CURRENT_TIME_CCC_IND
 * @param[in] param     Pointer to the struct tips_current_time_ccc_ind
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_TIPS
 *
 * @return If the message was consumed or not.
 * @description
 * This handler is used to inform the application about a modification of the Current Time
 * Client Configuration characteristic value.
 ****************************************************************************************
 */
int app_tips_current_time_ccc_ind_handler(ke_msg_id_t const msgid,
                                          struct tips_current_time_ccc_ind *param,
                                          ke_task_id_t const dest_id,
                                          ke_task_id_t const src_id)
{
    if (param->cfg_val == PRF_CLI_START_NTF) 
    {
        app_tips_env->features |= TIPS_CTS_CURRENT_TIME_CFG;
    }
    else
    {
        app_tips_env->features &= ~TIPS_CTS_CURRENT_TIME_CFG;
    }
    app_task_msg_hdl(msgid, param);

    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 29
0
/*
 ****************************************************************************************
 * @brief Handles the generic message for read responses for APP. *//**
 *
 * @param[in] msgid     PROXM_RD_CHAR_RSP
 * @param[in] param     Pointer to struct proxm_rd_char_rsp
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_PROXM
 * @return If the message was consumed or not.
 * @description
 *
 *  This API is used by the Monitor role to send the Application the
 *  characteristic read response data and the status of the read characteristic request. The
 *  application is in charge of deciphering the data or of the next step if an error is received.
 *
 ****************************************************************************************
 */
int app_proxm_rd_char_rsp_handler(ke_msg_id_t const msgid,
                                  struct proxm_rd_char_rsp *param,
                                  ke_task_id_t const dest_id,
                                  ke_task_id_t const src_id)
{
    uint8_t idx = KE_IDX_GET(src_id);

    QPRINTF("PROXM read char response status: 0x%X.\r\n", param->status);

    if (param->status == CO_ERROR_NO_ERROR)
    {
        if (app_proxm_env[idx].cur_code == 1)
            QPRINTF("Alert Level: ");
        else
            QPRINTF("TX Power Level: ");

        if (app_proxm_env[idx].cur_code == 1)
        {
            switch (param->val)
            {
            case PROXM_ALERT_NONE:
                QPRINTF("None.");
                break;
            case PROXM_ALERT_MILD:
                QPRINTF("Mild.");
                break;
            case PROXM_ALERT_HIGH:
                QPRINTF("High.");
                break;
            default:
                QPRINTF("Error.");
                break;
            }
        }
        else
            QPRINTF("%+d dbm", (int8_t)param->val);
        QPRINTF("\r\n");
    }
    app_task_msg_hdl(msgid, param);

    return (KE_MSG_CONSUMED);
}
Ejemplo n.º 30
0
/*
 ****************************************************************************************
 * @brief Handles the Blood pressure value send to APP. *//**
 *
 * @param[in] msgid     BLPC_BP_MEAS_IND
 * @param[in] param     Pointer to struct blpc_meas_ind
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_BLPC
 * @return If the message was consumed or not.
 * @description
 *
 *  This API is used by the Collector role to inform the Application of a received blood pressure 
 *  value, either by notification (flag_interm_cp = intermediate) or indication (flag_interm_cp = stable). The application 
 *  will do what it needs to do with the received measurement. No confirmation of reception is needed because the GATT 
 *  sends it directly to the peer. 
 ****************************************************************************************
 */
int app_blpc_bp_meas_ind_handler(ke_msg_id_t const msgid,
                      struct blpc_meas_ind *param,
                      ke_task_id_t const dest_id,
                      ke_task_id_t const src_id)
{
#if QN_DBG_TRACE_MORE  
    if (param->meas_val.flags & BPS_FLAG_TIME_STAMP_PRESENT)
        QPRINTF("Date: %04d:%02d:%02d Time: %02d:%02d:%02d\r\n", 
            param->meas_val.time_stamp.year,
            param->meas_val.time_stamp.month,
            param->meas_val.time_stamp.day,
            param->meas_val.time_stamp.hour,
            param->meas_val.time_stamp.min,
            param->meas_val.time_stamp.sec);
#endif

    QPRINTF("BP Value(%d), Flag:%X, User ID:%X, Meas Status:%X, Pulse Rate:%d\r\n",
        param->flag_interm_cp,
        param->meas_val.flags,
        (param->meas_val.flags & BPS_FLAG_USER_ID_PRESENT) ? param->meas_val.user_id : 0,
        (param->meas_val.flags & BPS_FLAG_MEAS_STATUS_PRESENT) ? param->meas_val.meas_status : 0,
        (param->meas_val.flags & BPS_FLAG_PULSE_RATE_PRESENT) ? param->meas_val.pulse_rate : 0
        );

#if QN_DBG_TRACE_MORE    
    if (param->meas_val.flags & BPS_FLAG_KPA)
        QPRINTF("Systolic:0x%X(kpa), Diastolic:0x%X(kpa), Mean Arterial Pressure:0x%X(kpa)\r\r\n",
            param->meas_val.systolic,
            param->meas_val.diastolic,
            param->meas_val.mean_arterial_pressure
            );
    else
        QPRINTF("Systolic:%d(mmhg), Diastolic:%d(mmhg), Mean Arterial Pressure:%d(mmhg)\r\r\n",
            param->meas_val.systolic,
            param->meas_val.diastolic,
            param->meas_val.mean_arterial_pressure
            );
#endif
    app_task_msg_hdl(msgid, param);

    return (KE_MSG_CONSUMED);
}