-->
Page 1 of 1

Proper way to store and update config via REST API

PostPosted: Sat May 22, 2021 3:51 pm
by Ice Cold
Hello everyone! I need to store config for my device so it can be updated easily via REST API . Now, what I do is just storing a json file like this
Code: Select allHello everyone
{

  "ap_name":"myDEvice",
  "ap_password":"mypassword",
  "ap_maxconn": 2,
  "ap_channel": 6,
  "sensors":[
    {
      "id":"sensor1",
      "pin": 0,
      "threshold": 0,
      ...   

    },
    {
      "id":"sensor2",
      "pin": 1,
      "threshold": 0,
      ...
    }
  ]
}

which I handle with ArduinoJson. To update some of the params I need to read the whole file, update desired json element and write it back. Possibly there are some better ways to do so ?