• 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 /**
17  * @addtogroup Bluetooth
18  * @{
19  *
20  * @brief Provides basic Bluetooth capabilities.
21  *
22  * This module allows you to enable and disable Bluetooth, and access basic Bluetooth capabilities.\n
23  * Bluetooth uses profiles such as BT-GAP, BLE, BLE-GATT, BT-data transmission, HFP, A2DP, AVRCP, MAP, and PBAP.
24  *
25  * @since 6
26  */
27 
28 /**
29  * @file ohos_bt_gatt.h
30  *
31  * @brief Declares basic GATT data structures and functions, such as advertising and scan functions.
32  *
33  * @since 6
34  */
35 
36 
37 #ifndef OHOS_BT_GATT_H
38 #define OHOS_BT_GATT_H
39 
40 #include "ohos_bt_def.h"
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /**
47  * @brief Enumerates advertising filtering parameters.
48  *
49  * The parameters specify whether the advertiser uses a whitelist to filter scan or connection requests from scanners.
50  *
51  * @since 6
52  */
53 typedef enum {
54     /** Processing scan and connection requests from all devices */
55     OHOS_BLE_ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY = 0x00,
56     /** Processing connection requests from all devices and only the scan requests from devices in the whitelist */
57     OHOS_BLE_ADV_FILTER_ALLOW_SCAN_WLST_CON_ANY = 0x01,
58     /** Processing scan requests from all devices and only the connection requests from devices in the whitelist */
59     OHOS_BLE_ADV_FILTER_ALLOW_SCAN_ANY_CON_WLST = 0x02,
60     /** Processing only the scan and connection requests from devices in the whitelist */
61     OHOS_BLE_ADV_FILTER_ALLOW_SCAN_WLST_CON_WLST = 0x03,
62 } BleAdvFilter;
63 
64 /**
65  * @brief Enumerates advertisement types.
66  *
67  * @since 6
68  */
69 typedef enum {
70     /** Connectable and scannable undirected advertisement (default) */
71     OHOS_BLE_ADV_IND = 0x00,
72     /** Connectable directed advertisement with a high duty ratio */
73     OHOS_BLE_ADV_DIRECT_IND_HIGH = 0x01,
74     /** Scannable undirected advertisement */
75     OHOS_BLE_ADV_SCAN_IND = 0x02,
76     /** Unconnectable undirected advertisement */
77     OHOS_BLE_ADV_NONCONN_IND = 0x03,
78     /** Connectable directed advertisement with a low duty ratio */
79     OHOS_BLE_ADV_DIRECT_IND_LOW  = 0x04,
80 } BleAdvType;
81 
82 /**
83  * @brief Enumerates I/O capability modes.
84  *
85  * @since 6
86  */
87 typedef enum {
88     /** <b>DisplayOnly</b>: display capability only */
89     OHOS_BLE_IO_CAP_OUT = 0x00,
90     /** <b>DisplayYesNo</b>: YES/NO input and display capabilities */
91     OHOS_BLE_IO_CAP_IO,
92     /**
93      * <b>KeyboardOnly</b>: Input of a number from 0 to 9, the confirmation key, and YES/NO,
94      * with no display capability
95      */
96     OHOS_BLE_IO_CAP_IN,
97     /** <b>NoInputNoOutput</b>: no I/O capability */
98     OHOS_BLE_IO_CAP_NONE,
99     /**
100      * <b>KeyboardDisplay</b>: Input of a number from 0 to 9, the confirmation key, and YES/NO,
101      * with the display capability
102      */
103     OHOS_BLE_IO_CAP_KBDISP
104 } BleIoCapMode;
105 
106 /**
107  * @brief Enumerates authentication modes for secure connection requests.
108  *
109  * @since 6
110  */
111 typedef enum {
112     /** No bonding */
113     OHOS_BLE_AUTH_NO_BOND = 0x00,
114     /** Bonding */
115     OHOS_BLE_AUTH_BOND,
116     /** MITM only */
117     OHOS_BLE_AUTH_REQ_MITM,
118     /** Secure connection only */
119     OHOS_BLE_AUTH_REQ_SC_ONLY,
120     /** Secure connection and bonding */
121     OHOS_BLE_AUTH_REQ_SC_BOND,
122     /** Secure connection and MITM */
123     OHOS_BLE_AUTH_REQ_SC_MITM,
124     /** Secure connection, MITM, and bonding */
125     OHOS_BLE_AUTH_REQ_SC_MITM_BOND
126 } BleAuthReqMode;
127 
128 /**
129  * @brief Enumerates BLE scan types.
130  *
131  * @since 6
132  */
133 typedef enum {
134     /** A passive scan with no scan request */
135     OHOS_BLE_SCAN_TYPE_PASSIVE = 0x00,
136     /** An active scan that may contain a scan request */
137     OHOS_BLE_SCAN_TYPE_ACTIVE,
138 } BleScanType;
139 
140 /**
141  * @brief Enumerates policies for filtering advertisements in a BLE scan.
142  *
143  * @since 6
144  */
145 typedef enum {
146     /**
147      * Accepting all advertisements except the directed advertisements
148      * that are not sent to the current device (default)
149      */
150     OHOS_BLE_SCAN_FILTER_POLICY_ACCEPT_ALL = 0x00,
151     /**
152      * Accepting advertisements from devices in the whitelist and ignoring the directed advertisements
153      * that are not sent to the current device */
154     OHOS_BLE_SCAN_FILTER_POLICY_ONLY_WHITE_LIST,
155     /**
156      * Accepting all undirected advertisements, directed advertisements sent by advertisers with
157      * resolvable private addresses, and all the directed advertisements sent to the current device
158      */
159     OHOS_BLE_SCAN_FILTER_POLICY_ACCEPT_ALL_AND_RPA,
160     /**
161      * Accepting all undirected advertisements from the devices in the whitelist,
162      * directed advertisements sent by advertisers with resolvable private addresses,
163      * and all the directed advertisements sent to the current device
164      */
165     OHOS_BLE_SCAN_FILTER_POLICY_ONLY_WHITE_LIST_AND_RPA
166 } BleScanFilterPolicy;
167 
168 /**
169  * @brief Enumerates advertisement types in the BLE scan result.
170  *
171  * @since 6
172  */
173 typedef enum {
174     /** Extended, unconnectable, unscannable, and undirected advertisement */
175     OHOS_BLE_EVT_NON_CONNECTABLE_NON_SCANNABLE = 0x00,
176     /** Extended, unconnectable, unscannable, and directed advertisement */
177     OHOS_BLE_EVT_NON_CONNECTABLE_NON_SCANNABLE_DIRECTED = 0x04,
178     /** Extended, connectable, and undirected advertisement */
179     OHOS_BLE_EVT_CONNECTABLE = 0x01,
180     /** Extended, connectable, and directed advertisement */
181     OHOS_BLE_EVT_CONNECTABLE_DIRECTED = 0x05,
182     /** Extended, scannable, and undirected advertisement */
183     OHOS_BLE_EVT_SCANNABLE = 0x02,
184     /** Extended, scannable, and directed advertisement */
185     OHOS_BLE_EVT_SCANNABLE_DIRECTED = 0x06,
186 
187     /** Legacy, unconnectable, and undirected advertisement */
188     OHOS_BLE_EVT_LEGACY_NON_CONNECTABLE = 0x10,
189     /** Legacy, scannable, and undirected advertisement */
190     OHOS_BLE_EVT_LEGACY_SCANNABLE = 0x12,
191     /** Legacy, connectable, scannable, and undirected advertisement */
192     OHOS_BLE_EVT_LEGACY_CONNECTABLE = 0x13,
193     /** Legacy, connectable, and directed advertisement */
194     OHOS_BLE_EVT_LEGACY_CONNECTABLE_DIRECTED = 0x15,
195     /** Legacy scan response corresponding to <b>ADV_SCAN_IND</b> */
196     OHOS_BLE_EVT_LEGACY_SCAN_RSP_TO_ADV_SCAN = 0x1A,
197     /** Legacy scan response corresponding to <b>ADV_IND</b> */
198     OHOS_BLE_EVT_LEGACY_SCAN_RSP_TO_ADV = 0x1B
199 } BleScanResultEvtType;
200 
201 /**
202  * @brief Enumerates data integrity types for a BLE scan result.
203  *
204  * @since 6
205  */
206 typedef enum {
207     /** Complete data or the last segment */
208     OHOS_BLE_DATA_COMPLETE = 0x00,
209     /** Incomplete data, with more data to come */
210     OHOS_BLE_DATA_INCOMPLETE_MORE_TO_COME = 0x01,
211     /** Incomplete truncated data, with no more data to come */
212     OHOS_BLE_DATA_INCOMPLETE_TRUNCATED = 0x02,
213 } BleScanResultDataStatus;
214 
215 /**
216  * @brief Enumerates address types for a BLE scan result.
217  *
218  * @since 6
219  */
220 typedef enum {
221     /** Public device address */
222     OHOS_BLE_PUBLIC_DEVICE_ADDRESS = 0x00,
223     /** Random device address */
224     OHOS_BLE_RANDOM_DEVICE_ADDRESS = 0x01,
225     /** Public identity address */
226     OHOS_BLE_PUBLIC_IDENTITY_ADDRESS = 0x02,
227     /** Random (static) identity address */
228     OHOS_BLE_RANDOM_STATIC_IDENTITY_ADDRESS = 0x03,
229     /** Unresolvable random device address */
230     OHOS_BLE_UNRESOLVABLE_RANDOM_DEVICE_ADDRESS = 0xFE,
231     /** No address (anonymous advertisement) */
232     OHOS_BLE_NO_ADDRESS = 0xFF,
233 } BleScanResultAddrType;
234 
235 /**
236  * @brief Enumerates PHY types for a BLE scan result.
237  *
238  * @since 6
239  */
240 typedef enum {
241     /** No advertisement packet */
242     OHOS_BLE_SCAN_PHY_NO_PACKET = 0x00,
243     /** 1M PHY */
244     OHOS_BLE_SCAN_PHY_1M = 0x01,
245     /** 2M PHY */
246     OHOS_BLE_SCAN_PHY_2M = 0x02,
247     /** Coded PHY */
248     OHOS_BLE_SCAN_PHY_CODED = 0x03
249 } BleScanResultPhyType;
250 
251 /**
252  * @brief Defines BLE advertising/scan response data.
253  *
254  * @since 6
255  */
256 typedef struct {
257     /** Advertising data length */
258     unsigned short advLength;
259     /** Advertising data */
260     char *advData;
261     /** Scan response data length */
262     unsigned short scanRspLength;
263     /** Scan response data */
264     char *scanRspData;
265 } BleConfigAdvData;
266 
267 /**
268  * @brief Defines BLE advertising parameters.
269  *
270  * @since 6
271  */
272 typedef struct {
273     /**
274      * Minimum advertising interval.
275      * It is calculated as follows: [N * 0.625 ms], where N indicates the value of this field.
276      */
277     int minInterval;
278     /**
279      * Maximum advertising interval.
280      * It is calculated as follows: [N * 0.625 ms], where N indicates the value of this field.
281      */
282     int maxInterval;
283     /** Advertising type */
284     BleAdvType advType;
285     /** Local address type */
286     unsigned char ownAddrType;
287     /** Peer address type */
288     unsigned char peerAddrType;
289     /** Peer address */
290     BdAddr peerAddr;
291     /**
292      * Advertising channel to be used. For example, <b>0x01</b> indicates that channel 37 is to be used,
293      * and <b>0x07</b> indicates that channels 37, 38, and 39 are used.
294      */
295     int channelMap;
296     /** Advertisement filtering policy based on a whitelist */
297     BleAdvFilter advFilterPolicy;
298     /** Transmit power (dBm) */
299     int txPower;
300     /** Advertising duration. It is calculated as follows: [N * 10 ms], where N indicates the value of this field. */
301     int duration;
302 } BleAdvParams;
303 
304 /**
305  * @brief Defines BLE scan parameters.
306  *
307  * @since 6
308  */
309 typedef struct {
310     /** Scan interval. It is calculated as follows: [N * 0.625 ms], where N indicates the value of this field. */
311     unsigned short scanInterval;
312     /** Scan window. It is calculated as follows: [N * 0.625 ms], where N indicates the value of this field. */
313     unsigned short scanWindow;
314     /** Scan type, as enumerated in {@link BleScanType} */
315     unsigned char scanType;
316     /**
317      * PHY on which the advertising packets are received.
318      * <b>bit0</b> indicates 1M PHY and <b>bit2</b> indicates LE Coded PHY.
319      * <b>bit0</b> and <b>bit2</b> can both be set to <b>1</b>. All other bits are reserved for future use.
320      */
321     unsigned char scanPhy;
322     /** Policy for filtering the scan result, as enumerated in {@link BleScanFilterPolicy} */
323     unsigned char scanFilterPolicy;
324 } BleScanParams;
325 
326 /**
327  * @brief Defines raw data for the BLE advertising and scan response.
328  *
329  * This structure is available for system applications only.
330  *
331  * @since 6
332  */
333 typedef struct {
334     /** Advertising data */
335     unsigned char *advData;
336     /** Advertising data length */
337     unsigned int advDataLen;
338     /** Scan response data */
339     unsigned char *rspData;
340     /** Scan response data length */
341     unsigned int rspDataLen;
342 } StartAdvRawData;
343 
344 /**
345  * @brief Defines the BLE scan result data.
346  *
347  * @since 6
348  */
349 typedef struct {
350     /** Advertisement type, as enumerated in {@link BleScanResultEvtType} */
351     unsigned char eventType;
352     /** Data status, as enumerated in {@link BleScanResultDataStatus} */
353     unsigned char dataStatus;
354     /** Address type, as enumerated in {@link BleScanResultAddrType}. Value <b>0xFE</b> is unavailable. */
355     unsigned char addrType;
356     /** Address */
357     BdAddr addr;
358     /**
359      * PHY type of a primary advertisement, as enumerated in {@link BleScanResultPhyType}.
360      * The value can only be <b>0x01</b> or <b>0x03</b>.
361      */
362     unsigned char primaryPhy;
363     /**
364      * PHY type of a secondary advertisement.
365      * The value can be any of the enumerations of {@link BleScanResultPhyType}.
366      */
367     unsigned char secondaryPhy;
368     /**
369      * Advertising SID in the ADI field of the PDU or of the original scannable advertisement (for scan responses).
370      * Value <b>0xFF</b> indicates that no ADI field is available.
371      */
372     unsigned char advSid;
373     /**
374      * Transmit power. The value ranges from -127 to +20 dBm.
375      * Value <b>0x7F</b> indicates that this field is invalid.
376      */
377     char txPower;
378     /** RSSI. The value ranges from -127 to +20 dBm. Value <b>0x7F</b> indicates that this field is invalid. */
379     char rssi;
380     /**
381      * Periodic advertising interval.
382      * It is calculated as follows: [N * 1.25 ms], where N indicates the value of this field.
383      * Value <b>0x00</b> indicates that this field is invalid.
384      */
385     unsigned short periodicAdvInterval;
386     /**
387      * Address type for directed advertising, as enumerated in {@link BleScanResultAddrType}.
388      * Value <b>0xFF</b> is unavailable.
389      */
390     unsigned char directAddrType;
391     /** Address for directed advertising */
392     BdAddr directAddr;
393     /** Advertising data length */
394     unsigned char advLen;
395     /** Advertising data */
396     unsigned char *advData;
397 } BtScanResultData;
398 
399 /**
400  * @brief Called when advertising is enabled. For details, see {@link BleStartAdv}.
401  *
402  * @since 6
403  */
404 typedef void (*AdvEnableCallback)(int advId, int status);
405 
406 /**
407  * @brief Called when advertising is disabled. For details, see {@link BleStopAdv}.
408  *
409  * @since 6
410  */
411 typedef void (*AdvDisableCallback)(int advId, int status);
412 
413 /**
414  * @brief Called when advertising data is set. For details, see {@link BleSetAdvData}.
415  *
416  * @since 6
417  */
418 typedef void (*AdvDataCallback)(int advId, int status);
419 
420 /**
421  * @brief Called when advertising parameters are updated. For details, see {@link BleUpdateAdv}
422  *
423  * @since 6
424  */
425 typedef void (*AdvUpdateCallback)(int advId, int status);
426 
427 /**
428  * @brief Called when a secure access request is received.
429  *
430  * {@link BleGattSecurityRsp} is used to grant the secure access permission.
431  *
432  * @since 6
433  */
434 typedef void (*SecurityRespondCallback)(const BdAddr *bdAddr);
435 
436 /**
437  * @brief Called when the scan result is received.
438  *
439  * @since 6
440  */
441 typedef void (*ScanResultCallback)(BtScanResultData *scanResultdata);
442 
443 /**
444  * @brief Called when scan parameters are set.
445  *
446  * @since 6
447  */
448 typedef void (*ScanParameterSetCompletedCallback)(int clientId, int status);
449 
450 /**
451  * @brief Defines GATT callbacks.
452  *
453  * @since 6
454  */
455 typedef struct {
456     /** Called when advertising is enabled. */
457     AdvEnableCallback advEnableCb;
458     /** Called when advertising is disabled. */
459     AdvDisableCallback advDisableCb;
460     /** Called when advertising data is set. */
461     AdvDataCallback advDataCb;
462     /** Called when advertising parameters are updated. */
463     AdvUpdateCallback advUpdateCb;
464     /** Called when a secure access request is received. */
465     SecurityRespondCallback securityRespondCb;
466     /** Called when the scan result is received. */
467     ScanResultCallback scanResultCb;
468     /** Called when scan parameters are set. */
469     ScanParameterSetCompletedCallback scanParamSetCb;
470 } BtGattCallbacks;
471 
472 /**
473  * @brief Initializes the Bluetooth protocol stack.
474  *
475  * @return Returns {@link OHOS_BT_STATUS_SUCCESS} if the Bluetooth protocol stack is initialized;
476  * returns an error code defined in {@link BtStatus} otherwise.
477  * @since 6
478  */
479 int InitBtStack(void);
480 
481 /**
482  * @brief Enables the Bluetooth protocol stack.
483  *
484  * @return Returns {@link OHOS_BT_STATUS_SUCCESS} if the Bluetooth protocol stack is enabled;
485  * returns an error code defined in {@link BtStatus} otherwise.
486  * @since 6
487  */
488 int EnableBtStack(void);
489 
490 /**
491  * @brief Disables the Bluetooth protocol stack.
492  *
493  * @return Returns {@link OHOS_BT_STATUS_SUCCESS} if the Bluetooth protocol stack is disabled;
494  * returns an error code defined in {@link BtStatus} otherwise.
495  * @since 6
496  */
497 int DisableBtStack(void);
498 
499 /**
500  * @brief Sets the Bluetooth device name.
501  *
502  * @param name Indicates the pointer to the name to set.
503  * @param len Indicates the length of the name to set.
504  * @return Returns {@link OHOS_BT_STATUS_SUCCESS} if the Bluetooth device name is set;
505  * returns an error code defined in {@link BtStatus} otherwise.
506  * @since 6
507  */
508 int SetDeviceName(const char *name, unsigned int len);
509 
510 /**
511  * @brief Sets advertising data.
512  *
513  * @param advId Indicates the advertisement ID, which is allocated by the upper layer of the advertiser.
514  * @param data Indicates the pointer to the advertising data. For details, see {@link BleConfigAdvData}.
515  * @return Returns {@link OHOS_BT_STATUS_SUCCESS} if advertising data is set;
516  * returns an error code defined in {@link BtStatus} otherwise.
517  * @since 6
518  */
519 int BleSetAdvData(int advId, const BleConfigAdvData *data);
520 
521 /**
522  * @brief Starts advertising.
523  *
524  * @param advId Indicates the advertisement ID, which is allocated by the upper layer of the advertiser.
525  * @param param Indicates the pointer to the advertising parameters. For details, see {@link BleAdvParams}.
526  * @return Returns {@link OHOS_BT_STATUS_SUCCESS} if advertising is started;
527  * returns an error code defined in {@link BtStatus} otherwise.
528  * @since 6
529  */
530 int BleStartAdv(int advId, const BleAdvParams *param);
531 
532 /**
533  * @brief Stops advertising.
534  *
535  * @param advId Indicates the advertisement ID, which is allocated by the upper layer of the advertiser.
536  * @return Returns {@link OHOS_BT_STATUS_SUCCESS} if advertising is stopped;
537  * returns an error code defined in {@link BtStatus} otherwise.
538  * @since 6
539  */
540 int BleStopAdv(int advId);
541 
542 /**
543  * @brief Updates advertising parameters.
544  *
545  * @param advId Indicates the advertisement ID, which is allocated by the upper layer of the advertiser.
546  * @param param Indicates the pointer to the advertising parameters. For details, see {@link BleAdvParams}.
547  * @return Returns {@link OHOS_BT_STATUS_SUCCESS} if advertising parameters are updated;
548  * returns an error code defined in {@link BtStatus} otherwise.
549  * @since 6
550  */
551 int BleUpdateAdv(int advId, const BleAdvParams *param);
552 
553 /**
554  * @brief Sets the secure I/O capability mode.
555  *
556  * @param mode Indicates the capability mode to set. For details, see {@link BleIoCapMode}.
557  * @return Returns {@link OHOS_BT_STATUS_SUCCESS} if the capability mode is set;
558  * returns an error code defined in {@link BtStatus} otherwise.
559  * @since 6
560  */
561 int BleSetSecurityIoCap(BleIoCapMode mode);
562 
563 /**
564  * @brief Sets the authentication mode for secure connection requests.
565  *
566  * @param mode Indicates the authentication mode to set. For details, see {@link BleAuthReqMode}.
567  * @return Returns {@link OHOS_BT_STATUS_SUCCESS} if the authentication mode is set;
568  * returns an error code defined in {@link BtStatus} otherwise.
569  * @since 6
570  */
571 int BleSetSecurityAuthReq(BleAuthReqMode mode);
572 
573 /**
574  * @brief Responds to a secure connection request.
575  *
576  * @param bdAddr Indicates the address of the device that sends the request.
577  * @param accept Specifies whether to accept the request. The value <b>true</b> means to accept the request,
578  * and <b>false</b> means to reject the request.
579  * @return Returns {@link OHOS_BT_STATUS_SUCCESS} if the request is responded to;
580  * returns an error code defined in {@link BtStatus} otherwise.
581  * @since 6
582  */
583 int BleGattSecurityRsp(BdAddr bdAddr, bool accept);
584 
585 /**
586  * @brief Obtains the device MAC address.
587  *
588  * @param mac Indicates the pointer to the device MAC address.
589  * @param len Indicates the length of the device MAC address.
590  * @return Returns {@link OHOS_BT_STATUS_SUCCESS} if the device MAC address is obtained;
591  * returns an error code defined in {@link BtStatus} otherwise.
592  * @since 6
593  */
594 int ReadBtMacAddr(unsigned char *mac, unsigned int len);
595 
596 /**
597  * @brief Sets scan parameters.
598  *
599  * @param clientId Indicates the client ID, which is obtained during client registration.
600  * @param param Indicates the pointer to the scan parameters. For details, see {@link BleScanParams}.
601  * @return Returns {@link OHOS_BT_STATUS_SUCCESS} if the scan parameters are set;
602  * returns an error code defined in {@link BtStatus} otherwise.
603  * @since 6
604  */
605 int BleSetScanParameters(int clientId, BleScanParams *param);
606 
607 /**
608  * @brief Starts a scan.
609  *
610  * @return Returns {@link OHOS_BT_STATUS_SUCCESS} if the scan is started;
611  * returns an error code defined in {@link BtStatus} otherwise.
612  * @since 6
613  */
614 int BleStartScan(void);
615 
616 /**
617  * @brief Stops a scan.
618  *
619  * @return Returns {@link OHOS_BT_STATUS_SUCCESS} if the scan is stopped;
620  * returns an error code defined in {@link BtStatus} otherwise.
621  * @since 6
622  */
623 int BleStopScan(void);
624 
625 /**
626  * @brief Registers GATT callbacks.
627  *
628  * @param func Indicates the pointer to the callbacks to register. For details, see {@link BtGattCallbacks}.
629  * @return Returns {@link OHOS_BT_STATUS_SUCCESS} if the GATT callbacks are registered;
630  * returns an error code defined in {@link BtStatus} otherwise.
631  * @since 6
632  */
633 int BleGattRegisterCallbacks(BtGattCallbacks *func);
634 
635 /**
636  * @brief Sets advertising data and parameters and starts advertising.
637  *
638  * This function is available for system applications only. \n
639  *
640  * @param advId Indicates the pointer to the advertisement ID.
641  * @param rawData Indicates the advertising data. For details, see {@link StartAdvRawData}.
642  * @param advParam Indicates the advertising parameters. For details, see {@link BleAdvParams}.
643  * @return Returns {@link OHOS_BT_STATUS_SUCCESS} if the operation is successful;
644  * returns an error code defined in {@link BtStatus} otherwise.
645  * @since 6
646  */
647 int BleStartAdvEx(int *advId, const StartAdvRawData rawData, BleAdvParams advParam);
648 
649 #ifdef __cplusplus
650 }
651 #endif
652 #endif
653 /** @} */