diff --git a/src/HAP.h b/src/HAP.h index b8d2107..3df5230 100644 --- a/src/HAP.h +++ b/src/HAP.h @@ -85,7 +85,7 @@ struct HAPClient { static const int MAX_HTTP=8096; // max number of bytes allowed for HTTP message static const int MAX_CONTROLLERS=16; // maximum number of paired controllers (HAP requires at least 16) - static const int MAX_ACCESSORIES=41; // maximum number of allowed Acessories (HAP limit=150, but not enough memory in ESP32 to run that many) + static const int MAX_ACCESSORIES=150; // maximum number of allowed Accessories (HAP limit=150) static TLV tlv8; // TLV8 structure (HAP Section 14.1) with space for 11 TLV records of type kTLVType (HAP Table 5-6) static nvs_handle hapNVS; // handle for non-volatile-storage of HAP data diff --git a/src/HomeSpan.cpp b/src/HomeSpan.cpp index 213e877..5f77a85 100644 --- a/src/HomeSpan.cpp +++ b/src/HomeSpan.cpp @@ -178,6 +178,10 @@ void Span::pollTask() { processSerialCommand("i"); // print homeSpan configuration info HAPClient::init(); // read NVS and load HAP settings + + if(heap_caps_get_minimum_free_size(MALLOC_CAP_DEFAULT)reset(); LOG0("%s is READY!\n\n",displayName); - isInitialized=true; + isInitialized=true; } // isInitialized @@ -838,13 +842,7 @@ void Span::processSerialCommand(const char *c){ break; case 'm': { - multi_heap_info_t heapInfo; - heap_caps_get_info(&heapInfo,MALLOC_CAP_INTERNAL); - LOG0("Total Heap=%d (low=%d) ",heapInfo.total_free_bytes,heapInfo.minimum_free_bytes); - heap_caps_get_info(&heapInfo,MALLOC_CAP_DEFAULT); - LOG0("DRAM-Capable=%d ",heapInfo.total_free_bytes); - heap_caps_get_info(&heapInfo,MALLOC_CAP_EXEC); - LOG0("IRAM-Capable=%d\n",heapInfo.total_free_bytes); + LOG0("Free Heap=%d bytes (low=%d)\n",heap_caps_get_free_size(MALLOC_CAP_DEFAULT),heap_caps_get_minimum_free_size(MALLOC_CAP_DEFAULT)); } break; diff --git a/src/Settings.h b/src/Settings.h index 2a2c3a4..d60ee5d 100644 --- a/src/Settings.h +++ b/src/Settings.h @@ -84,6 +84,8 @@ #define DEFAULT_WEBLOG_URL "status" // change with optional fourth argument in homeSpan.enableWebLog() +#define DEFAULT_LOW_MEM_THRESHOLD 80000 // default low watermark memory threshold that triggers warning + ///////////////////////////////////////////////////// // OTA PARTITION INFO // diff --git a/src/src.ino b/src/src.ino index 59d60b3..b86eddf 100644 --- a/src/src.ino +++ b/src/src.ino @@ -74,17 +74,30 @@ void setup() { // homeSpan.enableOTA(); homeSpan.setWifiCallback(wifiCB); - homeSpan.setWifiCallbackAll(wifiCB_ALL).setVerboseWifiReconnect(false); + homeSpan.setWifiCallbackAll(wifiCB_ALL).setVerboseWifiReconnect(true); new SpanUserCommand('D', " - disconnect WiFi", [](const char *buf){WiFi.disconnect();}); homeSpan.begin(Category::Lighting,"HomeSpan LED"); - + new SpanAccessory(); new Service::AccessoryInformation(); new Characteristic::Identify(); - new LED_Service(13); +// new LED_Service(13); + + for(int i=0;i<50;i++){ + new SpanAccessory(); + new Service::AccessoryInformation(); + new Characteristic::Identify(); + new Service::LightBulb(); + new Characteristic::On(true); + new Service::Fan(); + new Characteristic::Active(); + new Characteristic::RotationDirection(); + (new Characteristic::RotationSpeed(50))->setRange(0,100,25); + } + } //////////////////////////////////////