update nimble lib

This commit is contained in:
technyon
2022-04-22 22:30:50 +02:00
parent cf7e2464bd
commit 097604f6d0
43 changed files with 2148 additions and 174 deletions

View File

@@ -0,0 +1,29 @@
# Bluetooth 5.x features
## About extended advertising
Extended advertising allows for much more capability and flexibility.
* Allows for 251 bytes of advertisement data and up to 1650 bytes when chained (configuration dependant) vs 31.
* New PHY's (physical layers) that allow for faster data rate (2M PHY) or long range/slower data rates (CODED PHY) as well as the original 1M PHY.
* New periodic advertising, allowing the scanning device to sync with the advertisements of a beacon. This allows for the scanning device to sleep or perform other tasks before the next expected advertisement is sent, preserving cpu cycles and power (To be implemented).
<br>
## Enabling extended advertising
Extended advertising is supported when enabled with the config option `CONFIG_BT_NIMBLE_EXT_ADV` set to a value of 1. This is done in menuconfig under `Component config > Bluetooth > NimBLE options >
Enable extended advertising`.
When enabled the following will occur:
* `NimBLEScan::start` method will scan on both the 1M PHY and the coded PHY standards automatically.
* `NimBLEClient::connect` will use the primary PHY the device is listening on, unless specified (see below).
* `NimBLEClient::setConnectPhy` becomes available to specify the PHY's to connect with (default is all).
* `NimBLEAdvertising` is no longer available for use and is replaced by `NimBLEExtAdvertising`. `NimBLEDevice::getAdvertising` will now return an instance of `NimBLEExtAdvertising`.
* `NimBLEAdvertisementData` is no longer available for use and is replaced by `NimBLEExtAdvertisement`. This new class is where everything about the advertisement is configured, including the advertisement intervals and advertisement ended callback.

View File

@@ -23,7 +23,7 @@ characteristic or descriptor is constructed before a value is read/notifed.
Increasing this will reduce reallocations but increase memory footprint.
Default value is 20. Range: 1 : 512 (BLE_ATT_ATTR_MAX_LEN)
<br/>
`CONFIG_BT_NIMBLE_ATT_PREFERRED_MTU`
Sets the default MTU size.
@@ -140,3 +140,34 @@ Set the task stack size for the NimBLE core.
- Default is 4096
<br/>
## Extended advertising settings, For use with ESP32C3, ESP32S3, ESP32H2 ONLY!
`CONFIG_BT_NIMBLE_EXT_ADV`
Set to 1 to enable extended advertising features.
<br/>
`CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES`
Sets the max number of extended advertising instances
- Range: 0 - 4
- Default is 1
<br/>
`CONFIG_BT_NIMBLE_MAX_EXT_ADV_DATA_LEN`
Set the max extended advertising data size,
- Range: 31 - 1650
- Default is 255
<br/>
`CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV`
Set to 1 to enable periodic advertising.
<br/>
`CONFIG_BT_NIMBLE_MAX_PERIODIC_SYNCS`
Set the maximum number of periodically synced devices.
- Range: 1 - 8
- Default is 1

View File

@@ -15,7 +15,7 @@ At the top of your application file add `#include NimBLEDevice.h`, this is the o
## Using the Library
In order to perform any BLE tasks you must first initialize the library, this prepares the NimBLE stack to be ready for commands.
To do this you must call `NimBLEDevice::initialize("your device name here")`, the parameter passed is a character string containing the name you want to advertise.
To do this you must call `NimBLEDevice::init("your device name here")`, the parameter passed is a character string containing the name you want to advertise.
If you're not creating a server or do not want to advertise a name, simply pass an empty string for the parameter.
This can be called any time you wish to use BLE functions and does not need to be called from app_main(IDF) or setup(Arduino) but usually is.
@@ -41,7 +41,7 @@ For this example we will keep it simple and use a 16 bit value: ABCD.
// void setup() in Arduino
void app_main(void)
{
NimBLEDevice::initialize("NimBLE");
NimBLEDevice::init("NimBLE");
NimBLEServer *pServer = NimBLEDevice::createServer();
NimBLEService *pService = pServer->createService("ABCD");
@@ -83,7 +83,7 @@ The function call will simply be `pService->createCharacteristic("1234");`
// void setup() in Arduino
void app_main(void)
{
NimBLEDevice::initialize("NimBLE");
NimBLEDevice::init("NimBLE");
NimBLEServer *pServer = NimBLEDevice::createServer();
NimBLEService *pService = pServer->createService("ABCD");
@@ -117,7 +117,7 @@ That's it, this will be enough to create a BLE server with a service and a chara
// void setup() in Arduino
void app_main(void)
{
NimBLEDevice::initialize("NimBLE");
NimBLEDevice::init("NimBLE");
NimBLEServer *pServer = NimBLEDevice::createServer();
NimBLEService *pService = pServer->createService("ABCD");
@@ -159,7 +159,7 @@ This call returns an instance of `NimBLEScanResults` when the scan completes whi
// void setup() in Arduino
void app_main(void)
{
NimBLEDevice::initialize("");
NimBLEDevice::init("");
NimBLEScan *pScan = NimBLEDevice::getScan();
NimBLEScanResults results = pScan->start(10);
@@ -299,7 +299,7 @@ Note that there is no need to disconnect as that will be done when deleting the
// void setup() in Arduino
void app_main(void)
{
NimBLEDevice::initialize("");
NimBLEDevice::init("");
NimBLEScan *pScan = NimBLEDevice::getScan();
NimBLEScanResults results = pScan->start(10);