Lint for config

This commit is contained in:
Magnus Persson 2022-01-06 22:20:23 +01:00
parent 5d9115137f
commit 88bd971b73
2 changed files with 546 additions and 546 deletions

View File

@ -21,8 +21,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
#include "config.h" #include "src/config.h"
#include "helper.h" #include "src/helper.h"
#include <LittleFS.h> #include <LittleFS.h>
Config myConfig; Config myConfig;
@ -33,9 +33,9 @@ Config myConfig;
Config::Config() { Config::Config() {
// Assiging default values // Assiging default values
char buf[30]; char buf[30];
sprintf(&buf[0], "%6x", (unsigned int) ESP.getChipId() ); snprintf(&buf[0], sizeof(buf) "%6x", (unsigned int) ESP.getChipId());
id = String(&buf[0]); id = String(&buf[0]);
sprintf(&buf[0], "" WIFI_MDNS "%s", getID() ); snprintf(&buf[0], sizeof(buf), "" WIFI_MDNS "%s", getID());
mDNS = String(&buf[0]); mDNS = String(&buf[0]);
#if LOG_LEVEL == 6 && !defined( CFG_DISABLE_LOGGING ) #if LOG_LEVEL == 6 && !defined( CFG_DISABLE_LOGGING )

View File

@ -21,14 +21,14 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
#ifndef _CONFIG_H #ifndef SRC_CONFIG_H_
#define _CONFIG_H #define SRC_CONFIG_H_
// Includes // Includes
#include "helper.h" #include <stdlib.h>
#include "src/helper.h"
#include <Arduino.h> #include <Arduino.h>
#include <ArduinoJson.h> #include <ArduinoJson.h>
#include <stdlib.h>
// defintions // defintions
#define CFG_JSON_BUFSIZE 3192 #define CFG_JSON_BUFSIZE 3192
@ -141,7 +141,7 @@ class Config {
public: public:
Config(); Config();
const char* getID() { return id.c_str(); }; const char* getID() { return id.c_str(); }
const char* getMDNS() { return mDNS.c_str(); } const char* getMDNS() { return mDNS.c_str(); }
void setMDNS(String s) { mDNS = s; saveNeeded = true; } void setMDNS(String s) { mDNS = s; saveNeeded = true; }
@ -185,8 +185,8 @@ class Config {
char getTempFormat() { return tempFormat; } char getTempFormat() { return tempFormat; }
void setTempFormat(char c) { tempFormat = c; saveNeeded = true; } void setTempFormat(char c) { tempFormat = c; saveNeeded = true; }
bool isTempC() { return tempFormat=='C'?false:true; }; bool isTempC() { return tempFormat == 'C' ? false : true; }
bool isTempF() { return tempFormat=='F'?false:true; }; bool isTempF() { return tempFormat == 'F' ? false : true; }
float getVoltageFactor() { return voltageFactor; } float getVoltageFactor() { return voltageFactor; }
void setVoltageFactor(float f) { voltageFactor = f; saveNeeded = true; } void setVoltageFactor(float f) { voltageFactor = f; saveNeeded = true; }
@ -204,8 +204,8 @@ class Config {
char getGravityFormat() { return gravityFormat; } char getGravityFormat() { return gravityFormat; }
void setGravityFormat(char c) { gravityFormat = c; saveNeeded = true; } void setGravityFormat(char c) { gravityFormat = c; saveNeeded = true; }
bool isGravitySG() { return gravityFormat=='G'?false:true; }; bool isGravitySG() { return gravityFormat == 'G' ? false : true; }
bool isGravityPlato() { return gravityFormat=='P'?false:true; }; bool isGravityPlato() { return gravityFormat == 'P' ? false : true; }
const RawGyroData& getGyroCalibration() { return gyroCalibration; } const RawGyroData& getGyroCalibration() { return gyroCalibration; }
void setGyroCalibration(const RawGyroData &r) { gyroCalibration = r; saveNeeded = true; } void setGyroCalibration(const RawGyroData &r) { gyroCalibration = r; saveNeeded = true; }
@ -218,13 +218,13 @@ class Config {
bool saveFile(); bool saveFile();
bool loadFile(); bool loadFile();
void checkFileSystem(); void checkFileSystem();
bool isSaveNeeded() { return saveNeeded; }; bool isSaveNeeded() { return saveNeeded; }
void setSaveNeeded() { saveNeeded = true; }; void setSaveNeeded() { saveNeeded = true; }
}; };
// Global instance created // Global instance created
extern Config myConfig; extern Config myConfig;
#endif // _CONFIG_H #endif // SRC_CONFIG_H_
// EOF // EOF