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. Bug Reports
  3. Strange behavior of radio message callback

Strange behavior of radio message callback

Scheduled Pinned Locked Moved Bug Reports
5 Posts 2 Posters 2.0k Views 1 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.
  • G Offline
    G Offline
    GothicMaestro
    wrote on last edited by GothicMaestro
    #1

    Hi.
    I've stumbled upon a strange behavior of radio meassge callback firing. I have a node with a temperature sensor and a relay.
    In setup() I have
    gw.begin(onMessageReceived);
    ......

    in loop()
    gw.process();
    .........
    if (lastTemperature[7] != temperature && temperature != -127.00)
    {
    gw.send(msgTemperature.setSensor(7).set(temperature, 1));
    lastTemperature[sensorID] = temperature;
    }
    ......

    And my callback is:

    void onMessageReceived(const MyMessage &message)
    {
    if (message.type == V_LIGHT)
    {
    bool value = message.getBool();
    digitalWrite(message.sensor + FIRST_RELAY_PIN, value ? RELAY_ON : RELAY_OFF);
    gw.saveState(message.sensor, value);
    ....................

    When I once send a switch command to a relay from my controller callback fires up and relay switches. But then it keeps firing with the same parameter value EVERY time when temperature value is sent to controller. That was unexpected to me. Investigation of code of MySensor::process() function shows that value of "len" variable

    uint8_t len = RF24::getDynamicPayloadSize();
    RF24::read(&msg, len);

    equals 8 in case when the "true" radio message for relay is received and equals 1 in the rest of cases when temperature value is sent. In other words, callback fires both when message is received (len = 8 ) and is sent by a node (len = 1).

    Changing the end code of process() from

    if (msgCallback != NULL)
    msgCallback(msg);

    to

    if (msgCallback != NULL && len > 1)
    msgCallback(msg);

    solved the issue. But I think it's a temporary patch and not the right solution. Could the MySensors developers please take a look at this issue.
    And thank you for a great project and all hard work done!

    1 Reply Last reply
    0
    • hekH Offline
      hekH Offline
      hek
      Admin
      wrote on last edited by hek
      #2

      Are you running 1.4.1? If not please re-verify and post your results.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        GothicMaestro
        wrote on last edited by
        #3

        No, I'm running 1.4.
        OK, I'll give it a try and post results. Thank you.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          GothicMaestro
          wrote on last edited by
          #4

          Well now after switching to 1.4.1 it seems to be OK. Also the commands from controller seem to arrive faster.
          Thank you for your help!

          1 Reply Last reply
          0
          • hekH Offline
            hekH Offline
            hek
            Admin
            wrote on last edited by
            #5

            Good to hear.

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


            20

            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