Cordio Stack and Cordio Profiles  r2p3-02rel0
wdxs_main.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file
4  *
5  * \brief Wireless Data Exchange profile implementation.
6  *
7  * Copyright (c) 2013-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 
20 #ifndef WDXS_MAIN_H
21 #define WDXS_MAIN_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /*! \addtogroup WIRELESS_DATA_EXCHANGE_PROFILE
28  * \{ */
29 
30 /**************************************************************************************************
31  Macros
32 **************************************************************************************************/
33 
34 /** \name WDXS Default Feature Set
35  *
36  */
37 /**@{*/
38 #ifndef WDXS_DC_ENABLED
39 #define WDXS_DC_ENABLED TRUE
40 #endif
41 
42 #ifndef WDXS_AU_ENABLED
43 #define WDXS_AU_ENABLED TRUE
44 #endif
45 
46 #ifndef WDXS_OTA_ENABLED
47 #define WDXS_OTA_ENABLED TRUE
48 #endif
49 /**@}*/
50 
51 /*! \brief Special length for streaming file */
52 #define WDXS_STREAM_FILE_LEN 0xFFFFFFFF
53 
54 /** \name WSF event types for application event handler
55  *
56  */
57 /**@{*/
58 #define WDXS_EVT_TX_PATH 0x01 /*!< \brief Trigger tx data path */
59 #define WDXS_EVT_AU_SEC_COMPLETE 0x02 /*!< \brief AU encryption of challenge ready */
60 /**@}*/
61 
62 /** \name TX Ready Mask Bits
63  *
64  */
65 /**@{*/
66 #define WDXS_TX_MASK_READY_BIT (1<<0) /*!< \brief Ready bit */
67 #define WDXS_TX_MASK_DC_BIT (1<<1) /*!< \brief DC bit */
68 #define WDXS_TX_MASK_FTC_BIT (1<<2) /*!< \brief FTC bit */
69 #define WDXS_TX_MASK_FTD_BIT (1<<3) /*!< \brief FTD bit */
70 #define WDXS_TX_MASK_AU_BIT (1<<4) /*!< \brief AU bit */
71 /**@}*/
72 
73 /** \name Authentication states
74  *
75  */
76 /**@{*/
77 #define WDXS_AU_STATE_UNAUTHORIZED 0x00 /*!< \brief Authentication has not started */
78 #define WDXS_AU_STATE_HASHING 0x01 /*!< \brief Authentication hash is being calculated */
79 #define WDXS_AU_STATE_WAIT_SEC 0x02 /*!< \brief Authentication challenge sent */
80 #define WDXS_AU_STATE_WAIT_REPLY 0x03 /*!< \brief Authentication waiting for challenge reply */
81 #define WDXS_AU_STATE_AUTHORIZED 0x04 /*!< \brief Authentication completed successfully */
82 /**@}*/
83 
84 /**************************************************************************************************
85  Data Types
86 **************************************************************************************************/
87 
88 /*! \brief WDXS Device Configuration PHY Write Callback */
90  uint8_t *pValue);
91 
92 /**************************************************************************************************
93  Local Variables
94 **************************************************************************************************/
95 
96 /*! \brief WDXS profile control block */
97 typedef struct
98 {
99  wsfHandlerId_t handlerId; /*!< \brief WSF handler ID */
100  uint8_t txReadyMask; /*!< \brief Bits indicate DC, FTC, FTD, and/or AU wish to transmit */
101 
102  /* connection parameters */
103  uint16_t connInterval; /*!< \brief connection interval */
104  uint16_t connLatency; /*!< \brief connection latency */
105  uint16_t supTimeout; /*!< \brief supervision timeout */
106 
107  /* Phy parameters */
108  uint8_t txPhy; /*!< \brief transmitter PHY */
109  uint8_t rxPhy; /*!< \brief receiver PHY */
110 
111  /* for file transfer */
112  uint32_t ftOffset; /*!< \brief file data offset */
113  uint32_t ftLen; /*!< \brief remaining data length for current operation */
114  uint32_t ftTotalLen; /*!< \brief file total length */
115  uint16_t ftHandle; /*!< \brief file handle */
116  uint16_t ftcMsgLen; /*!< \brief message length */
117  uint8_t ftcMsgBuf[ATT_DEFAULT_PAYLOAD_LEN]; /*!< \brief message buffer */
118  uint8_t ftInProgress; /*!< \brief operation in progress */
119  uint8_t ftPrefXferType; /*!< \brief Preferred transport type */
120 
121  /* ccc index */
122  uint8_t dcCccIdx; /*!< \brief device configuration ccc index */
123  uint8_t auCccIdx; /*!< \brief authentication ccc index */
124  uint8_t ftcCccIdx; /*!< \brief file transfer control ccc index */
125  uint8_t ftdCccIdx; /*!< \brief file transfer data ccc index */
126 } wdxsCb_t;
127 
128 /*! \brief WDXS Device Configuration Control Block */
129 typedef struct
130 {
131  uint16_t dcMsgLen; /*!< \brief message length */
132  uint8_t dcMsgBuf[ATT_DEFAULT_PAYLOAD_LEN]; /*!< \brief message buffer */
133  bool_t doReset; /*!< \brief Reset device after disconnect */
134  wdxsDcPhyWriteCback_t phyWriteCback; /*!< \brief Device config PHY write callback */
135 } wdxsDcCb_t;
136 
137 /*! \brief WDXS Authentication Control Block */
138 typedef struct
139 {
140  uint8_t auMsgBuf[ATT_DEFAULT_PAYLOAD_LEN]; /*!< \brief message buffer */
141  uint8_t auRand[WDX_AU_RAND_LEN]; /*!< \brief random challenge */
142  uint8_t sessionKey[WDX_AU_KEY_LEN]; /*!< \brief session key */
143  uint8_t auHash[WDX_AU_HASH_LEN]; /*!< \brief session key */
144  uint16_t auMsgLen; /*!< \brief message length */
145  uint8_t authLevel; /*!< \brief current authentication level */
146  uint8_t authMode; /*!< \brief current authentication mode */
147  uint8_t reqAuthLevel; /*!< \brief requested authentication level */
148  uint8_t authState; /*!< \brief authentication protocol state */
149 } wdxsAuCb_t;
150 
151 /*! \brief WDXS event message union */
152 typedef union
153 {
154  wsfMsgHdr_t hdr; /*!< header */
155  dmEvt_t dm; /*!< DM event */
156  attsCccEvt_t ccc; /*!< ATT CCC event */
157 } wdxsMsg_t;
158 
159 /**************************************************************************************************
160  Global Variables
161 **************************************************************************************************/
162 
163 /** \name WDXS Control Block External Declaration
164  *
165  */
166 /**@{*/
167 extern wdxsCb_t wdxsCb; /*!< \brief WDXS control block */
168 extern wdxsAuCb_t wdxsAuCb; /*!< \brief WDXS AU control block */
169 extern wdxsDcCb_t wdxsDcCb; /*!< \brief WDXS DC control block */
170 /**@}*/
171 
172 /**************************************************************************************************
173  Global Function Prototypes
174 **************************************************************************************************/
175 
176 /*************************************************************************************************/
177 /*!
178  * \brief Send device configuration notification
179  *
180  * \param connId DM connection identifier.
181  *
182  * \return None.
183  */
184 /*************************************************************************************************/
185 void wdxsDcSend(dmConnId_t connId);
186 
187 /*************************************************************************************************/
188 /*!
189  * \brief Send a file transfer control characteristic notification.
190  *
191  * \param connId DM connection identifier.
192  *
193  * \return None.
194  */
195 /*************************************************************************************************/
196 void wdxsFtcSend(dmConnId_t connId);
197 
198 /*************************************************************************************************/
199 /*!
200  * \brief Send a file transfer data characteristic notification.
201  *
202  * \param connId DM connection identifier.
203  *
204  * \return None.
205  */
206 /*************************************************************************************************/
207 void wdxsFtdSend(dmConnId_t connId);
208 
209 /*************************************************************************************************/
210 /*!
211  * \brief Transmit to authentication characteristic.
212  *
213  * \param connId DM connection identifier.
214  *
215  * \return ATT status.
216  */
217 /*************************************************************************************************/
218 void wdxsAuSend(dmConnId_t connId);
219 
220 /*************************************************************************************************/
221 /*!
222  * \brief Process a write to the device configuration characteristic.
223  *
224  * \param connId DM connection identifier.
225  * \param len Length to write.
226  * \param pValue value to write.
227  *
228  * \return ATT status.
229  */
230 /*************************************************************************************************/
231 uint8_t wdxsDcWrite(dmConnId_t connId, uint16_t len, uint8_t *pValue);
232 
233 /*************************************************************************************************/
234 /*!
235  * \brief Process a write to the file transfer control characteristic.
236  *
237  * \param connId DM connection identifier.
238  * \param len Length to write.
239  * \param pValue Value to write.
240  *
241  * \return ATT status.
242  */
243 /*************************************************************************************************/
244 uint8_t wdxsFtcWrite(dmConnId_t connId, uint16_t len, uint8_t *pValue);
245 
246 /*************************************************************************************************/
247 /*!
248  * \brief Process a write to the file transfer data characteristic.
249  *
250  * \param connId DM connection identifier.
251  * \param len Length to write.
252  * \param pValue Value to write.
253  *
254  * \return ATT status.
255  */
256 /*************************************************************************************************/
257 uint8_t wdxsFtdWrite(dmConnId_t connId, uint16_t len, uint8_t *pValue);
258 
259 /*************************************************************************************************/
260 /*!
261  * \brief Process a write to the authentication characteristic.
262  *
263  * \param connId DM connection identifier.
264  * \param len Length to write.
265  * \param pValue Value to write
266  *
267  * \return ATT status.
268  */
269 /*************************************************************************************************/
270 uint8_t wdxsAuWrite(dmConnId_t connId, uint16_t len, uint8_t *pValue);
271 
272 /*************************************************************************************************/
273 /*!
274  * \brief Send update message for connection parameters.
275  *
276  * \param connId DM connection identifier.
277  * \param status Update status.
278  *
279  * \return ATT status.
280  */
281 /*************************************************************************************************/
283 
284 /*************************************************************************************************/
285 /*!
286  * \brief Send update message for PHY.
287  *
288  * \param connId DM connection identifier.
289  * \param status Update status.
290  *
291  * \return ATT status.
292  */
293 /*************************************************************************************************/
294 uint8_t wdxsDcUpdatePhy(dmConnId_t connId, uint8_t status);
295 
296 /*************************************************************************************************/
297 /*!
298  * \brief Register a PHY write callback for the device configuration characteristic.
299  *
300  * \param cback PHY callback function.
301  *
302  * \return None.
303  */
304 /*************************************************************************************************/
306 
307 /*************************************************************************************************/
308 /*!
309  * \brief Create the file list.
310  *
311  * \return none.
312  */
313 /*************************************************************************************************/
314 void WdxsUpdateListing(void);
315 
316 /*! \} */ /* WIRELESS_DATA_EXCHANGE_PROFILE */
317 
318 #ifdef __cplusplus
319 }
320 #endif
321 
322 #endif /* WDXS_MAIN_H */
uint8_t txPhy
transmitter PHY
Definition: wdxs_main.h:108
uint8_t ftcCccIdx
file transfer control ccc index
Definition: wdxs_main.h:124
uint8_t ftPrefXferType
Preferred transport type.
Definition: wdxs_main.h:119
wdxsAuCb_t wdxsAuCb
WDXS AU control block.
uint8_t dmConnId_t
Connection identifier.
Definition: dm_api.h:501
void wdxsFtcSend(dmConnId_t connId)
Send a file transfer control characteristic notification.
uint16_t supTimeout
supervision timeout
Definition: wdxs_main.h:105
uint8_t txReadyMask
Bits indicate DC, FTC, FTD, and/or AU wish to transmit.
Definition: wdxs_main.h:100
bool_t doReset
Reset device after disconnect.
Definition: wdxs_main.h:133
uint8_t wdxsFtcWrite(dmConnId_t connId, uint16_t len, uint8_t *pValue)
Process a write to the file transfer control characteristic.
uint8_t authMode
current authentication mode
Definition: wdxs_main.h:146
uint8_t authLevel
current authentication level
Definition: wdxs_main.h:145
uint8_t wdxsFtdWrite(dmConnId_t connId, uint16_t len, uint8_t *pValue)
Process a write to the file transfer data characteristic.
uint8_t wdxsDcWrite(dmConnId_t connId, uint16_t len, uint8_t *pValue)
Process a write to the device configuration characteristic.
uint16_t connLatency
connection latency
Definition: wdxs_main.h:104
uint32_t ftOffset
file data offset
Definition: wdxs_main.h:112
uint8_t bool_t
Boolean data type.
Definition: wsf_types.h:78
wsfHandlerId_t handlerId
WSF handler ID.
Definition: wdxs_main.h:99
uint8_t wdxsAuWrite(dmConnId_t connId, uint16_t len, uint8_t *pValue)
Process a write to the authentication characteristic.
uint8_t wdxsDcUpdatePhy(dmConnId_t connId, uint8_t status)
Send update message for PHY.
void wdxsAuSend(dmConnId_t connId)
Transmit to authentication characteristic.
uint32_t ftLen
remaining data length for current operation
Definition: wdxs_main.h:113
#define WDX_AU_RAND_LEN
Authentication Random challenge length (bytes)
Definition: wdx_defs.h:230
uint16_t connInterval
connection interval
Definition: wdxs_main.h:103
wdxsCb_t wdxsCb
WDXS control block.
uint16_t ftHandle
file handle
Definition: wdxs_main.h:115
void WdxsUpdateListing(void)
Create the file list.
uint8_t ftdCccIdx
file transfer data ccc index
Definition: wdxs_main.h:125
Union of DM callback event data types.
Definition: dm_api.h:658
uint8_t reqAuthLevel
requested authentication level
Definition: wdxs_main.h:147
void wdxsDcSend(dmConnId_t connId)
Send device configuration notification.
WDXS event message union.
Definition: wdxs_main.h:152
uint8_t dcCccIdx
device configuration ccc index
Definition: wdxs_main.h:122
void wdxsDcPhyRegister(wdxsDcPhyWriteCback_t cback)
Register a PHY write callback for the device configuration characteristic.
attsCccEvt_t ccc
Definition: wdxs_main.h:156
uint8_t(* wdxsDcPhyWriteCback_t)(dmConnId_t connId, uint8_t op, uint8_t id, uint16_t len, uint8_t *pValue)
WDXS Device Configuration PHY Write Callback.
Definition: wdxs_main.h:89
unsigned long uint32_t
Unsigned 32-bit value.
Definition: wsf_types.h:71
uint8_t wsfHandlerId_t
Event handler ID data type.
Definition: wsf_os.h:74
ATTS client characteristic configuration callback structure.
Definition: att_api.h:283
wsfMsgHdr_t hdr
Definition: wdxs_main.h:154
uint8_t ftInProgress
operation in progress
Definition: wdxs_main.h:118
uint32_t ftTotalLen
file total length
Definition: wdxs_main.h:114
wdxsDcCb_t wdxsDcCb
WDXS DC control block.
void wdxsFtdSend(dmConnId_t connId)
Send a file transfer data characteristic notification.
uint8_t wdxsDcUpdateConnParam(dmConnId_t connId, uint8_t status)
Send update message for connection parameters.
dmEvt_t dm
Definition: wdxs_main.h:155
uint8_t auCccIdx
authentication ccc index
Definition: wdxs_main.h:123
#define WDX_AU_HASH_LEN
Authentication Hash length (bytes)
Definition: wdx_defs.h:232
unsigned short uint16_t
Unsigned 16-bit value.
Definition: wsf_types.h:67
#define ATT_DEFAULT_PAYLOAD_LEN
Default maximum payload length for most PDUs.
Definition: att_defs.h:41
WDXS Authentication Control Block.
Definition: wdxs_main.h:138
WDXS Device Configuration Control Block.
Definition: wdxs_main.h:129
uint16_t auMsgLen
message length
Definition: wdxs_main.h:144
uint8_t authState
authentication protocol state
Definition: wdxs_main.h:148
uint16_t dcMsgLen
message length
Definition: wdxs_main.h:131
WDXS profile control block.
Definition: wdxs_main.h:97
uint8_t rxPhy
receiver PHY
Definition: wdxs_main.h:109
Common message structure passed to event handler.
Definition: wsf_os.h:97
wdxsDcPhyWriteCback_t phyWriteCback
Device config PHY write callback.
Definition: wdxs_main.h:134
unsigned char uint8_t
Unsigned 8-bit value.
Definition: wsf_types.h:63
uint16_t ftcMsgLen
message length
Definition: wdxs_main.h:116
#define WDX_AU_KEY_LEN
Authentication Key length (bytes)
Definition: wdx_defs.h:231