Nice, thanks for the quick response.
Posts made by DerTomm
-
RE: MySensors protocol page improvement recommendation
-
MySensors protocol page improvement recommendation
Hi MySensors team,
as I am working a lot with the MySensors library at the moment, I just found a little inconsistency between the API and the protocol documentation (https://www.mysensors.org/download/serial_api_20).
The documentation says that messages consists of these parts: node-id ; child-sensor-id ; message-type ; ack ; sub-type ; payload.
In the source code (class MyMessage.h) you don't use "message-type" and "sub-type" but instead "command" and "(message) type".As I think the latter terms are more suitable for the protocol understanding I'd like to raise the discussion whether it would we better using "command-type" and "message-type" in the protocol documentation as well instead. Then docs and sources would be "in sync" again and I think the protocol structure would be even better understandable.
Finally another little improvement request: The protocol docs are still talking about "Serial Protocol - 2.0.x" - maybe you should update this to "2.x".
Best regards,
Thomas -
RE: [Solved] Undefined reference to own class used in Arduino sketch .cpp
Finally I found a solution for the described situation.
PlatformIO did not compile all dependend files in a library due to a wrong folder layout. After correcting this it works now.
For people experiencing the same issue I recommend visiting the connected PlatformIO community thread: https://community.platformio.org/t/pio-does-not-compile-all-included-library-classes-which-leads-to-linker-errors/1034 -
[Solved] Undefined reference to own class used in Arduino sketch .cpp
Hi,
I just ran into a problem which occures as soon as I include another own class besides MySensors. Here is my code:
// Enable debug prints to serial monitor #define MY_DEBUG // Enable serial gateway #define MY_GATEWAY_SERIAL // Set blinking period #define MY_DEFAULT_LED_BLINK_PERIOD 300 // Inverses the behavior of leds #define MY_WITH_LEDS_BLINKING_INVERSE // Enable inclusion mode #define MY_INCLUSION_MODE_FEATURE // Enable Inclusion mode button on gateway //#define MY_INCLUSION_BUTTON_FEATURE // Inverses behavior of inclusion button (if using external pullup) //#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP // Set inclusion mode duration (in seconds) #define MY_INCLUSION_MODE_DURATION 60 // Digital pin used for inclusion mode button #define MY_INCLUSION_MODE_BUTTON_PIN 3 #include <SPI.h> #include <MySensors.h> #include "Applications/LedHandler.h" MyMessage msgNodeTemperature(0, V_TEMP); LedHandler* ledHandler; unsigned long lastSentTimestamp = 0L; void setup() { ledHandler = new LedHandler(); } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Demo", "1.0"); present(0, S_TEMP); // Board ambient temperature } /**************************************************************************************************************** * */ void loop() { if (millis() - lastSentTimestamp > 10000) { long int rand = random(0, 30); send(msgNodeTemperature.set(rand, 1)); lastSentTimestamp = millis(); } }
The problem starts when I create a new object of LedHandler and assign it to the pointer in the setup() method. Then I get the following linker error:
Compiling .pioenvs\nanoatmega328\src\OpenhabDemo.o Linking .pioenvs\nanoatmega328\firmware.elf .pioenvs\nanoatmega328\src\OpenhabDemo.o: In function `setup': C:\Users\Thomas\.platformio\lib\MySensors_ID548/drivers/ATSHA204/sha256.cpp:70: undefined reference to `LedHandler::LedHandler()' collect2.exe: error: ld returned 1 exit status *** [.pioenvs\nanoatmega328\firmware.elf] Error 1 [ERROR] Took 2.97 seconds
Obviously there is a dependency problem. Can you help me how to get rid of it?
I use PlatformIO for compilation. OpenhabDemo.cpp is my main Arduino sketch file.Here is the header and the class file of the dependend LedHandler:
#ifndef SRC_APPLICATIONS_LEDHANDLER_H_ #define SRC_APPLICATIONS_LEDHANDLER_H_ #include "Actor.h" #include "ApplicationHelper.h" class LedHandler: public Actor { public: LedHandler(); virtual ~LedHandler(); uint8_t getApplicationPort() const { return ApplicationHelper::LED_HANDLER; } void executeFunction(char* payload); void addLed(uint8_t ledPin); bool setLedEnabled(uint8_t ledId, bool enabled); private: uint8_t* managedLeds; uint8_t ledCounter; }; #endif /* SRC_APPLICATIONS_LEDHANDLER_H_ */
#include "Applications/LedHandler.h" /*************************************************************************************************** * */ LedHandler::LedHandler() { ledCounter = 0; managedLeds = 0; } /*************************************************************************************************** * */ LedHandler::~LedHandler() { if (managedLeds != 0) { delete managedLeds; } } /*************************************************************************************************** * */ void LedHandler::executeFunction(char* payload) { <deleted> } /*************************************************************************************************** * */ void LedHandler::addLed(uint8_t ledPin) { <deleted> } /*************************************************************************************************** * */ bool LedHandler::setLedEnabled(uint8_t ledId, bool enabled) { <deleted> }
-
RE: [SOLVED] GatewayESP8266MQTTClient node reboots permanently as soon as MyController activates it as gateway
Thanks - that solved the problem!
-
[SOLVED] GatewayESP8266MQTTClient node reboots permanently as soon as MyController activates it as gateway
Hi everyone,
up to now I used MySensors release 2.0.1-beta together with Arduino ยตCs and nRF24L01+ modules which works fine. Thanks to all developers and supporters for this great project.
Today I tried to include an ESP8266 node (ESP-01 module with a Dallas temperature sensor attached) into my network. I chose the GatewayESP8266MQTTClient sketch from the examples folder and adapted it to my Wifi network. The communication with the MQTT broker works flawlessly so far. After powering the node it transmits its meta/vital data and the temperature value:
;MCO:BGN:INIT GW,CP=R-NGE--,VER=2.0.1-beta scandone f 0, scandone state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 5 (10) add 0 aid 5 cnt connected with Kumanet, channel 6 ip:192.168.64.99,mask:255.255.255.0,gw:192.168.64.253 chg_B1:-40 .IP: 192.168.64.99 0;255;3;0;9;MCO:REG:NOT NEEDED 0;255;3;0;9;MCO:BGN:STP 0;255;3;0;9;MCO:BGN:INIT OK,ID=0,PAR=0,DIS=0,REG=1 IP: 192.168.64.99 0;255;3;0;9;Attempting MQTT connection... chg_B1:-80 0;255;3;0;9;MQTT connected 0;255;3;0;9;Sending message on topic: mygateway1-out/0/255/0/0/17 0;255;3;0;9;Sending message on topic: mygateway1-out/0/255/3/0/11 0;255;3;0;9;Sending message on topic: mygateway1-out/0/255/3/0/12 0;255;3;0;9;Sending message on topic: mygateway1-out/0/0/0/0/6 0;255;3;0;9;Sending message on topic: mygateway1-out/0/0/1/0/0 chg_B1:-120 pm open,type:2 0 0;255;3;0;9;Sending message on topic: mygateway1-out/0/0/1/0/0 0;255;3;0;9;Sending message on topic: mygateway1-out/0/0/1/0/0 0;255;3;0;9;Sending message on topic: mygateway1-out/0/0/1/0/0 0;255;3;0;9;Sending message on topic: mygateway1-out/0/0/1/0/0 ...
The problems starts as soon as I register the node in MyController as MQTT gateway:
As soon as I enable the newly added gateway the ESP8266 sensor node reboots and goes into a boot loop:
connected with Kumanet, channel 6 ip:192.168.64.99,mask:255.255.255.0,gw:192.168.64.253 chg_B1:-40 .IP: 192.168.64.99 0;255;3;0;9;MCO:REG:NOT NEEDED 0;255;3;0;9;MCO:BGN:STP 0;255;3;0;9;MCO:BGN:INIT OK,ID=0,PAR=0,DIS=0,REG=1 IP: 192.168.64.99 0;255;3;0;9;Attempting MQTT connection... 0;255;3;0;9;MQTT connected 0;255;3;0;9;Sending message on topic: mygateway1-out/0/255/0/0/17 0;255;3;0;9;Sending message on topic: mygateway1-out/0/255/3/0/11 0;255;3;0;9;Sending message on topic: mygateway1-out/0/255/3/0/12 0;255;3;0;9;Sending message on topic: mygateway1-out/0/0/0/0/6 0;255;3;0;9;Sending message on topic: mygateway1-out/0/0/1/0/0 chg_B1:-80 chg_B1:-120 pm open,type:2 0 0;255;3;0;9;Sending message on topic: mygateway1-out/0/0/1/0/0 0;255;3;0;9;Sending message on topic: mygateway1-out/0/0/1/0/0 IP: 192.168.64.99 0;255;3;0;9;Attempting MQTT connection... 0;255;3;0;9;MQTT connected 0;255;3;0;9;Sending message on topic: mygateway1-out/0/255/0/0/17 0;255;3;0;9;Sending message on topic: mygateway1-out/0/255/3/0/11 IP: 192.168.64.99 0;255;3;0;9;Attempting MQTT connection... 0;255;3;0;9;MQTT connected 0;255;3;0;9;Sending message on topic: mygateway1-out/0/255/0/0/17 IP: 192.168.64.99 0;255;3;0;9;Attempting MQTT connection... 0;255;3;0;9;MQTT connected 0;255;3;0;9;Sending message on topic: mygateway1-out/0/255/0/0/17 IP: 192.168.64.99 0;255;3;0;9;Attempting MQTT connection... 0;255;3;0;9;MQTT connected 0;255;3;0;9;Sending message on topic: mygateway1-out/0/255/0/0/17 ...
Unfortunately there are no further debug outputs. Neither on MySensors side nor on MyController side. As far as I see MyController does not send any MQTT messages at any time.
Is it possible that the sensor node reboots because it does not get any responses? But why aren't there any reboots if the node is not an enabled gateway in MyController? There must be any non-visible communication which causes the reboots...
Did anybody include a GatewayESP8266MQTTClient successfully into MyController yet?The MQTT broker is Mosquitto by the way, hostet on the same server as MyController.
This is my sketch:
#include <Arduino.h> #include <EEPROM.h> #include <SPI.h> // Enable debug prints to serial monitor #define MY_DEBUG // Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h #define MY_BAUD_RATE 115200 #define MY_NODE_ID 4 #define MY_PARENT_NODE_ID 0 #define MY_GATEWAY_MQTT_CLIENT #define MY_GATEWAY_ESP8266 // Set this node's subscribe and publish topic prefix #define MY_MQTT_PUBLISH_TOPIC_PREFIX "mygateway1-out" #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway1-in" // Set MQTT client id #define MY_MQTT_CLIENT_ID "mysensors-1" // Set WIFI SSID and password #define MY_ESP8266_SSID "Kumanet" #define MY_ESP8266_PASSWORD "<<REMOVED>>" // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP) #define MY_IP_ADDRESS 192,168,64,99 // If using static ip you need to define Gateway and Subnet address as well #define MY_IP_GATEWAY_ADDRESS 192,168,64,253 #define MY_IP_SUBNET_ADDRESS 255,255,255,0 // MQTT broker ip address. #define MY_CONTROLLER_IP_ADDRESS 192, 168, 64, 253 // The MQTT broker port to to open #define MY_PORT 1883 #include <ESP8266WiFi.h> #include <MySensors.h> #include <OneWire.h> #include <DallasTemperature.h> #define ONE_WIRE_BUS 0 OneWire oneWire(ONE_WIRE_BUS); DallasTemperature sensors(&oneWire); #define CHILD_ID_TEMPERATURE 0 MyMessage msgTemperature(CHILD_ID_TEMPERATURE, V_TEMP); unsigned long lastSent = 0; void setup() { sensors.begin(); } void presentation() { // Send the Sketch Version Information to the Gateway sendSketchInfo("ESP8266TempSensor", "0.9"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_TEMPERATURE, S_TEMP); } void loop() { sensors.requestTemperatures(); // Send the command to get temperatures delay(50); send(msgTemperature.set(sensors.getTempCByIndex(0), 1)); delay(10000); }