Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. [security] Introducing signing support to MySensors

[security] Introducing signing support to MySensors

Scheduled Pinned Locked Moved Development
security
491 Posts 48 Posters 334.1k Views 30 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • scalzS Offline
    scalzS Offline
    scalz
    Hardware Contributor
    wrote on last edited by scalz
    #83

    wow. can't wait to see your creations! Seems interesting. Your board could be very helpful.
    I love Sensebender. But 0402, it was difficult to solder for me! So I am trying to use 0805 in my designs, easier for me.
    I am finishing to modify a moteino (0805 so a little bigger) to add nrf and atsha. I am waiting for others boards (not received yet) : uCurrent module, one power management optimization board (based on ulpnode idea), esp8266-07 with nrf, rfm and atsha (I will try to make sort of mqtt gateway), and a mysensors relay board. I have others idea too: dimmer for one main, hb100 (for barrier security), mgc3030 (for gesture. lot of stuff on this one I think). But before I must finish what I started. Hihi, mysensors and automation is addictive!

    I read in previous post that you advised not to use A6,A7 for atsha. But I imagine that I can use others pin (if i take care of datasheet of course)? I think it is doable, just have to modify pin ref in code next, isn't it? Anyway, I always try to keep mysensors reference design (A3), it is just for personal info.

    AnticimexA 2 Replies Last reply
    0
    • scalzS scalz

      wow. can't wait to see your creations! Seems interesting. Your board could be very helpful.
      I love Sensebender. But 0402, it was difficult to solder for me! So I am trying to use 0805 in my designs, easier for me.
      I am finishing to modify a moteino (0805 so a little bigger) to add nrf and atsha. I am waiting for others boards (not received yet) : uCurrent module, one power management optimization board (based on ulpnode idea), esp8266-07 with nrf, rfm and atsha (I will try to make sort of mqtt gateway), and a mysensors relay board. I have others idea too: dimmer for one main, hb100 (for barrier security), mgc3030 (for gesture. lot of stuff on this one I think). But before I must finish what I started. Hihi, mysensors and automation is addictive!

      I read in previous post that you advised not to use A6,A7 for atsha. But I imagine that I can use others pin (if i take care of datasheet of course)? I think it is doable, just have to modify pin ref in code next, isn't it? Anyway, I always try to keep mysensors reference design (A3), it is just for personal info.

      AnticimexA Offline
      AnticimexA Offline
      Anticimex
      Contest Winner
      wrote on last edited by
      #84

      @scalz
      Then you'll be happy to hear that my board uses 0805 and 1206 and also has enlarged pads for hand soldering on all SMD footprints :)
      It also features a jumper for current measurement, three power connection options, switchable regulators for super low standby currents and some other features. But I will give the details in a separate post.

      Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

      1 Reply Last reply
      1
      • scalzS scalz

        wow. can't wait to see your creations! Seems interesting. Your board could be very helpful.
        I love Sensebender. But 0402, it was difficult to solder for me! So I am trying to use 0805 in my designs, easier for me.
        I am finishing to modify a moteino (0805 so a little bigger) to add nrf and atsha. I am waiting for others boards (not received yet) : uCurrent module, one power management optimization board (based on ulpnode idea), esp8266-07 with nrf, rfm and atsha (I will try to make sort of mqtt gateway), and a mysensors relay board. I have others idea too: dimmer for one main, hb100 (for barrier security), mgc3030 (for gesture. lot of stuff on this one I think). But before I must finish what I started. Hihi, mysensors and automation is addictive!

        I read in previous post that you advised not to use A6,A7 for atsha. But I imagine that I can use others pin (if i take care of datasheet of course)? I think it is doable, just have to modify pin ref in code next, isn't it? Anyway, I always try to keep mysensors reference design (A3), it is just for personal info.

        AnticimexA Offline
        AnticimexA Offline
        Anticimex
        Contest Winner
        wrote on last edited by
        #85

        @scalz
        Regarding pin, yes. You can freely choose any digital IO for ATSHA. A6 and A7 are not digital IO so they cannot be used. They are pure analog.

        Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

        1 Reply Last reply
        0
        • scalzS Offline
          scalzS Offline
          scalz
          Hardware Contributor
          wrote on last edited by scalz
          #86

          Very interesting. So your board will be a great addition. I will follow your work for sure!
          Thank you very much for your help.

          1 Reply Last reply
          0
          • O Offline
            O Offline
            otto001
            wrote on last edited by
            #87

            Hi @all!

            First off all: thanks for your great work :-)
            I am about to compile the ethernet gw with software signing, but unfortunately I am getting some compile errors.
            Does anyone maybe have a sketch handy and would up it here?

            Thanks in advance and best regards,

            Otto

            AnticimexA 1 Reply Last reply
            0
            • O otto001

              Hi @all!

              First off all: thanks for your great work :-)
              I am about to compile the ethernet gw with software signing, but unfortunately I am getting some compile errors.
              Does anyone maybe have a sketch handy and would up it here?

              Thanks in advance and best regards,

              Otto

              AnticimexA Offline
              AnticimexA Offline
              Anticimex
              Contest Winner
              wrote on last edited by
              #88

              @otto001
              Sorry, but that is not possible on Arduino Nano. There is not enough flash available to support both ethernet and software signing. You have to use ATSHA for an ethernet gw.

              Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

              1 Reply Last reply
              0
              • O Offline
                O Offline
                otto001
                wrote on last edited by
                #89

                @Anticimex:
                Thanks, but I am trying to compile it for an UNO R3?! That should do it. Nevertheless: Using nanos only for nodes should work with sw signing, shouldnt it?

                AnticimexA 1 Reply Last reply
                0
                • O otto001

                  @Anticimex:
                  Thanks, but I am trying to compile it for an UNO R3?! That should do it. Nevertheless: Using nanos only for nodes should work with sw signing, shouldnt it?

                  AnticimexA Offline
                  AnticimexA Offline
                  Anticimex
                  Contest Winner
                  wrote on last edited by
                  #90

                  @otto001
                  Yep. It is the ethernet stack that costs the most.
                  I need you to post the compiler error you get though in order to help you.

                  Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

                  1 Reply Last reply
                  0
                  • O Offline
                    O Offline
                    otto001
                    wrote on last edited by
                    #91

                    I used the latest devel-branch from github.

                    This is the error:

                    In file included from /home/otto/sketchbook/libraries/MySensors/MyTransportNRF24.h:26:0,
                                     from /home/otto/sketchbook/libraries/MySensors/MySensor.h:28,
                                     from ms_gw_neu.ino:42:
                    /home/otto/sketchbook/libraries/MySensors/utility/RF24.h:51:11: error: 'SOFT_SPI_MISO_PIN' was not declared in this scope
                       SoftSPI<SOFT_SPI_MISO_PIN, SOFT_SPI_MOSI_PIN, SOFT_SPI_SCK_PIN, SPI_MODE> spi;
                               ^
                    /home/otto/sketchbook/libraries/MySensors/utility/RF24.h:51:30: error: 'SOFT_SPI_MOSI_PIN' was not declared in this scope
                       SoftSPI<SOFT_SPI_MISO_PIN, SOFT_SPI_MOSI_PIN, SOFT_SPI_SCK_PIN, SPI_MODE> spi;
                                                  ^
                    /home/otto/sketchbook/libraries/MySensors/utility/RF24.h:51:49: error: 'SOFT_SPI_SCK_PIN' was not declared in this scope
                       SoftSPI<SOFT_SPI_MISO_PIN, SOFT_SPI_MOSI_PIN, SOFT_SPI_SCK_PIN, SPI_MODE> spi;
                                                                     ^
                    /home/otto/sketchbook/libraries/MySensors/utility/RF24.h:51:75: error: template argument 1 is invalid
                       SoftSPI<SOFT_SPI_MISO_PIN, SOFT_SPI_MOSI_PIN, SOFT_SPI_SCK_PIN, SPI_MODE> spi;
                                                                                               ^
                    /home/otto/sketchbook/libraries/MySensors/utility/RF24.h:51:75: error: template argument 2 is invalid
                    /home/otto/sketchbook/libraries/MySensors/utility/RF24.h:51:75: error: template argument 3 is invalid
                    In file included from ms_gw_neu.ino:43:0:
                    /home/otto/sketchbook/libraries/MySensors/MyGateway.h:39:28: error: 'DEFAULT_CE_PIN' was not declared in this scope
                       MyGateway(uint8_t _cepin=DEFAULT_CE_PIN, uint8_t _cspin=DEFAULT_CS_PIN, uint8_t _inclusion_time = 1, uint8_t _inclusion_pin = 3, uint8_t _rx=6, uint8_t _tx=5, uint8_t _er=4);
                                                ^
                    /home/otto/sketchbook/libraries/MySensors/MyGateway.h:39:59: error: 'DEFAULT_CS_PIN' was not declared in this scope
                       MyGateway(uint8_t _cepin=DEFAULT_CE_PIN, uint8_t _cspin=DEFAULT_CS_PIN, uint8_t _inclusion_time = 1, uint8_t _inclusion_pin = 3, uint8_t _rx=6, uint8_t _tx=5, uint8_t _er=4);
                                                                               ^
                    ms_gw_neu.ino:80:31: error: no matching function for call to 'MyGateway::MyGateway(MyTransportNRF24&, MyHwATMega328&, MySigningAtsha204Soft&)'
                    ms_gw_neu.ino:80:31: note: candidates are:
                    In file included from ms_gw_neu.ino:43:0:
                    /home/otto/sketchbook/libraries/MySensors/MyGateway.h:39:3: note: MyGateway::MyGateway(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)
                       MyGateway(uint8_t _cepin=DEFAULT_CE_PIN, uint8_t _cspin=DEFAULT_CS_PIN, uint8_t _inclusion_time = 1, uint8_t _inclusion_pin = 3, uint8_t _rx=6, uint8_t _tx=5, uint8_t _er=4);
                       ^
                    /home/otto/sketchbook/libraries/MySensors/MyGateway.h:39:3: note:   no known conversion for argument 1 from 'MyTransportNRF24' to 'uint8_t {aka unsigned char}'
                    /home/otto/sketchbook/libraries/MySensors/MyGateway.h:20:7: note: MyGateway::MyGateway(const MyGateway&)
                     class MyGateway : public MySensor
                           ^
                    /home/otto/sketchbook/libraries/MySensors/MyGateway.h:20:7: note:   candidate expects 1 argument, 3 provided
                    

                    and this is the sketch - I am not sure, if everything is right (I am not deep into mysensors yet):

                    /*
                     * Copyright (C) 2013 Henrik Ekblad <henrik.ekblad@gmail.com>
                     * 
                     * Contribution by a-lurker
                     *
                     * 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 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.
                     *
                     * The GW code is designed for Arduino 328p / 16MHz.  ATmega168 does not have enough memory to run this program.
                     * 
                     *
                     * COMPILING WIZNET (W5100) ETHERNET MODULE
                     * > Edit RF24_config.h in (libraries\MySensors\utility) to enable softspi (remove // before "#define SOFTSPI").
                     *
                     * COMPILING ENC28J60 ETHERNET MODULE
                     * > Use Arduino IDE 1.5.7 (or later) 
                     * > Disable DEBUG in Sensor.h before compiling this sketch. Othervise the sketch will probably not fit in program space when downloading. 
                     * > Remove Ethernet.h include below and include UIPEthernet.h 
                     * > Remove DigitalIO include 
                     * Note that I had to disable UDP and DHCP support in uipethernet-conf.h to reduce space. (which means you have to choose a static IP for that module)
                     *
                     * VERA CONFIGURATION:
                     * Enter "ip-number:port" in the ip-field of the Arduino GW device. This will temporarily override any serial configuration for the Vera plugin. 
                     * E.g. If you want to use the defualt values in this sketch enter: 192.168.178.66:5003
                     *
                     * LED purposes:
                     * - 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  
                     * 
                     * See http://www.mysensors.org/build/ethernet_gateway for wiring instructions.
                     *
                     */
                    
                    #include <DigitalIO.h>     // This include can be removed when using UIPEthernet module  
                    #include <SPI.h>  
                    #include <MySensor.h>
                    #include <MyGateway.h>  
                    #include <stdarg.h>
                    #include <MyConfig.h>
                    #include <MySigningAtsha204Soft.h>
                    
                    // Use this if you have attached a Ethernet ENC28J60 shields  
                    //#include <UIPEthernet.h>  
                    
                    // Use this fo WizNET W5100 module and Arduino Ethernet Shield 
                    #include <Ethernet.h>   
                    
                    
                    #define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
                    #define INCLUSION_MODE_PIN  3 // Digital pin used for inclusion mode button
                    
                    #define RADIO_CE_PIN        5  // radio chip enable
                    #define RADIO_SPI_SS_PIN    6  // radio SPI serial select
                    #define RADIO_ERROR_LED_PIN 7  // Error led pin
                    #define RADIO_RX_LED_PIN    8  // Receive led pin
                    #define RADIO_TX_LED_PIN    9  // the PCB, on board LED
                    
                    #define IP_PORT 5003        // The port you want to open 
                    IPAddress myIp (192, 168, 1, 66);  // Configure your static ip-address here    COMPILE ERROR HERE? Use Arduino IDE 1.5.7 or later!
                    
                    // 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.
                    byte mac[] = { 0xCE, 0x0D, 0xBE, 0xEF, 0xFE, 0xED };  // DEAD BEEF FEED
                    
                    
                    // a R/W server on the port
                    EthernetServer server = EthernetServer(IP_PORT);
                    
                    
                    MyTransportNRF24 radio;  // NRFRF24L01 radio driver
                    MyHwATMega328 hw; // Select AtMega328 hardware profile
                    MySigningAtsha204Soft signer(false); // Select ATSHA204A software signing backend
                    MyGateway gw(radio, hw, signer);
                    
                    // No blink or button functionality. Use the vanilla constructor.
                    // old MyGateway gw(RADIO_CE_PIN, RADIO_SPI_SS_PIN, INCLUSION_MODE_TIME);
                    
                    // Uncomment this constructor if you have leds and include button attached to your gateway 
                    //MyGateway gw(RADIO_CE_PIN, RADIO_SPI_SS_PIN, INCLUSION_MODE_TIME, INCLUSION_MODE_PIN, RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN);
                    
                    
                    char inputString[MAX_RECEIVE_LENGTH] = "";    // A string to hold incoming commands from serial/ethernet interface
                    int inputPos = 0;
                    
                    void setup()  
                    { 
                      Ethernet.begin(mac, myIp);
                    
                      // give the Ethernet interface a second to initialize
                      delay(1000);
                    
                      // Initialize gateway at maximum PA level, channel 70 and callback for write operations 
                      gw.begin(RF24_PA_LEVEL_GW, RF24_CHANNEL, RF24_DATARATE, writeEthernet);
                    
                      // start listening for clients
                      server.begin();
                    }
                    
                    // This will be called when data should be written to ethernet 
                    void writeEthernet(char *writeBuffer) {
                      server.write(writeBuffer);
                    }
                    
                    
                    void loop()
                    {
                      // if an incoming client connects, there will be
                      // bytes available to read via the client object
                      EthernetClient client = server.available();
                    
                      if (client) {
                          Serial.print("bytes");
                          // if got 1 or more bytes
                          if (client.available()) {
                             // read the bytes incoming from the client
                             char inChar = client.read();
                    
                             if (inputPos<MAX_RECEIVE_LENGTH-1) { 
                               // if newline then command is complete
                               if (inChar == '\n') {  
                                  // a command was issued by the client
                                  // we will now try to send it to the actuator
                                  inputString[inputPos] = 0;
                    
                                  // echo the string to the serial port
                                  Serial.print(inputString);
                    
                                  gw.parseAndSend(inputString);
                    
                                  // clear the string:
                                  inputPos = 0;
                               } else {  
                                 // add it to the inputString:
                                 inputString[inputPos] = inChar;
                                 inputPos++;
                               }
                            } else {
                               // Incoming message too long. Throw away 
                               inputPos = 0;
                            }
                          }
                       }  
                       gw.processRadioMessage();    
                    }
                    
                    

                    Thanks for your help in advance!

                    Otto

                    AnticimexA 1 Reply Last reply
                    0
                    • O otto001

                      I used the latest devel-branch from github.

                      This is the error:

                      In file included from /home/otto/sketchbook/libraries/MySensors/MyTransportNRF24.h:26:0,
                                       from /home/otto/sketchbook/libraries/MySensors/MySensor.h:28,
                                       from ms_gw_neu.ino:42:
                      /home/otto/sketchbook/libraries/MySensors/utility/RF24.h:51:11: error: 'SOFT_SPI_MISO_PIN' was not declared in this scope
                         SoftSPI<SOFT_SPI_MISO_PIN, SOFT_SPI_MOSI_PIN, SOFT_SPI_SCK_PIN, SPI_MODE> spi;
                                 ^
                      /home/otto/sketchbook/libraries/MySensors/utility/RF24.h:51:30: error: 'SOFT_SPI_MOSI_PIN' was not declared in this scope
                         SoftSPI<SOFT_SPI_MISO_PIN, SOFT_SPI_MOSI_PIN, SOFT_SPI_SCK_PIN, SPI_MODE> spi;
                                                    ^
                      /home/otto/sketchbook/libraries/MySensors/utility/RF24.h:51:49: error: 'SOFT_SPI_SCK_PIN' was not declared in this scope
                         SoftSPI<SOFT_SPI_MISO_PIN, SOFT_SPI_MOSI_PIN, SOFT_SPI_SCK_PIN, SPI_MODE> spi;
                                                                       ^
                      /home/otto/sketchbook/libraries/MySensors/utility/RF24.h:51:75: error: template argument 1 is invalid
                         SoftSPI<SOFT_SPI_MISO_PIN, SOFT_SPI_MOSI_PIN, SOFT_SPI_SCK_PIN, SPI_MODE> spi;
                                                                                                 ^
                      /home/otto/sketchbook/libraries/MySensors/utility/RF24.h:51:75: error: template argument 2 is invalid
                      /home/otto/sketchbook/libraries/MySensors/utility/RF24.h:51:75: error: template argument 3 is invalid
                      In file included from ms_gw_neu.ino:43:0:
                      /home/otto/sketchbook/libraries/MySensors/MyGateway.h:39:28: error: 'DEFAULT_CE_PIN' was not declared in this scope
                         MyGateway(uint8_t _cepin=DEFAULT_CE_PIN, uint8_t _cspin=DEFAULT_CS_PIN, uint8_t _inclusion_time = 1, uint8_t _inclusion_pin = 3, uint8_t _rx=6, uint8_t _tx=5, uint8_t _er=4);
                                                  ^
                      /home/otto/sketchbook/libraries/MySensors/MyGateway.h:39:59: error: 'DEFAULT_CS_PIN' was not declared in this scope
                         MyGateway(uint8_t _cepin=DEFAULT_CE_PIN, uint8_t _cspin=DEFAULT_CS_PIN, uint8_t _inclusion_time = 1, uint8_t _inclusion_pin = 3, uint8_t _rx=6, uint8_t _tx=5, uint8_t _er=4);
                                                                                 ^
                      ms_gw_neu.ino:80:31: error: no matching function for call to 'MyGateway::MyGateway(MyTransportNRF24&, MyHwATMega328&, MySigningAtsha204Soft&)'
                      ms_gw_neu.ino:80:31: note: candidates are:
                      In file included from ms_gw_neu.ino:43:0:
                      /home/otto/sketchbook/libraries/MySensors/MyGateway.h:39:3: note: MyGateway::MyGateway(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)
                         MyGateway(uint8_t _cepin=DEFAULT_CE_PIN, uint8_t _cspin=DEFAULT_CS_PIN, uint8_t _inclusion_time = 1, uint8_t _inclusion_pin = 3, uint8_t _rx=6, uint8_t _tx=5, uint8_t _er=4);
                         ^
                      /home/otto/sketchbook/libraries/MySensors/MyGateway.h:39:3: note:   no known conversion for argument 1 from 'MyTransportNRF24' to 'uint8_t {aka unsigned char}'
                      /home/otto/sketchbook/libraries/MySensors/MyGateway.h:20:7: note: MyGateway::MyGateway(const MyGateway&)
                       class MyGateway : public MySensor
                             ^
                      /home/otto/sketchbook/libraries/MySensors/MyGateway.h:20:7: note:   candidate expects 1 argument, 3 provided
                      

                      and this is the sketch - I am not sure, if everything is right (I am not deep into mysensors yet):

                      /*
                       * Copyright (C) 2013 Henrik Ekblad <henrik.ekblad@gmail.com>
                       * 
                       * Contribution by a-lurker
                       *
                       * 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 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.
                       *
                       * The GW code is designed for Arduino 328p / 16MHz.  ATmega168 does not have enough memory to run this program.
                       * 
                       *
                       * COMPILING WIZNET (W5100) ETHERNET MODULE
                       * > Edit RF24_config.h in (libraries\MySensors\utility) to enable softspi (remove // before "#define SOFTSPI").
                       *
                       * COMPILING ENC28J60 ETHERNET MODULE
                       * > Use Arduino IDE 1.5.7 (or later) 
                       * > Disable DEBUG in Sensor.h before compiling this sketch. Othervise the sketch will probably not fit in program space when downloading. 
                       * > Remove Ethernet.h include below and include UIPEthernet.h 
                       * > Remove DigitalIO include 
                       * Note that I had to disable UDP and DHCP support in uipethernet-conf.h to reduce space. (which means you have to choose a static IP for that module)
                       *
                       * VERA CONFIGURATION:
                       * Enter "ip-number:port" in the ip-field of the Arduino GW device. This will temporarily override any serial configuration for the Vera plugin. 
                       * E.g. If you want to use the defualt values in this sketch enter: 192.168.178.66:5003
                       *
                       * LED purposes:
                       * - 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  
                       * 
                       * See http://www.mysensors.org/build/ethernet_gateway for wiring instructions.
                       *
                       */
                      
                      #include <DigitalIO.h>     // This include can be removed when using UIPEthernet module  
                      #include <SPI.h>  
                      #include <MySensor.h>
                      #include <MyGateway.h>  
                      #include <stdarg.h>
                      #include <MyConfig.h>
                      #include <MySigningAtsha204Soft.h>
                      
                      // Use this if you have attached a Ethernet ENC28J60 shields  
                      //#include <UIPEthernet.h>  
                      
                      // Use this fo WizNET W5100 module and Arduino Ethernet Shield 
                      #include <Ethernet.h>   
                      
                      
                      #define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
                      #define INCLUSION_MODE_PIN  3 // Digital pin used for inclusion mode button
                      
                      #define RADIO_CE_PIN        5  // radio chip enable
                      #define RADIO_SPI_SS_PIN    6  // radio SPI serial select
                      #define RADIO_ERROR_LED_PIN 7  // Error led pin
                      #define RADIO_RX_LED_PIN    8  // Receive led pin
                      #define RADIO_TX_LED_PIN    9  // the PCB, on board LED
                      
                      #define IP_PORT 5003        // The port you want to open 
                      IPAddress myIp (192, 168, 1, 66);  // Configure your static ip-address here    COMPILE ERROR HERE? Use Arduino IDE 1.5.7 or later!
                      
                      // 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.
                      byte mac[] = { 0xCE, 0x0D, 0xBE, 0xEF, 0xFE, 0xED };  // DEAD BEEF FEED
                      
                      
                      // a R/W server on the port
                      EthernetServer server = EthernetServer(IP_PORT);
                      
                      
                      MyTransportNRF24 radio;  // NRFRF24L01 radio driver
                      MyHwATMega328 hw; // Select AtMega328 hardware profile
                      MySigningAtsha204Soft signer(false); // Select ATSHA204A software signing backend
                      MyGateway gw(radio, hw, signer);
                      
                      // No blink or button functionality. Use the vanilla constructor.
                      // old MyGateway gw(RADIO_CE_PIN, RADIO_SPI_SS_PIN, INCLUSION_MODE_TIME);
                      
                      // Uncomment this constructor if you have leds and include button attached to your gateway 
                      //MyGateway gw(RADIO_CE_PIN, RADIO_SPI_SS_PIN, INCLUSION_MODE_TIME, INCLUSION_MODE_PIN, RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN);
                      
                      
                      char inputString[MAX_RECEIVE_LENGTH] = "";    // A string to hold incoming commands from serial/ethernet interface
                      int inputPos = 0;
                      
                      void setup()  
                      { 
                        Ethernet.begin(mac, myIp);
                      
                        // give the Ethernet interface a second to initialize
                        delay(1000);
                      
                        // Initialize gateway at maximum PA level, channel 70 and callback for write operations 
                        gw.begin(RF24_PA_LEVEL_GW, RF24_CHANNEL, RF24_DATARATE, writeEthernet);
                      
                        // start listening for clients
                        server.begin();
                      }
                      
                      // This will be called when data should be written to ethernet 
                      void writeEthernet(char *writeBuffer) {
                        server.write(writeBuffer);
                      }
                      
                      
                      void loop()
                      {
                        // if an incoming client connects, there will be
                        // bytes available to read via the client object
                        EthernetClient client = server.available();
                      
                        if (client) {
                            Serial.print("bytes");
                            // if got 1 or more bytes
                            if (client.available()) {
                               // read the bytes incoming from the client
                               char inChar = client.read();
                      
                               if (inputPos<MAX_RECEIVE_LENGTH-1) { 
                                 // if newline then command is complete
                                 if (inChar == '\n') {  
                                    // a command was issued by the client
                                    // we will now try to send it to the actuator
                                    inputString[inputPos] = 0;
                      
                                    // echo the string to the serial port
                                    Serial.print(inputString);
                      
                                    gw.parseAndSend(inputString);
                      
                                    // clear the string:
                                    inputPos = 0;
                                 } else {  
                                   // add it to the inputString:
                                   inputString[inputPos] = inChar;
                                   inputPos++;
                                 }
                              } else {
                                 // Incoming message too long. Throw away 
                                 inputPos = 0;
                              }
                            }
                         }  
                         gw.processRadioMessage();    
                      }
                      
                      

                      Thanks for your help in advance!

                      Otto

                      AnticimexA Offline
                      AnticimexA Offline
                      Anticimex
                      Contest Winner
                      wrote on last edited by
                      #92

                      @otto001
                      Hm. Looks like you have a problem with your settings for soft SPI. The errors are not related to the signing backend.
                      I suspect a problem in MyConfig.h but I have not been up to speed with the changes on development nor have I dabbled with soft SPI. I run "hardware" SPI. @hek maybe knows what setting is wrong for your problem to occur. Could be that the soft SPI driver does not take UNO boards into account?

                      Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

                      1 Reply Last reply
                      0
                      • O Offline
                        O Offline
                        otto001
                        wrote on last edited by otto001
                        #93

                        @Anticimex:

                        Thanks anyway! I will try again without signing. Maybe there is a problem in the recent devel-branch. With stable 1.4 it compiled without any issues...
                        /update: does not compile with the "standard" ethernet-gw sketch too.... not related to signing...

                        AnticimexA 1 Reply Last reply
                        0
                        • O otto001

                          @Anticimex:

                          Thanks anyway! I will try again without signing. Maybe there is a problem in the recent devel-branch. With stable 1.4 it compiled without any issues...
                          /update: does not compile with the "standard" ethernet-gw sketch too.... not related to signing...

                          AnticimexA Offline
                          AnticimexA Offline
                          Anticimex
                          Contest Winner
                          wrote on last edited by
                          #94

                          @otto001
                          Alright. Thanks for confirming. I had a rough period on development with the signing support when I was developing it. Other commits kept breaking it (not intentionally but because there was other changes to the init sequences and such which did not take signing into account). And I have been busy doing other things so I have not refreshed my own sketches to HEAD on development for a couple of months so I am uncertain on the working state at the moment, but I trust @hek to let me know if something breaks again :)
                          I will get back on track soon I hope but project :baby: is coming up and is sure to mess quite a bit with my schedule :) so I trust others to keep me informed if signing support should fail.

                          Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

                          1 Reply Last reply
                          0
                          • F Offline
                            F Offline
                            franklin216
                            wrote on last edited by
                            #95

                            I do not understand how to set the Backend in the myconfig.h.

                            "you need to decide what signing backend to use. This is done in MyConfig.h"

                            But how? Just by commenting out the Pin Define?

                            1 Reply Last reply
                            0
                            • AnticimexA Offline
                              AnticimexA Offline
                              Anticimex
                              Contest Winner
                              wrote on last edited by
                              #96

                              My post is not really up2date with the code at the moment (at least on development branch). You now pick you backend by argument to the MySensor constructor. I will check with @hek how we should handle this post when master and development are diverging.

                              Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

                              1 Reply Last reply
                              0
                              • F Offline
                                F Offline
                                franklin216
                                wrote on last edited by
                                #97

                                Thank you for your quick reply :-) Now it is clearer to me.

                                1 Reply Last reply
                                0
                                • AnticimexA Offline
                                  AnticimexA Offline
                                  Anticimex
                                  Contest Winner
                                  wrote on last edited by
                                  #98

                                  Good! I will look into how the post can be clearer and handle the code specifics better with respect to both "master" and "development" where applicable. Sorry for the discrepancy :)

                                  Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

                                  1 Reply Last reply
                                  0
                                  • AnticimexA Offline
                                    AnticimexA Offline
                                    Anticimex
                                    Contest Winner
                                    wrote on last edited by
                                    #99

                                    First post updated to better reflect the state of the 'development' branch. Signing is currently not available on 'master'.

                                    Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

                                    1 Reply Last reply
                                    0
                                    • scalzS Offline
                                      scalzS Offline
                                      scalz
                                      Hardware Contributor
                                      wrote on last edited by scalz
                                      #100

                                      Hi @Anticimex,

                                      I read your first post and followed it, it was very interesting and comprehensible. So I am trying autentication to see how it looks. I entered the key in a Gateway (nano) and a mini pro node. The mini is running DHT Humidity sketch (I know it is not very interesting node for autentication but it's easy on breadboard). I am using latest dev branch. Communication seems to work but i am a little confused with serial output on GW as I see some no sign. It seems that humidity is ok, but not the temperature child.. but I am not sure.

                                      What do you think I am doing wrong?

                                      Edit: I am getting others nosign... Does presentation and version messages uses autentication too? because they seem to be ok but not the child sensors value..

                                      Here is GW logs:

                                      0;0;3;0;9;read: 10-10-0 s=255,c=3,t=15,pt=2,l=2,sg=0:1
                                      0;0;3;0;9;send: 0-0-10-10 s=255,c=3,t=15,pt=2,l=2,sg=0,st=ok:1
                                      0;0;3;0;9;read: 10-10-0 s=255,c=3,t=16,pt=0,l=0,sg=0:
                                      0;0;3;0;9;send: 0-0-10-10 s=255,c=3,t=17,pt=6,l=25,sg=0,st=ok:01F989B
                                      0;0;3;0;9;read: 10-10-0 s=255,c=0,t=17,pt=0,l=6,sg=1:1.5 b1
                                      10;255;0;0;17;1.5 b1
                                      0;0;3;0;9;read: 10-10-0 s=255,c=3,t=16,pt=0,l=0,sg=0:
                                      0;0;3;0;9;send: 0-0-10-10 s=255,c=3,t=17,pt=6,l=25,sg=0,st=ok:017DA4B
                                      0;0;3;0;9;read: 10-10-0 s=255,c=3,t=6,pt=1,l=1,sg=1:0
                                      10;255;3;0;6;0
                                      0;0;3;0;9;read: 10-10-0 s=255,c=3,t=16,pt=0,l=0,sg=0:
                                      0;0;3;0;9;send: 0-0-10-10 s=255,c=3,t=17,pt=6,l=25,sg=0,st=ok:01C7E11
                                      0;0;3;0;9;read: 10-10-0 s=255,c=3,t=11,pt=0,l=8,sg=1:Humidity
                                      10;255;3;0;11;Humidity
                                      0;0;3;0;9;read: 10-10-0 s=255,c=3,t=16,pt=0,l=0,sg=0:
                                      0;0;3;0;9;send: 0-0-10-10 s=255,c=3,t=17,pt=6,l=25,sg=0,st=ok:017B669
                                      0;0;3;0;9;read: 10-10-0 s=255,c=3,t=12,pt=0,l=3,sg=1:1.0
                                      10;255;3;0;12;1.0
                                      0;0;3;0;9;read: 10-10-0 s=0,c=0,t=7,pt=0,l=0,sg=0:
                                      10;0;0;0;7;
                                      0;0;3;0;9;read: 10-10-0 s=1,c=0,t=6,pt=0,l=0,sg=0:
                                      10;1;0;0;6;
                                      0;0;3;0;9;no sign
                                      0;0;3;0;9;no sign
                                      AnticimexA 1 Reply Last reply
                                      0
                                      • scalzS scalz

                                        Hi @Anticimex,

                                        I read your first post and followed it, it was very interesting and comprehensible. So I am trying autentication to see how it looks. I entered the key in a Gateway (nano) and a mini pro node. The mini is running DHT Humidity sketch (I know it is not very interesting node for autentication but it's easy on breadboard). I am using latest dev branch. Communication seems to work but i am a little confused with serial output on GW as I see some no sign. It seems that humidity is ok, but not the temperature child.. but I am not sure.

                                        What do you think I am doing wrong?

                                        Edit: I am getting others nosign... Does presentation and version messages uses autentication too? because they seem to be ok but not the child sensors value..

                                        Here is GW logs:

                                        0;0;3;0;9;read: 10-10-0 s=255,c=3,t=15,pt=2,l=2,sg=0:1
                                        0;0;3;0;9;send: 0-0-10-10 s=255,c=3,t=15,pt=2,l=2,sg=0,st=ok:1
                                        0;0;3;0;9;read: 10-10-0 s=255,c=3,t=16,pt=0,l=0,sg=0:
                                        0;0;3;0;9;send: 0-0-10-10 s=255,c=3,t=17,pt=6,l=25,sg=0,st=ok:01F989B
                                        0;0;3;0;9;read: 10-10-0 s=255,c=0,t=17,pt=0,l=6,sg=1:1.5 b1
                                        10;255;0;0;17;1.5 b1
                                        0;0;3;0;9;read: 10-10-0 s=255,c=3,t=16,pt=0,l=0,sg=0:
                                        0;0;3;0;9;send: 0-0-10-10 s=255,c=3,t=17,pt=6,l=25,sg=0,st=ok:017DA4B
                                        0;0;3;0;9;read: 10-10-0 s=255,c=3,t=6,pt=1,l=1,sg=1:0
                                        10;255;3;0;6;0
                                        0;0;3;0;9;read: 10-10-0 s=255,c=3,t=16,pt=0,l=0,sg=0:
                                        0;0;3;0;9;send: 0-0-10-10 s=255,c=3,t=17,pt=6,l=25,sg=0,st=ok:01C7E11
                                        0;0;3;0;9;read: 10-10-0 s=255,c=3,t=11,pt=0,l=8,sg=1:Humidity
                                        10;255;3;0;11;Humidity
                                        0;0;3;0;9;read: 10-10-0 s=255,c=3,t=16,pt=0,l=0,sg=0:
                                        0;0;3;0;9;send: 0-0-10-10 s=255,c=3,t=17,pt=6,l=25,sg=0,st=ok:017B669
                                        0;0;3;0;9;read: 10-10-0 s=255,c=3,t=12,pt=0,l=3,sg=1:1.0
                                        10;255;3;0;12;1.0
                                        0;0;3;0;9;read: 10-10-0 s=0,c=0,t=7,pt=0,l=0,sg=0:
                                        10;0;0;0;7;
                                        0;0;3;0;9;read: 10-10-0 s=1,c=0,t=6,pt=0,l=0,sg=0:
                                        10;1;0;0;6;
                                        0;0;3;0;9;no sign
                                        0;0;3;0;9;no sign
                                        AnticimexA Offline
                                        AnticimexA Offline
                                        Anticimex
                                        Contest Winner
                                        wrote on last edited by
                                        #101

                                        @scalz Thanks.
                                        Could you please also post the construction code of your MySensor object.
                                        And also your MyConfig.h changes (where you enable the signing functionality). Don't post your private key though :)
                                        The initial setup is all signed and well but then your node seem to not even attempt to sign the data it sends (because it should have sent a c=3,t=16 and waited for a c=3,t=17 prior to any sensor data).
                                        I see from the first two messages that the gateway has been informed that your sensor require signatures (of messages from the gateway). And the gateway do respond that it also require signautres but for some reason your sensor do not sign the sensor values (the presentation handshaking is transmitted in signed form as expected).
                                        I don't have a quick answer to why your node does not sign it's sensor data. Could you also share your code that transmits (in your sketch that is). Perhaps the easiest is to post the entire sketch :) (WITHOUT your private key).

                                        I am afraid I have to prioritize my newborn son, so I hope for understanding if my replies will be delayed. @hek might know if something has happened on dev branch that could affect signing. I did thoroughly test it when it was submitted but I have not been keeping track on activities on dev for a while now.

                                        Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

                                        1 Reply Last reply
                                        0
                                        • scalzS Offline
                                          scalzS Offline
                                          scalz
                                          Hardware Contributor
                                          wrote on last edited by scalz
                                          #102

                                          @Anticimex: Congratulation for your son! it is not hurry, no problem. and thank you for taking time.
                                          So maybe I am missing something, because I have no key in the sketch??? I am using ATSHA hardware chip.. The key is stored by using SHAPersonalizer, isn't it??

                                          I have not made any changes in Myconfig.h as it is default enabled. So it is like this:

                                          // Disable to completly disable signing functionality in library
                                          #define MY_SIGNING_FEATURE
                                          

                                          And the node sketch:

                                          #include <SPI.h>
                                          #include <MyTransportNRF24.h>
                                          #include <MyHwATMega328.h>
                                          #include <MySensor.h> 
                                          #include <DHT.h>  
                                          #include <MySigningAtsha204.h>
                                          
                                          #define CHILD_ID_HUM 0
                                          #define CHILD_ID_TEMP 1
                                          #define HUMIDITY_SENSOR_DIGITAL_PIN 5
                                          unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
                                          
                                          MyTransportNRF24 radio;  // NRFRF24L01 radio driver
                                          MyHwATMega328 hw; // Select AtMega328 hardware profile
                                          MySigningAtsha204 signer; // Select HW ATSHA signing backend
                                          MySensor gw(radio, hw, signer);
                                          
                                          DHT dht;
                                          float lastTemp;
                                          float lastHum;
                                          boolean metric = true; 
                                          MyMessage msgHum(CHILD_ID_HUM, V_HUM);
                                          MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
                                          
                                          
                                          void setup()  
                                          { 
                                            gw.begin(NULL, 10);
                                            dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
                                          
                                            // Send the Sketch Version Information to the Gateway
                                            gw.sendSketchInfo("Humidity", "1.0");
                                          
                                            // Register all sensors to gw (they will be created as child devices)
                                            gw.present(CHILD_ID_HUM, S_HUM);
                                            gw.present(CHILD_ID_TEMP, S_TEMP);
                                            
                                            metric = gw.getConfig().isMetric;
                                          }
                                          
                                          void loop()      
                                          {  
                                            delay(dht.getMinimumSamplingPeriod());
                                          
                                            float temperature = dht.getTemperature();
                                            if (isnan(temperature)) {
                                                Serial.println("Failed reading temperature from DHT");
                                            } else if (temperature != lastTemp) {
                                              lastTemp = temperature;
                                              if (!metric) {
                                                temperature = dht.toFahrenheit(temperature);
                                              }
                                              gw.send(msgTemp.set(temperature, 1));
                                              Serial.print("T: ");
                                              Serial.println(temperature);
                                            }
                                            
                                            float humidity = dht.getHumidity();
                                            if (isnan(humidity)) {
                                                Serial.println("Failed reading humidity from DHT");
                                            } else if (humidity != lastHum) {
                                                lastHum = humidity;
                                                gw.send(msgHum.set(humidity, 1));
                                                Serial.print("H: ");
                                                Serial.println(humidity);
                                            }
                                          
                                            gw.sleep(SLEEP_TIME); //sleep a bit
                                          }
                                          

                                          and in Serial Gateway, I have only changed this:

                                          // Message signing driver (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
                                          //MySigningNone signer;
                                          //MySigningAtsha204Soft signer;
                                          MySigningAtsha204 signer;
                                          
                                          // Hardware profile 
                                          MyHwATMega328 hw;
                                          
                                          // Construct MySensors library (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
                                          // To use LEDs blinking, uncomment WITH_LEDS_BLINKING in MyConfig.h
                                          #ifdef WITH_LEDS_BLINKING
                                          MySensor gw(transport, hw , signer, RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN);
                                          #else
                                          MySensor gw(transport, hw , signer);
                                          #endif
                                          
                                          AnticimexA 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          16

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.1k

                                          Posts


                                          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular