philbowles / h4 Goto Github PK
View Code? Open in Web Editor NEWUniversal functional scheduler / timer with rich API for asynchronous one-off, periodic and random events with event chaining
License: Other
Universal functional scheduler / timer with rich API for asynchronous one-off, periodic and random events with event chaining
License: Other
Hi. After 49 days, all tasks will stop working. I only use a few "every" tasks but after 49 days all are dead. My UDP server in a separate thread is still running, that means ESP32 is alive. I guess it is millis() integer overflow problem.
Hi,
I couldn't find any info about the license change.
For commercial purposes, is there a price to be paid now? How is the situation around that right now?
hi, thanks for your library, i was definitely waiting for something like this.
I'm trying to move the firmware ESPecial to use H4.
It's almost good, I have to remove some delay spreed in the code but it should be ok soon.
I only have one issue so fare in this part of the code:
void executeTask(Task& task) {
Serial.printf("jumped to task handler type: %i",task.type);
h4.queueFunction([task](){
Serial.println("Executing task");
if (task.type == 1) {
runAutomation(task.value);
} else if (task.type == 2) {
// Do not persist gpio state here, we want the main loop event (readPins function) to catch the change and trigger its own logic
preferencehandler->setGpioState(task.pin, task.value);
} else if (task.type == 3) {
if (strcmp(task.label,"reloadlist") == 0) {
getFirmwareList();
} else if (strcmp(task.label,"update") == 0 && strcmp(task.version,"")>0) {
execOTA(task.version);
}
} else if (task.type == 4) {
if (strcmp(task.label,"restart") == 0) {
ESP.restart();
}
}
});
}
the executeTask
is a callback I call in my other classes. In these other classes, when I want some task to be executed, I create a Task
object that I pass to the callback like so:
void ServerHandler::handleRunAutomation(AsyncWebServerRequest *request) {
if (request->hasParam(idParamName)) {
Task newTask = {};
newTask.type = 1;
newTask.value = request->getParam(idParamName)->value().toInt();
strcpy(newTask.label, "restart");
Serial.println("task created");
taskCallback(newTask);
request->send(200, "text/plain", "Done");
}
request->send(404, "text/plain", "Not found");
}
Here taskCallback
is executeTask
.
All this works fine, but as soon as the callback is called once, the next time h4 doesn't seem to execute the queuedFunction.
serial print something like this:
15:22:30.230 -> jumped to task handler type: 3
15:22:30.230 -> Executing task
15:22:30.230 -> [MAIN] Retrieving firmware list from https://raw.githubusercontent.com/RomeHein/ESPecial/master/versions/list.json
15:22:30.331 -> [MAIN] firmware list retrieved
15:22:44.340 -> jumped to task handler type: 4
It never "executes" the queued function.
I'm pretty sure it has to do with my implementation as I'm really not expert in C++.
The whole code is available here:
https://github.com/RomeHein/ESPecial/tree/h4-integration
edit:
I've just noticed that the task is actually executed but after a while. Something around 6minutes.
Would it be possible to pin (or queue) a certain task to a core?
I tried to read the code of H4, but it's fairly complex and could not figure if that was already the case.
My use case:
I'm trying to integrate H4 to my project (available here: https://github.com/RomeHein/ESPecial). This is a firmware with a lot of features, including one which is a huge bottleneck in term of performance: Telegram.
I'm using this library: https://github.com/witnessmenow/Universal-Arduino-Telegram-Bot, which has the big disadvantage to not be async (Telegram does work with websockets but that would mean async https, which is not working on esp32 atm). This means that the esp32 has to poll Telegram server every sec or so. Which block the core during the connection. Before integrating H4 I was splitting this task to the core 1 and the rest of the tasks to core 0 (like checking gpio's state) which was working ok.
Thanks for your help
src/H4.h
and src/inc/H4.h
are aliasing each other/there's a mismatch between a link and the real file content.
Unzipping the zip file (release & current master
branch) leads to a an error and the link is not created, nor is the full file content created.
Checkout from git leads to a git error and a weird state- again with regard to the linked/aliased file.
This is on OS X.
Workaround: copy the content from the 'raw' view on GitHub.
Hi- new to H4. Just trying to get "blink" to run on a NodeMCU. Failing to compile with:
In file included from /Users/julian/Documents/Arduino/libraries/H4-master/src/H4Utils.cpp:29:
/Users/julian/Documents/Arduino/libraries/H4-master/src/H4Utils.h:45:38: error: reference to 'byte' is ambiguous
45 | string stringFromBuff(const byte* data,int len);
| ^~~~
In file included from /Users/julian/Documents/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/10.2.0/cmath:42,
from /Users/julian/Documents/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/10.2.0/math.h:36,
from /Users/julian/Documents/Arduino/hardware/esp8266com/esp8266/cores/esp8266/Arduino.h:34,
from /Users/julian/Documents/Arduino/libraries/H4-master/src/H4Utils.h:32,
from /Users/julian/Documents/Arduino/libraries/H4-master/src/H4Utils.cpp:29:
/Users/julian/Documents/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/10.2.0/bits/cpp_type_traits.h:404:30: note: candidates are: 'enum class std::byte'
404 | enum class byte : unsigned char;
| ^~~~
I'm using Mac OS Big Sur, with latest Arduino. I had to install the git version of ESP8266 core due to a python serial issue that is in the version available in board manager.
Any suggestions?
Thanks in advance!
Quick update: at this point I've got blink to compile by commenting out stringFromBuff()
in the .h
and .cpp
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.