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:
parent
6045d2270c
commit
f9ad1e5b83
|
|
@ -58,7 +58,7 @@
|
||||||
* Uncomment what you need
|
* Uncomment what you need
|
||||||
* These are the default values.
|
* These are the default values.
|
||||||
*/
|
*/
|
||||||
//#define BLEMIDI_CLIENT_BOND
|
#define BLEMIDI_CLIENT_BOND
|
||||||
//#define BLEMIDI_CLIENT_MITM
|
//#define BLEMIDI_CLIENT_MITM
|
||||||
#define BLEMIDI_CLIENT_PAIR
|
#define BLEMIDI_CLIENT_PAIR
|
||||||
|
|
||||||
|
|
@ -78,7 +78,7 @@ static uint32_t userOnPassKeyRequest()
|
||||||
return passkey;
|
return passkey;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
###### BLE COMMUNICATION PARAMS ######
|
###### BLE COMMUNICATION PARAMS ######
|
||||||
*/
|
*/
|
||||||
/** Set connection parameters:
|
/** Set connection parameters:
|
||||||
|
|
@ -96,7 +96,7 @@ static uint32_t userOnPassKeyRequest()
|
||||||
*/
|
*/
|
||||||
#define BLEMIDI_CLIENT_COMM_MIN_INTERVAL 6 // 7.5ms
|
#define BLEMIDI_CLIENT_COMM_MIN_INTERVAL 6 // 7.5ms
|
||||||
#define BLEMIDI_CLIENT_COMM_MAX_INTERVAL 35 // 40ms
|
#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
|
#define BLEMIDI_CLIENT_COMM_TIMEOUT 200 //2000ms
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -191,6 +191,7 @@ private:
|
||||||
BLEAdvertising *_advertising = nullptr;
|
BLEAdvertising *_advertising = nullptr;
|
||||||
BLERemoteCharacteristic *_characteristic = nullptr;
|
BLERemoteCharacteristic *_characteristic = nullptr;
|
||||||
BLERemoteService *pSvc = 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;
|
BLEMIDI_Transport<class BLEMIDI_Client_ESP32> *_bleMidiTransport = nullptr;
|
||||||
|
|
||||||
|
|
@ -228,7 +229,18 @@ public:
|
||||||
return;
|
return;
|
||||||
if (_characteristic == NULL)
|
if (_characteristic == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (firstTimeSend)
|
||||||
|
{
|
||||||
_characteristic->writeValue(data, length, true);
|
_characteristic->writeValue(data, length, true);
|
||||||
|
firstTimeSend = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_characteristic->writeValue(data, length, !_characteristic->canWriteNoResponse()))
|
||||||
|
firstTimeSend = true;
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool available(byte *pvBuffer);
|
bool available(byte *pvBuffer);
|
||||||
|
|
@ -236,7 +248,7 @@ public:
|
||||||
void add(byte value)
|
void add(byte value)
|
||||||
{
|
{
|
||||||
// called from BLE-MIDI, to add it to a buffer here
|
// called from BLE-MIDI, to add it to a buffer here
|
||||||
xQueueSend(mRxQueue, &value, portMAX_DELAY/2);
|
xQueueSend(mRxQueue, &value, portMAX_DELAY / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -254,6 +266,7 @@ protected:
|
||||||
{
|
{
|
||||||
_bleMidiTransport->_connectedCallback();
|
_bleMidiTransport->_connectedCallback();
|
||||||
}
|
}
|
||||||
|
firstTimeSend = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void disconnected()
|
void disconnected()
|
||||||
|
|
@ -262,6 +275,7 @@ protected:
|
||||||
{
|
{
|
||||||
_bleMidiTransport->_disconnectedCallback();
|
_bleMidiTransport->_disconnectedCallback();
|
||||||
}
|
}
|
||||||
|
firstTimeSend = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void notifyCB(NimBLERemoteCharacteristic *pRemoteCharacteristic, uint8_t *pData, size_t length, bool isNotify);
|
void notifyCB(NimBLERemoteCharacteristic *pRemoteCharacteristic, uint8_t *pData, size_t length, bool isNotify);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue