mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
add OTA debug level
This commit is contained in:
parent
995f02f437
commit
137c50757e
@ -197,10 +197,14 @@ generic.menu.DebugLevel.HTTPUpdate3=HTTPClient + HTTPUpdate + Updater
|
|||||||
generic.menu.DebugLevel.HTTPUpdate3.build.debug_level=-DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_UPDATER
|
generic.menu.DebugLevel.HTTPUpdate3.build.debug_level=-DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_UPDATER
|
||||||
generic.menu.DebugLevel.HTTPServer=HTTPServer
|
generic.menu.DebugLevel.HTTPServer=HTTPServer
|
||||||
generic.menu.DebugLevel.HTTPServer.build.debug_level=-DDEBUG_ESP_HTTP_SERVER
|
generic.menu.DebugLevel.HTTPServer.build.debug_level=-DDEBUG_ESP_HTTP_SERVER
|
||||||
generic.menu.DebugLevel.UPDATER=Updater (OTA)
|
generic.menu.DebugLevel.UPDATER=Updater
|
||||||
generic.menu.DebugLevel.UPDATER.build.debug_level=-DDEBUG_ESP_UPDATER
|
generic.menu.DebugLevel.UPDATER.build.debug_level=-DDEBUG_ESP_UPDATER
|
||||||
|
generic.menu.DebugLevel.OTA=OTA
|
||||||
|
generic.menu.DebugLevel.OTA.build.debug_level=-DDEBUG_ESP_OTA
|
||||||
|
generic.menu.DebugLevel.OTA2=OTA + Updater
|
||||||
|
generic.menu.DebugLevel.OTA2.build.debug_level=-DDEBUG_ESP_OTA -DDEBUG_ESP_UPDATER
|
||||||
generic.menu.DebugLevel.all=All
|
generic.menu.DebugLevel.all=All
|
||||||
generic.menu.DebugLevel.all.build.debug_level=-DDEBUG_ESP_CORE -DDEBUG_ESP_SSL -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_HTTP_SERVER -DDEBUG_ESP_UPDATER
|
generic.menu.DebugLevel.all.build.debug_level=-DDEBUG_ESP_CORE -DDEBUG_ESP_SSL -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_HTTP_SERVER -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA
|
||||||
|
|
||||||
# disabled because espressif's bootloader refuses to write above 4M
|
# disabled because espressif's bootloader refuses to write above 4M
|
||||||
# generic.menu.FlashSize.8M=8M (7M SPIFFS)
|
# generic.menu.FlashSize.8M=8M (7M SPIFFS)
|
||||||
|
@ -18,7 +18,12 @@ extern "C" {
|
|||||||
#include "include/UdpContext.h"
|
#include "include/UdpContext.h"
|
||||||
#include <ESP8266mDNS.h>
|
#include <ESP8266mDNS.h>
|
||||||
|
|
||||||
//#define OTA_DEBUG 1
|
|
||||||
|
#ifdef DEBUG_ESP_OTA
|
||||||
|
#ifdef DEBUG_ESP_PORT
|
||||||
|
#define OTA_DEBUG DEBUG_ESP_PORT
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
ArduinoOTAClass::ArduinoOTAClass()
|
ArduinoOTAClass::ArduinoOTAClass()
|
||||||
: _port(0)
|
: _port(0)
|
||||||
@ -109,8 +114,8 @@ void ArduinoOTAClass::begin() {
|
|||||||
}
|
}
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
_state = OTA_IDLE;
|
_state = OTA_IDLE;
|
||||||
#if OTA_DEBUG
|
#ifdef OTA_DEBUG
|
||||||
Serial.printf("OTA server at: %s.local:%u\n", _hostname.c_str(), _port);
|
OTA_DEBUG.printf("OTA server at: %s.local:%u\n", _hostname.c_str(), _port);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,8 +231,8 @@ void ArduinoOTAClass::_onRx(){
|
|||||||
|
|
||||||
void ArduinoOTAClass::_runUpdate() {
|
void ArduinoOTAClass::_runUpdate() {
|
||||||
if (!Update.begin(_size, _cmd)) {
|
if (!Update.begin(_size, _cmd)) {
|
||||||
#if OTA_DEBUG
|
#ifdef OTA_DEBUG
|
||||||
Serial.println("Update Begin Error");
|
OTA_DEBUG.println("Update Begin Error");
|
||||||
#endif
|
#endif
|
||||||
if (_error_callback) {
|
if (_error_callback) {
|
||||||
_error_callback(OTA_BEGIN_ERROR);
|
_error_callback(OTA_BEGIN_ERROR);
|
||||||
@ -249,8 +254,8 @@ void ArduinoOTAClass::_runUpdate() {
|
|||||||
|
|
||||||
WiFiClient client;
|
WiFiClient client;
|
||||||
if (!client.connect(_ota_ip, _ota_port)) {
|
if (!client.connect(_ota_ip, _ota_port)) {
|
||||||
#if OTA_DEBUG
|
#ifdef OTA_DEBUG
|
||||||
Serial.printf("Connect Failed\n");
|
OTA_DEBUG.printf("Connect Failed\n");
|
||||||
#endif
|
#endif
|
||||||
_udp_ota->listen(*IP_ADDR_ANY, _port);
|
_udp_ota->listen(*IP_ADDR_ANY, _port);
|
||||||
if (_error_callback) {
|
if (_error_callback) {
|
||||||
@ -265,8 +270,8 @@ void ArduinoOTAClass::_runUpdate() {
|
|||||||
while (!client.available() && waited--)
|
while (!client.available() && waited--)
|
||||||
delay(1);
|
delay(1);
|
||||||
if (!waited){
|
if (!waited){
|
||||||
#if OTA_DEBUG
|
#ifdef OTA_DEBUG
|
||||||
Serial.printf("Receive Failed\n");
|
OTA_DEBUG.printf("Receive Failed\n");
|
||||||
#endif
|
#endif
|
||||||
_udp_ota->listen(*IP_ADDR_ANY, _port);
|
_udp_ota->listen(*IP_ADDR_ANY, _port);
|
||||||
if (_error_callback) {
|
if (_error_callback) {
|
||||||
@ -288,8 +293,8 @@ void ArduinoOTAClass::_runUpdate() {
|
|||||||
client.print("OK");
|
client.print("OK");
|
||||||
client.stop();
|
client.stop();
|
||||||
delay(10);
|
delay(10);
|
||||||
#if OTA_DEBUG
|
#ifdef OTA_DEBUG
|
||||||
Serial.printf("Update Success\nRebooting...\n");
|
OTA_DEBUG.printf("Update Success\nRebooting...\n");
|
||||||
#endif
|
#endif
|
||||||
if (_end_callback) {
|
if (_end_callback) {
|
||||||
_end_callback();
|
_end_callback();
|
||||||
@ -301,8 +306,8 @@ void ArduinoOTAClass::_runUpdate() {
|
|||||||
_error_callback(OTA_END_ERROR);
|
_error_callback(OTA_END_ERROR);
|
||||||
}
|
}
|
||||||
Update.printError(client);
|
Update.printError(client);
|
||||||
#if OTA_DEBUG
|
#ifdef OTA_DEBUG
|
||||||
Update.printError(Serial);
|
Update.printError(OTA_DEBUG);
|
||||||
#endif
|
#endif
|
||||||
_state = OTA_IDLE;
|
_state = OTA_IDLE;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user