FreeRTOS: BLE
BLE
Return to main page ↑
bt_hal_gatt_client.h
Go to the documentation of this file.
1 /*
2  * FreeRTOS BLE HAL V5.1.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 
40 #ifndef _BT_HAL_GATT_CLIENT_H_
41 #define _BT_HAL_GATT_CLIENT_H_
42 
43 #include <stdint.h>
44 #include "bt_hal_gatt_types.h"
45 #include "bt_hal_manager_types.h"
46 
47 
51 typedef struct
52 {
53  uint8_t ucValue[ btGATT_MAX_ATTR_LEN ];
54  uint16_t usLen;
56 
60 typedef struct
61 {
62  uint16_t usHandle;
64  uint16_t usValueType;
65  uint8_t ucStatus;
67 
71 typedef struct
72 {
73  BTGattSrvcId_t xSrvcId;
74  BTGattInstanceId_t xCharId;
75  BTGattInstanceId_t xDescrId;
76  uint8_t ucStatus;
78 
82 typedef struct
83 {
84  uint8_t ucValue[ btGATT_MAX_ATTR_LEN ];
85  BTBdaddr_t xBda;
86  uint16_t usHandle;
87  size_t xLen;
88  bool bIsNotify;
90 
94 typedef struct
95 {
96  BTBdaddr_t * pxBda1;
97  BTUuid_t * pxUuid1;
98  uint16_t usU1;
99  uint16_t usU2;
100  uint16_t usU3;
101  uint16_t usU4;
102  uint16_t usU5;
104 
105 
109 typedef enum
110 {
126 
139 typedef void ( * BTRegisterClientCallback_t)( BTGattStatus_t xStatus,
140  uint8_t ucClientIf,
141  BTUuid_t * pxAppUuid );
142 
152 typedef void ( * BTSearchCompleteCallback_t)( uint16_t usConnId,
153  BTGattStatus_t xStatus );
154 
169 typedef void ( * BTRegisterForNotificationCallback_t)( uint16_t usConnId,
170  bool bRegistered,
171  BTGattStatus_t xStatus,
172  uint16_t usHandle );
173 
183 typedef void ( * BTNotifyCallback_t)( uint16_t usConnId,
184  BTGattNotifyParams_t * pxData );
185 
196 typedef void ( * BTReadCharacteristicCallback_t)( uint16_t usConnId,
197  BTGattStatus_t xStatus,
198  BTGattReadParams_t * pxData );
199 
211 typedef void ( * BTWriteCharacteristicCallback_t)( uint16_t usConnId,
212  BTGattStatus_t xStatus,
213  uint16_t usHandle );
214 
223 typedef void ( * BTExecuteWriteCallback_t)( uint16_t usConnId,
224  BTGattStatus_t xStatus );
225 
236 typedef void ( * BTReadDescriptorCallback_t)( uint16_t usConnId,
237  BTGattStatus_t xStatus,
238  BTGattReadParams_t * pxData );
239 
250 typedef void ( * BTWriteDescriptorCallback_t)( uint16_t usConnId,
251  BTGattStatus_t xStatus,
252  uint16_t usHandle );
253 
260 typedef void ( * BTListenCallback_t)( BTGattStatus_t xStatus,
261  uint32_t ulServerIf );
262 
274 typedef void ( * BTConfigureMtuCallback_t)( uint16_t usConnId,
275  BTGattStatus_t xStatus,
276  uint32_t ulMtu );
277 
288 typedef void ( * BTGetGattDbCallback_t)( uint16_t usConnId,
289  BTGattDbElement_t * pxDb,
290  uint32_t ulCount );
291 
302 typedef void ( * BTServicesRemovedCallback_t)( uint16_t usConnId,
303  uint16_t usStartHandle,
304  uint16_t usEndHandle );
305 
316 typedef void ( * BTServicesAddedCallback_t)( uint16_t usConnId,
317  BTGattDbElement_t * pxAdded,
318  uint32_t ulAddedCount );
319 
320 typedef struct
321 {
322  BTRegisterClientCallback_t pxRegisterClientCb;
323  BTConnectCallback_t pxOpenCb;
324  BTDisconnectCallback_t pxCloseCb;
325  BTSearchCompleteCallback_t pxSearchCompleteCb;
326  BTRegisterForNotificationCallback_t pxRegisterForNotificationCb;
327  BTNotifyCallback_t pxNotifyCb;
328  BTReadCharacteristicCallback_t pxReadCharacteristicCb;
329  BTWriteCharacteristicCallback_t pxWriteCharacteristicCb;
330  BTReadDescriptorCallback_t pxReadDescriptorCb;
331  BTWriteDescriptorCallback_t pxWriteDescriptorCb;
332  BTExecuteWriteCallback_t pxExecuteWriteCb;
333  BTReadRemoteRssiCallback_t pxReadRemoteRssiCb;
334  BTListenCallback_t pxListenCb;
336  BTCongestionCallback_t pxCongestionCb;
337  BTGetGattDbCallback_t pxGetGattDbCb;
338  BTServicesRemovedCallback_t pxServicesRemovedCb;
339  BTServicesAddedCallback_t pxServicesAddedCb;
341 
343 typedef struct
344 {
353  BTStatus_t ( * pxRegisterClient )( BTUuid_t * pxUuid );
354 
364  BTStatus_t ( * pxUnregisterClient )( uint8_t ucClientIf );
365 
374  BTStatus_t ( * pxGattClientInit )( const BTGattClientCallbacks_t * pxCallbacks );
375 
391  BTStatus_t ( * pxConnect )( uint8_t ucClientIf,
392  const BTBdaddr_t * pxBdAddr,
393  bool bIsDirect,
394  BTTransport_t xTransport );
395 
410  BTStatus_t ( * pxDisconnect )( uint8_t ucClientIf,
411  const BTBdaddr_t * pxBdAddr,
412  uint16_t usConnId );
413 
425  BTStatus_t ( * pxRefresh )( uint8_t ucClientIf,
426  const BTBdaddr_t * pxBdAddr );
427 
441  BTStatus_t ( * pxSearchService )( uint16_t usConnId,
442  BTUuid_t * pxFilterUuid );
443 
457  BTStatus_t ( * pxReadCharacteristic )( uint16_t usConnId,
458  uint16_t usHandle,
459  uint32_t ulAuthReq );
460 
479  BTStatus_t ( * pxWriteCharacteristic )( uint16_t usConnId,
480  uint16_t usHandle,
481  BTAttrWriteRequests_t xWriteType,
482  size_t xLen,
483  uint32_t ulAuthReq,
484  char * pcValue );
485 
499  BTStatus_t ( * pxReadDescriptor )( uint16_t usConnId,
500  uint16_t usHandle,
501  uint32_t ulAuthReq );
502 
522  BTStatus_t ( * pxWriteDescriptor )( uint16_t usConnId,
523  uint16_t usHandle,
524  BTAttrWriteRequests_t xWriteType,
525  size_t xLen,
526  uint32_t ulAuthReq,
527  char * pcValue );
528 
540  BTStatus_t ( * pxExecuteWrite )( uint16_t usConnId,
541  bool bExecute );
542 
557  BTStatus_t ( * pxRegisterForNotification )( uint8_t ucClientIf,
558  const BTBdaddr_t * pxBdAddr,
559  uint16_t usHandle );
560 
575  BTStatus_t ( * pxUnregisterForNotification )( uint8_t ucClientIf,
576  const BTBdaddr_t * pxBdAddr,
577  uint16_t usHandle );
578 
590  BTStatus_t ( * pxReadRemoteRssi )( uint8_t ucClientIf,
591  const BTBdaddr_t * pxBdAddr );
592 
601  BTTransport_t ( * pxGetDeviceType )( const BTBdaddr_t * pxBdAddr );
602 
614  BTStatus_t ( * pxConfigureMtu )( uint16_t usConnId,
615  uint16_t usMtu );
616 
626  BTStatus_t ( * pxTestCommand )( uint32_t ulCommand,
627  BTGattTestParams_t * pxParams );
628 
637  BTStatus_t ( * pxGetGattDb )( uint16_t usConnId );
639 
640 #endif /* #ifndef _BT_HAL_GATT_CLIENT_H_ */
641 
void(* BTWriteDescriptorCallback_t)(uint16_t usConnId, BTGattStatus_t xStatus, uint16_t usHandle)
Callback invoked in response to pxWriteDescriptor.
Definition: bt_hal_gatt_client.h:250
Definition: bt_hal_gatt_client.h:343
Definition: bt_hal_gatt_client.h:116
Definition: bt_hal_gatt_client.h:120
void(* BTServicesAddedCallback_t)(uint16_t usConnId, BTGattDbElement_t *pxAdded, uint32_t ulAddedCount)
GATT services were added.
Definition: bt_hal_gatt_client.h:316
Definition: bt_hal_gatt_client.h:320
BTGattcError_t
BT GATT client error codes.
Definition: bt_hal_gatt_client.h:109
Definition: bt_hal_gatt_client.h:115
Definition: bt_hal_gatt_client.h:124
void(* BTExecuteWriteCallback_t)(uint16_t usConnId, BTGattStatus_t xStatus)
GATT execute prepared write callback. Triggered by pxExecuteWrite.
Definition: bt_hal_gatt_client.h:223
void(* BTReadDescriptorCallback_t)(uint16_t usConnId, BTGattStatus_t xStatus, BTGattReadParams_t *pxData)
Callback invoked in response to pxReadDescriptor.
Definition: bt_hal_gatt_client.h:236
void(* BTCongestionCallback_t)(uint16_t usConnId, bool bCongested)
Definition: bt_hal_gatt_types.h:311
Definition: bt_hal_gatt_client.h:114
GATT service instance ID.
Definition: bt_hal_gatt_types.h:146
BTGattStatus_t
GATT Status Codes.
Definition: bt_hal_gatt_types.h:56
Definition: bt_hal_gatt_types.h:265
void(* BTListenCallback_t)(BTGattStatus_t xStatus, uint32_t ulServerIf)
Callback indicating the status of a listen() operation.
Definition: bt_hal_gatt_client.h:260
Definition: bt_hal_gatt_client.h:112
Parameters for attribute change notifications.
Definition: bt_hal_gatt_client.h:82
Definition: bt_hal_gatt_client.h:121
void(* BTReadRemoteRssiCallback_t)(uint8_t ucClientIf, BTBdaddr_t *pxBda, uint32_t ulRssi, BTStatus_t xStatus)
Definition: bt_hal_gatt_types.h:301
UUID.
Definition: bt_hal_manager_types.h:83
Definition: bt_hal_gatt_client.h:113
void(* BTRegisterClientCallback_t)(BTGattStatus_t xStatus, uint8_t ucClientIf, BTUuid_t *pxAppUuid)
Callback invoked in response pxRegisterClient when the GATT client registration has been completed...
Definition: bt_hal_gatt_client.h:139
T HAL provides the standard defintions used by BT GATT interfaces.
Definition: bt_hal_gatt_client.h:123
void(* BTDisconnectCallback_t)(uint16_t usConnId, BTGattStatus_t xStatus, uint8_t ucClientIf, BTBdaddr_t *pxBda)
Definition: bt_hal_gatt_types.h:294
BTAttrWriteRequests_t
Write request type.
Definition: bt_hal_gatt_types.h:125
Definition: bt_hal_gatt_client.h:119
Definition: bt_hal_gatt_client.h:122
void(* BTServicesRemovedCallback_t)(uint16_t usConnId, uint16_t usStartHandle, uint16_t usEndHandle)
GATT services between startHandle and endHandle were removed.
Definition: bt_hal_gatt_client.h:302
Definition: bt_hal_gatt_client.h:117
void(* BTSearchCompleteCallback_t)(uint16_t usConnId, BTGattStatus_t xStatus)
Callback invoked in response to pxSearchService when the GATT service search has been completed...
Definition: bt_hal_gatt_client.h:152
Definition: bt_hal_gatt_client.h:118
BTStatus_t
Bluetooth Error Status .
Definition: bt_hal_manager_types.h:97
Parameters for test command interface.
Definition: bt_hal_gatt_client.h:94
Buffer type for unformatted reads/writes.
Definition: bt_hal_gatt_client.h:51
void(* BTRegisterForNotificationCallback_t)(uint16_t usConnId, bool bRegistered, BTGattStatus_t xStatus, uint16_t usHandle)
Callback invoked in response to pxRegisterForNotification and pxUnregisterForNotification.
Definition: bt_hal_gatt_client.h:169
void(* BTGetGattDbCallback_t)(uint16_t usConnId, BTGattDbElement_t *pxDb, uint32_t ulCount)
GATT get database callback. Triggered by pxGetGattDb.
Definition: bt_hal_gatt_client.h:288
BT/BLE address.
Definition: bt_hal_manager_types.h:66
Parameters for GATT write operations.
Definition: bt_hal_gatt_client.h:71
void(* BTNotifyCallback_t)(uint16_t usConnId, BTGattNotifyParams_t *pxData)
Remote device notification callback, invoked when a remote device sends a notification or indication ...
Definition: bt_hal_gatt_client.h:183
void(* BTConnectCallback_t)(uint16_t usConnId, BTGattStatus_t xStatus, uint8_t ucClientIf, BTBdaddr_t *pxBda)
Definition: bt_hal_gatt_types.h:288
#define btGATT_MAX_ATTR_LEN
Definition: bt_hal_gatt_types.h:49
void(* BTReadCharacteristicCallback_t)(uint16_t usConnId, BTGattStatus_t xStatus, BTGattReadParams_t *pxData)
Reports result of a GATT read operation. Triggered by pxReadCharacteristic.
Definition: bt_hal_gatt_client.h:196
Parameters for GATT read operations.
Definition: bt_hal_gatt_client.h:60
Definition: bt_hal_gatt_client.h:111
void(* BTConfigureMtuCallback_t)(uint16_t usConnId, BTGattStatus_t xStatus, uint32_t ulMtu)
Callback invoked when the MTU for a given connection changes. Triggered by pxConfigureMtu.
Definition: bt_hal_gatt_client.h:274
void(* BTWriteCharacteristicCallback_t)(uint16_t usConnId, BTGattStatus_t xStatus, uint16_t usHandle)
GATT write characteristic operation callback. Triggered by pxWriteCharacteristic. ...
Definition: bt_hal_gatt_client.h:211
GATT Service ID.
Definition: bt_hal_gatt_types.h:155
BTTransport_t
Preferred physical Transport for GATT connection .
Definition: bt_hal_manager.h:107
BTConfigureMtuCallback_t pxConfigureMtuCb
Definition: bt_hal_gatt_client.h:335