FreeRTOS: BLE
BLE
Return to main page ↑
bt_hal_gatt_server.h
Go to the documentation of this file.
1 /*
2  * FreeRTOS BLE HAL V5.0.0
3  * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * http://aws.amazon.com/freertos
23  * http://www.FreeRTOS.org
24  */
25 
44 #ifndef _BT_HAL_GATT_SERVER_H_
45 #define _BT_HAL_GATT_SERVER_H_
46 
47 #include "bt_hal_gatt_types.h"
48 
49 
53 typedef enum
54 {
61 
65 typedef struct
66 {
67  uint16_t usHandle;
68  uint8_t * pucValue;
69  uint16_t usOffset;
70  size_t xLen;
73 
77 typedef union
78 {
80  uint16_t usHandle;
82 
94 typedef void (* BTRegisterServerCallback_t)( BTStatus_t xStatus,
95  uint8_t ucServerIf,
96  BTUuid_t * pxAppUuid );
97 
108 typedef void (* BTUnregisterServerCallback_t)( BTStatus_t xStatus,
109  uint8_t ucServerIf );
110 
123 typedef void (* BTConnectionCallback_t)( uint16_t usConnId,
124  uint8_t ucServerIf,
125  bool bConnected,
126  BTBdaddr_t * pxBda );
127 
141 typedef void (* BTServiceAddedCallback_t)( BTStatus_t xStatus,
142  uint8_t ucServerIf,
143  BTGattSrvcId_t * pxSrvcId,
144  uint16_t usServiceHandle );
145 
159  uint8_t ucServerIf,
160  uint16_t usServiceHandle,
161  uint16_t usInclSrvcHandle );
162 
177 typedef void (* BTCharacteristicAddedCallback_t)( BTStatus_t xStatus,
178  uint8_t ucServerIf,
179  BTUuid_t * pxUuid,
180  uint16_t usServiceHandle,
181  uint16_t usCharHandle );
182 
190 typedef void (* BTSetValCallback_t)( BTStatus_t xStatus,
191  uint16_t usAttrHandle );
192 
207 typedef void (* BTDescriptorAddedCallback_t)( BTStatus_t xStatus,
208  uint8_t ucServerIf,
209  BTUuid_t * pxUuid,
210  uint16_t usServiceHandle,
211  uint16_t usDescrHandle );
212 
223 typedef void (* BTServiceStartedCallback_t)( BTStatus_t xStatus,
224  uint8_t ucServerIf,
225  uint16_t usServiceHandle );
226 
237 typedef void (* BTServiceStoppedCallback_t)( BTStatus_t xStatus,
238  uint8_t ucServerIf,
239  uint16_t usServiceHandle );
240 
251 typedef void (* BTServiceDeletedCallback_t)( BTStatus_t xStatus,
252  uint8_t ucServerIf,
253  uint16_t usServiceHandle );
254 
272 typedef void (* BTRequestReadCallback_t)( uint16_t usConnId,
273  uint32_t ulTransId,
274  BTBdaddr_t * pxBda,
275  uint16_t usAttrHandle,
276  uint16_t usOffset );
277 
303 typedef void (* BTRequestWriteCallback_t)( uint16_t usConnId,
304  uint32_t ulTransId,
305  BTBdaddr_t * pxBda,
306  uint16_t usAttrHandle,
307  uint16_t usOffset,
308  size_t xLength,
309  bool bNeedRsp,
310  bool bIsPrep,
311  uint8_t * pucValue );
312 
327 typedef void (* BTRequestExecWriteCallback_t)( uint16_t usConnId,
328  uint32_t ulTransId,
329  BTBdaddr_t * pxBda,
330  bool bExecWrite );
331 
341  uint16_t usHandle );
342 
351 typedef void (* BTIndicationSentCallback_t)( uint16_t usConnId,
352  BTStatus_t xStatus );
353 
362 typedef void (* BTMtuChangedCallback_t)( uint16_t usConnId,
363  uint16_t usMtu );
364 
372 typedef void (* BTWhiteListChangedCallback_t)( const BTBdaddr_t * pxBdAddr,
373  bool bIsAdded );
374 
378 typedef struct
379 {
380  BTRegisterServerCallback_t pxRegisterServerCb;
381  BTUnregisterServerCallback_t pxUnregisterServerCb;
382  BTConnectionCallback_t pxConnectionCb;
383  BTServiceAddedCallback_t pxServiceAddedCb;
384  BTIncludedServiceAddedCallback_t pxIncludedServiceAddedCb;
385  BTCharacteristicAddedCallback_t pxCharacteristicAddedCb;
386  BTSetValCallback_t pxSetValCallbackCb;
387  BTDescriptorAddedCallback_t pxDescriptorAddedCb;
388  BTServiceStartedCallback_t pxServiceStartedCb;
389  BTServiceStoppedCallback_t pxServiceStoppedCb;
390  BTServiceDeletedCallback_t pxServiceDeletedCb;
391  BTRequestReadCallback_t pxRequestReadCb;
392  BTRequestWriteCallback_t pxRequestWriteCb;
393  BTRequestExecWriteCallback_t pxRequestExecWriteCb;
394  BTResponseConfirmationCallback_t pxResponseConfirmationCb;
395  BTIndicationSentCallback_t pxIndicationSentCb;
396  BTCongestionCallback_t pxCongestionCb;
397  BTMtuChangedCallback_t pxMtuChangedCb;
398  BTWhiteListChangedCallback_t pxBTWhiteListChangedCb;
400 
402 typedef struct
403 {
413  BTStatus_t ( * pxRegisterServer )( BTUuid_t * pxUuid );
414 
425  BTStatus_t ( * pxUnregisterServer )( uint8_t ucServerIf );
426 
434  BTStatus_t ( * pxGattServerInit )( const BTGattServerCallbacks_t * pxCallbacks );
435 
452  BTStatus_t ( * pxConnect )( uint8_t ucServerIf,
453  const BTBdaddr_t * pxBdAddr,
454  bool bIsDirect,
455  BTTransport_t xTransport );
456 
473  BTStatus_t ( * pxDisconnect )( uint8_t ucServerIf,
474  const BTBdaddr_t * pxBdAddr,
475  uint16_t usConnId );
476 
490  BTStatus_t ( * pxAddServiceBlob )( uint8_t ucServerIf,
491  BTService_t * pxService );
492 
509  BTStatus_t ( * pxAddService )( uint8_t ucServerIf,
510  BTGattSrvcId_t * pxSrvcId,
511  uint16_t usNumHandles );
512 
529  BTStatus_t ( * pxAddIncludedService )( uint8_t ucServerIf,
530  uint16_t usServiceHandle,
531  uint16_t usIncludedHandle );
532 
555  BTStatus_t ( * pxAddCharacteristic )( uint8_t ucServerIf,
556  uint16_t usServiceHandle,
557  BTUuid_t * pxUuid,
558  BTCharProperties_t xProperties,
559  BTCharPermissions_t xPermissions );
560 
571  BTStatus_t ( * pxSetVal )( BTGattResponse_t * pxValue );
572 
593  BTStatus_t ( * pxAddDescriptor )( uint8_t ucServerIf,
594  uint16_t usServiceHandle,
595  BTUuid_t * pxUuid,
596  BTCharPermissions_t ulPermissions );
597 
613  BTStatus_t ( * pxStartService )( uint8_t ucServerIf,
614  uint16_t usServiceHandle,
615  BTTransport_t xTransport );
616 
630  BTStatus_t ( * pxStopService )( uint8_t ucServerIf,
631  uint16_t usServiceHandle );
632 
647  BTStatus_t ( * pxDeleteService )( uint8_t ucServerIf,
648  uint16_t usServiceHandle );
649 
671  BTStatus_t ( * pxSendIndication )( uint8_t ucServerIf,
672  uint16_t usAttributeHandle,
673  uint16_t usConnId,
674  size_t xLen,
675  uint8_t * pucValue,
676  bool bConfirm );
677 
694  BTStatus_t ( * pxSendResponse )( uint16_t usConnId,
695  uint32_t ulTransId,
696  BTStatus_t xStatus,
697  BTGattResponse_t * pxResponse );
698 
713  BTStatus_t ( * pxReconnect )( uint8_t ucServerIf,
714  const BTBdaddr_t * pxBdAddr );
715 
730  BTStatus_t ( * pxAddDevicesToWhiteList )( uint8_t ucServerIf,
731  const BTBdaddr_t * pxBdAddr,
732  uint32_t ulNumberOfDevices );
733 
748  BTStatus_t ( * pxRemoveDevicesFromWhiteList )( uint8_t ucServerIf,
749  const BTBdaddr_t * pxBdAddr,
750  uint32_t ulNumberOfDevices );
751 
762  BTStatus_t ( * pxConfigureMtu )( uint8_t ucServerIf,
763  uint16_t usMtu );
765 
766 #endif /* _BT_HAL_GATT_SERVER_H_ */
767 
eBTRspErrorNone
@ eBTRspErrorNone
Definition: bt_hal_gatt_server.h:55
eBTRspErrorSignedNoMitm
@ eBTRspErrorSignedNoMitm
Definition: bt_hal_gatt_server.h:58
BTGattValue_t::usHandle
uint16_t usHandle
Definition: bt_hal_gatt_server.h:67
eBTRspErrorMitm
@ eBTRspErrorMitm
Definition: bt_hal_gatt_server.h:57
BTUnregisterServerCallback_t
void(* BTUnregisterServerCallback_t)(BTStatus_t xStatus, uint8_t ucServerIf)
Callback invoked in response to pxUnregisterServer.
Definition: bt_hal_gatt_server.h:108
BTUuid_t
UUID.
Definition: bt_hal_manager_types.h:84
BTIncludedServiceAddedCallback_t
void(* BTIncludedServiceAddedCallback_t)(BTStatus_t xStatus, uint8_t ucServerIf, uint16_t usServiceHandle, uint16_t usInclSrvcHandle)
Callback invoked in response to pxAddIncludedService.
Definition: bt_hal_gatt_server.h:158
BTRequestWriteCallback_t
void(* BTRequestWriteCallback_t)(uint16_t usConnId, uint32_t ulTransId, BTBdaddr_t *pxBda, uint16_t usAttrHandle, uint16_t usOffset, size_t xLength, bool bNeedRsp, bool bIsPrep, uint8_t *pucValue)
Callback invoked on write event.
Definition: bt_hal_gatt_server.h:303
BTGattResponse_t::usHandle
uint16_t usHandle
Definition: bt_hal_gatt_server.h:80
BTConnectionCallback_t
void(* BTConnectionCallback_t)(uint16_t usConnId, uint8_t ucServerIf, bool bConnected, BTBdaddr_t *pxBda)
Callback invoked on a connection event.
Definition: bt_hal_gatt_server.h:123
BTSetValCallback_t
void(* BTSetValCallback_t)(BTStatus_t xStatus, uint16_t usAttrHandle)
Callback invoked in response to pxSetVal.
Definition: bt_hal_gatt_server.h:190
BTGattServerCallbacks_t
Callback structure for GATT server.
Definition: bt_hal_gatt_server.h:379
BTServiceStoppedCallback_t
void(* BTServiceStoppedCallback_t)(BTStatus_t xStatus, uint8_t ucServerIf, uint16_t usServiceHandle)
Callback invoked in response to pxStopService.
Definition: bt_hal_gatt_server.h:237
BTServiceStartedCallback_t
void(* BTServiceStartedCallback_t)(BTStatus_t xStatus, uint8_t ucServerIf, uint16_t usServiceHandle)
Callback invoked in response to pxStartService.
Definition: bt_hal_gatt_server.h:223
eBTRspErrorNo_mitm
@ eBTRspErrorNo_mitm
Definition: bt_hal_gatt_server.h:56
BTResponseConfirmationCallback_t
void(* BTResponseConfirmationCallback_t)(BTStatus_t xStatus, uint16_t usHandle)
Callback triggered in response to sendResponse if the remote device sends a confirmation.
Definition: bt_hal_gatt_server.h:340
BTStatus_t
BTStatus_t
Bluetooth Error Status .
Definition: bt_hal_manager_types.h:98
BTIndicationSentCallback_t
void(* BTIndicationSentCallback_t)(uint16_t usConnId, BTStatus_t xStatus)
Callback on confirmation device from the remote device to an indication. Or confirm a Notification as...
Definition: bt_hal_gatt_server.h:351
BTGattResponse_t::xAttrValue
BTGattValue_t xAttrValue
Definition: bt_hal_gatt_server.h:79
BTMtuChangedCallback_t
void(* BTMtuChangedCallback_t)(uint16_t usConnId, uint16_t usMtu)
Callback invoked when the MTU for a given connection changes.
Definition: bt_hal_gatt_server.h:362
BTServiceDeletedCallback_t
void(* BTServiceDeletedCallback_t)(BTStatus_t xStatus, uint8_t ucServerIf, uint16_t usServiceHandle)
Callback invoked in response to pxDeleteService.
Definition: bt_hal_gatt_server.h:251
BTDescriptorAddedCallback_t
void(* BTDescriptorAddedCallback_t)(BTStatus_t xStatus, uint8_t ucServerIf, BTUuid_t *pxUuid, uint16_t usServiceHandle, uint16_t usDescrHandle)
Callback invoked in response to pxAddDescriptor.
Definition: bt_hal_gatt_server.h:207
BTCongestionCallback_t
void(* BTCongestionCallback_t)(uint16_t usConnId, bool bCongested)
Definition: bt_hal_gatt_types.h:311
BTWhiteListChangedCallback_t
void(* BTWhiteListChangedCallback_t)(const BTBdaddr_t *pxBdAddr, bool bIsAdded)
Callback for notifying modification in white list.
Definition: bt_hal_gatt_server.h:372
BTGattValue_t::xRspErrorStatus
BTRspErrorStatus_t xRspErrorStatus
Definition: bt_hal_gatt_server.h:71
BTGattServerInterface_t
Definition: bt_hal_gatt_server.h:403
BTGattSrvcId_t
GATT Service ID.
Definition: bt_hal_gatt_types.h:156
BTRequestReadCallback_t
void(* BTRequestReadCallback_t)(uint16_t usConnId, uint32_t ulTransId, BTBdaddr_t *pxBda, uint16_t usAttrHandle, uint16_t usOffset)
Callback invoked on read event.
Definition: bt_hal_gatt_server.h:272
BTRspErrorStatus_t
BTRspErrorStatus_t
Error status sent inside response to a read or write from the client.
Definition: bt_hal_gatt_server.h:54
bt_hal_gatt_types.h
T HAL provides the standard defintions used by BT GATT interfaces.
eBTRspErrorSignedMitm
@ eBTRspErrorSignedMitm
Definition: bt_hal_gatt_server.h:59
BTGattValue_t::xLen
size_t xLen
Definition: bt_hal_gatt_server.h:70
BTGattResponse_t
GATT response to read and write.
Definition: bt_hal_gatt_server.h:78
BTRequestExecWriteCallback_t
void(* BTRequestExecWriteCallback_t)(uint16_t usConnId, uint32_t ulTransId, BTBdaddr_t *pxBda, bool bExecWrite)
Callback invoked on execute write event.
Definition: bt_hal_gatt_server.h:327
BTTransport_t
BTTransport_t
Preferred physical Transport for GATT connection .
Definition: bt_hal_manager.h:108
BTBdaddr_t
BT/BLE address.
Definition: bt_hal_manager_types.h:67
BTRegisterServerCallback_t
void(* BTRegisterServerCallback_t)(BTStatus_t xStatus, uint8_t ucServerIf, BTUuid_t *pxAppUuid)
Callback invoked in response to pxRegisterServer.
Definition: bt_hal_gatt_server.h:94
BTServiceAddedCallback_t
void(* BTServiceAddedCallback_t)(BTStatus_t xStatus, uint8_t ucServerIf, BTGattSrvcId_t *pxSrvcId, uint16_t usServiceHandle)
Callback invoked in response to pxAddService.
Definition: bt_hal_gatt_server.h:141
BTGattValue_t
GATT value type used in response to remote read/Write requests.
Definition: bt_hal_gatt_server.h:66
BTGattValue_t::pucValue
uint8_t * pucValue
Definition: bt_hal_gatt_server.h:68
BTCharacteristicAddedCallback_t
void(* BTCharacteristicAddedCallback_t)(BTStatus_t xStatus, uint8_t ucServerIf, BTUuid_t *pxUuid, uint16_t usServiceHandle, uint16_t usCharHandle)
Callback invoked in response to pxAddCharacteristic.
Definition: bt_hal_gatt_server.h:177
BTGattValue_t::usOffset
uint16_t usOffset
Definition: bt_hal_gatt_server.h:69