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. Announcements
  3. 1.4 Beta

1.4 Beta

Scheduled Pinned Locked Moved Announcements
1.4betahelp
129 Posts 18 Posters 87.1k Views 4 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.
  • JohnJ John

    Short question. I'm browsing the 1.4 code and is there a replacement for waitForMessage? I've looked into the code online but can't seem to find it. And if not, is it possible to attach the radio to an interrupt to call an interrupt routine on incoming message?

    YveauxY Offline
    YveauxY Offline
    Yveaux
    Mod
    wrote on last edited by Yveaux
    #75

    @John said:

    is it possible to attach the radio to an interrupt to call an interrupt routine on incoming message

    The last question is a definite yes, see for example https://github.com/Yveaux/NRF24_Sniffer/blob/master/Arduino/NRF24_sniff/NRF24_sniff.ino function handleNrfIrq. Connect the NRF24 IRQ to pin 2 and call attachInterrupt to register the interrup handler.

    Be very careful what you do in this interrupt handler, though. Don't try to receive any message for example, as the SPI access to the NRF24 is not interrupt-proof, as is the MySensors library!

    http://yveaux.blogspot.nl

    1 Reply Last reply
    0
    • JohnJ John

      Short question. I'm browsing the 1.4 code and is there a replacement for waitForMessage? I've looked into the code online but can't seem to find it. And if not, is it possible to attach the radio to an interrupt to call an interrupt routine on incoming message?

      hekH Offline
      hekH Offline
      hek
      Admin
      wrote on last edited by
      #76

      @John

      Yep, as @Yveaux says, be careful what you do inside interrupt handler.

      Not sure what you try to archive here.. but in 1.4 you should usually just call process() in your loop(). The callback you registered a in begin(callback) will be called on incoming messages.

      See RelayActuator for an example.

      1 Reply Last reply
      0
      • JohnJ Offline
        JohnJ Offline
        John
        Plugin Developer
        wrote on last edited by John
        #77

        @Yveaux

        Be very careful what you do in this interrupt handler, though. Don't try to receive any message for example, as the SPI access to the NRF24 is not interrupt-proof, as is the MySensors library!

        Darn, i hoped it could.

        @hek

        Not sure what you try to archive here.. but in 1.4 you should usually just call process() in your loop(). The callback you registered a in begin(callback) will be called on incoming messages.

        I'm averaging sensor results, so i read sensors every second an send them every minute, also this setup has an 16x2 display attached to show the values. But i would like it to be bi-directional with the server so it can display the server send data. Thus if i would use waitForMessage i can let it wait about a second for a message read sensor values, and let it wait for a second again. (because i understood it blocks?)

        My Domotica project: http://www.pidome.org

        YveauxY 1 Reply Last reply
        0
        • JohnJ John

          @Yveaux

          Be very careful what you do in this interrupt handler, though. Don't try to receive any message for example, as the SPI access to the NRF24 is not interrupt-proof, as is the MySensors library!

          Darn, i hoped it could.

          @hek

          Not sure what you try to archive here.. but in 1.4 you should usually just call process() in your loop(). The callback you registered a in begin(callback) will be called on incoming messages.

          I'm averaging sensor results, so i read sensors every second an send them every minute, also this setup has an 16x2 display attached to show the values. But i would like it to be bi-directional with the server so it can display the server send data. Thus if i would use waitForMessage i can let it wait about a second for a message read sensor values, and let it wait for a second again. (because i understood it blocks?)

          YveauxY Offline
          YveauxY Offline
          Yveaux
          Mod
          wrote on last edited by
          #78

          @John You can obtain the same result as the old waitForMessage by registering a callback. Have this callback set a flag and call process() in the loop, as hek suggests.
          You could also turn things around and read and average your sensors from a (timer)interrupt handler.
          But when you're not completely confident with using interrupts then its better to avoid them and just process everything from your loop(). Interrupts can introduce lots of nasty problems if you don't know exactly what you're doing!

          http://yveaux.blogspot.nl

          JohnJ 1 Reply Last reply
          0
          • YveauxY Yveaux

            @John You can obtain the same result as the old waitForMessage by registering a callback. Have this callback set a flag and call process() in the loop, as hek suggests.
            You could also turn things around and read and average your sensors from a (timer)interrupt handler.
            But when you're not completely confident with using interrupts then its better to avoid them and just process everything from your loop(). Interrupts can introduce lots of nasty problems if you don't know exactly what you're doing!

            JohnJ Offline
            JohnJ Offline
            John
            Plugin Developer
            wrote on last edited by
            #79

            @Yveaux

            You can obtain the same result as the old waitForMessage by registering a callback. Have this callback set a flag and call process() in the loop, as hek suggests.

            Well, that was my first try and hoped it was interrupt based because of one wire connected on arduino pin 2 to IRQ on the NRF. The reason i asked it because i saw an example from an other library: http://maniacbug.github.io/RF24/pingpair_irq_8pde-example.html .

            You could also turn things around and read and average your sensors from a (timer)interrupt handler.

            I will have to investigate if any of the components is using which timer and what will be influenced by it. I'm using an HD44780 alike as display so i'm not sure because never dived deep into the used library.

            But when you're not completely confident

            about 90%?

            @hek
            It would be nice if a waitForMessage like functionality would be included in 1.4.

            My Domotica project: http://www.pidome.org

            1 Reply Last reply
            0
            • clippermiamiC Offline
              clippermiamiC Offline
              clippermiami
              Hero Member
              wrote on last edited by
              #80

              @hek Any idea when 1.4 will become the production version?

              hekH 1 Reply Last reply
              0
              • clippermiamiC clippermiami

                @hek Any idea when 1.4 will become the production version?

                hekH Offline
                hekH Offline
                hek
                Admin
                wrote on last edited by
                #81

                @clippermiami

                We're still making small changes in the protocol and serial API which we need to stabilize before release.
                I also need time to update the main site to reflect the new version before its "released" .

                1 Reply Last reply
                0
                • hekH hek

                  The 1.4 version of the MySenors Arduino library is new open for beta testing.

                  Arduino library and examples
                  https://github.com/mysensors/Arduino/tree/development

                  Vera plugin (1.4)
                  https://github.com/mysensors/Vera/tree/development

                  Here are some of the hi-lights.

                  • Improved communication reliability (now uses hardware acks and resend functionality).
                  • Simplified sketches (only one include needed).
                  • Most common sleep scenarios build in.
                  • Helper for permanently storing values in the Arduinos EEPROM.
                  • Acknowledgments can now be requested from gateway and other sensors in network.
                  • Smaller footprint.
                  • The message structure has been adopted to work better on RPi platform.
                  • Binary payloads supported and used for integers between sensors.
                  • Configuration message (only metric setting in it today).
                  • Allow static parent (no dynamic lookups)
                  • Callbacks for incoming messages and time. No synchronous waiting methods any more -> no missed messages.

                  All examples in the development branch above has been converted to use the new functionality of the library.

                  The new API:

                  /**
                  * Constructor
                  *
                  * Creates a new instance of Sensor class.
                  *
                  * @param _cepin The pin attached to RF24 Chip Enable on the RF module (defualt 9)
                  * @param _cspin The pin attached to RF24 Chip Select (default 10)
                  */
                  MySensor(uint8_t _cepin=9, uint8_t _cspin=10);
                  
                  /**
                  * Begin operation of the MySensors library
                  *
                  * Call this in setup(), before calling any other sensor net library methods.
                  * @param incomingMessageCallback Callback function for incoming messages from other nodes or controller and request responses. Default is NULL.
                  * @param nodeId The unique id (1-254) for this sensor. Default is AUTO(255) which means sensor tries to fetch an id from controller.
                  * @param repeaterMode Activate repeater mode. This node will forward messages to other nodes in the radio network. Make sure to call process() regularly. Default in false
                  * @param parentNodeId Use this to force node to always communicate with a certain parent node. Default is AUTO which means node automatically tries to find a parent.
                  * @param paLevel Radio PA Level for this sensor. Default RF24_PA_MAX
                  * @param channel Radio channel. Default is channel 76
                  * @param dataRate Radio transmission speed. Default RF24_1MBPS
                  */
                  
                  void begin(void (* msgCallback)(const MyMessage &)=NULL, uint8_t nodeId=AUTO, boolean repeaterMode=false, uint8_t parentNodeId=AUTO, rf24_pa_dbm_e paLevel=RF24_PA_LEVEL, uint8_t channel=RF24_CHANNEL, rf24_datarate_e dataRate=RF24_DATARATE);
                  
                  /**
                   * Return the nodes nodeId.
                   */
                  uint8_t getNodeId();
                  
                  /**
                  * Each node must present all attached sensors before any values can be handled correctly by the controller.
                  * It is usually good to present all attached sensors after power-up in setup().
                  *
                  * @param sensorId Select a unique sensor id for this sensor. Choose a number between 0-254.
                  * @param sensorType The sensor type. See sensor typedef in MyMessage.h.
                  * @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
                  */
                  void present(uint8_t sensorId, uint8_t sensorType, bool ack=false);
                  
                  /**
                   * Sends sketch meta information to the gateway. Not mandatory but a nice thing to do.
                   * @param name String containing a short Sketch name or NULL  if not applicable
                   * @param version String containing a short Sketch version or NULL if not applicable
                   * @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
                   *
                   */
                  void sendSketchInfo(const char *name, const char *version, bool ack=false);
                  
                  /**
                  * Sends a message to gateway or one of the other nodes in the radio network
                  *
                  * @param msg Message to send
                  * @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
                  * @return true Returns true if message reached the first stop on its way to destination.
                  */
                  bool send(MyMessage &msg, bool ack=false);
                  
                  /**
                   * Send this nodes battery level to gateway.
                   * @param level Level between 0-100(%)
                   * @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
                   *
                   */
                  void sendBatteryLevel(uint8_t level, bool ack=false);
                  
                  /**
                  * Requests a value from gateway or some other sensor in the radio network.
                  * Make sure to add callback-method in begin-method to handle request responses.
                  *
                  * @param childSensorId  The unique child id for the different sensors connected to this Arduino. 0-254.
                  * @param variableType The variableType to fetch
                  * @param destination The nodeId of other node in radio network. Default is gateway
                  */
                  void request(uint8_t childSensorId, uint8_t variableType, uint8_t destination=GATEWAY_ADDRESS);
                  
                  /**
                   * Requests time from controller. Answer will be delivered to callback.
                   *
                   * @param callback for time request. Incoming argument is seconds since 1970.
                   */
                  void requestTime(void (* timeCallback)(unsigned long));
                  
                  
                  /**
                   * Processes incoming messages to this node. If this is a relaying node it will
                  * Returns true if there is a message addressed for this node just was received.
                  * Use callback to handle incoming messages.
                  */
                  boolean process();
                  
                  /**
                   * Returns the most recent node configuration received from controller
                   */
                  ControllerConfig getConfig();
                  
                  /**
                   * Save a state (in local EEPROM). Good for actuators to "remember" state between
                   * power cycles.
                   *
                   * You have 256 bytes to play with. Note that there is a limitation on the number
                   * of writes the EEPROM can handle (~100 000 cycles).
                   *
                   * @param pos The position to store value in (0-255)
                   * @param Value to store in position
                   */
                  void saveState(uint8_t pos, uint8_t value);
                  
                  /**
                   * Load a state (from local EEPROM).
                   *
                   * @param pos The position to fetch value from  (0-255)
                   * @return Value to store in position
                   */
                  uint8_t loadState(uint8_t pos);
                  
                  /**
                  * Returns the last received message
                  */
                  MyMessage& getLastMessage(void);
                  
                  /**
                   * Sleep (PowerDownMode) the Arduino and radio. Wake up on timer.
                   * @param ms Number of milliseconds to sleep.
                   */
                  void sleep(int ms);
                  
                  /**
                   * Sleep (PowerDownMode) the Arduino and radio. Wake up on timer or pin change.
                   * See: http://arduino.cc/en/Reference/attachInterrupt for details on modes and which pin
                   * is assigned to what interrupt. On Nano/Pro Mini: 0=Pin2, 1=Pin3
                   * @param interrupt Interrupt that should trigger the wakeup
                   * @param mode RISING, FALLING, CHANGE
                   * @param ms Number of milliseconds to sleep or 0 to sleep forever
                   * @return true if wake up was triggered by pin change and false means timer woke it up.
                   */
                  bool sleep(int interrupt, int mode, int ms=0);
                  
                  /**
                   * getInternalTemp
                   *
                   * Read temp from internal (ATMEGA328 only) temperature sensor. This reading is very
                   * inaccurate so we round the result to full degrees celsius.
                   * http://playground.arduino.cc/Main/InternalTemperatureSensor
                   *
                   * @return Temperature in full degrees Celsius.
                   */
                  int getInternalTemp(void);
                  

                  ###To convert an old 1.3 sketch follow this guide:

                  Include section

                  Remove the following includes
                  #include <Sleep_n0m1.h>
                  #include <EEPROM.h>
                  #include <RF24.h>
                  #include <Sensor.h>
                  #include <Relay.h>

                  Add
                  #include <MySensor.h>

                  Global variable scope

                  Change the following lines

                  Sensor gw;
                  or
                  Relay gw;
                  

                  To

                  MySensor gw;
                  

                  Also message containers for outgoing messages. E.g. Light level message for child sensor id 1.

                  MyMessage msg(1, V_LIGHT_LEVEL);
                  

                  ####Setup()
                  In setup() replace sendPresentation with present.
                  Also note that begin() now allows you to add an function-argument to get callbacks for incoming messages (actuators). begin also controls wether this node should act as an repeater node. See above for full argument list.

                  ####Loop()

                  The sending of values looks a bit different. The old sketches could look like this:

                  gw.sendVariable(CHILD_ID_LIGHT, V_LIGHT_LEVEL, lux);
                  

                  In new code you send a value by using the MyMessage contaner defined in global scope. Fill it with the value to send like this (where lux is light level in this case).

                   gw.send(msg.set(lux));
                  

                  Replace any sleeping with the new build in sleep functions. The old code might have a few lines like this:

                  delay(500);
                  gw.powerDown();
                  sleep.pwrDownMode(); //set sleep mode
                  sleep.sleepDelay(SLEEP_TIME * 1000);
                  

                  Replace those with:

                  gw.sleep(<sleep time in milliseconds>);
                  
                  hekH Offline
                  hekH Offline
                  hek
                  Admin
                  wrote on last edited by
                  #82

                  Added few small changes:

                  • Add dimmable LED actuator example (converted @blacey 1.3 example)
                  • Rename PING to the more suitable FIND_PARENT
                  • Float values sent in binary format over the air
                  • Move base-radio-id to MyConfig.h

                  https://github.com/mysensors/Arduino/commits/development

                  1 Reply Last reply
                  0
                  • hekH hek

                    The 1.4 version of the MySenors Arduino library is new open for beta testing.

                    Arduino library and examples
                    https://github.com/mysensors/Arduino/tree/development

                    Vera plugin (1.4)
                    https://github.com/mysensors/Vera/tree/development

                    Here are some of the hi-lights.

                    • Improved communication reliability (now uses hardware acks and resend functionality).
                    • Simplified sketches (only one include needed).
                    • Most common sleep scenarios build in.
                    • Helper for permanently storing values in the Arduinos EEPROM.
                    • Acknowledgments can now be requested from gateway and other sensors in network.
                    • Smaller footprint.
                    • The message structure has been adopted to work better on RPi platform.
                    • Binary payloads supported and used for integers between sensors.
                    • Configuration message (only metric setting in it today).
                    • Allow static parent (no dynamic lookups)
                    • Callbacks for incoming messages and time. No synchronous waiting methods any more -> no missed messages.

                    All examples in the development branch above has been converted to use the new functionality of the library.

                    The new API:

                    /**
                    * Constructor
                    *
                    * Creates a new instance of Sensor class.
                    *
                    * @param _cepin The pin attached to RF24 Chip Enable on the RF module (defualt 9)
                    * @param _cspin The pin attached to RF24 Chip Select (default 10)
                    */
                    MySensor(uint8_t _cepin=9, uint8_t _cspin=10);
                    
                    /**
                    * Begin operation of the MySensors library
                    *
                    * Call this in setup(), before calling any other sensor net library methods.
                    * @param incomingMessageCallback Callback function for incoming messages from other nodes or controller and request responses. Default is NULL.
                    * @param nodeId The unique id (1-254) for this sensor. Default is AUTO(255) which means sensor tries to fetch an id from controller.
                    * @param repeaterMode Activate repeater mode. This node will forward messages to other nodes in the radio network. Make sure to call process() regularly. Default in false
                    * @param parentNodeId Use this to force node to always communicate with a certain parent node. Default is AUTO which means node automatically tries to find a parent.
                    * @param paLevel Radio PA Level for this sensor. Default RF24_PA_MAX
                    * @param channel Radio channel. Default is channel 76
                    * @param dataRate Radio transmission speed. Default RF24_1MBPS
                    */
                    
                    void begin(void (* msgCallback)(const MyMessage &)=NULL, uint8_t nodeId=AUTO, boolean repeaterMode=false, uint8_t parentNodeId=AUTO, rf24_pa_dbm_e paLevel=RF24_PA_LEVEL, uint8_t channel=RF24_CHANNEL, rf24_datarate_e dataRate=RF24_DATARATE);
                    
                    /**
                     * Return the nodes nodeId.
                     */
                    uint8_t getNodeId();
                    
                    /**
                    * Each node must present all attached sensors before any values can be handled correctly by the controller.
                    * It is usually good to present all attached sensors after power-up in setup().
                    *
                    * @param sensorId Select a unique sensor id for this sensor. Choose a number between 0-254.
                    * @param sensorType The sensor type. See sensor typedef in MyMessage.h.
                    * @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
                    */
                    void present(uint8_t sensorId, uint8_t sensorType, bool ack=false);
                    
                    /**
                     * Sends sketch meta information to the gateway. Not mandatory but a nice thing to do.
                     * @param name String containing a short Sketch name or NULL  if not applicable
                     * @param version String containing a short Sketch version or NULL if not applicable
                     * @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
                     *
                     */
                    void sendSketchInfo(const char *name, const char *version, bool ack=false);
                    
                    /**
                    * Sends a message to gateway or one of the other nodes in the radio network
                    *
                    * @param msg Message to send
                    * @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
                    * @return true Returns true if message reached the first stop on its way to destination.
                    */
                    bool send(MyMessage &msg, bool ack=false);
                    
                    /**
                     * Send this nodes battery level to gateway.
                     * @param level Level between 0-100(%)
                     * @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
                     *
                     */
                    void sendBatteryLevel(uint8_t level, bool ack=false);
                    
                    /**
                    * Requests a value from gateway or some other sensor in the radio network.
                    * Make sure to add callback-method in begin-method to handle request responses.
                    *
                    * @param childSensorId  The unique child id for the different sensors connected to this Arduino. 0-254.
                    * @param variableType The variableType to fetch
                    * @param destination The nodeId of other node in radio network. Default is gateway
                    */
                    void request(uint8_t childSensorId, uint8_t variableType, uint8_t destination=GATEWAY_ADDRESS);
                    
                    /**
                     * Requests time from controller. Answer will be delivered to callback.
                     *
                     * @param callback for time request. Incoming argument is seconds since 1970.
                     */
                    void requestTime(void (* timeCallback)(unsigned long));
                    
                    
                    /**
                     * Processes incoming messages to this node. If this is a relaying node it will
                    * Returns true if there is a message addressed for this node just was received.
                    * Use callback to handle incoming messages.
                    */
                    boolean process();
                    
                    /**
                     * Returns the most recent node configuration received from controller
                     */
                    ControllerConfig getConfig();
                    
                    /**
                     * Save a state (in local EEPROM). Good for actuators to "remember" state between
                     * power cycles.
                     *
                     * You have 256 bytes to play with. Note that there is a limitation on the number
                     * of writes the EEPROM can handle (~100 000 cycles).
                     *
                     * @param pos The position to store value in (0-255)
                     * @param Value to store in position
                     */
                    void saveState(uint8_t pos, uint8_t value);
                    
                    /**
                     * Load a state (from local EEPROM).
                     *
                     * @param pos The position to fetch value from  (0-255)
                     * @return Value to store in position
                     */
                    uint8_t loadState(uint8_t pos);
                    
                    /**
                    * Returns the last received message
                    */
                    MyMessage& getLastMessage(void);
                    
                    /**
                     * Sleep (PowerDownMode) the Arduino and radio. Wake up on timer.
                     * @param ms Number of milliseconds to sleep.
                     */
                    void sleep(int ms);
                    
                    /**
                     * Sleep (PowerDownMode) the Arduino and radio. Wake up on timer or pin change.
                     * See: http://arduino.cc/en/Reference/attachInterrupt for details on modes and which pin
                     * is assigned to what interrupt. On Nano/Pro Mini: 0=Pin2, 1=Pin3
                     * @param interrupt Interrupt that should trigger the wakeup
                     * @param mode RISING, FALLING, CHANGE
                     * @param ms Number of milliseconds to sleep or 0 to sleep forever
                     * @return true if wake up was triggered by pin change and false means timer woke it up.
                     */
                    bool sleep(int interrupt, int mode, int ms=0);
                    
                    /**
                     * getInternalTemp
                     *
                     * Read temp from internal (ATMEGA328 only) temperature sensor. This reading is very
                     * inaccurate so we round the result to full degrees celsius.
                     * http://playground.arduino.cc/Main/InternalTemperatureSensor
                     *
                     * @return Temperature in full degrees Celsius.
                     */
                    int getInternalTemp(void);
                    

                    ###To convert an old 1.3 sketch follow this guide:

                    Include section

                    Remove the following includes
                    #include <Sleep_n0m1.h>
                    #include <EEPROM.h>
                    #include <RF24.h>
                    #include <Sensor.h>
                    #include <Relay.h>

                    Add
                    #include <MySensor.h>

                    Global variable scope

                    Change the following lines

                    Sensor gw;
                    or
                    Relay gw;
                    

                    To

                    MySensor gw;
                    

                    Also message containers for outgoing messages. E.g. Light level message for child sensor id 1.

                    MyMessage msg(1, V_LIGHT_LEVEL);
                    

                    ####Setup()
                    In setup() replace sendPresentation with present.
                    Also note that begin() now allows you to add an function-argument to get callbacks for incoming messages (actuators). begin also controls wether this node should act as an repeater node. See above for full argument list.

                    ####Loop()

                    The sending of values looks a bit different. The old sketches could look like this:

                    gw.sendVariable(CHILD_ID_LIGHT, V_LIGHT_LEVEL, lux);
                    

                    In new code you send a value by using the MyMessage contaner defined in global scope. Fill it with the value to send like this (where lux is light level in this case).

                     gw.send(msg.set(lux));
                    

                    Replace any sleeping with the new build in sleep functions. The old code might have a few lines like this:

                    delay(500);
                    gw.powerDown();
                    sleep.pwrDownMode(); //set sleep mode
                    sleep.sleepDelay(SLEEP_TIME * 1000);
                    

                    Replace those with:

                    gw.sleep(<sleep time in milliseconds>);
                    
                    DammeD Offline
                    DammeD Offline
                    Damme
                    Code Contributor
                    wrote on last edited by
                    #83

                    @hek another suggestion for addition

                    RelayWithButtonActuator
                    incomingMessage should check if there is any payload or not. (could be bad package)
                    I use empty payload as a request for latest state (Yes I could do this some other way but I think it is logical..)

                      if (msg.type==V_LIGHT && strlen(msg.getString())!=0) {
                    
                    1 Reply Last reply
                    0
                    • JohnJ Offline
                      JohnJ Offline
                      John
                      Plugin Developer
                      wrote on last edited by John
                      #84

                      Because of the use of custom variables and the possibility of receiving and sending and of many sensor type possibilities is it possible to add a "sensor" type of S_OTHER (or alike)? I think this then would be in line of having var types V_VAR1, etc.. of which then would be something else then defined.

                      This will add the possibility to send other then sensor related data. This is of course possible but could semantic wise be more applicable.

                      My Domotica project: http://www.pidome.org

                      hekH 1 Reply Last reply
                      0
                      • JohnJ John

                        Because of the use of custom variables and the possibility of receiving and sending and of many sensor type possibilities is it possible to add a "sensor" type of S_OTHER (or alike)? I think this then would be in line of having var types V_VAR1, etc.. of which then would be something else then defined.

                        This will add the possibility to send other then sensor related data. This is of course possible but could semantic wise be more applicable.

                        hekH Offline
                        hekH Offline
                        hek
                        Admin
                        wrote on last edited by
                        #85

                        @John

                        Yes

                        1 Reply Last reply
                        0
                        • YveauxY Yveaux

                          @hek said:

                          Make sense?

                          Makes sense ;-)

                          hekH Offline
                          hekH Offline
                          hek
                          Admin
                          wrote on last edited by
                          #86

                          A small serial protocol breaking change was just checked in. @John and @marceltrapman you might want to have a look at this.

                          Serial protocol changed to allowing controller to know if an incoming message is an ack. Outgoing and incoming serial messages now also have the same parameter count.

                          radioId;childId;messageType;ack;subType;payload\n
                          

                          Where ack parameter means the following:
                          outgoing: 0 = unacknowledged message, 1 = request ack from destination node
                          Incoming: 0 = normal message, 1 = this is an ack message

                          (previously only outging messages had the ack-flag)

                          YveauxY JohnJ 2 Replies Last reply
                          0
                          • JohnJ Offline
                            JohnJ Offline
                            John
                            Plugin Developer
                            wrote on last edited by
                            #87

                            @hek

                            Thanks for the heads up. This will give a good way of tracking messages send controller wise. I can take a look at it tomorrow evening if you would like a third party ack this works ok.

                            My Domotica project: http://www.pidome.org

                            1 Reply Last reply
                            0
                            • hekH hek

                              A small serial protocol breaking change was just checked in. @John and @marceltrapman you might want to have a look at this.

                              Serial protocol changed to allowing controller to know if an incoming message is an ack. Outgoing and incoming serial messages now also have the same parameter count.

                              radioId;childId;messageType;ack;subType;payload\n
                              

                              Where ack parameter means the following:
                              outgoing: 0 = unacknowledged message, 1 = request ack from destination node
                              Incoming: 0 = normal message, 1 = this is an ack message

                              (previously only outging messages had the ack-flag)

                              YveauxY Offline
                              YveauxY Offline
                              Yveaux
                              Mod
                              wrote on last edited by
                              #88

                              @hek Thanks for the quick response!

                              http://yveaux.blogspot.nl

                              DammeD 1 Reply Last reply
                              0
                              • YveauxY Yveaux

                                @hek Thanks for the quick response!

                                DammeD Offline
                                DammeD Offline
                                Damme
                                Code Contributor
                                wrote on last edited by
                                #89

                                @Yveaux take a look at (was thinking about your sniffer) https://github.com/mysensors/Arduino/commit/c910bfdb9e54a9a41e991734b60c757968bd8210

                                YveauxY 1 Reply Last reply
                                0
                                • hekH hek

                                  A small serial protocol breaking change was just checked in. @John and @marceltrapman you might want to have a look at this.

                                  Serial protocol changed to allowing controller to know if an incoming message is an ack. Outgoing and incoming serial messages now also have the same parameter count.

                                  radioId;childId;messageType;ack;subType;payload\n
                                  

                                  Where ack parameter means the following:
                                  outgoing: 0 = unacknowledged message, 1 = request ack from destination node
                                  Incoming: 0 = normal message, 1 = this is an ack message

                                  (previously only outging messages had the ack-flag)

                                  JohnJ Offline
                                  JohnJ Offline
                                  John
                                  Plugin Developer
                                  wrote on last edited by
                                  #90

                                  @hek I have a couple of questions:

                                  Have not tested it yet, but that now ack's are possible i would like to implement a retry queue next to a normal send queue. The questions then would be:

                                  • How long does it take for the longest possible message to be send?
                                  • Is there a delay needed between each send?
                                  • Is there an ack timeout?

                                  John.

                                  My Domotica project: http://www.pidome.org

                                  hekH 1 Reply Last reply
                                  0
                                  • DammeD Damme

                                    @Yveaux take a look at (was thinking about your sniffer) https://github.com/mysensors/Arduino/commit/c910bfdb9e54a9a41e991734b60c757968bd8210

                                    YveauxY Offline
                                    YveauxY Offline
                                    Yveaux
                                    Mod
                                    wrote on last edited by
                                    #91

                                    @Damme Yeah, so header changed again... Madness :facepunch:
                                    I'll have to update the dissector then...

                                    http://yveaux.blogspot.nl

                                    1 Reply Last reply
                                    0
                                    • JohnJ John

                                      @hek I have a couple of questions:

                                      Have not tested it yet, but that now ack's are possible i would like to implement a retry queue next to a normal send queue. The questions then would be:

                                      • How long does it take for the longest possible message to be send?
                                      • Is there a delay needed between each send?
                                      • Is there an ack timeout?

                                      John.

                                      hekH Offline
                                      hekH Offline
                                      hek
                                      Admin
                                      wrote on last edited by
                                      #92

                                      @John

                                      The send time depends on how many hops the message need to make. But on the controller side you could perhaps wait for a couple of second before trying again.

                                      There is no ack timeout but each hop on the way to the destination will only be tried once (using the build in retry functionality of the nrf-chip).

                                      1 Reply Last reply
                                      0
                                      • hekH hek

                                        The 1.4 version of the MySenors Arduino library is new open for beta testing.

                                        Arduino library and examples
                                        https://github.com/mysensors/Arduino/tree/development

                                        Vera plugin (1.4)
                                        https://github.com/mysensors/Vera/tree/development

                                        Here are some of the hi-lights.

                                        • Improved communication reliability (now uses hardware acks and resend functionality).
                                        • Simplified sketches (only one include needed).
                                        • Most common sleep scenarios build in.
                                        • Helper for permanently storing values in the Arduinos EEPROM.
                                        • Acknowledgments can now be requested from gateway and other sensors in network.
                                        • Smaller footprint.
                                        • The message structure has been adopted to work better on RPi platform.
                                        • Binary payloads supported and used for integers between sensors.
                                        • Configuration message (only metric setting in it today).
                                        • Allow static parent (no dynamic lookups)
                                        • Callbacks for incoming messages and time. No synchronous waiting methods any more -> no missed messages.

                                        All examples in the development branch above has been converted to use the new functionality of the library.

                                        The new API:

                                        /**
                                        * Constructor
                                        *
                                        * Creates a new instance of Sensor class.
                                        *
                                        * @param _cepin The pin attached to RF24 Chip Enable on the RF module (defualt 9)
                                        * @param _cspin The pin attached to RF24 Chip Select (default 10)
                                        */
                                        MySensor(uint8_t _cepin=9, uint8_t _cspin=10);
                                        
                                        /**
                                        * Begin operation of the MySensors library
                                        *
                                        * Call this in setup(), before calling any other sensor net library methods.
                                        * @param incomingMessageCallback Callback function for incoming messages from other nodes or controller and request responses. Default is NULL.
                                        * @param nodeId The unique id (1-254) for this sensor. Default is AUTO(255) which means sensor tries to fetch an id from controller.
                                        * @param repeaterMode Activate repeater mode. This node will forward messages to other nodes in the radio network. Make sure to call process() regularly. Default in false
                                        * @param parentNodeId Use this to force node to always communicate with a certain parent node. Default is AUTO which means node automatically tries to find a parent.
                                        * @param paLevel Radio PA Level for this sensor. Default RF24_PA_MAX
                                        * @param channel Radio channel. Default is channel 76
                                        * @param dataRate Radio transmission speed. Default RF24_1MBPS
                                        */
                                        
                                        void begin(void (* msgCallback)(const MyMessage &)=NULL, uint8_t nodeId=AUTO, boolean repeaterMode=false, uint8_t parentNodeId=AUTO, rf24_pa_dbm_e paLevel=RF24_PA_LEVEL, uint8_t channel=RF24_CHANNEL, rf24_datarate_e dataRate=RF24_DATARATE);
                                        
                                        /**
                                         * Return the nodes nodeId.
                                         */
                                        uint8_t getNodeId();
                                        
                                        /**
                                        * Each node must present all attached sensors before any values can be handled correctly by the controller.
                                        * It is usually good to present all attached sensors after power-up in setup().
                                        *
                                        * @param sensorId Select a unique sensor id for this sensor. Choose a number between 0-254.
                                        * @param sensorType The sensor type. See sensor typedef in MyMessage.h.
                                        * @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
                                        */
                                        void present(uint8_t sensorId, uint8_t sensorType, bool ack=false);
                                        
                                        /**
                                         * Sends sketch meta information to the gateway. Not mandatory but a nice thing to do.
                                         * @param name String containing a short Sketch name or NULL  if not applicable
                                         * @param version String containing a short Sketch version or NULL if not applicable
                                         * @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
                                         *
                                         */
                                        void sendSketchInfo(const char *name, const char *version, bool ack=false);
                                        
                                        /**
                                        * Sends a message to gateway or one of the other nodes in the radio network
                                        *
                                        * @param msg Message to send
                                        * @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
                                        * @return true Returns true if message reached the first stop on its way to destination.
                                        */
                                        bool send(MyMessage &msg, bool ack=false);
                                        
                                        /**
                                         * Send this nodes battery level to gateway.
                                         * @param level Level between 0-100(%)
                                         * @param ack Set this to true if you want destination node to send ack back to this node. Default is not to request any ack.
                                         *
                                         */
                                        void sendBatteryLevel(uint8_t level, bool ack=false);
                                        
                                        /**
                                        * Requests a value from gateway or some other sensor in the radio network.
                                        * Make sure to add callback-method in begin-method to handle request responses.
                                        *
                                        * @param childSensorId  The unique child id for the different sensors connected to this Arduino. 0-254.
                                        * @param variableType The variableType to fetch
                                        * @param destination The nodeId of other node in radio network. Default is gateway
                                        */
                                        void request(uint8_t childSensorId, uint8_t variableType, uint8_t destination=GATEWAY_ADDRESS);
                                        
                                        /**
                                         * Requests time from controller. Answer will be delivered to callback.
                                         *
                                         * @param callback for time request. Incoming argument is seconds since 1970.
                                         */
                                        void requestTime(void (* timeCallback)(unsigned long));
                                        
                                        
                                        /**
                                         * Processes incoming messages to this node. If this is a relaying node it will
                                        * Returns true if there is a message addressed for this node just was received.
                                        * Use callback to handle incoming messages.
                                        */
                                        boolean process();
                                        
                                        /**
                                         * Returns the most recent node configuration received from controller
                                         */
                                        ControllerConfig getConfig();
                                        
                                        /**
                                         * Save a state (in local EEPROM). Good for actuators to "remember" state between
                                         * power cycles.
                                         *
                                         * You have 256 bytes to play with. Note that there is a limitation on the number
                                         * of writes the EEPROM can handle (~100 000 cycles).
                                         *
                                         * @param pos The position to store value in (0-255)
                                         * @param Value to store in position
                                         */
                                        void saveState(uint8_t pos, uint8_t value);
                                        
                                        /**
                                         * Load a state (from local EEPROM).
                                         *
                                         * @param pos The position to fetch value from  (0-255)
                                         * @return Value to store in position
                                         */
                                        uint8_t loadState(uint8_t pos);
                                        
                                        /**
                                        * Returns the last received message
                                        */
                                        MyMessage& getLastMessage(void);
                                        
                                        /**
                                         * Sleep (PowerDownMode) the Arduino and radio. Wake up on timer.
                                         * @param ms Number of milliseconds to sleep.
                                         */
                                        void sleep(int ms);
                                        
                                        /**
                                         * Sleep (PowerDownMode) the Arduino and radio. Wake up on timer or pin change.
                                         * See: http://arduino.cc/en/Reference/attachInterrupt for details on modes and which pin
                                         * is assigned to what interrupt. On Nano/Pro Mini: 0=Pin2, 1=Pin3
                                         * @param interrupt Interrupt that should trigger the wakeup
                                         * @param mode RISING, FALLING, CHANGE
                                         * @param ms Number of milliseconds to sleep or 0 to sleep forever
                                         * @return true if wake up was triggered by pin change and false means timer woke it up.
                                         */
                                        bool sleep(int interrupt, int mode, int ms=0);
                                        
                                        /**
                                         * getInternalTemp
                                         *
                                         * Read temp from internal (ATMEGA328 only) temperature sensor. This reading is very
                                         * inaccurate so we round the result to full degrees celsius.
                                         * http://playground.arduino.cc/Main/InternalTemperatureSensor
                                         *
                                         * @return Temperature in full degrees Celsius.
                                         */
                                        int getInternalTemp(void);
                                        

                                        ###To convert an old 1.3 sketch follow this guide:

                                        Include section

                                        Remove the following includes
                                        #include <Sleep_n0m1.h>
                                        #include <EEPROM.h>
                                        #include <RF24.h>
                                        #include <Sensor.h>
                                        #include <Relay.h>

                                        Add
                                        #include <MySensor.h>

                                        Global variable scope

                                        Change the following lines

                                        Sensor gw;
                                        or
                                        Relay gw;
                                        

                                        To

                                        MySensor gw;
                                        

                                        Also message containers for outgoing messages. E.g. Light level message for child sensor id 1.

                                        MyMessage msg(1, V_LIGHT_LEVEL);
                                        

                                        ####Setup()
                                        In setup() replace sendPresentation with present.
                                        Also note that begin() now allows you to add an function-argument to get callbacks for incoming messages (actuators). begin also controls wether this node should act as an repeater node. See above for full argument list.

                                        ####Loop()

                                        The sending of values looks a bit different. The old sketches could look like this:

                                        gw.sendVariable(CHILD_ID_LIGHT, V_LIGHT_LEVEL, lux);
                                        

                                        In new code you send a value by using the MyMessage contaner defined in global scope. Fill it with the value to send like this (where lux is light level in this case).

                                         gw.send(msg.set(lux));
                                        

                                        Replace any sleeping with the new build in sleep functions. The old code might have a few lines like this:

                                        delay(500);
                                        gw.powerDown();
                                        sleep.pwrDownMode(); //set sleep mode
                                        sleep.sleepDelay(SLEEP_TIME * 1000);
                                        

                                        Replace those with:

                                        gw.sleep(<sleep time in milliseconds>);
                                        
                                        liningerL Offline
                                        liningerL Offline
                                        lininger
                                        wrote on last edited by
                                        #93

                                        @hek Any tips on upgrading the June 1.4b1 to the August 1.4b1. I just attempted it with disastrous results. :)

                                        I started off.

                                        1. Uploading the Vera files
                                        2. Re-compiled the new gateway (after changing the my IP Address and such)
                                        3. Re-complied the Repeaters

                                        Just to get going. Both repeaters failed at startup with the standard FAIL in the debug logs. Wiping the Eeprom and trying again did not work. Dropping the repeaters for vera and re-including did not work? Finally went back to the June build and restored the vera from last night and then two other units failed to come back online. Had to replace the antennas on those two units to get them back on-line – BIZARRE.

                                        1. Do all the sensors have to be updated at once?
                                        2. Will existing sensors under the June 1.4b1 build co-exist with the August 1.4b1 Gateway build?
                                        3. Can we just recompile our existing June sketches under the new mySensors library as long as no compile errors show?

                                        Thanks

                                        hekH 1 Reply Last reply
                                        0
                                        • liningerL lininger

                                          @hek Any tips on upgrading the June 1.4b1 to the August 1.4b1. I just attempted it with disastrous results. :)

                                          I started off.

                                          1. Uploading the Vera files
                                          2. Re-compiled the new gateway (after changing the my IP Address and such)
                                          3. Re-complied the Repeaters

                                          Just to get going. Both repeaters failed at startup with the standard FAIL in the debug logs. Wiping the Eeprom and trying again did not work. Dropping the repeaters for vera and re-including did not work? Finally went back to the June build and restored the vera from last night and then two other units failed to come back online. Had to replace the antennas on those two units to get them back on-line – BIZARRE.

                                          1. Do all the sensors have to be updated at once?
                                          2. Will existing sensors under the June 1.4b1 build co-exist with the August 1.4b1 Gateway build?
                                          3. Can we just recompile our existing June sketches under the new mySensors library as long as no compile errors show?

                                          Thanks

                                          hekH Offline
                                          hekH Offline
                                          hek
                                          Admin
                                          wrote on last edited by hek
                                          #94

                                          @lininger

                                          Yes, you'll have to recompile/update them all as message format has changed. No need for wiping eeprom or re-include sensors. Also update Vera plugin.

                                          Replacing antenna should not be necessary and I don't understand why that would change anything..

                                          YveauxY 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          6

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 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