From c75f4893e8182ea472db2ba067679dfebc2c9eda Mon Sep 17 00:00:00 2001 From: hsaturn Date: Sat, 10 Apr 2021 14:03:36 +0200 Subject: [PATCH] AsyncTcp AsyncTcp --- src/TinyMqtt.cpp | 1 + src/TinyMqtt.h | 10 +--------- tests/Makefile | 2 +- tests/local-tests/Makefile | 2 +- tests/nowifi-tests/Makefile | 2 +- tests/string-indexer-tests/Makefile | 2 +- 6 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/TinyMqtt.cpp b/src/TinyMqtt.cpp index da96ee1..74ca4b1 100644 --- a/src/TinyMqtt.cpp +++ b/src/TinyMqtt.cpp @@ -672,6 +672,7 @@ void MqttMessage::add(const char* p, size_t len, bool addLength) { if (addLength) { + buffer.reserve(buffer.length()+addLength+2); incoming(len>>8); incoming(len & 0xFF); } diff --git a/src/TinyMqtt.h b/src/TinyMqtt.h index ee9692e..d6dc2db 100644 --- a/src/TinyMqtt.h +++ b/src/TinyMqtt.h @@ -80,23 +80,15 @@ class MqttMessage // output buff+=2, len=length(str) static void getString(const char* &buff, uint16_t& len); - Type type() const { return state == Complete ? static_cast(buffer[0]) : Unknown; } - // shouldn't exist because it breaks constness :-( - // but this saves memory so ... - void changeType(Type type) const - { - buffer[0] = type; - } - void create(Type type) { buffer=(char)type; - buffer+='\0'; + buffer+='\0'; // reserved for msg length vheader=2; size=0; state=Create; diff --git a/tests/Makefile b/tests/Makefile index bfea400..e2d6bac 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -5,7 +5,7 @@ tests: $(MAKE) -C $$(dirname $$i) -j; \ done -runtests: +runtests: tests set -e; \ for i in *-tests/Makefile; do \ echo '==== Running:' $$(dirname $$i); \ diff --git a/tests/local-tests/Makefile b/tests/local-tests/Makefile index 8781b42..232112d 100644 --- a/tests/local-tests/Makefile +++ b/tests/local-tests/Makefile @@ -3,5 +3,5 @@ APP_NAME := local-tests ARDUINO_LIBS := AUnit AceCommon AceTime TinyMqtt EspMock -ESP_LIBS = ESP8266WiFi +ESP_LIBS = ESP8266WiFi ESPAsyncTCP include ../../../EspMock/EspMock.mk diff --git a/tests/nowifi-tests/Makefile b/tests/nowifi-tests/Makefile index 3733f64..b5913b1 100644 --- a/tests/nowifi-tests/Makefile +++ b/tests/nowifi-tests/Makefile @@ -3,5 +3,5 @@ APP_NAME := nowifi-tests ARDUINO_LIBS := AUnit AceCommon AceTime TinyMqtt EspMock -ESP_LIBS = ESP8266WiFi +ESP_LIBS = ESP8266WiFi ESPAsyncTCP include ../../../EspMock/EspMock.mk diff --git a/tests/string-indexer-tests/Makefile b/tests/string-indexer-tests/Makefile index acb264f..9673cca 100644 --- a/tests/string-indexer-tests/Makefile +++ b/tests/string-indexer-tests/Makefile @@ -3,5 +3,5 @@ APP_NAME := string-indexer-tests ARDUINO_LIBS := AUnit AceCommon AceTime TinyMqtt EspMock -ESP_LIBS = ESP8266WiFi +ESP_LIBS = ESP8266WiFi ESPAsyncTCP include ../../../EspMock/EspMock.mk