mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
added test for large MQTT packages
This commit is contained in:
@@ -711,6 +711,29 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) {
|
|||||||
shell.invoke_command("call system pin 1 true");
|
shell.invoke_command("call system pin 1 true");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (command == "mqtt2") {
|
||||||
|
shell.printfln(F("Testing MQTT large payloads..."));
|
||||||
|
|
||||||
|
DynamicJsonDocument doc(EMSESP_JSON_SIZE_XXLARGE_DYN);
|
||||||
|
|
||||||
|
char key[6];
|
||||||
|
char value[6];
|
||||||
|
|
||||||
|
// fit it up, to its limit of the Json buffer (which is about 169 records)
|
||||||
|
for (uint8_t i = 0; i < 200; i++) {
|
||||||
|
snprintf_P(key, 7, PSTR("key%03d"), i);
|
||||||
|
snprintf_P(value, 7, PSTR("val%03d"), i);
|
||||||
|
doc[key] = value;
|
||||||
|
}
|
||||||
|
doc.shrinkToFit();
|
||||||
|
JsonObject jo = doc.as<JsonObject>();
|
||||||
|
shell.printfln(F("Size of JSON payload = %d"), jo.memoryUsage());
|
||||||
|
shell.printfln(F("Length of JSON payload = %d"), measureJson(jo));
|
||||||
|
|
||||||
|
Mqtt::publish("test", jo);
|
||||||
|
Mqtt::show_mqtt(shell); // show queue
|
||||||
|
}
|
||||||
|
|
||||||
if (command == "mqtt") {
|
if (command == "mqtt") {
|
||||||
shell.printfln(F("Testing MQTT..."));
|
shell.printfln(F("Testing MQTT..."));
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ namespace emsesp {
|
|||||||
// #define EMSESP_TEST_DEFAULT "mixer"
|
// #define EMSESP_TEST_DEFAULT "mixer"
|
||||||
// #define EMSESP_TEST_DEFAULT "web"
|
// #define EMSESP_TEST_DEFAULT "web"
|
||||||
// #define EMSESP_TEST_DEFAULT "general"
|
// #define EMSESP_TEST_DEFAULT "general"
|
||||||
#define EMSESP_TEST_DEFAULT "boiler"
|
// #define EMSESP_TEST_DEFAULT "boiler"
|
||||||
|
#define EMSESP_TEST_DEFAULT "mqtt2"
|
||||||
|
|
||||||
class Test {
|
class Test {
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user