Skip to content

Commit b7e124c

Browse files
aerlonTD-er
authored andcommitted
- 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.
1 parent ee7d55e commit b7e124c

23 files changed

+974
-526
lines changed

libraries/ESP8266WiFiMesh/keywords.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ ESP8266WiFiMesh KEYWORD3
1212
# Datatypes (KEYWORD1)
1313
#######################################
1414

15-
ESP8266WiFiMesh KEYWORD1
16-
NetworkInfo KEYWORD1
17-
TransmissionResult KEYWORD1
1815
transmission_status_t KEYWORD1
1916

2017
#######################################
@@ -41,7 +38,7 @@ getSSID KEYWORD2
4138
setMessage KEYWORD2
4239
getMessage KEYWORD2
4340
attemptTransmission KEYWORD2
44-
acceptRequest KEYWORD2
41+
acceptRequests KEYWORD2
4542
setStaticIP KEYWORD2
4643
getStaticIP KEYWORD2
4744
disableStaticIP->KEYWORD2

libraries/ESP8266WiFiMesh/src/EncryptedConnectionData.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ uint8_t *EncryptedConnectionData::getPeerApMac(uint8_t *resultArray) const
8989
return resultArray;
9090
}
9191

92+
void EncryptedConnectionData::setPeerApMac(const uint8_t *peerApMac)
93+
{
94+
std::copy_n(peerApMac, 6, _peerApMac);
95+
}
96+
9297
bool EncryptedConnectionData::connectedTo(const uint8_t *peerMac) const
9398
{
9499
if(macEqual(peerMac, _peerStaMac) || macEqual(peerMac, _peerApMac))
@@ -146,10 +151,10 @@ bool EncryptedConnectionData::desync() const { return _desync; }
146151

147152
String EncryptedConnectionData::serialize() const
148153
{
149-
// Returns: {"connectionState":{"duration":"123","password":"abc","ownSessionKey":"1A2","peerSessionKey":"3B4","peerStaMac":"F2","peerApMac":"E3"}}
154+
// Returns: {"connectionState":{"duration":"123","password":"abc","ownSK":"1A2","peerSK":"3B4","peerStaMac":"F2","peerApMac":"E3"}}
150155

151156
return
152-
"{\"connectionState\":{"
157+
JsonTranslator::jsonConnectionState
153158
+ (temporary() ? JsonTranslator::jsonDuration + "\"" + String(temporary()->remainingDuration()) + "\"," : "")
154159
+ JsonTranslator::jsonDesync + "\"" + String(desync()) + "\","
155160
+ JsonTranslator::jsonOwnSessionKey + "\"" + uint64ToString(getOwnSessionKey()) + "\","

libraries/ESP8266WiFiMesh/src/EncryptedConnectionData.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ class EncryptedConnectionData {
5555

5656
// @param resultArray At least size 6.
5757
uint8_t *getPeerStaMac(uint8_t *resultArray) const;
58+
void setPeerStaMac(const uint8_t *peerStaMac) = delete; // A method for setPeerStaMac would sometimes require interacting with the ESP-NOW API to change encrypted connections, so it is not implemented.
5859
uint8_t *getPeerApMac(uint8_t *resultArray) const;
60+
void setPeerApMac(const uint8_t *peerApMac);
5961

6062
bool connectedTo(const uint8_t *peerMac) const;
6163

0 commit comments

Comments
 (0)