Generic UDP Controller with multi value sensors problem

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
stefbo
Normal user
Posts: 19
Joined: 24 Apr 2016, 15:35
Location: Germany

Generic UDP Controller with multi value sensors problem

#1 Post by stefbo » 13 Sep 2018, 23:33

Hi,
I am using UDP controller to send data to influxdb. This works well for single valued sensors like DS18B20. However for multi value sensors like BME280 only the first value is transfered. Looking at the code for the controller (C010.ino) I conclude that for each element several txt entries are created. However these are not processed. As a workaround I creted a separate element for each value, This seems to work for me, but I am not sure if it is consistent with the original ideas...
The UDP controller worked fine with older versions (I assume my last version was from June '18)

Stefan

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Generic UDP Controller with multi value sensors problem

#2 Post by TD-er » 14 Sep 2018, 00:18

Could you post a part of your changes?
I did change a lot recently regarding the controllers, so it may very well be there is some bug left.

So please help me here to fix it :)

stefbo
Normal user
Posts: 19
Joined: 24 Apr 2016, 15:35
Location: Germany

Re: Generic UDP Controller with multi value sensors problem

#3 Post by stefbo » 15 Sep 2018, 12:27

Sure.
here is what I did:

Code: Select all

    case CPLUGIN_PROTOCOL_SEND:
      {
        byte valueCount = getValueCountFromSensorType(event->sensorType);
        C010_queue_element element(event, 1);
        if (ExtraTaskSettings.TaskDeviceValueNames[0][0] == 0)
          PluginCall(PLUGIN_GET_DEVICEVALUENAMES, event, dummyString);

        ControllerSettingsStruct ControllerSettings;
        LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));

        for (byte x = 0; x < valueCount; x++)
        {
          bool isvalid;
          String formattedValue = formatUserVar(event, x, isvalid);
          if (isvalid) {
            element.txt[0] = "";
            element.txt[0] += ControllerSettings.Publish;
            parseControllerVariables(element.txt[0], event, false);
            element.txt[0].replace(F("%valname%"), ExtraTaskSettings.TaskDeviceValueNames[x]);
            element.txt[0].replace(F("%value%"), formattedValue);
            if (loglevelActiveFor(LOG_LEVEL_DEBUG_MORE)) {
              char log[80];
              element.txt[0].toCharArray(log, 80);
              addLog(LOG_LEVEL_DEBUG_MORE, log);
            }
          }
          success = C010_DelayHandler.addToQueue(element);
          scheduleNextDelayQueue(TIMER_C010_DELAY_QUEUE, C010_DelayHandler.getNextScheduleTime());
        }

        break;
      }

To sum up my changes:
  • only write to element.txt[0] instead of element.txt[x]
  • put addToQueue and scheduleNextDelayQueue in the loop
Open point: correct value for success

Stefan

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Generic UDP Controller with multi value sensors problem

#4 Post by TD-er » 16 Sep 2018, 11:04


Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 93 guests