Giter VIP home page Giter VIP logo

enigmaiot's Introduction

EnigmaIoT

EnigmaIoT Logo

ESP8266

ESP32

Introduction

EnigmaIoT is an open source solution for wireless multi sensor systems. It has two main components, multiple nodes and one gateway.

A number of nodes with one or more sensors each one communicate in a secure way to a central gateway in a star network using EnigmaIoT protocol.

This protocol has been designed with security on mind. All node data is encrypted with a random key that changes periodically. Key is unique for each node and dynamically negotiated, so user do not have to enter any key. Indeed, all encryption and key agreement is transparent to user.

I designed this because I was searching for a way to have a relatively high number of nodes at home. I thought about using WiFi but it would overload my home router. So I looked for an alternative. I evaluated LoRa or cheap nRF24 modules but I wanted the simplest solution in terms of hardware.

ESP8266 and ESP32 microcontrollers implement a protocol known as ESP-NOW. It is a point to point protocol, based on vendor specific WiFi management action frames, that works in a connectionless fashion and every packet is a few milliseconds long. Because of this, it eases to have a battery powered node so that it enables designing totally wireless sensors.

But use of encryption on ESP-NOW limits the number of nodes to only 6 nodes. So I thought that I could implement encryption on payload but I found many problems I should solve to grade this as "secure enough".

Find library documentation on https://gmag11.github.io/EnigmaIOT

Quick start

It you are courious to quickly test how does EnigmaIOT performs you can follow this howto guide. This will guide you on how to:

  • Setup your gateway
  • Build simplest EnigmaIOT node
  • Configure your first node
  • Develop custom nodes with advanced features

Project requirements

During this project conception I decided that it should fulfil this list of requirements.

  • Use the simplest hardware, based on ESP8266 and/or ESP32.
  • Secure by design. Make use of a secure channel for data transmission.
  • Automatic dynamic key agreement.
  • Do not require connection to the Internet.
  • Do not overload my home WiFi infrastructure. Only Gateway will be connected to LAN.
  • Able to use deep sleep to run on batteries.
  • Enough wireless range for a house.
  • Support for a high number of nodes.

Features

  • Encrypted communication using ChaCha20/Poly1305
  • Dynamic key, shared between one node and gateway. Keys are independent for each node
  • Shared keys are expired after a certain (configurable) time.
  • Number of nodes is only limited by memory on gateway (60 bytes per node)
  • Key is never on air so it is cannot be captured
  • Key expiration and renewal is managed transparently
  • Avoid repeatability attack having a new random initialization vector on every message. This is mandatory for ChaCha20/Poly1305 in order to keep cipher secure
  • Automatic and transparent node attachment
  • Avoid rogue node, rogue gateway and man-in-the-middle attack

Notice that network key used to implement this feature is stored on flash. ESP8266 do not allow flash encryption so network key may be recovered reading flash.

  • Pluggable physical layer communication. Right now only ESP-NOW protocol is developed but you can easily add more communication alternatives

  • When using ESP-NOW only ESP8266 or ESP32 is needed. No more electronics apart from sensor

  • Data message counter to detect lost or repeated messages

  • Designed as two libraries (one for gateway, one for node) for easier use

  • Crypto algorithm could be changed with low effort

  • Node and Gateway do store shared keys only on RAM. They are lost on power cycle. This protects system against flash reading attack. All nodes attach automatically with a new shared key after gateway is switched on

  • Downlink available. If deep sleep is used on sensor nodes, it is queued and sent just after node send a data message

  • Optional sleep mode management. In this case key and context has to be stored temporally. Normally RTC memory is the recommended place, and it is the one currently implemented. Note: There is the alternative to store context on flash memory so that node can be completely switched off between massages without requiring a new registering. Notice that on every received or sent message node updates this context so consider that a high number of writes in flash may degrade it in the medium term. If messages counters are disabled in configuration the number of writes is decreased drastically but this reduces security level as it makes possible to repeat messages.

  • Initial configuration over WiFi portal on each device

  • Node configuration while in service using control downlink commands

  • OTA over WiFi. Question: Is it really useful? Place an issue explaining an use case.

  • OTA over MQTT/ESP-NOW. Check OTA script guide.

  • Node identification by using a flashing LED. This is useful when you have a bunch of nodes together :D

  • Broadcast messages that go to all nodes. This is implemented by sending messages to broadcast address (ff:ff:ff:ff:ff:ff in esp-now). Only nodes that are always listening are able to receive these messages, they are not queued. In order to send a broadcast message using EnigmaIOTGatewayMQTT you may use <network name>/broadcast/... as topi beginning. Any control or data message will arrive all nodes that have broadcast enabled. Control messages are processed normally except OTA and SET NAME, which are ignored. Data messages are passed to user code for processing.

    A shared encryption key is used to encrypt broadcast messages. It is generated automatically by Gateway on every restart.

    If a node registers with broadcast flag active, gateway sends broadcast key using this message just after successful registration. Broadcast key is automatically generated on gateway on boot, so it will be different after every restart. Nodes will be synchronized as soon they register again.

    A node may not send broadcast messages, only gateway can.

  • Both gateway or nodes may run on ESP32 or ESP8266

  • Simple REST API to get information and send commands to gateway and nodes. Check api.md

  • Node library includes methods to configure Home Assistant automatic integration using MQTT discovery

Technical background

If you want to know the internals about EnigmaIOT check Technical Background Guide.

enigmaiot's People

Contributors

arihantdaga avatar gmag11 avatar steven52880 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

enigmaiot's Issues

Issue building for an esp32 with version 0.9.7

.pio/libdeps/esp32/Crypto/src/SHA384.cpp: In member function 'virtual void SHA384::reset()':
.pio/libdeps/esp32/Crypto/src/SHA384.cpp:57:51: error: 'memcpy' was not declared in this scope
     memcpy_P(state.h, hashStart, sizeof(hashStart));
                                                   ^
*** [.pio/build/esp32/libe26/Crypto/SHA384.cpp.o] Error 1

please fix

Portal recovery problem

Try with esp32 models;

  • MH-ET LIVE D1 mini
  • MH-ET LIVE
  • DevKit v1

Code source: https://github.com/gmag11/EnigmaIOT/tree/master/examples/EnigmaIOTGatewayMQTT

Description:
When there is no more valid connection to the router and the gateway returns to portal mode, the web server does not display the portal.

logs

*WM: Connecting as wifi client...
*WM: Try to connect with saved credentials
E (7288) wifi:sta is connecting, return error
[E][WiFiSTA.cpp:221] begin(): connect failed!

*WM: SET AP STA
*WM: 
*WM: Configuring access point... 
*WM: EnigmaIoTGateway
[W][WiFiGeneric.cpp:391] _eventCallback(): Reason: 201 - NO_AP_FOUND
*WM: AP IP address: 
*WM: 192.168.4.1
[E][AsyncTCP.cpp:1268] begin(): bind error: -8
*WM: HTTP server started
*WM: About to scan()
*WM: About to scan()
*WM: Scan done
*WM: About to scan()
*WM: About to scan()
*WM: Scan done
[W][GatewayAPI.cpp:379] onNotFound(): 26989 Heap: 199708 404 Not found: /generate_204_1df8d5dd-4364-4223-a4f3-e55fef11ec25
[W][GatewayAPI.cpp:380] onNotFound(): 26989 Heap: 199708 Method: GET
[W][GatewayAPI.cpp:379] onNotFound(): 27036 Heap: 198940 404 Not found: /generate_204
[W][GatewayAPI.cpp:380] onNotFound(): 27036 Heap: 198940 Method: GET
[W][GatewayAPI.cpp:379] onNotFound(): 28175 Heap: 198852 404 Not found: /generate_204_7b4d026c-1ade-41d5-89ec-0ffa4b10b526
[W][GatewayAPI.cpp:380] onNotFound(): 28176 Heap: 198852 Method: GET
[W][GatewayAPI.cpp:379] onNotFound(): 28207 Heap: 200412 404 Not found: /generate_204
[W][GatewayAPI.cpp:380] onNotFound(): 28208 Heap: 200412 Method: GET
[W][GatewayAPI.cpp:379] onNotFound(): 30260 Heap: 200324 404 Not found: /generate_204_023258e7-f9c4-4477-b271-36d16e1cd08f
[W][GatewayAPI.cpp:380] onNotFound(): 30261 Heap: 200324 Method: GET
[W][GatewayAPI.cpp:379] onNotFound(): 30290 Heap: 198948 404 Not found: /generate_204

Infinite loop

I have been testing v0.8.3 and I only receive the status and the rssi but not the message.
I have compiled the gateway with debug_info and this is what I get:
[I][EnigmaIOTGatewayMQTT.ino:174] processRxData(): 7725 Heap: 237524 Published MQTT from A0:20:A6:08:CD:88: {"per":0.000000e+00,"lostmessages":0,"totalmessages":1,"packetshour":11320.75}
[I][GwOutput_mqtt.cpp:411] publishMQTT(): 7764 Heap: 237772 Publish MQTT. Esp-New/A0:20:A6:08:CD:88/data : [{"channel":38,"type":103,"name":"temperature","value":27.4},{"channel":38,"type":104,"name":"humidity","value":69},{"channel":38,"type":142,"name":"switch","value":0},{"channel":38,"type":115,"name":"pressure","value":0.9},{"channel":38,"type":142,"name":"switch","value":0},{"channel":39,"type":2,"name":"analog_input","value":42}]
[I][EnigmaIOTGateway.cpp:836] manageMessage(): 7780 Heap: 238048 Data OK
[I][GwOutput_mqtt.cpp:411] publishMQTT(): 7819 Heap: 238412 Publish MQTT. Esp-New/A0:20:A6:08:CD:88/data : [{"channel":38,"type":103,"name":"temperature","value":27.4},{"channel":38,"type":104,"name":"humidity","value":69},{"channel":38,"type":142,"name":"switch","value":0},{"channel":38,"type":115,"name":"pressure","value":0.9},{"channel":38,"type":142,"name":"switch","value":0},{"channel":39,"type":2,"name":"analog_input","value":42}]
[I][GwOutput_mqtt.cpp:411] publishMQTT(): 7863 Heap: 240256 Publish MQTT. Esp-New/A0:20:A6:08:CD:88/data : [{"channel":38,"type":103,"name":"temperature","value":27.4},{"channel":38,"type":104,"name":"humidity","value":69},{"channel":38,"type":142,"name":"switch","value":0},{"channel":38,"type":115,"name":"pressure","value":0.9},{"channel":38,"type":142,"name":"switch","value":0},{"channel":39,"type":2,"name":"analog_input","value":42}]
[I][GwOutput_mqtt.cpp:411] publishMQTT(): 7902 Heap: 240256 Publish MQTT. Esp-New/A0:20:A6:08:CD:88/data : [{"channel":38,"type":103,"name":"temperature","value":27.4},{"channel":38,"type":104,"name":"humidity","value":69},{"channel":38,"type":142,"name":"switch","value":0},{"channel":38,"type":115,"name":"pressure","value":0.9},{"channel":38,"type":142,"name":"switch","value":0},{"channel":39,"type":2,"name":"analog_input","value":42}]
[I][GwOutput_mqtt.cpp:411] publishMQTT(): 7940 Heap: 240256 Publish MQTT. Esp-New/A0:20:A6:08:CD:88/data : [{"channel":38,"type":103,"name":"temperature","value":27.4},{"channel":38,"type":104,"name":"humidity","value":69},{"channel":38,"type":142,"name":"switch","value":0},{"channel":38,"type":115,"name":"pressure","value":0.9},{"channel":38,"type":142,"name":"switch","value":0},{"channel":39,"type":2,"name":"analog_input","value":42}]

...infinite

I have tried with Wemos D1 mini
and with LOLIN32 (without mqtt_secure)
both with the same result.

El Gateway MQTT EnigmaIOT no funciona correctamente.

