How to write a constructor for many input cases

Hi all,
So I am writing an addon to an existing FRSKY arduino library so that I can use custom arduino sensors in addition to off shelves sensor such as GPS, altimeter and so on .

The library communicates over the SPORT bus system where there is a master that polls the different sensor(max 28) at different intervals.

Everything is working fine, but I am unsure how to make it more generic and open source so that everyone can make their own sensors as well. In the orginal libray the constructor only takes in ID if specified. Then there is a method to setData for the given parameters for that spesific sensor.

The question I have is what is the best practice to make a generic arduino sensor?

The sensor can have 512 parameters and each parameter can be sent with different time intervals.

Currently the constructor looks like this for an inbuilt sensor:

FrSkySportSensorFlvss flvss2(FrSkySportSensor::ID15);  // Create FLVSS sensor with given ID

//with this method to send data:

  flvss2.setData(4.13, 4.14);                          // Cell voltages in volts (cells 7-8)

In the default library the timeinterval is hardcoded such as

#define RPM_T1_DATA_PERIOD  1000
#define RPM_T2_DATA_PERIOD  1000
#define RPM_ROT_DATA_PERIOD 500

Sorry for the long introduction but here is where it start,
If I knew how many parameters everyone would use for their sensor I would typically just set the timeinterval in the constructor such as:

FrSkySportSensorFlvss flvss2(FrSkySportSensor::ID15,1000,500);  // Create FLVSS sensor with given ID and poll interval 1000ms for parameter1 and 500ms for parameter 2

Is there a good way to do up to xx parameters? My current suggestion is to use string instead of int and split the string such as:

FrSkySportSensorFlvss flvss2(FrSkySportSensor::ID15,"1000,500");  // Create FLVSS sensor with given ID and poll interval 1000ms for parameter1 and 500ms for parameter 2

or is it better to have all default to 1000ms and then in your setup rotuine do like this

flvss2.setPollInterval(2,500); // Setting parameter  2 poll interval to 500ms

the same analogy goes for the method setData which also needs to be able to handle up to XX parameters

void FrSkySportSensorRpm::setData(uint32_t rpm, float t1, float t2)
{
  rpmData = rpm * 2;
  t1Data = (int32_t)round(t1);
  t2Data = (int32_t)round(t2);
}

where I thought could be rewritten to something like this:

flvss2.setData("float:2;176.32,uint;34"); // setting first parameter as float with value 176.32 and second as unsigned int with value 34.

My biggest concern with going down the whole string split path is that it will be slow, but maybe someone out there has done something similiar when you simply dont know how many parameters the user want to send and what type the parameter is.

Any tips will be highly appreciated.

There is a mechanism to pass an unknown number of arguments to a C++ function (these are called varadic functions, like printf()). See https://en.cppreference.com/w/cpp/utility/variadic for the C++ reference or you can do your own search now you know what to look for.

Thanks, just what i was looking for...