diff --git a/src/HomeSpan.cpp b/src/HomeSpan.cpp index 534d372..ed7e230 100644 --- a/src/HomeSpan.cpp +++ b/src/HomeSpan.cpp @@ -1009,13 +1009,13 @@ void Span::processSerialCommand(const char *c){ uint8_t channel; wifi_second_chan_t 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",d,d,d,d,d); 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)->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)":""); } @@ -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.encrypt=true; // turn on encryption for this peer + peerInfo.encrypt=useEncryption; // set encryption for this peer memcpy(peerInfo.lmk, lmk, 16); // set local key 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]; boolean SpanPoint::initialized=false; boolean SpanPoint::isHub=false; +boolean SpanPoint::useEncryption=true; vector> SpanPoint::SpanPoints; uint16_t SpanPoint::channelMask=0x3FFE; QueueHandle_t SpanPoint::statusQueue; diff --git a/src/HomeSpan.h b/src/HomeSpan.h index 2bf8323..557a73a 100644 --- a/src/HomeSpan.h +++ b/src/HomeSpan.h @@ -931,6 +931,7 @@ class SpanPoint { static uint8_t lmk[16]; static boolean initialized; static boolean isHub; + static boolean useEncryption; static vector> SpanPoints; static uint16_t channelMask; // channel mask (only used for remote devices) static QueueHandle_t statusQueue; // queue for communication between SpanPoint::dataSend and SpanPoint::send @@ -948,8 +949,9 @@ class SpanPoint { public: SpanPoint(const char *macAddress, int sendSize, int receiveSize, int queueDepth=1, boolean useAPaddress=false); - static void setPassword(const char *pwd){init(pwd);}; - static void setChannelMask(uint16_t mask); + static void setPassword(const char *pwd){init(pwd);} + static void setChannelMask(uint16_t mask); + static void setEncryption(boolean encrypt){useEncryption=encrypt;} boolean get(void *dataBuf); boolean send(const void *data); uint32_t time(){return(millis()-receiveTime);}