Added ability to turn off SpanPoint encryption
New class-level method SpanPoint::setEncryption(boolean encrypt). Default is to use encryption unless method is called with encrypt=false. With encryption, 7 connections max; without encryption, 20 connections max. Serial Monitor provides warnings if connections are exceeded.
This commit is contained in:
parent
9708678dcf
commit
a6a84b5e21
|
|
@ -1009,13 +1009,13 @@ void Span::processSerialCommand(const char *c){
|
||||||
uint8_t channel;
|
uint8_t channel;
|
||||||
wifi_second_chan_t channel2;
|
wifi_second_chan_t channel2;
|
||||||
esp_wifi_get_channel(&channel,&channel2);
|
esp_wifi_get_channel(&channel,&channel2);
|
||||||
LOG0("\nFound %d SpanPoint Links:\n\n",SpanPoint::SpanPoints.size());
|
LOG0("\nFound %d %s SpanPoint Links:\n\n",SpanPoint::SpanPoints.size(),SpanPoint::useEncryption?"encrypted":"unencrypted");
|
||||||
LOG0("%-17s %18s %7s %7s %7s\n","Local MAC Address","Remote MAC Address","Send","Receive","Depth");
|
LOG0("%-17s %18s %7s %7s %7s\n","Local MAC Address","Remote MAC Address","Send","Receive","Depth");
|
||||||
LOG0("%.17s %.18s %.7s %.7s %.7s\n",d,d,d,d,d);
|
LOG0("%.17s %.18s %.7s %.7s %.7s\n",d,d,d,d,d);
|
||||||
for(auto it=SpanPoint::SpanPoints.begin();it!=SpanPoint::SpanPoints.end();it++)
|
for(auto it=SpanPoint::SpanPoints.begin();it!=SpanPoint::SpanPoints.end();it++)
|
||||||
LOG0("%-18s %02X:%02X:%02X:%02X:%02X:%02X %7d %7d %7d\n",(*it)->peerInfo.ifidx==WIFI_IF_AP?WiFi.softAPmacAddress().c_str():WiFi.macAddress().c_str(),
|
LOG0("%-18s %02X:%02X:%02X:%02X:%02X:%02X %7d %7d %7d %s\n",(*it)->peerInfo.ifidx==WIFI_IF_AP?WiFi.softAPmacAddress().c_str():WiFi.macAddress().c_str(),
|
||||||
(*it)->peerInfo.peer_addr[0],(*it)->peerInfo.peer_addr[1],(*it)->peerInfo.peer_addr[2],(*it)->peerInfo.peer_addr[3],(*it)->peerInfo.peer_addr[4],(*it)->peerInfo.peer_addr[5],
|
(*it)->peerInfo.peer_addr[0],(*it)->peerInfo.peer_addr[1],(*it)->peerInfo.peer_addr[2],(*it)->peerInfo.peer_addr[3],(*it)->peerInfo.peer_addr[4],(*it)->peerInfo.peer_addr[5],
|
||||||
(*it)->sendSize,(*it)->receiveSize,uxQueueSpacesAvailable((*it)->receiveQueue));
|
(*it)->sendSize,(*it)->receiveSize,uxQueueSpacesAvailable((*it)->receiveQueue),esp_now_is_peer_exist((*it)->peerInfo.peer_addr)?"":"(max connections exceeded!)");
|
||||||
LOG0("\nSpanPoint using WiFi Channel %d%s\n",channel,WiFi.status()!=WL_CONNECTED?" (subject to change once WiFi connection established)":"");
|
LOG0("\nSpanPoint using WiFi Channel %d%s\n",channel,WiFi.status()!=WL_CONNECTED?" (subject to change once WiFi connection established)":"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2332,7 +2332,7 @@ SpanPoint::SpanPoint(const char *macAddress, int sendSize, int receiveSize, int
|
||||||
|
|
||||||
peerInfo.ifidx=useAPaddress?WIFI_IF_AP:WIFI_IF_STA; // specify interface as either STA or AP
|
peerInfo.ifidx=useAPaddress?WIFI_IF_AP:WIFI_IF_STA; // specify interface as either STA or AP
|
||||||
|
|
||||||
peerInfo.encrypt=true; // turn on encryption for this peer
|
peerInfo.encrypt=useEncryption; // set encryption for this peer
|
||||||
memcpy(peerInfo.lmk, lmk, 16); // set local key
|
memcpy(peerInfo.lmk, lmk, 16); // set local key
|
||||||
esp_now_add_peer(&peerInfo); // add peer to ESP-NOW
|
esp_now_add_peer(&peerInfo); // add peer to ESP-NOW
|
||||||
|
|
||||||
|
|
@ -2496,6 +2496,7 @@ void SpanPoint::dataReceived(const uint8_t *mac, const uint8_t *incomingData, in
|
||||||
uint8_t SpanPoint::lmk[16];
|
uint8_t SpanPoint::lmk[16];
|
||||||
boolean SpanPoint::initialized=false;
|
boolean SpanPoint::initialized=false;
|
||||||
boolean SpanPoint::isHub=false;
|
boolean SpanPoint::isHub=false;
|
||||||
|
boolean SpanPoint::useEncryption=true;
|
||||||
vector<SpanPoint *, Mallocator<SpanPoint *>> SpanPoint::SpanPoints;
|
vector<SpanPoint *, Mallocator<SpanPoint *>> SpanPoint::SpanPoints;
|
||||||
uint16_t SpanPoint::channelMask=0x3FFE;
|
uint16_t SpanPoint::channelMask=0x3FFE;
|
||||||
QueueHandle_t SpanPoint::statusQueue;
|
QueueHandle_t SpanPoint::statusQueue;
|
||||||
|
|
|
||||||
|
|
@ -931,6 +931,7 @@ class SpanPoint {
|
||||||
static uint8_t lmk[16];
|
static uint8_t lmk[16];
|
||||||
static boolean initialized;
|
static boolean initialized;
|
||||||
static boolean isHub;
|
static boolean isHub;
|
||||||
|
static boolean useEncryption;
|
||||||
static vector<SpanPoint *, Mallocator<SpanPoint *>> SpanPoints;
|
static vector<SpanPoint *, Mallocator<SpanPoint *>> SpanPoints;
|
||||||
static uint16_t channelMask; // channel mask (only used for remote devices)
|
static uint16_t channelMask; // channel mask (only used for remote devices)
|
||||||
static QueueHandle_t statusQueue; // queue for communication between SpanPoint::dataSend and SpanPoint::send
|
static QueueHandle_t statusQueue; // queue for communication between SpanPoint::dataSend and SpanPoint::send
|
||||||
|
|
@ -948,8 +949,9 @@ class SpanPoint {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SpanPoint(const char *macAddress, int sendSize, int receiveSize, int queueDepth=1, boolean useAPaddress=false);
|
SpanPoint(const char *macAddress, int sendSize, int receiveSize, int queueDepth=1, boolean useAPaddress=false);
|
||||||
static void setPassword(const char *pwd){init(pwd);};
|
static void setPassword(const char *pwd){init(pwd);}
|
||||||
static void setChannelMask(uint16_t mask);
|
static void setChannelMask(uint16_t mask);
|
||||||
|
static void setEncryption(boolean encrypt){useEncryption=encrypt;}
|
||||||
boolean get(void *dataBuf);
|
boolean get(void *dataBuf);
|
||||||
boolean send(const void *data);
|
boolean send(const void *data);
|
||||||
uint32_t time(){return(millis()-receiveTime);}
|
uint32_t time(){return(millis()-receiveTime);}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue