Page 1 of 1

Generic UDP Controller with multi value sensors problem

Posted: 13 Sep 2018, 23:33
by stefbo
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

Re: Generic UDP Controller with multi value sensors problem

Posted: 14 Sep 2018, 00:18
by TD-er
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 :)

Re: Generic UDP Controller with multi value sensors problem

Posted: 15 Sep 2018, 12:27
by stefbo
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

Re: Generic UDP Controller with multi value sensors problem

Posted: 16 Sep 2018, 11:04
by TD-er