@@ -120,32 +120,29 @@ class sfeNLCommands
120
120
// / @param theApp Pointer to the DataLogger App
121
121
// / @retval bool indicates success (true) or failure (!true)
122
122
// /
123
- // bool loadJSONSettings(sfeIoTNodeLoRaWAN *theApp)
124
- // {
125
- // if (!theApp)
126
- // return false;
127
-
128
- // flxLog_I(F("Load JSON Settings - Not Implemented"));
123
+ bool loadJSONSettings (sfeIoTNodeLoRaWAN *theApp)
124
+ {
125
+ if (!theApp)
126
+ return false ;
129
127
130
- // // // Create a JSON prefs serial object and read in the settings
131
- // // flxStorageJSONPrefSerial prefsSerial(flxSettings.fallbackBuffer() > 0 ? flxSettings.fallbackBuffer() :
132
- // 2000);
128
+ // Create a JSON prefs serial object and read in the settings
129
+ flxStorageJSONPrefSerial prefsSerial (flxSettings.fallbackBuffer () > 0 ? flxSettings.fallbackBuffer () : 2000 );
133
130
134
- // // // restore the settings from serial
135
- // // bool status = flxSettings.restoreObjectFromStorage(&flux, &prefsSerial);
136
- // // if (!status)
137
- // // return false;
131
+ // restore the settings from serial
132
+ bool status = flxSettings.restoreObjectFromStorage (&flux, &prefsSerial);
133
+ if (!status)
134
+ return false ;
138
135
139
- // // flxLog_I_(F("Settings restored from serial..."));
136
+ flxLog_I_ (F (" Settings restored from serial..." ));
140
137
141
- // // // now save the new settings in primary storage
142
- // // status = flxSettings.save(&flux, true);
143
- // // if (status)
144
- // // flxLog_N(F("saved locally"));
138
+ // now save the new settings in primary storage
139
+ status = flxSettings.save (&flux, true );
140
+ if (status)
141
+ flxLog_N (F (" saved locally" ));
145
142
146
- // // return status;
147
- // return true;
148
- // }
143
+ // return status;
144
+ return true ;
145
+ }
149
146
// ---------------------------------------------------------------------
150
147
// /
151
148
// / @brief Saves the current system to preferences/Settings
@@ -232,35 +229,37 @@ class sfeNLCommands
232
229
// / @param theApp Pointer to the DataLogger App
233
230
// / @retval bool indicates success (true) or failure (!true)
234
231
// /
235
- // bool sdCardStats(sfeIoTNodeLoRaWAN *theApp)
236
- // {
237
- // if (!theApp)
238
- // return false;
232
+ bool sdCardStats (sfeIoTNodeLoRaWAN *theApp)
233
+ {
234
+ if (!theApp)
235
+ return false ;
239
236
240
- // flxLog_I(F("SD Stats - Not Implemented"));
237
+ if (theApp->_theSDCard .enabled ())
238
+ {
239
+ char szSize[32 ];
240
+ char szCap[32 ];
241
+ char szAvail[32 ];
241
242
242
- // // if ( theApp->_theSDCard.enabled())
243
- // // {
243
+ uint64_t sd_size = theApp->_theSDCard .size ();
244
+ uint64_t sd_total = theApp-> _theSDCard . total ();
244
245
245
- // // char szSize[32];
246
- // // char szCap[32];
247
- // // char szAvail[32];
246
+ flx_utils::formatByteString (sd_size, 2 , szSize, sizeof (szSize));
247
+ flx_utils::formatByteString (sd_total, 2 , szCap, sizeof (szCap));
248
248
249
- // // flx_utils::formatByteString(theApp->_theSDCard.size(), 2, szSize, sizeof(szSize));
250
- // // flx_utils::formatByteString(theApp->_theSDCard.total(), 2, szCap, sizeof(szCap));
251
- // // flx_utils::formatByteString(theApp->_theSDCard.total() - theApp->_theSDCard.used(), 2, szAvail,
252
- // // sizeof(szAvail));
249
+ flxLog_I_ (" SD Card - Type: %s Size: %s Capacity: %s " , theApp->_theSDCard .type (), szSize, szCap);
253
250
254
- // // flxLog_I(F("SD Card - Type: %s Size: %s Capacity: %s Free: %s (%.1f%%)"), theApp->_theSDCard.type(),
255
- // // szSize,
256
- // // szCap, szAvail, 100. - (theApp->_theSDCard.used() / (float)theApp->_theSDCard.total() *
257
- // 100.));
258
- // // }
259
- // // else
260
- // // flxLog_I(F("SD card not available"));
251
+ flxLog_N_ (" ..." );
252
+ flxSerial.flush ();
253
+ // This call can take some time .. .so
254
+ uint64_t sd_used = theApp->_theSDCard .used ();
255
+ flx_utils::formatByteString (sd_total - sd_used, 2 , szAvail, sizeof (szAvail));
256
+ flxLog_N (" Free: %s (%.1f%%)" , szAvail, 100 . - (sd_used / (float )sd_total * 100 .));
257
+ }
258
+ else
259
+ flxLog_I (F (" SD card not available" ));
261
260
262
- // return true;
263
- // }
261
+ return true ;
262
+ }
264
263
265
264
// ---------------------------------------------------------------------
266
265
// /
@@ -429,11 +428,11 @@ class sfeNLCommands
429
428
{" clear-settings-forced" , &sfeNLCommands::clearDeviceSettingsForced},
430
429
{" restart" , &sfeNLCommands::restartDevice},
431
430
{" restart-forced" , &sfeNLCommands::restartDeviceForced},
432
- // {"json-settings", &sfeNLCommands::loadJSONSettings},
431
+ {" json-settings" , &sfeNLCommands::loadJSONSettings},
433
432
{" log-rate" , &sfeNLCommands::logRateStats},
434
433
{" log-rate-toggle" , &sfeNLCommands::logRateToggle},
435
434
{" log-now" , &sfeNLCommands::logObservationNow},
436
- // {"sdcard", &sfeNLCommands::sdCardStats},
435
+ {" sdcard" , &sfeNLCommands::sdCardStats},
437
436
{" devices" , &sfeNLCommands::listLoadedDevices},
438
437
{" save-settings" , &sfeNLCommands::saveSettings},
439
438
{" heap" , &sfeNLCommands::heapStatus},
@@ -472,6 +471,7 @@ class sfeNLCommands
472
471
flxLog_N (F (" Unknown Command: `%s`" ), sBuffer .c_str ());
473
472
status = false ;
474
473
}
474
+ flxLog_N (" " );
475
475
return status;
476
476
}
477
477
};
0 commit comments