Add Notification and Response parameters to Config

Added after Nimble Lib update.
end() updated.
This commit is contained in:
RobertoHE 2022-11-21 17:45:01 +01:00 committed by GitHub
parent 24f4addb36
commit 81462befb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 9 deletions

View File

@ -40,7 +40,6 @@ struct DefaultSettingsClient : public BLEMIDI_NAMESPACE::DefaultSettings
*/ */
static constexpr char *name = "BleMidiClient"; static constexpr char *name = "BleMidiClient";
/* /*
###### TX POWER ##### ###### TX POWER #####
*/ */
@ -59,7 +58,6 @@ struct DefaultSettingsClient : public BLEMIDI_NAMESPACE::DefaultSettings
*/ */
static const esp_power_level_t clientTXPwr = ESP_PWR_LVL_P9; static const esp_power_level_t clientTXPwr = ESP_PWR_LVL_P9;
/* /*
###### SECURITY ##### ###### SECURITY #####
*/ */
@ -88,7 +86,6 @@ struct DefaultSettingsClient : public BLEMIDI_NAMESPACE::DefaultSettings
*/ */
static constexpr PasskeyRequestCallback userOnPassKeyRequest = defautlPasskeyRequest; static constexpr PasskeyRequestCallback userOnPassKeyRequest = defautlPasskeyRequest;
/* /*
###### BLE COMMUNICATION PARAMS ###### ###### BLE COMMUNICATION PARAMS ######
*/ */
@ -111,7 +108,6 @@ struct DefaultSettingsClient : public BLEMIDI_NAMESPACE::DefaultSettings
static const uint16_t commLatency = 0; // static const uint16_t commLatency = 0; //
static const uint16_t commTimeOut = 200; // 2000ms static const uint16_t commTimeOut = 200; // 2000ms
/* /*
###### BLE FORCE NEW CONNECTION ###### ###### BLE FORCE NEW CONNECTION ######
*/ */
@ -124,6 +120,21 @@ struct DefaultSettingsClient : public BLEMIDI_NAMESPACE::DefaultSettings
* *
*/ */
static const bool forceNewConnection = false; static const bool forceNewConnection = false;
/*
###### BLE SUBSCRIPTION: NOTIFICATION & RESPONSE ######
*/
/**
* Subscribe in Notification Mode [true] or Indication Mode [false]
* Don't modify this parameter except is completely necessary.
*/
static const bool notification = true;
/**
* Respond to after a notification message.
* Don't modify this parameter except is completely necessary.
*/
static const bool response = true;
}; };
/** Define a class to handle the callbacks when advertisments are received */ /** Define a class to handle the callbacks when advertisments are received */
@ -206,9 +217,11 @@ public:
myAdvCB.enableConnection = false; myAdvCB.enableConnection = false;
xQueueReset(mRxQueue); xQueueReset(mRxQueue);
_client->disconnect(); _client->disconnect();
bool success = !_client->isConnected();
if (success)
_client = nullptr; _client = nullptr;
return !_client->isConnected(); return success;
} }
void write(uint8_t *data, uint8_t length) void write(uint8_t *data, uint8_t length)
@ -468,7 +481,7 @@ bool BLEMIDI_Client_ESP32<_Settings>::connect()
{ {
if (_characteristic->canNotify()) if (_characteristic->canNotify())
{ {
if (_characteristic->subscribe(true, std::bind(&BLEMIDI_Client_ESP32::notifyCB, this, _1, _2, _3, _4))) if (_characteristic->subscribe(_Settings::notification, std::bind(&BLEMIDI_Client_ESP32::notifyCB, this, _1, _2, _3, _4), _Settings::response))
{ {
// Re-connection SUCCESS // Re-connection SUCCESS
return true; return true;
@ -537,7 +550,7 @@ bool BLEMIDI_Client_ESP32<_Settings>::connect()
{ {
if (_characteristic->canNotify()) if (_characteristic->canNotify())
{ {
if (_characteristic->subscribe(true, std::bind(&BLEMIDI_Client_ESP32::notifyCB, this, _1, _2, _3, _4))) if (_characteristic->subscribe(_Settings::notification, std::bind(&BLEMIDI_Client_ESP32::notifyCB, this, _1, _2, _3, _4), _Settings::response))
{ {
// Connection SUCCESS // Connection SUCCESS
return true; return true;