mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-23 08:45:22 +03:00
- Make connectionQueue(), latestTransmissionOutcomes() and latestTransmissionSuccessful() methods static in order to match the underlying data storage.
- Make it possible to transfer elements directly between connectionQueues. - Add defaultBSSID value. - Fix bug where encrypted Espnow-connections expired 1 ms too late. - Add MutexTracker::captureBan() functionality and use it in the espnowReceiveCallbackWrapper method to ensure a consistent mutex environment there. - Rename acceptRequest to acceptRequests since several requests can be accepted, not just one. - Reorganize EspnowMeshBackend.cpp. - Split sendEspnowResponses() method into sendEspnowResponses() and sendPeerRequestConfirmations(). - Add sendStoredEspnowMessages() method to provide the same functionality as the previous version of sendEspnowResponses(). - Add logic for handling peerRequestConfirmations received at the same time as a peer request is being made, to avoid lockups when there are simultaneous cyclic peer requests. - Add logic for handling simultaneous reciprocal peer requests. - Include MAC addresses in HMAC calculations for peer requests and use HMAC for all unencrypted peer request messages, to make sure we receive valid MAC combinations. - Add asserts to ensure ESP-NOW encryption integrity during code changes. - Add estimatedMaxDuration argument to performEspnowMaintainance and related methods. - Add methods to EncryptedConnectionData for setting peer MAC. - Remove createEncryptionRequestMessage function from JsonTranslator since it is not used, to increase clarity. - Add encryptedConnectionsSoftLimit() and related functionality. - Add mutex to protect connectionQueue usage during attemptTransmission. - Add _ongoingPeerRequestMac variable. - Add reservedEncryptedConnections() method. - Add TransmissionOutcomesUpdateHook() callback. - Add constConnectionQueue() method to allow connectionQueue usage while connectionQueue mutex is active. - Rearrange attemptAutoEncryptingTransmission argument order to increase efficiency. - Add functionality for serializing the unencrypted ESP-NOW connection. - Add some constness. - Improve comments. - Improve documentation. - Update keywords.txt.
This commit is contained in:
@ -30,6 +30,7 @@
|
||||
const IPAddress TcpIpMeshBackend::emptyIP = IPAddress();
|
||||
|
||||
bool TcpIpMeshBackend::_tcpIpTransmissionMutex = false;
|
||||
bool TcpIpMeshBackend::_tcpIpConnectionQueueMutex = false;
|
||||
|
||||
String TcpIpMeshBackend::lastSSID = "";
|
||||
bool TcpIpMeshBackend::staticIPActivated = false;
|
||||
@ -58,6 +59,17 @@ TcpIpMeshBackend::TcpIpMeshBackend(requestHandlerType requestHandler, responseHa
|
||||
|
||||
std::vector<TcpIpNetworkInfo> & TcpIpMeshBackend::connectionQueue()
|
||||
{
|
||||
MutexTracker connectionQueueMutexTracker(_tcpIpConnectionQueueMutex);
|
||||
if(!connectionQueueMutexTracker.mutexCaptured())
|
||||
{
|
||||
assert(false && "ERROR! connectionQueue locked. Don't call connectionQueue() from callbacks other than NetworkFilter as this may corrupt program state!");
|
||||
}
|
||||
|
||||
return _connectionQueue;
|
||||
}
|
||||
|
||||
const std::vector<TcpIpNetworkInfo> & TcpIpMeshBackend::constConnectionQueue()
|
||||
{
|
||||
return _connectionQueue;
|
||||
}
|
||||
|
||||
@ -66,6 +78,11 @@ std::vector<TransmissionOutcome> & TcpIpMeshBackend::latestTransmissionOutcomes(
|
||||
return _latestTransmissionOutcomes;
|
||||
}
|
||||
|
||||
bool TcpIpMeshBackend::latestTransmissionSuccessful()
|
||||
{
|
||||
return latestTransmissionSuccessfulBase(latestTransmissionOutcomes());
|
||||
}
|
||||
|
||||
void TcpIpMeshBackend::begin()
|
||||
{
|
||||
if(!TcpIpMeshBackend::getAPController()) // If there is no active AP controller
|
||||
@ -433,7 +450,7 @@ void TcpIpMeshBackend::attemptTransmission(const String &message, bool scan, boo
|
||||
if(WiFi.status() == WL_CONNECTED)
|
||||
{
|
||||
transmission_status_t transmissionResult = attemptDataTransfer();
|
||||
latestTransmissionOutcomes().push_back(TransmissionOutcome(connectionQueue().back(), transmissionResult));
|
||||
latestTransmissionOutcomes().push_back(TransmissionOutcome(constConnectionQueue().back(), transmissionResult));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -443,11 +460,22 @@ void TcpIpMeshBackend::attemptTransmission(const String &message, bool scan, boo
|
||||
scanForNetworks(scanAllWiFiChannels);
|
||||
}
|
||||
|
||||
for(TcpIpNetworkInfo ¤tNetwork : connectionQueue())
|
||||
MutexTracker connectionQueueMutexTracker(_tcpIpConnectionQueueMutex);
|
||||
if(!connectionQueueMutexTracker.mutexCaptured())
|
||||
{
|
||||
transmission_status_t transmissionResult = initiateTransmission(currentNetwork);
|
||||
|
||||
latestTransmissionOutcomes().push_back(TransmissionOutcome{.origin = currentNetwork, .transmissionStatus = transmissionResult});
|
||||
assert(false && "ERROR! connectionQueue locked. Don't call attemptTransmission from callbacks as this may corrupt program state! Aborting.");
|
||||
}
|
||||
else
|
||||
{
|
||||
for(const TcpIpNetworkInfo ¤tNetwork : constConnectionQueue())
|
||||
{
|
||||
transmission_status_t transmissionResult = initiateTransmission(currentNetwork);
|
||||
|
||||
latestTransmissionOutcomes().push_back(TransmissionOutcome{.origin = currentNetwork, .transmissionStatus = transmissionResult});
|
||||
|
||||
if(!getTransmissionOutcomesUpdateHook()(*this))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -492,12 +520,12 @@ transmission_status_t TcpIpMeshBackend::attemptTransmission(const String &messag
|
||||
return transmissionResult;
|
||||
}
|
||||
|
||||
void TcpIpMeshBackend::acceptRequest()
|
||||
void TcpIpMeshBackend::acceptRequests()
|
||||
{
|
||||
MutexTracker mutexTracker(_tcpIpTransmissionMutex);
|
||||
if(!mutexTracker.mutexCaptured())
|
||||
{
|
||||
assert(false && "ERROR! TCP/IP transmission in progress. Don't call acceptRequest from TCP/IP callbacks as this may corrupt program state! Aborting.");
|
||||
assert(false && "ERROR! TCP/IP transmission in progress. Don't call acceptRequests from callbacks as this may corrupt program state! Aborting.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user