簡介
藍(lán)牙服務(wù)組件為設(shè)備提供接入與使用Bluetooth的相關(guān)接口,包括BLE設(shè)備gatt相關(guān)的操作,以及BLE廣播、掃描等功能。
目錄
/foundation/communication/bluetooth
├── interfaces # 接口代碼
│ └── innerkits # 系統(tǒng)服務(wù)接口存放目錄
│ ├── native_c # C接口存放目錄
│ │ └── include # C接口定義目錄
│ └── native_cpp # C++接口存放目錄
│── sa_profile # 藍(lán)牙服務(wù)定義目錄
│── services # 藍(lán)牙服務(wù)代碼目錄
└── LICENSE # 版權(quán)聲明文件
約束
藍(lán)牙服務(wù)組件使用C語言編寫。
說明
現(xiàn)在提供的是BLE相關(guān)接口及GAP基本開關(guān)藍(lán)牙的接口,其它接口暫不提供。
標(biāo)準(zhǔn)系統(tǒng)使用說明
標(biāo)準(zhǔn)系統(tǒng)提供C接口定義及服務(wù)和協(xié)議棧的代碼,目前提供的只有BLE相關(guān)的接口,包括BLE設(shè)備gatt相關(guān)的操作,以及BLE廣播、掃描等功能,其它A2DP,AVRCP,HFP等相關(guān)接口在后續(xù)增量發(fā)布。
標(biāo)準(zhǔn)系統(tǒng)使用目錄如下:
輕量或小型系統(tǒng)使用說明
輕量或小型系統(tǒng)只提供C接口定義,目前只有BLE相關(guān)接口,包括BLE設(shè)備gatt相關(guān)的操作,以及BLE廣播、掃描等功能,其它A2DP,AVRCP,HFP等相關(guān)接口在后續(xù)增量發(fā)布。
輕量或小型系統(tǒng)使用目錄如下:
interfaces/innerkits/native_c/include
C接口使用說明
- 打開/關(guān)閉藍(lán)牙:
/* 打開傳統(tǒng)藍(lán)牙 */
bool EnableBt(void);
/* 關(guān)閉傳統(tǒng)藍(lán)牙 */
bool DisableBt(void);
/* 打開低功耗藍(lán)牙 */
bool EnableBle(void);
/* 關(guān)閉低功耗藍(lán)牙 */
bool DisableBle(void);
- 獲取藍(lán)牙狀態(tài)
/* 獲取傳統(tǒng)藍(lán)牙狀態(tài) */
int GetBtState();
/* 判斷低功耗藍(lán)牙狀態(tài) */
bool IsBleEnabled();
- 獲取本端Mac地址
/* 獲取mac地址 */
bool GetLocalAddr(unsigned char *mac, unsigned int len);
- 設(shè)置本端設(shè)備名稱
/* 設(shè)置本端設(shè)備名稱 */
bool SetLocalName(unsigned char *localName, unsigned char length);
- 設(shè)備需要完成以下接口的開發(fā)步驟,以使能Gatt server功能并開啟服務(wù):
/* 初始化藍(lán)牙協(xié)議棧 */
int InitBtStack(void);
int EnableBtStack(void);
/* 注冊應(yīng)用,appUuid由應(yīng)用提供 */
int BleGattsRegister(BtUuid appUuid);
/* 添加服務(wù) */
int BleGattsAddService(int serverId, BtUuid srvcUuid, bool isPrimary, int number);
/* 添加特征值 */
int BleGattsAddCharacteristic(int serverId, int srvcHandle, BtUuid characUuid, int properties, int permissions);
/* 添加描述符 */
int BleGattsAddDescriptor(int serverId, int srvcHandle, BtUuid descUuid, int permissions);
/* 開始服務(wù) */
int BleGattsStartService(int serverId, int srvcHandle);
- 設(shè)備需要完成以下接口的開發(fā)步驟,以使能BLE廣播的發(fā)送:
/* 設(shè)置廣播數(shù)據(jù) */
int BleSetAdvData(int advId, const BleConfigAdvData *data);
/* 開始發(fā)送廣播 */
int BleStartAdv(int advId, const BleAdvParams *param);
- 若需要掃描功能,設(shè)備需要完成以下接口的開發(fā)步驟,以使能BLE掃描功能:
/* 設(shè)置掃描參數(shù) */
int BleSetScanParameters(int clientId, BleScanParams *param);
/* 開始掃描 */
int BleStartScan(void);
審核編輯 黃宇
-
接口
+關(guān)注
關(guān)注
33文章
8691瀏覽量
151911 -
藍(lán)牙
+關(guān)注
關(guān)注
114文章
5866瀏覽量
171207 -
鴻蒙
+關(guān)注
關(guān)注
57文章
2392瀏覽量
43050 -
Harmony
+關(guān)注
關(guān)注
0文章
54瀏覽量
2639
發(fā)布評論請先 登錄
相關(guān)推薦
評論