Added homeSpan.getAutoPollTask() to return task handler of autoPoll

Returns NULL if autoPoll has not been used.

Also added low stack size for both main Arduino loop task and HomeSpan autoPoll task to 'm' command
This commit is contained in:
Gregg 2024-01-12 21:57:57 -06:00
parent 2d86ee4a25
commit 3c3e5c21ea
3 changed files with 10 additions and 6 deletions

View File

@ -55,6 +55,8 @@ HapCharacteristics hapChars; // Instantiation of all HAP Characteristics
///////////////////////////////
void Span::begin(Category catID, const char *displayName, const char *hostNameBase, const char *modelName){
loopTaskHandle=xTaskGetCurrentTaskHandle(); // a roundabout way of getting the current task handle
this->displayName=displayName;
this->hostNameBase=hostNameBase;
@ -834,7 +836,9 @@ void Span::processSerialCommand(const char *c){
Serial.printf(" Internal: %9d %9d %9d %9d\n",heapInternal.total_allocated_bytes,heapInternal.total_free_bytes,heapInternal.largest_free_block,heapInternal.minimum_free_bytes);
Serial.printf(" PSRAM: %9d %9d %9d %9d\n\n",heapPSRAM.total_allocated_bytes,heapPSRAM.total_free_bytes,heapPSRAM.largest_free_block,heapPSRAM.minimum_free_bytes);
LOG0("Lowest stack level: %d bytes\n",uxTaskGetStackHighWaterMark(NULL));
if(getAutoPollTask())
LOG0("Lowest stack level: %d bytes (%s)\n",uxTaskGetStackHighWaterMark(getAutoPollTask()),pcTaskGetName(getAutoPollTask()));
LOG0("Lowest stack level: %d bytes (%s)\n",uxTaskGetStackHighWaterMark(loopTaskHandle),pcTaskGetName(loopTaskHandle));
nvs_stats_t nvs_stats;
nvs_get_stats(NULL, &nvs_stats);
LOG0("NVS Flash Partition: %d of %d records used\n\n",nvs_stats.used_entries,nvs_stats.total_entries-126);

View File

@ -249,6 +249,7 @@ class Span{
Network network; // configures WiFi and Setup Code via either serial monitor or temporary Access Point
SpanWebLog webLog; // optional web status/log
TaskHandle_t pollTaskHandle = NULL; // optional task handle to use for poll() function
TaskHandle_t loopTaskHandle; // Arduino Loop Task handle
boolean verboseWifiReconnect = true; // set to false to not print WiFi reconnect attempts messages
SpanOTA spanOTA; // manages OTA process
@ -370,6 +371,8 @@ class Span{
LOG0("\n*** AutoPolling Task started with priority=%d\n\n",uxTaskPriorityGet(pollTaskHandle));
}
TaskHandle_t getAutoPollTask(){return(pollTaskHandle);}
Span& setTimeServerTimeout(uint32_t tSec){webLog.waitTime=tSec*1000;return(*this);} // sets wait time (in seconds) for optional web log time server to connect
[[deprecated("Please use reserveSocketConnections(n) method instead.")]]

View File

@ -29,8 +29,6 @@
#define MAX_LIGHTS 2
SpanCharacteristic *brightness[2];
void setup() {
Serial.begin(115200);
@ -53,14 +51,13 @@ void setup() {
new Characteristic::Name(c);
new Service::LightBulb();
new Characteristic::On(0,true);
brightness[i]=new Characteristic::Saturation(0,true);
new Characteristic::Saturation(0,true);
WEBLOG("Configuring %s\n",c);
}
new SpanUserCommand('w', " - get web log test",webLogTest); // simulate getting an HTTPS request for weblog
new SpanUserCommand('b', " - change brightness to fraction",[](const char *buf){brightness[0]->setVal(atof(buf+1));}); // simulate getting an HTTPS request for weblog
new SpanUserCommand('c', " - change brightness to fraction",[](const char *buf){brightness[1]->setVal(atof(buf+1));}); // simulate getting an HTTPS request for weblog
// homeSpan.autoPoll(8192+10000);
}
//////////////////////////////////////