This section provides APIs to set GAP service and characteristics information, such as device name, appearance, peripheral preferred connection parameters and central address resolution.
More...
This section provides APIs to set GAP service and characteristics information, such as device name, appearance, peripheral preferred connection parameters and central address resolution.
Terms and Acronyms
| Terms | Details |
| GAP | Generic Access Profile. This profile defines the generic procedures related to discovery of Bluetooth enabled devices and link management aspects of connecting to the Bluetooth enabled devices. It also defines procedures related to the use of different security levels. |
| GATTS | GATT Server, is the device that accepts incoming commands and requests from the GATT client. |
| PPCP | Peripheral Preferred Connection Parameters, contains the preferred connection parameters of Peripheral. |
How to use this module
- Step 1. Initialize the GATTS service.
- Step 2. Use GATTS Service APIs to set device name, appearance, peripheral preferred connection parameters and central address resolution characteristic of GAP service.
- Sample code:
uint8_t car_flag = 1;
uint16_t appearance = 0x1234;
char* local_device_name = "HB_DEVICE_LE";
|
| | Struct |
| | This section defines structures for the GATTS service.
|
| |
| const uint8_t* bt_gatts_service_get_gap_device_name |
( |
void |
| ) |
|
This function gets the current Device Name Characteristic value.
- Parameters
-
- Returns
- device name is a pointer to a UTF-8 encoded string.
| void bt_gatts_service_init |
( |
void |
| ) |
|
This function initializes the GATTS service.
It is recommended to call this API once during the bootup.
- Parameters
-
- Returns
- void.
| void bt_gatts_service_set_gap_appearance |
( |
uint16_t |
appearance | ) |
|
This function sets Appearance Characteristic.
It should be called after bt_gatts_service_init().
- Parameters
-
| [in] | appearance | is the Appearance Characteristic value, it shall be 2 octets in length. |
- Returns
- void.
| bt_status_t bt_gatts_service_set_gap_central_address_resolution |
( |
uint8_t |
flag | ) |
|
This function sets Central Address Resolution Characteristic.
It should be called after bt_gatts_service_init(). This function should be called by Central role only to define whether the device supports privacy with the address resolution.
- Parameters
-
| [in] | flag | is a 1 octet value, 0 means the address resolution is not supported in this device, 1 means the address solution is supported in this device, the reserved value range is from 2 to 255. |
- Returns
- BT_STATUS_SUCCESS, the resolution is set successfully. BT_STATUS_FAIL, the resolution failed to set, an invalid parameter is supplied.
| bt_status_t bt_gatts_service_set_gap_device_name |
( |
const uint8_t * |
device_name, |
|
|
uint16_t |
length |
|
) |
| |
This function sets Device Name Characteristic.
It should be called after bt_gatts_service_init().
- Parameters
-
| [in] | device_name | is a pointer to a UTF-8 encoded string. |
| [in] | length | is the length of a UTF-8 string pointed to by device_name in octets (shall be 0 to 248 octets). |
- Returns
- BT_STATUS_SUCCESS, the device name is set successfully. BT_STATUS_FAIL, the device name failed to set, a NULL pointer or invalid length is supplied.
This function sets Peripheral Preferred Connection Parameters Characteristic.
It should be called after (). This function should be called by Peripheral role only to set the Peripheral Preferred Connection Parameters.
- Parameters
-
- Returns
- BT_STATUS_SUCCESS, the PPCP value is set successfully. BT_STATUS_FAIL, the PPCP value failed to set, an invalid parameter is supplied.