Transmition speed Improved WriteNoResponse

Now it sends data to server in Write Without Response mode. This increase the transmission speed and it get adapted to MIDI over BLE protocol.
Some devices needs a first message with confirmation for clean security flags. After a connection or after an error, the first message is sended like Write (with response).
This commit is contained in:
RobertoHE 2021-09-21 17:39:06 +02:00 committed by GitHub
parent 6045d2270c
commit f9ad1e5b83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 32 additions and 18 deletions

View File

@ -58,7 +58,7 @@
* Uncomment what you need
* These are the default values.
*/
//#define BLEMIDI_CLIENT_BOND
#define BLEMIDI_CLIENT_BOND
//#define BLEMIDI_CLIENT_MITM
#define BLEMIDI_CLIENT_PAIR
@ -96,7 +96,7 @@ static uint32_t userOnPassKeyRequest()
*/
#define BLEMIDI_CLIENT_COMM_MIN_INTERVAL 6 // 7.5ms
#define BLEMIDI_CLIENT_COMM_MAX_INTERVAL 35 // 40ms
#define BLEMIDI_CLIENT_COMM_LATENCY 0
#define BLEMIDI_CLIENT_COMM_LATENCY 0 //
#define BLEMIDI_CLIENT_COMM_TIMEOUT 200 //2000ms
/*
@ -191,6 +191,7 @@ private:
BLEAdvertising *_advertising = nullptr;
BLERemoteCharacteristic *_characteristic = nullptr;
BLERemoteService *pSvc = nullptr;
bool firstTimeSend = true; //First writeValue get sends like Write with reponse for clean security flags. After first time, all messages are send like WriteNoResponse for increase transmision speed.
BLEMIDI_Transport<class BLEMIDI_Client_ESP32> *_bleMidiTransport = nullptr;
@ -228,7 +229,18 @@ public:
return;
if (_characteristic == NULL)
return;
if (firstTimeSend)
{
_characteristic->writeValue(data, length, true);
firstTimeSend = false;
return;
}
if (!_characteristic->writeValue(data, length, !_characteristic->canWriteNoResponse()))
firstTimeSend = true;
return;
}
bool available(byte *pvBuffer);
@ -254,6 +266,7 @@ protected:
{
_bleMidiTransport->_connectedCallback();
}
firstTimeSend = true;
}
void disconnected()
@ -262,6 +275,7 @@ protected:
{
_bleMidiTransport->_disconnectedCallback();
}
firstTimeSend = true;
}
void notifyCB(NimBLERemoteCharacteristic *pRemoteCharacteristic, uint8_t *pData, size_t length, bool isNotify);