mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
optional compile with CRASH support
This commit is contained in:
@@ -291,7 +291,10 @@ void MyESP::_mqtt_setup() {
|
||||
|
||||
//mqttClient.onPublish([this](uint16_t packetId) { myDebug_P(PSTR("[MQTT] Publish ACK for PID %d"), packetId); });
|
||||
|
||||
mqttClient.onMessage([this](char * topic, char * payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total) { _mqttOnMessage(topic, payload, len); });
|
||||
mqttClient.onMessage(
|
||||
[this](char * topic, char * payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total) {
|
||||
_mqttOnMessage(topic, payload, len);
|
||||
});
|
||||
}
|
||||
|
||||
// WiFI setup
|
||||
@@ -468,7 +471,10 @@ void MyESP::_consoleShowHelp() {
|
||||
#else
|
||||
String hostname = WiFi.hostname();
|
||||
#endif
|
||||
SerialAndTelnet.printf("* Hostname: %s IP: %s MAC: %s", hostname.c_str(), WiFi.localIP().toString().c_str(), WiFi.macAddress().c_str());
|
||||
SerialAndTelnet.printf("* Hostname: %s IP: %s MAC: %s",
|
||||
hostname.c_str(),
|
||||
WiFi.localIP().toString().c_str(),
|
||||
WiFi.macAddress().c_str());
|
||||
#ifdef ARDUINO_BOARD
|
||||
SerialAndTelnet.printf(" Board: %s", ARDUINO_BOARD);
|
||||
#endif
|
||||
@@ -864,7 +870,17 @@ void MyESP::setWIFI(const char * wifi_ssid, const char * wifi_password, wifi_cal
|
||||
}
|
||||
|
||||
// init MQTT settings
|
||||
void MyESP::setMQTT(const char * mqtt_host, const char * mqtt_username, const char * mqtt_password, const char * mqtt_base, unsigned long mqtt_keepalive, unsigned char mqtt_qos, bool mqtt_retain, const char * mqtt_will_topic, const char * mqtt_will_online_payload, const char * mqtt_will_offline_payload, mqtt_callback_f callback) {
|
||||
void MyESP::setMQTT(const char * mqtt_host,
|
||||
const char * mqtt_username,
|
||||
const char * mqtt_password,
|
||||
const char * mqtt_base,
|
||||
unsigned long mqtt_keepalive,
|
||||
unsigned char mqtt_qos,
|
||||
bool mqtt_retain,
|
||||
const char * mqtt_will_topic,
|
||||
const char * mqtt_will_online_payload,
|
||||
const char * mqtt_will_offline_payload,
|
||||
mqtt_callback_f callback) {
|
||||
// can be empty
|
||||
if (!mqtt_host || *mqtt_host == 0x00) {
|
||||
_mqtt_host = NULL;
|
||||
@@ -1148,13 +1164,13 @@ int MyESP::getWifiQuality() {
|
||||
return 2 * (dBm + 100);
|
||||
}
|
||||
|
||||
#ifdef CRASH
|
||||
/**
|
||||
* Save crash information in EEPROM
|
||||
* This function is called automatically if ESP8266 suffers an exception
|
||||
* It should be kept quick / consise to be able to execute before hardware wdt may kick in
|
||||
*/
|
||||
extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack_start, uint32_t stack_end) {
|
||||
|
||||
// Note that 'EEPROM.begin' method is reserving a RAM buffer
|
||||
// The buffer size is SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_SPACE_SIZE
|
||||
EEPROM.begin(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EEPROM_SIZE);
|
||||
@@ -1295,6 +1311,17 @@ void MyESP::crashDump() {
|
||||
}
|
||||
myDebug("<<<stack<<<");
|
||||
}
|
||||
#else
|
||||
void MyESP::crashTest(uint8_t t) {
|
||||
myDebug("[CRASH] disabled or not supported");
|
||||
}
|
||||
void MyESP::crashClear() {
|
||||
myDebug("[CRASH] disabled or not supported");
|
||||
}
|
||||
void MyESP::crashDump() {
|
||||
myDebug("[CRASH] disabled or not supported");
|
||||
}
|
||||
#endif
|
||||
|
||||
// setup MyESP
|
||||
void MyESP::begin(const char * app_hostname, const char * app_name, const char * app_version) {
|
||||
|
||||
@@ -19,10 +19,12 @@
|
||||
#include <JustWifi.h> // https://github.com/xoseperez/justwifi
|
||||
#include <TelnetSpy.h> // modified from https://github.com/yasheena/telnetspy
|
||||
|
||||
#ifdef CRASH
|
||||
#include "EEPROM.h"
|
||||
extern "C" {
|
||||
void custom_crash_callback(struct rst_info*, uint32_t, uint32_t);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
//#include <ESPmDNS.h>
|
||||
|
||||
@@ -5,7 +5,7 @@ env_default = d1_mini
|
||||
platform = espressif8266
|
||||
flash_mode = dout
|
||||
|
||||
build_flags_debug = -ggdb3 -Wall -Wextra -Werror -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-variable
|
||||
build_flags_debug = -ggdb3 -Wall -Wextra -Werror -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-variable -DCRASH
|
||||
;build_flags_prod = -Os -DBUILD_TIME=$UNIX_TIME
|
||||
|
||||
build_flags = ${common.build_flags_debug}
|
||||
|
||||
Reference in New Issue
Block a user