Device Configuration File

Hi Particle Community,

I would like some advice on configuration management of firmware across my devices.

At a high level my needs are to be able to keep my core device firmware the consistent but have file/object that specifies details of the devices configuration and have the firmware adapt to that config file.

Below is a sudo-code example of what I would like to achieve:


#include <InputDevice.h> // A dummy input device class
#include <OutputDevice.h> // A dummy output  device class

#include <ConfigFile.h> // Some sort of file where configuration for a particular device is stored

InputDevice inputDevices[config.numInputs];
OutputDevice outputDevices[config.numOutputs];

for(int i = 0; i < config.numInputs; i++){
    inputDevices[i] = new InputDevice(config.inputDeviceParams[i]);
}

for(int i = 0; i < config.numOutputs; i++){
    outputDevices[i] = new OutputDevice(config.outputDeviceParams[i]);
}

void setup(){
    for(int i = 0; i < config.numInputs; i++){
        inputDevices[i].Begin();
    }
    for(int i = 0; i < config.numOutputs; i++){
        outputDevices[i].Begin();
    }
}

void loop() {
    for(int i = 0; i < config.numInputs; i++){
        inputDevices[i].Update();
    }
    for(int i = 0; i < config.numOutputs; i++){
        outputDevices[i].Update();
    }
}

You mean pseudo-code, right?

sudo would be what you’d use to execute programs with root privileges on a Linux/Unix system :wink:

It depends on how complex the “dynamic” code parts are, but when these are only moderately elaborate, you can store device specific parameters in EEPROM or in the cloud (device notes) and decide which of these parts will be used based on these parameters.
This way you’d have one code base that is equipped with all the logic needed for any of your use-cases running on all your devices but each individual device will base it’s actual behaviour on the dynamic settings.

Haha yes, meant psuedo. Ive been doing too much Linux development that I didn’t even think about it.

I intend to make the configuration decently complex, I connect the Argon to a number of devices on i2c and spi buses. So the config should be flexibility enough to accommodate varying number of devices on those buses as well as different configurations of those devices.

The need for one code base with logic for all hardware options is a primary need. Having that config stored in a file would be helpful as well, so I could keep a record in a document repository.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.