Compare commits

...
Author SHA1 Message Date
ESPEasy release bot 8fc6486855 automatically updated release notes for mega-20180910 2018-09-10 04:00:23 +02:00
Gijs NoorlanderandGitHub eeb1cc71b3 Merge pull request #1728 from TD-er/bugfix/command_send_http
Bugfix/command SendToHTTP  & Domoticz IDX > 9999
2018-09-10 01:02:58 +02:00
TD-er 13837830e8 [Domoticz IDX] Allow for IDX of > 9999 2018-09-09 23:00:16 +02:00
Gijs NoorlanderandGitHub f86ff46a82 Merge pull request #1727 from sakinit/P1WifiGatewayModuleBufSize
Reduced buffer size to prevent stack overflow
2018-09-09 22:53:23 +02:00
TD-er e901bc957a [HTTP] Command SendToHttp cannot connect
Incorrect check for return value.
As suggested via the [forum](https://www.letscontrolit.com/forum/viewtopic.php?f=6&t=5794&p=31203#p31181)
2018-09-09 21:58:14 +02:00
sakinit e7e10c5305 Reduced buffer size to prevent stack overflow 2018-09-09 19:54:23 +02:00
6 changed files with 38 additions and 16 deletions
+14
View File
@@ -1,3 +1,17 @@
-------------------------------------------------
Changes in release mega-20180910 (since mega-20180909)
-------------------------------------------------
Release date: Mon Sep 10 04:00:22 CEST 2018
TD-er (2):
[HTTP] Command SendToHttp cannot connect
[Domoticz IDX] Allow for IDX of > 9999
sakinit (1):
Reduced buffer size to prevent stack overflow
-------------------------------------------------
Changes in release mega-20180909 (since mega-20180908)
-------------------------------------------------
+2 -1
View File
@@ -24,7 +24,8 @@ String Command_HTTP_SendToHTTP(struct EventStruct *event, const char* Line)
}
WiFiClient client;
const int port_int = port.toInt();
if (client.connect(host.c_str(), port_int) != 1) {
const bool connected = client.connect(host.c_str(), port_int) == 1;
if (connected) {
String hostportString = host;
if (port_int != 0 && port_int != 80) {
hostportString += ':';
+3
View File
@@ -357,6 +357,9 @@
#define SENSOR_TYPE_LONG 20
#define SENSOR_TYPE_WIND 21
#define UNIT_NUMBER_MAX 9999 // Stored in Settings.Unit
#define DOMOTICZ_MAX_IDX 999999999 // Looks like it is an unsigned int, so could be up to 4 bln.
#define VALUE_SOURCE_SYSTEM 1
#define VALUE_SOURCE_SERIAL 2
#define VALUE_SOURCE_HTTP 3
+2 -2
View File
@@ -1082,7 +1082,7 @@ void handle_config() {
Settings.Name[25] = 0;
SecuritySettings.Password[25] = 0;
addFormTextBox( F("Unit Name"), F("name"), Settings.Name, 25);
addFormNumericBox( F("Unit Number"), F("unit"), Settings.Unit, 0, 9999);
addFormNumericBox( F("Unit Number"), F("unit"), Settings.Unit, 0, UNIT_NUMBER_MAX);
addFormPasswordBox(F("Admin Password"), F("password"), SecuritySettings.Password, 25);
addFormSubHeader(F("Wifi Settings"));
@@ -2283,7 +2283,7 @@ void handle_devices() {
html_TR_TD(); TXBuffer += F("IDX:<TD>");
id = F("TDID"); //="taskdeviceid"
id += controllerNr + 1;
addNumericBox(id, Settings.TaskDeviceID[controllerNr][taskIndex], 0, 999999999); // Looks like it is an unsigned int, so could be up to 4 bln.
addNumericBox(id, Settings.TaskDeviceID[controllerNr][taskIndex], 0, DOMOTICZ_MAX_IDX);
}
}
}
+1 -1
View File
@@ -53,7 +53,7 @@ boolean Plugin_029(byte function, struct EventStruct *event, String& string)
addHtml(F("<TR><TD>IDX:<TD>"));
String id = F("TDID"); //="taskdeviceid"
id += controllerNr + 1;
addNumericBox(id, Settings.TaskDeviceID[controllerNr][event->TaskIndex], 0, 9999);
addNumericBox(id, Settings.TaskDeviceID[controllerNr][event->TaskIndex], 0, DOMOTICZ_MAX_IDX);
success = true;
break;
}
+16 -12
View File
@@ -16,7 +16,7 @@
#define P044_STATUS_LED 12
#define P044_BUFFER_SIZE 1024
#define P044_NETBUF_SIZE 600
#define P044_NETBUF_SIZE 128
#define P044_DISABLED 0
#define P044_WAITING 1
#define P044_READING 2
@@ -31,7 +31,7 @@ boolean CRCcheck = false;
unsigned int currCRC = 0;
int checkI = 0;
WiFiServer *P1GatewayServer;
WiFiServer *P1GatewayServer = nullptr;
WiFiClient P1GatewayClient;
boolean Plugin_044(byte function, struct EventStruct *event, String& string)
@@ -125,7 +125,11 @@ boolean Plugin_044(byte function, struct EventStruct *event, String& string)
#if defined(ESP32)
Serial.begin(ExtraTaskSettings.TaskDevicePluginConfigLong[1], serialconfig);
#endif
if (P1GatewayServer) P1GatewayServer->close();
if (P1GatewayServer)
{
P1GatewayServer->close();
delete P1GatewayServer;
}
P1GatewayServer = new WiFiServer(ExtraTaskSettings.TaskDevicePluginConfigLong[0]);
P1GatewayServer->begin();
@@ -164,7 +168,7 @@ boolean Plugin_044(byte function, struct EventStruct *event, String& string)
{
if (P1GatewayServer) {
P1GatewayServer->close();
//FIXME: shouldnt P1P1GatewayServer be deleted?
delete P1GatewayServer;
P1GatewayServer = NULL;
}
success = true;
@@ -175,7 +179,6 @@ boolean Plugin_044(byte function, struct EventStruct *event, String& string)
{
if (Plugin_044_init)
{
size_t bytes_read;
if (P1GatewayServer->hasClient())
{
if (P1GatewayClient) P1GatewayClient.stop();
@@ -186,24 +189,25 @@ boolean Plugin_044(byte function, struct EventStruct *event, String& string)
if (P1GatewayClient.connected())
{
connectionState = 1;
uint8_t net_buf[P044_BUFFER_SIZE];
uint8_t net_buf[P044_NETBUF_SIZE];
int count = P1GatewayClient.available();
if (count > 0)
{
if (count > P044_BUFFER_SIZE)
count = P044_BUFFER_SIZE;
bytes_read = P1GatewayClient.read(net_buf, count);
Serial.write(net_buf, bytes_read);
size_t net_bytes_read;
if (count > P044_NETBUF_SIZE)
count = P044_NETBUF_SIZE;
net_bytes_read = P1GatewayClient.read(net_buf, count);
Serial.write(net_buf, net_bytes_read);
Serial.flush(); // Waits for the transmission of outgoing serial data to complete
if (count == P044_BUFFER_SIZE) // if we have a full buffer, drop the last position to stuff with string end marker
if (count == P044_NETBUF_SIZE) // if we have a full buffer, drop the last position to stuff with string end marker
{
count--;
// and log buffer full situation
addLog(LOG_LEVEL_ERROR, F("P1 : Error: network buffer full!"));
}
net_buf[count] = 0; // before logging as a char array, zero terminate the last position to be safe.
char log[P044_BUFFER_SIZE + 40];
char log[P044_NETBUF_SIZE + 40];
sprintf_P(log, PSTR("P1 : Error: N>: %s"), (char*)net_buf);
addLog(LOG_LEVEL_DEBUG, log);
}