• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef SOFTBUS_ADAPTER_BLE_GATT_CLIENT_H
17 #define SOFTBUS_ADAPTER_BLE_GATT_CLIENT_H
18 
19 #include "stdbool.h"
20 #include "stdint.h"
21 
22 #include "softbus_adapter_bt_common.h"
23 
24 #ifdef __cplusplus
25 #if __cplusplus
26 extern "C" {
27 #endif
28 #endif
29 
30 typedef struct {
31     SoftBusBtUuid charaUuid;
32     uint32_t dataLen;
33     uint8_t *data;
34 } SoftBusGattcNotify;
35 
36 typedef struct {
37     SoftBusBtUuid serviceUuid;
38     SoftBusBtUuid characterUuid;
39     uint32_t valueLen;
40     const uint8_t *value;
41 } SoftBusGattcData;
42 
43 typedef struct {
44     void (*ConnectionStateCallback)(int32_t clientId, int32_t connState, int32_t status);
45     void (*ServiceCompleteCallback)(int32_t clientId, int32_t status);
46     void (*RegistNotificationCallback)(int32_t clientId, int status);
47     void (*NotificationReceiveCallback)(int32_t clientId, SoftBusGattcNotify *param, int32_t status);
48     void (*ConfigureMtuSizeCallback)(int clientId, int mtuSize, int status);
49 } SoftBusGattcCallback;
50 
51 typedef enum {
52     SOFTBUS_GATT_PRIORITY_BALANCED = 0x0,
53     SOFTBUS_GATT_PRIORITY_HIGH,
54     SOFTBUS_GATT_PRIORITY_LOW_POWER,
55 } SoftbusBleGattPriority;
56 
57 void SoftbusGattcRegisterCallback(SoftBusGattcCallback *cb);
58 int32_t SoftbusGattcRegister(void);
59 int32_t SoftbusGattcUnRegister(int32_t clientId);
60 int32_t SoftbusGattcConnect(int32_t clientId, SoftBusBtAddr *addr);
61 int32_t SoftbusBleGattcDisconnect(int32_t clientId, bool refreshGatt);
62 int32_t SoftbusGattcSearchServices(int32_t clientId);
63 int32_t SoftbusGattcRefreshServices(int32_t clientId);
64 int32_t SoftbusGattcGetService(int32_t clientId, SoftBusBtUuid *serverUuid);
65 int32_t SoftbusGattcRegisterNotification(
66     int32_t clientId, SoftBusBtUuid *serverUuid, SoftBusBtUuid *charaUuid, SoftBusBtUuid *descriptorUuid);
67 int32_t SoftbusGattcWriteCharacteristic(int32_t clientId, SoftBusGattcData *clientData);
68 int32_t SoftbusGattcConfigureMtuSize(int32_t clientId, int mtuSize);
69 
70 int32_t SoftbusGattcSetFastestConn(int32_t clientId);
71 int32_t SoftbusGattcSetPriority(int32_t clientId, SoftBusBtAddr *addr, SoftbusBleGattPriority priority);
72 
73 #ifdef __cplusplus
74 #if __cplusplus
75 }
76 #endif /* __cplusplus */
77 #endif /* __cplusplus */
78 #endif /* SOFTBUS_ADAPTER_BLE_GATT_CLIENT_H */
79