[security] Introducing signing support to MySensors


  • Contest Winner

    @meddie Sorry, missed that post.
    You have SKIP_KEY_STORAGE defined so no keys will be stored. This is the default and intentional, to avoid people just executing the sketch and accidentally overwrite existing keys.
    Furthermore, you have selected to personalize a ATSHA device, and have it generate the keys. That means that you have to define LOCK_CONFIGURATION or the ATSHA random number generator will not work.


  • Contest Winner

    You can read about personalization here.



  • Ah, thank you very much, yes now i get generated a key. But one more question the AES key will not be generated? I got only the HMAC Key, do i have to put the AES Key at myself?
    Thank you very much!


  • Contest Winner

    @meddie Please read the documentation and the sketch carefully. It quite clearly states in both documentation and code that you need to define STORE_AES_KEY to generate and store an AES key.



  • @Anticimex
    sorry sorry for so many questions, i have read the how to use already some times, but maybe its my bad english or the fear to do something wrong or to destroy the chip. I get a little bit unsure.

    Now i get both keys. If i understood correctly, the keys are now stored, i have now to put the shown keys to the sketch as HMAC and AES Key, and run this sketch on the sensor nodes.
    On the gateway on which i generated the keys i dont need to do anything more as to upload the gateway sketch ?
    Thank you very much for your support!


  • Contest Winner

    @meddie assuming you locked the configuration of the atsha, no you should not need to do more.



  • @Anticimex said in 💬 Sensebender Gateway:

    @meddie Sorry, missed that post.
    You have SKIP_KEY_STORAGE defined so no keys will be stored. This is the default and intentional, to avoid people just executing the sketch and accidentally overwrite existing keys.
    Furthermore, you have selected to personalize a ATSHA device, and have it generate the keys. That means that you have to define LOCK_CONFIGURATION or the ATSHA random number generator will not work.

    @Anticimex
    sorry i have one more question, because i didnt fully understand this. In the gettings started how to you wrote:

    Pick a “master” device with serial debug port.
    Set the following sketch configuration of the personalizer:
    ...
    
    Enable SKIP_KEY_STORAGE
    ...
    
    Execute the sketch on the “master” device to obtain a randomized key. Save this key to a secure location and keep it confidential so that you can retrieve it if you need to personalize more devices later on.
    Now reconfigure the sketch with these settings:
    ...
    Disable SKIP_KEY_STORAGE
    ...
    Put the saved key in the user_key_data variable.
    Now execute the sketch on all devices you want to personalize with this secret key.
    

    on the first run i have to enable SKIP_KEY_STORAGE so i removed the comments.
    But here in forum you write i have to disable this. After i has disabled it wroked fine for me.

    But now i have to run the sketch on my node, and i think i have to disable the SKIP function too, because i need that the keys will be stored in the node.

    So if i am right, the on both runs the SKIP function has to be commented out? Or i am wrong?
    Thank you.


  • Contest Winner

    @meddie If your read the text carefully it says:
    Set the following sketch configuration of the personalizer:
    ...
    Execute the sketch on the “master” device to obtain a randomized key. Save this key to a secure location and keep it confidential so that you can retrieve it if you need to personalize more devices later on.
    Now reconfigure the sketch with these settings:
    ...
    Now execute the sketch on all devices you want to personalize with this secret key.

    So in other words; you first use the settings described in the first setting, execute that once. Follow the instructions carefully. Write down the key you got. Then you reconfigure the sketch and execute it on all devices you want to personalize. That is, you execute it twice on the first device.
    I wrote that you need to undefine SKIP_KEY_STORAGE if you want to store a key. But the first set of instructions in the documentation is not saying that you are supposed to store a key. It says "Execute the sketch on the “master” device to obtain a randomized key."

    So the documentation is correct, and describe a flow where you personalize nodes and gateways with the minimum amount of changes needed. First you generate a key, and this step can actually be skipped altogether if you just make your own random key or password to use for HMAC/AES.
    Then you reconfigure the personalizer to use your generated (or selected) key and write it to all your devices.



  • @Anticimex
    but as i runned the sketch with SKIP_KEY_STORAGE defined, so no keys were generated.

    i did not like to say that the documentation is incorrect, i like your documentation and your work very well! i just didnt understand it!

    Thank you very much!
    Greets Eddie


  • Contest Winner

    @meddie are you sure you ran with the exact settings described for generating the keys? The SKIP_KEY_STORAGE flag does not prevent the keys from being generated. They are still printed in the serial log. It prevents the keys from being stored to the atsha204a device.



  • i fear to write again, but my fail story goes on 😞
    i have uploaded on the gateway this sketch:

    /**
    * The MySensors Arduino library handles the wireless radio link and protocol
    * between your home built sensors/actuators and HA controller of choice.
    * The sensors forms a self healing radio network with optional repeaters. Each
    * repeater and gateway builds a routing tables in EEPROM which keeps track of the
    * network topology allowing messages to be routed to nodes.
    *
    * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
    * Copyright (C) 2013-2015 Sensnology AB
    * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
    *
    * Documentation: http://www.mysensors.org
    * Support Forum: http://forum.mysensors.org
    *
    * This program is free software; you can redistribute it and/or
    * modify it under the terms of the GNU General Public License
    * version 2 as published by the Free Software Foundation.
    *
    *******************************
    *
    * REVISION HISTORY
    * Version 1.0 - Henrik EKblad
    * Contribution by a-lurker and Anticimex,
    * Contribution by Norbert Truchsess <norbert.truchsess@t-online.de>
    * Contribution by Tomas Hozza <thozza@gmail.com>
    *
    *
    * DESCRIPTION
    * The EthernetGateway sends data received from sensors to the ethernet link.
    * The gateway also accepts input on ethernet interface, which is then sent out to the radio network.
    *
    * This GW code is designed for Sensebender GateWay / (Arduino Zero variant)
    *
    * Wire connections (OPTIONAL):
    * - Inclusion button should be connected to SW2
    *
    * LEDs on board (default assignments):
    * - Orange: USB RX/TX - Blink when receiving / transmitting on USB CDC device
    * - Yellow: RX  - Blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
    * - Green : TX  - Blink fast on radio message transmitted. In inclusion mode will blink slowly
    * - Red   : ERR - Fast blink on error during transmission error or recieve crc error
    * - Blue  : free - (use with LED_BLUE macro)
    *
    */
    
    #include <stdint.h>
    #include <pins_arduino.h>
    #define SKETCH_VERSION "0.2"
    // Enable debug prints to serial monitor
    #define MY_DEBUG
    #define MY_DEBUG_VERBOSE_SIGNING
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    // Set LOW transmit power level as default, if you have an amplified NRF-module and
    // power your radio separately with a good regulator you can turn up PA level.
    //#define MY_RF24_PA_LEVEL RF24_PA_HIGH
    
    #define MY_SIGNING_ATSHA204
    //#define MY_SIGNING_NODE_WHITELISTING {{.nodeId = GATEWAY_ADDRESS,.serial = {0x09,0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01}}}
    //#define MY_SIGNING_REQUEST_SIGNATURES
    #ifndef MY_SIGNING_SOFT_RANDOMSEED_PIN
    #define MY_SIGNING_SOFT_RANDOMSEED_PIN 7
    #endif                              
    #ifndef MY_SIGNING_ATSHA204_PIN
    #define MY_SIGNING_ATSHA204_PIN 17
    #endif        
    #define MY_RF24_ENABLE_ENCRYPTION
        
    // Enable gateway ethernet module type
    #define MY_GATEWAY_W5100
    
    // W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal)
    //#define MY_W5100_SPI_EN 4
    
    // Enable Soft SPI for NRF radio (note different radio wiring is required)
    // The W5100 ethernet module seems to have a hard time co-operate with
    // radio on the same spi bus.
    #if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD)
    #define MY_SOFTSPI
    #define MY_SOFT_SPI_SCK_PIN 14
    #define MY_SOFT_SPI_MISO_PIN 16
    #define MY_SOFT_SPI_MOSI_PIN 15
    #endif
    
    // When W5100 is connected we have to move CE/CSN pins for NRF radio
    #ifndef MY_RF24_CE_PIN
    #define MY_RF24_CE_PIN 5
    #endif
    #ifndef MY_RF24_CS_PIN
    #define MY_RF24_CS_PIN 6
    #endif
    
    // Enable to UDP
    //#define MY_USE_UDP
    
    #define MY_IP_ADDRESS 10,0,0,253   // If this is disabled, DHCP is used to retrieve address
    // Renewal period if using DHCP
    //#define MY_IP_RENEWAL_INTERVAL 60000
    // The port to keep open on node server mode / or port to contact in client mode
    #define MY_PORT 5003
    
    // Controller ip address. Enables client mode (default is "server" mode).
    // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere.
    //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 254
    
    // The MAC address can be anything you want but should be unique on your network.
    // Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use.
    // Note that most of the Ardunio examples use  "DEAD BEEF FEED" for the MAC address.
    #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
    
    // 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
    
    // Set blinking period
    #define MY_DEFAULT_LED_BLINK_PERIOD 300
    
    // Inverses the behavior of leds
    //#define MY_WITH_LEDS_BLINKING_INVERSE
    
    // Flash leds on rx/tx/err
    // Uncomment to override default HW configurations
    //#define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
    //#define MY_DEFAULT_RX_LED_PIN  6  // Receive led pin
    //#define MY_DEFAULT_TX_LED_PIN  5  // the PCB, on board LED
    
    
    #if defined(MY_USE_UDP)
    #include <EthernetUdp.h>
    #endif
    #include <Ethernet.h>
    #include <MySensors.h>
    #include <SD.h>
    //#include <drivers/ATSHA204/ATSHA204.cpp>
    
    Sd2Card card;
    
    #define EEPROM_VERIFICATION_ADDRESS 0x01
    
    static uint8_t num_of_leds = 5;
    static uint8_t leds[] = {LED_BLUE, LED_RED, LED_GREEN, LED_YELLOW, LED_ORANGE};
    
    void setup()
    {
      // Setup locally attached sensors
    }
    
    void presentation()
    {
      // Present locally attached sensors
    }
    
    void loop()
    {
      // Send locally attached sensor data here
    }
    
    
    void preHwInit()
    {
    
      pinMode(MY_SWC1, INPUT_PULLUP);
      pinMode(MY_SWC2, INPUT_PULLUP);
      if (digitalRead(MY_SWC1) && digitalRead(MY_SWC2)) {
        return;
      }
    
      uint8_t tests = 0;
    
      for (int i=0; i< num_of_leds; i++) {
        pinMode(leds[i], OUTPUT);
      }
      uint8_t led_state = 0;
      if (digitalRead(MY_SWC1)) {
        while (!Serial) {
          digitalWrite(LED_BLUE, led_state);
          led_state ^= 0x01;
          delay(500);
        } // Wait for USB to be connected, before spewing out data.
      }
      digitalWrite(LED_BLUE, LOW);
      if (Serial) {
        Serial.println("Sensebender GateWay test routine");
        Serial.print("Mysensors core version : ");
        Serial.println(MYSENSORS_LIBRARY_VERSION);
        Serial.print("GateWay sketch version : ");
        Serial.println(SKETCH_VERSION);
        Serial.println("----------------------------------");
        Serial.println();
      }
      if (testSha204()) {
        digitalWrite(LED_GREEN, HIGH);
        tests++;
      }
      if (testSDCard()) {
        digitalWrite(LED_YELLOW, HIGH);
        tests++;
      }
    
      if (testEEProm()) {
        digitalWrite(LED_ORANGE, HIGH);
        tests++;
      }
      if (testAnalog()) {
        digitalWrite(LED_BLUE, HIGH);
        tests++;
      }
      if (tests == 4) {
        while(1) {
          for (int i=0; i<num_of_leds; i++) {
            digitalWrite(leds[i], HIGH);
            delay(200);
            digitalWrite(leds[i], LOW);
          }
        }
      } else {
        while (1) {
          digitalWrite(LED_RED, HIGH);
          delay(200);
          digitalWrite(LED_RED, LOW);
          delay(200);
        }
      }
    
    }
    
    bool testSha204()
    {
      uint8_t rx_buffer[SHA204_RSP_SIZE_MAX];
      uint8_t ret_code;
      if (Serial) {
        Serial.print("- > SHA204 ");
      }
      atsha204_init(MY_SIGNING_ATSHA204_PIN);
      ret_code = atsha204_wakeup(rx_buffer);
    
      if (ret_code == SHA204_SUCCESS) {
        ret_code = atsha204_getSerialNumber(rx_buffer);
        if (ret_code != SHA204_SUCCESS) {
          if (Serial) {
            Serial.println(F("Failed to obtain device serial number. Response: "));
          }
          Serial.println(ret_code, HEX);
        } else {
          if (Serial) {
            Serial.print(F("Ok (serial : "));
            for (int i=0; i<9; i++) {
              if (rx_buffer[i] < 0x10) {
                Serial.print('0'); // Because Serial.print does not 0-pad HEX
              }
              Serial.print(rx_buffer[i], HEX);
            }
            Serial.println(")");
          }
          return true;
        }
      } else {
        if (Serial) {
          Serial.println(F("Failed to wakeup SHA204"));
        }
      }
      return false;
    }
    
    bool testSDCard()
    {
      if (Serial) {
        Serial.print("- > SD CARD ");
      }
      if (!card.init(SPI_HALF_SPEED, MY_SDCARD_CS)) {
        if (Serial) {
          Serial.println("SD CARD did not initialize!");
        }
      } else {
        if (Serial) {
          Serial.print("SD Card initialized correct! - ");
          Serial.print("type detected : ");
          switch(card.type()) {
          case SD_CARD_TYPE_SD1:
            Serial.println("SD1");
            break;
          case SD_CARD_TYPE_SD2:
            Serial.println("SD2");
            break;
          case SD_CARD_TYPE_SDHC:
            Serial.println("SDHC");
            break;
          default:
            Serial.println("Unknown");
          }
        }
        return true;
      }
      return false;
    }
    
    bool testEEProm()
    {
      uint8_t eeprom_d1, eeprom_d2;
      SerialUSB.print(" -> EEPROM ");
      Wire.begin();
      eeprom_d1 = i2c_eeprom_read_byte(EEPROM_VERIFICATION_ADDRESS);
      delay(500);
      eeprom_d1 = ~eeprom_d1; // invert the bits
      i2c_eeprom_write_byte(EEPROM_VERIFICATION_ADDRESS, eeprom_d1);
      delay(500);
      eeprom_d2 = i2c_eeprom_read_byte(EEPROM_VERIFICATION_ADDRESS);
      if (eeprom_d1 == eeprom_d2) {
        SerialUSB.println("PASSED");
        i2c_eeprom_write_byte(EEPROM_VERIFICATION_ADDRESS, ~eeprom_d1);
        return true;
      }
      SerialUSB.println("FAILED!");
      return false;
    }
    
    bool testAnalog()
    {
      int bat_detect = analogRead(MY_BAT_DETECT);
      Serial.print("-> analog : ");
      Serial.print(bat_detect);
      if (bat_detect < 400 || bat_detect > 650) {
        Serial.println(" Failed");
        return false;
      }
      Serial.println(" Passed");
      return true;
    }
    


  • and on the node this sketch:

    /*
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2015 Sensnology AB
     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     */
    #include <stdint.h>
    #include <pins_arduino.h>
    #define MY_DEBUG
    #define MY_DEBUG_VERBOSE_SIGNING
    #define MY_RADIO_NRF24
    //#define MY_SIGNING_SOFT
    #define MY_SIGNING_ATSHA204
    //#define MY_SIGNING_NODE_WHITELISTING {{.nodeId = GATEWAY_ADDRESS,.serial = {0x09,0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01}}}
    #define MY_SIGNING_REQUEST_SIGNATURES
    #ifndef MY_SIGNING_SOFT_RANDOMSEED_PIN
    #define MY_SIGNING_SOFT_RANDOMSEED_PIN 7
    #endif
    #ifndef MY_SIGNING_ATSHA204_PIN
    #define MY_SIGNING_ATSHA204_PIN 17
    #endif
    #define MY_RF24_ENABLE_ENCRYPTION
    #include <MySensors.h>
    

    But the node does not connect and i get this on the serial monitor:

    0 MCO:BGN:INIT NODE,CP=RNNNAA-,VER=2.1.1
    4 TSM:INIT
    4 TSF:WUR:MS=0
    12 TSM:INIT:TSP OK
    14 TSF:SID:OK,ID=100
    16 TSM:FPAR
    18 Will not sign message for destination 255 as it does not require it
    67 TSF:MSG:SEND,100-100-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    2076 !TSM:FPAR:NO REPLY
    2078 TSM:FPAR
    2080 Will not sign message for destination 255 as it does not require it
    2127 TSF:MSG:SEND,100-100-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    4139 !TSM:FPAR:NO REPLY
    4141 TSM:FPAR
    4143 Will not sign message for destination 255 as it does not require it
    4190 TSF:MSG:SEND,100-100-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    6199 !TSM:FPAR:NO REPLY
    6201 TSM:FPAR
    6203 Will not sign message for destination 255 as it does not require it
    6250 TSF:MSG:SEND,100-100-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    8259 !TSM:FPAR:FAIL
    8261 TSM:FAIL:CNT=1
    8263 TSM:FAIL:PDT
    18266 TSM:FAIL:RE-INIT
    18268 TSM:INIT
    18276 TSM:INIT:TSP OK
    18278 TSF:SID:OK,ID=100
    18280 TSM:FPAR
    18282 Will not sign message for destination 255 as it does not require it
    18331 TSF:MSG:SEND,100-100-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    20340 !TSM:FPAR:NO REPLY
    20342 TSM:FPAR
    20344 Will not sign message for destination 255 as it does not require it
    20393 TSF:MSG:SEND,100-100-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    22403 !TSM:FPAR:NO REPLY
    22405 TSM:FPAR
    22407 Will not sign message for destination 255 as it does not require it
    22456 TSF:MSG:SEND,100-100-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    24465 !TSM:FPAR:NO REPLY
    24467 TSM:FPAR
    24469 Will not sign message for destination 255 as it does not require it
    24518 TSF:MSG:SEND,100-100-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    26527 !TSM:FPAR:FAIL
    26529 TSM:FAIL:CNT=2
    26531 TSM:FAIL:PDT
    36534 TSM:FAIL:RE-INIT
    36536 TSM:INIT
    36544 TSM:INIT:TSP OK
    36546 TSF:SID:OK,ID=100
    36548 TSM:FPAR
    36550 Will not sign message for destination 255 as it does not require it
    36599 TSF:MSG:SEND,100-100-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    38610 !TSM:FPAR:NO REPLY
    38612 TSM:FPAR
    38615 Will not sign message for destination 255 as it does not require it
    38664 TSF:MSG:SEND,100-100-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    40673 !TSM:FPAR:NO REPLY
    40675 TSM:FPAR
    40677 Will not sign message for destination 255 as it does not require it
    40726 TSF:MSG:SEND,100-100-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    42735 !TSM:FPAR:NO REPLY
    42737 TSM:FPAR
    42739 Will not sign message for destination 255 as it does not require it
    42788 TSF:MSG:SEND,100-100-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    44800 !TSM:FPAR:FAIL
    44802 TSM:FAIL:CNT=3
    44804 TSM:FAIL:PDT
    54808 TSM:FAIL:RE-INIT
    54810 TSM:INIT
    54818 TSM:INIT:TSP OK
    54820 TSF:SID:OK,ID=100
    54822 TSM:FPAR
    54824 Will not sign message for destination 255 as it does not require it
    54874 TSF:MSG:SEND,100-100-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    56883 !TSM:FPAR:NO REPLY
    56885 TSM:FPAR
    56887 Will not sign message for destination 255 as it does not require it
    56936 TSF:MSG:SEND,100-100-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    

    please help me once again
    Thank you


  • Contest Winner

    @meddie if you want your node to sign messages to the gateway you have to tell the gateway to require it. The log says that it does not require it and it is clear from your gateway sketch that you have disabled the requirement.
    Is that your problem?
    EDIT: I see that the messages are broadcasts, those will never be signed. So the "will not sign messages" are perfectly normal no matter how you configure your gateway in this case.
    The problem, at least based on the node log is that your node cannot find a parent to communicate with for some reason.


  • Contest Winner

    @meddie for parsing the log file you can use this tool


  • Contest Winner

    @meddie I also see that you fail to find parent. Have you verified that you had working node-gateway communication before you enabled signing?



  • @Anticimex
    Hi, i have just uploaded the GatewayW5100 Sketch to the Gateway and the HumidtyTemp Sketch to the Node and it works fine, but without signing and encryption.


  • Contest Winner

    @meddie You had encryption enabled when it failed? That could explain the failure of the broadcast if you did not have a matching setting between the nodes/gateway.



  • @Anticimex
    yes the encryption was enabled. Should i upload the personalized sketch again with my keys?


  • Contest Winner

    @meddie You can just run an unmodified personalizer to have it read the EEPROM contents. That way you can verify that all devices share the exact same AES key. Assuming a mismatch in the AES key was the reason for the problem.
    But I strongly encourage you to just enable one security feature at a time if you are not sure what you are doing or it will be hard to debug what is going wrong.



  • @Anticimex
    yes, i try to activate one feature and when it works the next. So i decided to activate the encryption and then when it works then i try to activate the signing. But first i would to check the keys like you said and when i now upload the securitypersonalization sketch unmodified i dont get any output on the serial monitor.
    😞


  • Contest Winner

    @meddie Well, you have to make the patch to the baud rate and the changes we discussed earlier. I presume you did something necessary since you got output previously.



  • @Anticimex
    when i run the personalizer sketch i see in all keys FFFFFF....... What does it mean that no keys are stored?


  • Contest Winner

    @meddie yes, that mean eeprom is in default state. The node has not been properly personalized.



  • @Anticimex
    ok, i think i know what went wrong! But i dont know how to fix it. On the first run when i tried came the prompt to sens space to lock configuration i did it.
    Now when i upload the modified personalization sketch with my keys i get this output on serial monitor:
    of course i removed my keys with xx!

    Device serial:   {0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX}
    xxxxxxxxxxxxxxxxxxxxx
    Skipping configuration write and lock (configuration already locked).
    Chip configuration:
    EEPROM DATA:
    SOFT_HMAC_KEY | FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
    SOFT_SERIAL   | FFFFFFFFFFFFFFFFFF
    AES_KEY       | XXFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
    ATSHA204A DATA:
               SN[0:1]           |         SN[2:3]           | XX   XX | XX   XX   
                              Revnum                         | 00   09   04   00   
                              SN[4:7]                        | XX   XX   XX   XX   
        SN[8]    |  Reserved13   | I2CEnable | Reserved15    | EE | 10 | 00 | 00   
      I2CAddress |  TempOffset   |  OTPmode  | SelectorMode  | C8 | 00 | 55 | 00   
             SlotConfig00        |       SlotConfig01        | 8F   80 | 80   A1   
             SlotConfig02        |       SlotConfig03        | 82   E0 | A3   60   
             SlotConfig04        |       SlotConfig05        | 94   40 | A0   85   
             SlotConfig06        |       SlotConfig07        | 86   40 | 87   07   
             SlotConfig08        |       SlotConfig09        | 0F   00 | 89   F2   
             SlotConfig0A        |       SlotConfig0B        | 8A   7A | 0B   8B   
             SlotConfig0C        |       SlotConfig0D        | 0C   4C | DD   4D   
             SlotConfig0E        |       SlotConfig0F        | C2   42 | AF   8F   
      UseFlag00  | UpdateCount00 | UseFlag01 | UpdateCount01 | FF | 00 | FF | 00   
      UseFlag02  | UpdateCount02 | UseFlag03 | UpdateCount03 | FF | 00 | FF | 00   
      UseFlag04  | UpdateCount04 | UseFlag05 | UpdateCount05 | FF | 00 | FF | 00   
      UseFlag06  | UpdateCount06 | UseFlag07 | UpdateCount07 | FF | 00 | FF | 00   
                          LastKeyUse[0:3]                    | FF   FF   FF   FF   
                          LastKeyUse[4:7]                    | FF   FF   FF   FF   
                          LastKeyUse[8:B]                    | FF   FF   FF   FF   
                          LastKeyUse[C:F]                    | FF   FF   FF   FF   
      UserExtra  |    Selector   | LockValue |  LockConfig   | 00 | 00 | 55 | 00   
    Using this user supplied HMAC key:
    #define MY_HMAC_KEY 0xxx,0xxx,0xxx,0xxx,0xxx,0xxx,0xxx,0xxx,0xxx,0xxx,0xxx,0xxx,0xxx,0xxx,0xxx,0xxx,\
                        0xxx,0xxx,0xxx,0xxx,0xxx,0xxx,0xxx,0xxx,0xxx,0xxx,0xxx,0xxx,0xxx,0xxx,0xxx,0xxx
    Writing key to slot 0...
    Data not locked. Define LOCK_DATA to lock for real.
    --------------------------------
    Personalization is now complete.
    Configuration is LOCKED
    Data is UNLOCKED
    

    i thin this is the reason:

    Skipping configuration write and lock (configuration already locked).
    

    and what i find very interestin that the first two signs of AES Key are correct the rest of them are FFFFF

    AES_KEY       | XXFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
    

    is it possible to unlock the configuration or did i kill the chip?
    Thank you
    Greets Eddie


  • Contest Winner

    @meddie you cannot undo a lock, and you have to lock the chip in order to use it. And it is not an error that it reports chip is already locked since you have locked it already.
    Furthermore, AES key and eeprom has nothing to do with the atsha204a chip so the lock state of the chip is irrelevant.
    Now, why your AES key is only partially stored, I am not sure. But my bet would be that you have an error in the line where you define it in the sketch. A space or something like that.
    Finally, as long as you don't lock the data zone, and you don't tamper with the configuration bits for the atsha204a device, you cannot destroy the chip. You can always replace the hmac key, which is the only thing you program to the atsha using the personalizer. Except for the chip configuration bits, and those the sketch handles for you and once config is locked they are fixed in place.



  • @Anticimex
    i checked the sketch already few times but i dont see an error.
    here is the code i have only change my key with XX

    
    
    #include "sha204_library.h"
    #include "sha204_lib_return_codes.h"
    #define MY_CORE_ONLY
    #include <MySensors.h>
    
    #if DOXYGEN
    #define LOCK_CONFIGURATION
    #define LOCK_DATA
    #define SKIP_KEY_STORAGE
    #define USER_KEY
    #define SKIP_UART_CONFIRMATION
    #define USE_SOFT_SIGNING
    #define STORE_SOFT_KEY
    #define USER_SOFT_KEY
    #define STORE_SOFT_SERIAL
    #define USER_SOFT_SERIAL
    #define STORE_AES_KEY
    #define USER_AES_KEY
    #endif
    
    #define LOCK_CONFIGURATION
    
    //#define LOCK_DATA
    
    //#define SKIP_KEY_STORAGE
    
    #define USER_KEY
    
    //#define SKIP_UART_CONFIRMATION
    
    //#define USE_SOFT_SIGNING
    
    //#define STORE_SOFT_KEY
    
    //#define USER_SOFT_KEY
    
    //#define STORE_SOFT_SERIAL
    
    //#define USER_SOFT_SERIAL
    
    #define STORE_AES_KEY
    
    #define USER_AES_KEY
    
    #if defined(SKIP_UART_CONFIRMATION) && !defined(USER_KEY)
    #error You have to define USER_KEY for boards that does not have UART
    #endif
    
    #ifdef USER_KEY
    /** @brief The user-defined HMAC key to use for personalization */
    #define MY_HMAC_KEY 0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX
    /** @brief The data to store in key slot 0 */
    const uint8_t user_key_data[32] = {MY_HMAC_KEY};
    #endif
    
    #ifdef USER_SOFT_KEY
    /** @brief The user-defined soft HMAC key to use for EEPROM personalization */
    #define MY_SOFT_HMAC_KEY 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
    /** @brief The data to store as soft HMAC key in EEPROM */
    const uint8_t user_soft_key_data[32] = {MY_SOFT_HMAC_KEY};
    #endif
    
    #ifdef USER_SOFT_SERIAL
    /** @brief The user-defined soft serial to use for EEPROM personalization */
    #define MY_SOFT_SERIAL 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
    /** @brief The data to store as soft serial in EEPROM */
    const uint8_t user_soft_serial[9] = {MY_SOFT_SERIAL};
    #endif
    
    #ifdef USER_AES_KEY
    /** @brief The user-defined AES key to use for EEPROM personalization */
    #define MY_AES_KEY 0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX,0xXX
    /** @brief The data to store as AES key in EEPROM */
    const uint8_t user_aes_key[16] = {MY_AES_KEY};
    #endif
    
    #ifndef USE_SOFT_SIGNING
    const int sha204Pin = MY_SIGNING_ATSHA204_PIN; //!< The IO pin to use for ATSHA204A
    atsha204Class sha204(sha204Pin);
    #endif
    
    /** @brief Print a error notice and halt the execution */
    void halt()
    {
    	Serial.println(F("Halting!"));
    	while(1);
    }
    
    #ifndef USE_SOFT_SIGNING
    
    uint16_t write_config_and_get_crc()
    {
    	uint16_t crc = 0;
    	uint8_t config_word[4];
    	uint8_t tx_buffer[SHA204_CMD_SIZE_MAX];
    	uint8_t rx_buffer[SHA204_RSP_SIZE_MAX];
    	uint8_t ret_code;
    	bool do_write;
    
    	for (int i=0; i < 88; i += 4) {
    		do_write = true;
    		if (i == 20) {
    			config_word[0] = 0x8F;
    			config_word[1] = 0x80;
    			config_word[2] = 0x80;
    			config_word[3] = 0xA1;
    		} else if (i == 24) {
    			config_word[0] = 0x82;
    			config_word[1] = 0xE0;
    			config_word[2] = 0xA3;
    			config_word[3] = 0x60;
    		} else if (i == 28) {
    			config_word[0] = 0x94;
    			config_word[1] = 0x40;
    			config_word[2] = 0xA0;
    			config_word[3] = 0x85;
    		} else if (i == 32) {
    			config_word[0] = 0x86;
    			config_word[1] = 0x40;
    			config_word[2] = 0x87;
    			config_word[3] = 0x07;
    		} else if (i == 36) {
    			config_word[0] = 0x0F;
    			config_word[1] = 0x00;
    			config_word[2] = 0x89;
    			config_word[3] = 0xF2;
    		} else if (i == 40) {
    			config_word[0] = 0x8A;
    			config_word[1] = 0x7A;
    			config_word[2] = 0x0B;
    			config_word[3] = 0x8B;
    		} else if (i == 44) {
    			config_word[0] = 0x0C;
    			config_word[1] = 0x4C;
    			config_word[2] = 0xDD;
    			config_word[3] = 0x4D;
    		} else if (i == 48) {
    			config_word[0] = 0xC2;
    			config_word[1] = 0x42;
    			config_word[2] = 0xAF;
    			config_word[3] = 0x8F;
    		} else if (i == 52 || i == 56 || i == 60 || i == 64) {
    			config_word[0] = 0xFF;
    			config_word[1] = 0x00;
    			config_word[2] = 0xFF;
    			config_word[3] = 0x00;
    		} else if (i == 68 || i == 72 || i == 76 || i == 80) {
    			config_word[0] = 0xFF;
    			config_word[1] = 0xFF;
    			config_word[2] = 0xFF;
    			config_word[3] = 0xFF;
    		} else {
    			// All other configs are untouched
    			ret_code = sha204.sha204m_read(tx_buffer, rx_buffer, SHA204_ZONE_CONFIG, i);
    			if (ret_code != SHA204_SUCCESS) {
    				Serial.print(F("Failed to read config. Response: "));
    				Serial.println(ret_code, HEX);
    				halt();
    			}
    			// Set config_word to the read data
    			config_word[0] = rx_buffer[SHA204_BUFFER_POS_DATA+0];
    			config_word[1] = rx_buffer[SHA204_BUFFER_POS_DATA+1];
    			config_word[2] = rx_buffer[SHA204_BUFFER_POS_DATA+2];
    			config_word[3] = rx_buffer[SHA204_BUFFER_POS_DATA+3];
    			do_write = false;
    		}
    
    		// Update crc with CRC for the current word
    		crc = sha204.calculateAndUpdateCrc(4, config_word, crc);
    
    		// Write config word
    		if (do_write) {
    			ret_code = sha204.sha204m_execute(SHA204_WRITE, SHA204_ZONE_CONFIG,
    			                                  i >> 2, 4, config_word, 0, NULL, 0, NULL,
    			                                  WRITE_COUNT_SHORT, tx_buffer, WRITE_RSP_SIZE, rx_buffer);
    			if (ret_code != SHA204_SUCCESS) {
    				Serial.print(F("Failed to write config word at address "));
    				Serial.print(i);
    				Serial.print(F(". Response: "));
    				Serial.println(ret_code, HEX);
    				halt();
    			}
    		}
    	}
    	return crc;
    }
    
    /**
     * @brief Write provided key to slot 0
     * @param key The key data to write
     */
    void write_key(uint8_t* key)
    {
    	uint8_t tx_buffer[SHA204_CMD_SIZE_MAX];
    	uint8_t rx_buffer[SHA204_RSP_SIZE_MAX];
    	uint8_t ret_code;
    
    	// Write key to slot 0
    	ret_code = sha204.sha204m_execute(SHA204_WRITE, SHA204_ZONE_DATA | SHA204_ZONE_COUNT_FLAG,
    	                                  0, SHA204_ZONE_ACCESS_32, key, 0, NULL, 0, NULL,
    	                                  WRITE_COUNT_LONG, tx_buffer, WRITE_RSP_SIZE, rx_buffer);
    	if (ret_code != SHA204_SUCCESS) {
    		Serial.print(F("Failed to write key to slot 0. Response: "));
    		Serial.println(ret_code, HEX);
    		halt();
    	}
    }
    #endif // not USE_SOFT_SIGNING
    
    /** @brief Dump current configuration to UART */
    void dump_configuration()
    {
    	uint8_t buffer[32];
    #ifndef USE_SOFT_SIGNING
    	Serial.println(F("EEPROM DATA:"));
    #endif
    	hwReadConfigBlock((void*)buffer, (void*)EEPROM_SIGNING_SOFT_HMAC_KEY_ADDRESS, 32);
    	Serial.print(F("SOFT_HMAC_KEY | "));
    	for (int j=0; j<32; j++) {
    		if (buffer[j] < 0x10) {
    			Serial.print('0'); // Because Serial.print does not 0-pad HEX
    		}
    		Serial.print(buffer[j], HEX);
    	}
    	Serial.println();
    	hwReadConfigBlock((void*)buffer, (void*)EEPROM_SIGNING_SOFT_SERIAL_ADDRESS, 9);
    	Serial.print(F("SOFT_SERIAL   | "));
    	for (int j=0; j<9; j++) {
    		if (buffer[j] < 0x10) {
    			Serial.print('0'); // Because Serial.print does not 0-pad HEX
    		}
    		Serial.print(buffer[j], HEX);
    	}
    	Serial.println();
    	hwReadConfigBlock((void*)buffer, (void*)EEPROM_RF_ENCRYPTION_AES_KEY_ADDRESS, 16);
    	Serial.print(F("AES_KEY       | "));
    	for (int j=0; j<16; j++) {
    		if (buffer[j] < 0x10) {
    			Serial.print('0'); // Because Serial.print does not 0-pad HEX
    		}
    		Serial.print(buffer[j], HEX);
    	}
    	Serial.println();
    #ifndef USE_SOFT_SIGNING
    	uint8_t tx_buffer[SHA204_CMD_SIZE_MAX];
    	uint8_t rx_buffer[SHA204_RSP_SIZE_MAX];
    	uint8_t ret_code;
    	Serial.println(F("ATSHA204A DATA:"));
    	for (int i=0; i < 88; i += 4) {
    		ret_code = sha204.sha204m_read(tx_buffer, rx_buffer, SHA204_ZONE_CONFIG, i);
    		if (ret_code != SHA204_SUCCESS) {
    			Serial.print(F("Failed to read config. Response: "));
    			Serial.println(ret_code, HEX);
    			halt();
    		}
    		if (i == 0x00) {
    			Serial.print(F("           SN[0:1]           |         SN[2:3]           | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j == 1) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x04) {
    			Serial.print(F("                          Revnum                         | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				Serial.print(F("   "));
    			}
    			Serial.println();
    		} else if (i == 0x08) {
    			Serial.print(F("                          SN[4:7]                        | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				Serial.print(F("   "));
    			}
    			Serial.println();
    		} else if (i == 0x0C) {
    			Serial.print(F("    SN[8]    |  Reserved13   | I2CEnable | Reserved15    | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j < 3) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x10) {
    			Serial.print(F("  I2CAddress |  TempOffset   |  OTPmode  | SelectorMode  | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j < 3) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x14) {
    			Serial.print(F("         SlotConfig00        |       SlotConfig01        | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j == 1) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x18) {
    			Serial.print(F("         SlotConfig02        |       SlotConfig03        | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j == 1) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x1C) {
    			Serial.print(F("         SlotConfig04        |       SlotConfig05        | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j == 1) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x20) {
    			Serial.print(F("         SlotConfig06        |       SlotConfig07        | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j == 1) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x24) {
    			Serial.print(F("         SlotConfig08        |       SlotConfig09        | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j == 1) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x28) {
    			Serial.print(F("         SlotConfig0A        |       SlotConfig0B        | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j == 1) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x2C) {
    			Serial.print(F("         SlotConfig0C        |       SlotConfig0D        | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j == 1) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x30) {
    			Serial.print(F("         SlotConfig0E        |       SlotConfig0F        | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j == 1) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x34) {
    			Serial.print(F("  UseFlag00  | UpdateCount00 | UseFlag01 | UpdateCount01 | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j < 3) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x38) {
    			Serial.print(F("  UseFlag02  | UpdateCount02 | UseFlag03 | UpdateCount03 | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j < 3) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x3C) {
    			Serial.print(F("  UseFlag04  | UpdateCount04 | UseFlag05 | UpdateCount05 | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j < 3) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x40) {
    			Serial.print(F("  UseFlag06  | UpdateCount06 | UseFlag07 | UpdateCount07 | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j < 3) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x44) {
    			Serial.print(F("                      LastKeyUse[0:3]                    | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				Serial.print(F("   "));
    			}
    			Serial.println();
    		} else if (i == 0x48) {
    			Serial.print(F("                      LastKeyUse[4:7]                    | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				Serial.print(F("   "));
    			}
    			Serial.println();
    		} else if (i == 0x4C) {
    			Serial.print(F("                      LastKeyUse[8:B]                    | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				Serial.print(F("   "));
    			}
    			Serial.println();
    		} else if (i == 0x50) {
    			Serial.print(F("                      LastKeyUse[C:F]                    | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				Serial.print(F("   "));
    			}
    			Serial.println();
    		} else if (i == 0x54) {
    			Serial.print(F("  UserExtra  |    Selector   | LockValue |  LockConfig   | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j < 3) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		}
    	}
    #endif // not USE_SOFT_SIGNING
    }
    
    /** @brief Sketch setup code */
    void setup()
    {
    	// Delay startup a bit for serial consoles to catch up
    	unsigned long enter = hwMillis();
    	while (hwMillis() - enter < (unsigned long)500);
    #ifndef USE_SOFT_SIGNING
    	uint8_t tx_buffer[SHA204_CMD_SIZE_MAX];
    	uint8_t rx_buffer[SHA204_RSP_SIZE_MAX];
    	uint8_t ret_code;
    	uint8_t lockConfig = 0;
    	uint8_t lockValue = 0;
    	uint16_t crc;
    	(void)crc;
    #else
    	// initialize pseudo-RNG
    	randomSeed(analogRead(MY_SIGNING_SOFT_RANDOMSEED_PIN));
    #endif
    	uint8_t key[32];
    	(void)key;
    
      Serial.begin(9600);
    	hwInit();
    	Serial.println(F("Personalization sketch for MySensors usage."));
    	Serial.println(F("-------------------------------------------"));
    
    #ifndef USE_SOFT_SIGNING
    	// Wake device before starting operations
    	ret_code = sha204.sha204c_wakeup(rx_buffer);
    	if (ret_code != SHA204_SUCCESS) {
    		Serial.print(F("Failed to wake device. Response: "));
    		Serial.println(ret_code, HEX);
    		halt();
    	}
    	// Read out lock config bits to determine if locking is possible
    	ret_code = sha204.sha204m_read(tx_buffer, rx_buffer, SHA204_ZONE_CONFIG, 0x15<<2);
    	if (ret_code != SHA204_SUCCESS) {
    		Serial.print(F("Failed to determine device lock status. Response: "));
    		Serial.println(ret_code, HEX);
    		halt();
    	} else {
    		lockConfig = rx_buffer[SHA204_BUFFER_POS_DATA+3];
    		lockValue = rx_buffer[SHA204_BUFFER_POS_DATA+2];
    	}
    #endif
    
    #ifdef STORE_SOFT_KEY
    #ifdef USER_SOFT_KEY
    	memcpy(key, user_soft_key_data, 32);
    	Serial.println(F("Using this user supplied soft HMAC key:"));
    #else
    	// Retrieve random value to use as soft HMAC key
    #ifdef USE_SOFT_SIGNING
    	for (int i = 0; i < 32; i++) {
    		key[i] = random(256) ^ micros();
    		unsigned long enter = hwMillis();
    		while (hwMillis() - enter < (unsigned long)2);
    	}
    	Serial.println(F("This value will be stored in EEPROM as soft HMAC key:"));
    #else
    	ret_code = sha204.sha204m_random(tx_buffer, rx_buffer, RANDOM_SEED_UPDATE);
    	if (ret_code != SHA204_SUCCESS) {
    		Serial.print(F("Random key generation failed. Response: "));
    		Serial.println(ret_code, HEX);
    		halt();
    	} else {
    		memcpy(key, rx_buffer+SHA204_BUFFER_POS_DATA, 32);
    	}
    	if (lockConfig == 0x00) {
    		Serial.println(F("This value will be stored in EEPROM as soft HMAC key:"));
    	} else {
    		Serial.println(F("Key is not randomized (configuration not locked):"));
    	}
    #endif // not USE_SOFT_SIGNING
    #endif // not USER_SOFT_KEY
    	Serial.print("#define MY_SOFT_HMAC_KEY ");
    	for (int i=0; i<32; i++) {
    		Serial.print("0x");
    		if (key[i] < 0x10) {
    			Serial.print('0'); // Because Serial.print does not 0-pad HEX
    		}
    		Serial.print(key[i], HEX);
    		if (i < 31) {
    			Serial.print(',');
    		}
    	}
    	Serial.println();
    	hwWriteConfigBlock((void*)key, (void*)EEPROM_SIGNING_SOFT_HMAC_KEY_ADDRESS, 32);
    #endif // STORE_SOFT_KEY
    
    #ifdef STORE_SOFT_SERIAL
    #ifdef USER_SOFT_SERIAL
    	memcpy(key, user_soft_serial, 9);
    	Serial.println(F("Using this user supplied soft serial:"));
    #else
    	// Retrieve random value to use as serial
    #ifdef USE_SOFT_SIGNING
    	for (int i = 0; i < 9; i++) {
    		key[i] = random(256) ^ micros();
    		unsigned long enter = hwMillis();
    		while (hwMillis() - enter < (unsigned long)2);
    	}
    	Serial.println(F("This value will be stored in EEPROM as soft serial:"));
    #else
    	ret_code = sha204.sha204m_random(tx_buffer, rx_buffer, RANDOM_SEED_UPDATE);
    	if (ret_code != SHA204_SUCCESS) {
    		Serial.print(F("Random serial generation failed. Response: "));
    		Serial.println(ret_code, HEX);
    		halt();
    	} else {
    		memcpy(key, rx_buffer+SHA204_BUFFER_POS_DATA, 9);
    	}
    	if (lockConfig == 0x00) {
    		Serial.println(F("This value will be stored in EEPROM as soft serial:"));
    	} else {
    		Serial.println(F("Serial is not randomized (configuration not locked):"));
    	}
    #endif // not USE_SOFT_SIGNING
    #endif // not USER_SOFT_SERIAL
    	Serial.print("#define MY_SOFT_SERIAL ");
    	for (int i=0; i<9; i++) {
    		Serial.print("0x");
    		if (key[i] < 0x10) {
    			Serial.print('0'); // Because Serial.print does not 0-pad HEX
    		}
    		Serial.print(key[i], HEX);
    		if (i < 8) {
    			Serial.print(',');
    		}
    	}
    	Serial.println();
    	hwWriteConfigBlock((void*)key, (void*)EEPROM_SIGNING_SOFT_SERIAL_ADDRESS, 9);
    #endif // STORE_SOFT_SERIAL
    
    #ifdef STORE_AES_KEY
    #ifdef USER_AES_KEY
    	memcpy(key, user_aes_key, 16);
    	Serial.println(F("Using this user supplied AES key:"));
    #else
    	// Retrieve random value to use as key
    #ifdef USE_SOFT_SIGNING
    	for (int i = 0; i < 16; i++) {
    		key[i] = random(256) ^ micros();
    		unsigned long enter = hwMillis();
    		while (hwMillis() - enter < (unsigned long)2);
    	}
    	Serial.println(F("This key will be stored in EEPROM as AES key:"));
    #else
    	ret_code = sha204.sha204m_random(tx_buffer, rx_buffer, RANDOM_SEED_UPDATE);
    	if (ret_code != SHA204_SUCCESS) {
    		Serial.print(F("Random key generation failed. Response: "));
    		Serial.println(ret_code, HEX);
    		halt();
    	} else {
    		memcpy(key, rx_buffer+SHA204_BUFFER_POS_DATA, 32);
    	}
    	if (lockConfig == 0x00) {
    		Serial.println(F("This key will be stored in EEPROM as AES key:"));
    	} else {
    		Serial.println(F("Key is not randomized (configuration not locked):"));
    	}
    #endif // not USE_SOFT_SIGNING
    #endif // not USER_AES_KEY
    	Serial.print("#define MY_AES_KEY ");
    	for (int i=0; i<16; i++) {
    		Serial.print("0x");
    		if (key[i] < 0x10) {
    			Serial.print('0'); // Because Serial.print does not 0-pad HEX
    		}
    		Serial.print(key[i], HEX);
    		if (i < 15) {
    			Serial.print(',');
    		}
    	}
    	Serial.println();
    	hwWriteConfigBlock((void*)key, (void*)EEPROM_RF_ENCRYPTION_AES_KEY_ADDRESS, 16);
    #endif // STORE_AES_KEY
    
    #ifdef USE_SOFT_SIGNING
    	Serial.println(F("EEPROM configuration:"));
    	dump_configuration();
    #else
    	// Output device revision on console
    	ret_code = sha204.sha204m_dev_rev(tx_buffer, rx_buffer);
    	if (ret_code != SHA204_SUCCESS) {
    		Serial.print(F("Failed to determine device revision. Response: "));
    		Serial.println(ret_code, HEX);
    		halt();
    	} else {
    		Serial.print(F("Device revision: "));
    		for (int i=0; i<4; i++) {
    			if (rx_buffer[SHA204_BUFFER_POS_DATA+i] < 0x10) {
    				Serial.print('0'); // Because Serial.print does not 0-pad HEX
    			}
    			Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+i], HEX);
    		}
    		Serial.println();
    	}
    
    	// Output serial number on console
    	ret_code = sha204.getSerialNumber(rx_buffer);
    	if (ret_code != SHA204_SUCCESS) {
    		Serial.print(F("Failed to obtain device serial number. Response: "));
    		Serial.println(ret_code, HEX);
    		halt();
    	} else {
    		Serial.print(F("Device serial:   "));
    		Serial.print('{');
    		for (int i=0; i<9; i++) {
    			Serial.print(F("0x"));
    			if (rx_buffer[i] < 0x10) {
    				Serial.print('0'); // Because Serial.print does not 0-pad HEX
    			}
    			Serial.print(rx_buffer[i], HEX);
    			if (i < 8) {
    				Serial.print(',');
    			}
    		}
    		Serial.print('}');
    		Serial.println();
    		for (int i=0; i<9; i++) {
    			if (rx_buffer[i] < 0x10) {
    				Serial.print('0'); // Because Serial.print does not 0-pad HEX
    			}
    			Serial.print(rx_buffer[i], HEX);
    		}
    		Serial.println();
    	}
    
    	if (lockConfig != 0x00) {
    		// Write config and get CRC for the updated config
    		crc = write_config_and_get_crc();
    
    		// List current configuration before attempting to lock
    		Serial.println(F("Chip configuration:"));
    		dump_configuration();
    
    #ifdef LOCK_CONFIGURATION
    		// Purge serial input buffer
    #ifndef SKIP_UART_CONFIRMATION
    		while (Serial.available()) {
    			Serial.read();
    		}
    		Serial.println(F("Send SPACE character now to lock the configuration..."));
    
    		while (Serial.available() == 0);
    		if (Serial.read() == ' ')
    #endif //not SKIP_UART_CONFIRMATION
    		{
    			Serial.println(F("Locking configuration..."));
    
    			// Correct sequence, resync chip
    			ret_code = sha204.sha204c_resync(SHA204_RSP_SIZE_MAX, rx_buffer);
    			if (ret_code != SHA204_SUCCESS && ret_code != SHA204_RESYNC_WITH_WAKEUP) {
    				Serial.print(F("Resync failed. Response: "));
    				Serial.println(ret_code, HEX);
    				halt();
    			}
    
    			// Lock configuration zone
    			ret_code = sha204.sha204m_execute(SHA204_LOCK, SHA204_ZONE_CONFIG,
    			                                  crc, 0, NULL, 0, NULL, 0, NULL,
    			                                  LOCK_COUNT, tx_buffer, LOCK_RSP_SIZE, rx_buffer);
    			if (ret_code != SHA204_SUCCESS) {
    				Serial.print(F("Configuration lock failed. Response: "));
    				Serial.println(ret_code, HEX);
    				halt();
    			} else {
    				Serial.println(F("Configuration locked."));
    
    				// Update lock flags after locking
    				ret_code = sha204.sha204m_read(tx_buffer, rx_buffer, SHA204_ZONE_CONFIG, 0x15<<2);
    				if (ret_code != SHA204_SUCCESS) {
    					Serial.print(F("Failed to determine device lock status. Response: "));
    					Serial.println(ret_code, HEX);
    					halt();
    				} else {
    					lockConfig = rx_buffer[SHA204_BUFFER_POS_DATA+3];
    					lockValue = rx_buffer[SHA204_BUFFER_POS_DATA+2];
    				}
    			}
    		}
    #ifndef SKIP_UART_CONFIRMATION
    		else {
    			Serial.println(F("Unexpected answer. Skipping lock."));
    		}
    #endif //not SKIP_UART_CONFIRMATION
    #else //LOCK_CONFIGURATION
    		Serial.println(F("Configuration not locked. Define LOCK_CONFIGURATION to lock for real."));
    #endif
    	} else {
    		Serial.println(F("Skipping configuration write and lock (configuration already locked)."));
    		Serial.println(F("Chip configuration:"));
    		dump_configuration();
    	}
    
    #ifdef SKIP_KEY_STORAGE
    	Serial.println(F("Disable SKIP_KEY_STORAGE to store key."));
    #else
    #ifdef USER_KEY
    	memcpy(key, user_key_data, 32);
    	Serial.println(F("Using this user supplied HMAC key:"));
    #else
    	// Retrieve random value to use as key
    	ret_code = sha204.sha204m_random(tx_buffer, rx_buffer, RANDOM_SEED_UPDATE);
    	if (ret_code != SHA204_SUCCESS) {
    		Serial.print(F("Random key generation failed. Response: "));
    		Serial.println(ret_code, HEX);
    		halt();
    	} else {
    		memcpy(key, rx_buffer+SHA204_BUFFER_POS_DATA, 32);
    	}
    	if (lockConfig == 0x00) {
    		Serial.println(F("Take note of this key, it will never be the shown again:"));
    	} else {
    		Serial.println(F("Key is not randomized (configuration not locked):"));
    	}
    #endif
    	Serial.print("#define MY_HMAC_KEY ");
    	for (int i=0; i<32; i++) {
    		Serial.print("0x");
    		if (key[i] < 0x10) {
    			Serial.print('0'); // Because Serial.print does not 0-pad HEX
    		}
    		Serial.print(key[i], HEX);
    		if (i < 31) {
    			Serial.print(',');
    		}
    		if (i+1 == 16) {
    			Serial.print("\\\n                    ");
    		}
    	}
    	Serial.println();
    
    	// It will not be possible to write the key if the configuration zone is unlocked
    	if (lockConfig == 0x00) {
    		// Write the key to the appropriate slot in the data zone
    		Serial.println(F("Writing key to slot 0..."));
    		write_key(key);
    	} else {
    		Serial.println(F("Skipping key storage (configuration not locked)."));
    		Serial.println(F("The configuration must be locked to be able to write a key."));
    	}
    #endif
    
    	if (lockValue != 0x00) {
    #ifdef LOCK_DATA
    #ifndef SKIP_UART_CONFIRMATION
    		while (Serial.available()) {
    			Serial.read();
    		}
    		Serial.println(F("Send SPACE character to lock data..."));
    		while (Serial.available() == 0);
    		if (Serial.read() == ' ')
    #endif //not SKIP_UART_CONFIRMATION
    		{
    			// Correct sequence, resync chip
    			ret_code = sha204.sha204c_resync(SHA204_RSP_SIZE_MAX, rx_buffer);
    			if (ret_code != SHA204_SUCCESS && ret_code != SHA204_RESYNC_WITH_WAKEUP) {
    				Serial.print(F("Resync failed. Response: "));
    				Serial.println(ret_code, HEX);
    				halt();
    			}
    
    			// If configuration is unlocked, key is not updated. Locking data in this case will cause
    			// slot 0 to contain an unknown (or factory default) key, and this is in practically any
    			// usecase not the desired behaviour, so ask for additional confirmation in this case.
    			if (lockConfig != 0x00) {
    				while (Serial.available()) {
    					Serial.read();
    				}
    				Serial.println(F("*** ATTENTION ***"));
    				Serial.println(F("Configuration is not locked. Are you ABSULOUTELY SURE you want to lock data?"));
    				Serial.println(F("Locking data at this stage will cause slot 0 to contain a factory default key"));
    				Serial.println(
    				    F("which cannot be change after locking is done. This is in practically any usecase"));
    				Serial.println(F("NOT the desired behavour. Send SPACE character now to lock data anyway..."));
    				while (Serial.available() == 0);
    				if (Serial.read() != ' ') {
    					Serial.println(F("Unexpected answer. Skipping lock."));
    					halt();
    				}
    			}
    
    			// Lock data zone
    			ret_code = sha204.sha204m_execute(SHA204_LOCK, SHA204_ZONE_DATA | LOCK_ZONE_NO_CRC,
    			                                  0x0000, 0, NULL, 0, NULL, 0, NULL,
    			                                  LOCK_COUNT, tx_buffer, LOCK_RSP_SIZE, rx_buffer);
    			if (ret_code != SHA204_SUCCESS) {
    				Serial.print(F("Data lock failed. Response: "));
    				Serial.println(ret_code, HEX);
    				halt();
    			} else {
    				Serial.println(F("Data locked."));
    
    				// Update lock flags after locking
    				ret_code = sha204.sha204m_read(tx_buffer, rx_buffer, SHA204_ZONE_CONFIG, 0x15<<2);
    				if (ret_code != SHA204_SUCCESS) {
    					Serial.print(F("Failed to determine device lock status. Response: "));
    					Serial.println(ret_code, HEX);
    					halt();
    				} else {
    					lockConfig = rx_buffer[SHA204_BUFFER_POS_DATA+3];
    					lockValue = rx_buffer[SHA204_BUFFER_POS_DATA+2];
    				}
    			}
    		}
    #ifndef SKIP_UART_CONFIRMATION
    		else {
    			Serial.println(F("Unexpected answer. Skipping lock."));
    		}
    #endif //not SKIP_UART_CONFIRMATION
    #else //LOCK_DATA
    		Serial.println(F("Data not locked. Define LOCK_DATA to lock for real."));
    #endif
    	} else {
    		Serial.println(F("Skipping OTP/data zone lock (zone already locked)."));
    	}
    #endif // not USE_SOFT_SIGNING
    
    	Serial.println(F("--------------------------------"));
    	Serial.println(F("Personalization is now complete."));
    #ifndef USE_SOFT_SIGNING
    	Serial.print(F("Configuration is "));
    	if (lockConfig == 0x00) {
    		Serial.println("LOCKED");
    	} else {
    		Serial.println("UNLOCKED");
    	}
    	Serial.print(F("Data is "));
    	if (lockValue == 0x00) {
    		Serial.println("LOCKED");
    	} else {
    		Serial.println("UNLOCKED");
    	}
    #endif
    }
    
    /** @brief Sketch execution code */
    void loop()
    {
    }```


  • @Anticimex
    the interesting thing is when i upload the same sketch to the sensebender micro it works the AES Key will be stored correctly.
    But on the Sensebender Gateway only the first two digits


  • Contest Winner

    @meddie sorry, I cannot see anything out of the ordinary. What hardware do you run on? SAMD? I know the personalizer to work on AVR.
    Have you executed a sketch between personalizer rounds? Perhaps it overwrite parts of the eeprom.



  • @Anticimex
    the troubles i have on sensebender gateway its a samd. On the micro (avr based) works fine.
    On the gateway i didnt upload a sketch between. I have uploaded the personalizer sketch and after them i tried the unmoded personalizer.


  • Contest Winner

    @meddie ok, so samd hardware. @tbowmo is eeprom handling on samd fully compatible with avr? It would appear something is not quite right with eeprom writes (or reads) on samd.


  • Admin

    @Anticimex

    eeprom on samd is handled differently, than avr, since it's an external I2C eeprom. So the normal avr commands for read/write to the eeprom doesn't work.

    the pieces that handle eeprom is located in MyHwSAMD.cpp between line 45 and 100
    https://github.com/mysensors/MySensors/blob/development/core/MyHwSAMD.cpp#L45


  • Contest Winner

    @tbowmo
    That may be, but I would still expect hwReadConfigBlock and hwWriteConfigBlock to be chip agnostic.



  • @tbowmo
    sorry can you say me please what i have to add to the sketch that will store my aes key on the sensebender gateway?
    I am a very very noob
    thanks


  • Contest Winner

    @meddie could you please try an experiment?
    Configure the personalizer to use soft signing and store a soft hmac key and serial to eeprom? Just make up some numbers as keys and see if the same problem happen with those or if it is just the AES key that fail.



  • @Anticimex
    yes of course!!!
    here is the sketch:

    #include "sha204_library.h"
    #include "sha204_lib_return_codes.h"
    #define MY_CORE_ONLY
    #include <MySensors.h>
    
    // Doxygen specific constructs, not included when built normally
    // This is used to enable disabled macros/definitions to be included in the documentation as well.
    #if DOXYGEN
    #define LOCK_CONFIGURATION
    #define LOCK_DATA
    #define SKIP_KEY_STORAGE
    #define USER_KEY
    #define SKIP_UART_CONFIRMATION
    #define USE_SOFT_SIGNING
    #define STORE_SOFT_KEY
    #define USER_SOFT_KEY
    #define STORE_SOFT_SERIAL
    #define USER_SOFT_SERIAL
    #define STORE_AES_KEY
    #define USER_AES_KEY
    #endif
    
    #define LOCK_CONFIGURATION
    
    
    //#define LOCK_DATA
    
    
    //#define SKIP_KEY_STORAGE
    
    
    //#define USER_KEY
    
    
    //#define SKIP_UART_CONFIRMATION
    
    
    #define USE_SOFT_SIGNING
    
    
    #define STORE_SOFT_KEY
    
    
    #define USER_SOFT_KEY
    
    
    #define STORE_SOFT_SERIAL
    
    
    #define USER_SOFT_SERIAL
    
    
    #define STORE_AES_KEY
    
    
    //#define USER_AES_KEY
    
    #if defined(SKIP_UART_CONFIRMATION) && !defined(USER_KEY)
    #error You have to define USER_KEY for boards that does not have UART
    #endif
    
    #ifdef USER_KEY
    /** @brief The user-defined HMAC key to use for personalization */
    #define MY_HMAC_KEY 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
    /** @brief The data to store in key slot 0 */
    const uint8_t user_key_data[32] = {MY_HMAC_KEY};
    #endif
    
    #ifdef USER_SOFT_KEY
    /** @brief The user-defined soft HMAC key to use for EEPROM personalization */
    #define MY_SOFT_HMAC_KEY 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x010,0x11,0x12,0x13,0x14,0x15,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0xAA,0xAB,0xBA,0xBB,0xAC,0xAD,0xAE,0xEB,0xEC,0xED,0xDD
    /** @brief The data to store as soft HMAC key in EEPROM */
    const uint8_t user_soft_key_data[32] = {MY_SOFT_HMAC_KEY};
    #endif
    
    #ifdef USER_SOFT_SERIAL
    /** @brief The user-defined soft serial to use for EEPROM personalization */
    #define MY_SOFT_SERIAL 0x10,0x09,0x08,0x07,0x06,0x05,0x04,0x03,0x02
    /** @brief The data to store as soft serial in EEPROM */
    const uint8_t user_soft_serial[9] = {MY_SOFT_SERIAL};
    #endif
    
    #ifdef USER_AES_KEY
    /** @brief The user-defined AES key to use for EEPROM personalization */
    #define MY_AES_KEY 0x15,0x14,0x13,0x12,0x11,0x10,0x09,0x08,0x07,0x06,0x05,0x05,0x04,0x03,0x14,0x15
    /** @brief The data to store as AES key in EEPROM */
    const uint8_t user_aes_key[16] = {MY_AES_KEY};
    #endif
    
    #ifndef USE_SOFT_SIGNING
    const int sha204Pin = MY_SIGNING_ATSHA204_PIN; //!< The IO pin to use for ATSHA204A
    atsha204Class sha204(sha204Pin);
    #endif
    
    /** @brief Print a error notice and halt the execution */
    void halt()
    {
    	Serial.println(F("Halting!"));
    	while(1);
    }
    
    #ifndef USE_SOFT_SIGNING
    
    uint16_t write_config_and_get_crc()
    {
    	uint16_t crc = 0;
    	uint8_t config_word[4];
    	uint8_t tx_buffer[SHA204_CMD_SIZE_MAX];
    	uint8_t rx_buffer[SHA204_RSP_SIZE_MAX];
    	uint8_t ret_code;
    	bool do_write;
    
    	
    	for (int i=0; i < 88; i += 4) {
    		do_write = true;
    		if (i == 20) {
    			config_word[0] = 0x8F;
    			config_word[1] = 0x80;
    			config_word[2] = 0x80;
    			config_word[3] = 0xA1;
    		} else if (i == 24) {
    			config_word[0] = 0x82;
    			config_word[1] = 0xE0;
    			config_word[2] = 0xA3;
    			config_word[3] = 0x60;
    		} else if (i == 28) {
    			config_word[0] = 0x94;
    			config_word[1] = 0x40;
    			config_word[2] = 0xA0;
    			config_word[3] = 0x85;
    		} else if (i == 32) {
    			config_word[0] = 0x86;
    			config_word[1] = 0x40;
    			config_word[2] = 0x87;
    			config_word[3] = 0x07;
    		} else if (i == 36) {
    			config_word[0] = 0x0F;
    			config_word[1] = 0x00;
    			config_word[2] = 0x89;
    			config_word[3] = 0xF2;
    		} else if (i == 40) {
    			config_word[0] = 0x8A;
    			config_word[1] = 0x7A;
    			config_word[2] = 0x0B;
    			config_word[3] = 0x8B;
    		} else if (i == 44) {
    			config_word[0] = 0x0C;
    			config_word[1] = 0x4C;
    			config_word[2] = 0xDD;
    			config_word[3] = 0x4D;
    		} else if (i == 48) {
    			config_word[0] = 0xC2;
    			config_word[1] = 0x42;
    			config_word[2] = 0xAF;
    			config_word[3] = 0x8F;
    		} else if (i == 52 || i == 56 || i == 60 || i == 64) {
    			config_word[0] = 0xFF;
    			config_word[1] = 0x00;
    			config_word[2] = 0xFF;
    			config_word[3] = 0x00;
    		} else if (i == 68 || i == 72 || i == 76 || i == 80) {
    			config_word[0] = 0xFF;
    			config_word[1] = 0xFF;
    			config_word[2] = 0xFF;
    			config_word[3] = 0xFF;
    		} else {
    			// All other configs are untouched
    			ret_code = sha204.sha204m_read(tx_buffer, rx_buffer, SHA204_ZONE_CONFIG, i);
    			if (ret_code != SHA204_SUCCESS) {
    				Serial.print(F("Failed to read config. Response: "));
    				Serial.println(ret_code, HEX);
    				halt();
    			}
    			// Set config_word to the read data
    			config_word[0] = rx_buffer[SHA204_BUFFER_POS_DATA+0];
    			config_word[1] = rx_buffer[SHA204_BUFFER_POS_DATA+1];
    			config_word[2] = rx_buffer[SHA204_BUFFER_POS_DATA+2];
    			config_word[3] = rx_buffer[SHA204_BUFFER_POS_DATA+3];
    			do_write = false;
    		}
    
    		// Update crc with CRC for the current word
    		crc = sha204.calculateAndUpdateCrc(4, config_word, crc);
    
    		// Write config word
    		if (do_write) {
    			ret_code = sha204.sha204m_execute(SHA204_WRITE, SHA204_ZONE_CONFIG,
    			                                  i >> 2, 4, config_word, 0, NULL, 0, NULL,
    			                                  WRITE_COUNT_SHORT, tx_buffer, WRITE_RSP_SIZE, rx_buffer);
    			if (ret_code != SHA204_SUCCESS) {
    				Serial.print(F("Failed to write config word at address "));
    				Serial.print(i);
    				Serial.print(F(". Response: "));
    				Serial.println(ret_code, HEX);
    				halt();
    			}
    		}
    	}
    	return crc;
    }
    
    
    void write_key(uint8_t* key)
    {
    	uint8_t tx_buffer[SHA204_CMD_SIZE_MAX];
    	uint8_t rx_buffer[SHA204_RSP_SIZE_MAX];
    	uint8_t ret_code;
    
    	// Write key to slot 0
    	ret_code = sha204.sha204m_execute(SHA204_WRITE, SHA204_ZONE_DATA | SHA204_ZONE_COUNT_FLAG,
    	                                  0, SHA204_ZONE_ACCESS_32, key, 0, NULL, 0, NULL,
    	                                  WRITE_COUNT_LONG, tx_buffer, WRITE_RSP_SIZE, rx_buffer);
    	if (ret_code != SHA204_SUCCESS) {
    		Serial.print(F("Failed to write key to slot 0. Response: "));
    		Serial.println(ret_code, HEX);
    		halt();
    	}
    }
    #endif // not USE_SOFT_SIGNING
    
    /** @brief Dump current configuration to UART */
    void dump_configuration()
    {
    	uint8_t buffer[32];
    #ifndef USE_SOFT_SIGNING
    	Serial.println(F("EEPROM DATA:"));
    #endif
    	hwReadConfigBlock((void*)buffer, (void*)EEPROM_SIGNING_SOFT_HMAC_KEY_ADDRESS, 32);
    	Serial.print(F("SOFT_HMAC_KEY | "));
    	for (int j=0; j<32; j++) {
    		if (buffer[j] < 0x10) {
    			Serial.print('0'); // Because Serial.print does not 0-pad HEX
    		}
    		Serial.print(buffer[j], HEX);
    	}
    	Serial.println();
    	hwReadConfigBlock((void*)buffer, (void*)EEPROM_SIGNING_SOFT_SERIAL_ADDRESS, 9);
    	Serial.print(F("SOFT_SERIAL   | "));
    	for (int j=0; j<9; j++) {
    		if (buffer[j] < 0x10) {
    			Serial.print('0'); // Because Serial.print does not 0-pad HEX
    		}
    		Serial.print(buffer[j], HEX);
    	}
    	Serial.println();
    	hwReadConfigBlock((void*)buffer, (void*)EEPROM_RF_ENCRYPTION_AES_KEY_ADDRESS, 16);
    	Serial.print(F("AES_KEY       | "));
    	for (int j=0; j<16; j++) {
    		if (buffer[j] < 0x10) {
    			Serial.print('0'); // Because Serial.print does not 0-pad HEX
    		}
    		Serial.print(buffer[j], HEX);
    	}
    	Serial.println();
    #ifndef USE_SOFT_SIGNING
    	uint8_t tx_buffer[SHA204_CMD_SIZE_MAX];
    	uint8_t rx_buffer[SHA204_RSP_SIZE_MAX];
    	uint8_t ret_code;
    	Serial.println(F("ATSHA204A DATA:"));
    	for (int i=0; i < 88; i += 4) {
    		ret_code = sha204.sha204m_read(tx_buffer, rx_buffer, SHA204_ZONE_CONFIG, i);
    		if (ret_code != SHA204_SUCCESS) {
    			Serial.print(F("Failed to read config. Response: "));
    			Serial.println(ret_code, HEX);
    			halt();
    		}
    		if (i == 0x00) {
    			Serial.print(F("           SN[0:1]           |         SN[2:3]           | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j == 1) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x04) {
    			Serial.print(F("                          Revnum                         | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				Serial.print(F("   "));
    			}
    			Serial.println();
    		} else if (i == 0x08) {
    			Serial.print(F("                          SN[4:7]                        | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				Serial.print(F("   "));
    			}
    			Serial.println();
    		} else if (i == 0x0C) {
    			Serial.print(F("    SN[8]    |  Reserved13   | I2CEnable | Reserved15    | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j < 3) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x10) {
    			Serial.print(F("  I2CAddress |  TempOffset   |  OTPmode  | SelectorMode  | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j < 3) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x14) {
    			Serial.print(F("         SlotConfig00        |       SlotConfig01        | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j == 1) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x18) {
    			Serial.print(F("         SlotConfig02        |       SlotConfig03        | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j == 1) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x1C) {
    			Serial.print(F("         SlotConfig04        |       SlotConfig05        | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j == 1) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x20) {
    			Serial.print(F("         SlotConfig06        |       SlotConfig07        | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j == 1) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x24) {
    			Serial.print(F("         SlotConfig08        |       SlotConfig09        | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j == 1) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x28) {
    			Serial.print(F("         SlotConfig0A        |       SlotConfig0B        | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j == 1) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x2C) {
    			Serial.print(F("         SlotConfig0C        |       SlotConfig0D        | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j == 1) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x30) {
    			Serial.print(F("         SlotConfig0E        |       SlotConfig0F        | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j == 1) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x34) {
    			Serial.print(F("  UseFlag00  | UpdateCount00 | UseFlag01 | UpdateCount01 | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j < 3) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x38) {
    			Serial.print(F("  UseFlag02  | UpdateCount02 | UseFlag03 | UpdateCount03 | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j < 3) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x3C) {
    			Serial.print(F("  UseFlag04  | UpdateCount04 | UseFlag05 | UpdateCount05 | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j < 3) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x40) {
    			Serial.print(F("  UseFlag06  | UpdateCount06 | UseFlag07 | UpdateCount07 | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j < 3) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		} else if (i == 0x44) {
    			Serial.print(F("                      LastKeyUse[0:3]                    | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				Serial.print(F("   "));
    			}
    			Serial.println();
    		} else if (i == 0x48) {
    			Serial.print(F("                      LastKeyUse[4:7]                    | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				Serial.print(F("   "));
    			}
    			Serial.println();
    		} else if (i == 0x4C) {
    			Serial.print(F("                      LastKeyUse[8:B]                    | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				Serial.print(F("   "));
    			}
    			Serial.println();
    		} else if (i == 0x50) {
    			Serial.print(F("                      LastKeyUse[C:F]                    | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				Serial.print(F("   "));
    			}
    			Serial.println();
    		} else if (i == 0x54) {
    			Serial.print(F("  UserExtra  |    Selector   | LockValue |  LockConfig   | "));
    			for (int j=0; j<4; j++) {
    				if (rx_buffer[SHA204_BUFFER_POS_DATA+j] < 0x10) {
    					Serial.print('0'); // Because Serial.print does not 0-pad HEX
    				}
    				Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+j], HEX);
    				if (j < 3) {
    					Serial.print(F(" | "));
    				} else {
    					Serial.print(F("   "));
    				}
    			}
    			Serial.println();
    		}
    	}
    #endif // not USE_SOFT_SIGNING
    }
    
    /** @brief Sketch setup code */
    void setup()
    {
    	// Delay startup a bit for serial consoles to catch up
    	unsigned long enter = hwMillis();
    	while (hwMillis() - enter < (unsigned long)500);
    #ifndef USE_SOFT_SIGNING
    	uint8_t tx_buffer[SHA204_CMD_SIZE_MAX];
    	uint8_t rx_buffer[SHA204_RSP_SIZE_MAX];
    	uint8_t ret_code;
    	uint8_t lockConfig = 0;
    	uint8_t lockValue = 0;
    	uint16_t crc;
    	(void)crc;
    #else
    	// initialize pseudo-RNG
    	randomSeed(analogRead(MY_SIGNING_SOFT_RANDOMSEED_PIN));
    #endif
    	uint8_t key[32];
    	(void)key;
    
    	Serial.begin(9600);
    	hwInit();
    	Serial.println(F("Personalization sketch for MySensors usage."));
    	Serial.println(F("-------------------------------------------"));
    
    #ifndef USE_SOFT_SIGNING
    	// Wake device before starting operations
    	ret_code = sha204.sha204c_wakeup(rx_buffer);
    	if (ret_code != SHA204_SUCCESS) {
    		Serial.print(F("Failed to wake device. Response: "));
    		Serial.println(ret_code, HEX);
    		halt();
    	}
    	// Read out lock config bits to determine if locking is possible
    	ret_code = sha204.sha204m_read(tx_buffer, rx_buffer, SHA204_ZONE_CONFIG, 0x15<<2);
    	if (ret_code != SHA204_SUCCESS) {
    		Serial.print(F("Failed to determine device lock status. Response: "));
    		Serial.println(ret_code, HEX);
    		halt();
    	} else {
    		lockConfig = rx_buffer[SHA204_BUFFER_POS_DATA+3];
    		lockValue = rx_buffer[SHA204_BUFFER_POS_DATA+2];
    	}
    #endif
    
    #ifdef STORE_SOFT_KEY
    #ifdef USER_SOFT_KEY
    	memcpy(key, user_soft_key_data, 32);
    	Serial.println(F("Using this user supplied soft HMAC key:"));
    #else
    	// Retrieve random value to use as soft HMAC key
    #ifdef USE_SOFT_SIGNING
    	for (int i = 0; i < 32; i++) {
    		key[i] = random(256) ^ micros();
    		unsigned long enter = hwMillis();
    		while (hwMillis() - enter < (unsigned long)2);
    	}
    	Serial.println(F("This value will be stored in EEPROM as soft HMAC key:"));
    #else
    	ret_code = sha204.sha204m_random(tx_buffer, rx_buffer, RANDOM_SEED_UPDATE);
    	if (ret_code != SHA204_SUCCESS) {
    		Serial.print(F("Random key generation failed. Response: "));
    		Serial.println(ret_code, HEX);
    		halt();
    	} else {
    		memcpy(key, rx_buffer+SHA204_BUFFER_POS_DATA, 32);
    	}
    	if (lockConfig == 0x00) {
    		Serial.println(F("This value will be stored in EEPROM as soft HMAC key:"));
    	} else {
    		Serial.println(F("Key is not randomized (configuration not locked):"));
    	}
    #endif // not USE_SOFT_SIGNING
    #endif // not USER_SOFT_KEY
    	Serial.print("#define MY_SOFT_HMAC_KEY ");
    	for (int i=0; i<32; i++) {
    		Serial.print("0x");
    		if (key[i] < 0x10) {
    			Serial.print('0'); // Because Serial.print does not 0-pad HEX
    		}
    		Serial.print(key[i], HEX);
    		if (i < 31) {
    			Serial.print(',');
    		}
    	}
    	Serial.println();
    	hwWriteConfigBlock((void*)key, (void*)EEPROM_SIGNING_SOFT_HMAC_KEY_ADDRESS, 32);
    #endif // STORE_SOFT_KEY
    
    #ifdef STORE_SOFT_SERIAL
    #ifdef USER_SOFT_SERIAL
    	memcpy(key, user_soft_serial, 9);
    	Serial.println(F("Using this user supplied soft serial:"));
    #else
    	// Retrieve random value to use as serial
    #ifdef USE_SOFT_SIGNING
    	for (int i = 0; i < 9; i++) {
    		key[i] = random(256) ^ micros();
    		unsigned long enter = hwMillis();
    		while (hwMillis() - enter < (unsigned long)2);
    	}
    	Serial.println(F("This value will be stored in EEPROM as soft serial:"));
    #else
    	ret_code = sha204.sha204m_random(tx_buffer, rx_buffer, RANDOM_SEED_UPDATE);
    	if (ret_code != SHA204_SUCCESS) {
    		Serial.print(F("Random serial generation failed. Response: "));
    		Serial.println(ret_code, HEX);
    		halt();
    	} else {
    		memcpy(key, rx_buffer+SHA204_BUFFER_POS_DATA, 9);
    	}
    	if (lockConfig == 0x00) {
    		Serial.println(F("This value will be stored in EEPROM as soft serial:"));
    	} else {
    		Serial.println(F("Serial is not randomized (configuration not locked):"));
    	}
    #endif // not USE_SOFT_SIGNING
    #endif // not USER_SOFT_SERIAL
    	Serial.print("#define MY_SOFT_SERIAL ");
    	for (int i=0; i<9; i++) {
    		Serial.print("0x");
    		if (key[i] < 0x10) {
    			Serial.print('0'); // Because Serial.print does not 0-pad HEX
    		}
    		Serial.print(key[i], HEX);
    		if (i < 8) {
    			Serial.print(',');
    		}
    	}
    	Serial.println();
    	hwWriteConfigBlock((void*)key, (void*)EEPROM_SIGNING_SOFT_SERIAL_ADDRESS, 9);
    #endif // STORE_SOFT_SERIAL
    
    #ifdef STORE_AES_KEY
    #ifdef USER_AES_KEY
    	memcpy(key, user_aes_key, 16);
    	Serial.println(F("Using this user supplied AES key:"));
    #else
    	// Retrieve random value to use as key
    #ifdef USE_SOFT_SIGNING
    	for (int i = 0; i < 16; i++) {
    		key[i] = random(256) ^ micros();
    		unsigned long enter = hwMillis();
    		while (hwMillis() - enter < (unsigned long)2);
    	}
    	Serial.println(F("This key will be stored in EEPROM as AES key:"));
    #else
    	ret_code = sha204.sha204m_random(tx_buffer, rx_buffer, RANDOM_SEED_UPDATE);
    	if (ret_code != SHA204_SUCCESS) {
    		Serial.print(F("Random key generation failed. Response: "));
    		Serial.println(ret_code, HEX);
    		halt();
    	} else {
    		memcpy(key, rx_buffer+SHA204_BUFFER_POS_DATA, 32);
    	}
    	if (lockConfig == 0x00) {
    		Serial.println(F("This key will be stored in EEPROM as AES key:"));
    	} else {
    		Serial.println(F("Key is not randomized (configuration not locked):"));
    	}
    #endif // not USE_SOFT_SIGNING
    #endif // not USER_AES_KEY
    	Serial.print("#define MY_AES_KEY ");
    	for (int i=0; i<16; i++) {
    		Serial.print("0x");
    		if (key[i] < 0x10) {
    			Serial.print('0'); // Because Serial.print does not 0-pad HEX
    		}
    		Serial.print(key[i], HEX);
    		if (i < 15) {
    			Serial.print(',');
    		}
    	}
    	Serial.println();
    	hwWriteConfigBlock((void*)key, (void*)EEPROM_RF_ENCRYPTION_AES_KEY_ADDRESS, 16);
    #endif // STORE_AES_KEY
    
    #ifdef USE_SOFT_SIGNING
    	Serial.println(F("EEPROM configuration:"));
    	dump_configuration();
    #else
    	// Output device revision on console
    	ret_code = sha204.sha204m_dev_rev(tx_buffer, rx_buffer);
    	if (ret_code != SHA204_SUCCESS) {
    		Serial.print(F("Failed to determine device revision. Response: "));
    		Serial.println(ret_code, HEX);
    		halt();
    	} else {
    		Serial.print(F("Device revision: "));
    		for (int i=0; i<4; i++) {
    			if (rx_buffer[SHA204_BUFFER_POS_DATA+i] < 0x10) {
    				Serial.print('0'); // Because Serial.print does not 0-pad HEX
    			}
    			Serial.print(rx_buffer[SHA204_BUFFER_POS_DATA+i], HEX);
    		}
    		Serial.println();
    	}
    
    	// Output serial number on console
    	ret_code = sha204.getSerialNumber(rx_buffer);
    	if (ret_code != SHA204_SUCCESS) {
    		Serial.print(F("Failed to obtain device serial number. Response: "));
    		Serial.println(ret_code, HEX);
    		halt();
    	} else {
    		Serial.print(F("Device serial:   "));
    		Serial.print('{');
    		for (int i=0; i<9; i++) {
    			Serial.print(F("0x"));
    			if (rx_buffer[i] < 0x10) {
    				Serial.print('0'); // Because Serial.print does not 0-pad HEX
    			}
    			Serial.print(rx_buffer[i], HEX);
    			if (i < 8) {
    				Serial.print(',');
    			}
    		}
    		Serial.print('}');
    		Serial.println();
    		for (int i=0; i<9; i++) {
    			if (rx_buffer[i] < 0x10) {
    				Serial.print('0'); // Because Serial.print does not 0-pad HEX
    			}
    			Serial.print(rx_buffer[i], HEX);
    		}
    		Serial.println();
    	}
    
    	if (lockConfig != 0x00) {
    		// Write config and get CRC for the updated config
    		crc = write_config_and_get_crc();
    
    		// List current configuration before attempting to lock
    		Serial.println(F("Chip configuration:"));
    		dump_configuration();
    
    #ifdef LOCK_CONFIGURATION
    		// Purge serial input buffer
    #ifndef SKIP_UART_CONFIRMATION
    		while (Serial.available()) {
    			Serial.read();
    		}
    		Serial.println(F("Send SPACE character now to lock the configuration..."));
    
    		while (Serial.available() == 0);
    		if (Serial.read() == ' ')
    #endif //not SKIP_UART_CONFIRMATION
    		{
    			Serial.println(F("Locking configuration..."));
    
    			// Correct sequence, resync chip
    			ret_code = sha204.sha204c_resync(SHA204_RSP_SIZE_MAX, rx_buffer);
    			if (ret_code != SHA204_SUCCESS && ret_code != SHA204_RESYNC_WITH_WAKEUP) {
    				Serial.print(F("Resync failed. Response: "));
    				Serial.println(ret_code, HEX);
    				halt();
    			}
    
    			// Lock configuration zone
    			ret_code = sha204.sha204m_execute(SHA204_LOCK, SHA204_ZONE_CONFIG,
    			                                  crc, 0, NULL, 0, NULL, 0, NULL,
    			                                  LOCK_COUNT, tx_buffer, LOCK_RSP_SIZE, rx_buffer);
    			if (ret_code != SHA204_SUCCESS) {
    				Serial.print(F("Configuration lock failed. Response: "));
    				Serial.println(ret_code, HEX);
    				halt();
    			} else {
    				Serial.println(F("Configuration locked."));
    
    				// Update lock flags after locking
    				ret_code = sha204.sha204m_read(tx_buffer, rx_buffer, SHA204_ZONE_CONFIG, 0x15<<2);
    				if (ret_code != SHA204_SUCCESS) {
    					Serial.print(F("Failed to determine device lock status. Response: "));
    					Serial.println(ret_code, HEX);
    					halt();
    				} else {
    					lockConfig = rx_buffer[SHA204_BUFFER_POS_DATA+3];
    					lockValue = rx_buffer[SHA204_BUFFER_POS_DATA+2];
    				}
    			}
    		}
    #ifndef SKIP_UART_CONFIRMATION
    		else {
    			Serial.println(F("Unexpected answer. Skipping lock."));
    		}
    #endif //not SKIP_UART_CONFIRMATION
    #else //LOCK_CONFIGURATION
    		Serial.println(F("Configuration not locked. Define LOCK_CONFIGURATION to lock for real."));
    #endif
    	} else {
    		Serial.println(F("Skipping configuration write and lock (configuration already locked)."));
    		Serial.println(F("Chip configuration:"));
    		dump_configuration();
    	}
    
    #ifdef SKIP_KEY_STORAGE
    	Serial.println(F("Disable SKIP_KEY_STORAGE to store key."));
    #else
    #ifdef USER_KEY
    	memcpy(key, user_key_data, 32);
    	Serial.println(F("Using this user supplied HMAC key:"));
    #else
    	// Retrieve random value to use as key
    	ret_code = sha204.sha204m_random(tx_buffer, rx_buffer, RANDOM_SEED_UPDATE);
    	if (ret_code != SHA204_SUCCESS) {
    		Serial.print(F("Random key generation failed. Response: "));
    		Serial.println(ret_code, HEX);
    		halt();
    	} else {
    		memcpy(key, rx_buffer+SHA204_BUFFER_POS_DATA, 32);
    	}
    	if (lockConfig == 0x00) {
    		Serial.println(F("Take note of this key, it will never be the shown again:"));
    	} else {
    		Serial.println(F("Key is not randomized (configuration not locked):"));
    	}
    #endif
    	Serial.print("#define MY_HMAC_KEY ");
    	for (int i=0; i<32; i++) {
    		Serial.print("0x");
    		if (key[i] < 0x10) {
    			Serial.print('0'); // Because Serial.print does not 0-pad HEX
    		}
    		Serial.print(key[i], HEX);
    		if (i < 31) {
    			Serial.print(',');
    		}
    		if (i+1 == 16) {
    			Serial.print("\\\n                    ");
    		}
    	}
    	Serial.println();
    
    	// It will not be possible to write the key if the configuration zone is unlocked
    	if (lockConfig == 0x00) {
    		// Write the key to the appropriate slot in the data zone
    		Serial.println(F("Writing key to slot 0..."));
    		write_key(key);
    	} else {
    		Serial.println(F("Skipping key storage (configuration not locked)."));
    		Serial.println(F("The configuration must be locked to be able to write a key."));
    	}
    #endif
    
    	if (lockValue != 0x00) {
    #ifdef LOCK_DATA
    #ifndef SKIP_UART_CONFIRMATION
    		while (Serial.available()) {
    			Serial.read();
    		}
    		Serial.println(F("Send SPACE character to lock data..."));
    		while (Serial.available() == 0);
    		if (Serial.read() == ' ')
    #endif //not SKIP_UART_CONFIRMATION
    		{
    			// Correct sequence, resync chip
    			ret_code = sha204.sha204c_resync(SHA204_RSP_SIZE_MAX, rx_buffer);
    			if (ret_code != SHA204_SUCCESS && ret_code != SHA204_RESYNC_WITH_WAKEUP) {
    				Serial.print(F("Resync failed. Response: "));
    				Serial.println(ret_code, HEX);
    				halt();
    			}
    
    			// If configuration is unlocked, key is not updated. Locking data in this case will cause
    			// slot 0 to contain an unknown (or factory default) key, and this is in practically any
    			// usecase not the desired behaviour, so ask for additional confirmation in this case.
    			if (lockConfig != 0x00) {
    				while (Serial.available()) {
    					Serial.read();
    				}
    				Serial.println(F("*** ATTENTION ***"));
    				Serial.println(F("Configuration is not locked. Are you ABSULOUTELY SURE you want to lock data?"));
    				Serial.println(F("Locking data at this stage will cause slot 0 to contain a factory default key"));
    				Serial.println(
    				    F("which cannot be change after locking is done. This is in practically any usecase"));
    				Serial.println(F("NOT the desired behavour. Send SPACE character now to lock data anyway..."));
    				while (Serial.available() == 0);
    				if (Serial.read() != ' ') {
    					Serial.println(F("Unexpected answer. Skipping lock."));
    					halt();
    				}
    			}
    
    			// Lock data zone
    			ret_code = sha204.sha204m_execute(SHA204_LOCK, SHA204_ZONE_DATA | LOCK_ZONE_NO_CRC,
    			                                  0x0000, 0, NULL, 0, NULL, 0, NULL,
    			                                  LOCK_COUNT, tx_buffer, LOCK_RSP_SIZE, rx_buffer);
    			if (ret_code != SHA204_SUCCESS) {
    				Serial.print(F("Data lock failed. Response: "));
    				Serial.println(ret_code, HEX);
    				halt();
    			} else {
    				Serial.println(F("Data locked."));
    
    				// Update lock flags after locking
    				ret_code = sha204.sha204m_read(tx_buffer, rx_buffer, SHA204_ZONE_CONFIG, 0x15<<2);
    				if (ret_code != SHA204_SUCCESS) {
    					Serial.print(F("Failed to determine device lock status. Response: "));
    					Serial.println(ret_code, HEX);
    					halt();
    				} else {
    					lockConfig = rx_buffer[SHA204_BUFFER_POS_DATA+3];
    					lockValue = rx_buffer[SHA204_BUFFER_POS_DATA+2];
    				}
    			}
    		}
    #ifndef SKIP_UART_CONFIRMATION
    		else {
    			Serial.println(F("Unexpected answer. Skipping lock."));
    		}
    #endif //not SKIP_UART_CONFIRMATION
    #else //LOCK_DATA
    		Serial.println(F("Data not locked. Define LOCK_DATA to lock for real."));
    #endif
    	} else {
    		Serial.println(F("Skipping OTP/data zone lock (zone already locked)."));
    	}
    #endif // not USE_SOFT_SIGNING
    
    	Serial.println(F("--------------------------------"));
    	Serial.println(F("Personalization is now complete."));
    #ifndef USE_SOFT_SIGNING
    	Serial.print(F("Configuration is "));
    	if (lockConfig == 0x00) {
    		Serial.println("LOCKED");
    	} else {
    		Serial.println("UNLOCKED");
    	}
    	Serial.print(F("Data is "));
    	if (lockValue == 0x00) {
    		Serial.println("LOCKED");
    	} else {
    		Serial.println("UNLOCKED");
    	}
    #endif
    }
    
    /** @brief Sketch execution code */
    void loop()
    {
    }
    


  • @Anticimex
    and this is the serial output:

    This key will be stored in EEPROM as AES key:
    #define MY_AES_KEY 0x6A,0x2B,0xF7,0xFB,0x03,0x8D,0x03,0x85,0x4D,0xDA,0x2D,0x89,0x9F,0xAD,0x8B,0x4F
    EEPROM configuration:
    SOFT_HMAC_KEY | 01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0BFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
    SOFT_SERIAL   | 10FFFFFFFFFFFFFFFF
    AES_KEY       | 6AFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
    --------------------------------
    Personalization is now complete.
    
    

  • Contest Winner

    @meddie ok, clearly there is some issue with eeprom storage on samd then.


  • Contest Winner

    We will investigate this further. Thanks for identifying the issue. Perhaps you could test signing with atsha on the gateway. That should work since it does not depend on eeprom.



  • @Anticimex
    thank you very much for your support and for your patience with me!!!!
    i just tried and the signing is working fine!!!!
    i look forward to try the encryption! i


  • Contest Winner

    @meddie you are so welcome! Glad that signing works for you. That is actually more complicated than encryption. We (the core team) have confirmed a problem with the write routine to the I2C eeprom on the SenseBender gateway. So people are investigating.


  • Contest Winner

    @meddie the development branch has been updated with a bug fix for the eeprom problem on samd based boards. If you pull the latest changes you should be able to properly personalize the AES key so that encryption will work.



  • @Anticimex
    Hi, i just tried it out and now it and it has worked! The Aes key is stored correctly! BUT i get now an error on compile the gateway sketch

    C:\Users\meddie\Documents\Arduino\SenseebnderGW_LAN_NRF24\SenseebnderGW_LAN_NRF24.ino\SenseebnderGW_LAN_NRF24.ino.ino: In function 'bool testEEProm()':
    
    SenseebnderGW_LAN_NRF24.ino:315: error: 'i2c_eeprom_read_byte' was not declared in this scope
    
       eeprom_d1 = i2c_eeprom_read_byte(EEPROM_VERIFICATION_ADDRESS);
    
                                                                   ^
    
    SenseebnderGW_LAN_NRF24.ino:318: error: 'i2c_eeprom_write_byte' was not declared in this scope
    
       i2c_eeprom_write_byte(EEPROM_VERIFICATION_ADDRESS, eeprom_d1);
    

    i could use the stable lib again then it should compile, but i think you would like to know that an error occours.
    Greets Eddie


  • Contest Winner

    @meddie thanks for reporting! @tbowmo something that slipped through the Jenkins filter?


  • Contest Winner

    @meddie the sketch you compile, is it from the MySensors library examples tree, the external examples repository, or a local sketch?



  • @Anticimex
    its combined from two example sketches sensebendergateway and gatewayw5100 example sketch


  • Contest Winner

    @meddie ok, if it is a local construction, it might be an expected error due to api changes in the library, in which case you need to update locally. The examples from the repository should compile ok.



  • i used the stable lib and comiled the sketch both features are now working encryption and signing! Thank you very much!!!!! I will try to update the example lib and try again.

    I got just the next problem the space from sensebender micro is not enought to use all three features signing, encryption and ota. When i use AES and Signing i get over 109%, when i use the example sketch temp and humidty meassure.

    Greets Eddie


  • Contest Winner

    @meddie you could consider using a conversion board (@tbowmo has published one at openhardware.io) and use rfm69 radios which do AES encryption in hw. It should put less strain on memory resources.



  • @Anticimex I am using a default SensebenderGatewaySerial sketch and get the following error when compiling:

    In file included from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:98:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:6:16: error: redefinition of 'uint8_t device_pin'
    
     static uint8_t device_pin;
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:96:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:6:16: error: 'uint8_t device_pin' previously declared here
    
     static uint8_t device_pin;
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:98:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'void swi_set_signal_pin(uint8_t)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:24:13: error: redefinition of 'void swi_set_signal_pin(uint8_t)'
    
     static void swi_set_signal_pin(uint8_t is_high)
    
                 ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:96:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:24:13: error: 'void swi_set_signal_pin(uint8_t)' previously defined here
    
     static void swi_set_signal_pin(uint8_t is_high)
    
                 ^
    
    In file included from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:98:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t swi_send_bytes(uint8_t, uint8_t*)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:35:16: error: redefinition of 'uint8_t swi_send_bytes(uint8_t, uint8_t*)'
    
     static uint8_t swi_send_bytes(uint8_t count, uint8_t *buffer)
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:96:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:35:16: error: 'uint8_t swi_send_bytes(uint8_t, uint8_t*)' previously defined here
    
     static uint8_t swi_send_bytes(uint8_t count, uint8_t *buffer)
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:98:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t swi_send_byte(uint8_t)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:74:16: error: redefinition of 'uint8_t swi_send_byte(uint8_t)'
    
     static uint8_t swi_send_byte(uint8_t value)
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:96:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:74:16: error: 'uint8_t swi_send_byte(uint8_t)' previously defined here
    
     static uint8_t swi_send_byte(uint8_t value)
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:98:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t swi_receive_bytes(uint8_t, uint8_t*)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:79:16: error: redefinition of 'uint8_t swi_receive_bytes(uint8_t, uint8_t*)'
    
     static uint8_t swi_receive_bytes(uint8_t count, uint8_t *buffer)
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:96:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:79:16: error: 'uint8_t swi_receive_bytes(uint8_t, uint8_t*)' previously defined here
    
     static uint8_t swi_receive_bytes(uint8_t count, uint8_t *buffer)
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:98:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t sha204p_receive_response(uint8_t, uint8_t*)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:178:16: error: redefinition of 'uint8_t sha204p_receive_response(uint8_t, uint8_t*)'
    
     static uint8_t sha204p_receive_response(uint8_t size, uint8_t *response)
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:96:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:178:16: error: 'uint8_t sha204p_receive_response(uint8_t, uint8_t*)' previously defined here
    
     static uint8_t sha204p_receive_response(uint8_t size, uint8_t *response)
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:98:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t sha204c_resync(uint8_t, uint8_t*)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:212:16: error: redefinition of 'uint8_t sha204c_resync(uint8_t, uint8_t*)'
    
     static uint8_t sha204c_resync(uint8_t size, uint8_t *response)
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:96:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:212:16: error: 'uint8_t sha204c_resync(uint8_t, uint8_t*)' previously defined here
    
     static uint8_t sha204c_resync(uint8_t size, uint8_t *response)
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:98:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t sha204c_send_and_receive(uint8_t*, uint8_t, uint8_t*, uint8_t, uint8_t)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:234:16: error: redefinition of 'uint8_t sha204c_send_and_receive(uint8_t*, uint8_t, uint8_t*, uint8_t, uint8_t)'
    
     static uint8_t sha204c_send_and_receive(uint8_t *tx_buffer, uint8_t rx_size, uint8_t *rx_buffer,
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:96:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:234:16: error: 'uint8_t sha204c_send_and_receive(uint8_t*, uint8_t, uint8_t*, uint8_t, uint8_t)' previously defined here
    
     static uint8_t sha204c_send_and_receive(uint8_t *tx_buffer, uint8_t rx_size, uint8_t *rx_buffer,
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:98:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t sha204m_read(uint8_t*, uint8_t*, uint8_t, uint16_t)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:379:16: error: redefinition of 'uint8_t sha204m_read(uint8_t*, uint8_t*, uint8_t, uint16_t)'
    
     static uint8_t sha204m_read(uint8_t *tx_buffer, uint8_t *rx_buffer, uint8_t zone, uint16_t address)
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:96:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:379:16: error: 'uint8_t sha204m_read(uint8_t*, uint8_t*, uint8_t, uint16_t)' previously defined here
    
     static uint8_t sha204m_read(uint8_t *tx_buffer, uint8_t *rx_buffer, uint8_t zone, uint16_t address)
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:98:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'void sha204c_calculate_crc(uint8_t, uint8_t*, uint8_t*)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:399:13: error: redefinition of 'void sha204c_calculate_crc(uint8_t, uint8_t*, uint8_t*)'
    
     static void sha204c_calculate_crc(uint8_t length, uint8_t *data, uint8_t *crc)
    
                 ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:96:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:399:13: error: 'void sha204c_calculate_crc(uint8_t, uint8_t*, uint8_t*)' previously defined here
    
     static void sha204c_calculate_crc(uint8_t length, uint8_t *data, uint8_t *crc)
    
                 ^
    
    In file included from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:98:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t sha204c_check_crc(uint8_t*)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:424:16: error: redefinition of 'uint8_t sha204c_check_crc(uint8_t*)'
    
     static uint8_t sha204c_check_crc(uint8_t *response)
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:96:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:424:16: error: 'uint8_t sha204c_check_crc(uint8_t*)' previously defined here
    
     static uint8_t sha204c_check_crc(uint8_t *response)
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:98:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'void atsha204_init(uint8_t)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:438:6: error: redefinition of 'void atsha204_init(uint8_t)'
    
     void atsha204_init(uint8_t pin)
    
          ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:96:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:438:6: error: 'void atsha204_init(uint8_t)' previously defined here
    
     void atsha204_init(uint8_t pin)
    
          ^
    
    In file included from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:98:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'void atsha204_idle()':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:455:6: error: redefinition of 'void atsha204_idle()'
    
     void atsha204_idle(void)
    
          ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:96:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:455:6: error: 'void atsha204_idle()' previously defined here
    
     void atsha204_idle(void)
    
          ^
    
    In file included from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:98:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'void atsha204_sleep()':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:460:6: error: redefinition of 'void atsha204_sleep()'
    
     void atsha204_sleep(void)
    
          ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:96:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:460:6: error: 'void atsha204_sleep()' previously defined here
    
     void atsha204_sleep(void)
    
          ^
    
    In file included from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:98:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t atsha204_wakeup(uint8_t*)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:465:9: error: redefinition of 'uint8_t atsha204_wakeup(uint8_t*)'
    
     uint8_t atsha204_wakeup(uint8_t *response)
    
             ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:96:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:465:9: error: 'uint8_t atsha204_wakeup(uint8_t*)' previously defined here
    
     uint8_t atsha204_wakeup(uint8_t *response)
    
             ^
    
    In file included from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:98:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t atsha204_execute(uint8_t, uint8_t, uint16_t, uint8_t, uint8_t*, uint8_t, uint8_t*, uint8_t, uint8_t*)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:495:9: error: redefinition of 'uint8_t atsha204_execute(uint8_t, uint8_t, uint16_t, uint8_t, uint8_t*, uint8_t, uint8_t*, uint8_t, uint8_t*)'
    
     uint8_t atsha204_execute(uint8_t op_code, uint8_t param1, uint16_t param2,
    
             ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:96:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:495:9: error: 'uint8_t atsha204_execute(uint8_t, uint8_t, uint16_t, uint8_t, uint8_t*, uint8_t, uint8_t*, uint8_t, uint8_t*)' previously defined here
    
     uint8_t atsha204_execute(uint8_t op_code, uint8_t param1, uint16_t param2,
    
             ^
    
    In file included from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:98:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t atsha204_getSerialNumber(uint8_t*)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:571:9: error: redefinition of 'uint8_t atsha204_getSerialNumber(uint8_t*)'
    
     uint8_t atsha204_getSerialNumber(uint8_t * response)
    
             ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\Documents\Arduino\SensebenderGatewaySerial-2.1.1\SensebenderGatewaySerial-2.1.1.ino:96:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:571:9: error: 'uint8_t atsha204_getSerialNumber(uint8_t*)' previously defined here
    
     uint8_t atsha204_getSerialNumber(uint8_t * response)
    
             ^
    
    Multiple libraries were found for "SD.h"
     Used: C:\Users\Alex\Documents\Arduino\libraries\SD
     Not used: C:\Program Files (x86)\Arduino\libraries\SD
    Using library MySensors at version 2.1.1 in folder: C:\Users\Alex\Documents\Arduino\libraries\MySensors 
    Using library Wire at version 1.0 in folder: C:\Users\Alex\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12\libraries\Wire 
    Using library SPI at version 1.0 in folder: C:\Users\Alex\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12\libraries\SPI 
    Using library SD at version 1.1.1 in folder: C:\Users\Alex\Documents\Arduino\libraries\SD 
    exit status 1
    Error compiling for board Sensebender Gateway.
    

    If I delete "#include <drivers/ATSHA204/ATSHA204.cpp>", it compiles just fine.
    Any ideas please?

    I am using Mysensors 2.1.1, Arduino IDE 1.8.1 and latest SAMD board def.


  • Contest Winner

    @alexsh1 That is because the sketch has this line

    #include <drivers/ATSHA204/ATSHA204.cpp>
    

    @tbowmo Is it intentional to include the cpp and not the header in the sketch?



  • @Anticimex Thanks! I can confirm it compiles fine with the header included rather than the cpp. I suppose it was not an intention


  • Admin

    @alexsh1

    What environment are you building in? platform.io ? Or?

    I know it's awkward to include the cpp file, but it must have been done intentional at some point in time, and arduino way of doing things are very weird at times..

    Btw it does compile fine for me (even with the .cpp as include)



  • @tbowmo No, I am just using Arduino IDE in Windows 10


  • Contest Winner

    I tried building the sketch in Arduino 1.8.1 on Windows 10. Worked fine here. In your log, the sketch name looks changed. It does not end with -2.1.1 here.

    Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\P\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\P\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Cloud\Google Drive\gits\libraries -fqbn=MySensors:samd:mysensors_gw_native -ide-version=10801 -build-path 
    ....
    "C:\Users\P\AppData\Local\Temp\arduino_build_482491/SensebenderGatewaySerial.ino.elf" "C:\Users\P\AppData\Local\Temp\arduino_build_482491\sketch\SensebenderGatewaySerial.ino.cpp.o" "C:\Users\P\AppData\Local\Temp\arduino_build_482491\libraries\Wire\Wire.cpp.o" "C:\Users\P\AppData\Local\Temp\arduino_build_482491\libraries\SPI\SPI.cpp.o" "C:\Users\P\AppData\Local\Temp\arduino_build_482491\libraries\SD\File.cpp.o" "C:\Users\P\AppData\Local\Temp\arduino_build_482491\libraries\SD\SD.cpp.o" "C:\Users\P\AppData\Local\Temp\arduino_build_482491\libraries\SD\utility\Sd2Card.cpp.o" "C:\Users\P\AppData\Local\Temp\arduino_build_482491\libraries\SD\utility\SdFile.cpp.o" "C:\Users\P\AppData\Local\Temp\arduino_build_482491\libraries\SD\utility\SdVolume.cpp.o" "C:\Users\P\AppData\Local\Temp\arduino_build_482491\core\variant.cpp.o" -Wl,--start-group "-LC:\Users\P\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0/CMSIS/Lib/GCC/" -larm_cortexM0l_math -lm "C:\Users\P\AppData\Local\Temp\arduino_build_482491/core\core.a" -Wl,--end-group
    "C:\Users\P\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-objcopy" -O binary  "C:\Users\P\AppData\Local\Temp\arduino_build_482491/SensebenderGatewaySerial.ino.elf" "C:\Users\P\AppData\Local\Temp\arduino_build_482491/SensebenderGatewaySerial.ino.bin"
    "C:\Users\P\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-objcopy" -O ihex -R .eeprom  "C:\Users\P\AppData\Local\Temp\arduino_build_482491/SensebenderGatewaySerial.ino.elf" "C:\Users\P\AppData\Local\Temp\arduino_build_482491/SensebenderGatewaySerial.ino.hex"
    Multiple libraries were found for "SD.h"
     Used: C:\Cloud\Google Drive\gits\libraries\SD
     Not used: C:\Program Files (x86)\Arduino\libraries\SD
    Using library MySensors at version 2.1.1 in folder: C:\Cloud\Google Drive\gits\libraries\MySensors 
    Using library Wire at version 1.0 in folder: C:\Users\P\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12\libraries\Wire 
    Using library SPI at version 1.0 in folder: C:\Users\P\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12\libraries\SPI 
    Using library SD at version 1.1.1 in folder: C:\Cloud\Google Drive\gits\libraries\SD 
    Sketch uses 42984 bytes (16%) of program storage space. Maximum is 262144 bytes.
    


  • @Anticimex Sorry, my bad I forgot to mention that the sketch compiles OK as is.
    Only when I add signing:

    //#define MY_SIGNING
    #define MY_SIGNING_ATSHA204
    #define MY_SIGNING_REQUEST_SIGNATURES
    #define MY_SIGNING_ATSHA204_PIN 17
    

    It fails to compile:

    Arduino: 1.8.1 (Windows 10), Board: "Sensebender Gateway"
    
    C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Alex\AppData\Local\Arduino15\packages -hardware C:\Users\Alex\Documents\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Alex\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Alex\Documents\Arduino\libraries -fqbn=MySensors:samd:mysensors_gw_native -ide-version=10801 -build-path C:\Users\Alex\AppData\Local\Temp\arduino_build_806240 -warnings=none -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.openocd.path=C:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\openocd\0.9.0-arduino5-static -prefs=runtime.tools.bossac.path=C:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\bossac\1.7.0 -prefs=runtime.tools.CMSIS.path=C:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0 -prefs=runtime.tools.arm-none-eabi-gcc.path=C:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1 -prefs=runtime.tools.CMSIS-Atmel.path=C:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.1.0 -verbose C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino
    C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Alex\AppData\Local\Arduino15\packages -hardware C:\Users\Alex\Documents\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Alex\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Alex\Documents\Arduino\libraries -fqbn=MySensors:samd:mysensors_gw_native -ide-version=10801 -build-path C:\Users\Alex\AppData\Local\Temp\arduino_build_806240 -warnings=none -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.openocd.path=C:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\openocd\0.9.0-arduino5-static -prefs=runtime.tools.bossac.path=C:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\bossac\1.7.0 -prefs=runtime.tools.CMSIS.path=C:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0 -prefs=runtime.tools.arm-none-eabi-gcc.path=C:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1 -prefs=runtime.tools.CMSIS-Atmel.path=C:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.1.0 -verbose C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino
    Using board 'mysensors_gw_native' from platform in folder: C:\Users\Alex\AppData\Local\Arduino15\packages\MySensors\hardware\samd\1.0.5
    Using core 'arduino' from platform in folder: C:\Users\Alex\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12
    WARNING: Spurious .mystools folder in 'MySensors' library
    Detecting libraries used...
    "C:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-g++" -mcpu=cortex-m0plus -mthumb -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions  -w -x c++ -E -CC -DF_CPU=48000000L -DARDUINO=10801 -DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD  -D__SAMD21G18A__ -DUSB_VID=0x1209 -DUSB_PID=0x6949 -DUSBCON '-DUSB_MANUFACTURER="MySensors.org"' '-DUSB_PRODUCT="Sensebender GW"' "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0/CMSIS/Include/" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.1.0/CMSIS/Device/ATMEL/" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12\cores\arduino" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\MySensors\hardware\samd\1.0.5\variants\mysensors_gw" "C:\Users\Alex\AppData\Local\Temp\arduino_build_806240\sketch\SensebenderGatewaySerial.ino.cpp" -o "nul"
    "C:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-g++" -mcpu=cortex-m0plus -mthumb -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions  -w -x c++ -E -CC -DF_CPU=48000000L -DARDUINO=10801 -DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD  -D__SAMD21G18A__ -DUSB_VID=0x1209 -DUSB_PID=0x6949 -DUSBCON '-DUSB_MANUFACTURER="MySensors.org"' '-DUSB_PRODUCT="Sensebender GW"' "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0/CMSIS/Include/" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.1.0/CMSIS/Device/ATMEL/" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12\cores\arduino" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\MySensors\hardware\samd\1.0.5\variants\mysensors_gw" "-IC:\Users\Alex\Documents\Arduino\libraries\MySensors" "C:\Users\Alex\AppData\Local\Temp\arduino_build_806240\sketch\SensebenderGatewaySerial.ino.cpp" -o "nul"
    "C:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-g++" -mcpu=cortex-m0plus -mthumb -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions  -w -x c++ -E -CC -DF_CPU=48000000L -DARDUINO=10801 -DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD  -D__SAMD21G18A__ -DUSB_VID=0x1209 -DUSB_PID=0x6949 -DUSBCON '-DUSB_MANUFACTURER="MySensors.org"' '-DUSB_PRODUCT="Sensebender GW"' "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0/CMSIS/Include/" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.1.0/CMSIS/Device/ATMEL/" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12\cores\arduino" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\MySensors\hardware\samd\1.0.5\variants\mysensors_gw" "-IC:\Users\Alex\Documents\Arduino\libraries\MySensors" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12\libraries\Wire" "C:\Users\Alex\AppData\Local\Temp\arduino_build_806240\sketch\SensebenderGatewaySerial.ino.cpp" -o "nul"
    "C:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-g++" -mcpu=cortex-m0plus -mthumb -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions  -w -x c++ -E -CC -DF_CPU=48000000L -DARDUINO=10801 -DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD  -D__SAMD21G18A__ -DUSB_VID=0x1209 -DUSB_PID=0x6949 -DUSBCON '-DUSB_MANUFACTURER="MySensors.org"' '-DUSB_PRODUCT="Sensebender GW"' "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0/CMSIS/Include/" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.1.0/CMSIS/Device/ATMEL/" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12\cores\arduino" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\MySensors\hardware\samd\1.0.5\variants\mysensors_gw" "-IC:\Users\Alex\Documents\Arduino\libraries\MySensors" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12\libraries\Wire" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12\libraries\SPI" "C:\Users\Alex\AppData\Local\Temp\arduino_build_806240\sketch\SensebenderGatewaySerial.ino.cpp" -o "nul"
    "C:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-g++" -mcpu=cortex-m0plus -mthumb -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions  -w -x c++ -E -CC -DF_CPU=48000000L -DARDUINO=10801 -DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD  -D__SAMD21G18A__ -DUSB_VID=0x1209 -DUSB_PID=0x6949 -DUSBCON '-DUSB_MANUFACTURER="MySensors.org"' '-DUSB_PRODUCT="Sensebender GW"' "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0/CMSIS/Include/" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.1.0/CMSIS/Device/ATMEL/" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12\cores\arduino" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\MySensors\hardware\samd\1.0.5\variants\mysensors_gw" "-IC:\Users\Alex\Documents\Arduino\libraries\MySensors" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12\libraries\Wire" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12\libraries\SPI" "-IC:\Users\Alex\Documents\Arduino\libraries\SD\src" "C:\Users\Alex\AppData\Local\Temp\arduino_build_806240\sketch\SensebenderGatewaySerial.ino.cpp" -o "nul"
    Using cached library dependencies for file: C:\Users\Alex\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12\libraries\Wire\Wire.cpp
    Using cached library dependencies for file: C:\Users\Alex\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12\libraries\SPI\SPI.cpp
    Using cached library dependencies for file: C:\Users\Alex\Documents\Arduino\libraries\SD\src\File.cpp
    Using cached library dependencies for file: C:\Users\Alex\Documents\Arduino\libraries\SD\src\SD.cpp
    Using cached library dependencies for file: C:\Users\Alex\Documents\Arduino\libraries\SD\src\utility\Sd2Card.cpp
    Using cached library dependencies for file: C:\Users\Alex\Documents\Arduino\libraries\SD\src\utility\SdFile.cpp
    Using cached library dependencies for file: C:\Users\Alex\Documents\Arduino\libraries\SD\src\utility\SdVolume.cpp
    Generating function prototypes...
    "C:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-g++" -mcpu=cortex-m0plus -mthumb -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions  -w -x c++ -E -CC -DF_CPU=48000000L -DARDUINO=10801 -DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD  -D__SAMD21G18A__ -DUSB_VID=0x1209 -DUSB_PID=0x6949 -DUSBCON '-DUSB_MANUFACTURER="MySensors.org"' '-DUSB_PRODUCT="Sensebender GW"' "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0/CMSIS/Include/" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.1.0/CMSIS/Device/ATMEL/" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12\cores\arduino" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\MySensors\hardware\samd\1.0.5\variants\mysensors_gw" "-IC:\Users\Alex\Documents\Arduino\libraries\MySensors" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12\libraries\Wire" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12\libraries\SPI" "-IC:\Users\Alex\Documents\Arduino\libraries\SD\src" "C:\Users\Alex\AppData\Local\Temp\arduino_build_806240\sketch\SensebenderGatewaySerial.ino.cpp" -o "C:\Users\Alex\AppData\Local\Temp\arduino_build_806240\preproc\ctags_target_for_gcc_minus_e.cpp"
    "C:\Program Files (x86)\Arduino\tools-builder\ctags\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\Alex\AppData\Local\Temp\arduino_build_806240\preproc\ctags_target_for_gcc_minus_e.cpp"
    Compiling sketch...
    "C:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-g++" -mcpu=cortex-m0plus -mthumb -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -DF_CPU=48000000L -DARDUINO=10801 -DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD  -D__SAMD21G18A__ -DUSB_VID=0x1209 -DUSB_PID=0x6949 -DUSBCON '-DUSB_MANUFACTURER="MySensors.org"' '-DUSB_PRODUCT="Sensebender GW"' "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0/CMSIS/Include/" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.1.0/CMSIS/Device/ATMEL/" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12\cores\arduino" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\MySensors\hardware\samd\1.0.5\variants\mysensors_gw" "-IC:\Users\Alex\Documents\Arduino\libraries\MySensors" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12\libraries\Wire" "-IC:\Users\Alex\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12\libraries\SPI" "-IC:\Users\Alex\Documents\Arduino\libraries\SD\src" "C:\Users\Alex\AppData\Local\Temp\arduino_build_806240\sketch\SensebenderGatewaySerial.ino.cpp" -o "C:\Users\Alex\AppData\Local\Temp\arduino_build_806240\sketch\SensebenderGatewaySerial.ino.cpp.o"
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:91:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:6:16: error: redefinition of 'uint8_t device_pin'
    
     static uint8_t device_pin;
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:89:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:6:16: error: 'uint8_t device_pin' previously declared here
    
     static uint8_t device_pin;
    
                    ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:91:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'void swi_set_signal_pin(uint8_t)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:24:13: error: redefinition of 'void swi_set_signal_pin(uint8_t)'
    
     static void swi_set_signal_pin(uint8_t is_high)
    
                 ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:89:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:24:13: error: 'void swi_set_signal_pin(uint8_t)' previously defined here
    
     static void swi_set_signal_pin(uint8_t is_high)
    
                 ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:91:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t swi_send_bytes(uint8_t, uint8_t*)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:35:16: error: redefinition of 'uint8_t swi_send_bytes(uint8_t, uint8_t*)'
    
     static uint8_t swi_send_bytes(uint8_t count, uint8_t *buffer)
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:89:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:35:16: error: 'uint8_t swi_send_bytes(uint8_t, uint8_t*)' previously defined here
    
     static uint8_t swi_send_bytes(uint8_t count, uint8_t *buffer)
    
                    ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:91:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t swi_send_byte(uint8_t)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:74:16: error: redefinition of 'uint8_t swi_send_byte(uint8_t)'
    
     static uint8_t swi_send_byte(uint8_t value)
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:89:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:74:16: error: 'uint8_t swi_send_byte(uint8_t)' previously defined here
    
     static uint8_t swi_send_byte(uint8_t value)
    
                    ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:91:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t swi_receive_bytes(uint8_t, uint8_t*)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:79:16: error: redefinition of 'uint8_t swi_receive_bytes(uint8_t, uint8_t*)'
    
     static uint8_t swi_receive_bytes(uint8_t count, uint8_t *buffer)
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:89:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:79:16: error: 'uint8_t swi_receive_bytes(uint8_t, uint8_t*)' previously defined here
    
     static uint8_t swi_receive_bytes(uint8_t count, uint8_t *buffer)
    
                    ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:91:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t sha204p_receive_response(uint8_t, uint8_t*)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:178:16: error: redefinition of 'uint8_t sha204p_receive_response(uint8_t, uint8_t*)'
    
     static uint8_t sha204p_receive_response(uint8_t size, uint8_t *response)
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:89:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:178:16: error: 'uint8_t sha204p_receive_response(uint8_t, uint8_t*)' previously defined here
    
     static uint8_t sha204p_receive_response(uint8_t size, uint8_t *response)
    
                    ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:91:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t sha204c_resync(uint8_t, uint8_t*)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:212:16: error: redefinition of 'uint8_t sha204c_resync(uint8_t, uint8_t*)'
    
     static uint8_t sha204c_resync(uint8_t size, uint8_t *response)
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:89:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:212:16: error: 'uint8_t sha204c_resync(uint8_t, uint8_t*)' previously defined here
    
     static uint8_t sha204c_resync(uint8_t size, uint8_t *response)
    
                    ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:91:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t sha204c_send_and_receive(uint8_t*, uint8_t, uint8_t*, uint8_t, uint8_t)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:234:16: error: redefinition of 'uint8_t sha204c_send_and_receive(uint8_t*, uint8_t, uint8_t*, uint8_t, uint8_t)'
    
     static uint8_t sha204c_send_and_receive(uint8_t *tx_buffer, uint8_t rx_size, uint8_t *rx_buffer,
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:89:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:234:16: error: 'uint8_t sha204c_send_and_receive(uint8_t*, uint8_t, uint8_t*, uint8_t, uint8_t)' previously defined here
    
     static uint8_t sha204c_send_and_receive(uint8_t *tx_buffer, uint8_t rx_size, uint8_t *rx_buffer,
    
                    ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:91:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t sha204m_read(uint8_t*, uint8_t*, uint8_t, uint16_t)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:379:16: error: redefinition of 'uint8_t sha204m_read(uint8_t*, uint8_t*, uint8_t, uint16_t)'
    
     static uint8_t sha204m_read(uint8_t *tx_buffer, uint8_t *rx_buffer, uint8_t zone, uint16_t address)
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:89:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:379:16: error: 'uint8_t sha204m_read(uint8_t*, uint8_t*, uint8_t, uint16_t)' previously defined here
    
     static uint8_t sha204m_read(uint8_t *tx_buffer, uint8_t *rx_buffer, uint8_t zone, uint16_t address)
    
                    ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:91:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'void sha204c_calculate_crc(uint8_t, uint8_t*, uint8_t*)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:399:13: error: redefinition of 'void sha204c_calculate_crc(uint8_t, uint8_t*, uint8_t*)'
    
     static void sha204c_calculate_crc(uint8_t length, uint8_t *data, uint8_t *crc)
    
                 ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:89:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:399:13: error: 'void sha204c_calculate_crc(uint8_t, uint8_t*, uint8_t*)' previously defined here
    
     static void sha204c_calculate_crc(uint8_t length, uint8_t *data, uint8_t *crc)
    
                 ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:91:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t sha204c_check_crc(uint8_t*)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:424:16: error: redefinition of 'uint8_t sha204c_check_crc(uint8_t*)'
    
     static uint8_t sha204c_check_crc(uint8_t *response)
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:89:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:424:16: error: 'uint8_t sha204c_check_crc(uint8_t*)' previously defined here
    
     static uint8_t sha204c_check_crc(uint8_t *response)
    
                    ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:91:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'void atsha204_init(uint8_t)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:438:6: error: redefinition of 'void atsha204_init(uint8_t)'
    
     void atsha204_init(uint8_t pin)
    
          ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:89:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:438:6: error: 'void atsha204_init(uint8_t)' previously defined here
    
     void atsha204_init(uint8_t pin)
    
          ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:91:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'void atsha204_idle()':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:455:6: error: redefinition of 'void atsha204_idle()'
    
     void atsha204_idle(void)
    
          ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:89:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:455:6: error: 'void atsha204_idle()' previously defined here
    
     void atsha204_idle(void)
    
          ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:91:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'void atsha204_sleep()':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:460:6: error: redefinition of 'void atsha204_sleep()'
    
     void atsha204_sleep(void)
    
          ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:89:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:460:6: error: 'void atsha204_sleep()' previously defined here
    
     void atsha204_sleep(void)
    
          ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:91:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t atsha204_wakeup(uint8_t*)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:465:9: error: redefinition of 'uint8_t atsha204_wakeup(uint8_t*)'
    
     uint8_t atsha204_wakeup(uint8_t *response)
    
             ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:89:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:465:9: error: 'uint8_t atsha204_wakeup(uint8_t*)' previously defined here
    
     uint8_t atsha204_wakeup(uint8_t *response)
    
             ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:91:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t atsha204_execute(uint8_t, uint8_t, uint16_t, uint8_t, uint8_t*, uint8_t, uint8_t*, uint8_t, uint8_t*)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:495:9: error: redefinition of 'uint8_t atsha204_execute(uint8_t, uint8_t, uint16_t, uint8_t, uint8_t*, uint8_t, uint8_t*, uint8_t, uint8_t*)'
    
     uint8_t atsha204_execute(uint8_t op_code, uint8_t param1, uint16_t param2,
    
             ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:89:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:495:9: error: 'uint8_t atsha204_execute(uint8_t, uint8_t, uint16_t, uint8_t, uint8_t*, uint8_t, uint8_t*, uint8_t, uint8_t*)' previously defined here
    
     uint8_t atsha204_execute(uint8_t op_code, uint8_t param1, uint16_t param2,
    
             ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:91:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t atsha204_getSerialNumber(uint8_t*)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:571:9: error: redefinition of 'uint8_t atsha204_getSerialNumber(uint8_t*)'
    
     uint8_t atsha204_getSerialNumber(uint8_t * response)
    
             ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:131:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_295317\SensebenderGatewaySerial.ino:89:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:571:9: error: 'uint8_t atsha204_getSerialNumber(uint8_t*)' previously defined here
    
     uint8_t atsha204_getSerialNumber(uint8_t * response)
    
             ^
    
    Multiple libraries were found for "SD.h"
     Used: C:\Users\Alex\Documents\Arduino\libraries\SD
     Not used: C:\Program Files (x86)\Arduino\libraries\SD
    Using library MySensors at version 2.1.1 in folder: C:\Users\Alex\Documents\Arduino\libraries\MySensors 
    Using library Wire at version 1.0 in folder: C:\Users\Alex\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12\libraries\Wire 
    Using library SPI at version 1.0 in folder: C:\Users\Alex\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12\libraries\SPI 
    Using library SD at version 1.1.1 in folder: C:\Users\Alex\Documents\Arduino\libraries\SD 
    exit status 1
    Error compiling for board Sensebender Gateway.```

  • Admin

    Have you tried to comment the #include out?



  • This is the sketch:

    /**
    * The MySensors Arduino library handles the wireless radio link and protocol
    * between your home built sensors/actuators and HA controller of choice.
    * The sensors forms a self healing radio network with optional repeaters. Each
    * repeater and gateway builds a routing tables in EEPROM which keeps track of the
    * network topology allowing messages to be routed to nodes.
    *
    * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
    * Copyright (C) 2013-2015 Sensnology AB
    * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
    *
    * Documentation: http://www.mysensors.org
    * Support Forum: http://forum.mysensors.org
    *
    * This program is free software; you can redistribute it and/or
    * modify it under the terms of the GNU General Public License
    * version 2 as published by the Free Software Foundation.
    *
    *******************************
    *
    * DESCRIPTION
    * The ArduinoGateway prints data received from sensors on the serial link.
    * The gateway accepts input on seral which will be sent out on radio network.
    *
    * This GW code is designed for Sensebender GateWay / (Arduino Zero variant)
    *
    * Wire connections (OPTIONAL):
    * - Inclusion button should be connected to SW2
    *
    * LEDs on board (default assignments):
    * - Orange: USB RX/TX - Blink when receiving / transmitting on USB CDC device
    * - Yellow: RX  - Blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
    * - Green : TX  - Blink fast on radio message transmitted. In inclusion mode will blink slowly
    * - Red   : ERR - Fast blink on error during transmission error or recieve crc error
    * - Blue  : free - (use with LED_BLUE macro)
    *
    */
    
    #define SKETCH_VERSION "0.2"
    // Enable debug prints to serial monitor
    #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    // Set LOW transmit power level as default, if you have an amplified NRF-module and
    // power your radio separately with a good regulator you can turn up PA level.
    #define MY_RF24_PA_LEVEL RF24_PA_HIGH
    
    // Enable serial gateway
    #define MY_GATEWAY_SERIAL
    
    //#define MY_SIGNING
    #define MY_SIGNING_ATSHA204
    #define MY_SIGNING_REQUEST_SIGNATURES
    #define MY_SIGNING_ATSHA204_PIN 17
    
    // Define a lower baud rate for Arduino's running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
    #if F_CPU == 8000000L
    #define MY_BAUD_RATE 38400
    #endif
    
    // 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
    
    // Set blinking period
    #define MY_DEFAULT_LED_BLINK_PERIOD 300
    
    // Inverses the behavior of leds
    //#define MY_WITH_LEDS_BLINKING_INVERSE
    
    // Flash leds on rx/tx/err
    // Uncomment to override default HW configurations
    //#define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
    //#define MY_DEFAULT_RX_LED_PIN  6  // Receive led pin
    //#define MY_DEFAULT_TX_LED_PIN  5  // the PCB, on board LED
    
    #include <MySensors.h>
    #include <SD.h>
    #include <drivers/ATSHA204/ATSHA204.cpp>
    
    Sd2Card card;
    
    #define EEPROM_VERIFICATION_ADDRESS 0x01
    
    static uint8_t num_of_leds = 5;
    static uint8_t leds[] = {LED_BLUE, LED_RED, LED_GREEN, LED_YELLOW, LED_ORANGE};
    
    void setup()
    {
    	// Setup locally attached sensors
    }
    
    void presentation()
    {
    	// Present locally attached sensors
    }
    
    void loop()
    {
    	// Send locally attached sensor data here
    }
    
    
    void preHwInit()
    {
    
    	pinMode(MY_SWC1, INPUT_PULLUP);
    	pinMode(MY_SWC2, INPUT_PULLUP);
    	if (digitalRead(MY_SWC1) && digitalRead(MY_SWC2)) {
    		return;
    	}
    
    	uint8_t tests = 0;
    
    	for (int i=0; i< num_of_leds; i++) {
    		pinMode(leds[i], OUTPUT);
    	}
    	uint8_t led_state = 0;
    	if (digitalRead(MY_SWC1)) {
    		while (!Serial) {
    			digitalWrite(LED_BLUE, led_state);
    			led_state ^= 0x01;
    			delay(500);
    		} // Wait for USB to be connected, before spewing out data.
    	}
    	digitalWrite(LED_BLUE, LOW);
    	if (Serial) {
    		Serial.println("Sensebender GateWay test routine");
    		Serial.print("Mysensors core version : ");
    		Serial.println(MYSENSORS_LIBRARY_VERSION);
    		Serial.print("GateWay sketch version : ");
    		Serial.println(SKETCH_VERSION);
    		Serial.println("----------------------------------");
    		Serial.println();
    	}
    	if (testSha204()) {
    		digitalWrite(LED_GREEN, HIGH);
    		tests++;
    	}
    	if (testSDCard()) {
    		digitalWrite(LED_YELLOW, HIGH);
    		tests++;
    	}
    
    	if (testEEProm()) {
    		digitalWrite(LED_ORANGE, HIGH);
    		tests++;
    	}
    	if (testAnalog()) {
    		digitalWrite(LED_BLUE, HIGH);
    		tests++;
    	}
    	if (tests == 4) {
    		while(1) {
    			for (int i=0; i<num_of_leds; i++) {
    				digitalWrite(leds[i], HIGH);
    				delay(200);
    				digitalWrite(leds[i], LOW);
    			}
    		}
    	} else {
    		while (1) {
    			digitalWrite(LED_RED, HIGH);
    			delay(200);
    			digitalWrite(LED_RED, LOW);
    			delay(200);
    		}
    	}
    
    }
    
    bool testSha204()
    {
    	uint8_t rx_buffer[SHA204_RSP_SIZE_MAX];
    	uint8_t ret_code;
    	if (Serial) {
    		Serial.print("- > SHA204 ");
    	}
    	atsha204_init(MY_SIGNING_ATSHA204_PIN);
    	ret_code = atsha204_wakeup(rx_buffer);
    
    	if (ret_code == SHA204_SUCCESS) {
    		ret_code = atsha204_getSerialNumber(rx_buffer);
    		if (ret_code != SHA204_SUCCESS) {
    			if (Serial) {
    				Serial.println(F("Failed to obtain device serial number. Response: "));
    			}
    			Serial.println(ret_code, HEX);
    		} else {
    			if (Serial) {
    				Serial.print(F("Ok (serial : "));
    				for (int i=0; i<9; i++) {
    					if (rx_buffer[i] < 0x10) {
    						Serial.print('0'); // Because Serial.print does not 0-pad HEX
    					}
    					Serial.print(rx_buffer[i], HEX);
    				}
    				Serial.println(")");
    			}
    			return true;
    		}
    	} else {
    		if (Serial) {
    			Serial.println(F("Failed to wakeup SHA204"));
    		}
    	}
    	return false;
    }
    
    bool testSDCard()
    {
    	if (Serial) {
    		Serial.print("- > SD CARD ");
    	}
    	if (!card.init(SPI_HALF_SPEED, MY_SDCARD_CS)) {
    		if (Serial) {
    			Serial.println("SD CARD did not initialize!");
    		}
    	} else {
    		if (Serial) {
    			Serial.print("SD Card initialized correct! - ");
    			Serial.print("type detected : ");
    			switch(card.type()) {
    			case SD_CARD_TYPE_SD1:
    				Serial.println("SD1");
    				break;
    			case SD_CARD_TYPE_SD2:
    				Serial.println("SD2");
    				break;
    			case SD_CARD_TYPE_SDHC:
    				Serial.println("SDHC");
    				break;
    			default:
    				Serial.println("Unknown");
    			}
    		}
    		return true;
    	}
    	return false;
    }
    
    bool testEEProm()
    {
    	uint8_t eeprom_d1, eeprom_d2;
    	SerialUSB.print(" -> EEPROM ");
    	Wire.begin();
    	eeprom_d1 = i2c_eeprom_read_byte(EEPROM_VERIFICATION_ADDRESS);
    	delay(500);
    	eeprom_d1 = ~eeprom_d1; // invert the bits
    	i2c_eeprom_write_byte(EEPROM_VERIFICATION_ADDRESS, eeprom_d1);
    	delay(500);
    	eeprom_d2 = i2c_eeprom_read_byte(EEPROM_VERIFICATION_ADDRESS);
    	if (eeprom_d1 == eeprom_d2) {
    		SerialUSB.println("PASSED");
    		i2c_eeprom_write_byte(EEPROM_VERIFICATION_ADDRESS, ~eeprom_d1);
    		return true;
    	}
    	SerialUSB.println("FAILED!");
    	return false;
    }
    
    bool testAnalog()
    {
    	int bat_detect = analogRead(MY_BAT_DETECT);
    	Serial.print("-> analog : ");
    	Serial.print(bat_detect);
    	if (bat_detect < 400 || bat_detect > 650) {
    		Serial.println(" Failed");
    		return false;
    	}
    	Serial.println(" Passed");
    	return true;
    }
    

  • Contest Winner

    The gateway sketch include a test of the atsha which I don't think belong there. You can probably remove the include and the test function.



  • @tbowmo it compiles with this:

    #include <drivers/ATSHA204/ATSHA204.h>

    However, I cannot confirm that the singing is working - I need more time to set-up a node to test it.


  • Admin

    @Anticimex

    It's the default sketch, that itead is putting in the gateway, including a simple hardware self-test routine.

    I would like to keep it there, in case people run into troubles.. Then they can go back to factory stock firmware...



  • @Anticimex You suggest to remote it? It compiles fine if I remove it. I will set-up a node tomorrow to test signing with #include <drivers/ATSHA204/ATSHA204.cpp> removed.


  • Contest Winner

    @tbowmo may I suggest an update which would switch out the include of the cpp file and the test if atsha based signing is enabled? Or is it too late to ship firmware updates to iTead?


  • Admin

    @Anticimex

    Such a change won't affect the firmware that is put into the sensebender GW per se, as we don't use signing in the default sketch. I was about to suggest the same 🙂


  • Contest Winner

    @tbowmo then we have a way forward 🙂



  • @Anticimex
    sorry i didnt let hear anything from me for the last few days.
    i had the same problems with compiling the sketch. It depends on the signing. When you remove the #define MY_SIGNING_ATSHA204 the you can compile but when the singning is defined you get an error until you remove this line:
    #include <drivers/ATSHA204/ATSHA204.cpp>

    i have removed the line and defined the signing and for me works the singing and encryption.

    but i have an another problem, i dont know if i am right here or i better have to post in the sensebender micro forum, i posted that i had some troubles with the space on the sb micro, i have removed the #define my_debug that solved my space problem, but now i have observed that the node is starting and sends few times the temp and humidity but after the few times nothing happens anymore.



  • i observed, when i hold the sensor in the fingers so that it will be worm, and start the node then it sends all minute the temp, but when the temp goes donw to the room temperature the the node sends only when the humidity or temp changes over the threshhold, but in the room i dont have much changes and i think that when the node does not send about longer time, that the the problem comes up.
    I tested it in some different distances, on another floor but in very short distance too. I dont think that is a radio problem.
    What do you think about?
    The Problem is, that i cant debug the node because i disabled it because of space problems.
    Thank you


  • Contest Winner

    Please post these kind of things in the sensebender thread, they are not signing related.



  • @Anticimex I have a quick question. I have the following in the node log:

    2076 Will not sign message for destination 255 as it does not require it
    2117 TSF:MSG:SEND,6-6-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    2779 TSF:MSG:READ,0-0-6,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    2785 Skipping security for command 3 type 8
    2789 TSF:MSG:FPAR OK,ID=0,D=1
    4126 TSM:FPAR:OK
    4126 TSM:ID
    4128 TSM:ID:OK
    4130 TSM:UPL
    4132 Will not sign message for destination 0 as it does not require it
    4143 TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    4161 TSF:MSG:READ,0-0-6,s=255,c=3,t=25,pt=1,l=1,sg=0:1
    4165 Skipping security for command 3 type 25
    

    both the GW and the node have #define MY_SIGNING_REQUEST_SIGNATURES
    Am I missing anything? Why signing is skipped?


  • Contest Winner

    @alexsh1 has the node and gateway successfully exchanged their signing preferences? It is done at node startup.



  • @Anticimex No, straight at the beginning I got this:

    0 MCO:BGN:INIT NODE,CP=RNONAA-,VER=2.1.1
    4 TSM:INIT
    4 TSF:WUR:MS=0
    12 TSM:INIT:TSP OK
    14 TSM:INIT:STATID=6
    16 TSF:SID:OK,ID=6
    18 TSM:FPAR
    20 Will not sign message for destination 255 as it does not require it
    61 TSF:MSG:SEND,6-6-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    538 TSF:MSG:READ,0-0-6,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    544 Skipping security for command 3 type 8
    548 TSF:MSG:FPAR OK,ID=0,D=1
    2070 TSM:FPAR:OK
    2070 TSM:ID
    2072 TSM:ID:OK
    2074 TSM:UPL
    2076 Will not sign message for destination 0 as it does not require it
    2086 TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    2103 TSF:MSG:READ,0-0-6,s=255,c=3,t=25,pt=1,l=1,sg=0:1
    2109 Skipping security for command 3 type 25
    2115 TSF:MSG:PONG RECV,HP=1
    2117 TSM:UPL:OK
    2119 TSM:READY:ID=6,PAR=0,DIS=1
    2123 ‘"Yð·�æ–à”]-”ô*“"2125 TSM:INIT
    2 MCO:BGN:INIT NODE,CP=RNONAA-,VER=2.1.1```

  • Contest Winner

    @alexsh1 is that all? It looks like it has not reached the signing setup part yet. Is node and gw alive or are one of them hanging?



  • @Anticimex Yes, I am afraid. The GW is showing
    "0;255;3;0;9;Message is not signed, but it should have been!
    0;255;3;0;9;!TSF:MSG:SIGN VERIFY FAIL"

    Yes, both node and GW are fine, but messages are not reaching the GW as signing is required.


  • Contest Winner

    @alexsh1 at startup of the node, it sends its signing preferences to the GW (assuming you have selected a signing backend, atsha204a or soft signing). The GW will then reply with its own preference to inform the node that it should sign messages. If the GW said that it rejects messages because they are unsigned, it suggests that the GW require signatures from that node, but the node does not realize that it needs to sign them. So either the node is not properly configured to sign messages or there have been a radio issue preventing message exchange during startup.



  • @Anticimex After forcing all nodes to sign with #define MY_SIGNING_GW_REQUEST_SIGNATURES_FROM_ALL
    got this:

    0 MCO:BGN:INIT NODE,CP=RNNNAA-,VER=2.1.1
    4 TSM:INIT
    4 TSF:WUR:MS=0
    12 TSM:INIT:TSP OK
    14 TSM:INIT:STATID=6
    16 TSF:SID:OK,ID=6
    18 TSM:FPAR
    18 Will not sign message for destination 255 as it does not require it
    61 TSF:MSG:SEND,6-6-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    1044 TSF:MSG:READ,0-0-6,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    1050 TSF:MSG:FPAR OK,ID=0,D=1
    2070 TSM:FPAR:OK
    2070 TSM:ID
    2072 TSM:ID:OK
    2074 TSM:UPL
    2076 Skipping security for command 3 type 24
    2082 TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    2103 TSF:MSG:READ,0-0-6,s=255,c=3,t=25,pt=1,l=1,sg=0:1
    2109 TSF:MSG:PONG RECV,HP=1
    2113 TSM:UPL:OK
    2115 TSM:READY:ID=6,PAR=0,DIS=1
    2117 Skipping security for command 3 type 15
    2123 TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
    2131 Waiting for GW to send signing preferences...
    2164 TSF:MSG:READ,0-0-6,s=255,c=3,t=15,pt=6,l=2,sg=0:0101
    2170 Mark node 0 as one that require signed messages
    2177 Mark node 0 as one that do not require whitelisting
    2183 Skipping security for command 3 type 16
    2189 TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=16,pt=0,l=0,sg=0,ft=0,st=OK:
    2197 Nonce requested from 0. Waiting...
    2201 Message to send could not be signed!
    2205 !TSF:MSG:SIGN FAIL
    2207 Skipping security for command 3 type 16
    2213 TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=16,pt=0,l=0,sg=0,ft=1,st=OK:
    2222 Nonce requested from 0. Waiting...
    2226 Message to send could not be signed!
    2230 !TSF:MSG:SIGN FAIL
    2232 TSF:MSG:READ,0-0-6,s=255,c=3,t=17,pt=6,l=25,sg=0:A03E832C91BD0CC2C02E2A16D834F9CA91816D234ABB1188A2
    2244 Nonce received from 0.
    2246 Proceeding with signing...
    Message to process: 06000E2306FF00
    Current nonce: A03E832C91BD0CC2C02E2A16D834F9CA91816D234ABB1188A2AAAAAAAAAAAAAA
    HMAC: AF54D68677672C45B3E1329A9A1B4E7517D0A0FF340569C633D5DC52207F8DDA
    Signature in message: 0154D68677672C45B3E1329A9A1B4E7517D0A0FF340569C6
    2371 Message signed
    2379 TSF:MSG:READ,0-0-6,s=255,c=3,t=17,pt=6,l=25,sg=0:C1FACC7B2E3B538E31853CB92C73A87E3240FBC2253CE63A9E
    2392 Nonce received from 0.
    2394 Proceeding with signing...
    Message to process: 06000E2306FF00
    Current nonce: C1FACC7B2E3B538E31853CB92C73A87E3240FBC2253CE63A9EAAAAAAAAAAAAAA
    HMAC: 9EE43EA4A510354CB2D3A0AB2C0D13D106CD9B666103E7B7115B73B646DB20DD
    Signature in message: 01E43EA4A510354CB2D3A0AB2C0D13D106CD9B666103E7B7
    2519 Message signed
    4233 Skipping security for command 3 type 16
    4239 TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=16,pt=0,l=0,sg=1,ft=1,st=OK:
    4247 Nonce requested from 0. Waiting...
    4280 TSF:MSG:READ,0-0-6,s=255,c=3,t=17,pt=6,l=25,sg=0:25E2116C25EBB38BB5F87AFFC892073803D818F07FB1E36738
    4292 Nonce received from 0.
    4294 Proceeding with signing...
    4298 Failed to sign message!
    4300 Message to send could not be signed!
    4304 !TSF:MSG:SIGN FAIL
    4306 Skipping security for command 3 type 16
    4315 TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=16,pt=0,l=0,sg=0,ft=1,st=OK:
    4321 Nonce requested from 0. Waiting...
    4354 TSF:MSG:READ,0-0-6,s=255,c=3,t=17,pt=6,l=25,sg=0:6FE06CCBD9098A24D65907C9C7CF62062DA365227E5A836108
    4366 Nonce received from 0.
    4368 Proceeding with signing...
    Message to process: 06001E030CFF312E31
    Current nonce: 6FE06CCBD9098A24D65907C9C7CF62062DA365227E5A836108AAAAAAAAAAAAAA
    HMAC: 564EF68106E0B7333A233F7C396BEDBE537F9AF012C78856F3BD37753B9F096E
    Signature in message: 014EF68106E0B7333A233F7C396BEDBE537F9AF012C7
    4491 Message signed
    4499 Message to send has been signed
    4505 TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=12,pt=0,l=3,sg=1,ft=0,st=OK:1.1
    4513 Skipping security for command 3 type 16
    4519 TSF:MSG:SEND,6-6-0-0,s=0,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    4528 Nonce requested from 0. Waiting...
    4651 TSF:MSG:READ,0-0-6,s=255,c=3,t=17,pt=6,l=25,sg=0:67AD75E666FB63B0A606CCA15003152448DE5D66C1EA34E541
    4663 Nonce received from 0.
    4665 Proceeding with signing...
    Message to process: 060006000800
    Current nonce: 67AD75E666FB63B0A606CCA15003152448DE5D66C1EA34E541AAAAAAAAAAAAAA
    HMAC: 4901D9D648B90185224D2256EADC4C607543E698EC2252B7E88BAD91696824CB
    Signature in message: 0101D9D648B90185224D2256EADC4C607543E698EC2252B7E8
    4790 Message signed
    4798 Message to send has been signed
    4804 TSF:MSG:SEND,6-6-0-0,s=0,c=0,t=8,pt=0,l=0,sg=1,ft=0,st=OK:
    4812 Skipping security for command 3 type 16
    4818 TSF:MSG:SEND,6-6-0-0,s=1,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    4827 Nonce requested from 0. Waiting...
    4950 TSF:MSG:READ,0-0-6,s=255,c=3,t=17,pt=6,l=25,sg=0:44DC6983F5E93696CEFD0B73423B33946AE1BC3DC40F562012
    4962 Nonce received from 0.
    4964 Proceeding with signing...
    Message to process: 060006000601
    Current nonce: 44DC6983F5E93696CEFD0B73423B33946AE1BC3DC40F562012AAAAAAAAAAAAAA
    HMAC: 4D37001CE6A4C2E5C7C5B8995C871DA6386E9C7ADD90D3AF36D83C98C1E98166
    Signature in message: 0137001CE6A4C2E5C7C5B8995C871DA6386E9C7ADD90D3AF36
    5091 Message signed
    5099 Message to send has been signed
    5105 TSF:MSG:SEND,6-6-0-0,s=1,c=0,t=6,pt=0,l=0,sg=1,ft=0,st=OK:
    5113 Skipping security for command 3 type 16
    5122 TSF:MSG:SEND,6-6-0-0,s=2,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    5128 Nonce requested from 0. Waiting...
    5253 TSF:MSG:READ,0-0-6,s=255,c=3,t=17,pt=6,l=25,sg=0:B6C405695A2B551DE4C1AFC02125F42528209A3DF9013820E2
    5263 Nonce received from 0.
    5267 Proceeding with signing...
    Message to process: 060006000702
    Current nonce: B6C405695A2B551DE4C1AFC02125F42528209A3DF9013820E2AAAAAAAAAAAAAA
    HMAC: B767B39D7B5F78422608CCF763DA7C94B333DA95C07087D896DFB36CACF0CE77
    Signature in message: 0167B39D7B5F78422608CCF763DA7C94B333DA95C07087D896
    5392 Message signed
    5398 Message to send has been signed
    5404 TSF:MSG:SEND,6-6-0-0,s=2,c=0,t=7,pt=0,l=0,sg=1,ft=0,st=OK:
    5412 Skipping security for command 3 type 16
    5421 TSF:MSG:SEND,6-6-0-0,s=3,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    5427 Nonce requested from 0. Waiting...
    5554 TSF:MSG:READ,0-0-6,s=255,c=3,t=17,pt=6,l=25,sg=0:9A92C415D6BE672E588BE107BE88637D9D3551A029796C12EF
    5566 Nonce received from 0.
    5568 Proceeding with signing...
    Message to process: 060006000D03
    Current nonce: 9A92C415D6BE672E588BE107BE88637D9D3551A029796C12EFAAAAAAAAAAAAAA
    HMAC: B75B0F0C356378B1EEC25726EE552581F98B1957ADE9A82EF48408FD528927E6
    Signature in message: 015B0F0C356378B1EEC25726EE552581F98B1957ADE9A82EF4
    5693 Message signed
    5699 Message to send has been signed
    5707 TSF:MSG:SEND,6-6-0-0,s=3,c=0,t=13,pt=0,l=0,sg=1,ft=0,st=OK:
    5713 MCO:REG:REQ
    5715 Skipping security for command 3 type 26
    5724 TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=26,pt=1,l=1,sg=1,ft=0,st=OK:2
    5830 TSF:MSG:READ,0-0-6,s=255,c=3,t=27,pt=1,l=1,sg=0:1
    5836 MCO:PIM:NODE REG=1
    5838 MCO:BGN:STP
    BME280 Pressure Sensor1.1isMetric: 1
    6160 Skipping security for command 3 type 16
    6168 TSF:MSG:SEND,6-6-0-0,s=3,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    6174 Nonce requested from 0. Waiting...
    6207 TSF:MSG:READ,0-0-6,s=255,c=3,t=17,pt=6,l=25,sg=0:F7F1A5F6C487947D093E7676AA05AF1BE65AFE31B4223034C2
    6219 Nonce received from 0.
    6221 Proceeding with signing...
    Message to process: 06002EE12603EE7C4F4002
    Current nonce: F7F1A5F6C487947D093E7676AA05AF1BE65AFE31B4223034C2AAAAAAAAAAAAAA
    HMAC: DF2217C08446766ECC9CD41D4C9643B546CC921AEAA9E1971DF314F965D2D0FE
    Signature in message: 012217C08446766ECC9CD41D4C9643B546CC921A
    6346 Message signed
    6354 Message to send has been signed
    6361 TSF:MSG:SEND,6-6-0-0,s=3,c=1,t=38,pt=7,l=5,sg=1,ft=0,st=OK:3.24
    6369 Skipping security for command 3 type 16
    6377 TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    6383 Nonce requested from 0. Waiting...
    6508 TSF:MSG:READ,0-0-6,s=255,c=3,t=17,pt=6,l=25,sg=0:027634E4197B49C4FDB8059CB6D34AA6D81EB340D934252BBF
    6518 Nonce received from 0.
    6522 Proceeding with signing...
    Message to process: 06000E2300FF67
    Current nonce: 027634E4197B49C4FDB8059CB6D34AA6D81EB340D934252BBFAAAAAAAAAAAAAA
    HMAC: 572A1585F50CE39199035088548A9877A08B8B3FA8404FA31B8B55B5190320C1
    Signature in message: 012A1585F50CE39199035088548A9877A08B8B3FA8404FA3
    6645 Message signed
    6651 Message to send has been signed
    6660 TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=0,pt=1,l=1,sg=1,ft=0,st=OK:103
    6666 MCO:BGN:INIT OK,TSP=1
    Temperature = 24.90 *C
    Humidity = 48.62 %
    Pressure = 994.33 hPa
    Forecast = unknown
    6678 Skipping security for command 3 type 16
    6688 TSF:MSG:SEND,6-6-0-0,s=1,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    6696 Nonce requested from 0. Waiting...
    6805 TSF:MSG:READ,0-0-6,s=255,c=3,t=17,pt=6,l=25,sg=0:988D1BCE8B949E24FA8D7FE18200429C16B01AF0B927CE0709
    6815 Nonce received from 0.
    6819 Proceeding with signing...
    Message to process: 06002EE1149307E4071493
    Current nonce: 988D1BCE8B949E24FA8D7FE18200429C16B01AF0B927CE0709AAAAAAAAAAAAAA
    HMAC: EAB0E2B8ECF6B95E6D07BE2651BECF977C53DDB8516DD847CFE6688DD61140ED
    Signature in message: 01B0E2B8ECF6B95E6D07BE2651BECF977C53DDB8
    6944 Message signed
    6952 Message to send has been signed
    6959 TSF:MSG:SEND,6-6-0-0,s=147,c=1,t=20,pt=7,l=5,sg=1,ft=0,st=OK:0.00000000
    6967 Skipping security for command 3 type 16
    6975 TSF:MSG:SEND,6-6-0-0,s=2,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    6981 Nonce requested from 0. Waiting...
    6985 Message to send could not be signed!
    6989 !TSF:MSG:SIGN FAIL
    6993 Skipping security for command 3 type 16
    7000 TSF:MSG:SEND,6-6-0-0,s=0,c=3,t=16,pt=0,l=0,sg=0,ft=1,st=OK:
    7006 Nonce requested from 0. Waiting...
    7010 Message to send could not be signed!
    7014 !TSF:MSG:SIGN FAIL
    7018 Skipping security for command 3 type 16
    7024 TSF:MSG:SEND,6-6-0-0,s=0,c=3,t=16,pt=0,l=0,sg=0,ft=1,st=OK:
    7030 Nonce requested from 0. Waiting...
    7034 Message to send could not be signed!
    7038 !TSF:MSG:SIGN FAIL
    7092 MCO:SLP:MS=300000,SMS=0,I1=255,M1=255,I2=255,M2=255
    7098 MCO:SLP:TPD
    

    What do you think the problem is?
    Why is it still MSG:SIGN FAIL

    EDIT: this is the GW log:

    0;255;3;0;9;MCO:BGN:INIT GW,CP=RNNGAS-,VER=2.1.1
    0;255;3;0;9;TSM:INIT
    0;255;3;0;9;TSF:WUR:MS=0
    0;255;3;0;9;TSM:INIT:TSP OK
    0;255;3;0;9;TSM:INIT:GW MODE
    0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0
    0;255;3;0;9;MCO:REG:NOT NEEDED
    IP: 10.1.1.120
    0;255;3;0;9;MCO:BGN:STP
    0;255;3;0;9;MCO:BGN:INIT OK,TSP=1
    0;255;3;0;9;TSF:MSG:READ,15-15-0,s=1,c=1,t=0,pt=7,l=5,sg=0:27.0
    0;255;3;0;9;Message is not signed, but it should have been!
    0;255;3;0;9;!TSF:MSG:SIGN VERIFY FAIL
    0;255;3;0;9;TSF:MSG:READ,15-15-0,s=0,c=1,t=4,pt=7,l=5,sg=0:996
    0;255;3;0;9;Message is not signed, but it should have been!
    0;255;3;0;9;!TSF:MSG:SIGN VERIFY FAIL
    0;255;3;0;9;TSF:MSG:READ,6-6-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    0;255;3;0;9;TSF:MSG:BC
    0;255;3;0;9;TSF:MSG:FPAR REQ,ID=6
    0;255;3;0;9;TSF:PNG:SEND,TO=0
    0;255;3;0;9;TSF:CKU:OK
    0;255;3;0;9;TSF:MSG:GWL OK
    0;255;3;0;9;Skipping security for command 3 type 8
    0;255;3;0;9;TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    0;255;3;0;9;TSF:MSG:READ,6-6-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1
    0;255;3;0;9;Skipping security for command 3 type 24
    0;255;3;0;9;TSF:MSG:PINGED,ID=6,HP=1
    0;255;3;0;9;Skipping security for command 3 type 25
    0;255;3;0;9;TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=OK:1
    0;255;3;0;9;TSF:MSG:READ,6-6-0,s=255,c=3,t=15,pt=6,l=2,sg=0:0101
    0;255;3;0;9;Skipping security for command 3 type 15
    0;255;3;0;9;Mark node 6 as one that require signed messages
    0;255;3;0;9;Mark node 6 as one that do not require whitelisting
    0;255;3;0;9;Informing node 6 that we require signatures
    0;255;3;0;9;Informing node 6 that we do not require whitelisting
    0;255;3;0;9;Skipping security for command 3 type 15
    0;255;3;0;9;TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0101
    0;255;3;0;9;TSF:MSG:READ,6-6-0,s=255,c=3,t=16,pt=0,l=0,sg=0:
    0;255;3;0;9;Skipping security for command 3 type 16
    0;255;3;0;9;SHA256: BB0EE26FC4C35E155CA36591DFC8DF866D188923ADCCA99ED700000000000000
    0;255;3;0;9;Skipping security for command 3 type 17
    0;255;3;0;9;TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=17,pt=6,l=25,sg=0,ft=0,st=OK:BB0EE26FC4C35E155CA36591DFC8DF866D188923ADCCA99ED7
    0;255;3;0;9;Transmitted nonce
    0;255;3;0;9;TSF:MSG:READ,6-6-0,s=255,c=3,t=16,pt=0,l=0,sg=0:
    0;255;3;0;9;Skipping security for command 3 type 16
    0;255;3;0;9;SHA256: C62553080FACCBBA84B0BE05AEA1871324370BD8BBF431D38CAAAAAAAAAAAAAA
    0;255;3;0;9;Skipping security for command 3 type 17
    0;255;3;0;9;TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=17,pt=6,l=25,sg=0,ft=0,st=OK:C62553080FACCBBA84B0BE05AEA1871324370BD8BBF431D38C
    0;255;3;0;9;Transmitted nonce
    0;255;3;0;9;TSF:MSG:READ,6-6-0,s=255,c=3,t=16,pt=0,l=0,sg=1:
    0;255;3;0;9;Skipping security for command 3 type 16
    0;255;3;0;9;SHA256: AA4BF678F8D0BE6885E67795A8D6E001CF8E0AFECD0D6146B0AAAAAAAAAAAAAA
    0;255;3;0;9;Skipping security for command 3 type 17
    0;255;3;0;9;TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=17,pt=6,l=25,sg=1,ft=0,st=OK:AA4BF678F8D0BE6885E67795A8D6E001CF8E0AFECD0D6146B0
    0;255;3;0;9;Transmitted nonce
    0;255;3;0;9;TSF:MSG:READ,6-6-0,s=255,c=3,t=16,pt=0,l=0,sg=0:
    0;255;3;0;9;Skipping security for command 3 type 16
    0;255;3;0;9;SHA256: 6122BFB72296B95B45E44C2B4D43A3CE1C9D1F43F24137149AAAAAAAAAAAAAAA
    0;255;3;0;9;Skipping security for command 3 type 17
    0;255;3;0;9;TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=17,pt=6,l=25,sg=0,ft=0,st=OK:6122BFB72296B95B45E44C2B4D43A3CE1C9D1F43F24137149A
    0;255;3;0;9;Transmitted nonce
    0;255;3;0;9;TSF:MSG:READ,6-6-0,s=255,c=3,t=12,pt=0,l=3,sg=1:1.1
    0;255;3;0;9;Signature in message: 016583B112FED6ED3698EB4A4AE12B319ACC2755CF92
    0;255;3;0;9;Message to process: 06001E030CFF312E31
    0;255;3;0;9;Current nonce: 6122BFB72296B95B45E44C2B4D43A3CE1C9D1F43F24137149AAAAAAAAAAAAAAA
    0;255;3;0;9;HMAC: DD6583B112FED6ED3698EB4A4AE12B319ACC2755CF9239836E845A5B3DD186FF
    0;255;3;0;9;TSF:MSG:READ,6-6-0,s=0,c=3,t=16,pt=0,l=0,sg=1:
    0;255;3;0;9;Skipping security for command 3 type 16
    0;255;3;0;9;SHA256: D3F6004F4966A6D33936AC7EBCEEBF9CE919AD644BFA33289AAAAAAAAAAAAAAA
    0;255;3;0;9;Skipping security for command 3 type 17
    0;255;3;0;9;TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=17,pt=6,l=25,sg=1,ft=0,st=OK:D3F6004F4966A6D33936AC7EBCEEBF9CE919AD644BFA33289A
    0;255;3;0;9;Transmitted nonce
    0;255;3;0;9;TSF:MSG:READ,6-6-0,s=0,c=0,t=8,pt=0,l=0,sg=1:
    0;255;3;0;9;Signature in message: 01CF6F511AAA6A0F2750F6437F3DEA644A13335E155EC94488
    0;255;3;0;9;Message to process: 060006000800
    0;255;3;0;9;Current nonce: D3F6004F4966A6D33936AC7EBCEEBF9CE919AD644BFA33289AAAAAAAAAAAAAAA
    0;255;3;0;9;HMAC: D6CF6F511AAA6A0F2750F6437F3DEA644A13335E155EC944884A4A6D7C667140
    0;255;3;0;9;TSF:MSG:READ,6-6-0,s=1,c=3,t=16,pt=0,l=0,sg=1:
    0;255;3;0;9;Skipping security for command 3 type 16
    0;255;3;0;9;SHA256: E310DE1F44902508B12558EB2C3C51066F381572694AD4D7CEAAAAAAAAAAAAAA
    0;255;3;0;9;Skipping security for command 3 type 17
    0;255;3;0;9;TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=17,pt=6,l=25,sg=1,ft=0,st=OK:E310DE1F44902508B12558EB2C3C51066F381572694AD4D7CE
    0;255;3;0;9;Transmitted nonce
    0;255;3;0;9;TSF:MSG:READ,6-6-0,s=1,c=0,t=6,pt=0,l=0,sg=1:
    0;255;3;0;9;Signature in message: 012F140689293B434B043699F131C397F629633FD7D9E9D489
    0;255;3;0;9;Message to process: 060006000601
    0;255;3;0;9;Current nonce: E310DE1F44902508B12558EB2C3C51066F381572694AD4D7CEAAAAAAAAAAAAAA
    0;255;3;0;9;HMAC: 942F140689293B434B043699F131C397F629633FD7D9E9D48992B327A0CB9BB8
    0;255;3;0;9;TSF:MSG:READ,6-6-0,s=2,c=3,t=16,pt=0,l=0,sg=1:
    0;255;3;0;9;Skipping security for command 3 type 16
    0;255;3;0;9;SHA256: 0EB8A85D42109C29EBE8E78BF9B8C66092845EB7D92AC1B381AAAAAAAAAAAAAA
    0;255;3;0;9;Skipping security for command 3 type 17
    0;255;3;0;9;TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=17,pt=6,l=25,sg=1,ft=0,st=OK:0EB8A85D42109C29EBE8E78BF9B8C66092845EB7D92AC1B381
    0;255;3;0;9;Transmitted nonce
    0;255;3;0;9;TSF:MSG:READ,6-6-0,s=2,c=0,t=7,pt=0,l=0,sg=1:
    0;255;3;0;9;Signature in message: 018D9FBD8E3E4730D1932EE4E4BB998B10B593631551BBB575
    0;255;3;0;9;Message to process: 060006000702
    0;255;3;0;9;Current nonce: 0EB8A85D42109C29EBE8E78BF9B8C66092845EB7D92AC1B381AAAAAAAAAAAAAA
    0;255;3;0;9;HMAC: 798D9FBD8E3E4730D1932EE4E4BB998B10B593631551BBB575BEC03A5C759E36
    0;255;3;0;9;TSF:MSG:READ,6-6-0,s=3,c=3,t=16,pt=0,l=0,sg=1:
    0;255;3;0;9;Skipping security for command 3 type 16
    0;255;3;0;9;SHA256: F8F8706BAAAD66823E6048248088515F8083EB545EBAF8C1DFAAAAAAAAAAAAAA
    0;255;3;0;9;Skipping security for command 3 type 17
    0;255;3;0;9;TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=17,pt=6,l=25,sg=1,ft=0,st=OK:F8F8706BAAAD66823E6048248088515F8083EB545EBAF8C1DF
    0;255;3;0;9;Transmitted nonce
    0;255;3;0;9;TSF:MSG:READ,10-10-0,s=1,c=1,t=17,pt=5,l=4,sg=0:332
    0;255;3;0;9;Message is not signed, but it should have been!
    0;255;3;0;9;!TSF:MSG:SIGN VERIFY FAIL
    0;255;3;0;9;TSF:MSG:READ,10-10-0,s=1,c=1,t=24,pt=5,l=4,sg=0:51270118
    0;255;3;0;9;Message is not signed, but it should have been!
    0;255;3;0;9;!TSF:MSG:SIGN VERIFY FAIL
    0;255;3;0;9;TSF:MSG:READ,10-10-0,s=1,c=1,t=18,pt=7,l=5,sg=0:51270.1210
    0;255;3;0;9;Message is not signed, but it should have been!
    0;255;3;0;9;!TSF:MSG:SIGN VERIFY FAIL
    0;255;3;0;9;TSF:MSG:READ,6-6-0,s=3,c=0,t=13,pt=0,l=0,sg=1:
    0;255;3;0;9;Signature in message: 0137F7F5A35542631C67BB42381A81FAB165AE75D7B5C7408F
    0;255;3;0;9;Message to process: 060006000D03
    0;255;3;0;9;Current nonce: F8F8706BAAAD66823E6048248088515F8083EB545EBAF8C1DFAAAAAAAAAAAAAA
    0;255;3;0;9;HMAC: 1237F7F5A35542631C67BB42381A81FAB165AE75D7B5C7408F3EE91419294238
    0;255;3;0;9;TSF:MSG:READ,6-6-0,s=255,c=3,t=26,pt=1,l=1,sg=1:2
    0;255;3;0;9;Skipping security for command 3 type 26
    0;255;3;0;9;Skipping security for command 3 type 16
    0;255;3;0;9;TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=16,pt=0,l=0,sg=0,ft=0,st=OK:
    0;255;3;0;9;Nonce requested from 6. Waiting...
    0;255;3;0;9;TSF:MSG:READ,6-6-0,s=255,c=3,t=17,pt=6,l=25,sg=0:84A969C4138F0268D8E015A27E2306F288252601FE54AE62A6
    0;255;3;0;9;Skipping security for command 3 type 17
    0;255;3;0;9;Nonce received from 6.
    0;255;3;0;9;Proceeding with signing...
    0;255;3;0;9;Message to process: 00060E231BFF01
    0;255;3;0;9;Current nonce: 84A969C4138F0268D8E015A27E2306F288252601FE54AE62A6AAAAAAAAAAAAAA
    0;255;3;0;9;HMAC: DB6CBDAB2875D284BE0CEA1518B86988A8CE3DC36A0B38E4BF1A35C416295EB3
    0;255;3;0;9;Signature in message: 016CBDAB2875D284BE0CEA1518B86988A8CE3DC36A0B38E4
    0;255;3;0;9;Message signed
    0;255;3;0;9;Message to send has been signed
    0;255;3;0;9;TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=27,pt=1,l=1,sg=1,ft=0,st=OK:1
    0;255;3;0;9;TSF:MSG:READ,6-6-0,s=3,c=3,t=16,pt=0,l=0,sg=1:
    0;255;3;0;9;Skipping security for command 3 type 16
    0;255;3;0;9;SHA256: D38475550145574228E4E252AB0608F22CFADB55C307F076C4AAAAAAAAAAAAAA
    0;255;3;0;9;Skipping security for command 3 type 17
    0;255;3;0;9;TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=17,pt=6,l=25,sg=1,ft=0,st=OK:D38475550145574228E4E252AB0608F22CFADB55C307F076C4
    0;255;3;0;9;Transmitted nonce
    0;255;3;0;9;TSF:MSG:READ,6-6-0,s=3,c=1,t=38,pt=7,l=5,sg=1:3.29
    0;255;3;0;9;Signature in message: 01A48C0E185B8B50EDA96A7C905C0778B16D2C78
    0;255;3;0;9;Message to process: 06002EE126035C8F524002
    0;255;3;0;9;Current nonce: D38475550145574228E4E252AB0608F22CFADB55C307F076C4AAAAAAAAAAAAAA
    0;255;3;0;9;HMAC: 8BA48C0E185B8B50EDA96A7C905C0778B16D2C78707A2959F86F0DBAF3FFE851
    0;255;3;0;9;TSF:MSG:READ,6-6-0,s=255,c=3,t=16,pt=0,l=0,sg=1:
    0;255;3;0;9;Skipping security for command 3 type 16
    0;255;3;0;9;SHA256: 028248EABB9E64FD89808ED98032CB650D3DCB81525A43BB31AAAAAAAAAAAAAA
    0;255;3;0;9;Skipping security for command 3 type 17
    0;255;3;0;9;TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=17,pt=6,l=25,sg=1,ft=0,st=OK:028248EABB9E64FD89808ED98032CB650D3DCB81525A43BB31
    0;255;3;0;9;Transmitted nonce
    0;255;3;0;9;TSF:MSG:READ,6-6-0,s=255,c=3,t=0,pt=1,l=1,sg=1:106
    0;255;3;0;9;Signature in message: 01D5CB11EFD24211E2CDCED741211AE9FF3E0AFE0AA9BBEE
    0;255;3;0;9;Message to process: 06000E2300FF6A
    0;255;3;0;9;Current nonce: 028248EABB9E64FD89808ED98032CB650D3DCB81525A43BB31AAAAAAAAAAAAAA
    0;255;3;0;9;HMAC: F5D5CB11EFD24211E2CDCED741211AE9FF3E0AFE0AA9BBEE96970EB2EF247BB5
    0;255;3;0;9;TSF:MSG:READ,6-6-0,s=1,c=3,t=16,pt=0,l=0,sg=1:
    0;255;3;0;9;Skipping security for command 3 type 16
    0;255;3;0;9;SHA256: 6DE60F283CD99033EEC6DF5DE044BE08F5151149E6DFD04FEAAAAAAAAAAAAAAA
    0;255;3;0;9;Skipping security for command 3 type 17
    0;255;3;0;9;!TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=17,pt=6,l=25,sg=1,ft=0,st=NACK:6DE60F283CD99033EEC6DF5DE044BE08F5151149E6DFD04FEA
    0;255;3;0;9;Failed to transmit nonce!
    0;255;3;0;9;TSF:MSG:READ,6-6-0,s=2,c=3,t=16,pt=0,l=0,sg=0:
    0;255;3;0;9;Skipping security for command 3 type 16
    0;255;3;0;9;SHA256: 21D7B27EEF84BF6A8ABEA9264986E7637435C28952B4477F7AAAAAAAAAAAAAAA
    0;255;3;0;9;Skipping security for command 3 type 17
    0;255;3;0;9;!TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=17,pt=6,l=25,sg=0,ft=0,st=NACK:21D7B27EEF84BF6A8ABEA9264986E7637435C28952B4477F7A
    0;255;3;0;9;Failed to transmit nonce!
    0;255;3;0;9;TSF:MSG:READ,6-6-0,s=0,c=3,t=16,pt=0,l=0,sg=0:
    0;255;3;0;9;Skipping security for command 3 type 16
    0;255;3;0;9;SHA256: 3B83A566EB5C3E32546BE372D5913CB3FA8596A2F61DC57F1FAAAAAAAAAAAAAA
    0;255;3;0;9;Skipping security for command 3 type 17
    0;255;3;0;9;!TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=17,pt=6,l=25,sg=0,ft=0,st=NACK:3B83A566EB5C3E32546BE372D5913CB3FA8596A2F61DC57F1F
    0;255;3;0;9;Failed to transmit nonce!
    0;255;3;0;9;TSF:MSG:READ,6-6-0,s=0,c=3,t=16,pt=0,l=0,sg=0:
    0;255;3;0;9;Skipping security for command 3 type 16
    0;255;3;0;9;SHA256: B6A6160EAF37C79EBCAEEE7701A6D798E2244CEB8B067A1FADAAAAAAAAAAAAAA
    0;255;3;0;9;Skipping security for command 3 type 17
    0;255;3;0;9;!TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=17,pt=6,l=25,sg=0,ft=0,st=NACK:B6A6160EAF37C79EBCAEEE7701A6D798E2244CEB8B067A1FAD
    0;255;3;0;9;Failed to transmit nonce!
    

    RF issue?


  • Contest Winner

    @alexsh1 I think the problem is that you use the GW you reported was malfunctioning where the self test reported that the atsha204a did not answer as expected. And that you now try to use that device. Since the log said that a message failed to be signed.



  • @Anticimex No, the GW I am using is Mega 2560 with W5100 not the sensebender GW.
    It has been working for many months after I resolved a power issue. However, signing is a different thing...


  • Contest Winner

    @alexsh1 seeing your latest log it appears you have rf issues. You have NACKs.



  • @Anticimex It seems that the legacy of nrf24l01+ RF communication is still chasing me ...
    :((((((

    Thank for your help



  • @Anticimex I did manage to make it after swapping a radio module:

    Node log:

    0 MCO:BGN:INIT NODE,CP=RNNNAA-,VER=2.1.1
    4 TSM:INIT
    4 TSF:WUR:MS=0
    12 TSM:INIT:TSP OK
    14 TSM:INIT:STATID=6
    16 TSF:SID:OK,ID=6
    18 TSM:FPAR
    18 Will not sign message for destination 255 as it does not require it
    61 TSF:MSG:SEND,6-6-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    245 TSF:MSG:READ,0-0-6,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    249 Skipping security for command 3 type 8
    256 TSF:MSG:FPAR OK,ID=0,D=1
    2070 TSM:FPAR:OK
    2070 TSM:ID
    2072 TSM:ID:OK
    2074 TSM:UPL
    2076 Skipping security for command 3 type 24
    2082 TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    2101 TSF:MSG:READ,0-0-6,s=255,c=3,t=25,pt=1,l=1,sg=0:1
    2107 Skipping security for command 3 type 25
    2111 TSF:MSG:PONG RECV,HP=1
    2115 TSM:UPL:OK
    2117 TSM:READY:ID=6,PAR=0,DIS=1
    2119 Signing required
    2123 Skipping security for command 3 type 15
    2129 TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0101
    2138 Waiting for GW to send signing preferences...
    2166 TSF:MSG:READ,0-0-6,s=255,c=3,t=15,pt=6,l=2,sg=0:0101
    2172 Skipping security for command 3 type 15
    2179 Mark node 0 as one that require signed messages
    2183 Mark node 0 as one that do not require whitelisting
    2189 Skipping security for command 3 type 16
    2195 TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=16,pt=0,l=0,sg=0,ft=0,st=OK:
    2203 Nonce requested from 0. Waiting...
    2207 Message to send could not be signed!
    2211 !TSF:MSG:SIGN FAIL
    2213 Skipping security for command 3 type 16
    2222 TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=16,pt=0,l=0,sg=0,ft=1,st=OK:
    2228 Nonce requested from 0. Waiting...
    2232 Message to send could not be signed!
    2236 !TSF:MSG:SIGN FAIL
    2240 TSF:MSG:READ,0-0-6,s=255,c=3,t=17,pt=6,l=25,sg=0:1BE362BF98C9E1F508502D7747DED1F8376FC361937F20CE6A
    2250 Skipping security for command 3 type 17
    2256 Nonce received from 0.
    2258 Proceeding with signing...
    Message to process: 06000E2306FF00
    Current nonce: 1BE362BF98C9E1F508502D7747DED1F8376FC361937F20CE6AAAAAAAAAAAAAAA
    HMAC: 3B9527A241A1BFB1A02E518D14912973BE3D259FC8A6CAFA402A677AEE279E20
    Signature in message: 019527A241A1BFB1A02E518D14912973BE3D259FC8A6CAFA
    2383 Message signed
    2392 TSF:MSG:READ,0-0-6,s=255,c=3,t=17,pt=6,l=25,sg=0:44401CD36C03AD558AA6503466C5DA2F01E5704FDB694FEC79
    2402 Skipping security for command 3 type 17
    2406 Nonce received from 0.
    2410 Proceeding with signing...
    Message to process: 06000E2306FF00
    Current nonce: 44401CD36C03AD558AA6503466C5DA2F01E5704FDB694FEC79AAAAAAAAAAAAAA
    HMAC: D0AE81996EB21C95474594FDB94C39A7632D3742FB4D7C2E75E765037BEE3041
    Signature in message: 01AE81996EB21C95474594FDB94C39A7632D3742FB4D7C2E
    2533 Message signed
    4239 Skipping security for command 3 type 16
    4245 TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=16,pt=0,l=0,sg=1,ft=1,st=OK:
    4253 Nonce requested from 0. Waiting...
    4284 TSF:MSG:READ,0-0-6,s=255,c=3,t=17,pt=6,l=25,sg=1:E2261FE7028EC3025346CDB70233DAEB1371B5230AAD518FC3
    4296 Skipping security for command 3 type 17
    4300 Nonce received from 0.
    4302 Proceeding with signing...
    4306 Failed to sign message!
    4308 Message to send could not be signed!
    4313 !TSF:MSG:SIGN FAIL
    4317 Skipping security for command 3 type 16
    4323 TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=16,pt=0,l=0,sg=0,ft=1,st=OK:
    4329 Nonce requested from 0. Waiting...
    4362 TSF:MSG:READ,0-0-6,s=255,c=3,t=17,pt=6,l=25,sg=0:A96C3564F5D0DFAF77FB11B256ED369DFBA6241F5089345413
    4372 Skipping security for command 3 type 17
    4376 Nonce received from 0.
    4380 Proceeding with signing...
    Message to process: 06001E030CFF312E31
    Current nonce: A96C3564F5D0DFAF77FB11B256ED369DFBA6241F5089345413AAAAAAAAAAAAAA
    HMAC: D39D3672372B7BD037D571D8D35F6F6322A7349F3148B40F286ACFA2805B82A2
    Signature in message: 019D3672372B7BD037D571D8D35F6F6322A7349F3148
    4505 Message signed
    4513 Message to send has been signed
    4519 TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=12,pt=0,l=3,sg=1,ft=0,st=OK:1.1
    4528 Skipping security for command 3 type 16
    4534 TSF:MSG:SEND,6-6-0-0,s=0,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    4542 Nonce requested from 0. Waiting...
    4663 TSF:MSG:READ,0-0-6,s=255,c=3,t=17,pt=6,l=25,sg=1:F5DCC8A96132142030ACFDE7E7EFC75232D0F27E7CD5845D5D
    4675 Skipping security for command 3 type 17
    4679 Nonce received from 0.
    4681 Proceeding with signing...
    Message to process: 060006000800
    Current nonce: F5DCC8A96132142030ACFDE7E7EFC75232D0F27E7CD5845D5DAAAAAAAAAAAAAA
    HMAC: 9EB71F4EB9B6CF53A94E491367F3BD380C87FF26C413CFD4F2798C8F52BD7A3D
    Signature in message: 01B71F4EB9B6CF53A94E491367F3BD380C87FF26C413CFD4F2
    4806 Message signed
    4814 Message to send has been signed
    4820 TSF:MSG:SEND,6-6-0-0,s=0,c=0,t=8,pt=0,l=0,sg=1,ft=0,st=OK:
    4829 Skipping security for command 3 type 16
    4835 TSF:MSG:SEND,6-6-0-0,s=1,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    4843 Nonce requested from 0. Waiting...
    4966 TSF:MSG:READ,0-0-6,s=255,c=3,t=17,pt=6,l=25,sg=1:F310284FED0D6C8F5856B3CAD3460974122858DD71EDEFD8F8
    4976 Skipping security for command 3 type 17
    4980 Nonce received from 0.
    4984 Proceeding with signing...
    Message to process: 060006000601
    Current nonce: F310284FED0D6C8F5856B3CAD3460974122858DD71EDEFD8F8AAAAAAAAAAAAAA
    HMAC: 7C53D2D46131415C36657634AF69950186687C143509D199AD8DA3358CB0F636
    Signature in message: 0153D2D46131415C36657634AF69950186687C143509D199AD
    5107 Message signed
    5115 Message to send has been signed
    5122 TSF:MSG:SEND,6-6-0-0,s=1,c=0,t=6,pt=0,l=0,sg=1,ft=0,st=OK:
    5128 Skipping security for command 3 type 16
    5136 TSF:MSG:SEND,6-6-0-0,s=2,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    5144 Nonce requested from 0. Waiting...
    5265 TSF:MSG:READ,0-0-6,s=255,c=3,t=17,pt=6,l=25,sg=1:D8B7B2BAC0485BFF1AC6CFB2312B8ABD392E776AE29670ABF1
    5277 Skipping security for command 3 type 17
    5281 Nonce received from 0.
    5283 Proceeding with signing...
    Message to process: 060006000702
    Current nonce: D8B7B2BAC0485BFF1AC6CFB2312B8ABD392E776AE29670ABF1AAAAAAAAAAAAAA
    HMAC: FC0F44D95CCF58C065DFD54B4AD7A4222067560BB3957088E7FC1D4AF82E4FF8
    Signature in message: 010F44D95CCF58C065DFD54B4AD7A4222067560BB3957088E7
    5408 Message signed
    5416 Message to send has been signed
    5427 TSF:MSG:SEND,6-6-0-0,s=2,c=0,t=7,pt=0,l=0,sg=1,ft=0,st=OK:
    5433 Skipping security for command 3 type 16
    5441 TSF:MSG:SEND,6-6-0-0,s=3,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    5447 Nonce requested from 0. Waiting...
    5568 TSF:MSG:READ,0-0-6,s=255,c=3,t=17,pt=6,l=25,sg=1:01075582171E1B52EF26C04A9F6CD20BF2A4B690F430131644
    5578 Skipping security for command 3 type 17
    5584 Nonce received from 0.
    5586 Proceeding with signing...
    Message to process: 060006000D03
    Current nonce: 01075582171E1B52EF26C04A9F6CD20BF2A4B690F430131644AAAAAAAAAAAAAA
    HMAC: 15723FF6A4D539DE67CD75B2D42D7743012DAADD2282DF2C54633BB2A0426467
    Signature in message: 01723FF6A4D539DE67CD75B2D42D7743012DAADD2282DF2C54
    5711 Message signed
    5720 Message to send has been signed
    5726 TSF:MSG:SEND,6-6-0-0,s=3,c=0,t=13,pt=0,l=0,sg=1,ft=0,st=OK:
    5732 MCO:REG:REQ
    5734 Skipping security for command 3 type 26
    5742 TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=26,pt=1,l=1,sg=1,ft=0,st=OK:2
    5851 TSF:MSG:READ,0-0-6,s=255,c=3,t=16,pt=0,l=0,sg=1:
    5857 Skipping security for command 3 type 16
    SHA256: 28366C70B76446E6C5DC055CC58108A110D2C824AB7F3F1B642845A9C0D087AE
    5937 Skipping security for command 3 type 17
    5949 TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=17,pt=6,l=25,sg=1,ft=0,st=OK:28366C70B76446E6C5DC055CC58108A110D2C824AB7F3F1B64
    5961 Transmitted nonce
    6078 TSF:MSG:READ,0-0-6,s=255,c=3,t=27,pt=1,l=1,sg=1:1
    Signature in message: 016CD1F0B409A5501C07F29F8D0CD5C1B7E39D86D679C9BB
    Message to process: 00060E231BFF01
    Current nonce: 28366C70B76446E6C5DC055CC58108A110D2C824AB7F3F1B64AAAAAAAAAAAAAA
    HMAC: 1F6CD1F0B409A5501C07F29F8D0CD5C1B7E39D86D679C9BB62AA56E3DA35E996
    6207 MCO:PIM:NODE REG=1
    6213 MCO:BGN:STP
    BME280 Pressure Sensor1.1isMetric: 1
    6535 Skipping security for command 3 type 16
    6543 TSF:MSG:SEND,6-6-0-0,s=3,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    6549 Nonce requested from 0. Waiting...
    6580 TSF:MSG:READ,0-0-6,s=255,c=3,t=17,pt=6,l=25,sg=1:F8B4C6C225F5F91BE58A32A2B45F8ACFA2D9BBC0C56DF1704E
    6592 Skipping security for command 3 type 17
    6596 Nonce received from 0.
    6598 Proceeding with signing...
    Message to process: 06002EE126033333534002
    Current nonce: F8B4C6C225F5F91BE58A32A2B45F8ACFA2D9BBC0C56DF1704EAAAAAAAAAAAAAA
    HMAC: 738C2FFDEAA1208BFA4FAA139FFEB6DD08D9A3DDE5575DC11A40A9CB7A892B49
    Signature in message: 018C2FFDEAA1208BFA4FAA139FFEB6DD08D9A3DD
    6721 Message signed
    6729 Message to send has been signed
    6735 TSF:MSG:SEND,6-6-0-0,s=3,c=1,t=38,pt=7,l=5,sg=1,ft=0,st=OK:3.30
    6744 Skipping security for command 3 type 16
    6754 TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    6762 Nonce requested from 0. Waiting...
    6881 TSF:MSG:READ,0-0-6,s=255,c=3,t=17,pt=6,l=25,sg=1:1EF21E9C248C620832C15B2B31BFA59494E58B0025A12105C7
    6891 Skipping security for command 3 type 17
    6897 Nonce received from 0.
    6899 Proceeding with signing...
    Message to process: 06000E2300FF6B
    Current nonce: 1EF21E9C248C620832C15B2B31BFA59494E58B0025A12105C7AAAAAAAAAAAAAA
    HMAC: 2EA40330191EBC1C034C9B5FE86F15BB200C897E39C01A6A001387F54A7AC87E
    Signature in message: 01A40330191EBC1C034C9B5FE86F15BB200C897E39C01A6A
    7026 Message signed
    7034 Message to send has been signed
    7041 TSF:MSG:SEND,6-6-0-0,s=255,c=3,t=0,pt=1,l=1,sg=1,ft=0,st=OK:107
    7049 MCO:BGN:INIT OK,TSP=1
    Temperature = 25.59 *C
    Humidity = 47.27 %
    Pressure = 993.82 hPa
    Forecast = unknown
    7061 Skipping security for command 3 type 16
    7071 TSF:MSG:SEND,6-6-0-0,s=1,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    7079 Nonce requested from 0. Waiting...
    7084 Message to send could not be signed!
    7088 !TSF:MSG:SIGN FAIL
    7090 Skipping security for command 3 type 16
    7096 TSF:MSG:SEND,6-6-0-0,s=2,c=3,t=16,pt=0,l=0,sg=0,ft=1,st=OK:
    7104 Nonce requested from 0. Waiting...
    7186 TSF:MSG:READ,0-0-6,s=255,c=3,t=17,pt=6,l=25,sg=1:A534CA40967C4BF2319ECB1E9F78A46DAE29876C512FA43068
    7196 Skipping security for command 3 type 17
    7202 Nonce received from 0.
    7204 Proceeding with signing...
    Message to process: 0600160407E307FD
    Current nonce: A534CA40967C4BF2319ECB1E9F78A46DAE29876C512FA43068AAAAAAAAAAAAAA
    HMAC: DF63A40176DC348626CCF63EF31FDF9B381922BBA1035A00F48475B533B1FFB8
    Signature in message: 0163A40176DC348626CCF63EF31FDF9B381922BBA1035A
    7331 Message signed
    7340 TSF:MSG:READ,0-0-6,s=255,c=3,t=17,pt=6,l=25,sg=0:CDABB60B9D503D264DE301FC0E70DBB3F14A5682D1D519643A
    7352 Skipping security for command 3 type 17
    7356 Nonce received from 0.
    7358 Proceeding with signing...
    Message to process: 0600160407E30802
    Current nonce: CDABB60B9D503D264DE301FC0E70DBB3F14A5682D1D519643AAAAAAAAAAAAAAA
    HMAC: B9D87BB4381C95DE3F87DB59BF7F8A3B78596AB1779ABD8A9D7000539D0FC9B3
    Signature in message: 01D87BB4381C95DE3F87DB59BF7F8A3B78596AB1779ABD
    7483 Message signed
    7491 Message to send has been signed
    7497 TSF:MSG:SEND,6-6-0-0,s=227,c=4,t=7,pt=0,l=2,sg=1,ft=0,st=OK:
    7505 Skipping security for command 3 type 16
    7512 TSF:MSG:SEND,6-6-0-0,s=0,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    7520 Nonce requested from 0. Waiting...
    7524 Message to send could not be signed!
    7528 !TSF:MSG:SIGN FAIL
    7530 Skipping security for command 3 type 16
    7536 TSF:MSG:SEND,6-6-0-0,s=0,c=3,t=16,pt=0,l=0,sg=0,ft=1,st=OK:
    7544 Nonce requested from 0. Waiting...
    7548 Message to send could not be signed!
    7553 !TSF:MSG:SIGN FAIL
    7606 MCO:SLP:MS=300000,SMS=0,I1=255,M1=255,I2=255,M2=255
    7612 MCO:SLP:TPD
    

    But it still throws many SIGN FAIL.


  • Contest Winner

    @alexsh1 the log still looks like you sometimes don't get the nonce you requested so signing times out and fails. I am still quite sure that if you looked in the log on the other side, it would show NACKs on some nonce transmissions. Signing won't work when those fail.



  • @Anticimex This is what we discussed before, this is not a signing issue. Guess what? I did notice that RF is much better with non-amplified nrf24l01+. Given my experience in the past with nrf24l01+ pa+lna, I have just soldered out and replaced AMS1117-3.3V (Mega 2560 works on 5V so I need a stable 3.3V source, which I cannot take from Mega's 3.3V pin for a hungry nrf24l01+pa+lna) and signing started working!

    0 MCO:BGN:INIT NODE,CP=RNNNAS-,VER=2.1.1
    4 TSM:INIT
    4 TSF:WUR:MS=0
    12 TSM:INIT:TSP OK
    14 TSM:INIT:STATID=15
    16 TSF:SID:OK,ID=15
    18 TSM:FPAR
    20 Will not sign message for destination 255 as it does not require it
    63 TSF:MSG:SEND,15-15-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    1026 TSF:MSG:READ,0-0-15,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    1032 Skipping security for command 3 type 8
    1038 TSF:MSG:FPAR OK,ID=0,D=1
    2070 TSM:FPAR:OK
    2070 TSM:ID
    2072 TSM:ID:OK
    2074 TSM:UPL
    2076 Skipping security for command 3 type 24
    2082 TSF:MSG:SEND,15-15-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    2111 TSF:MSG:READ,0-0-15,s=255,c=3,t=25,pt=1,l=1,sg=0:1
    2117 Skipping security for command 3 type 25
    2121 TSF:MSG:PONG RECV,HP=1
    2123 TSM:UPL:OK
    2125 TSM:READY:ID=15,PAR=0,DIS=1
    2129 Signing required
    2131 Skipping security for command 3 type 15
    2140 TSF:MSG:SEND,15-15-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0101
    2148 Waiting for GW to send signing preferences...
    2181 TSF:MSG:READ,0-0-15,s=255,c=3,t=15,pt=6,l=2,sg=0:0101
    2187 Skipping security for command 3 type 15
    2191 Mark node 0 as one that require signed messages
    2197 Mark node 0 as one that do not require whitelisting
    2203 Skipping security for command 3 type 16
    2211 TSF:MSG:SEND,15-15-0-0,s=255,c=3,t=16,pt=0,l=0,sg=0,ft=0,st=OK:
    2220 Nonce requested from 0. Waiting...
    2275 TSF:MSG:READ,0-0-15,s=255,c=3,t=17,pt=6,l=25,sg=0:BC9F06296E185623C02C586CECB3CBA37A7AD097699C918CB1
    2287 Skipping security for command 3 type 17
    2291 Nonce received from 0.
    2295 Proceeding with signing...
    Message to process: 0F002E0011FF322E312E31
    Current nonce: BC9F06296E185623C02C586CECB3CBA37A7AD097699C918CB1AAAAAAAAAAAAAA
    HMAC: D96C3B9964666D36495BBAF4E6C4E414088A553065E8CCA764CD8DF65D6353CA
    Signature in message: 016C3B9964666D36495BBAF4E6C4E414088A5530
    2469 Message signed
    2478 Message to send has been signed
    2486 TSF:MSG:SEND,15-15-0-0,s=255,c=0,t=17,pt=0,l=5,sg=1,ft=0,st=OK:2.1.1
    2494 Skipping security for command 3 type 16
    2502 TSF:MSG:SEND,15-15-0-0,s=255,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    2510 Nonce requested from 0. Waiting...
    2643 TSF:MSG:READ,0-0-15,s=255,c=3,t=17,pt=6,l=25,sg=1:556C16AFC48CBCC8758A6D0BA0CA9920BAAFB13290AC599CC1
    2656 Skipping security for command 3 type 17
    2660 Nonce received from 0.
    2662 Proceeding with signing...
    Message to process: 0F000E2306FF00
    Current nonce: 556C16AFC48CBCC8758A6D0BA0CA9920BAAFB13290AC599CC1AAAAAAAAAAAAAA
    HMAC: 598965B2F76BF9805E79A23C9CDBEA71A5F0B5749D4E2FA44C3DEDDAD21B3238
    Signature in message: 018965B2F76BF9805E79A23C9CDBEA71A5F0B5749D4E2FA4
    2838 Message signed
    2844 Message to send has been signed
    2854 TSF:MSG:SEND,15-15-0-0,s=255,c=3,t=6,pt=1,l=1,sg=1,ft=0,st=OK:0
    3801 TSF:MSG:READ,0-0-15,s=255,c=3,t=16,pt=0,l=0,sg=1:
    3807 Skipping security for command 3 type 16
    SHA256: 46DEE622257BDFA07B804BA9C02440CC083DC010C7A609123900000000000000
    3842 Skipping security for command 3 type 17
    3858 TSF:MSG:SEND,15-15-0-0,s=255,c=3,t=17,pt=6,l=25,sg=1,ft=0,st=OK:46DEE622257BDFA07B804BA9C02440CC083DC010C7A6091239
    3870 Transmitted nonce
    4012 TSF:MSG:READ,0-0-15,s=255,c=3,t=6,pt=0,l=1,sg=1:M
    Signature in message: 018AF802A7325E4D37B322FA8B0F4BA61CA5DF6548CEE589
    Message to process: 000F0E0306FF4D
    Current nonce: 46DEE622257BDFA07B804BA9C02440CC083DC010C7A6091239AAAAAAAAAAAAAA
    HMAC: DA8AF802A7325E4D37B322FA8B0F4BA61CA5DF6548CEE58953ADF17286D22669
    4190 Skipping security for command 3 type 16
    4202 TSF:MSG:SEND,15-15-0-0,s=255,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    4208 Nonce requested from 0. Waiting...
    4255 TSF:MSG:READ,0-0-15,s=255,c=3,t=17,pt=6,l=25,sg=1:90818AAA44B6AFD7880153E7AA7E981981744CC98028809A09
    4265 Skipping security for command 3 type 17
    4272 Nonce received from 0.
    4274 Proceeding with signing...
    Message to process: 0F00B6030BFF424D503238302050726573737572652053656E736F72
    Current nonce: 90818AAA44B6AFD7880153E7AA7E981981744CC98028809A09AAAAAAAAAAAAAA
    HMAC: 486FAFD76801F66D900E883F2C012B7104EE043ABC68E0AE894D0026E9D7A8AB
    Signature in message: 016FAF
    4448 Message signed
    4456 Message to send has been signed
    4466 TSF:MSG:SEND,15-15-0-0,s=255,c=3,t=11,pt=0,l=22,sg=1,ft=0,st=OK:BMP280 Pressure Sensor
    4476 Skipping security for command 3 type 16
    4483 TSF:MSG:SEND,15-15-0-0,s=255,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    4491 Nonce requested from 0. Waiting...
    4642 TSF:MSG:READ,0-0-15,s=255,c=3,t=17,pt=6,l=25,sg=1:A3B017C2562256E455C640C28667B9BB3D3062687A5C49160C
    4655 Skipping security for command 3 type 17
    4659 Nonce received from 0.
    4661 Proceeding with signing...
    Message to process: 0F001E030CFF312E31
    Current nonce: A3B017C2562256E455C640C28667B9BB3D3062687A5C49160CAAAAAAAAAAAAAA
    HMAC: F27274FF114AE80AE6217C1B2B80A322AB82697AF3BFBE59BC53069948AA234A
    Signature in message: 017274FF114AE80AE6217C1B2B80A322AB82697AF3BF
    4837 Message signed
    4843 Message to send has been signed
    4853 TSF:MSG:SEND,15-15-0-0,s=255,c=3,t=12,pt=0,l=3,sg=1,ft=0,st=OK:1.1
    4861 Skipping security for command 3 type 16
    4868 TSF:MSG:SEND,15-15-0-0,s=0,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    4876 Nonce requested from 0. Waiting...
    9881 Timeout waiting for nonce!
    9883 !TSF:MSG:SIGN FAIL
    9885 Skipping security for command 3 type 16
    9895 TSF:MSG:SEND,15-15-0-0,s=1,c=3,t=16,pt=0,l=0,sg=1,ft=1,st=OK:
    9904 Nonce requested from 0. Waiting...
    9957 TSF:MSG:READ,0-0-15,s=255,c=3,t=17,pt=6,l=25,sg=1:B91AB74E50528ACC3F64B480A47D6CEB269E2EA48004C57A7F
    9967 Skipping security for command 3 type 17
    9971 Nonce received from 0.
    9975 Proceeding with signing...
    Message to process: 0F0006000601
    Current nonce: B91AB74E50528ACC3F64B480A47D6CEB269E2EA48004C57A7FAAAAAAAAAAAAAA
    HMAC: A95DB25F392535043F3DEA960F6C2136115A29AF51F6B11D4E0BFFB7ABE9946E
    Signature in message: 015DB25F392535043F3DEA960F6C2136115A29AF51F6B11D4E
    10149 Message signed
    10158 Message to send has been signed
    10168 TSF:MSG:SEND,15-15-0-0,s=1,c=0,t=6,pt=0,l=0,sg=1,ft=0,st=OK:
    10174 Skipping security for command 3 type 16
    10182 TSF:MSG:SEND,15-15-0-0,s=2,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    10188 Nonce requested from 0. Waiting...
    15194 Message to send could not be signed!
    15198 !TSF:MSG:SIGN FAIL
    15200 MCO:REG:REQ
    15202 Skipping security for command 3 type 26
    15212 TSF:MSG:SEND,15-15-0-0,s=255,c=3,t=26,pt=1,l=1,sg=1,ft=1,st=OK:2
    15230 TSF:MSG:READ,0-0-15,s=255,c=3,t=16,pt=0,l=0,sg=1:
    15237 Skipping security for command 3 type 16
    SHA256: 6F1E9148E2B8755A2B5019D803BBE9E531F1B5507406B58820AAAAAAAAAAAAAA
    15271 Skipping security for command 3 type 17
    15286 TSF:MSG:SEND,15-15-0-0,s=255,c=3,t=17,pt=6,l=25,sg=1,ft=0,st=OK:6F1E9148E2B8755A2B5019D803BBE9E531F1B5507406B58820
    15298 Transmitted nonce
    15429 TSF:MSG:READ,0-0-15,s=255,c=3,t=27,pt=1,l=1,sg=1:1
    Signature in message: 01B4B105F62283F53943B57B3B2B034B44DA23B4D71C97A1
    Message to process: 000F0E231BFF01
    Current nonce: 6F1E9148E2B8755A2B5019D803BBE9E531F1B5507406B58820AAAAAAAAAAAAAA
    HMAC: B3B4B105F62283F53943B57B3B2B034B44DA23B4D71C97A14CE49895135B98FA
    15607 MCO:PIM:NODE REG=1
    15613 MCO:BGN:STP
    Pressure Sensor BMP280 1.1
    isMetric: 1
    15628 Skipping security for command 3 type 16
    15638 TSF:MSG:SEND,15-15-0-0,s=2,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    15646 Nonce requested from 0. Waiting...
    15683 TSF:MSG:READ,0-0-15,s=255,c=3,t=17,pt=6,l=25,sg=1:4EDBAA807BB751EFD72E54A450E8B76C3B45D503270FF3C9C6
    15693 Skipping security for command 3 type 17
    15699 Nonce received from 0.
    15702 Proceeding with signing...
    Message to process: 0F002EE1260285EB514002
    Current nonce: 4EDBAA807BB751EFD72E54A450E8B76C3B45D503270FF3C9C6AAAAAAAAAAAAAA
    HMAC: 66D0E5314979BE6AC80387B12A6A8CF79AAB4C325F64A6762176D35C4E36C369
    Signature in message: 01D0E5314979BE6AC80387B12A6A8CF79AAB4C32
    15878 Message signed
    15884 Message to send has been signed
    15894 TSF:MSG:SEND,15-15-0-0,s=2,c=1,t=38,pt=7,l=5,sg=1,ft=0,st=OK:3.28
    15902 Skipping security for command 3 type 16
    15910 TSF:MSG:SEND,15-15-0-0,s=255,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    15919 Nonce requested from 0. Waiting...
    16048 TSF:MSG:READ,0-0-15,s=255,c=3,t=17,pt=6,l=25,sg=1:7E290F0590861636DF52F69D21796856F958F03E7956953C8D
    16060 Skipping security for command 3 type 17
    16064 Nonce received from 0.
    16068 Proceeding with signing...
    Message to process: 0F000E2300FF69
    Current nonce: 7E290F0590861636DF52F69D21796856F958F03E7956953C8DAAAAAAAAAAAAAA
    HMAC: 164ABE25D777EE3EA65F536ADE147D60B404561D07A26CA156E25EBB234507E0
    Signature in message: 014ABE25D777EE3EA65F536ADE147D60B404561D07A26CA1
    16242 Message signed
    16250 Message to send has been signed
    16261 TSF:MSG:SEND,15-15-0-0,s=255,c=3,t=0,pt=1,l=1,sg=1,ft=0,st=OK:105
    16269 MCO:BGN:INIT OK,TSP=1
    Temperature = 24.96 *C
    Pressure = 997.80 mBar
    Forecast = unknown
    16277 Skipping security for command 3 type 16
    16287 TSF:MSG:SEND,15-15-0-0,s=1,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    16295 Nonce requested from 0. Waiting...
    16410 TSF:MSG:READ,0-0-15,s=255,c=3,t=17,pt=6,l=25,sg=1:E4C3BDA88C3EFFD0A435849C1199E79C9D2B215FA1D05A7E76
    16422 Skipping security for command 3 type 17
    16427 Nonce received from 0.
    16431 Proceeding with signing...
    Message to process: 0F002EE1000114AEC74101
    Current nonce: E4C3BDA88C3EFFD0A435849C1199E79C9D2B215FA1D05A7E76AAAAAAAAAAAAAA
    HMAC: 144BFD3C6A7CBE0DC1CCEEC102FDA3E3A15C1A5A22BA604A5F5CAEE2F682BE37
    Signature in message: 014BFD3C6A7CBE0DC1CCEEC102FDA3E3A15C1A5A
    16605 Message signed
    16613 Message to send has been signed
    16623 TSF:MSG:SEND,15-15-0-0,s=1,c=1,t=0,pt=7,l=5,sg=1,ft=0,st=OK:25.0
    16631 Skipping security for command 3 type 16
    16637 TSF:MSG:SEND,15-15-0-0,s=0,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    16646 Nonce requested from 0. Waiting...
    16766 TSF:MSG:READ,0-0-15,s=255,c=3,t=17,pt=6,l=25,sg=1:0E091DD4985125377E63651907B9830D4D7265831F17FD65FE
    16779 Skipping security for command 3 type 17
    16783 Nonce received from 0.
    16787 Proceeding with signing...
    Message to process: 0F002EE104002973794400
    Current nonce: 0E091DD4985125377E63651907B9830D4D7265831F17FD65FEAAAAAAAAAAAAAA
    HMAC: A157ECB56A03D70529E1F9A26D972AF3EB1332FB20E2A3CDD909D5A8B9F7A8C4
    Signature in message: 0157ECB56A03D70529E1F9A26D972AF3EB1332FB
    16961 Message signed
    16969 Message to send has been signed
    16975 TSF:MSG:SEND,15-15-0-0,s=0,c=1,t=4,pt=7,l=5,sg=1,ft=0,st=OK:998
    16984 Skipping security for command 3 type 16
    16992 TSF:MSG:SEND,15-15-0-0,s=0,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    16998 Nonce requested from 0. Waiting...
    17129 TSF:MSG:READ,0-0-15,s=255,c=3,t=17,pt=6,l=25,sg=1:E7504291BD4FE363A66BD9A571064AFEB381F5282651DB1040
    17141 Skipping security for command 3 type 17
    17145 Nonce received from 0.
    17149 Proceeding with signing...
    Message to process: 0F003E010500756E6B6E6F776E
    Current nonce: E7504291BD4FE363A66BD9A571064AFEB381F5282651DB1040AAAAAAAAAAAAAA
    HMAC: 9E56ED49FE4589E4F61D7A954CF433334527DB1D8BC515183834201570327BF5
    Signature in message: 0156ED49FE4589E4F61D7A954CF433334527
    17324 Message signed
    17332 Message to send has been signed
    17342 TSF:MSG:SEND,15-15-0-0,s=0,c=1,t=5,pt=0,l=7,sg=1,ft=0,st=OK:unknown
    17448 MCO:SLP:MS=300000,SMS=0,I1=255,M1=255,I2=255,M2=255
    17455 MCO:SLP:TPD
    
    

    This is the second time I change AMS1117 in one year. Very odd
    Anyway, very much appreciate your help on signing! Very helpful


  • Contest Winner

    @alexsh1 glad you got it working again 🙂



  • @Anticimex Last time, I took me moths to resolve it. AMS1117 has not failed completely, but was working intermittently. This had a major impact on how nrf24l01+pa+lna was working. Unfortunately, range and signing were affected.
    My theory is that it is getting probably 45-50C in my GW - there are many wires and it is a very tight fit. This may contribute in such AMS1117 behavior. Or probably just a bad batch.


  • Contest Winner

    @alexsh1 sounds like it. I've always considered the AMS1117 to be a trustworthy part.



  • @Anticimex it seems that replacing AMS1117 has resolved the issue.

    I have a poor reception in one particular place and was thinking about a repeater node. Is signing working fine with the repeater node (both the node and the repeater are going to force signing by "MY_SIGNING_REQUEST_SIGNATURES"? Just curious


  • Contest Winner

    @alexsh1 repeaters support signing even if it isn't enabled on the repeater. It simply forwards the message and signature (and nonce).
    Glad you resolved the issue 👍



  • @Anticimex so no need to enable signing if this is just a repeater node? (No sleeping just waiting)

    Yeah, every time it takes me quicker and quicker to troubleshoot mysensors 😉
    Obviously, thanks to your excellent support


  • Contest Winner

    @alexsh1 it never hurts to enable signing. It is not the same as requiring signatures. But no, you should not have to. I am just glad to help 🙂



  • I have been playing with 2.2.0 beta
    Security personalisation went fine for sensebender GW (serial), but signing is not working. Any ideas please?

    0;255;3;0;9;4840 MCO:BGN:INIT GW,CP=RNNGSA--,VER=2.2.0-beta
    0;255;3;0;9;4964 Could not read ATSHA204A lock config, refusing to use backend```

  • Contest Winner

    @alexsh1 only that you have the atsha pin misconfigured in your gw sketch.



  • @Anticimex This is a standard GW sketch:
    atsha204 pin is A3 (17). Cannot understand whats wrong...

    /**
    * The MySensors Arduino library handles the wireless radio link and protocol
    * between your home built sensors/actuators and HA controller of choice.
    * The sensors forms a self healing radio network with optional repeaters. Each
    * repeater and gateway builds a routing tables in EEPROM which keeps track of the
    * network topology allowing messages to be routed to nodes.
    *
    * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
    * Copyright (C) 2013-2015 Sensnology AB
    * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
    *
    * Documentation: http://www.mysensors.org
    * Support Forum: http://forum.mysensors.org
    *
    * This program is free software; you can redistribute it and/or
    * modify it under the terms of the GNU General Public License
    * version 2 as published by the Free Software Foundation.
    *
    *******************************
    *
    * DESCRIPTION
    * The ArduinoGateway prints data received from sensors on the serial link.
    * The gateway accepts input on seral which will be sent out on radio network.
    *
    * The GW code is designed for Arduino Nano 328p / 16MHz
    *
    * Wire connections (OPTIONAL):
    * - Inclusion button should be connected between digital pin 3 and GND
    * - RX/TX/ERR leds need to be connected between +5V (anode) and digital pin 6/5/4 with resistor 270-330R in a series
    *
    * LEDs (OPTIONAL):
    * - To use the feature, uncomment any of the MY_DEFAULT_xx_LED_PINs
    * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
    * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
    * - ERR (red) - fast blink on error during transmission error or recieve crc error
    *
    */
    #define MY_DEBUG
    #define MY_DEBUG_VERBOSE_SIGNING
    #define MY_SPECIAL_DEBUG
    
    #define MY_SIGNING_ATSHA204
    #define MY_SIGNING_REQUEST_SIGNATURES
    #define MY_SIGNING_ATSHA204_PIN 17
    
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    #define MY_NODE_ID 18
    //#define MY_PARENT_NODE_ID 0
    //#define MY_RADIO_RFM69
    
    // Enabled repeater feature for this node
    #define MY_REPEATER_FEATURE
    
    // Set LOW transmit power level as default, if you have an amplified NRF-module and
    // power your radio separately with a good regulator you can turn up PA level.
    #define MY_RF24_PA_LEVEL RF24_PA_LOW
    
    // Enable serial gateway
    #define MY_GATEWAY_SERIAL
    
    // Define a lower baud rate for Arduino's running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
    #if F_CPU == 8000000L
    #define MY_BAUD_RATE 38400
    #endif
    
    // 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
    
    // Set blinking period
    #define MY_DEFAULT_LED_BLINK_PERIOD 300
    
    // Inverses the behavior of leds
    //#define MY_WITH_LEDS_BLINKING_INVERSE
    
    // Flash leds on rx/tx/err
    // Uncomment to override default HW configurations
    //#define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
    //#define MY_DEFAULT_RX_LED_PIN  6  // Receive led pin
    //#define MY_DEFAULT_TX_LED_PIN  5  // the PCB, on board LED
    
    #include <MySensors.h>
    
    void setup()
    {
    	// Setup locally attached sensors
    }
    
    void presentation()
    {
    	// Present locally attached sensors
    }
    
    void loop()
    {
    	// Send locally attached sensor data here
    }
    

  • Contest Winner

    @alexsh1 I don't think A3 is valid for samd targets.


  • Contest Winner

    @alexsh1 there is a special gw sketch for the SenseBender gw. Are you using that? SensebenderGatewaySerial.ino


  • Contest Winner

    @alexsh1 I think the SenseBender automatically assigns the appropriate atsha pin so if you run the SenseBender gw sketch you should not need to configure it.



  • @Anticimex No, I was using a standard GW Serial sketch. I cannot compile the sensebenderserial.ino under 2.2.0 dev:

    ........................
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:96:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:6:16: error: redefinition of 'uint8_t device_pin'
    
     static uint8_t device_pin;
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:155:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:94:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:6:16: error: 'uint8_t device_pin' previously declared here
    
     static uint8_t device_pin;
    
                    ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:96:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'void swi_set_signal_pin(uint8_t)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:23:13: error: redefinition of 'void swi_set_signal_pin(uint8_t)'
    
     static void swi_set_signal_pin(uint8_t is_high)
    
                 ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:155:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:94:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:23:13: error: 'void swi_set_signal_pin(uint8_t)' previously defined here
    
     static void swi_set_signal_pin(uint8_t is_high)
    
                 ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:96:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t swi_send_bytes(uint8_t, uint8_t*)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:34:16: error: redefinition of 'uint8_t swi_send_bytes(uint8_t, uint8_t*)'
    
     static uint8_t swi_send_bytes(uint8_t count, uint8_t *buffer)
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:155:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:94:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:34:16: error: 'uint8_t swi_send_bytes(uint8_t, uint8_t*)' previously defined here
    
     static uint8_t swi_send_bytes(uint8_t count, uint8_t *buffer)
    
                    ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:96:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t swi_send_byte(uint8_t)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:73:16: error: redefinition of 'uint8_t swi_send_byte(uint8_t)'
    
     static uint8_t swi_send_byte(uint8_t value)
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:155:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:94:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:73:16: error: 'uint8_t swi_send_byte(uint8_t)' previously defined here
    
     static uint8_t swi_send_byte(uint8_t value)
    
                    ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:96:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t swi_receive_bytes(uint8_t, uint8_t*)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:78:16: error: redefinition of 'uint8_t swi_receive_bytes(uint8_t, uint8_t*)'
    
     static uint8_t swi_receive_bytes(uint8_t count, uint8_t *buffer)
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:155:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:94:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:78:16: error: 'uint8_t swi_receive_bytes(uint8_t, uint8_t*)' previously defined here
    
     static uint8_t swi_receive_bytes(uint8_t count, uint8_t *buffer)
    
                    ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:96:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t sha204p_receive_response(uint8_t, uint8_t*)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:177:16: error: redefinition of 'uint8_t sha204p_receive_response(uint8_t, uint8_t*)'
    
     static uint8_t sha204p_receive_response(uint8_t size, uint8_t *response)
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:155:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:94:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:177:16: error: 'uint8_t sha204p_receive_response(uint8_t, uint8_t*)' previously defined here
    
     static uint8_t sha204p_receive_response(uint8_t size, uint8_t *response)
    
                    ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:96:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t sha204c_resync(uint8_t, uint8_t*)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:211:16: error: redefinition of 'uint8_t sha204c_resync(uint8_t, uint8_t*)'
    
     static uint8_t sha204c_resync(uint8_t size, uint8_t *response)
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:155:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:94:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:211:16: error: 'uint8_t sha204c_resync(uint8_t, uint8_t*)' previously defined here
    
     static uint8_t sha204c_resync(uint8_t size, uint8_t *response)
    
                    ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:96:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t sha204c_send_and_receive(uint8_t*, uint8_t, uint8_t*, uint8_t, uint8_t)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:233:16: error: redefinition of 'uint8_t sha204c_send_and_receive(uint8_t*, uint8_t, uint8_t*, uint8_t, uint8_t)'
    
     static uint8_t sha204c_send_and_receive(uint8_t *tx_buffer, uint8_t rx_size, uint8_t *rx_buffer,
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:155:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:94:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:233:16: error: 'uint8_t sha204c_send_and_receive(uint8_t*, uint8_t, uint8_t*, uint8_t, uint8_t)' previously defined here
    
     static uint8_t sha204c_send_and_receive(uint8_t *tx_buffer, uint8_t rx_size, uint8_t *rx_buffer,
    
                    ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:96:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'void sha204c_calculate_crc(uint8_t, uint8_t*, uint8_t*)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:377:13: error: redefinition of 'void sha204c_calculate_crc(uint8_t, uint8_t*, uint8_t*)'
    
     static void sha204c_calculate_crc(uint8_t length, uint8_t *data, uint8_t *crc)
    
                 ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:155:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:94:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:377:13: error: 'void sha204c_calculate_crc(uint8_t, uint8_t*, uint8_t*)' previously defined here
    
     static void sha204c_calculate_crc(uint8_t length, uint8_t *data, uint8_t *crc)
    
                 ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:96:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t sha204c_check_crc(uint8_t*)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:402:16: error: redefinition of 'uint8_t sha204c_check_crc(uint8_t*)'
    
     static uint8_t sha204c_check_crc(uint8_t *response)
    
                    ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:155:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:94:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:402:16: error: 'uint8_t sha204c_check_crc(uint8_t*)' previously defined here
    
     static uint8_t sha204c_check_crc(uint8_t *response)
    
                    ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:96:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'void atsha204_init(uint8_t)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:416:6: error: redefinition of 'void atsha204_init(uint8_t)'
    
     void atsha204_init(uint8_t pin)
    
          ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:155:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:94:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:416:6: error: 'void atsha204_init(uint8_t)' previously defined here
    
     void atsha204_init(uint8_t pin)
    
          ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:96:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'void atsha204_idle()':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:433:6: error: redefinition of 'void atsha204_idle()'
    
     void atsha204_idle(void)
    
          ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:155:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:94:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:433:6: error: 'void atsha204_idle()' previously defined here
    
     void atsha204_idle(void)
    
          ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:96:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'void atsha204_sleep()':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:438:6: error: redefinition of 'void atsha204_sleep()'
    
     void atsha204_sleep(void)
    
          ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:155:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:94:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:438:6: error: 'void atsha204_sleep()' previously defined here
    
     void atsha204_sleep(void)
    
          ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:96:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t atsha204_wakeup(uint8_t*)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:443:9: error: redefinition of 'uint8_t atsha204_wakeup(uint8_t*)'
    
     uint8_t atsha204_wakeup(uint8_t *response)
    
             ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:155:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:94:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:443:9: error: 'uint8_t atsha204_wakeup(uint8_t*)' previously defined here
    
     uint8_t atsha204_wakeup(uint8_t *response)
    
             ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:96:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t atsha204_execute(uint8_t, uint8_t, uint16_t, uint8_t, uint8_t*, uint8_t, uint8_t*, uint8_t, uint8_t*)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:473:9: error: redefinition of 'uint8_t atsha204_execute(uint8_t, uint8_t, uint16_t, uint8_t, uint8_t*, uint8_t, uint8_t*, uint8_t, uint8_t*)'
    
     uint8_t atsha204_execute(uint8_t op_code, uint8_t param1, uint16_t param2,
    
             ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:155:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:94:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:473:9: error: 'uint8_t atsha204_execute(uint8_t, uint8_t, uint16_t, uint8_t, uint8_t*, uint8_t, uint8_t*, uint8_t, uint8_t*)' previously defined here
    
     uint8_t atsha204_execute(uint8_t op_code, uint8_t param1, uint16_t param2,
    
             ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:96:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t atsha204_getSerialNumber(uint8_t*)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:549:9: error: redefinition of 'uint8_t atsha204_getSerialNumber(uint8_t*)'
    
     uint8_t atsha204_getSerialNumber(uint8_t * response)
    
             ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:155:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:94:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:549:9: error: 'uint8_t atsha204_getSerialNumber(uint8_t*)' previously defined here
    
     uint8_t atsha204_getSerialNumber(uint8_t * response)
    
             ^
    
    In file included from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:96:0:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp: In function 'uint8_t atsha204_read(uint8_t*, uint8_t*, uint8_t, uint16_t)':
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:578:9: error: redefinition of 'uint8_t atsha204_read(uint8_t*, uint8_t*, uint8_t, uint16_t)'
    
     uint8_t atsha204_read(uint8_t *tx_buffer, uint8_t *rx_buffer, uint8_t zone, uint16_t address)
    
             ^
    
    In file included from C:\Users\Alex\Documents\Arduino\libraries\MySensors/MySensors.h:155:0,
    
                     from C:\Users\Alex\AppData\Local\Temp\arduino_modified_sketch_501069\SensebenderGatewaySerial.ino:94:
    
    C:\Users\Alex\Documents\Arduino\libraries\MySensors/drivers/ATSHA204/ATSHA204.cpp:578:9: error: 'uint8_t atsha204_read(uint8_t*, uint8_t*, uint8_t, uint16_t)' previously defined here
    
     uint8_t atsha204_read(uint8_t *tx_buffer, uint8_t *rx_buffer, uint8_t zone, uint16_t address)
    
             ^
    
    Multiple libraries were found for "SD.h"
     Used: C:\Users\Alex\Documents\Arduino\libraries\SD
     Not used: C:\Program Files (x86)\Arduino\libraries\SD
    Using library MySensors at version 2.2.0-beta in folder: C:\Users\Alex\Documents\Arduino\libraries\MySensors 
    Using library Wire at version 1.0 in folder: C:\Users\Alex\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12\libraries\Wire 
    Using library SPI at version 1.0 in folder: C:\Users\Alex\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12\libraries\SPI 
    Using library SD at version 1.1.1 in folder: C:\Users\Alex\Documents\Arduino\libraries\SD 
    exit status 1
    Error compiling for board Sensebender Gateway.
    

  • Contest Winner

    @alexsh1 Well, you need to use the sensebenderserial.ino if you want to run a serial gw on the sensebender board.
    Why have you modified the sketch? You should not touch HW configurations for the sensebender sketch as it is a predefined board unless you have a customized sensebender board or made your own PCB.



  • @Anticimex All I modified was adding this for signing:

    #define MY_SIGNING_ATSHA204
    #define MY_SIGNING_REQUEST_SIGNATURES
    #define MY_SIGNING_ATSHA204_PIN 17
    

    Is signing working without these lines on SAMD?


  • Contest Winner

    @alexsh1 Yes but why? The sensebender is not a AVR board. How do you know that "pin 17" is valid pin for ATSHA in a sensebender board? I can almost guarantee that it is not, and if you have picked the board in the board manager as your target board, the appropriate ATSHA pin will be configured for you. You do not need to (and in fact you should not) define a pin for the ATSHA on a sensebender board, as it is natively supported by the board.
    So what you have done here is to actually override the default for the board to something that is wrong, so communication with the atsha will fail, as it uses the wrong pin.
    Edit: And no, signing will not work if you have not enabled it. You have to enable MY_SIGNING_ATSHA204 (or MY_SIGNING_SOFT) to support signing in all cases. Requesting signatures is depending on your personal preference. The pin should only be defined if you know what it is supposed to be for your target HW. Usually it is automatically assigned if the board is "known".



  • @Anticimex You are right - I am looking into the sensebender GW docs and I think it is PA11 pin where pin 3 of atsha204 is connected. Apologies - my experience with SAMD is still very limited. I deleted the three lines above with signing and the sketch does compile. However, as soon as I add:

    #define MY_SIGNING_ATSHA204
    

    Compiling breaks


  • Contest Winner

    @alexsh1 Can you please be a bit more elaborate on what "Compiling breaks" mean? @tbowmo a known issue?


Log in to reply
 

Suggested Topics

19
Online

11.4k
Users

11.1k
Topics

112.7k
Posts