Minor Syntax correction

Tabulation indentation fixed after last commit changes and other minor changes in comments
This commit is contained in:
RobertoHE 2022-06-21 19:19:32 +02:00 committed by GitHub
parent 24dce9ac6a
commit fe3412b289
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 53 additions and 47 deletions

View File

@ -33,15 +33,18 @@ struct DefaultSettingsClient : public BLEMIDI_NAMESPACE::DefaultSettings
/*
##### BLE DEVICE NAME #####
*/
/**
* Set name of ble device (not affect to connection with server)
* max 16 characters
*/
static constexpr char *name = "BleMidiClient";
/*
###### TX POWER #####
*/
/**
* Set power transmision
*
@ -56,9 +59,11 @@ struct DefaultSettingsClient : public BLEMIDI_NAMESPACE::DefaultSettings
*/
static const esp_power_level_t clientTXPwr = ESP_PWR_LVL_P9;
/*
###### SECURITY #####
*/
/** Set the IO capabilities of the device, each option will trigger a different pairing method.
* BLE_HS_IO_KEYBOARD_ONLY - Passkey pairing
* BLE_HS_IO_DISPLAY_YESNO - Numeric comparison pairing
@ -83,9 +88,11 @@ struct DefaultSettingsClient : public BLEMIDI_NAMESPACE::DefaultSettings
*/
static constexpr PasskeyRequestCallback userOnPassKeyRequest = defautlPasskeyRequest;
/*
###### BLE COMMUNICATION PARAMS ######
*/
/** Set connection parameters:
* If you only use one connection, put recomended BLE server param communication
* (you may scan it ussing "nRF Connect" app or other similar apps).
@ -104,6 +111,7 @@ struct DefaultSettingsClient : public BLEMIDI_NAMESPACE::DefaultSettings
static const uint16_t commLatency = 0; //
static const uint16_t commTimeOut = 200; // 2000ms
/*
###### BLE FORCE NEW CONNECTION ######
*/
@ -118,7 +126,6 @@ struct DefaultSettingsClient : public BLEMIDI_NAMESPACE::DefaultSettings
static const bool forceNewConnection = false;
};
/** Define a class to handle the callbacks when advertisments are received */
class AdvertisedDeviceCallbacks : public NimBLEAdvertisedDeviceCallbacks
{
@ -275,15 +282,15 @@ protected:
uint32_t onPassKeyRequest()
{
//if (nullptr != _Settings::userOnPassKeyRequest)
// if (nullptr != _Settings::userOnPassKeyRequest)
return _Settings::userOnPassKeyRequest();
//return 0;
// return 0;
};
void onConnect(BLEClient *pClient)
{
DEBUGCLIENT("##Connected##");
//pClient->updateConnParams(_Settings::commMinInterval, _Settings::commMaxInterval, _Settings::commLatency, _Settings::commTimeOut);
// pClient->updateConnParams(_Settings::commMinInterval, _Settings::commMaxInterval, _Settings::commLatency, _Settings::commTimeOut);
vTaskDelay(1);
if (_bluetoothEsp32)
_bluetoothEsp32->connected();
@ -299,12 +306,12 @@ protected:
_bluetoothEsp32->disconnected();
}
if (_Settings::forceNewConnection)
{
if (_Settings::forceNewConnection)
{
// Renew Client
NimBLEDevice::deleteClient(pClient);
pClient = nullptr;
}
}
// Try reconnection or search a new one
NimBLEDevice::getScan()->start(1, scanEndedCB);
@ -346,24 +353,23 @@ bool BLEMIDI_Client_ESP32<_Settings>::begin(const char *deviceName, BLEMIDI_Tran
_bleMidiTransport = bleMidiTransport;
std::string strDeviceName(deviceName);
if (strDeviceName == "") // Connect to the first midi server found
// Connect to the first midi server found
if (strDeviceName == "")
{
myAdvCB.specificTarget = false;
myAdvCB.nameTarget = "";
}
else // Connect to a specific name or address
// Connect to a specific name or address
else
{
myAdvCB.specificTarget = true;
myAdvCB.nameTarget = strDeviceName;
}
static char array[16] = "patata";
static char array[16];
memcpy(array, _Settings::name, 16);
strDeviceName = array;
DEBUGCLIENT(strDeviceName.c_str());
NimBLEDevice::init(strDeviceName);
// To communicate between the 2 cores.
@ -390,7 +396,8 @@ bool BLEMIDI_Client_ESP32<_Settings>::available(byte *pvBuffer)
return false;
}
if (_client == nullptr || !_client->isConnected()) // Try to connect/reconnect
// Try to connect/reconnect
if (_client == nullptr || !_client->isConnected())
{
if (myAdvCB.doConnect)
{
@ -445,9 +452,9 @@ bool BLEMIDI_Client_ESP32<_Settings>::connect()
{
using namespace std::placeholders; //<- for bind funtion in callback notification
//Retry to connecto to last one
if (!_Settings::forceNewConnection)
{
// Retry to connecto to last one
if (!_Settings::forceNewConnection)
{
/** Check if we have a client we should reuse first
* Special case when we already know this device
* This saves considerable time and power.
@ -479,8 +486,7 @@ if (!_Settings::forceNewConnection)
NimBLEDevice::deleteClient(_client);
_client = nullptr;
}
}
}
if (NimBLEDevice::getClientListSize() >= NIMBLE_MAX_CONNECTIONS)
{
@ -493,7 +499,7 @@ if (!_Settings::forceNewConnection)
_client->setClientCallbacks(new MyClientCallbacks<_Settings>(this), false);
_client->setConnectionParams(_Settings::commMinInterval,_Settings::commMaxInterval, _Settings::commLatency, _Settings::commTimeOut);
_client->setConnectionParams(_Settings::commMinInterval, _Settings::commMaxInterval, _Settings::commLatency, _Settings::commTimeOut);
/** Set how long we are willing to wait for the connection to complete (seconds), default is 30. */
_client->setConnectTimeout(15);