Cordio Stack and Cordio Profiles  r2p3-02rel0
bas_api.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file
4  *
5  * \brief Battery service server.
6  *
7  * Copyright (c) 2012-2018 Arm Ltd. All Rights Reserved.
8  * ARM Ltd. confidential and proprietary.
9  *
10  * IMPORTANT. Your use of this file is governed by a Software License Agreement
11  * ("Agreement") that must be accepted in order to download or otherwise receive a
12  * copy of this file. You may not use or copy this file for any purpose other than
13  * as described in the Agreement. If you do not agree to all of the terms of the
14  * Agreement do not use this file and delete all copies in your possession or control;
15  * if you do not have a copy of the Agreement, you must contact ARM Ltd. prior
16  * to any use, copying or further distribution of this software.
17  */
18 /*************************************************************************************************/
19 #ifndef BAS_API_H
20 #define BAS_API_H
21 
22 #include "wsf_timer.h"
23 #include "att_api.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 /*! \addtogroup BATTERY_PROFILE
30  * \{ */
31 
32 /**************************************************************************************************
33  Data Types
34 **************************************************************************************************/
35 
36 
37 /**************************************************************************************************
38  Function Declarations
39 **************************************************************************************************/
40 
41 /*! \brief Battery service configurable parameters */
42 typedef struct
43 {
44  wsfTimerTicks_t period; /*!< \brief Battery measurement timer expiration period in seconds */
45  uint16_t count; /*!< \brief Perform battery measurement after this many timer periods */
46  uint8_t threshold; /*!< \brief Send battery level notification to peer when below this level. */
47 } basCfg_t;
48 
49 /*************************************************************************************************/
50 /*!
51  * \brief Initialize the battery service server.
52  *
53  * \param handlerId WSF handler ID of the application using this service.
54  * \param pCfg Battery service configurable parameters.
55  *
56  * \return None.
57  */
58 /*************************************************************************************************/
59 void BasInit(wsfHandlerId_t handlerId, basCfg_t *pCfg);
60 
61 /*************************************************************************************************/
62 /*!
63  * \brief Start periodic battery level measurement. This function starts a timer to perform
64  * periodic battery measurements.
65  *
66  * \param connId DM connection identifier.
67  * \param timerEvt WSF event designated by the application for the timer.
68  * \param battCccIdx Index of battery level CCC descriptor in CCC descriptor handle table.
69  *
70  * \return None.
71  */
72 /*************************************************************************************************/
73 void BasMeasBattStart(dmConnId_t connId, uint8_t timerEvt, uint8_t battCccIdx);
74 
75 /*************************************************************************************************/
76 /*!
77  * \brief Stop periodic battery level measurement.
78  *
79  * \param connId DM connection identifier.
80  *
81  * \return None.
82  */
83 /*************************************************************************************************/
84 void BasMeasBattStop(dmConnId_t connId);
85 
86 /*************************************************************************************************/
87 /*!
88  * \brief Process received WSF message.
89  *
90  * \param pMsg Event message.
91  *
92  * \return None.
93  */
94 /*************************************************************************************************/
95 void BasProcMsg(wsfMsgHdr_t *pMsg);
96 
97 /*************************************************************************************************/
98 /*!
99  * \brief Send the battery level to the peer device.
100  *
101  * \param connId DM connection identifier.
102  * \param idx Index of battery level CCC descriptor in CCC descriptor handle table.
103  * \param level The battery level.
104  *
105  * \return None.
106  */
107 /*************************************************************************************************/
108 void BasSendBattLevel(dmConnId_t connId, uint8_t idx, uint8_t level);
109 
110 /*************************************************************************************************/
111 /*!
112  * \brief ATTS read callback for battery service used to read the battery level. Use this
113  * function as a parameter to SvcBattCbackRegister().
114  *
115  * \param connId DM connection identifier.
116  * \param handle ATT handle.
117  * \param operation ATT operation.
118  * \param offset read offset.
119  * \param pAttr pointer to Attribute
120  *
121  * \return ATT status.
122  */
123 /*************************************************************************************************/
124 uint8_t BasReadCback(dmConnId_t connId, uint16_t handle, uint8_t operation,
125  uint16_t offset, attsAttr_t *pAttr);
126 
127 /*! \} */ /* BATTERY_PROFILE */
128 
129 #ifdef __cplusplus
130 };
131 #endif
132 
133 #endif /* BAS_API_H */
uint8_t dmConnId_t
Connection identifier.
Definition: dm_api.h:501
void BasSendBattLevel(dmConnId_t connId, uint8_t idx, uint8_t level)
Send the battery level to the peer device.
void BasMeasBattStart(dmConnId_t connId, uint8_t timerEvt, uint8_t battCccIdx)
Start periodic battery level measurement. This function starts a timer to perform periodic battery me...
uint8_t threshold
Send battery level notification to peer when below this level.
Definition: bas_api.h:46
wsfTimerTicks_t period
Battery measurement timer expiration period in seconds.
Definition: bas_api.h:44
void BasMeasBattStop(dmConnId_t connId)
Stop periodic battery level measurement.
uint8_t wsfHandlerId_t
Event handler ID data type.
Definition: wsf_os.h:74
Battery service configurable parameters.
Definition: bas_api.h:42
Attribute structure.
Definition: att_api.h:186
void BasInit(wsfHandlerId_t handlerId, basCfg_t *pCfg)
Initialize the battery service server.
unsigned short uint16_t
Unsigned 16-bit value.
Definition: wsf_types.h:67
Timer service.
uint16_t count
Perform battery measurement after this many timer periods.
Definition: bas_api.h:45
uint32_t wsfTimerTicks_t
Timer ticks data type.
Definition: wsf_timer.h:45
void BasProcMsg(wsfMsgHdr_t *pMsg)
Process received WSF message.
uint8_t BasReadCback(dmConnId_t connId, uint16_t handle, uint8_t operation, uint16_t offset, attsAttr_t *pAttr)
ATTS read callback for battery service used to read the battery level. Use this function as a paramet...
Attribute protocol client and server API.
Common message structure passed to event handler.
Definition: wsf_os.h:97
unsigned char uint8_t
Unsigned 8-bit value.
Definition: wsf_types.h:63