Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

const missing in class member declarations #1

Open
mverch67 opened this issue Jun 13, 2024 · 0 comments
Open

const missing in class member declarations #1

mverch67 opened this issue Jun 13, 2024 · 0 comments

Comments

@mverch67
Copy link

mverch67 commented Jun 13, 2024

The two methods

String getValue(char *keys);
String getUnit(char *keys);

must be declared const char*:

String getValue(const char *keys);
String getUnit(const char *keys);

otherwise get compiler warnings when using this interface:

src/modules/Telemetry/Sensor/DFRobotLarkSensor.cpp: In member function 'virtual bool DFRobotLarkSensor::getMetrics(meshtastic_Telemetry*)':
src/modules/Telemetry/Sensor/DFRobotLarkSensor.cpp:38:80: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     measurement->variant.environment_metrics.temperature = lark.getValue("Temp").toFloat();
                                                                                ^
src/modules/Telemetry/Sensor/DFRobotLarkSensor.cpp:39:86: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     measurement->variant.environment_metrics.relative_humidity = lark.getValue("Humi").toFloat();
                                                                                      ^
src/modules/Telemetry/Sensor/DFRobotLarkSensor.cpp:40:80: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     measurement->variant.environment_metrics.wind_speed = lark.getValue("Speed").toFloat();
                                                                                ^
src/modules/Telemetry/Sensor/DFRobotLarkSensor.cpp:41:109: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     measurement->variant.environment_metrics.wind_direction = GeoCoord::bearingToDegrees(lark.getValue("Dir").c_str());
                                                                                                             ^
src/modules/Telemetry/Sensor/DFRobotLarkSensor.cpp:42:92: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     measurement->variant.environment_metrics.barometric_pressure = lark.getValue("Pressure").toFloat();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant