-
-
Notifications
You must be signed in to change notification settings - Fork 4
Cleanup ota example #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanup ota example #17
Conversation
- Stripped factory.py from the OTA environment to speed up processing before upload - Added build time and date to the example website to see the effect of a newly build OTA upload - minor changes to readme.md (corrected a typo, renamed section heading, added some more hints on usage)
Forgot to remove variants folder for the waveshare_esp32_s3_tiny (which I used just for testing)
@mathieucarbou Sorry, I cannot keep up with your lightspeed pace. As soon as I try out something, you have already implemented it yourself (better than I could), tested, documented and merged everything into the library already... Just a note on "Platformio experience", I tried to re-route the monitor port in the OTA environments to telnet (the pySerial base for platformio's monitoring would support a socket connection). Actually, it would require adding additional dependencies like karol-brejna-i/RemoteDebug, or something similar. All of the libraries I looked at would require some major rework to be compatible with ESPConnect. |
Thanks for the PR :-) I will merge!
I agree, and also adding some features now would maybe require to disable mDNS or something else. I think the way it is right now is nice. About logging the startup, I had this use case in YaSolR (https://github.com/mathieucarbou/YaSolR) to help the support. So I am using a combination of Here is my startup sequence: Mycila::Logger logger;
// redirect logs to file system
class LogStream : public Print {
public:
LogStream(const char* path, size_t limit) : _path(path), _limit(limit) {
File file = LittleFS.open(_path, "r");
_logSize = file ? file.size() : 0;
file.close();
}
size_t write(const uint8_t* buffer, size_t size) override {
if (_logSize + size > _limit)
return 0;
File file = LittleFS.open(_path, "a");
if (!file)
return 0;
size_t written = file.write(buffer, size);
file.close();
_logSize += written;
return written;
}
size_t write(uint8_t c) override {
assert(false);
return 0;
}
private:
const char* _path;
const size_t _limit;
size_t _logSize = 0;
};
// Arduino setup()
void setup() {
// HardwareSerial
Serial.begin(YASOLR_SERIAL_BAUDRATE);
#if ARDUINO_USB_CDC_ON_BOOT
Serial.setTxTimeoutMs(0);
delay(100);
#else
while (!Serial)
yield();
#endif
// MycilaLogger - uses ets_install_putc1 hook
logger.redirectArduinoLogs();
logger.forwardTo(&Serial);
// TODO: not shown here:
// - initialize LittleFS - LittleFS.begin()
// - initialize NVS
// - load app config from NVS
logger.info(TAG, "Initialize logging");
// remove previous log file
if (LittleFS.remove(YASOLR_LOG_FILE))
logger.info(TAG, "Previous log file removed");
// only in debug mode, redirect logs to WebSerial and flash
if (config.getBool(KEY_ENABLE_DEBUG)) {
logger.setLevel(ARDUHAL_LOG_LEVEL_DEBUG);
esp_log_level_set("*", static_cast<esp_log_level_t>(ARDUHAL_LOG_LEVEL_DEBUG));
logger.info(TAG, "Redirecting logs to WebSerial");
webSerial = new WebSerial();
webSerial->begin(&webServer, "/console");
logger.forwardTo(webSerial);
logger.info(TAG, "Redirecting logs to " YASOLR_LOG_FILE);
webServer.on("/api" YASOLR_LOG_FILE, HTTP_GET, [](AsyncWebServerRequest* request) {
LittleFS.open(YASOLR_LOG_FILE, "r");
request->send(LittleFS, YASOLR_LOG_FILE, "text/plain");
});
logger.forwardTo(new LogStream(YASOLR_LOG_FILE, 32 * 1024));
} else {
logger.setLevel(ARDUHAL_LOG_LEVEL_INFO);
esp_log_level_set("*", static_cast<esp_log_level_t>(ARDUHAL_LOG_LEVEL_INFO));
}
} Currently, Arduino Core has a bug (IMO) that prevents log redirect on some boards. |
This is just a quality of service update. No functional changes to the library.