v5.7.1e - Add Sonoff SC debugging

5.7.1e
 * Add Sonoff SC debug information
 * Change syslog service
This commit is contained in:
arendst 2017-09-14 14:20:27 +02:00
parent c16fd3d99e
commit 2d5fc29976
8 changed files with 54 additions and 34 deletions

View File

@ -1,7 +1,7 @@
## Sonoff-Tasmota
Provide ESP8266 based Sonoff by [iTead Studio](https://www.itead.cc/) and ElectroDragon IoT Relay with Serial, Web and MQTT control allowing 'Over the Air' or OTA firmware updates using Arduino IDE.
Current version is **5.7.1d** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
Current version is **5.7.1e** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
### ATTENTION All versions

View File

@ -1,7 +1,11 @@
/* 5.7.1d
/* 5.7.1e
* Add Sonoff SC debug information
* Change syslog service
*
* 5.7.1d
* Fix watchdog timeout caused by lack of stack space by now using global buffers (#853)
* Removed webserver syslog disable as now no longer needed
* Increased default MQTT message size from 368 to 405 bytes while keeping DMQTT_MAX_PACKET_SIZE = 512 (because we can)
* Increased default MQTT message size from 368 to 405 bytes while keeping MQTT_MAX_PACKET_SIZE = 512 (because we can)
* Fix MQTT Offline or Remove MQTT retained topic code
* Allow command SwitchTopic in group mode (#861)
* Allow command SwitchMode if no switches are defined (#861)

View File

@ -175,6 +175,7 @@
#define D_TOGGLE "Toggle"
#define D_TOPIC "Topic"
#define D_TOTAL "Total"
#define D_TRANSMIT "Transmit"
#define D_TRUE "True"
#define D_TYPE "Type"
#define D_UNKNOWN "Unknown"
@ -478,7 +479,7 @@
#define D_LOG_APPLICATION "APP: "
#define D_LOG_BRIDGE "BRG: "
#define D_LOG_CONFIG "CFG: "
#define D_LOG_COMMAND "CND: "
#define D_LOG_COMMAND "CMD: "
#define D_LOG_DHT "DHT: "
#define D_LOG_DOMOTICZ "DOM: "
#define D_LOG_DSB "DSB: "
@ -494,6 +495,7 @@
#define D_LOG_UPLOAD "UPL: "
#define D_LOG_UPNP "UPP: "
#define D_LOG_WIFI "WIF: "
#define D_LOG_SERIAL "SER: "
// Result
#define D_RSLT_RESULT "RESULT"

View File

@ -175,6 +175,7 @@
#define D_TOGGLE "Toggle" // Wissel, Tuimel
#define D_TOPIC "Topic" // Onderwerp
#define D_TOTAL "Totaal"
#define D_TRANSMIT "Verzend"
#define D_TRUE "Waar"
#define D_TYPE "Soort"
#define D_UNKNOWN "Onbekend"
@ -478,7 +479,7 @@
#define D_LOG_APPLICATION "APP: "
#define D_LOG_BRIDGE "BRG: "
#define D_LOG_CONFIG "CFG: "
#define D_LOG_COMMAND "CND: "
#define D_LOG_COMMAND "CMD: "
#define D_LOG_DHT "DHT: "
#define D_LOG_DOMOTICZ "DOM: "
#define D_LOG_DSB "DSB: "
@ -494,6 +495,7 @@
#define D_LOG_UPLOAD "UPL: "
#define D_LOG_UPNP "UPP: "
#define D_LOG_WIFI "WIF: "
#define D_LOG_SERIAL "SER: "
// Result
#define D_RSLT_RESULT "RESULTAAT"

View File

@ -25,7 +25,7 @@
- Select IDE Tools - Flash Size: "1M (no SPIFFS)"
====================================================*/
#define VERSION 0x05070104 // 5.7.1d
#define VERSION 0x05070105 // 5.7.1e
enum log_t {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE, LOG_LEVEL_ALL};
enum week_t {Last, First, Second, Third, Fourth};
@ -158,7 +158,6 @@ enum opt_t {P_HOLD_TIME, P_MAX_POWER_RETRY, P_MAX_PARAM8}; // Index in sysCf
#include <PubSubClient.h> // MQTT
#ifndef MESSZ
// #define MESSZ 368 // Max number of characters in JSON message string (4 x DS18x20 sensors)
#define MESSZ 405 // Max number of characters in JSON message string (4 x DS18x20 sensors)
#endif
@ -218,13 +217,9 @@ TimeChangeRule mySTD = { TIME_STD }; // Standard Time
int Baudrate = APP_BAUDRATE; // Serial interface baud rate
byte SerialInByte; // Received byte
int SerialInByteCounter = 0; // Index in receive buffer
char serialInBuf[INPUT_BUFFER_SIZE + 2]; // Receive buffer
byte Hexcode = 0; // Sonoff dual input flag
uint16_t ButtonCode = 0; // Sonoff dual received code
int16_t savedatacounter; // Counter and flag for config save to Flash
char Version[16]; // Version string from VERSION define
char Hostname[33]; // Composed Wifi hostname
char MQTTClient[33]; // Composed MQTT Clientname
uint8_t mqttcounter = 0; // MQTT connection retry counter
uint8_t fallbacktopic = 0; // Use Topic or FallbackTopic
unsigned long timerxs = 0; // State loop timer
@ -298,6 +293,10 @@ uint8_t pwm_idxoffset = 0; // Allowed PWM command offset (change for
boolean mDNSbegun = false;
char Version[16]; // Version string from VERSION define
char Hostname[33]; // Composed Wifi hostname
char MQTTClient[33]; // Composed MQTT Clientname
char serialInBuf[INPUT_BUFFER_SIZE + 2]; // Receive buffer
char mqtt_data[MESSZ]; // MQTT publish buffer
char log_data[TOPSZ + MESSZ]; // Logging
String Log[MAX_LOG_LINES]; // Web log buffer

View File

@ -1146,11 +1146,15 @@ uint16_t getAdc0()
void syslog()
{
char str[TOPSZ + MESSZ];
// Destroys log_data
char syslog_preamble[64]; // Hostname + Id
if (portUDP.beginPacket(sysCfg.syslog_host, sysCfg.syslog_port)) {
snprintf_P(str, sizeof(str), PSTR("%s ESP-%s"), Hostname, log_data);
portUDP.write(str);
snprintf_P(syslog_preamble, sizeof(syslog_preamble), PSTR("%s ESP-"), Hostname);
memmove(log_data + strlen(syslog_preamble), log_data, sizeof(log_data) - strlen(syslog_preamble));
log_data[sizeof(log_data) -1] = '\0';
memcpy(log_data, syslog_preamble, strlen(syslog_preamble));
portUDP.write(log_data);
portUDP.endPacket();
} else {
syslog_level = 0;
@ -1166,7 +1170,9 @@ void addLog(byte loglevel)
snprintf_P(mxtime, sizeof(mxtime), PSTR("%02d" D_HOUR_MINUTE_SEPARATOR "%02d" D_MINUTE_SECOND_SEPARATOR "%02d"), rtcTime.Hour, rtcTime.Minute, rtcTime.Second);
if (loglevel <= seriallog_level) Serial.printf("%s %s\n", mxtime, log_data);
if (loglevel <= seriallog_level) {
Serial.printf("%s %s\n", mxtime, log_data);
}
#ifdef USE_WEBSERVER
if (sysCfg.webserver && (loglevel <= sysCfg.weblog_level)) {
Log[logidx] = String(mxtime) + " " + String(log_data);
@ -1189,11 +1195,11 @@ void addLog_P(byte loglevel, const char *formatP)
void addLog_P(byte loglevel, const char *formatP, const char *formatP2)
{
char mes2[100];
char message[100];
snprintf_P(log_data, sizeof(log_data), formatP);
snprintf_P(mes2, sizeof(mes2), formatP2);
strncat(log_data, mes2, sizeof(log_data));
snprintf_P(message, sizeof(message), formatP2);
strncat(log_data, message, sizeof(log_data));
addLog(loglevel);
}

View File

@ -429,7 +429,8 @@ void handleRoot()
if (HTTP_MANAGER == _httpflag) {
handleWifi0();
} else {
char stemp[10], line[160];
char stemp[10];
char line[160];
String page = FPSTR(HTTP_HEAD);
page.replace(F("{v}"), FPSTR(S_MAIN_MENU));
page.replace(F("<body>"), F("<body onload='la()'>"));
@ -1085,7 +1086,7 @@ void handleReset()
return;
}
char svalue[16]; // was MESSZ
char svalue[16];
addLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_RESET_CONFIGURATION);
@ -1144,7 +1145,7 @@ void handleUpgradeStart()
if (httpUser()) {
return;
}
char svalue[100]; // was MESSZ
char svalue[100];
addLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_UPGRADE_STARTED));
WIFI_configCounter();

View File

@ -55,11 +55,19 @@
uint16_t sc_value[5] = { 0 };
void sc_send(const char *data)
{
Serial.write(data);
Serial.write('\x1B');
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_SERIAL D_TRANSMIT " %s"), data);
addLog(LOG_LEVEL_DEBUG);
}
void sc_init()
{
// Serial.write("AT+DEVCONFIG=\"uploadFreq\":1800\e");
Serial.write("AT+START\e");
// Serial.write("AT+STATUS\e");
// sc_send("AT+DEVCONFIG=\"uploadFreq\":1800");
sc_send("AT+START");
// sc_send("AT+STATUS");
}
void sc_rcvstat(char *rcvstat)
@ -68,7 +76,10 @@ void sc_rcvstat(char *rcvstat)
char *str;
uint16_t value[5] = { 0 };
if (!strncmp(rcvstat, "AT+UPDATE=", 10)) {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_SERIAL D_RECEIVED " %s"), rcvstat);
addLog(LOG_LEVEL_DEBUG);
if (!strncasecmp_P(rcvstat, PSTR("AT+UPDATE="), 10)) {
int8_t i = -1;
for (str = strtok_r(rcvstat, ":", &p); str && i < 5; str = strtok_r(NULL, ":", &p)) {
value[i++] = atoi(str);
@ -80,13 +91,13 @@ void sc_rcvstat(char *rcvstat)
sc_value[2] = (11 - sc_value[2]) * 10; // Invert light level
sc_value[3] *= 10;
sc_value[4] = (11 - sc_value[4]) * 10; // Invert dust level
Serial.write("AT+SEND=ok\e");
sc_send("AT+SEND=ok");
} else {
Serial.write("AT+SEND=fail\e");
sc_send("AT+SEND=fail");
}
}
else if (!strcmp_P(rcvstat,PSTR("AT+STATUS?"))) {
Serial.write("AT+STATUS=4\e");
else if (!strcasecmp_P(rcvstat, PSTR("AT+STATUS?"))) {
sc_send("AT+STATUS=4");
}
}
@ -94,11 +105,6 @@ void sc_rcvstat(char *rcvstat)
* Presentation
\*********************************************************************************************/
float sc_convertCtoF(float c)
{
return c * 1.8 + 32;
}
void sc_mqttPresent(uint8_t* djson)
{
if (sc_value[0] > 0) {