From 7fd3d07511607dc10f30e22c6ac78dcc0e50af03 Mon Sep 17 00:00:00 2001 From: annie_wangli Date: Thu, 30 Sep 2021 15:15:18 +0800 Subject: [PATCH] update docs Signed-off-by: annie_wangli --- README.md | 87 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 75 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 8fb88b7a..230f8112 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,100 @@ -# Bluetooth +# Bluetooth - [Introduction](#section11660541593) - [Directory Structure](#section161941989596) - [Constraints](#section119744591305) - [Usage](#section1312121216216) - - [Usage Guidelines](#section129654513264) + - [Standard System](#section1699952017198) + - [Mini or Small System](#section223312597203) + - [C APIs](#section129654513264) - [Repositories Involved](#section1371113476307) ## Introduction -The Bluetooth module provides APIs for accessing and using Bluetooth services, such as APIs for GATT operations, BLE advertising, and scan. +The Bluetooth module provides APIs for accessing and using Bluetooth services, such as APIs for Generic Attribute Profile (GATT) operations, Bluetooth Low Energy (BLE) advertising, and scan. ## Directory Structure ``` /foundation/communication/bluetooth -├── interfaces # APIs exposed externally -├── LICENSE # Copyright notice file +├── interfaces # API code +│ └── innerkits # System service APIs +│ ├── native_c # C APIs +│ │ └── include # Header files for C APIs +│ └── native_cpp # C++ APIs +├── sa_profile # Service ability profile +└── services # Bluetooth service code +└── LICENSE # License declaration file ``` ## Constraints -The Bluetooth module is compiled using the C language. +The Bluetooth module must be compiled in C language. ## Usage -Currently, only BLE-related APIs are available. APIs for different profiles, such as A2DP, AVRCP, and HFP will be provided in the future. +Only BLE-related APIs and basic Bluetooth Generic Access Profile (GAP) APIs are provided. -### Usage Guidelines +### Standard System -- Perform the following steps to enable the GATT server feature and start the GATT service: +The C API definition as well as the service and protocol stack code are provided for the standard system. Currently, only the BLE-related APIs, including the APIs for GATT operations on BLE devices, BLE advertising, and scan, are provided. Other APIs, such as APIs related to A2DP, AVRCP, and HFP, will be gradually provided later. + +The directories for the standard system are as follows: + +interface/ + +sa\_profile/ + +services/ + +### Mini or Small System + +Only C APIs for BLE, such as APIs for GATT operations, BLE advertising, and scan, are provided for the mini and small systems. Other APIs, such as APIs related to A2DP, AVRCP, and HFP, will be gradually provided later. + +The directory for the mini or standard system is as follows: + +interfaces/innerkits/native\_c/include + +### C APIs + +- Enable or disable Bluetooth. + +``` +/* Enable classic Bluetooth.*/ +bool EnableBt(void); +/* Disable classic Bluetooth. */ +bool DisableBt(void); +/* Enable BLE. */ +bool EnableBle(void); +/* Disable BLE. */ +bool DisableBle(void); +``` + +- Obtain Bluetooth status. + +``` +/* Obtain the classic Bluetooth status. */ +int GetBtState(); +/* Check whether BLE is enabled. */ +bool IsBleEnabled(); +``` + +- Obtain the local MAC address. + +``` +/* Obtain the MAC address. */ +bool GetLocalAddr(unsigned char *mac, unsigned int len); +``` + +- Set the name of the local device. + +``` +/* Set the name of the local device.*/ +bool SetLocalName(unsigned char *localName, unsigned char length); +``` + +- Enable the GATT server feature and start the GATT service. ``` /* Initialize the Bluetooth protocol stack. */ @@ -48,7 +112,7 @@ int BleGattsAddDescriptor(int serverId, int srvcHandle, BtUuid descUuid, int per int BleGattsStartService(int serverId, int srvcHandle); ``` -- Perform the following steps to enable BLE advertising. +- Enable BLE advertising. ``` /* Set the data to advertise. */ @@ -57,7 +121,7 @@ int BleSetAdvData(int advId, const BleConfigAdvData *data); int BleStartAdv(int advId, const BleAdvParams *param); ``` -- If you want to use scan capabilities, perform the following steps: +- Enable BLE scan. ``` /* Set scan parameters. */ @@ -69,4 +133,3 @@ int BleStartScan(void); ## Repositories Involved communication\_bluetooth - -- Gitee