Enabling signing (Development branch)?
-
Driven by the latest patch with respect to repeater nodes in combination with signing I tried to move one of my nodes who is supposed to act as repeater to the latest version of the development branch.
My nodes are using for signing the ATSHA204. The node I wanted to update since it is supposed to be a repeater worked before.
After the upgrade it doesn't seem to sign messages anymore.
Messages are sent out, but there is no nonce request sent out or anything related to the SHA204 protocol. The messages are received on the gateway, but but are reported "no sign".I inserted the define
#define MY_SIGNING_ATSHA204
It seems that is not sufficient. Any help is appreciated. Please find below the full sketch.
/* IRSendActuator Author: Thomas Krebs, thkrebs@gmx.de This transforms the payload into IR signals for the supported IR receivers. Currently, only the Denon receiver on child id 1 is supported The expected payload format is: cmd1,cmd2[,repetition] cmd1 and cmd2 are tranformed into the proper Denon IR protocol The cmd1, cmd2 sequence will be sent consecutively <repetition> times. If not provided a default will be used. The IR led is to be connected on pin 3 */ #define MY_RADIO_NRF24 #define MY_SIGNING_ATSHA204 #define MY_REPEATER_FEATURE #define MY_DEBUG //#define MY_DEBUG_VERBOSE #include <MySensor.h> #include <IRLib.h> #include <avr/power.h> #include <SPI.h> #include <dht.h> #define VERSION "1.2" #define SKETCH_NAME "IRSendActuator" //#define BAUD_RATE 115200 // Pin definitions #define LED_PIN 4 // The pin the ATSHA204 is connected on #define ATSHA204_PIN A3 // A3 // TV Sense Pin #define LIGHT_SENSE_PIN A0 // currently not in use // Temp Sensor pin #define DHTPIN 5 // How many milli seconds between each measurement #define MEASURE_INTERVAL 120000 // FORCE_TRANSMIT_INTERVAL, this number of times of wakeup, the sensor is forced to report all values to the controller #define FORCE_TRANSMIT_INTERVAL 30 // When MEASURE_INTERVAL is 60000 and FORCE_TRANSMIT_INTERVAL is 30, we force a transmission every 30 minutes. // Between the forced transmissions a tranmission will only occur if the measured value differs from the previous measurement // HUMI_TRANSMIT_THRESHOLD tells how much the humidity should have changed since last time it was transmitted. Likewise with // TEMP_TRANSMIT_THRESHOLD for temperature threshold. #define HUMI_TRANSMIT_THRESHOLD 1.0 #define TEMP_TRANSMIT_THRESHOLD 0.5 #define LIGHT_THRESHOLD 450 // threshold which determine ON or OFF state // Define a static node address, remove if you want auto address assignment #define MY_NODE_ID 24 #define TEMP_CHILD_ID 1 #define HUM_CHILD_ID 2 #define IR_DENON_CHILD_ID 3 #define IR_SAMSUNG_CHILD_ID 4 #define LIGHT_CHILD_ID 5 // Comment //#define DEBUG //#undef DEBUG // IR Sender IRsend mySender; int defaultRepeats = 7; // default value for repetitions send int delayBetweenSent= 20; // delay between two send int khz=38; //NB Change this default value as neccessary to the correct carrier frequency char payload[64]; // Temp Sensor dht DHT; int measureCount = 0; boolean isMetric = true; // Storage of old measurements float lastTemperature = -100; float lastHumidity = -100; int last_light_status = -1; unsigned long prevMillis = 0; // Sensor messages MyMessage msgTemp(TEMP_CHILD_ID,V_TEMP); MyMessage msgHum(HUM_CHILD_ID,V_HUM); MyMessage msgLight(LIGHT_CHILD_ID, V_STATUS); void setup() { pinMode(LED_PIN, OUTPUT); blink(5,150,50); delay(500); Serial.print(F(SKETCH_NAME)); Serial.println(VERSION); Serial.flush(); delay(500); Serial.flush(); Serial.println(F(" - Online!")); // Send the sketch version information to the gateway and Controller sendSketchInfo(SKETCH_NAME, VERSION); present(TEMP_CHILD_ID, S_TEMP); present(HUM_CHILD_ID, S_HUM); present(IR_DENON_CHILD_ID, S_IR); // gw.present(LIGHT_CHILD_ID, S_BINARY); isMetric = getConfig().isMetric; Serial.print(F("isMetric: ")); Serial.println(isMetric); delay(5000); sendTempHumidityMeasurements(false); } void loop() { unsigned long currentMillis = millis(); bool forceTransmit = false; if (currentMillis - prevMillis > MEASURE_INTERVAL) { prevMillis = currentMillis; measureCount++; if (measureCount > FORCE_TRANSMIT_INTERVAL) { // force a transmission forceTransmit = true; measureCount = 0; } sendTempHumidityMeasurements(forceTransmit); } // Light is checked in each loop; making sure we determine changes immediately // sendLightStatus(forceTransmit); } void receive(const MyMessage &message) { Serial.print(F("Received message of type: ")); Serial.println(message.type); Serial.print(F("Payload: ")); Serial.println(message.getString()); blink(5,150,50); // We only expect one type of message from controller. But we better check anyway. if (message.type==V_IR_SEND) { /* parse payload */ strncpy(payload, message.getString(), sizeof(payload)); payload[sizeof(payload)-1]=0; char *str, *p; unsigned long cmd1, cmd2; int repeats = -1; uint8_t i = 0; if (message.sensor == IR_DENON_CHILD_ID) { cmd1= strtoul(payload,&p,16); cmd2= strtoul(p,&p,16); repeats = atoi(p); if (repeats <= 0) { repeats = defaultRepeats; } Serial.print("cmd1: "); Serial.println(cmd1,HEX); Serial.print("cmd2: "); Serial.println(cmd2,HEX); Serial.print("repeats:"); Serial.println(repeats); for (int i=0; i<repeats; i++) { /* changed khz was 0 before */ mySender.IRsendBase::sendGeneric(cmd1,15,0,0,275,275,1900,775,khz,true,46060); mySender.IRsendBase::sendGeneric(cmd2,15,0,0,275,275,1900,775,khz,true,46060); delay(20); } } else if (message.sensor == IR_SAMSUNG_CHILD_ID) { cmd1 = strtoul(payload,&p,16); repeats = atoi(p); if (repeats <= 0) { repeats = defaultRepeats; } Serial.print("cmd1: "); Serial.println(cmd1,HEX); Serial.print("repeats:"); Serial.println(repeats); for (int i=0; i<repeats; i++) { mySender.IRsendBase::sendGeneric(cmd1,32,4500,4500,560,560,1690,560,khz,true,0); delay(20); } } else { blink(5,25,50); } } } void blink(int nr, int high, int low) { for (int i=0; i<nr; i++) { digitalWrite(LED_PIN, HIGH); delay(high); digitalWrite(LED_PIN,LOW); delay(low); } digitalWrite(LED_PIN,LOW); } /********************************************* * * Sends temperature and humidity from DHT sensor * * Parameters * - force : Forces transmission of a value (even if it's the same as previous measurement) * *********************************************/ void sendTempHumidityMeasurements(bool force) { bool tx = force; int ret = DHT.read22(DHTPIN); if (ret != DHTLIB_OK) { Serial.print(F("Error reading DHT22 :")); Serial.println(ret); return; } float hum = DHT.humidity; float temp = DHT.temperature; Serial.print(F("lastTemperature: ")); Serial.println(lastTemperature); Serial.print(F("lastHumidity: ")); Serial.println(lastHumidity); float diffTemp = abs(lastTemperature - temp); float diffHum = abs(lastHumidity - hum); Serial.print(F("TempDiff :"));Serial.println(diffTemp); Serial.print(F("HumDiff :"));Serial.println(diffHum); if (isnan(diffHum)) tx = true; if (diffTemp > TEMP_TRANSMIT_THRESHOLD) tx = true; if (diffHum >= HUMI_TRANSMIT_THRESHOLD) tx = true; if (tx) { measureCount = 0; Serial.print(F("Temperature: "));Serial.println(temp); Serial.print(F("Humidity: "));Serial.println(hum); send(msgTemp.setSensor(TEMP_CHILD_ID).set(temp,1)); send(msgHum.setSensor(HUM_CHILD_ID).set(hum,1)); lastTemperature = temp; lastHumidity = hum; } } void sendLightStatus(bool force) { bool tx = force; int avg = 0; int level = 0; // I don't care about rounding errors int light_status; // Take 5 samples for (int i = 0; i < 5; i++) { level = analogRead(LIGHT_SENSE_PIN); avg = avg + (level - avg)/(i+1); } light_status = (avg > LIGHT_THRESHOLD) ? 1 : 0; if (light_status != last_light_status) tx= true; Serial.print(F("Light Status: ")); Serial.print(level); Serial.print(F("/")); Serial.println(light_status); if (tx) { send(msgLight.setSensor(LIGHT_CHILD_ID).set(light_status,1)); last_light_status = light_status; } }
-
Move the inclusion of MySensor.h below all MY_* defines.
-
@hek: That's what I have. See attached sketch.
-
@hek I just saw that there is a another define MY_SIGNING_FEATURE. I defined that as well. Now, I receive a compile error, see below:
erwende die Bibliothek MySensors im Ordner: /Users/tom/Documents/Arduino/libraries/MySensors Verwende die Bibliothek IRLib im Ordner: /Users/tom/Documents/Arduino/libraries/IRLib (legacy) Verwende die Bibliothek SPI im Ordner: /Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI Verwende die Bibliothek DHTlib im Ordner: /Users/tom/Documents/Arduino/libraries/DHTlib (legacy) /Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10604 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/eightanaloginputs -I/Users/tom/Documents/Arduino/libraries/MySensors -I/Users/tom/Documents/Arduino/libraries/IRLib -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI -I/Users/tom/Documents/Arduino/libraries/DHTlib /var/folders/3s/rjbksrj96nv0hqfqjlpfw8bm0000gn/T/build3975560794087132630.tmp/IRSendActuator.cpp -o /var/folders/3s/rjbksrj96nv0hqfqjlpfw8bm0000gn/T/build3975560794087132630.tmp/IRSendActuator.cpp.o In file included from /Users/tom/Documents/Arduino/libraries/MySensors/MySensor.h:23:0, from IRSendActuator.ino:24: /Users/tom/Documents/Arduino/libraries/MySensors/core/MySensorCore.h:28:27: fatal error: MySigningNone.h: No such file or directory #include "MySigningNone.h" ^ compilation terminated. Fehler beim Kompilieren.```
-
The MY_SIGNING_FEATURE should be enabled automatically when when defining MY_SIGNING_ATSHA204
https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/MySensor.h#L74
Does it work when disabling REPEATER-feature?
-
@hek Disabling the REPEATER feature was one of the first things I tried. That does not work, either.
But anyway, I cannot find the header file MySigningNone.h which the compiler tries to include.
-
Yes, the MySigningNone.h include shouldn't be there.
Strange that SecureActuator example isn't failing when compiling.. need to investigate this a bit.
-
@hek I got it working after inserting the define
#define MY_SIGNING_REQUEST_SIGNATURES
The same applies for soft signing which I tried as well.
For an actuator it makes sense only to process signed messages.
However, I thought that in general this feature was intended to be specified independently.