He descargado el proyecto EnigmaIOT y estoy compilando sus ejemplos (Los nodos en ESP8266, El Gateway en ESP32 y el broker lo alterno entre un Odroid C1+ y un tv box con Armbian instalado) hasta ahora los ejemplos compilan sin errores pero no he logrado poner en marcha la red. Aún no he entrado a fondo a solucionar el error pero en el código de:

  • @file EnigmaIOTGatewayMQTT.ino
    • @Version 0.9.8
    • @Date 15/07/2021
    • @author German Martin
    • @brief MQTT Gateway based on EnigmaIoT over ESP-NOW
      Una vez se carga al ESP32 este entra en punto de acceso como debe ser con WifiManager sin embargo al ingresarle los datos de autenticación no sale del modo punto de acceso y no se conecta a la red, envia el mensaje "Handle not found" y vuelve a mostar el portal cautivo. Favor revisar el ejemplo.

trying to build MQTT-noSSL

build_errors.txt
Hi,

Got PlatformIO installed, got Git working (issue #30) and now trying to build the MQTT-nossl example. I am used to Arduino IDE so step learning curve here.. going to be something very basic I suspect (missing library?) .. googling now
PS: Please keep writing that "how to" documentation .

I have attached a text file with the build output

Archiving .pio\build\esp32-MQTTGateway-NoSSL\libFrameworkArduino.a
Linking .pio\build\esp32-MQTTGateway-NoSSL\firmware.elf
.pio\build\esp32-MQTTGateway-NoSSL\libFrameworkArduino.a(main.cpp.o):(.literal._Z8loopTaskPv+0x8): undefined reference to setup()' .pio\build\esp32-MQTTGateway-NoSSL\libFrameworkArduino.a(main.cpp.o):(.literal._Z8loopTaskPv+0xc): undefined reference to loop()'.pio\build\esp32-MQTTGateway-NoSSL\libFrameworkArduino.a(main.cpp.o): In function loopTask(void*)': C:\Users\gam\.platformio\packages\framework-arduinoespressif32\cores\esp32/main.cpp:18: undefined reference to setup()'
C:\Users\gam.platformio\packages\framework-arduinoespressif32\cores\esp32/main.cpp:21: undefined reference to `loop()'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\esp32-MQTTGateway-NoSSL\firmware.elf] Error 1

Thanks
Geoffrey Mills

Problem with time synchronization in node_nonsleepy

In release 0.9.7 when you synchronize the time you always get "19/01/1970 17:51:34", it always does not change with the passage of time.
The gateway synchronizes well with NTP, its date and time are correct.
here is a screenshot of the node's debug_info.

No sync localtime: 986986500
Timestamp sec: 1615894
19/01/1970 17:51:34
Vcc: 3.050000
Trying to send: 00 02 01 31 01 67 00 CB 
I [3800382][EnigmaIOTNode.cpp:1686] dataMessage() Heap: 38208 | Data message #385
I [3800387][EnigmaIOTNode.cpp:1729] dataMessage() Heap: 38208 |  -------> DATA
---- Data sent
I [3805378][EnigmaIOTNode.cpp:1309] clockRequest() Heap: 38232 | Control message #136
I [3805378][EnigmaIOTNode.cpp:1338] clockRequest() Heap: 38232 |  -------> CLOCK REQUEST
I [3805387][EnigmaIOTNode.cpp:2522] manageMessage() Heap: 38232 | Reveived message. Origin MAC: 3C:61:05:17:18:4D
I [3805392][EnigmaIOTNode.cpp:2652] manageMessage() Heap: 38232 |  <------- CLOCK RESPONSE
I [3805400][EnigmaIOTNode.cpp:1394] processClockResponse() Heap: 38232 | Downlink msg #136
I [3805408][EnigmaIOTNode.cpp:1397] processClockResponse() Heap: 38232 | Accepted
I [3805415][EnigmaIOTNode.cpp:1431] processClockResponse() Heap: 38232 | Offest adjusted to 970 us, Roundtrip delay is 36620
I [3805426][EnigmaIOTNode.cpp:2655] manageMessage() Heap: 38232 | Clock Response OK
No sync localtime: 986996502
Timestamp sec: 1615894
19/01/1970 17:51:34
Vcc: 3.050000
Trying to send: 00 02 01 31 01 67 00 CB 
I [3810383][EnigmaIOTNode.cpp:1686] dataMessage() Heap: 38208 | Data message #386
I [3810388][EnigmaIOTNode.cpp:1729] dataMessage() Heap: 38208 |  -------> DATA
---- Data sent

MQTT Gateway with a reed contact instead of a DS18B20

Hey,
first of all I like your work very much. Thank your for making this public.
At the moment I am trying to switch my sensor network from ESPHome to EnigmaIOT.
My gateway has a reed contact soldered to it, so i changed your example code in order to substitute the temp sensor with the reed contact (Message should be sent on state change).

I`d really like to get this protocol running in the HomeAssistant Community as it is very nice for battery powered devices.

Here is my EnigmaIOTGatewayMQTTReed.ino:

#include <Arduino.h>

#include <PubSubClient.h>

#include <GwOutput_generic.h>
#include "GwOutput_mqtt.h"

#ifdef SECURE_MQTT
#include <WiFiClientSecure.h>
#else
#include <WiFiClient.h>
#endif // SECURE_MQTT


#ifdef ESP32
#include <WiFi.h>
#include <AsyncTCP.h> // Comment to compile for ESP8266
#include <Update.h>
#include <SPIFFS.h>
#include "esp_system.h"
#include "esp_event.h"
#include "esp_tls.h"
#include <ESPmDNS.h>
#include "soc/soc.h"           // Disable brownout problems
#include "soc/rtc_cntl_reg.h"  // Disable brownout problems
#elif defined(ESP8266)
#include <ESP8266WiFi.h>
//#include <ESPAsyncTCP.h> // Comment to compile for ESP32
#include <ESP8266mDNS.h>
#include <Hash.h>
#include <SPI.h>
#endif // ESP32

#include <ArduinoOTA.h>

#include <CayenneLPP.h>
#include <FS.h>

#include <EnigmaIOTGateway.h>
#include <helperFunctions.h>
#include <debug.h>
#include <espnow_hal.h>
#include <Curve25519.h>
#include <ChaChaPoly.h>
#include <Poly1305.h>
#include <SHA256.h>
#include <ArduinoJson.h>
#include <DNSServer.h>
#include <ESPAsyncWebServer.h>
#include <ESPAsyncWiFiManager.h>

#define SENSOR_REED // REED Tuersensor

#ifdef SENSOR_REED
const int REED_PIN = 35;
bool previousDoorState = true;
boolean isStateChanged = false;
unsigned long previousMillis = 0;
unsigned long interval = 500; // Half second Delay for Reed Switch
bool doorstate;
#endif

#ifndef LED_BUILTIN
#define LED_BUILTIN 5
#endif // BUILTIN_LED

#define BLUE_LED LED_BUILTIN
#define RED_LED LED_BUILTIN

#ifdef ESP32
TimerHandle_t connectionLedTimer;
#elif defined(ESP8266)
ETSTimer connectionLedTimer;
#endif // ESP32

const int connectionLed = LED_BUILTIN;
bool connectionLedFlashing = false;

bool restartRequested = false;
time_t restartRequestTime;


void flashConnectionLed (void* led) {
	//digitalWrite (*(int*)led, !digitalRead (*(int*)led));
	digitalWrite (LED_BUILTIN, !digitalRead (LED_BUILTIN));
}

void startConnectionFlash (int period) {
#ifdef ESP32
	if (!connectionLedFlashing) {
		connectionLedFlashing = true;
		connectionLedTimer = xTimerCreate ("led_flash", pdMS_TO_TICKS (period), pdTRUE, (void*)0, flashConnectionLed);
		xTimerStart (connectionLedTimer, 0);
	}
#elif defined (ESP8266)
	ets_timer_disarm (&connectionLedTimer);
	if (!connectionLedFlashing) {
		connectionLedFlashing = true;
		ets_timer_arm_new (&connectionLedTimer, period, true, true);
	}
#endif // ESP32
}

void stopConnectionFlash () {
#ifdef ESP32
	if (connectionLedFlashing) {
		connectionLedFlashing = false;
		xTimerStop (connectionLedTimer, 0);
		xTimerDelete (connectionLedTimer, 0);
	}
#elif defined(ESP8266)
	if (connectionLedFlashing) {
		connectionLedFlashing = false;
		ets_timer_disarm (&connectionLedTimer);
		digitalWrite (connectionLed, LED_OFF);
	}
#endif // ESP32
}

void arduinoOTAConfigure () {
	// Port defaults to 3232
	// ArduinoOTA.setPort(3232);

	// Hostname defaults to esp3232-[MAC]
	ArduinoOTA.setHostname (EnigmaIOTGateway.getNetworkName ());

	// No authentication by default
	ArduinoOTA.setPassword (EnigmaIOTGateway.getNetworkKey (true));

	// Password can be set with it's md5 value as well
	// MD5(admin) = 21232f297a57a5a743894a0e4a801fc3
	// ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3");

	ArduinoOTA.onStart ([] () {
		if (ArduinoOTA.getCommand () == U_FLASH) {
			DEBUG_WARN ("Start updating sketch");
		} else {// U_SPIFFS
			DEBUG_WARN ("Start updating filesystem");
			// NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
		}
						});
	ArduinoOTA.onEnd ([] () {
		DEBUG_WARN ("OTA Finished");
					  });
	ArduinoOTA.onProgress ([] (unsigned int progress, unsigned int total) {
		static bool printed = false;
		unsigned int percent = progress / (total / 100);
		digitalWrite (BLUE_LED, !digitalRead (BLUE_LED));
		if (!(percent % 1)) {
			//Serial.print ('.');
		}
		if (!(percent % 20) && !printed && percent != 0) {
			DEBUG_WARN (" %d%%\n", percent);
			printed = true;
		} else if (percent % 20) {
			printed = false;
		}
		if (progress == total) {
			DEBUG_WARN ("OTA transfer finished");
		}
						   });
	ArduinoOTA.onError ([] (ota_error_t error) {
		DEBUG_WARN ("OTA Error[%u]: ", error);
		if (error == OTA_AUTH_ERROR) { DEBUG_WARN ("OTA Auth Failed"); } 		else if (error == OTA_BEGIN_ERROR) { DEBUG_WARN ("OTA Begin Failed"); } 		else if (error == OTA_CONNECT_ERROR) { DEBUG_WARN ("OTA Connect Failed"); } 		else if (error == OTA_RECEIVE_ERROR) { DEBUG_WARN ("OTA Receive Failed"); } 		else if (error == OTA_END_ERROR) { DEBUG_WARN ("OTA End Failed"); }
						});

	ArduinoOTA.begin ();
}

void wifiManagerExit (boolean status) {
	GwOutput.configManagerExit (status);
}

void wifiManagerStarted () {
	GwOutput.configManagerStart (&EnigmaIOTGateway);
}

void processRxControlData (char* macStr, uint8_t* data, uint8_t length) {
	if (data) {
		if (data[0] == VERSION_ANS && length >= 4) {
			DEBUG_INFO ("Version message: %d.%d.%d", data[1], data[2], data[3]);
			Node* node = EnigmaIOTGateway.getNodes ()->getNodeFromName (macStr);
			if (node) {
				node->setVersion (data[1], data[2], data[3]);
			}
		}
		GwOutput.outputControlSend (macStr, data, length);
	}
}

void doRestart () {
	DEBUG_WARN ("Restart requested");
	const size_t capacity = JSON_OBJECT_SIZE (1);
	size_t len;
	char* payload;

	DynamicJsonDocument doc (capacity);

	doc["action"] = "restart";

	len = measureJson (doc) + 1;
	payload = (char*)malloc (len);
	serializeJson (doc, (char*)payload, len);
	char addr[] = "gateway";
	GwOutput.outputDataSend (addr, payload, len - 1);
	free (payload);

	restartRequested = true;
	restartRequestTime = millis ();

}

void processRxData (uint8_t* mac, uint8_t* buffer, uint8_t length, uint16_t lostMessages, bool control, gatewayPayloadEncoding_t payload_type, char* nodeName = NULL) {
	uint8_t* addr = mac;
	size_t pld_size = 0;
	const int PAYLOAD_SIZE = 1024; // Max MQTT payload in PubSubClient library normal operation.

	char payload[PAYLOAD_SIZE];

	char mac_str[ENIGMAIOT_ADDR_LEN * 3];
	mac2str (addr, mac_str);

	if (control) {
		processRxControlData (nodeName ? nodeName : mac_str, buffer, length);
		return;
	}
	//char* netName = EnigmaIOTGateway.getNetworkName ();
	if (payload_type == CAYENNELPP) {
		DEBUG_INFO ("CayenneLPP message");
		const int capacity = JSON_ARRAY_SIZE (25) + 25 * JSON_OBJECT_SIZE (4);
		DynamicJsonDocument jsonBuffer (capacity);
		JsonArray root = jsonBuffer.createNestedArray ();
		CayenneLPP cayennelpp (MAX_DATA_PAYLOAD_SIZE);

		cayennelpp.decode ((uint8_t*)buffer, length, root);
		uint8_t error = cayennelpp.getError ();
		if (error != LPP_ERROR_OK) {
			DEBUG_ERROR ("Error decoding CayenneLPP data: %d", error);
			return;
		}
		pld_size = serializeJson (root, payload, PAYLOAD_SIZE);
	} else if (payload_type == MSG_PACK) {
		DEBUG_INFO ("MsgPack message");
		const int capacity = JSON_ARRAY_SIZE (25) + 25 * JSON_OBJECT_SIZE (4);
		DynamicJsonDocument jsonBuffer (capacity);
		DeserializationError error = deserializeMsgPack (jsonBuffer, buffer, length);
		if (error != DeserializationError::Ok) {
			DEBUG_ERROR ("Error decoding MSG Pack data: %s", error.c_str ());
			return;
		}
		pld_size = serializeJson (jsonBuffer, payload, PAYLOAD_SIZE);
	} else if (payload_type == RAW) {
		DEBUG_INFO ("RAW message");
		if (length <= PAYLOAD_SIZE) {
			memcpy (payload, buffer, length);
			pld_size = length;
		} else { // This will not happen but may lead to errors in case of using another physical transport
			memcpy (payload, buffer, PAYLOAD_SIZE);
			pld_size = PAYLOAD_SIZE;
		}
	}

	GwOutput.outputDataSend (nodeName ? nodeName : mac_str, payload, pld_size);
	DEBUG_INFO ("Published data message from %s, length %d: %s, Encoding 0x%02X", nodeName ? nodeName : mac_str, pld_size, payload, payload_type);
	if (lostMessages > 0) {
		pld_size = snprintf (payload, PAYLOAD_SIZE, "%u", lostMessages);
		GwOutput.outputDataSend (nodeName ? nodeName : mac_str, payload, pld_size, GwOutput_data_type::lostmessages);
		DEBUG_INFO ("Published MQTT from %s: %s", nodeName ? nodeName : mac_str, payload);
	}
	pld_size = snprintf (payload, PAYLOAD_SIZE, "{\"per\":%e,\"lostmessages\":%u,\"totalmessages\":%u,\"packetshour\":%.2f}",
						 EnigmaIOTGateway.getPER ((uint8_t*)mac),
						 EnigmaIOTGateway.getErrorPackets ((uint8_t*)mac),
						 EnigmaIOTGateway.getTotalPackets ((uint8_t*)mac),
						 EnigmaIOTGateway.getPacketsHour ((uint8_t*)mac));
	GwOutput.outputDataSend (nodeName ? nodeName : mac_str, payload, pld_size, GwOutput_data_type::status);
	DEBUG_INFO ("Published MQTT from %s: %s", nodeName ? nodeName : mac_str, payload);
}

void onDownlinkData (uint8_t* address, char* nodeName, control_message_type_t msgType, char* data, unsigned int len) {
	uint8_t* buffer;
	unsigned int bufferLen = len;
	gatewayPayloadEncoding_t encoding = ENIGMAIOT;

	if (nodeName) {
		DEBUG_INFO ("DL Message for %s. Type 0x%02X", nodeName, msgType);
	} else {
		DEBUG_INFO ("DL Message for " MACSTR ". Type 0x%02X", MAC2STR (address), msgType);
	}
	DEBUG_DBG ("Data: %.*s Length: %d", len, data, len);

	if (msgType == USERDATA_GET || msgType == USERDATA_SET) {
		const int capacity = JSON_ARRAY_SIZE (25) + 25 * JSON_OBJECT_SIZE (4);
		DynamicJsonDocument json (capacity);
		DeserializationError error = deserializeJson (json, data, len, DeserializationOption::NestingLimit (3));
		if (error == DeserializationError::Ok) {
			DEBUG_INFO ("JSON Message. Result %s", error.c_str ());
			bufferLen = measureMsgPack (json) + 1; // Add place for \0
			buffer = (uint8_t*)malloc (bufferLen);
			bufferLen = serializeMsgPack (json, (char*)buffer, bufferLen);
			encoding = MSG_PACK;
		} else {
			DEBUG_INFO ("Not JSON Message. Error %s", error.c_str ());
			bufferLen++; // Add place for \0
			buffer = (uint8_t*)malloc (bufferLen);
			sprintf ((char*)buffer, "%.*s", len, data);
			encoding = RAW;
		}
	} else {
		bufferLen = len + 1;
		buffer = (uint8_t*)calloc (sizeof (uint8_t), bufferLen);
		memcpy (buffer, data, len);
	}


	if (!EnigmaIOTGateway.sendDownstream (address, (uint8_t*)buffer, bufferLen, msgType, encoding, nodeName)) {
		if (nodeName) {
			DEBUG_WARN ("Error sending esp_now message to %s", nodeName);
		} else {
			DEBUG_WARN ("Error sending esp_now message to " MACSTR, MAC2STR (address));
		}
	} else {
		DEBUG_DBG ("Esp-now message sent or queued correctly");
	}

	free (buffer);
}

void newNodeConnected (uint8_t* mac, uint16_t node_id, char* nodeName = NULL) {

	//Serial.printf ("New node connected: %s\n", macstr);

	if (nodeName) {
		if (!GwOutput.newNodeSend (nodeName, node_id)) {
			DEBUG_WARN ("Error sending new node %s", nodeName);
		} else {
			DEBUG_DBG ("New node %s message sent", nodeName);
		}
	} else {
		char macstr[ENIGMAIOT_ADDR_LEN * 3];
		mac2str (mac, macstr);
		if (!GwOutput.newNodeSend (macstr, node_id)) {
			DEBUG_WARN ("Error sending new node %s", macstr);
		} else {
			DEBUG_DBG ("New node %s message sent", macstr);
		}
	}

}

void nodeDisconnected (uint8_t* mac, gwInvalidateReason_t reason) {
	char macstr[ENIGMAIOT_ADDR_LEN * 3];
	mac2str (mac, macstr);
	//Serial.printf ("Node %s disconnected. Reason %u\n", macstr, reason);
	if (!GwOutput.nodeDisconnectedSend (macstr, reason)) {
		DEBUG_WARN ("Error sending node disconnected %s reason %d", macstr, reason);
	} else {
		DEBUG_DBG ("Node %s disconnected message sent. Reason %d", macstr, reason);
	}
}

//#ifdef ESP32
//void EnigmaIOTGateway_handle (void * param) {
//	for (;;) {
//		EnigmaIOTGateway.handle ();
//		vTaskDelay (0);
//	}
//}
//
//void GwOutput_handle (void* param) {
//	for (;;) {
//		GwOutput.loop ();
//		vTaskDelay (0);
//	}
//}
//
//TaskHandle_t xEnigmaIOTGateway_handle = NULL;
//TaskHandle_t gwoutput_handle = NULL;
//#endif // ESP32

void setup () {
	Serial.begin (115200); Serial.println (); Serial.println ();

#ifdef ESP32
// Turn-off the 'brownout detector' to avoid random restarts during wake up,
// normally due to bad quality regulator on board
	WRITE_PERI_REG (RTC_CNTL_BROWN_OUT_REG, 0);
#endif

#ifdef ESP8266
	ets_timer_setfn (&connectionLedTimer, flashConnectionLed, (void*)&connectionLed);
#elif defined ESP32

#endif
	pinMode (LED_BUILTIN, OUTPUT);
	digitalWrite (LED_BUILTIN, LED_OFF);
	startConnectionFlash (100);

#ifdef SENSOR_REED
	pinMode(REED_PIN, INPUT);
#endif // SENSOR_REED

	if (!GwOutput.loadConfig ()) {
		DEBUG_WARN ("Error reading config file");
	}

	EnigmaIOTGateway.setRxLed (BLUE_LED);
	EnigmaIOTGateway.setTxLed (RED_LED);
	EnigmaIOTGateway.onNewNode (newNodeConnected);
	EnigmaIOTGateway.onNodeDisconnected (nodeDisconnected);
	EnigmaIOTGateway.onWiFiManagerStarted (wifiManagerStarted);
	EnigmaIOTGateway.onWiFiManagerExit (wifiManagerExit);
	EnigmaIOTGateway.onDataRx (processRxData);
	EnigmaIOTGateway.onGatewayRestartRequested (doRestart);

	EnigmaIOTGateway.begin (&Espnow_hal);

	WiFi.mode (WIFI_AP_STA);
	WiFi.begin ();

	EnigmaIOTGateway.configWiFiManager ();

	WiFi.softAP (EnigmaIOTGateway.getNetworkName (), EnigmaIOTGateway.getNetworkKey (true));
	stopConnectionFlash ();

	DEBUG_INFO ("STA MAC Address: %s", WiFi.macAddress ().c_str ());
	DEBUG_INFO ("AP MAC Address: %s", WiFi.softAPmacAddress ().c_str ());
	DEBUG_INFO ("BSSID Address: %s", WiFi.BSSIDstr ().c_str ());

	DEBUG_INFO ("IP address: %s", WiFi.localIP ().toString ().c_str ());
	DEBUG_INFO ("WiFi Channel: %d", WiFi.channel ());
	DEBUG_INFO ("WiFi SSID: %s", WiFi.SSID ().c_str ());
	DEBUG_INFO ("Network Name: %s", EnigmaIOTGateway.getNetworkName ());

	GwOutput.setDlCallback (onDownlinkData);
	GwOutput.begin ();

	arduinoOTAConfigure ();

#ifdef ESP32
	//xTaskCreate (EnigmaIOTGateway_handle, "handle", 10000, NULL, 1, &xEnigmaIOTGateway_handle);
	//xTaskCreatePinnedToCore (EnigmaIOTGateway_handle, "handle", 4096, NULL, 0, &xEnigmaIOTGateway_handle, 1);
	//xTaskCreatePinnedToCore (GwOutput_handle, "gwoutput", 10000, NULL, 2, &gwoutput_handle, 1);
#endif
}

#ifdef SENSOR_REED
void sendStatus (bool doorstate) {
	const size_t capacity = JSON_OBJECT_SIZE (1) + JSON_OBJECT_SIZE (3) + 30;;
	size_t len;
	char* payload;

	DynamicJsonDocument doc (capacity);

	JsonObject status = doc.createNestedObject ("status");
	status["door"] = doorstate;
	status["nodes"] = EnigmaIOTGateway.getActiveNodesNumber ();
	status["mem"] = ESP.getFreeHeap ();

	len = measureJson (doc) + 1;
	payload = (char*)malloc (len);
	serializeJson (doc, (char*)payload, len);
	char addr[] = "gateway";
	GwOutput.outputDataSend (addr, payload, len - 1);
	free (payload);
}
#endif // SENSOR_REED

void loop () {
	GwOutput.loop ();
	EnigmaIOTGateway.handle ();
	ArduinoOTA.handle ();

#ifdef SENSOR_REED
  doorstate = digitalRead(REED_PIN) == LOW ? true : false;
  if((previousDoorState != doorstate) && !isStateChanged) {
    // Reset timer
    previousDoorState = doorstate;
    previousMillis = millis();
    isStateChanged = true;
  }
  // Only publish message whet the door is open minimum 0.5 sec
  if(isStateChanged && millis() - previousMillis > interval){ 
    if(doorstate == previousDoorState) {
        sendStatus (doorstate);
        DEBUG_WARN ("ReedState: ", doorstate);
      }
    isStateChanged = false;
  }
#endif // SENSOR_REED

	if (restartRequested) {
		if (millis () - restartRequestTime > 100) {
			ESP.restart ();
		}
	}
}

Now I have a few problems/questions:

  • how do I set a MQTT prefix (I use HomeAssistant and it needs the homeassistant prefix)?
  • it seems that I do not get a MQTT message when the state of the reed changes

GatewayAPI.cpp getNodeInfo() compile error

In 0.98 release GatewayAPI.cpp L155 char* GatewayAPI::getNodeInfo ....

L165 The index = snprint parameters keyValidSince & lastMessageTime changed to using %11d (were using %1d pre July commit) and now compile fails on Arduino IDE.
latest v0.98:
L165: index = snprintf (nodeInfo, len,
"{"version":"%d.%d.%d","node_id":%d,"address":"" MACSTR "","
""keyValidSince":%lld,"lastMessageTime":%lld,"sleepy":%s,"
""Broadcast":%s,"TimeSync":%s,"rssi":%d,"packetsHour":%f,"per":%f",

Before July commit ( this works OK )
L:165 index = snprintf (nodeInfo, len,
"{"version":"%d.%d.%d","node_id":%d,"address":"" MACSTR "","
""keyValidSince":%ld,"lastMessageTime":%ld,"sleepy":%s,"
""Broadcast":%s,"TimeSync":%s,"rssi":%d,"packetsHour":%f,"per":%f",

Regards
Geoffrey

web interface gpio configuration

I have been working since more than 15 days, and I also use tasmota.
I am thinking of changing my tasmota plugs to enigmaiot, and I think that it would not be very expensive to be able to configure the gpio from the web, even that it would support the tasmota templates (since it has a very large database).
this would make it much more accessible to non-advanced users in arduino

Fail safe library not found

i am getting error as no fail safe library. I searched online for the library but I couldn't find one . will you please provide the link where the library is available

Bootloop in new nodes

I have been testing the new version 0.9.8, for the integration in homeassitant especially.
And I have found that flashing a new esp (with clean flash) not finding "/config.json" fails, it causes a bootloop instead of creating the access point and asking for parameters.

This is the serial output:

<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------
��␀␀�␀␀␀��␀�␀���␀�␀␀␀�␀��␀�␀��␀␀␀␀␀␀␀␀␀␀␀␀␀�␀␀�␀␀␀�␀␀␀��␀�␀��␀␀�␀��␀������␀���␀�␀�␀␀␀␀␀�␀␀␀␀␀�������␀��␀␀�������␀␀���␀�␀�␀␀�␀�␀␀␀�␀��␀�␀�␀��␀␀�␀��␀␀�␀␀������␀�␀␀�␀␀␀␀␀�␀�␀␀␀�␀␀␀␀␀␀�␀␀␀␀␀␀␀�␀␀␀␀����␀�␀��␀␀�␀␀␀�␀␀�␀␀␀␀�␀␀␀␀␀�����������␀␀�␀␀␀�␀␀␀��␀␀�␀␀���␀��␀��␀��␀␀␀�␀��␀␀�␀�␀�␀�������␀���������␀␀␀␀␀��␀��␀���␀␀�␀␀������␀�␀␀�␀␀␀␀␀��␀␀␀␀�␀␀�␀␀�␀␀␀␀␀␀␀�␀␀␀�␀␀␀␀����␀�␀��␀␀␀�␀␀␀␀�␀␀␀␀␀�����������␀␀␀�␀␀␀��␀␀�␀␀���␀��␀��␀��␀␀␀�␀��␀␀�␀�␀�␀�������␀���������␀␀␀␀␀��␀��␀␀��␀␀�␀�␀��␀���������␀␀␀␀␀��␀��␀␀��␀␀�␀␀��␀␀␀␀␀␀�␀␀�␀�␀␀�␀␀�␀␀��␀␀�␀␀�␀��␀␀���␀␀�␀

W [96][H: 4184][EnigmaIOTNode.cpp:346] loadFlashData() | /config.json do not exist
*WM: Adding parameter
*WM: sleepy
*WM: Adding parameter
*WM: nodename
*WM: SET AP STA
*WM:
*WM: Configuring access point...
*WM: EnigmaIoTNode1e122d
*WM: AP IP address: 
*WM: 192.168.4.1

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Exception (28):
epc1=0x40232f58 epc2=0x00000000 epc3=0x00000000 excvaddr=0x11c00000 depc=0x00000000

>>>stack>>>

ctx: cont
sp: 3ffffa20 end: 3fffffc0 offset: 0190
3ffffbb0:  4028cd8c 00000001 3ffffc30 0000000bb

If the "config.json" exists (created with version 0.9.7) it does not give problems.
I have tried this with:

  • enigmaiot_node_nonsleepy
  • EnigmaIOT-Sensor-Controller
  • EnigmaIOT-SmartSwitch-Controller

all the same problem.

Missing library "arduino.h"

Just downloaded the latest repository. I am having serious problems. When compiling the enigmaiot_node example in Arduino 1.8.13 IDE on a debian Linux machine I receive the following compile error:
Arduino/libraries/EnigmaIOT-master/src/Comms_hal.h:14:21: fatal error: arduino.h: No such file or directory
#include "arduino.h"
I have installed all of the external libraries listed on the code tab. Any useful assistance would be breatly appreciated.
Glenn G.

Data not received

Hi,
I have been testing the 0.5.1 with a enigmaiot_node_nonsleepy on ESP8622 with a temperature sensor and two ESP8622 for the Gatway and works ok.
Now, I tried test the 0.9.4 version with the enigmaiot_node_nonsleepy.ino without modification on a ESP8622 and the EnigmaIOTGatewayMQTT.ino on a ESP32 without secure MQTT.
In the Mosquito MQTT broker i suscribe all the mensages from Gateway, but dont receive the data from node.
The network name of Gateway is Casa01, and I receive "status" from Gateway, and when I connect the node, receive the hello message, and after that de rssi result from node.
After that, when the node send a data, the MQTT broker only receive the topic "status", but not the topic "data" from Gateway
This is the data received in the MQTT broker:

11/9/2020 20:30:51node: a57e08c9.0914a8
Casa01/gateway/status : msg.payload : string[1]
"1"
11/9/2020 20:32:32node: a57e08c9.0914a8
Casa01/5C:CF:7F:B5:60:FA/hello : msg.payload : buffer[32]
[ 123, 34, 97, 100, 100, 114, 101, 115, 115, 34 … ]
11/9/2020 20:32:32node: a57e08c9.0914a8
Casa01/W01/hello : msg.payload : buffer[32]
[ 123, 34, 97, 100, 100, 114, 101, 115, 115, 34 … ]
11/9/2020 20:32:34node: a57e08c9.0914a8
Casa01/W01/result/rssi : msg.payload : string[24]
"{"rssi":-44,"channel":1}"
11/9/2020 20:37:22node: a57e08c9.0914a8
Casa01/W01/status : msg.payload : string[75]
"{"per":0.000000e+00,"lostmessages":0,"totalmessages":1,"packetshour":39.70}"
11/9/2020 20:39:02node: a57e08c9.0914a8
Casa01/W01/status : msg.payload : string[75]
"{"per":0.000000e+00,"lostmessages":0,"totalmessages":2,"packetshour":37.25}"
11/9/2020 20:40:42node: a57e08c9.0914a8
Casa01/W01/status : msg.payload : string[75]
"{"per":0.000000e+00,"lostmessages":0,"totalmessages":3,"packetshour":36.55}"
11/9/2020 20:42:22node: a57e08c9.0914a8
Casa01/W01/status : msg.payload : string[75]
"{"per":0.000000e+00,"lostmessages":0,"totalmessages":4,"packetshour":36.27}"
11/9/2020 20:44:02node: a57e08c9.0914a8
Casa01/W01/status : msg.payload : string[75]
"{"per":0.000000e+00,"lostmessages":0,"totalmessages":5,"packetshour":36.14}"
11/9/2020 20:45:42node: a57e08c9.0914a8

The debug information from Gateway when the node is connected, is in the debug file attached named logGateway01. LogGateway_01.txt
The debug output from Gateway goes into a loop only interrumpied when the node send a data. See logGateway 02
LogGateway_02.txt
I compiled the Gateway with "Info" debug level because if I use a sup level the ESP crash.

If I use the enigmaiot_node_msgpack example, the data send by the node are received by the MQTT broker.

Any ideas what I can try from here?
Thanks a lot for all your work on this project.

More permissive license?

This looks like a really cool project and there are lots of things in here, I still want to implement.
I am the main author of IoTempower (https://github.com/iotempire/iotempower), my vision would be to merge or integrate EnigmaIOT, PJON (https://github.com/gioblu/PJON), and IoTempower, maybe offer some more (static) mesh-functionality, but PJON should allow that easily.

However, I can not do that out of legal reasons as you picked the GPLv3 as a license. If I use code from you, I have to put all my code under the GPLv3 and also all projects created with it. That makes it very unattractive to use IoTempower (and also EnigmaIOT) in a commercial or even university setting.

I can understand that you want changes and fixes to your code back in the project, but could you at least relax the license to the LGPLv3? That would allow us to use the code at least as a library in other projects without adopting the license itself. If you just seek attribution and could trust (most of us) other developers to contribute changes back and help fix problems, of course an even more permissive license like MIT or BSD would probably be appreciated by the developer community.

Node data send error: Registration timeout

I've been struggling with a bit of an enigma of my own. I can't seem to get a message sent successfully after I initialize the node. The gateway joins my wifi network okay:

*WM: Adding parameter
*WM: netkey
*WM: Adding parameter
*WM: channel
*WM: Adding parameter
*WM: netname
*WM: Adding parameter
*WM:
*WM: Adding parameter
*WM: mqttserver
*WM: Adding parameter
*WM: mqttport
*WM: Adding parameter
*WM: mqttuser
*WM: Adding parameter
*WM: mqttpass
*WM:
*WM: AutoConnect Try No.:
*WM: 0
*WM: Connecting as wifi client...
*WM: Try to connect with saved credentials
*WM: Connection result:
*WM: 3
*WM: IP Address:
*WM: 192.168.178.35

My node also seems to initialize okay:

*WM: WiFi save
*WM: Parameter
*WM: sleepy
*WM: 10
*WM: Parameter
*WM: nodename
*WM: test_node
*WM: Sent wifi save page
*WM: Handle not found
*WM: Connecting to new AP
*WM: Connecting as wifi client...
*WM: Waiting for connection result with time out
*WM: Connection result:
*WM: 3

But then it starts looping and none of the messages get through, as far as I can tell:

RTC MEM DATA:
-- CRC: 32 BD E8 49
-- Node Key: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-- Node key is NOT valid
-- Node status is 0: NOT REGISTERED
-- Node name: test_node
-- Last message counter: 0
-- NodeID: 0
-- Channel: 6
-- RSSI: -45
-- Network name: IreMarIOT
-- Gateway: 3C:71:BF:5A:A9:29
-- Comm errors: 0
-- Network Key: 66 68 7A AD F8 62 BD 77 6C 8F C1 8B 8E 9F 8E 20 08 97 14 85 6E E2 33 B3 90 2A 59 1D 0D 5F 29 25
-- Mode: sleepy

ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5816
entry 0x400806ac
Vcc: 0.000000
Trying to send: 00 02 00 00 01 67 00 CB 02 00 7B 03 73 27 58 04 75 09 7E
---- Error sending data
Total time: 1913 ms

ets Jun 8 2016 00:22:57
rst:0x5 (DEEPSLEEP_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5816
entry 0x400806ac

RTC MEM DATA:
-- CRC: 11 88 0D DC
-- Node Key: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-- Node key is NOT valid
-- Node status is 0: NOT REGISTERED
-- Node name: test_node
-- Last message counter: 0
-- NodeID: 0
-- Channel: 6
-- RSSI: -49
-- Network name: IreMarIOT
-- Gateway: 3C:71:BF:5A:A9:29
-- Comm errors: 0
-- Network Key: 66 68 7A AD F8 62 BD 77 6C 8F C1 8B 8E 9F 8E 20 08 97 14 85 6E E2 33 B3 90 2A 59 1D 0D 5F 29 25
-- Mode: sleepy
Vcc: 0.000000
Trying to send: 00 02 00 00 01 67 00 CB 02 00 7B 03 73 27 58 04 75 09 7E
---- Error sending data
Total time: 67 ms

...etc

This is using two TTGO Lora32 boards (only ESP32 boards I could find). I also tried it with a Wemos D1 Pro Mini as the node and I get some more verbose output there but still no luck:

D [50][EnigmaIOTNode.cpp:547] begin() Heap: 34200 | Set sleepy mode: sleepy
V [51][EnigmaIOTNode.cpp:116] loadRTCData() Heap: 34200 | Read RTCData: E5 10 04 C3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 3C 71 BF 5A A9 29 D4 55 41 A0 B3 44 25 F6 38 34 DD BC C9 42 0E 31 17 1F FA 39 3B E7 17 A7 14 22 35 8C 8B CB 6C D7 A3 49 72 65 4D 61 72 49 4F 54 00 89 28 74 68 F1 BF 2A F3 2C AB 29 01 0A 00 00 00 74 65 73 74 6E 6F 64 65 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3A 00 00 00 00 00 00 00 00 34 4E
V [92][EnigmaIOTNode.cpp:982] checkCRC() Heap: 34200 | CRC32 = Calc: 0xC30410E5 Recvd: 0xC30410E5 Length: 144
D [101][EnigmaIOTNode.cpp:149] loadRTCData() Heap: 34200 | Set sleepy mode
RTC MEM DATA:
-- CRC: E5 10 04 C3
-- Node Key: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-- Node key is NOT valid
-- Node status is 0: NOT REGISTERED
-- Node name: testnode
-- Last message counter: 0
-- NodeID: 0
-- Channel: 6
-- RSSI: -44
-- Network name: IreMarIOT
-- Gateway: 3C:71:BF:5A:A9:29
-- Comm errors: 0
-- Network Key: 55 41 A0 B3 44 25 F6 38 34 DD BC C9 42 0E 31 17 1F FA 39 3B E7 17 A7 14 22 35 8C 8B CB 6C D7 A3
-- Mode: sleepy
D [153][EnigmaIOTNode.cpp:552] begin() Heap: 34200 | RTC data loaded. Gateway: 3C:71:BF:5A:A9:29
D [161][EnigmaIOTNode.cpp:553] begin() Heap: 34200 | Own address: 00:00:00:00:00:00
D [168][helperFunctions.cpp:32] initWiFi() Heap: 34200 | initWifi
D [239][helperFunctions.cpp:51] initWiFi() Heap: 34200 | Mode set to STA. Channel 6
I [239][helperFunctions.cpp:58] initWiFi() Heap: 34200 | AP MAC address of this device is B6:E6:2D:29:00:27
I [245][helperFunctions.cpp:59] initWiFi() Heap: 34200 | STA MAC address of this device is B4:E6:2D:29:00:27
I [254][espnow_hal.cpp:70] begin() Heap: 34200 | Starting ESP-NOW as node
D [261][espnow_hal.cpp:72] begin() Heap: 34200 | Gateway address is 3c:71:bf:5a:a9:29
D [269][EnigmaIOTNode.cpp:630] begin() Heap: 34168 | Comms started. Channel 6
D [275][enigmaiot_node.ino:127] setup() Heap: 34168 | Node address set to B4:E6:2D:29:00:27
Vcc: 3.021000
Trying to send: 00 02 01 2E 01 67 00 CB 02 00 7B 03 73 27 58 04 75 09 7E
---- Error sending data
Total time: 243 ms
D [295][EnigmaIOTNode.cpp:1307] sleep() Heap: 33720 | Sleep programmed for 10000 ms
D [1803][EnigmaIOTNode.cpp:898] handle() Heap: 33944 | Current node status: 0
D [1803][NodeList.cpp:105] reset() Heap: 33944 | Reset node
D [1804][NodeList.cpp:114] reset() Heap: 33944 | Reset packet rate
I [1810][EnigmaIOTNode.cpp:902] handle() Heap: 33944 | Random delay (3147)
V [6760][cryptModule.cpp:143] getDH1() Heap: 33944 | Public key: 67 CF 45 B3 E8 BA EB 37 A1 8D CB 91 68 1B A4 F4 AD FE 39 54 0C F7 94 D1 EC 5B 28 57 A7 B7 D1 07
V [6763][cryptModule.cpp:145] getDH1() Heap: 33944 | Private key: A8 3B 1E D4 2E A3 4A 1B 24 3C 72 03 43 77 4A BF D2 23 3A 4E 14 86 CB BE 8C 44 E8 F5 02 3D 07 4D
V [6777][EnigmaIOTNode.cpp:1028] clientHello() Heap: 33944 | IV: F4 DB 96 BD AF E6 69 85 F3 D8 8B 77
D [6786][EnigmaIOTNode.cpp:1039] clientHello() Heap: 33944 | Signal sleepy node
V [6793][EnigmaIOTNode.cpp:1047] clientHello() Heap: 33944 | Client Hello message: FF F4 DB 96 BD AF E6 69 85 F3 D8 8B 77 67 CF 45 B3 E8 BA EB 37 A1 8D CB 91 68 1B A4 F4 AD FE 39 54 0C F7 94 D1 EC 5B 28 57 A7 B7 D1 07 27 53 90 BA
V [6813][cryptModule.cpp:92] encryptBuffer() Heap: 33944 | IV: F4 DB 96 BD AF E6 69 85 F3 D8 8B 77
V [6822][cryptModule.cpp:93] encryptBuffer() Heap: 33944 | Key: 55 41 A0 B3 44 25 F6 38 34 DD BC C9 42 0E 31 17 1F FA 39 3B E7 17 A7 14
V [6834][cryptModule.cpp:94] encryptBuffer() Heap: 33944 | AAD: FF F4 DB 96 BD AF E6 69 85 F3 D8 8B 77 22 35 8C 8B CB 6C D7 A3
V [6846][cryptModule.cpp:103] encryptBuffer() Heap: 33944 | Tag: 48 C5 94 09 57 98 D5 CB BA 97 5E 9C 89 3B 22 51
V [6855][EnigmaIOTNode.cpp:1065] clientHello() Heap: 33944 | Encrypted Client Hello message: FF F4 DB 96 BD AF E6 69 85 F3 D8 8B 77 2D 16 C4 9D E9 44 24 11 5C 8B 20 DD 4E 4C 5D 27 38 14 C3 F6 7D 26 E1 37 CB 31 D6 0F 03 B5 A8 26 93 53 42 AA 48 C5 94 09 57 98 D5 CB BA 97 5E 9C 89 3B 22 51
I [6881][EnigmaIOTNode.cpp:1070] clientHello() Heap: 33944 | -------> CLIENT HELLO
D [6889][EnigmaIOTNode.cpp:2235] getStatus() Heap: 33728 | SENDStatus OK
I [9270][EnigmaIOTNode.cpp:869] handle() Heap: 33944 | Current node status: 2
D [9271][NodeList.cpp:105] reset() Heap: 33944 | Reset node
D [9272][NodeList.cpp:114] reset() Heap: 33944 | Reset packet rate
D [9278][EnigmaIOTNode.cpp:292] saveRTCData() Heap: 33944 | Write configuration data to RTC memory
V [9286][EnigmaIOTNode.cpp:294] saveRTCData() Heap: 33944 | Write RTCData: E5 10 04 C3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 3C 71 BF 5A A9 29 D4 55 41 A0 B3 44 25 F6 38 34 DD BC C9 42 0E 31 17 1F FA 39 3B E7 17 A7 14 22 35 8C 8B CB 6C D7 A3 49 72 65 4D 61 72 49 4F 54 00 89 28 74 68 F1 BF 2A F3 2C AB 29 01 0A 00 00 00 74 65 73 74 6E 6F 64 65 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3A 00 00 00 00 00 00 00 00 34 4E
RTC MEM DATA:
-- CRC: E5 10 04 C3
-- Node Key: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-- Node key is NOT valid
-- Node status is 0: NOT REGISTERED
-- Node name: testnode
-- Last message counter: 0
-- NodeID: 0
-- Channel: 6
-- RSSI: -44
-- Network name: IreMarIOT
-- Gateway: 3C:71:BF:5A:A9:29
-- Comm errors: 0
-- Network Key: 55 41 A0 B3 44 25 F6 38 34 DD BC C9 42 0E 31 17 1F FA 39 3B E7 17 A7 14 22 35 8C 8B CB 6C D7 A3
-- Mode: sleepy
I [9376][EnigmaIOTNode.cpp:879] handle() Heap: 33944 | Registration timeout. Go to sleep for 9385 ms

If it helps, here's what I am putting in my configs:
photo_2020-07-20_22-27-28
photo_2020-07-20_22-27-30

Any ideas what I can try from here? I don't have any other esp32 boards to try for the gateway, but I will try that once I get some more. Thanks a lot for all your work on this project, seems really promising and exactly what I am looking for my home IOT network!

MQTT command line to switch LED off/on

Hi,
FYI This is a documentation change/advisory maybe??
I wanted to control an LED on a node, so I used your code (under examples LED Controller) and added this to the node software I have been using (with a BME280 sensor). I am running Mosquitto (and Thingsboard) on a Centos VM, so I used the linux command line below to switch the LED status:
mosquitto_pub -h localhost -t Mesh/6130/set/data -m "{"cmd":"led","led":1}"

The node did not like this, the data was not recognised as MSG_PACK or CAYENNELPP. But other MQTT commands work e.g:
mosquitto_pub -h localhost -t Mesh/6130/get/version -m " "

I was reading the ArduinoJSON website about deserializing JSON Objects when I saw the formatting on their JSON examples:
char json[] = "{"hello":"world"}";

So I formatted the mosquitto_pub command line to match:
mosquitto_pub -h localhost -t Mesh/6130/set/data -m "{"cmd":"led","led":1}"

and viola! working now :)
processRxCommand() | Data: {"cmd":"led","led":1}
[BME280Controller.cpp:176] processRxCommand() | Set LED status to ON

Hmm, seems so obvious now... might save someone some time one day

Regards
Geoffrey Mills

FailSafe.h

exit status 1
FailSafe.h: No such file or directory
??

Every node takes a memory of 520 bytes in gateway which is not reused on disconnection and reconnection of node

I was using with esp8266 nodes and esp8266 gateway. All my nodes are non sleepy (I am using them for toggling relays)
I noticed one thing, that if I power off few nodes. And then power them back on, the nodes get connected to the gateway but the free heap in the gateway decreases.
I would like to contribute to this project and try to fix this behavior. Can you point me in some direction.

esp32-MQTTGateway not compiling

I have started with a clean install and tried compiling the esp32-MQTTGateway. I'm getting these errors:

Compiling .pio\build\esp32-MQTTGateway-NoSSL\lib70a\src\espnow_hal.cpp.o
src\espnow_hal.cpp: In member function 'virtual void Espnow_halClass::initComms(peerType_t)':
src\espnow_hal.cpp:38:19: error: cannot convert 'esp_interface_t' to 'wifi_interface_t' in assignment
   networkGw.ifidx = ESP_IF_WIFI_STA;
                   ^
src\espnow_hal.cpp:40:19: warning: unused variable 'result' [-Wunused-variable]
         esp_err_t result = esp_now_add_peer (&networkGw);
                   ^
src\espnow_hal.cpp: In member function 'bool Espnow_halClass::addPeer(const uint8_t*)':
src\espnow_hal.cpp:92:13: error: cannot convert 'esp_interface_t' to 'wifi_interface_t' in assignment
  peer.ifidx = ESP_IF_WIFI_AP;

I have replaced ESP_IF_WIFI_STA with WIFI_IF_STA, and ESP_IF_WIFI_AP with WIFI_IF_AP and it works. Not sure though if I'm introducing other problems thought that are not immediately obvious to me.

Thanks

Store complete nodes and gateway connection data in flash ?

Hi gmag11
Thanks for the great library with very detailed documentation. I have few questions:

  • How do I hardcode network name and network key for both nodes and gateway so I don't have to configure them individually after flashing?
  • How do I save complete nodes and gateway current data into flash (including shared key, valid status etc) so they can load it up, skip registration and exchange data straightaway after a cold boot (I know it only takes 200ms to register but I want to experiment how fast nodes can work)
  • DEBUG seems only work on my ESP8266 node but not ESP32 gateway. I tried "#define DEBUG_LEVEL VERBOSE" and "#define DEBUG_ESP_PORT Serial" at the main sketch with no effect. Serial.printf() still works as normal. (Im using Platform IO latest core)
    Thanks

ESP32 Gateway crashing in addInputMsgQueue function

Hello,
Thank you very much @gmag11 for this project. I started using it recently for one of my application. So far it has been working great, i was using esp8266 gateway. But then due to heap shortage, i decided to switch to esp32 for the gateway.
But i think something is crashing esp32 in the addInputMsqQueue function. I am realtively new to esp32, so i could not pinpoint the reason.
I am using a slightly modified version of EnigmaIOTGatewayDummy example. Its working with esp8266 perfectly.
In esp8266i get this in logs

D [8966][EnigmaIOTGateway.h:157] push() Heap: 24952 | Add element. Buffer was not full

D [8967][EnigmaIOTGateway.h:158] push() Heap: 24952 | Before -- > ReadIdx: 0. WriteIdx: 0. Size: 0

D [8972][EnigmaIOTGateway.h:173] push() Heap: 24952 | After -- > ReadIdx: 0. WriteIdx: 1. Size: 1

D [8981][EnigmaIOTGateway.cpp:815] addInputMsgQueue() Heap: 24952 | Message 0xFF added from 40:F5:20:3E:58:1D. Size: 1
D [8991][EnigmaIOTGateway.h:201] front() Heap: 24952 | Read element. ReadIdx: 0. WriteIdx: 1. Size: 1

D [9000][EnigmaIOTGateway.cpp:834] getInputMsgQueue() Heap: 24952 | EnigmaIOT message got from queue. Size: 1

But in esp32

[D][EnigmaIOTGateway.h:157] push(): 26627 Heap: 223640 Add element. Buffer was not full

[D][EnigmaIOTGateway.h:158] push(): 26628 Heap: 223640 Before -- > ReadIdx: 0. WriteIdx: 0. Size: 0

[D][EnigmaIOTGateway.h:173] push(): 26634 Heap: 223640 After -- > ReadIdx: 0. WriteIdx: 1. Size: 1

[D][EnigGuru Meditation Error: Core  0 panic'ed (Interrupt wdt timeout on CPU0)
Core 0 register dump:
PC      : 0x4008b56e  PS      : 0x00060134  A0      : 0x8008a6ef  A1      : 0x3ffb5810  
A2      : 0x3ffb81f0  A3      : 0x3ffb5d6c  A4      : 0x00000001  A5      : 0x00000001  
A6      : 0x00060123  A7      : 0x00000000  A8      : 0x3ffb5d6c  A9      : 0x3ffb5d6c  
A10     : 0x00000002  A11     : 0x00000002  A12     : 0x00000001  A13     : 0x00000001  
A14     : 0x00060123  A15     : 0x00000000  SAR     : 0x00000004  EXCCAUSE: 0x00000005  
EXCVADDR: 0x00000000  LBEG    : 0x400014fd  LEND    : 0x4000150d  LCOUNT  : 0xfffffffb  

Backtrace: 0x4008b56e:0x3ffb5810 0x4008a6ec:0x3ffb5830 0x40088987:0x3ffb5850 0x400e3b78:0x3ffb5890 0x400d8767:0x3ffb58f0 0x400d8795:0x3ffb5a40 0x400e11f5:0x3ffb5a60 0x4013dee9:0x3ffb5a80 0x4010abcf:0x3ffb5aa0 0x4010aab0:0x3ffb5ad0 0x400f5d29:0x3ffb5b00 0x400f602b:0x3ffb5c00 0x4016dc21:0x3ffb5c20 0x4008f616:0x3ffb5c70 0x40088b81:0x3ffb5cb0


It did not reach EnigmaIOTGateway.cpp:815. And i saw something like portENTER_CRITICAL (&myMutex); in addInputMsgQueue. So i understand something is special here. But i could not understand why is it crashing here.

Node without name

When I put a node far away from the gateway, HASS often shows that the node is offline.

I checked /api/gw/nodes, it shows {"nodeId":2,"address":"ac:0b:fb:c1:89:1c"}.
I checked mqtt messages in esp/#

Topic: esp/AC:0B:FB:C1:89:1C/data
{"temp":13.32533,"humidity":56.04333}
2022-01-31 01:38:56

Topic: esp/AC:0B:FB:C1:89:1C/debug/lostmessages
{"lostMessages":1}
2022-01-31 01:38:56

Topic: esp/AC:0B:FB:C1:89:1C/status
{"per":2.136862e-01,"lostmessages":331,"totalmessages":1880,"packetshour":20.48}
2022-01-31 01:38:56

I guess that the data package with the node name was lost during re registration. So the gateway send the message in a topic with MAC address instead of the topic with a node name.

Storing temporary node data into flash instead RTC

@quangvankts asked in #11

How do I save complete nodes and gateway current data into flash (including shared key, valid status etc) so they can load it up, skip registration and exchange data straightaway after a cold boot (I know it only takes 200ms to register but I want to experiment how fast nodes can work)

ESP32 WiFi won't connect

ESP32 - Tried EnigmaIOT Gateway and EnigmaIOTMQTT. Keyed WiFI data into WiFiManager (192.168.4.1) OK but ESP32 (Sparkfun Thing, WeMos Lolin32) won't connect!. So I ran up the basic examples of ESPAsyncWiFiManager for both the alanswx and tzapu releases in Github and they both worked. The "alanswx" release was updated 2 days ago with WiFi disconnect changes.

ESPAsyncWiFiManager.cpp -> int AsyncWiFiManager::connectWifi(String ssid, String pass)
L580, L595 Changed "WiFi.disconnect(false); -> "WiFi.enableSTA(false)" and it started working.
Cannot find the source of "WiFi.enableSTA(false)" , was looking in WiFiManager issues for tzapu and alanswx.
Tested instead with "WiFi.disconnect(true,true)" - working. Reference: tzapu/WiFiManager#591
FYI Using latest ESPAyncWiFiManager v0.25, ESP 1.0.6

espressif/arduino-esp32#4980 Of concern but could not see where global timeout is stored?
espressif/arduino-esp32#3522 disconnect(true) seems to
permanently close WiFi #3522 (what I was seeing)

FWIW Found the HOWTO.md notes late in the day, specifically ..ESPAsyncWiFiManager -- https://github.com/gmag11/ESPAsyncWiFiManager forked... But the gmag11 version did not change the issue with not connecting, still needed changes above. Found the ESPAsyncWiFiManager confusing because "alanswx" source is very much ESP8266 only now

Also hit the Issue #18. looks like setting DEBUG to WARN and speed to 115200 has solved that.
Got MQTT messages from the node showing in Mosquitto now :)

Geoffrey

EnigmaIOT beginner's guide or help sources?

EnigmaIOT seems like a great product and something that matches what I've been looking for. But where does one go to get help?

I've got the gateway binary loaded onto one of my ESP32's (a TinyPico) and I think I've got that running. But I'm completely lost on how to get a node working. I think the problem is that I'm a noob with PlatformIO and I can't get any Enigma code to compile. Do you have a beginner's guide on how to set up PlatformIO and get your sources and dependent libraries into a project and get it to compile? BTW, my dev environment is Win10.

Are there any precompiled example node binaries that behave the same as the gateway with a similar "setup" process? It would be great to test out the complete environment without compiling anything and have a node binary to do simple LED on or off or respond to GPIO inputs on various pins and relay via MQTT, etc.

@gmag11 I couldn't find any contact information besides what's listed on GitHub page. Is that ok? Twitter? Discord?

cheers!
Scott

Problem with nodes of more than one sensor.

Before with version 0.5.1 there was no problem with a bme280 connected to the node.
But with version 0.8.1 / 0.8.2
the mqtt is not sent complete.
this is the DBG output:
[609330] 24392 free (processRxData:162) Published data message from A0:20:A6:08:CD:88: [{"channel":38,"type":103,"name":"temperature","value":13.6},{"channel":38,"type":104,"name":"humidity","value":99},{"channel":38,"type":142,"name":"switch","value":0},{"channel":38,"type":115,"name":"pressure","value":0.9},{"channel":38,"type":142,"name":"switch","value":0},{"channel":39,"type":2,"name":"analog_input","value":246}]
And mqtt
I [609415] 24760 free (publishMQTT:411) Publish MQTT. Esp-Now/A0:20:A6:08:CD:88/data : [{"channel":38,"type":103,"name":"temperature","value":13.6},{"channel":38,"ty

I have tried to change the size of the mqtt buffer but it gets worse, I use esp8266.
Thank you.

P.D.
I use the channel number as Domoticz idx, and the switch type as dummy data for domoticz.

Support for BMP280 sensor

Hi, impressive work you have done. I try to understand how to make a sensornode with a BMP280 pressure/temperature sensor, but I get lost in the number of examples. So if you can help me a little...?

What example node should I use as a starting point? And where do I put library, setup and loop functions for this sensor? I like to use the EnigmaIOT MsgPack example because I have no experience with Cayenne.

Thx in advance.
Aernout

How to send sane messages? (with cayenneLLP)

I don't see it in any of the examples, best one seems to be:
https://github.com/gmag11/EnigmaIOT/blob/master/examples/enigmaiot_node/enigmaiot_node.ino
which has no control of what is sent?

Instead of:

g/1/data [{"channel":0,"type":2,"name":"analog_in","value":2.99},{"channel":1,"type":103,"name":"temperature","value":21.1}]
g/1/status {"per":0.000000e+00,"lostmessages":0,"totalmessages":292,"packetshour":122.46}

should be:

g/1/data {"analog_in":2.99,"temperature":21.1}

JSON is like:
"THING":"VALUE"
no reason to do
"name":"THING","value":VALUE

What's all the channel, types, etc I can't find documentation at all and I can't think of a use case for it? MQTT has channels (topics) if it's needed to spread them out. And status calculations/storage just seems to waste gateway memory.

Is this padding for the encryption so it's harder to break or something?

This tutorial does it good:
https://github.com/gmag11/EnigmaIOT/tree/master/examples/enigmaiot_node_msgpack
Is this cayenneLLP specific that it has all of the extra data? You say msgpack is less efficient but it also can have less data, can we achieve the same in Cayenne or no?

Thanks!

EnigmaIOTGatewayMQTT example not working

I'm having trouble getting this example program to work.

  1. I can't get back to the config page. The webserver has a presence on port 80 once it's connected to my network but any request url is just "not found". The only way to reconfigure is to erase flash. That's a bit drastic!

  2. I see Fouter/gateway/status 1 mqtt message being issued every 5 mins but I don't know what it means. There is no response to any messages I send such as Fouter/gateway/get/version. If I try to update firmware using python tool it just sits there reporting Waiting for non sleepy confirmation.

  3. The config does not allow to connect without mqtt user/pwd. It should be permitted.

It's always nice when an example works because it provides a platform to get to know the application. Can you give me any advise to help get this example working?

Thanks

Having trouble compiling gateway

Hi gmag11,

i unfortunately am not able to compile the gateway example of this project.
Platform IO Core 6.1.3, Home 3.4.3
Windows 10
Git installed, python installed for what its worth. Other projects compile just fine.

i downloaded the whole github project folder and used "open project" in platformIO. Selected env:esp32-MQTTGateway-NoSSL down at the bottom. Left everything else as is. Compiling of the source code does not seem to make any problems besides a few warnings. However when linking, it spews errors (?) typed in yellow, followed by an error without further definiton.
i cannot help myself with any of these errors as there are too deeply rooted into the programm code. Also it references to the SmartSwitchController example file which is kinda off?

Log is over here on pastebin.

Thanks for your help in advance !

edit: also tried building the whole project. Every example fails when it comes to linking.

Feature Request : include IR protocol with ESP-Now protocol

There are very few implementation of ESP-Now protocol on internet so I am glad I found your repository here. Is it possible to implement IR communication between sensor & gateway in your code? It will be useful if sensor and gateway are indoor in same room then we can use IR protocol and that way it will help to add more sensors to gateway beyond the limit of 6 ESP-Now sensors to each gateway.Since these are indoor sensors with IR protocol with very limited range encryption for their data are not required.

I was also curious to see how much time & power consumption it takes to send a periodic message every few minutes from sensors to gateway. Andreas did test in his video and it looks very promising. Link to video below:

https://www.youtube.com/watch?v=6NsBN42B80Q&t=10s

Thanks

Errors when DEBUG enabled

Hi,
Using Arduino IDE - Compiling the MQTT Gateway with debug enabled (INFO or DEBUG) fails

\EnigmaIOT\src\GatewayAPI.cpp:122:73: error: the address of 'addr' will always evaluate as 'true' [-Werror=address]
DEBUG_INFO ("Node to process is %s", addr ? p->value ().c_str () : "NULL");

Hack - Commented out L122

EnigmaIOT\src\EnigmaIOTNode.cpp:2247:46: error: 'numBytes' was not declared in this scope
DEBUG_INFO ("%u bytes written. Total %u", numBytes, totalBytes);

#if DEBUG_LEVEL >= INFO
size_t numBytes =
#endif

set numBytes = 0; Moved #endif to end of block

compiled OK, running, going to add a node next
WiFi setup process is very nice
Geoffrey Mills

esp8266 do not have enough RAM to run the default examples due to NUM_NODE mostly

edit: well I've solved the issue you can see on the second post, this is a deterrent to newcomers to enigmaIOT because the tutorial assumes esp8266's work and I assume you didn't test them. Due to the methods of switching scan mode to AP mode it uses +30% ram so you need <70% of max ram at compile time, anymore and it is bound to crash quickly.
NUM_NODES = 35 is guaranteed to crash esp8266.

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Unhandled C++ exception: OOM

>>>stack>>>

ctx: sys
sp: 3fffee50 end: 3fffffb0 offset: 0000
3fffee50:  4000050c 3fff79d4 3ffedcb4 00000000  
3fffee60:  000000fe 00000000 00000000 00000000  
3fffee70:  00000000 00000000 00000000 00000001  
3fffee80:  00007fff 00000000 00000000 3fff79d4  
3fffee90:  402226fc 40222741 000000f0 40220cbe  
3fffeea0:  402226fc 40222741 00000020 40220cdd  
3fffeeb0:  00000000 40279592 000000f0 402204d8  
3fffeec0:  402226fc 00000000 3fffbf84 40222741  
3fffeed0:  402985f0 0000010f 000000ff 0000000d  
3fffeee0:  402795ed 00000000 3fff10e8 402796a2  
3fffeef0:  0000010f 402793a9 3fff1100 3fff1920  
3fffef00:  01f80741 60000600 00000003 00000024  
3fffef10:  4027990d 3ffedcbe 4028ea53 3fff01b8  
3fffef20:  40292dd9 3fffdcc0 3ffec7c8 3ffec7c8  
3fffef30:  40292e1e 3fffdab0 00000000 3fffdcb0  
3fffef40:  3fff1940 3fffdab0 00000000 00000004  
3fffef50:  40000f49 40000f49 3fffdab0 40000f49  
3fffef60:  40000e19 000a8c04 00000000 00000005  
3fffef70:  00000000 40105631 000a8c04 00000000  
3fffef80:  40105637 00000000 00000000 40100c04  
3fffef90:  4010000d 33317453 000a8c04 401000ac  
3fffefa0:  40282ae0 3fffef3c 40282a91 3ffffd18  
3fffefb0:  3fffffc0 00000000 00000000 feefeffe  
3fffefc0:  feefeffe feefeffe feefeffe feefeffe  
3fffefd0:  feefeffe feefeffe feefeffe feefeffe  
3fffefe0:  feefeffe feefeffe feefeffe feefeffe  
3fffeff0:  feefeffe feefeffe feefeffe feefeffe  
3ffff000:  feefeffe feefeffe feefeffe feefeffe  
3ffff010:  feefeffe feefeffe feefeffe feefeffe  
3ffff020:  feefeffe feefeffe feefeffe feefeffe  
3ffff030:  feefeffe feefeffe feefeffe feefeffe  
3ffff040:  feefeffe feefeffe feefeffe feefeffe  
3ffff050:  feefeffe feefeffe feefeffe feefeffe  
3ffff060:  feefeffe feefeffe feefeffe feefeffe  
3ffff070:  feefeffe feefeffe feefeffe feefeffe  
3ffff080:  feefeffe feefeffe feefeffe feefeffe  
3ffff090:  feefeffe feefeffe feefeffe feefeffe  
3ffff0a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff0b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff0c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff0d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff0e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff0f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff100:  feefeffe feefeffe feefeffe feefeffe  
3ffff110:  feefeffe feefeffe feefeffe feefeffe  
3ffff120:  feefeffe feefeffe feefeffe feefeffe  
3ffff130:  feefeffe feefeffe feefeffe feefeffe  
3ffff140:  feefeffe feefeffe feefeffe feefeffe  
3ffff150:  feefeffe feefeffe feefeffe feefeffe  
3ffff160:  feefeffe feefeffe feefeffe feefeffe  
3ffff170:  feefeffe feefeffe feefeffe feefeffe  
3ffff180:  feefeffe feefeffe feefeffe feefeffe  
3ffff190:  feefeffe feefeffe feefeffe feefeffe  
3ffff1a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff1b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff1c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff1d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff1e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff1f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff200:  feefeffe feefeffe feefeffe feefeffe  
3ffff210:  feefeffe feefeffe feefeffe feefeffe  
3ffff220:  feefeffe feefeffe feefeffe feefeffe  
3ffff230:  feefeffe feefeffe feefeffe feefeffe  
3ffff240:  feefeffe feefeffe feefeffe feefeffe  
3ffff250:  feefeffe feefeffe feefeffe feefeffe  
3ffff260:  feefeffe feefeffe feefeffe feefeffe  
3ffff270:  feefeffe feefeffe feefeffe feefeffe  
3ffff280:  feefeffe feefeffe feefeffe feefeffe  
3ffff290:  feefeffe feefeffe feefeffe feefeffe  
3ffff2a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff2b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff2c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff2d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff2e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff2f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff300:  feefeffe feefeffe feefeffe feefeffe  
3ffff310:  feefeffe feefeffe feefeffe feefeffe  
3ffff320:  feefeffe feefeffe feefeffe feefeffe  
3ffff330:  feefeffe feefeffe feefeffe feefeffe  
3ffff340:  feefeffe feefeffe feefeffe feefeffe  
3ffff350:  feefeffe feefeffe feefeffe feefeffe  
3ffff360:  feefeffe feefeffe feefeffe feefeffe  
3ffff370:  feefeffe feefeffe feefeffe feefeffe  
3ffff380:  feefeffe feefeffe feefeffe feefeffe  
3ffff390:  feefeffe feefeffe feefeffe feefeffe  
3ffff3a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff3b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff3c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff3d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff3e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff3f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff400:  feefeffe feefeffe feefeffe feefeffe  
3ffff410:  feefeffe feefeffe feefeffe feefeffe  
3ffff420:  feefeffe feefeffe feefeffe feefeffe  
3ffff430:  feefeffe feefeffe feefeffe feefeffe  
3ffff440:  feefeffe feefeffe feefeffe feefeffe  
3ffff450:  feefeffe feefeffe feefeffe feefeffe  
3ffff460:  feefeffe feefeffe feefeffe feefeffe  
3ffff470:  feefeffe feefeffe feefeffe feefeffe  
3ffff480:  feefeffe feefeffe feefeffe feefeffe  
3ffff490:  feefeffe feefeffe feefeffe feefeffe  
3ffff4a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff4b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff4c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff4d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff4e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff4f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff500:  feefeffe feefeffe feefeffe feefeffe  
3ffff510:  feefeffe feefeffe feefeffe feefeffe  
3ffff520:  feefeffe feefeffe feefeffe feefeffe  
3ffff530:  feefeffe feefeffe feefeffe feefeffe  
3ffff540:  feefeffe feefeffe feefeffe feefeffe  
3ffff550:  feefeffe feefeffe feefeffe feefeffe  
3ffff560:  feefeffe feefeffe feefeffe feefeffe  
3ffff570:  feefeffe feefeffe feefeffe feefeffe  
3ffff580:  feefeffe feefeffe feefeffe feefeffe  
3ffff590:  feefeffe feefeffe feefeffe feefeffe  
3ffff5a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff5b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff5c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff5d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff5e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff5f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff600:  feefeffe feefeffe feefeffe feefeffe  
3ffff610:  feefeffe feefeffe feefeffe feefeffe  
3ffff620:  feefeffe feefeffe feefeffe feefeffe  
3ffff630:  feefeffe feefeffe feefeffe feefeffe  
3ffff640:  feefeffe feefeffe feefeffe feefeffe  
3ffff650:  feefeffe feefeffe feefeffe feefeffe  
3ffff660:  feefeffe feefeffe feefeffe feefeffe  
3ffff670:  feefeffe feefeffe feefeffe feefeffe  
3ffff680:  feefeffe feefeffe feefeffe feefeffe  
3ffff690:  feefeffe feefeffe feefeffe feefeffe  
3ffff6a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff6b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff6c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff6d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff6e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff6f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff700:  feefeffe feefeffe feefeffe feefeffe  
3ffff710:  feefeffe feefeffe feefeffe feefeffe  
3ffff720:  feefeffe feefeffe feefeffe feefeffe  
3ffff730:  feefeffe feefeffe feefeffe feefeffe  
3ffff740:  feefeffe feefeffe feefeffe feefeffe  
3ffff750:  feefeffe feefeffe feefeffe feefeffe  
3ffff760:  feefeffe feefeffe feefeffe feefeffe  
3ffff770:  feefeffe feefeffe feefeffe feefeffe  
3ffff780:  feefeffe feefeffe feefeffe feefeffe  
3ffff790:  feefeffe feefeffe feefeffe feefeffe  
3ffff7a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff7b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff7c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff7d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff7e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff7f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff800:  feefeffe feefeffe feefeffe feefeffe  
3ffff810:  feefeffe feefeffe feefeffe feefeffe  
3ffff820:  feefeffe feefeffe feefeffe feefeffe  
3ffff830:  feefeffe feefeffe feefeffe feefeffe  
3ffff840:  feefeffe feefeffe feefeffe feefeffe  
3ffff850:  feefeffe feefeffe feefeffe feefeffe  
3ffff860:  feefeffe feefeffe feefeffe feefeffe  
3ffff870:  feefeffe feefeffe feefeffe feefeffe  
3ffff880:  feefeffe feefeffe feefeffe feefeffe  
3ffff890:  feefeffe feefeffe feefeffe feefeffe  
3ffff8a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff8b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff8c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff8d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff8e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff8f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff900:  feefeffe feefeffe feefeffe feefeffe  
3ffff910:  feefeffe feefeffe feefeffe feefeffe  
3ffff920:  feefeffe feefeffe feefeffe feefeffe  
3ffff930:  feefeffe feefeffe feefeffe feefeffe  
3ffff940:  feefeffe feefeffe feefeffe feefeffe  
3ffff950:  feefeffe feefeffe feefeffe feefeffe  
3ffff960:  feefeffe feefeffe feefeffe feefeffe  
3ffff970:  feefeffe feefeffe feefeffe feefeffe  
3ffff980:  feefeffe feefeffe feefeffe feefeffe  
3ffff990:  feefeffe feefeffe feefeffe feefeffe  
3ffff9a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff9b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff9c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff9d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff9e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff9f0:  feefeffe feefeffe feefeffe feefeffe  
3ffffa00:  feefeffe feefeffe feefeffe feefeffe  
3ffffa10:  feefeffe feefeffe feefeffe feefeffe  
3ffffa20:  feefeffe feefeffe feefeffe feefeffe  
3ffffa30:  feefeffe feefeffe feefeffe feefeffe  
3ffffa40:  feefeffe feefeffe feefeffe feefeffe  
3ffffa50:  feefeffe feefeffe feefeffe feefeffe  
3ffffa60:  feefeffe feefeffe feefeffe feefeffe  
3ffffa70:  feefeffe feefeffe feefeffe feefeffe  
3ffffa80:  00000000 400042db feefeffe feefeffe  
3ffffa90:  00000009 00000000 00000010 00000000  
3ffffaa0:  00000009 00000000 00000010 00000000  
3ffffab0:  401003d6 00000001 3fffaf1c 003020c0  
3ffffac0:  00000000 80000000 00000000 0000001b  
3ffffad0:  00004800 00000000 00004800 3ffe83d0  
3ffffae0:  00000000 00000000 0000001f 40100370  
3ffffaf0:  3ffffbe1 3ffffbe3 3fffc228 40105d01  
3ffffb00:  4000050c 00000000 4023d369 3ffe83d0  
3ffffb10:  4020c5cb 00000030 00000008 ffffffff  
3ffffb20:  4020c5be 3fff5cf8 3ffffce8 00000000  
3ffffb30:  00000001 00000001 0104a8c0 3ffffcdc  
3ffffb40:  00ffffff 0104a8c0 67696e45 40237998  
3ffffb50:  3fff5cf8 00000010 0104a8c0 00000030  
3ffffb60:  40299a15 3ffe83d0 40242208 00000009  
3ffffb70:  40294696 3ffffbb0 3fff5cf8 00000003  
3ffffb80:  40294696 00000000 00000000 0104a8c0  
3ffffb90:  00000010 3ffffce8 00000020 40100c54  
3ffffba0:  4020c388 00000000 3fff5cf8 401005b0  
3ffffbb0:  40295d01 6404a8c0 4028f46b 00000001  
3ffffbc0:  ffffffff 00000000 3ffec8a1 00000008  
3ffffbd0:  4028f4ba 3fffbf84 3fffbf84 00000000  
3ffffbe0:  00000000 00000000 00000020 40100370  
3ffffbf0:  000000c0 0000000a 00000000 4010229c  
3ffffc00:  3ffec750 4028e57b 3fffbf84 3fff09f0  
3ffffc10:  00000000 402779ff 3fff09f0 3fffbf84  
3ffffc20:  3ffea46f 4029b7f0 00000000 4021d310  
3ffffc30:  3fffbec6 3fff79d4 00000000 00000000  
3ffffc40:  3ffea46f 3ffea46f 3fff7caf 40279817  
3ffffc50:  3fff10e8 40279410 402226fc 3fff10e8  
3ffffc60:  40105e45 00937f39 3fff1218 00000000  
3ffffc70:  3fff1920 3fff1218 3ffffcce 40221bd0  
3ffffc80:  00000000 0092ecbd 4027b413 3fff11e0  
3ffffc90:  3fff1218 402226fc 3fff10e8 3fff5cc8  
3ffffca0:  3fff0a74 4027b388 3fff09f0 00000012  
3ffffcb0:  40279400 402793d4 3fff0a74 00000012  
3ffffcc0:  4027939f 3fff09f0 00000012 4029286e  
3ffffcd0:  40279950 3fff09f0 3fff0b6c 402226fc  
3ffffce0:  4027937d 3fff0b6c 00000003 3fff0b6c  
3ffffcf0:  4027b7a5 3ffffd40 0000010f 3fff0b6c  
3ffffd00:  3fff1f78 0000010f 3ffea5f7 40221bd0  
3ffffd10:  402226fc 40295475 00000000 00000000  
3ffffd20:  00000000 3fff1f78 40220694 3fffefa0  
3ffffd30:  3ffffd40 402226fc 3fff79d4 402228a3  
3ffffd40:  00000000 00000000 00000000 00000000  
3ffffd50:  00000000 00000000 3fff5cc8 4021e4e0  
3ffffd60:  00000000 4029a81c 3fff5cc8 4021e504  
3ffffd70:  00000004 4029a81c 3fff5cc8 3ffe9971  
3ffffd80:  00000000 00000000 3fffb514 4020e66b  
3ffffd90:  40295854 3ffffdb0 3fffb514 4020ef73  
3ffffda0:  4020f8d2 3fff1f78 3fffb514 4020f8d9  
3ffffdb0:  4021d304 3ffea5f6 3fff5cc8 4021e268  
3ffffdc0:  3fffb580 00000000 3ffffdf0 4021f4cc  
3ffffdd0:  3fff1f78 3ffe8ca0 3ffffdf0 00000001  
3ffffde0:  3fff1f78 00000003 3fffb514 4020fab0  
3ffffdf0:  00000000 3fffb644 00000000 00000000  
3ffffe00:  3fff58fa 00000000 3fff1e38 40208e64  
3ffffe10:  00000003 3ffe9971 00000000 000007d0  
3ffffe20:  00000064 3fff1fa0 3fff59a0 40208003  
3ffffe30:  3fff58fa 3fffb62c 3fffb514 3fffb62c  
3ffffe40:  3fff58fa 3fff1fa0 3fff59a0 40215a23  
3ffffe50:  4029bd3d feefeffe feefeffe feefeffe  
3ffffe60:  00000000 00000000 00000000 00000000  
3ffffe70:  00000000 00000000 00000000 00000000  
3ffffe80:  3ffffe00 3ffe95cc 3ffe9904 3fffb33c  
3ffffe90:  00000004 3ffe98d3 3ffe98cc 3ffe98c1  
3ffffea0:  3fffb604 00000021 3ffe988b 3ffe9883  
3ffffeb0:  3ffe9876 3fffb31c 00000014 3ffe9840  
3ffffec0:  6f720033 65722072 6e696461 3fff1e38  
3ffffed0:  3fff58a0 40215c02 3fffb514 40100c54  
3ffffee0:  692e5454 3fff5bb4 3fff1f94 3fff58a0  
3ffffef0:  3fff1f94 3fff5bb4 3fff1fa0 40215d1a  
3fffff00:  3ffea5f8 3fffff10 00000008 00005ba7  
3fffff10:  63b8bac1 e85a9b25 7dda032d baf941ab  
3fffff20:  b0259f2e 8305bfc6 088582b8 54467b70  
3fffff30:  00000000 00000001 3fff5cc8 40205e70  
3fffff40:  00000000 00000000 00000000 3fff1e38  
3fffff50:  3fff58a0 3fff1fa0 00000000 40208afa  
3fffff60:  4029bc58 feefeffe feefeffe feefeffe  
3fffff70:  40208520 00000000 40235270 4023525c  
3fffff80:  40205864 feefeffe 4023530c 402352f0  
3fffff90:  feefeffe feefeffe feefeffe 3fff5e40  
3fffffa0:  3fffdad0 00000000 3fff5e2c 402207bc  
<<<stack<<<

last failed alloc call: 40222741(240)

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

last failed alloc caller: 0x40222741

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 3460, room 16 
tail 4
chksum 0xcc
load 0x3fff20b8, len 40, room 4 
tail 4
chksum 0xc9
csum 0xc9
v000a8c10
~ld
�c$`␃s�'␇l

W [81][H: 4104][GwOutput_mqtt.cpp:159] loadConfig() | /mqtt.json do not exist
W [81][H: 4104][EnigmaIOTGatewayMQTT.ino:418] setup() | Error reading config file
W [85][H: 3296][EnigmaIOTGateway.cpp:678] loadFlashData() | /config.json do not exist
W [94][H: 2696][EnigmaIOTGateway.cpp:687] loadFlashData() | Dummy STA config loaded
*WM: Adding parameter
*WM: netkey
*WM: Adding parameter
*WM: channel
*WM: Adding parameter
*WM: netname
*WM: Adding parameter
*WM: 
*WM: Adding parameter
*WM: mqttserver
*WM: Adding parameter
*WM: mqttport
*WM: Adding parameter
*WM: mqttuser
*WM: Adding parameter
*WM: mqttpass
*WM: 
*WM: AutoConnect Try No.:
*WM: 0
*WM: Connecting as wifi client...
*WM: Using last saved values, should be faster
*WM: Connection result: 
*WM: 1
*WM: AutoConnect Try No.:
*WM: 1
*WM: Connecting as wifi client...
*WM: Using last saved values, should be faster
*WM: Connection result: 
*WM: 1
*WM: AutoConnect Try No.:
*WM: 2
*WM: Connecting as wifi client...
*WM: Using last saved values, should be faster
*WM: Connection result: 
*WM: 1
*WM: SET AP STA
*WM: 
*WM: Configuring access point... 
*WM: EnigmaIoTGateway
*WM: AP IP address: 
*WM: (IP unset)
*WM: HTTP server started
*WM: About to scan()
*WM: About to scan()

User exception (panic/abort/assert)
--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Unhandled C++ exception: OOM

>>>stack>>>

ctx: sys
sp: 3fffee50 end: 3fffffb0 offset: 0000
3fffee50:  4000050c 3fff79d4 3ffee93c 00000000  
3fffee60:  000000fe 00000000 00000000 00000000  
3fffee70:  00000000 00000000 00000000 00000001  

on all esp8266 (have 6 different ones), don't have esp32 to test

Limitation on Number of total nodes

Please forgive me This is a question not an issue.
I read in the Readme that there is no limitation on the number of nodes with EnigmaIot, even when using esp now, how will that be possible? Since 20 nodes is the limit imposed by esp now itself. Is there something special we are doing in this project ?
I was looking at the code and i did not see a call to the function esp_now_add_peer in case of esp8266 (Which i saw in espressig esp now guide). Is this how we are lifting that limit by not adding peer, instead directly sending a message with esp_now_send method ?

I am also curious about this, because i started seeing a problem when we are trying to send more than 1 message quickly without a delay, the message won't be sent. and tx_cb is called with status error. I was wondering if we have to put a queue in the espnow_hal also for sending the messages and ensuring delays between every message.

Note: I am using esp8266 gateway and nodes.

Wrong use of searchForGateway (&rtcmem_data) ?

Hi @gmag11 , I came across these if conditions
if (searchForGateway (&rtcmem_data), true) in lines

if (searchForGateway (&rtcmem_data), true) {

if (!searchForGateway (&rtcmem_data), true) {

was it meant to be - if (searchForGateway (&rtcmem_data, true))
I noticed this problem because by node was always trying to conenct to the gateway even when it could not find the gateway.
It would print this in the logs.

 Gateway SMART_S not found
Found gateway. Storing

OTA not working on version 0.9.5

OTA is not working on any version. It's not been any change on OTA management since some time ago so it must be something external.

Activity LED does not flash so it seems that it is due to an external library.

Can’t work with EnigmaIOT

My setup,
Arduino IDE 1.8.16
Esp8266 board 3.0.2
I’ve installed all the external libraries as you mention on “howto”.
EnigmaIOT version 0.9.8.
“EnigmaIOTGatewayMQTT.ino” compile fine in “WEMOS lolin D1 mini”, (the led flash) but I can´t configure them.

The web page is not correct and when I click “Configure WiFi” opens a blank page.

192_168_4_1

In debug IDE terminal:
*WM: Configuring access point...
*WM: EnigmaIoTGateway
*WM: AP IP address:
*WM: 192.168.4.1
*WM: HTTP server started
*WM: About to scan()
*WM: About to scan()
*WM: Scan done
*WM: About to scan()
*WM: About to scan()

I appreciate your help.
Carlos Leite

Compilation error in helperFunctions.h for ESP8266

Hi @gmag11 , I'm trying to use your EnigmaIoT solution to set up a mesh of battery powered sensors in my garden, and I think yor solution is great for that :-)

I'm getting a compilation error in EnigmaIOTGatewayMQTT.ino configured for an ESP8266:

helperFunctions.cpp:139:23: error: expected initializer before 'extractFileName'

const char* IRAM_ATTR extractFileName (const char* path) {

                   ^

exit status 1

Arduino:1.8.7 (Windows 10), Tarjeta:"LOLIN(WEMOS) D1 R2 & mini, 80 MHz, Flash, 4M (1M SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 921600"

ATENCIÓN: Categoría '' en librería Crypto no es válida. Configurando a 'Uncategorized'
D:\Google Drive\Domotica\ARDUINO\sketches_ROB_Skethces_MySensors_modificados\libraries\src\helperFunctions.cpp:139:23: error: expected initializer before 'extractFileName'

const char* IRAM_ATTR extractFileName (const char* path) {

                   ^

exit status 1

Could you please help me to solve it?

Thank you for your support!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.