MCPcopy Create free account
hub / github.com/BlueAndi/Pixelix / save

Method save

src/Hal/SensorDataProvider.cpp:328–371  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

326}
327
328bool SensorDataProvider::save()
329{
330 JsonFile jsonFile(FILESYSTEM);
331 const size_t JSON_DOC_SIZE = 512U;
332 DynamicJsonDocument jsonDoc(JSON_DOC_SIZE);
333 uint8_t sensorIdx = 0U;
334 const uint8_t SENSOR_CNT = m_impl->getNumSensors();
335
336 while (SENSOR_CNT > sensorIdx)
337 {
338 ISensor* sensor = m_impl->getSensor(sensorIdx);
339
340 if (nullptr != sensor)
341 {
342 JsonArray jsonChannels = jsonDoc.createNestedArray(sensor->getName());
343
344 if (true == sensor->isAvailable())
345 {
346 uint8_t channelIdx = 0U;
347 const uint8_t CHANNEL_CNT = sensor->getNumChannels();
348
349 while (CHANNEL_CNT > channelIdx)
350 {
351 ISensorChannel* channel = sensor->getChannel(channelIdx);
352
353 if (nullptr == channel)
354 {
355 (void)jsonChannels.add("null");
356 }
357 else
358 {
359 channelOffsetToJson(jsonChannels, *channel);
360 }
361
362 ++channelIdx;
363 }
364 }
365 }
366
367 ++sensorIdx;
368 }
369
370 return jsonFile.save(SENSOR_CALIB_FILE_NAME, jsonDoc);
371}
372
373/******************************************************************************
374 * Protected Methods

Callers

nothing calls this directly

Calls 6

getNumSensorsMethod · 0.45
getSensorMethod · 0.45
getNameMethod · 0.45
isAvailableMethod · 0.45
getNumChannelsMethod · 0.45
getChannelMethod · 0.45

Tested by

no test coverage detected