RDK Documentation (Open Sourced RDK Components)
btrCore_le.h
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2017 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 /*
21  * @file btrCore_le.h
22  * Includes information for LE functionality over BT.
23  */
24 
25 
26 #ifndef __BTR_CORE_LE_H__
27 #define __BTR_CORE_LE_H__
28 
29 #include "btrCoreTypes.h"
30 
31 /**
32  * @addtogroup BLUETOOTH_TYPES
33  * @{
34  */
35 
36 
37 typedef void* tBTRCoreLeHdl;
38 
39 /* Enum Types */
40 typedef enum _enBTRCoreLEGattProp {
41  enBTRCoreLEGPropUUID,
42  enBTRCoreLEGPropPrimary,
43  enBTRCoreLEGPropDevice,
44  enBTRCoreLEGPropService,
45  enBTRCoreLEGPropValue,
46  enBTRCoreLEGPropNotifying,
47  enBTRCoreLEGPropFlags,
48  enBTRCoreLEGPropChar,
49  enBTRCoreLEGPropDesc,
50  enBTRCoreLEGPropDescValue,
51  enBTRCoreLEGPropUnknown
52 } enBTRCoreLEGattProp;
53 
54 typedef enum _enBTRCoreLEGattOp {
55  enBTRCoreLEGOpReady,
56  enBTRCoreLEGOpReadValue,
57  enBTRCoreLEGOpWriteValue,
58  enBTRCoreLEGOpStartNotify,
59  enBTRCoreLEGOpStopNotify,
60  enBTRCoreLEGOpUnknown
61 } enBTRCoreLEGattOp;
62 
63 typedef enum _enBTRCoreLEAdvProp {
64  enBTRCoreLEAdvTypeProp,
65  enBTRCoreLEServUUIDProp,
66  enBTRCoreLENumServicesProp,
67  enBTRCoreLEManfData,
68  enBTRCoreLEServiceData,
69  enBTRCoreLESolictiUUIDProp,
70  enBTRCoreLETxPowerProp,
71  enBTRCoreLEUnknown
72 } enBTRCoreLEAdvProp;
73 
74 typedef struct _stBTRCoreLeGattInfo {
75  enBTRCoreLEGattOp enLeOper;
76  enBTRCoreLEGattProp enLeProp;
77  char* pui8Uuid;
78  char* pui8Value;
80 
81 /* @} */ // End of group BLUETOOTH_TYPES
82 
83 /**
84  * @addtogroup BLUETOOTH_APIS
85  * @{
86  */
87 
88 
89 /* Fptr callback types */
90 //TODO: char* apBtLeInfo -> apstBtLeInfo | define a struct based on future need
91 typedef enBTRCoreRet (*fPtr_BTRCore_LeStatusUpdateCb) (stBTRCoreLeGattInfo* apstBtrLeInfo, const char* apBtDevAddr, void* apUserData);
92 
93 
94 /* Interfaces */
95 /**
96  * @brief This API registers the callback function that has to be called when the LE device are added or removed.
97  *
98  * @param[in] phBTRCoreLe Handle to bluetooth low energy device interface.
99  * @param[in] apBtConn Dbus connection.
100  * @param[in] apBtAdapter Bluetooth adapter address.
101  *
102  * @return Returns the status of the operation.
103  * @retval Returns enBTRCoreSuccess on success, appropiate error code otherwise.
104  */
105 enBTRCoreRet BTRCore_LE_Init (tBTRCoreLeHdl* phBTRCoreLe, void* apBtConn, const char* apBtAdapter);
106 
107 /**
108  * @brief This API deinitializes the LE device.
109  *
110  * @param[in] hBTRCoreLe Handle to bluetooth low energy device interface.
111  * @param[in] apBtConn Dbus connection.
112  * @param[in] apBtAdapter Bluetooth adapter address.
113 
114  * @return Returns the status of the operation.
115  * @retval Returns enBTRCoreSuccess on success, appropiate error code otherwise.
116  */
117 enBTRCoreRet BTRCore_LE_DeInit (tBTRCoreLeHdl hBTRCoreLe, void* apBtConn, const char* apBtAdapter);
118 
119 /**
120  * @brief This API fetches the GATT property value that is supported.
121  *
122  * @param[in] hBTRCoreLe Handle to bluetooth low energy device interface.
123  * @param[in] apBtDevPath Device Id of the remote device.
124  * @param[in] apBtUuid UUID to distinguish the devices.
125  * @param[in] aenBTRCoreLEGattProp Indicates the operation to be performed.
126  * @param[out] apBtPropValue Property values.
127  *
128  * @return Returns the status of the operation.
129  * @retval Returns enBTRCoreSuccess on success, appropiate error code otherwise.
130  */
131 enBTRCoreRet BTRCore_LE_GetGattProperty (tBTRCoreLeHdl hBTRCoreLe, tBTRCoreDevId atBTRCoreDevId,
132  const char* apBtUuid, enBTRCoreLEGattProp aenBTRCoreLEGattProp, void* apBtPropValue);
133 
134 /**
135  * @brief This API is used to perform read, write, notify operations on LE devices.
136  *
137  * @param[in] hBTRCoreLe Handle to bluetooth low energy device interface.
138  * @param[in] apBtDevPath Device Id of the remote device.
139  * @param[in] apBtUuid UUID to distinguish the devices.
140  * @param[in] aenBTRCoreLEGattOp Indicates the operation to be performed.
141  * @param[out] rpLeOpRes Indicates the result of the operation.
142  *
143  * @return Returns the status of the operation.
144  * @retval Returns enBTRCoreSuccess on success, appropiate error code otherwise.
145  */
146 enBTRCoreRet BtrCore_LE_PerformGattOp (tBTRCoreLeHdl hBTRCoreLe, tBTRCoreDevId atBTRCoreDevId,
147  const char* apBtUuid, enBTRCoreLEGattOp aenBTRCoreLEGattOp, char* apLeOpArg, char* rpLeOpRes);
148 
149 /**
150  * @brief This API is used to invoke method calls to RegisterAdvertisement and RegisterApplication to
151  * begin LE advertising
152  *
153  * @param[in] hBTRCoreLe Handle to bluetooth low energy device interface.
154  * @param[in] apBtConn Dbus connection..
155  * @param[in] apBtAdapter Bluetooth adapter address.
156  *
157  * @return Returns the status of the operation.
158  * @retval Returns enBTRCoreSuccess on success, appropiate error code otherwise.
159  */
160 enBTRCoreRet BTRCore_LE_StartAdvertisement(tBTRCoreLeHdl hBTRCoreLe, void* apBtConn, const char* apBtAdapter);
161 
162 /**
163  * @brief This API is used to store the advertisement type supported by device
164  *
165  * @param[in] hBTRCoreLe Handle to bluetooth low energy device interface.
166  * @param[in] aAdvtType Advertisement type
167  *
168  * @return Returns the status of the operation.
169  * @retval Returns enBTRCoreSuccess on success, appropiate error code otherwise.
170  */
171 enBTRCoreRet BTRCore_LE_SetAdvertisementType(tBTRCoreLeHdl hBTRCoreLe, char* aAdvtType);
172 
173 /**
174  * @brief This API is used to store the UUIDs that would be advertised by the device during the advertisement
175  *
176  * @param[in] hBTRCoreLe Handle to bluetooth low energy device interface.
177  * @param[in] aUUID Service UUID
178  *
179  * @return Returns the status of the operation.
180  * @retval Returns enBTRCoreSuccess on success, appropiate error code otherwise.
181  */
182 enBTRCoreRet BTRCore_LE_SetServiceUUIDs(tBTRCoreLeHdl hBTRCoreLe, char* aUUID);
183 
184 /**
185  * @brief This API is used to store the manufacturer data to be sent with the advertisement
186  *
187  * @param[in] hBTRCoreLe Handle to bluetooth low energy device interface.
188  * @param[in] aManfId Manufacturer ID
189  * @param[in] aDeviceDetails Manufacturer device details
190  * @param[in] aLenManfData Length of manufacturer data
191  *
192  * @return Returns the status of the operation.
193  * @retval Returns enBTRCoreSuccess on success, appropiate error code otherwise.
194  */
195 enBTRCoreRet BTRCore_LE_SetManufacturerData(tBTRCoreLeHdl hBTRCoreLe, unsigned short aManfId, unsigned char* aDeviceDetails, int aLenManfData);
196 
197 /**
198  * @brief This API is used to enable/disable sending tranmission power with the advertisement data
199 
200  * @param[in] hBTRCoreLe Handle to bluetooth low energy device interface.
201  * @param[in] aTxPower Enable or disable sending Tx power
202  *
203  * @return Returns the status of the operation.
204  * @retval Returns enBTRCoreSuccess on success, appropiate error code otherwise.
205  */
206 enBTRCoreRet BTRCore_LE_SetEnableTxPower(tBTRCoreLeHdl hBTRCoreLe, BOOLEAN aTxPower);
207 
208 /**
209  * @brief This API is used to invoke method calls to UnRegisterAdvertisement and UnRegisterApplication to
210  * stop LE advertising
211  *
212  * @param[in] hBTRCoreLe Handle to bluetooth low energy device interface.
213  * @param[in] apBtConn Dbus connection..
214  * @param[in] apBtAdapter Bluetooth adapter address.
215  *
216  * @return Returns the status of the operation.
217  * @retval Returns enBTRCoreSuccess on success, appropiate error code otherwise.
218  */
219 enBTRCoreRet BTRCore_LE_StopAdvertisement(tBTRCoreLeHdl hBTRCoreLe, void* apBtConn, const char* apBtAdapter);
220 
221 /**
222  * @brief This API is used to add service info for the advertisement
223  *
224  * @param[in] hBTRCoreLe Handle to bluetooth low energy device interface.
225  * @param[in] aBtdevAddr BT Address of advertising device
226  * @param[in] aUUID UUID of the service
227  * @param[in] aServiceType Indicates Primary or secondary service
228  * @param[out] aNumGattServices Returns number of gatt services added
229  *
230  * @return Returns the pointer to the service added
231  * @retval Returns NULL on failure, appropiate address otherwise.
232  */
233 int* BTRCore_LE_AddGattServiceInfo(tBTRCoreLeHdl hBTRCoreLe, const char* apBtAdapter, char* aBtdevAddr, char* aUUID, BOOLEAN aServiceType, int *aNumGattServices);
234 
235 /**
236  * @brief This API is used to add gatt characteristic info for the advertisement
237  *
238  * @param[in] hBTRCoreLe Handle to bluetooth low energy device interface.
239  * @param[in] aBtdevAddr BT Address of advertising device
240  * @param[in] aParentUUID Service the characteristic belongs to
241  * @param[in] aUUID UUID of the service
242  * @param[in] aCharFlags Bit field to indicate usage of characteristic
243  * @param[in] aValue Value of the characteristic if applicable
244  *
245  * @return Returns the pointer to the characteristic added
246  * @retval Returns NULL on failure, appropiate address otherwise.
247  */
248 int* BTRCore_LE_AddGattCharInfo(tBTRCoreLeHdl hBTRCoreLe, const char* apBtAdapter, char* aBtdevAddr, char* aParentUUID, char* aUUID, unsigned short aCharFlags, char* aValue);
249 
250 /**
251  * @brief This API is used to add gatt descriptor info for the advertisement
252  *
253  * @param[in] hBTRCoreLe Handle to bluetooth low energy device interface.
254  * @param[in] aBtdevAddr BT Address of advertising device
255  * @param[in] aParentUUID Characteristic the descriptor belongs to
256  * @param[in] aUUID UUID of the service
257  * @param[in] aDescFlags Bit field to indicate usage of characteristic
258  * @param[out] aValue Value of the descriptor if applicable
259  *
260  * @return Returns the pointer to the characteristic added
261  * @retval Returns NULL on failure, appropiate address otherwise.
262  */
263 int* BTRCore_LE_AddGattDescInfo(tBTRCoreLeHdl hBTRCoreLe, const char* apBtAdapter, char* aBtdevAddr, char* aParentUUID, char* aUUID, unsigned short aDescFlags, char* aValue);
264 
265 /**
266  * @brief This API Returns the specified property value associated with the UUID
267  *
268  * @param[in] hBTRCoreLe Handle to bluetooth low energy device interface.
269  * @param[in] aUUID UUID of the Gatt element
270  * @param[in] aGattProp Gatt property to be fetched
271  * @param[out] aValue Value of the property
272  *
273  * @return Returns the status of the operation.
274  * @retval Returns enBTRCoreSuccess on success, appropiate error code otherwise.
275  */
276 enBTRCoreRet BTRCore_LE_SetPropertyValue(tBTRCoreLeHdl hBTRCoreLe, char *aUUID, char *aValue, enBTRCoreLEGattProp aElement);
277 
278 /* Outgoing callbacks Registration Interfaces */
279 /* BTRCore_LE_RegisterStatusUpdateCb - Callback for LE dev notifications and state changes */
280 enBTRCoreRet BTRCore_LE_RegisterStatusUpdateCb (tBTRCoreLeHdl hBTRCoreLe, fPtr_BTRCore_LeStatusUpdateCb afPtr_BTRCore_LeStatusUpdateCb, void* apUserData);
281 
282 /* @} */ // End of group BLUETOOTH_APIS
283 
284 #endif // __BTR_CORE_LE_H__
BOOLEAN
unsigned char BOOLEAN
DTCP Manager return codes.
Definition: dtcpmgr.h:163
BTRCore_LE_GetGattProperty
enBTRCoreRet BTRCore_LE_GetGattProperty(tBTRCoreLeHdl hBTRCoreLe, tBTRCoreDevId atBTRCoreDevId, const char *apBtUuid, enBTRCoreLEGattProp aenBTRCoreLEGattProp, void *apBtPropValue)
This API fetches the GATT property value that is supported.
Definition: btrCore_le.c:1304
BtrCore_LE_PerformGattOp
enBTRCoreRet BtrCore_LE_PerformGattOp(tBTRCoreLeHdl hBTRCoreLe, tBTRCoreDevId atBTRCoreDevId, const char *apBtUuid, enBTRCoreLEGattOp aenBTRCoreLEGattOp, char *apLeOpArg, char *rpLeOpRes)
This API is used to perform read, write, notify operations on LE devices.
Definition: btrCore_le.c:1468
BTRCore_LE_SetPropertyValue
enBTRCoreRet BTRCore_LE_SetPropertyValue(tBTRCoreLeHdl hBTRCoreLe, char *aUUID, char *aValue, enBTRCoreLEGattProp aElement)
This API Returns the specified property value associated with the UUID.
Definition: btrCore_le.c:1267
BTRCore_LE_StartAdvertisement
enBTRCoreRet BTRCore_LE_StartAdvertisement(tBTRCoreLeHdl hBTRCoreLe, void *apBtConn, const char *apBtAdapter)
This API is used to invoke method calls to RegisterAdvertisement and RegisterApplication to begin LE ...
Definition: btrCore_le.c:954
BTRCore_LE_AddGattDescInfo
int * BTRCore_LE_AddGattDescInfo(tBTRCoreLeHdl hBTRCoreLe, const char *apBtAdapter, char *aBtdevAddr, char *aParentUUID, char *aUUID, unsigned short aDescFlags, char *aValue)
This API is used to add gatt descriptor info for the advertisement.
Definition: btrCore_le.c:1215
BTRCore_LE_SetEnableTxPower
enBTRCoreRet BTRCore_LE_SetEnableTxPower(tBTRCoreLeHdl hBTRCoreLe, BOOLEAN aTxPower)
This API is used to enable/disable sending tranmission power with the advertisement data.
Definition: btrCore_le.c:1088
BTRCore_LE_SetServiceUUIDs
enBTRCoreRet BTRCore_LE_SetServiceUUIDs(tBTRCoreLeHdl hBTRCoreLe, char *aUUID)
This API is used to store the UUIDs that would be advertised by the device during the advertisement.
Definition: btrCore_le.c:1032
BTRCore_LE_AddGattCharInfo
int * BTRCore_LE_AddGattCharInfo(tBTRCoreLeHdl hBTRCoreLe, const char *apBtAdapter, char *aBtdevAddr, char *aParentUUID, char *aUUID, unsigned short aCharFlags, char *aValue)
This API is used to add gatt characteristic info for the advertisement.
Definition: btrCore_le.c:1163
BTRCore_LE_SetManufacturerData
enBTRCoreRet BTRCore_LE_SetManufacturerData(tBTRCoreLeHdl hBTRCoreLe, unsigned short aManfId, unsigned char *aDeviceDetails, int aLenManfData)
This API is used to store the manufacturer data to be sent with the advertisement.
Definition: btrCore_le.c:1058
BTRCore_LE_StopAdvertisement
enBTRCoreRet BTRCore_LE_StopAdvertisement(tBTRCoreLeHdl hBTRCoreLe, void *apBtConn, const char *apBtAdapter)
This API is used to invoke method calls to UnRegisterAdvertisement and UnRegisterApplication to stop ...
Definition: btrCore_le.c:981
BTRCore_LE_Init
enBTRCoreRet BTRCore_LE_Init(tBTRCoreLeHdl *phBTRCoreLe, void *apBtConn, const char *apBtAdapter)
This API registers the callback function that has to be called when the LE device are added or remove...
Definition: btrCore_le.c:881
BTRCore_LE_DeInit
enBTRCoreRet BTRCore_LE_DeInit(tBTRCoreLeHdl hBTRCoreLe, void *apBtConn, const char *apBtAdapter)
This API deinitializes the LE device.
Definition: btrCore_le.c:931
BTRCore_LE_SetAdvertisementType
enBTRCoreRet BTRCore_LE_SetAdvertisementType(tBTRCoreLeHdl hBTRCoreLe, char *aAdvtType)
This API is used to store the advertisement type supported by device.
Definition: btrCore_le.c:1006
_stBTRCoreLeGattInfo
Definition: btrCore_le.h:74
BTRCore_LE_AddGattServiceInfo
int * BTRCore_LE_AddGattServiceInfo(tBTRCoreLeHdl hBTRCoreLe, const char *apBtAdapter, char *aBtdevAddr, char *aUUID, BOOLEAN aServiceType, int *aNumGattServices)
This API is used to add service info for the advertisement.
Definition: btrCore_le.c:1108