diff --git a/src/HomeSpan.cpp b/src/HomeSpan.cpp index 6d8718c..300c524 100644 --- a/src/HomeSpan.cpp +++ b/src/HomeSpan.cpp @@ -2247,6 +2247,16 @@ void SpanPoint::init(const char *password){ statusQueue = xQueueCreate(1,sizeof(esp_now_send_status_t)); // create statusQueue even if not needed setChannelMask(channelMask); // default channel mask at start-up uses channels 1-13 + uint8_t channel; + if(!isHub){ // this is not a hub + nvs_flash_init(); // initialize NVS + nvs_open("POINT",NVS_READWRITE,&pointNVS); // open SpanPoint data namespace in NVS + if(!nvs_get_u8(pointNVS,"CHANNEL",&channel)){ // if channel found in NVS... + if(channelMask & (1< SpanPoint::SpanPoints; uint16_t SpanPoint::channelMask=0x3FFE; QueueHandle_t SpanPoint::statusQueue; +nvs_handle SpanPoint::pointNVS; + /////////////////////////////// // MISC // diff --git a/src/HomeSpan.h b/src/HomeSpan.h index 97c6acc..bb6efb1 100644 --- a/src/HomeSpan.h +++ b/src/HomeSpan.h @@ -799,8 +799,9 @@ class SpanPoint { static boolean initialized; static boolean isHub; static vector SpanPoints; - static uint16_t channelMask; // channel mask + 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 nvs_handle pointNVS; // NVS storage for channel number (only used for remote devices) static void dataReceived(const uint8_t *mac, const uint8_t *incomingData, int len); static void init(const char *password="HomeSpan");