Mistake on this page? Email us
att_api.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file
4  *
5  * \brief Attribute protocol client and server API.
6  *
7  * Copyright (c) 2009-2019 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 ATT_API_H
20 #define ATT_API_H
21 
22 #include "wsf_timer.h"
23 #include "att_defs.h"
24 #include "att_uuid.h"
25 #include "dm_api.h"
26 #include "cfg_stack.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 /**************************************************************************************************
33  Macros
34 **************************************************************************************************/
35 /*! \addtogroup STACK_ATTS_API
36  * \{ */
37 /** \name ATT Server Attribute Settings
38  * Settings that may be set on each attribute.
39  */
40 /**@{*/
41 #define ATTS_SET_UUID_128 0x01 /*!< \brief Set if the UUID is 128 bits in length */
42 #define ATTS_SET_WRITE_CBACK 0x02 /*!< \brief Set if the group callback is executed when
43  this attribute is written by a client device */
44 #define ATTS_SET_READ_CBACK 0x04 /*!< \brief Set if the group callback is executed when
45  this attribute is read by a client device */
46 #define ATTS_SET_VARIABLE_LEN 0x08 /*!< \brief Set if the attribute has a variable length */
47 #define ATTS_SET_ALLOW_OFFSET 0x10 /*!< \brief Set if writes are allowed with an offset */
48 #define ATTS_SET_CCC 0x20 /*!< \brief Set if the attribute is a client characteristic
49  configuration descriptor */
50 #define ATTS_SET_ALLOW_SIGNED 0x40 /*!< \brief Set if signed writes are allowed */
51 #define ATTS_SET_REQ_SIGNED 0x80 /*!< \brief Set if signed writes are required if link
52  is not encrypted */
53 /**@}*/
54 
55 /** \name ATT Server Attribute Permissions
56  * Permissions used to describe a attribute's security setting.
57  * These values can be set in any combination.
58  */
59 /**@{*/
60 #define ATTS_PERMIT_READ 0x01 /*!< \brief Set if attribute can be read */
61 #define ATTS_PERMIT_READ_AUTH 0x02 /*!< \brief Set if attribute read requires authentication */
62 #define ATTS_PERMIT_READ_AUTHORIZ 0x04 /*!< \brief Set if attribute read requires authorization */
63 #define ATTS_PERMIT_READ_ENC 0x08 /*!< \brief Set if attribute read requires encryption */
64 #define ATTS_PERMIT_WRITE 0x10 /*!< \brief Set if attribute can be written */
65 #define ATTS_PERMIT_WRITE_AUTH 0x20 /*!< \brief Set if attribute write requires authentication */
66 #define ATTS_PERMIT_WRITE_AUTHORIZ 0x40 /*!< \brief Set if attribute write requires authorization */
67 #define ATTS_PERMIT_WRITE_ENC 0x80 /*!< \brief Set if attribute write requires encryption */
68 /**@}*/
69 /*! \} */ /* STACK_ATTS_API */
70 
71 /*! \addtogroup STACK_ATTC_API
72  * \{ */
73 /** \name ATT Client Discovery and Configuration Settings
74  * Settings used to configurate ATT Discovery procedure for ATT Clients.
75  */
76 /**@{*/
77 #define ATTC_SET_UUID_128 0x01 /*!< \brief Set if the UUID is 128 bits in length */
78 #define ATTC_SET_REQUIRED 0x02 /*!< \brief Set if characteristic must be discovered */
79 #define ATTC_SET_DESCRIPTOR 0x04 /*!< \brief Set if this is a characteristic descriptor */
80 /**@}*/
81 /*! \} */ /* STACK_ATTC_API */
82 
83 /*! \addtogroup STACK_ATT_API
84  * \{ */
85 /** \name ATT Callback Events
86  * Events related to ATT transactions.
87  */
88 /**@{*/
89 #define ATT_CBACK_START 0x02 /*!< \brief ATT callback event starting value */
90 
91 /*! \brief ATT client callback events */
92 enum /*!< \brief Internal note: event values match method values */
93 {
94  ATTC_FIND_INFO_RSP = ATT_CBACK_START, /*!< \brief Find information response */
95  ATTC_FIND_BY_TYPE_VALUE_RSP, /*!< \brief Find by type value response */
96  ATTC_READ_BY_TYPE_RSP, /*!< \brief Read by type value response */
97  ATTC_READ_RSP, /*!< \brief Read response */
98  ATTC_READ_LONG_RSP, /*!< \brief Read long response */
99  ATTC_READ_MULTIPLE_RSP, /*!< \brief Read multiple response */
100  ATTC_READ_BY_GROUP_TYPE_RSP, /*!< \brief Read group type response */
101  ATTC_WRITE_RSP, /*!< \brief Write response */
102  ATTC_WRITE_CMD_RSP, /*!< \brief Write command response */
103  ATTC_PREPARE_WRITE_RSP, /*!< \brief Prepare write response */
104  ATTC_EXECUTE_WRITE_RSP, /*!< \brief Execute write response */
105  ATTC_HANDLE_VALUE_NTF, /*!< \brief Handle value notification */
106  ATTC_HANDLE_VALUE_IND, /*!< \brief Handle value indication */
107  /* ATT server callback events */
108  ATTS_HANDLE_VALUE_CNF, /*!< \brief Handle value confirmation */
109  ATTS_CCC_STATE_IND, /*!< \brief Client chracteristic configuration state change */
110  ATTS_DB_HASH_CALC_CMPL_IND, /*!< \brief Database hash calculation complete */
111  /* ATT common callback events */
112  ATT_MTU_UPDATE_IND /*!< \brief Negotiated MTU value */
113 };
115 /*! \brief ATT callback events */
116 #define ATT_CBACK_END ATT_MTU_UPDATE_IND /*!< \brief ATT callback event ending value */
117 /**@}*/
118 
119 /** \name ATT Client Awareness of Database Change
120  * Status of a client's awareness of a database change.
121  */
122 /**@{*/
123 /*! \brief client's awareness to database change. */
125 {
126  ATTS_CLIENT_CHANGE_AWARE = 0, /*!< Client Aware. */
127  ATTS_CLIENT_CHANGE_PENDING_AWARE, /*!< Client Aware pending ATT Request. For internal stack use only. */
128  ATTS_CLIENT_CHANGE_AWARE_DB_READ_PENDING, /*!< Client Aware, Database Hash read pending hash update completion. For internal stack use only. */
129  ATTS_CLIENT_CHANGE_UNAWARE, /*!< Client Unaware. */
130 };
131 /**@}*/
133 /**************************************************************************************************
134  Data Types
135 **************************************************************************************************/
136 
137 /*! \brief ATT run-time configurable parameters */
138 typedef struct
139 {
140  wsfTimerTicks_t discIdleTimeout; /*!< \brief ATT server service discovery connection idle timeout in seconds */
141  uint16_t mtu; /*!< \brief desired ATT MTU */
142  uint8_t transTimeout; /*!< \brief transcation timeout in seconds */
143  uint8_t numPrepWrites; /*!< \brief number of queued prepare writes supported by server */
146 /*!
147  * \brief ATT callback event
148  *
149  * \param hdr.event Callback event
150  * \param hdr.param DM connection ID
151  * \param hdr.status Event status: ATT_SUCCESS or error status
152  * \param pValue Pointer to value data, valid if valueLen > 0
153  * \param valueLen Length of value data
154  * \param handle Attribute handle
155  * \param continuing TRUE if more response packets expected
156  * \param mtu Negotiated MTU value
157  */
158 typedef struct
159 {
160  wsfMsgHdr_t hdr; /*!< \brief Header structure */
161  uint8_t *pValue; /*!< \brief Value */
162  uint16_t valueLen; /*!< \brief Value length */
163  uint16_t handle; /*!< \brief Attribute handle */
164  bool_t continuing; /*!< \brief TRUE if more response packets expected */
165  uint16_t mtu; /*!< \brief Negotiated MTU value */
168 /*! \brief ATT event callback type.
169  *
170  * This callback function sends ATT events to the client application. A
171  * single callback function is used for both ATTS and ATTC.
172  *
173  * \param pEvt Pointer to ATT event structure.
174  *
175  * \return None.
176  */
177 typedef void (*attCback_t)(attEvt_t *pEvt);
178 /*! \} */ /* STACK_ATT_API */
179 
180 /*! \addtogroup STACK_ATTS_API
181  * \{ */
182 /**
183  * \name Attribute Server Data Types
184  *
185  */
186 /**@{*/
187 /*! \brief Attribute structure */
188 typedef struct
189 {
190  uint8_t const *pUuid; /*!< \brief Pointer to the attribute's UUID */
191  uint8_t *pValue; /*!< \brief Pointer to the attribute's value */
192  uint16_t *pLen; /*!< \brief Pointer to the length of the attribute's value */
193  uint16_t maxLen; /*!< \brief Maximum length of attribute's value */
194  uint8_t settings; /*!< \brief Attribute settings */
195  uint8_t permissions; /*!< \brief Attribute permissions */
198 /*! \brief Client supported features record structure. */
199 typedef struct
200 {
201  uint8_t csf; /*!< Client supported features characteristic value */
202  uint8_t changeAwareState; /*!< Client awareness of GATT database changes */
204 /**@}*/
206 /** \name ATT Server Callbacks
207  *
208  */
209 /**@{*/
210 /*! \brief Attribute group read callback
211  *
212  * This is the attribute server read callback. It is executed on an attribute
213  * read operation if bitmask ATTS_SET_READ_CBACK is set in the settings field
214  * of the attribute structure.
215  * For a read operation, if the operation is successful the function must set
216  * pAttr->pValue to the data to be read. In addition, if the attribute is
217  * variable length then pAttr->pLen must be set as well.
218  *
219  * \param connId DM connection ID.
220  * \param handle Attribute handle.
221  * \param operation Operation type.
222  * \param offset Read data offset.
223  * \param pAttr Pointer to attribute structure.
224  *
225  * \return status of the operation. \ref ATT_SUCCESS if successful.
226  */
227 typedef uint8_t (*attsReadCback_t)(dmConnId_t connId, uint16_t handle, uint8_t operation,
228  uint16_t offset, attsAttr_t *pAttr);
229 
230 /*! \brief Attribute group write callback
231  *
232  * This is the attribute server write callback. It is executed on an
233  * attribute write operation if bitmask ATTS_SET_WRITE_CBACK is set
234  * in the settings field of the attribute structure.
235  *
236  * \param connId DM connection ID.
237  * \param handle Attribute handle.
238  * \param operation Operation type.
239  * \param offset Write data offset.
240  * \param len Length of data to write.
241  * \param pValue Pointer to data to write.
242  * \param pAttr Pointer to attribute structure.
243  *
244  * \return status of operation. \ref ATT_SUCCESS if successful.
245  */
246 typedef uint8_t (*attsWriteCback_t)(dmConnId_t connId, uint16_t handle, uint8_t operation,
247  uint16_t offset, uint16_t len, uint8_t *pValue,
248  attsAttr_t *pAttr);
249 
250 /*! \brief ATTS authorization callback type
251  *
252  * This callback function is executed when a read or write operation occurs
253  * and the security field of an attribute structure is set to
254  * \ref ATTS_PERMIT_READ_AUTHORIZ or \ref ATTS_PERMIT_WRITE_AUTHORIZ respectively.
255  *
256  * \param connId DM Connection ID.
257  * \param permit Set to \ref ATTS_PERMIT_WRITE for a writre operation or
258  * \ref ATTS_PERMIT_READ for a read operation.
259  * \param handle Attribute handle.
260  *
261  * \return status of the operation. \ref ATT_SUCCESS if successful, else if failure
262  * the \ref ATT_ERR_AUTH is typically returned.
263  */
264 typedef uint8_t (*attsAuthorCback_t)(dmConnId_t connId, uint8_t permit, uint16_t handle);
265 
266 /*! \brief ATTS client supported features write callback type
267  *
268  * This callback function is executed when the client supported features record for
269  * this client has been updated.
270  *
271  * \param connId DM Connection ID.
272  * \param changeAwareState The state of awareness to a change, see ::attClientAwareStates.
273  * \param pCsf Pointer to the client supported features value.
274  *
275  * \return None.
276  */
277 typedef void (*attsCsfWriteCback_t)(dmConnId_t connId, uint8_t changeAwareState, uint8_t *pCsf);
278 /**@}*/
279 
280 /**
281  * \name Attribute Server Data Types
282  *
283  */
284 /**@{*/
285 /*! \brief Attribute group */
286 typedef struct attsGroup_tag
287 {
288  struct attsGroup_tag *pNext; /*!< \brief For internal use only */
289  attsAttr_t *pAttr; /*!< \brief Pointer to attribute list for this group */
290  attsReadCback_t readCback; /*!< \brief Read callback function */
291  attsWriteCback_t writeCback; /*!< \brief Write callback function */
292  uint16_t startHandle; /*!< \brief The handle of the first attribute in this group */
293  uint16_t endHandle; /*!< \brief The handle of the last attribute in this group */
296 /*! \brief Client characteristc configuration settings */
297 typedef struct
298 {
299  uint16_t handle; /*!< \brief Client characteristc configuration descriptor handle */
300  uint16_t valueRange; /*!< \brief Acceptable value range of the descriptor value */
301  uint8_t secLevel; /*!< \brief Security level of characteristic value */
302 } attsCccSet_t;
304 /*! \brief ATTS client characteristic configuration callback structure */
305 typedef struct
306 {
307  wsfMsgHdr_t hdr; /*!< \brief Header structure */
308  uint16_t handle; /*!< \brief CCCD handle */
309  uint16_t value; /*!< \brief CCCD value */
310  uint8_t idx; /*!< \brief CCCD settings index */
312 /**@}*/
313 /*! \} */ /* STACK_ATTS_API */
315 /*! \addtogroup STACK_ATTC_API
316  * \{ */
317 /**
318  * \name ATT Client Data Types
319  */
320 /**@{*/
321 /*! \brief ATT client structure for characteristic and descriptor discovery */
322 typedef struct attcDiscChar_tag
323 {
324  uint8_t const *pUuid; /*!< \brief Pointer to UUID */
325  uint8_t settings; /*!< \brief Characteristic discovery settings */
327 
328 /*! \brief ATT client structure for characteristic and descriptor configuration */
329 typedef struct
330 {
331  uint8_t const *pValue; /*!< \brief Pointer to default value or NULL */
332  uint8_t valueLen; /*!< \brief Default value length */
333  uint8_t hdlIdx; /*!< \brief Index of its handle in handle list */
334 } attcDiscCfg_t;
336 /*! \brief ATT client discovery control block */
337 typedef struct
338 {
339  attcDiscChar_t **pCharList; /*!< \brief Characterisic list for discovery */
340  uint16_t *pHdlList; /*!< \brief Characteristic handle list */
341  attcDiscCfg_t *pCfgList; /*!< \brief Characterisic list for configuration */
342  uint8_t charListLen; /*!< \brief Characteristic and handle list length */
343  uint8_t cfgListLen; /*!< \brief Configuration list length */
345  uint16_t svcStartHdl; /*!< \brief Internal use only */
346  uint16_t svcEndHdl; /*!< \brief Internal use only */
347  uint8_t charListIdx; /*!< \brief Internal use only */
348  uint8_t endHdlIdx; /*!< \brief Internal use only */
350 /**@}*/
351 /*! \} */ /* STACK_ATTC_API */
353 /*! \addtogroup STACK_ATTS_API
354  * \{ */
355 /** \name ATT Server Callbacks
356  *
357  */
358 /**@{*/
359 /*! \brief ATTS client characteristic configuration callback
360  *
361  * Client characteristic configuration callback. This function is executed
362  * when a CCCD value changes. This happens when a peer device writes a new
363  * value to the CCCD or when a CCCD table is initialized by calling \ref AttsCccInitTable.
364  *
365  * \param pEvt Pointer to callback structure.
366  *
367  * \return None.
368  */
369 typedef void (*attsCccCback_t)(attsCccEvt_t *pEvt);
370 /**@}*/
371 /*! \} */ /* STACK_ATTS_API */
372 
373 /**************************************************************************************************
374  Global Variables
375 **************************************************************************************************/
376 
377 /*! \addtogroup STACK_INIT
378  * \{ */
379 /** \name ATT Configuration Structure
380  * Pointer to structure containing initialization details of the ATT Subsystem. To be configured
381  * by Application.
382  */
383 /**@{*/
384 /*! \brief Configuration pointer */
385 extern attCfg_t *pAttCfg;
386 /**@}*/
387 /*! \} */ /* STACK_INIT */
388 
389 /**************************************************************************************************
390  Function Declarations
391 **************************************************************************************************/
392 
393 /*! \addtogroup STACK_ATT_API
394  * \{ */
395 /** \name ATT Setup Functions
396  *
397  */
398 /**@{*/
399 /*************************************************************************************************/
400 /*!
401  * \brief Register a callback with ATT. This callback will be used for messages from both ATTC
402  * and ATTS.
403  *
404  * \param cback Client callback function.
405  *
406  * \return None.
407  */
408 /*************************************************************************************************/
409 void AttRegister(attCback_t cback);
410 
411 /*************************************************************************************************/
412 /*!
413  * \brief Register a connection callback with ATT. The callback is typically used to
414  * manage the attribute server database.
415  *
416  * \param cback Client callback function.
417  *
418  * \return None.
419  */
420 /*************************************************************************************************/
421 void AttConnRegister(dmCback_t cback);
422 /**@}*/
423 
424 /** \name ATT Parameter Functions
425  * Functions specific to a connection between 2 devices. Functions may be called by either
426  * Client or server.
427  */
428 /**@{*/
429 /*************************************************************************************************/
430 /*!
431  * \brief Get the attribute protocol MTU of a connection.
432  *
433  * \param connId DM connection ID.
434  *
435  * \return MTU of the connection.
436  */
437 /*************************************************************************************************/
438 uint16_t AttGetMtu(dmConnId_t connId);
439 /**@}*/
440 
441 /** \name ATT Message Passing Functions
442  *
443  */
444 /**@{*/
445 /*************************************************************************************************/
446 /*!
447  * \brief Allocate an ATT message buffer to be sent with the ATT attribute protocol
448  * zero-copy APIs.
449  *
450  * \param len Message length in bytes.
451  * \param opcode Opcode for ATT message.
452  *
453  * \return Pointer to message buffer or NULL if allocation failed.
454  */
455 /*************************************************************************************************/
456 void *AttMsgAlloc(uint16_t len, uint8_t opcode);
457 
458 /*************************************************************************************************/
459 /*!
460  * \brief Free an ATT message buffer allocated with AttMsgAlloc().
461  *
462  * \param pMsg Pointer to message buffer.
463  * \param opcode Opcode for ATT message.
464  *
465  * \return None.
466  */
467 /*************************************************************************************************/
468 void AttMsgFree(void *pMsg, uint8_t opcode);
469 /**@}*/
470 /*! \} */ /* STACK_ATT_API */
471 
472 /*! \addtogroup STACK_ATTS_API
473  * \{ */
474 /** \name ATT Server Functions
475  *
476  */
477 /**@{*/
478 /*************************************************************************************************/
479 /*!
480  * \brief Initialize ATT server.
481  *
482  * \return None.
483  */
484 /*************************************************************************************************/
485 void AttsInit(void);
486 
487 /*************************************************************************************************/
488 /*!
489  * \brief Initialize ATT server for indications/notifications.
490  *
491  * \return None.
492  */
493 /*************************************************************************************************/
494 void AttsIndInit(void);
495 
496 /*************************************************************************************************/
497 /*!
498  * \brief Initialize ATT server for data signing.
499  *
500  * \return None.
501  */
502 /*************************************************************************************************/
503 void AttsSignInit(void);
504 
505 /*************************************************************************************************/
506 /*!
507  * \brief Register an authorization callback with the attribute server.
508  *
509  * \param cback Client callback function.
510  *
511  * \return None.
512  */
513 /*************************************************************************************************/
515 
516 /*************************************************************************************************/
517 /*!
518  * \brief Add an attribute group to the attribute server.
519  *
520  * \param pGroup Pointer to an attribute group structure.
521  *
522  * \return None.
523  */
524 /*************************************************************************************************/
525 void AttsAddGroup(attsGroup_t *pGroup);
526 
527 /*************************************************************************************************/
528 /*!
529  * \brief Remove an attribute group from the attribute server.
530  *
531  * \param startHandle Start handle of attribute group to be removed.
532  *
533  * \return None.
534  */
535 /*************************************************************************************************/
536 void AttsRemoveGroup(uint16_t startHandle);
537 
538 /*************************************************************************************************/
539 /*!
540 * \brief Calculate database hash from the GATT database.
541 *
542 * \return None.
543 */
544 /*************************************************************************************************/
545 void AttsCalculateDbHash(void);
546 
547 /*************************************************************************************************/
548 /*!
549  * \brief Create hash from the database string.
550  *
551  * \param pKey Key for hashing.
552  * \param pMsg Plaintext to hash.
553  * \param msgLen Length of Plaintext data.
554  *
555  * \return \ref TRUE if successful, \ref FALSE if not.
556  */
557 /*************************************************************************************************/
558 bool_t AttsHashDatabaseString(uint8_t *pKey, uint8_t *pMsg, uint16_t msgLen);
559 
560 /*************************************************************************************************/
561 /*!
562  * \brief Set an attribute value in the attribute server.
563  *
564  * \param handle Attribute handle.
565  * \param valueLen Attribute length.
566  * \param pValue Attribute value.
567  *
568  * \return ATT_SUCCESS if successful otherwise error.
569  */
570 /*************************************************************************************************/
571 uint8_t AttsSetAttr(uint16_t handle, uint16_t valueLen, uint8_t *pValue);
572 
573 /*************************************************************************************************/
574 /*!
575  * \brief Get an attribute value in the attribute server.
576  *
577  * \param handle Attribute handle.
578  * \param pLen Returned attribute length pointer.
579  * \param pValue Returned attribute value pointer.
580  *
581  * \return ATT_SUCCESS if successful otherwise error.
582  * \return This function returns the attribute length in pLen and a pointer to the attribute
583  * value in pValue.
584  */
585 /*************************************************************************************************/
586 uint8_t AttsGetAttr(uint16_t handle, uint16_t *pLen, uint8_t **pValue);
587 
588 /*************************************************************************************************/
589 /*!
590  * \brief Send an attribute protocol Handle Value Indication.
591  *
592  * \param connId DM connection ID.
593  * \param handle Attribute handle.
594  * \param valueLen Length of value data.
595  * \param pValue Pointer to value data.
596  *
597  * \return None.
598  */
599 /*************************************************************************************************/
600 void AttsHandleValueInd(dmConnId_t connId, uint16_t handle, uint16_t valueLen, uint8_t *pValue);
601 
602 /*************************************************************************************************/
603 /*!
604  * \brief Send an attribute protocol Handle Value Notification.
605  *
606  * \param connId DM connection ID.
607  * \param handle Attribute handle.
608  * \param valueLen Length of value data.
609  * \param pValue Pointer to value data.
610  *
611  * \return None.
612  */
613 /*************************************************************************************************/
614 void AttsHandleValueNtf(dmConnId_t connId, uint16_t handle, uint16_t valueLen, uint8_t *pValue);
615 
616 /*************************************************************************************************/
617 /*!
618  * \brief Send an attribute protocol Handle Value Indication without copying the attribute
619  * value data.
620  *
621  * Note: attribute value buffer 'pValue' must be allocated with AttMsgAlloc().
622  *
623  * \param connId DM connection ID.
624  * \param handle Attribute handle.
625  * \param valueLen Length of value data.
626  * \param pValue Pointer to value data.
627  *
628  * \return None.
629  */
630 /*************************************************************************************************/
631 void AttsHandleValueIndZeroCpy(dmConnId_t connId, uint16_t handle, uint16_t valueLen,
632  uint8_t *pValue);
633 
634 /*************************************************************************************************/
635 /*!
636  * \brief Send an attribute protocol Handle Value Notification without copying the attribute
637  * value data.
638  *
639  * Note: attribute value buffer 'pValue' must be allocated with AttMsgAlloc().
640  *
641  * \param connId DM connection ID.
642  * \param handle Attribute handle.
643  * \param valueLen Length of value data.
644  * \param pValue Pointer to value data.
645  *
646  * \return None.
647  */
648 /*************************************************************************************************/
649 void AttsHandleValueNtfZeroCpy(dmConnId_t connId, uint16_t handle, uint16_t valueLen,
650  uint8_t *pValue);
651 
652 /*************************************************************************************************/
653 /*!
654  * \brief Register the utility service for managing client characteristic
655  * configuration descriptors. This function is typically called once on
656  * system initialization.
657  *
658  * \param setLen Length of settings array.
659  * \param pSet Array of CCC descriptor settings.
660  * \param cback Client callback function.
661  *
662  * \return None.
663  */
664 /*************************************************************************************************/
665 void AttsCccRegister(uint8_t setLen, attsCccSet_t *pSet, attsCccCback_t cback);
666 
667 /*************************************************************************************************/
668 /*!
669  * \brief Initialize the client characteristic configuration descriptor value table for a
670  * connection. The table is initialized with the values from pCccTbl. If pCccTbl
671  * is NULL the table will be initialized to zero.
672  *
673  * This function must be called when a connection is established or when a
674  * device is bonded.
675  *
676  * \param connId DM connection ID.
677  * \param pCccTbl Pointer to the descriptor value array. The length of the array
678  * must equal the value of setLen passed to AttsCccRegister().
679  *
680  * \return None.
681  */
682 /*************************************************************************************************/
683 void AttsCccInitTable(dmConnId_t connId, uint16_t *pCccTbl);
684 
685 /*************************************************************************************************/
686 /*!
687  * \brief Clear and deallocate the client characteristic configuration descriptor value
688  * table for a connection. This function must be called when a connection is closed.
689  *
690  * \param connId DM connection ID.
691  *
692  * \return None.
693  */
694 /*************************************************************************************************/
695 void AttsCccClearTable(dmConnId_t connId);
696 
697 /*************************************************************************************************/
698 /*!
699  * \brief Get the value of a client characteristic configuration descriptor by its index.
700  * If not found, return zero.
701  *
702  * \param connId DM connection ID.
703  * \param idx Index of descriptor in CCC descriptor handle table.
704  *
705  * \return Value of the descriptor.
706  */
707 /*************************************************************************************************/
708 uint16_t AttsCccGet(dmConnId_t connId, uint8_t idx);
709 
710 /*************************************************************************************************/
711 /*!
712  * \brief Set the value of a client characteristic configuration descriptor by its index.
713  *
714  * \param connId DM connection ID.
715  * \param idx Index of descriptor in CCC descriptor handle table.
716  * \param value Value of the descriptor.
717  *
718  * \return None.
719  */
720 /*************************************************************************************************/
721 void AttsCccSet(dmConnId_t connId, uint8_t idx, uint16_t value);
722 
723 /*************************************************************************************************/
724 /*!
725  * \brief Check if a client characteristic configuration descriptor is enabled and if
726  * the characteristic's security level has been met.
727  *
728  * \param connId DM connection ID.
729  * \param idx Index of descriptor in CCC descriptor handle table.
730  *
731  * \return Value of the descriptor if security level is met, otherwise zero.
732  */
733 /*************************************************************************************************/
734 uint16_t AttsCccEnabled(dmConnId_t connId, uint8_t idx);
735 
736 /*************************************************************************************************/
737 /*!
738  * \brief Get number of CCC entries in table.
739  *
740  * \return Number of CCC entries in table.
741  */
742 /*************************************************************************************************/
743 uint8_t AttsGetCccTableLen(void);
744 
745 /*************************************************************************************************/
746 /*!
747  * \brief Send a response to a pending write request. For use with ATT_RSP_PENDING.
748  *
749  * \param connId Connection ID.
750  * \param handle Attribute handle.
751  * \param status Status of the write request.
752  *
753  * \return None.
754  *
755  * \note When a higher layer returns ATT_RSP_PENDING to an ATT write callback indicating the
756  * response status is pending, the higher layer must subsequently call this function
757  * with the status of the write request.
758  */
759 /*************************************************************************************************/
760 void AttsContinueWriteReq(dmConnId_t connId, uint16_t handle, uint8_t status);
761 
762 /*************************************************************************************************/
763 /*!
764  * \brief Set the peer's data signing key on this connection. This function
765  * is typically called from the ATT connection callback when the connection is
766  * established. The caller is responsible for maintaining the memory that
767  * contains the key.
768  *
769  * \param connId DM connection ID.
770  * \param pCsrk Pointer to data signing key (CSRK).
771  *
772  * \return None.
773  */
774 /*************************************************************************************************/
775 void AttsSetCsrk(dmConnId_t connId, uint8_t *pCsrk);
776 
777 /*************************************************************************************************/
778 /*!
779  * \brief Set the peer's sign counter on this connection. This function
780  * is typically called from the ATT connection callback when the connection is
781  * established. ATT maintains the value of the sign counter internally and
782  * sets the value when a signed packet is successfully received.
783  *
784  * \param connId DM connection ID.
785  * \param signCounter Sign counter.
786  *
787  * \return None.
788  */
789 /*************************************************************************************************/
790 void AttsSetSignCounter(dmConnId_t connId, uint32_t signCounter);
791 
792 /*************************************************************************************************/
793 /*!
794  * \brief Get the current value peer's sign counter on this connection. This function
795  * is typically called from the ATT connection callback when the connection is
796  * closed so the application can store the sign counter for use on future
797  * connections.
798  *
799  * \param connId DM connection ID.
800  *
801  * \return Sign counter.
802  */
803 /*************************************************************************************************/
804 uint32_t AttsGetSignCounter(dmConnId_t connId);
805 
806 /*************************************************************************************************/
807 /*!
808  * \brief Initialize ATTS client supported features module.
809  *
810  * \return None.
811  */
812 /*************************************************************************************************/
813 void AttsCsfInit(void);
814 
815 /*************************************************************************************************/
816 /*!
817  * \brief Initialize the client supported features for a connection.
818  *
819  * \param connId DM connection ID.
820  * \param changeAwareState The state of awareness to a change in the database.
821  * \param pCsf Pointer to the client supported features value to cache. \ref NULL or
822  * buffer of length \ref ATT_CSF_LEN.
823  *
824  * \return None.
825  */
826 /*************************************************************************************************/
827 void AttsCsfConnOpen(dmConnId_t connId, uint8_t changeAwareState, uint8_t *pCsf);
828 
829 /*************************************************************************************************/
830 /*!
831  * \brief GATT write of client supported feature characteristic value.
832  *
833  * \param connId DM connection ID.
834  * \param offset offset into csf characteristic.
835  * \param valueLen length of write in bytes.
836  * \param pValue Pointer to client's supported features characteristic value.
837  *
838  * \return \ref ATT_SUCCESS is successful, \ref ATT_ERR_VALUE_NOT_ALLOWED if any supported
839  * features are flipped from 1 to 0.
840  */
841 /*************************************************************************************************/
842 uint8_t AttsCsfWriteFeatures(dmConnId_t connId, uint16_t offset, uint16_t valueLen,
843  uint8_t *pValue);
844 
845 /*************************************************************************************************/
846 /*!
847  * \brief Get client supported feature record.
848  *
849  * \param connId DM connection ID.
850  * \param pCsfOut Output parameter for client supported features buffer.
851  * \param pCsfOutLen Length of output parameter buffer.
852  *
853  * \return None.
854  */
855 /*************************************************************************************************/
856 void AttsCsfGetFeatures(dmConnId_t connId, uint8_t *pCsfOut, uint8_t pCsfOutLen);
857 
858 /*************************************************************************************************/
859 /*!
860  * \brief Get client state of awareness to a change in the database.
861  *
862  * \param connId DM connection ID.
863  *
864  * \return Client's change-aware state.
865  */
866 /*************************************************************************************************/
867 uint8_t AttsCsfGetChangeAwareState(dmConnId_t connId);
868 
869 /*************************************************************************************************/
870 /*!
871  * \brief Update a client's state of awareness to a change in the database.
872  *
873  * \param connId DM connection ID. if \ref DM_CONN_ID_NONE, sets the state for all connected
874  * clients.
875  * \param state The state of awareness to a change, see \ref attClientAwareStates.
876  *
877  * \return None.
878  *
879  * \note A callback to application is not needed as it is expected the caller (i.e. the
880  * application) will have updated all persistent records prior to calling this function.
881  */
882 /*************************************************************************************************/
883 void AttsCsfSetClientsChangeAwarenessState(dmConnId_t connId, uint8_t state);
884 
885 /*************************************************************************************************/
886 /*!
887  * \brief Register callback.
888  *
889  * \param writeCback Application callback for when client supported features record is updated.
890  *
891  * \return None.
892  */
893 /*************************************************************************************************/
894 void AttsCsfRegister(attsCsfWriteCback_t writeCback);
895 /**@}*/
896 
897 /** \name ATT Server Dynamic Service Subsystem Functions
898  *
899  */
900 /**@{*/
901 /*************************************************************************************************/
902 /*!
903  * \brief Initialize the Dynamic ATT Service subsystem.
904  *
905  * \return None.
906  */
907 /*************************************************************************************************/
908 void AttsDynInit(void);
909 
910 /*************************************************************************************************/
911 /*!
912  * \brief Dynamically create an ATT Service at runtime.
913  *
914  * \param startHandle Starting attribute handle in the service
915  * \param endHandle Last attribute handle in the service
916  *
917  * \return Service Handle.
918  */
919 /*************************************************************************************************/
920 void *AttsDynCreateGroup(uint16_t startHandle, uint16_t endHandle);
921 
922 /*************************************************************************************************/
923 /*!
924  * \brief Dynamically delete an ATT Service at runtime.
925  *
926  * \param pSvcHandle Service handle returned by \ref AttsDynCreateGroup
927  *
928  * \return None.
929  */
930 /*************************************************************************************************/
931 void AttsDynDeleteGroup(void *pSvcHandle);
932 
933 /*************************************************************************************************/
934 /*!
935  * \brief Register callback functions for a dynamic ATT Service at runtime.
936  *
937  * \param pSvcHandle Service handle returned by \ref AttsDynCreateGroup
938  * \param readCback Read callback function
939  * \param writeCback Write callback function
940  *
941  * \return None.
942  */
943 /*************************************************************************************************/
944 void AttsDynRegister(void *pSvcHandle, attsReadCback_t readCback, attsWriteCback_t writeCback);
945 
946 /*************************************************************************************************/
947 /*!
948  * \brief Dynamically add an attribute to a dynamic ATT Services at runtime.
949  *
950  * \param pSvcHandle Service handle returned by \ref AttsDynCreateGroup
951  * \param pUuid Constant UUID
952  * \param pValue Initial value of attribute (copied into attribute memory)
953  * \param len Length of pValue in bytes
954  * \param maxLen Maximum length of the attribute in bytes
955  * \param settings Attribute settings
956  * \param permissions Attribute permissions
957  *
958  * \return None.
959  */
960 /*************************************************************************************************/
961 void AttsDynAddAttr(void *pSvcHandle, const uint8_t *pUuid, const uint8_t *pValue, uint16_t len,
962  const uint16_t maxLen, uint8_t settings, uint8_t permissions);
963 
964 /*************************************************************************************************/
965 /*!
966  * \brief Dynamically add an attribute with a constant value to a dynamic ATT Services at runtime.
967  *
968  * \param pSvcHandle Service handle returned by \ref AttsDynCreateGroup
969  * \param pUuid Constant UUID
970  * \param pValue Pointer to constant attribute memory
971  * \param len Length of pValue in bytes
972  * \param settings Attribute settings
973  * \param permissions Attribute permissions
974  *
975  * \return None.
976  */
977 /*************************************************************************************************/
978 void AttsDynAddAttrConst(void *pSvcHandle, const uint8_t *pUuid, const uint8_t *pValue,
979  const uint16_t len, uint8_t settings, uint8_t permissions);
980 /**@}*/
981 
982 /** \name ATT Server Testing
983  *
984  */
985 /**@{*/
986 /*************************************************************************************************/
987 /*!
988  * \brief For testing purposes only.
989  *
990  * \param status ATT status
991  *
992  * \return None.
993  */
994 /*************************************************************************************************/
995 void AttsErrorTest(uint8_t status);
996 /**@}*/
997 /*! \} */ /* STACK_ATTS_API */
998 
999 /*! \addtogroup STACK_ATTC_API
1000  * \{ */
1001 /** \name ATT Client Functions
1002  *
1003  */
1004 /**@{*/
1005 /*************************************************************************************************/
1006 /*!
1007  * \brief Initialize ATT client.
1008  *
1009  * \return None.
1010  */
1011 /*************************************************************************************************/
1012 void AttcInit(void);
1013 
1014 /*************************************************************************************************/
1015 /*!
1016  * \brief Initialize ATT client for data signing.
1017  *
1018  * \return None.
1019  */
1020 /*************************************************************************************************/
1021 void AttcSignInit(void);
1022 
1023 /*************************************************************************************************/
1024 /*!
1025  * \brief Initiate an attribute protocol Find Information Request.
1026  *
1027  * \param connId DM connection ID.
1028  * \param startHandle Attribute start handle.
1029  * \param endHandle Attribute end handle.
1030  * \param continuing TRUE if ATTC continues sending requests until complete.
1031  *
1032  * \return None.
1033  */
1034 /*************************************************************************************************/
1035 void AttcFindInfoReq(dmConnId_t connId, uint16_t startHandle, uint16_t endHandle, bool_t continuing);
1036 
1037 /*************************************************************************************************/
1038 /*!
1039  * \brief Initiate an attribute protocol Find By Type Value Request.
1040  *
1041  * \param connId DM connection ID.
1042  * \param startHandle Attribute start handle.
1043  * \param endHandle Attribute end handle.
1044  * \param uuid16 16-bit UUID to find.
1045  * \param valueLen Length of value data.
1046  * \param pValue Pointer to value data.
1047  * \param continuing TRUE if ATTC continues sending requests until complete.
1048  *
1049  * \return None.
1050  */
1051 /*************************************************************************************************/
1052 void AttcFindByTypeValueReq(dmConnId_t connId, uint16_t startHandle, uint16_t endHandle,
1053  uint16_t uuid16, uint16_t valueLen, uint8_t *pValue, bool_t continuing);
1054 
1055 /*************************************************************************************************/
1056 /*!
1057  * \brief Initiate an attribute protocol Read By Type Request.
1058  *
1059  * \param connId DM connection ID.
1060  * \param startHandle Attribute start handle.
1061  * \param endHandle Attribute end handle.
1062  * \param uuidLen Length of UUID (2 or 16).
1063  * \param pUuid Pointer to UUID data.
1064  * \param continuing TRUE if ATTC continues sending requests until complete.
1065  *
1066  * \return None.
1067  */
1068 /*************************************************************************************************/
1069 void AttcReadByTypeReq(dmConnId_t connId, uint16_t startHandle, uint16_t endHandle,
1070  uint8_t uuidLen, uint8_t *pUuid, bool_t continuing);
1071 
1072 /*************************************************************************************************/
1073 /*!
1074  * \brief Initiate an attribute protocol Read Request.
1075  *
1076  * \param connId DM connection ID.
1077  * \param handle Attribute handle.
1078  *
1079  * \return None.
1080  */
1081 /*************************************************************************************************/
1082 void AttcReadReq(dmConnId_t connId, uint16_t handle);
1083 
1084 /*************************************************************************************************/
1085 /*!
1086  * \brief Initiate an attribute protocol Read Long Request.
1087  *
1088  * \param connId DM connection ID.
1089  * \param handle Attribute handle.
1090  * \param offset Read attribute data starting at this offset.
1091  * \param continuing TRUE if ATTC continues sending requests until complete.
1092  *
1093  * \return None.
1094  */
1095 /*************************************************************************************************/
1096 void AttcReadLongReq(dmConnId_t connId, uint16_t handle, uint16_t offset, bool_t continuing);
1097 
1098 /*************************************************************************************************/
1099 /*!
1100  * \brief Initiate an attribute protocol Read Multiple Request.
1101  *
1102  * \param connId DM connection ID.
1103  * \param numHandles Number of handles in attribute handle list.
1104  * \param pHandles List of attribute handles.
1105  *
1106  * \return None.
1107  */
1108 /*************************************************************************************************/
1109 void AttcReadMultipleReq(dmConnId_t connId, uint8_t numHandles, uint16_t *pHandles);
1110 
1111 /*************************************************************************************************/
1112 /*!
1113  * \brief Initiate an attribute protocol Read By Group Type Request.
1114  *
1115  * \param connId DM connection ID.
1116  * \param startHandle Attribute start handle.
1117  * \param endHandle Attribute end handle.
1118  * \param uuidLen Length of UUID (2 or 16).
1119  * \param pUuid Pointer to UUID data.
1120  * \param continuing TRUE if ATTC continues sending requests until complete.
1121  *
1122  * \return None.
1123  */
1124 /*************************************************************************************************/
1125 void AttcReadByGroupTypeReq(dmConnId_t connId, uint16_t startHandle, uint16_t endHandle,
1126  uint8_t uuidLen, uint8_t *pUuid, bool_t continuing);
1127 
1128 /*************************************************************************************************/
1129 /*!
1130  * \brief Initiate an attribute protocol Write Request.
1131  *
1132  * \param connId DM connection ID.
1133  * \param handle Attribute handle.
1134  * \param valueLen Length of value data.
1135  * \param pValue Pointer to value data.
1136  *
1137  * \return None.
1138  */
1139 /*************************************************************************************************/
1140 void AttcWriteReq(dmConnId_t connId, uint16_t handle, uint16_t valueLen, uint8_t *pValue);
1141 
1142 /*************************************************************************************************/
1143 /*!
1144  * \brief Initiate an attribute protocol Write Command.
1145  *
1146  * \param connId DM connection ID.
1147  * \param handle Attribute handle.
1148  * \param valueLen Length of value data.
1149  * \param pValue Pointer to value data.
1150  *
1151  * \return None.
1152  */
1153 /*************************************************************************************************/
1154 void AttcWriteCmd(dmConnId_t connId, uint16_t handle, uint16_t valueLen, uint8_t *pValue);
1155 
1156 /*************************************************************************************************/
1157 /*!
1158  * \brief Initiate an attribute protocol signed Write Command.
1159  *
1160  * \param connId DM connection ID.
1161  * \param handle Attribute handle.
1162  * \param signCounter Value of the sign counter.
1163  * \param valueLen Length of value data.
1164  * \param pValue Pointer to value data.
1165  *
1166  * \return None.
1167  */
1168 /*************************************************************************************************/
1169 void AttcSignedWriteCmd(dmConnId_t connId, uint16_t handle, uint32_t signCounter,
1170  uint16_t valueLen, uint8_t *pValue);
1171 
1172 /*************************************************************************************************/
1173 /*!
1174  * \brief Initiate an attribute protocol Prepare Write Request.
1175  *
1176  * \param connId DM connection ID.
1177  * \param handle Attribute handle.
1178  * \param offset Write attribute data starting at this offset.
1179  * \param valueLen Length of value data.
1180  * \param pValue Pointer to value data.
1181  * \param valueByRef TRUE if pValue data is accessed by reference rather than copied.
1182  * \param continuing TRUE if ATTC continues sending requests until complete.
1183  *
1184  * \return None.
1185  */
1186 /*************************************************************************************************/
1187 void AttcPrepareWriteReq(dmConnId_t connId, uint16_t handle, uint16_t offset, uint16_t valueLen,
1188  uint8_t *pValue, bool_t valueByRef, bool_t continuing);
1189 
1190 /*************************************************************************************************/
1191 /*!
1192  * \brief Initiate an attribute protocol Execute Write Request.
1193  *
1194  * \param connId DM connection ID.
1195  * \param writeAll TRUE to write all queued writes, FALSE to cancel all queued writes.
1196  *
1197  * \return None.
1198  */
1199 /*************************************************************************************************/
1200 void AttcExecuteWriteReq(dmConnId_t connId, bool_t writeAll);
1201 
1202 /*************************************************************************************************/
1203 /*!
1204  * \brief Cancel an attribute protocol request in progress.
1205  *
1206  * \param connId DM connection ID.
1207  *
1208  * \return None.
1209  */
1210 /*************************************************************************************************/
1211 void AttcCancelReq(dmConnId_t connId);
1212 
1213 /*************************************************************************************************/
1214 /*!
1215  * \brief This utility function discovers the given service on a peer device. Function
1216  * AttcFindByTypeValueReq() is called to initiate the discovery procedure.
1217  *
1218  * \param connId DM connection ID.
1219  * \param pCb Pointer to discovery control block.
1220  * \param uuidLen Length of service UUID (2 or 16).
1221  * \param pUuid Pointer to service UUID.
1222  *
1223  * \return None.
1224  */
1225 /*************************************************************************************************/
1226 void AttcDiscService(dmConnId_t connId, attcDiscCb_t *pCb, uint8_t uuidLen, uint8_t *pUuid);
1227 
1228 /*************************************************************************************************/
1229 /*!
1230  * \brief This utility function processes a service discovery result. It should be called
1231  * when an \ref ATTC_FIND_BY_TYPE_VALUE_RSP callback event is received after service
1232  * discovery is initiated by calling AttcDiscService().
1233  *
1234  * \param pCb Pointer to discovery control block.
1235  * \param pMsg ATT callback event message.
1236  *
1237  * \return ATT_SUCCESS if successful otherwise error.
1238  */
1239 /*************************************************************************************************/
1240 uint8_t AttcDiscServiceCmpl(attcDiscCb_t *pCb, attEvt_t *pMsg);
1241 
1242 /*************************************************************************************************/
1243 /*!
1244  * \brief This utility function starts characteristic and characteristic descriptor
1245  * discovery for a service on a peer device. The service must have been previously
1246  * discovered by calling AttcDiscService() and AttcDiscServiceCmpl().
1247  *
1248  * \param connId DM connection ID.
1249  * \param pCb Pointer to discovery control block.
1250  *
1251  * \return None.
1252  */
1253 /*************************************************************************************************/
1254 void AttcDiscCharStart(dmConnId_t connId, attcDiscCb_t *pCb);
1255 
1256 /*************************************************************************************************/
1257 /*!
1258  * \brief This utility function processes a characteristic discovery result. It should be
1259  * called when an \ref ATTC_READ_BY_TYPE_RSP or \ref ATTC_FIND_INFO_RSP callback event is
1260  * received after characteristic discovery is initiated by calling AttcDiscCharStart().
1261  *
1262  * \param pCb Pointer to discovery control block.
1263  * \param pMsg ATT callback event message.
1264  *
1265  * \return ATT_CONTINUING if successful and the discovery procedure is continuing.
1266  * ATT_SUCCESS if the discovery procedure completed successfully.
1267  * Otherwise the discovery procedure failed.
1268  */
1269 /*************************************************************************************************/
1270 uint8_t AttcDiscCharCmpl(attcDiscCb_t *pCb, attEvt_t *pMsg);
1271 
1272 /*************************************************************************************************/
1273 /*!
1274  * \brief This utility function starts characteristic configuration for characteristics on a
1275  * peer device. The characteristics must have been previously discovered by calling
1276  * AttcDiscCharStart() and AttcDiscCharCmpl().
1277  *
1278  * \param connId DM connection ID.
1279  * \param pCb Pointer to discovery control block.
1280  *
1281  * \return ATT_CONTINUING if successful and configuration procedure is continuing.
1282  * ATT_SUCCESS if nothing to configure.
1283  */
1284 /*************************************************************************************************/
1285 uint8_t AttcDiscConfigStart(dmConnId_t connId, attcDiscCb_t *pCb);
1286 
1287 /*************************************************************************************************/
1288 /*!
1289  * \brief This utility function initiates the next characteristic configuration procedure.
1290  * It should be called when an \ref ATTC_READ_RSP or \ref ATTC_WRITE_RSP callback event
1291  * is received after characteristic configuration is initiated by calling
1292  * AttcDiscConfigStart().
1293  *
1294  * \param connId DM connection ID.
1295  * \param pCb Pointer to discovery control block.
1296  *
1297  * \return ATT_CONTINUING if successful and configuration procedure is continuing.
1298  * ATT_SUCCESS if configuration procedure completed successfully.
1299  */
1300 /*************************************************************************************************/
1301 uint8_t AttcDiscConfigCmpl(dmConnId_t connId, attcDiscCb_t *pCb);
1302 
1303 /*************************************************************************************************/
1304 /*!
1305  * \brief This utility function resumes the characteristic configuration procedure. It can
1306  * be called when an \ref ATTC_READ_RSP or \ref ATTC_WRITE_RSP callback event is received
1307  * with failure status to attempt the read or write procedure again.
1308  *
1309  * \param connId DM connection ID.
1310  * \param pCb Pointer to discovery control block.
1311  *
1312  * \return ATT_CONTINUING if successful and configuration procedure is continuing.
1313  * ATT_SUCCESS if configuration procedure completed successfully.
1314  */
1315 /*************************************************************************************************/
1316 uint8_t AttcDiscConfigResume(dmConnId_t connId, attcDiscCb_t *pCb);
1317 
1318 /*************************************************************************************************/
1319 /*!
1320  * \brief For internal use only.
1321  *
1322  * \param connId DM connection ID.
1323  * \param mtu Attribute protocol MTU.
1324  *
1325  * \return None.
1326  */
1327 /*************************************************************************************************/
1328 void AttcMtuReq(dmConnId_t connId, uint16_t mtu);
1329 
1330 /*************************************************************************************************/
1331 /*!
1332  * \brief Set automatic Indication Confirmations sent from this ATT Client.
1333  *
1334  * \param enable \ref TRUE to enable automatic confirmations (default), \ref FALSE to disable.
1335  *
1336  * \return None.
1337  */
1338 /*************************************************************************************************/
1339 void AttcSetAutoConfirm(bool_t enable);
1340 
1341 /*************************************************************************************************/
1342 /*!
1343  * \brief Send an attribute protocol indication confirmation.
1344  *
1345  * \param connId DM connection ID.
1346  *
1347  * \return None.
1348  */
1349 /*************************************************************************************************/
1350 void AttcIndConfirm(dmConnId_t connId);
1351 /**@}*/
1352 /*! \} */ /* STACK_ATTC_API */
1353 
1354 
1355 #ifdef __cplusplus
1356 };
1357 #endif
1358 
1359 #endif /* ATT_API_H */
uint16_t AttsCccGet(dmConnId_t connId, uint8_t idx)
Get the value of a client characteristic configuration descriptor by its index. If not found...
#define ATT_CBACK_START
ATT callback event starting value.
Definition: att_api.h:93
void AttcReadLongReq(dmConnId_t connId, uint16_t handle, uint16_t offset, bool_t continuing)
Initiate an attribute protocol Read Long Request.
void AttcReadMultipleReq(dmConnId_t connId, uint8_t numHandles, uint16_t *pHandles)
Initiate an attribute protocol Read Multiple Request.
uint8_t dmConnId_t
Connection identifier.
Definition: dm_api.h:521
Read group type response.
Definition: att_api.h:104
uint8_t AttsCsfGetChangeAwareState(dmConnId_t connId)
Get client state of awareness to a change in the database.
void AttsContinueWriteReq(dmConnId_t connId, uint16_t handle, uint8_t status)
Send a response to a pending write request. For use with ATT_RSP_PENDING.
ATT callback event.
Definition: att_api.h:162
void AttsDynDeleteGroup(void *pSvcHandle)
Dynamically delete an ATT Service at runtime.
uint8_t AttsCsfWriteFeatures(dmConnId_t connId, uint16_t offset, uint16_t valueLen, uint8_t *pValue)
GATT write of client supported feature characteristic value.
void AttsCsfGetFeatures(dmConnId_t connId, uint8_t *pCsfOut, uint8_t pCsfOutLen)
Get client supported feature record.
void AttcReadByGroupTypeReq(dmConnId_t connId, uint16_t startHandle, uint16_t endHandle, uint8_t uuidLen, uint8_t *pUuid, bool_t continuing)
Initiate an attribute protocol Read By Group Type Request.
uint8_t AttcDiscServiceCmpl(attcDiscCb_t *pCb, attEvt_t *pMsg)
This utility function processes a service discovery result. It should be called when an ATTC_FIND_BY_...
void AttcDiscCharStart(dmConnId_t connId, attcDiscCb_t *pCb)
This utility function starts characteristic and characteristic descriptor discovery for a service on ...
void AttsRemoveGroup(uint16_t startHandle)
Remove an attribute group from the attribute server.
uint32_t AttsGetSignCounter(dmConnId_t connId)
Get the current value peer&#39;s sign counter on this connection. This function is typically called from ...
void AttsAuthorRegister(attsAuthorCback_t cback)
Register an authorization callback with the attribute server.
void AttRegister(attCback_t cback)
Register a callback with ATT. This callback will be used for messages from both ATTC and ATTS...
void AttsSetSignCounter(dmConnId_t connId, uint32_t signCounter)
Set the peer&#39;s sign counter on this connection. This function is typically called from the ATT connec...
uint8_t(* attsWriteCback_t)(dmConnId_t connId, uint16_t handle, uint8_t operation, uint16_t offset, uint16_t len, uint8_t *pValue, attsAttr_t *pAttr)
Attribute group write callback.
Definition: att_api.h:250
void AttsCccRegister(uint8_t setLen, attsCccSet_t *pSet, attsCccCback_t cback)
Register the utility service for managing client characteristic configuration descriptors. This function is typically called once on system initialization.
uint8_t AttcDiscConfigStart(dmConnId_t connId, attcDiscCb_t *pCb)
This utility function starts characteristic configuration for characteristics on a peer device...
void AttsDynAddAttr(void *pSvcHandle, const uint8_t *pUuid, const uint8_t *pValue, uint16_t len, const uint16_t maxLen, uint8_t settings, uint8_t permissions)
Dynamically add an attribute to a dynamic ATT Services at runtime.
ATT client structure for characteristic and descriptor discovery.
Definition: att_api.h:326
void AttsCsfRegister(attsCsfWriteCback_t writeCback)
Register callback.
void AttcSignedWriteCmd(dmConnId_t connId, uint16_t handle, uint32_t signCounter, uint16_t valueLen, uint8_t *pValue)
Initiate an attribute protocol signed Write Command.
void AttsCccClearTable(dmConnId_t connId)
Clear and deallocate the client characteristic configuration descriptor value table for a connection...
attCfg_t * pAttCfg
Configuration pointer.
ATT run-time configurable parameters.
Definition: att_api.h:142
void AttsDynInit(void)
Initialize the Dynamic ATT Service subsystem.
void(* attCback_t)(attEvt_t *pEvt)
ATT event callback type.
Definition: att_api.h:181
void AttcIndConfirm(dmConnId_t connId)
Send an attribute protocol indication confirmation.
void AttcFindByTypeValueReq(dmConnId_t connId, uint16_t startHandle, uint16_t endHandle, uint16_t uuid16, uint16_t valueLen, uint8_t *pValue, bool_t continuing)
Initiate an attribute protocol Find By Type Value Request.
void AttcExecuteWriteReq(dmConnId_t connId, bool_t writeAll)
Initiate an attribute protocol Execute Write Request.
Handle value notification.
Definition: att_api.h:109
void AttsAddGroup(attsGroup_t *pGroup)
Add an attribute group to the attribute server.
void AttcSetAutoConfirm(bool_t enable)
Set automatic Indication Confirmations sent from this ATT Client.
void AttcInit(void)
Initialize ATT client.
void AttcWriteCmd(dmConnId_t connId, uint16_t handle, uint16_t valueLen, uint8_t *pValue)
Initiate an attribute protocol Write Command.
Attribute group.
Definition: att_api.h:290
void(* attsCccCback_t)(attsCccEvt_t *pEvt)
ATTS client characteristic configuration callback.
Definition: att_api.h:373
void AttsSignInit(void)
Initialize ATT server for data signing.
void AttsInit(void)
Initialize ATT server.
void AttsHandleValueNtf(dmConnId_t connId, uint16_t handle, uint16_t valueLen, uint8_t *pValue)
Send an attribute protocol Handle Value Notification.
uint8_t AttcDiscCharCmpl(attcDiscCb_t *pCb, attEvt_t *pMsg)
This utility function processes a characteristic discovery result. It should be called when an ATTC_R...
Read response.
Definition: att_api.h:101
uint8_t(* attsAuthorCback_t)(dmConnId_t connId, uint8_t permit, uint16_t handle)
ATTS authorization callback type.
Definition: att_api.h:268
Read long response.
Definition: att_api.h:102
void AttcSignInit(void)
Initialize ATT client for data signing.
Handle value confirmation.
Definition: att_api.h:112
void AttMsgFree(void *pMsg, uint8_t opcode)
Free an ATT message buffer allocated with AttMsgAlloc().
attClientAwareStates
client&#39;s awareness to database change.
Definition: att_api.h:128
void AttcCancelReq(dmConnId_t connId)
Cancel an attribute protocol request in progress.
void AttsCalculateDbHash(void)
Calculate database hash from the GATT database.
bool_t AttsHashDatabaseString(uint8_t *pKey, uint8_t *pMsg, uint16_t msgLen)
Create hash from the database string.
Database hash calculation complete.
Definition: att_api.h:114
void AttcFindInfoReq(dmConnId_t connId, uint16_t startHandle, uint16_t endHandle, bool_t continuing)
Initiate an attribute protocol Find Information Request.
uint8_t AttcDiscConfigCmpl(dmConnId_t connId, attcDiscCb_t *pCb)
This utility function initiates the next characteristic configuration procedure. It should be called ...
uint16_t AttsCccEnabled(dmConnId_t connId, uint8_t idx)
Check if a client characteristic configuration descriptor is enabled and if the characteristic&#39;s secu...
uint8_t AttsGetAttr(uint16_t handle, uint16_t *pLen, uint8_t **pValue)
Get an attribute value in the attribute server.
ATTS client characteristic configuration callback structure.
Definition: att_api.h:309
void AttsHandleValueInd(dmConnId_t connId, uint16_t handle, uint16_t valueLen, uint8_t *pValue)
Send an attribute protocol Handle Value Indication.
void AttsCsfConnOpen(dmConnId_t connId, uint8_t changeAwareState, uint8_t *pCsf)
Initialize the client supported features for a connection.
void(* dmCback_t)(dmEvt_t *pDmEvt)
Callback type.
Definition: dm_api.h:779
Negotiated MTU value.
Definition: att_api.h:116
Execute write response.
Definition: att_api.h:108
void AttsDynAddAttrConst(void *pSvcHandle, const uint8_t *pUuid, const uint8_t *pValue, const uint16_t len, uint8_t settings, uint8_t permissions)
Dynamically add an attribute with a constant value to a dynamic ATT Services at runtime.
Client characteristc configuration settings.
Definition: att_api.h:301
Find by type value response.
Definition: att_api.h:99
void * AttsDynCreateGroup(uint16_t startHandle, uint16_t endHandle)
Dynamically create an ATT Service at runtime.
Write response.
Definition: att_api.h:105
ATT client discovery control block.
Definition: att_api.h:341
Attribute structure.
Definition: att_api.h:192
void AttcWriteReq(dmConnId_t connId, uint16_t handle, uint16_t valueLen, uint8_t *pValue)
Initiate an attribute protocol Write Request.
Device Manager subsystem API.
void AttsHandleValueIndZeroCpy(dmConnId_t connId, uint16_t handle, uint16_t valueLen, uint8_t *pValue)
Send an attribute protocol Handle Value Indication without copying the attribute value data...
void AttcMtuReq(dmConnId_t connId, uint16_t mtu)
For internal use only.
uint16_t AttGetMtu(dmConnId_t connId)
Get the attribute protocol MTU of a connection.
Handle value indication.
Definition: att_api.h:110
Client chracteristic configuration state change.
Definition: att_api.h:113
void AttsIndInit(void)
Initialize ATT server for indications/notifications.
uint8_t(* attsReadCback_t)(dmConnId_t connId, uint16_t handle, uint8_t operation, uint16_t offset, attsAttr_t *pAttr)
Attribute group read callback.
Definition: att_api.h:231
Write command response.
Definition: att_api.h:106
void * AttMsgAlloc(uint16_t len, uint8_t opcode)
Allocate an ATT message buffer to be sent with the ATT attribute protocol zero-copy APIs...
Prepare write response.
Definition: att_api.h:107
Client supported features record structure.
Definition: att_api.h:203
void AttcReadByTypeReq(dmConnId_t connId, uint16_t startHandle, uint16_t endHandle, uint8_t uuidLen, uint8_t *pUuid, bool_t continuing)
Initiate an attribute protocol Read By Type Request.
uint8_t AttcDiscConfigResume(dmConnId_t connId, attcDiscCb_t *pCb)
This utility function resumes the characteristic configuration procedure. It can be called when an AT...
uint8_t AttsSetAttr(uint16_t handle, uint16_t valueLen, uint8_t *pValue)
Set an attribute value in the attribute server.
void AttcPrepareWriteReq(dmConnId_t connId, uint16_t handle, uint16_t offset, uint16_t valueLen, uint8_t *pValue, bool_t valueByRef, bool_t continuing)
Initiate an attribute protocol Prepare Write Request.
uint8_t AttsGetCccTableLen(void)
Get number of CCC entries in table.
Read multiple response.
Definition: att_api.h:103
void AttsDynRegister(void *pSvcHandle, attsReadCback_t readCback, attsWriteCback_t writeCback)
Register callback functions for a dynamic ATT Service at runtime.
Attribute protocol constants and definitions from the Bluetooth specification.
Attribute protocol UUIDs from the Bluetooth specification.
void AttsSetCsrk(dmConnId_t connId, uint8_t *pCsrk)
Set the peer&#39;s data signing key on this connection. This function is typically called from the ATT co...
Read by type value response.
Definition: att_api.h:100
void(* attsCsfWriteCback_t)(dmConnId_t connId, uint8_t changeAwareState, uint8_t *pCsf)
ATTS client supported features write callback type.
Definition: att_api.h:281
ATT client structure for characteristic and descriptor configuration.
Definition: att_api.h:333
void AttsCccSet(dmConnId_t connId, uint8_t idx, uint16_t value)
Set the value of a client characteristic configuration descriptor by its index.
void AttsCsfInit(void)
Initialize ATTS client supported features module.
void AttcReadReq(dmConnId_t connId, uint16_t handle)
Initiate an attribute protocol Read Request.
void AttsCsfSetClientsChangeAwarenessState(dmConnId_t connId, uint8_t state)
Update a client&#39;s state of awareness to a change in the database.
void AttConnRegister(dmCback_t cback)
Register a connection callback with ATT. The callback is typically used to manage the attribute serve...
void AttsHandleValueNtfZeroCpy(dmConnId_t connId, uint16_t handle, uint16_t valueLen, uint8_t *pValue)
Send an attribute protocol Handle Value Notification without copying the attribute value data...
void AttsErrorTest(uint8_t status)
For testing purposes only.
Find information response.
Definition: att_api.h:98
void AttcDiscService(dmConnId_t connId, attcDiscCb_t *pCb, uint8_t uuidLen, uint8_t *pUuid)
This utility function discovers the given service on a peer device. Function AttcFindByTypeValueReq()...
void AttsCccInitTable(dmConnId_t connId, uint16_t *pCccTbl)
Initialize the client characteristic configuration descriptor value table for a connection. The table is initialized with the values from pCccTbl. If pCccTbl is NULL the table will be initialized to zero.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.