The input and output report characteristics share the same UUID and the `getOutputReport` was returning the input report characteristic.
This change will return the correct characteristic by finding it with the index parameter.
When constructing a NimBLEAddress via string or other non `ble_addr_t` parameters it is important that the address type be specified.
This will help prevent issues where applications are not able to connect or identify scanned devices when comparing their addresses.
* General code cleanup.
* All functions that return a characteristic or service have been renamed to have a `get` prefix to better represent their function.
* All functions that set a value have been renamed with the prefix `set` to better represent their functionality.
* Added an `bool notify` parameter to `setBatteryLevel`, which if `true`, will send a notification of the value to the peer.
This allows the NimBLEServer instance to create a NimBLEClient instance to read/write form/to a connected peer.
Only one instance is supported subsequent calls will overwrite the previous client connection information and data.
* Add a workaround for esp32s3 and esp32c3 tx power bug
This adds a workaround to get the tx power when the function returns error due to a bug introduced in some versions of esp-idf.
* Added error checking, return value will be 0xFF if there was an error.
* Calculates the tx power level to and from dbm to `esp_power_level` types for esp32 devices.
* Add esp32 specific funtions `NimBLEDevice::setPowerLevel` and `NimBLEDevice::getPowerLevel` which take and return the related `esp_power_level* ` types.
---------
Co-authored-by: h2zero <powell.rg@gmail.com>
* Adds parameter `rcPtr` to `NimBLEDevice::startSecurity`, default value works as the original method.
* * `rcPtr`: if not nullptr, will allow caller to obtain the internal return code.
* Adds parameter `async` to `NimBLEClient::secureConnection`, default value works as the original method.
* * `async`; if true, will send the secure command and return immediately with a true value for successfully sending the command, else false.
* `NimBLEEddystoneTLM::BeaconData` struct is now public and usable by the application.
* `NimBLEEddystoneTLM::setTemp` now takes an `int16_t` parameter instead of float to be friendly to devices without floating point support.
* `NimBLEEddystoneTLM::getTemp` now returns `int16_t` to work with devices that don't have floating point support.
* `NimBLEEddystoneTLM::setData` now takes a reference to * `NimBLEEddystoneTLM::BeaconData` instead of `std::string`.
* `NimBLEEddystoneTLM::getData` now returns a reference to * `NimBLEEddystoneTLM::BeaconData` instead of `std::string`.
* General code cleanup
* The internal data struct type `BeaconData` is now public and can be used by the application.
* `NimBLEBeacon::setData` now takes `const NimBLEBeacon::BeaconData&` instead of `std::string`.
* Added overload for `NimBLEBeacon::setData` that takes a pointer to raw `uint8_t` data and length`.
* `NimBLEBeacon::getData` now returns `const NimBLEBeacon::BeaconData&` instead of `std::string`.
This makes the services changes notification more accurate by waiting until the changes have taken effect and the server re-started before indicating the change.
Removes tracking of client characteristic subscription status from `NimBLEServer` and `NimBLECharacteristic` and instead uses
the functions and tracking in the host stack.
* `NimBLECharacteristic::notify` and `NimBLECharacteristic::indicate` now return a `bool`, true = success.
* General code cleanup
* `NimBLEServerCallbacks::onMTUChanged` renamed to `NimBLEServerCallbacks::onMTUChange` to be consistent with the client callback.
* `NimBLEServer::getPeerIDInfo` renamed to `NimBLEServer::getPeerInfoByHandle` to better describe it's use.
* Use a std::array to store client connection handles instead of std::vector to reduce memory allocation.
* `NimBLEServer::disconnect` now returns `bool`, true = success, instead of `int` to be consistent with the rest of the library.
* Added `NimBLEDevice::setDefaultPhy` which will set the default preferred PHY for all connections.
* Added `NimBLEClient::updatePhy` to request a PHY change with a peer.
* Added `NimBLEClient::getPhy` to read the current connection PHY setting.
* Added `NimBLEServer::updatePhy` to request a PHY change with a peer.
* Added `NimBLEServer::getPhy` to read the PHY of a peer connection.
* Added callbacks:
* - `NimBLEClientCallbacks::onPhyUpdate`
* - `NimBLEServerCallbacks::onPhyUpdate`
Which are called when the PHY update is complete.
* Added new method `NimBLEScan::setScanPhy` to enable/disable the PHY's to scan on.
* Added new method `NimBLEScan::setScanPeriod` which will allow for setting a scan restart timer in the controller.
* Updated `NimBLEScan::start` to allow the command to be sent with updated parameters if already scanning.
* Added extended scan example.
* Removed storing and restarting of the scan on host reset as it is more appropriate to call the scanEnded callback instead.
* General code cleanup
* `NimBLEExtAdvertisement` : All functions that set data now return `bool`, true = success.
* Added new method, `NimBLEExtAdvertisement::removeData`, which will remove the data of the specified type from the advertisement.
* Added new method, `NimBLEExtAdvertisement::addServiceUUID`, which will append to the service uuids advertised.
* Added new method, `NimBLEExtAdvertisement::removeServiceUUID`, which will remove the service from the uuids advertised.
* Added new method, `NimBLEExtAdvertisement::removeServices`, which will remove all service uuids advertised.
* Added overloads for `NimBLEExtAdvertisement::setServiceData` with the parameters `const NimBLEUUID& uuid, const uint8_t* data, size_t length` and
`const NimBLEUUID& uuid, const std::vector<uint8_t>& data`.
* Added new method, `NimBLEExtAdvertisement::getDataLocation`, which returns the location in the advertisment data of the type requested in parameter `uint8_t type`.
* Added new method, `toString` which returns a Hex string representation of the advertisement data.
* General code cleanup.
* `NimBLEAdvertisementData` moved to it's own .h and .cpp files.
* Added new method, `NimBLEAdvertising::setPreferredParams` that takes the min and max preferred connection parameters as an alternative for `setMinPreferred` and `setMaxPreferred`.
* Added new method, `NimBLEAdvertising::setAdvertisingInterval` Sets the advertisement interval for min and max to the same value instead of calling `setMinInterval` and `setMaxInterval` separately if there is not value difference.
* `NimBLEAdvertisementData` payload is now stored in `std::vector<uint8_t>` instead of `std::string`.
* `NimBLEAdvertisementData::getPayload` now returns `std::vector<uint8_t>` instead of `std::string`.
* `NimBLEAdvertisementData::addData` now takes either a `std::vector<uint8_t>` or `uint8_t* + length` instead of `std::string` or `char + length`.
* `NimBLEAdvertisementData::setName` now takes an optional `bool` parameter to indicate if the name is complete or incomplete, default = complete.
* `NimBLEAdvertising::start` No longer takes a callback pointer parameter, instead the new method `NimBLEAdvertising::setAdvertisingCompleteCallback` should be used.
* `NimBLEAdvertising::setAdvertisementType` has been renamed to `NimBLEAdvertising::setConnectableMode` to better reflect it's function.
* `NimBLEAdvertising::setScanResponse` has been renamed to `NimBLEAdvertising::enableScanResponse` to better reflect it's function.
* Scan response is no longer enabled by default.
* Added new method, `NimBLEAdvertising::setDiscoverableMode` to allow applications to control the discoverability of the advertiser.
* Advertising the name and TX power of the device will no longer happen by default and should be set manually by the application.
* Added overload for `NimBLEAdvertising::setManufacturerData` that takes a `const uint8_t*` and , size_t` paramter.
* Added overload for `NimBLEAdvertising::setServiceData` that takes `const NimBLEUUID& uuid`, ` const uint8_t* data`, ` size_t length` as parameters.
* Added overload for `NimBLEAdvertising::setServiceData` that takes `const NimBLEUUID& uuid`, `const std::vector<uint8_t>&` as parameters.
* All `NimBLEAdvertisementData` functions that change data values now return `bool`, true = success.
* All `NimBLEAdvertising` functions that change data values now return `bool`, true = success.
* `NimBLEAdvertising::setMinPreferred` and `NimBLEAdvertising::setMaxPreferred` have been removed, use `NimBLEAdvertising::setPreferredParams` instead.
* All advertising data is now stored in instances of `NimBLEAdvertisingData` and vectors removed from `NimBLEAdvertising`.
* `NimBLEAdvertising::setAdvertisementData` and `NimBLEAdvertising::setScanResponseData` now return `bool`, true = success.
* Added new method, `NimBLEAdvertisementData::removeData`, which takes a parameter `uint8_t type`, the data type to remove.
* Added new method, `NimBLEAdvertisementData::toString`, which will print the data in hex.
* Added new method, `NimBLEAdvertising::getAdvertisementData`, which returns a reference to the currently set advertisement data.
* Added new method, `NimBLEAdvertising::getScanData`, which returns a reference to the currently set scan response data.
* Added overloads for `NimBLEAdvertising::removeServiceUUID` and `NimBLEAdvertisementData::removeServiceUUID` to accept a `const char*`
* Added new method, `NimBLEAdvertising::clearData`, which will clear the advertisement and scan response data.
This removes the ignore list feature as it can be implemented by the application if desired.
The scan will now ignore any device we are connected to already by checking for any connected client with the same peer address.