pinebuds/services/ble_profiles/dis/diss/src/diss.h

198 lines
5.1 KiB
C
Raw Normal View History

2022-08-15 04:20:27 -05:00
#ifndef DISS_H_
#define DISS_H_
/**
****************************************************************************************
* @addtogroup DISS Device Information Service Server
* @ingroup DIS
* @brief Device Information Service Server
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "rwip_config.h"
#if (BLE_DIS_SERVER)
#include "prf_types.h"
#include "prf.h"
/*
* DEFINES
****************************************************************************************
*/
#define DISS_IDX_MAX (1)
/*
* ENUMERATIONS
****************************************************************************************
*/
/// Possible states of the DISS task
enum
{
/// Idle state
DISS_IDLE,
/// Busy state
DISS_BUSY,
/// Number of defined states.
DISS_STATE_MAX
};
/// DISS Attributes database handle list
enum diss_att_db_handles
{
DIS_IDX_SVC,
DIS_IDX_MANUFACTURER_NAME_CHAR,
DIS_IDX_MANUFACTURER_NAME_VAL,
DIS_IDX_MODEL_NB_STR_CHAR,
DIS_IDX_MODEL_NB_STR_VAL,
DIS_IDX_SERIAL_NB_STR_CHAR,
DIS_IDX_SERIAL_NB_STR_VAL,
DIS_IDX_HARD_REV_STR_CHAR,
DIS_IDX_HARD_REV_STR_VAL,
DIS_IDX_FIRM_REV_STR_CHAR,
DIS_IDX_FIRM_REV_STR_VAL,
DIS_IDX_SW_REV_STR_CHAR,
DIS_IDX_SW_REV_STR_VAL,
DIS_IDX_SYSTEM_ID_CHAR,
DIS_IDX_SYSTEM_ID_VAL,
DIS_IDX_IEEE_CHAR,
DIS_IDX_IEEE_VAL,
DIS_IDX_PNP_ID_CHAR,
DIS_IDX_PNP_ID_VAL,
DIS_IDX_NB,
};
/// Value element
struct diss_val_elmt
{
/// list element header
struct co_list_hdr hdr;
/// value identifier
uint8_t value;
/// value length
uint8_t length;
/// value data
uint8_t data[__ARRAY_EMPTY];
};
///Device Information Service Server Environment Variable
struct diss_env_tag
{
/// profile environment
prf_env_t prf_env;
/// List of values set by application
struct co_list values;
/// Service Attribute Start Handle
uint16_t start_hdl;
/// Services features
uint16_t features;
/// Last requested value
uint8_t req_val;
/// Last connection index which request value
uint8_t req_conidx;
/// DISS task state
ke_state_t state[DISS_IDX_MAX];
};
/*
* GLOBAL VARIABLE DECLARATIONS
****************************************************************************************
*/
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Retrieve DIS service profile interface
*
* @return DIS service profile interface
****************************************************************************************
*/
const struct prf_task_cbs* diss_prf_itf_get(void);
/**
****************************************************************************************
* @brief Check if an attribute shall be added or not in the database
*
* @param features DIS features
*
* @return Feature config flag
****************************************************************************************
*/
uint32_t diss_compute_cfg_flag(uint16_t features);
/**
****************************************************************************************
* @brief Check if the provided value length matches characteristic requirements
* @param char_code Characteristic Code
* @param val_len Length of the Characteristic value
*
* @return status if value length is ok or not
****************************************************************************************
*/
uint8_t diss_check_val_len(uint8_t char_code, uint8_t val_len);
/**
****************************************************************************************
* @brief Retrieve handle attribute from value
*
* @param[in] env Service environment variable
* @param[in] value Value to search
*
* @return Handle attribute from value
****************************************************************************************
*/
uint16_t diss_value_to_handle(struct diss_env_tag* env, uint8_t value);
/**
****************************************************************************************
* @brief Retrieve value from attribute handle
*
* @param[in] env Service environment variable
* @param[in] handle Attribute handle to search
*
* @return Value from attribute handle
****************************************************************************************
*/
uint8_t diss_handle_to_value(struct diss_env_tag* env, uint16_t handle);
/*
* TASK DESCRIPTOR DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* Initialize task handler
*
* @param task_desc Task descriptor to fill
****************************************************************************************
*/
void diss_task_init(struct ke_task_desc *task_desc);
#endif //BLE_DIS_SERVER
/// @} DISS
#endif // DISS_H_