From 2b2a0ce294e7dcbcf72df9e88517d49249684b7d Mon Sep 17 00:00:00 2001 From: Patrick Fallberg Date: Sun, 9 Aug 2015 02:01:24 +0200 Subject: [PATCH] Fixed various sketch-specific warnings --- .../DimmableLightWithRotaryEncoderButton.ino | 2 +- .../MySensors/examples/DistanceSensor/DistanceSensor.ino | 2 +- .../MySensors/examples/LightningSensor/LightningSensor.ino | 3 +-- libraries/MySensors/examples/MQTTGateway/MQTTGateway.ino | 5 +++-- libraries/MySensors/examples/RainGauge/RainGauge.ino | 2 +- .../RealTimeClockDisplaySensor.ino | 4 ++-- .../examples/SecretKnockSensor/SecretKnockSensor.ino | 1 - .../MySensors/examples/SecureActuator/SecureActuator.ino | 2 +- .../examples/Sha204Personalizer/Sha204Personalizer.ino | 3 ++- .../MySensors/examples/TimeAwareSensor/TimeAwareSensor.ino | 4 ++-- libraries/MySensors/examples/UVSensor/UVSensor.ino | 4 ++-- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/libraries/MySensors/examples/DimmableLightWithRotaryEncoderButton/DimmableLightWithRotaryEncoderButton.ino b/libraries/MySensors/examples/DimmableLightWithRotaryEncoderButton/DimmableLightWithRotaryEncoderButton.ino index 81fe076..2386526 100644 --- a/libraries/MySensors/examples/DimmableLightWithRotaryEncoderButton/DimmableLightWithRotaryEncoderButton.ino +++ b/libraries/MySensors/examples/DimmableLightWithRotaryEncoderButton/DimmableLightWithRotaryEncoderButton.ino @@ -133,7 +133,7 @@ void incomingMessage(const MyMessage &message) newLevel = loadLevelState(EEPROM_DIM_LEVEL_SAVE); } // Send dimmer level back to controller with ack enabled - gw.send(dimmerMsg.set(0), true); + gw.send(dimmerMsg.set(newLevel), true); // We do not change any levels here until ack comes back from gateway return; } else if (message.type == V_DIMMER) { diff --git a/libraries/MySensors/examples/DistanceSensor/DistanceSensor.ino b/libraries/MySensors/examples/DistanceSensor/DistanceSensor.ino index a21e86a..59f15a8 100644 --- a/libraries/MySensors/examples/DistanceSensor/DistanceSensor.ino +++ b/libraries/MySensors/examples/DistanceSensor/DistanceSensor.ino @@ -51,7 +51,7 @@ void setup() // Register all sensors to gw (they will be created as child devices) gw.present(CHILD_ID, S_DISTANCE); - boolean metric = gw.getConfig().isMetric; + metric = gw.getConfig().isMetric; } void loop() diff --git a/libraries/MySensors/examples/LightningSensor/LightningSensor.ino b/libraries/MySensors/examples/LightningSensor/LightningSensor.ino index 8d2bace..63b1a53 100644 --- a/libraries/MySensors/examples/LightningSensor/LightningSensor.ino +++ b/libraries/MySensors/examples/LightningSensor/LightningSensor.ino @@ -42,7 +42,6 @@ void setup() // Register all sensors to gw (they will be created as child devices) gw.present(CHILD_ID_DISTANCE, S_DISTANCE); gw.present(CHILD_ID_INTENSITY, S_CUSTOM); - boolean metric = gw.getConfig().isMetric; Serial.begin(115200); Serial.println("Playing With Fusion: AS3935 Lightning Sensor, SEN-39001"); @@ -118,4 +117,4 @@ void loop() void AS3935_ISR() { AS3935_ISR_Trig = 1; -} \ No newline at end of file +} diff --git a/libraries/MySensors/examples/MQTTGateway/MQTTGateway.ino b/libraries/MySensors/examples/MQTTGateway/MQTTGateway.ino index 0bb722d..34d3fff 100644 --- a/libraries/MySensors/examples/MQTTGateway/MQTTGateway.ino +++ b/libraries/MySensors/examples/MQTTGateway/MQTTGateway.ino @@ -279,6 +279,7 @@ void processMQTTMessage(char *inputString, uint8_t inputPos) { uint8_t i = 0; buffer[0]= 0; buffsize = 0; + (void)inputPos; if ((uint8_t)inputString[0] >> 4 == MQTTCONNECT) { buffer[buffsize++] = MQTTCONNACK << 4; @@ -336,7 +337,7 @@ void processMQTTMessage(char *inputString, uint8_t inputPos) { } else if (i==2) { msg.sensor = atoi(str); //SensorID } else if (i==3) { - char match=255; //SensorType + unsigned char match=255; //SensorType #ifdef MQTT_TRANSLATE_TYPES for (uint8_t j=0; strcpy_P(convBuf, (char*)pgm_read_word(&(vType[j]))) ; j++) { @@ -348,7 +349,7 @@ void processMQTTMessage(char *inputString, uint8_t inputPos) { } #endif - if ( atoi(str)!=0 || str=="0" ) { + if ( atoi(str)!=0 || (str[0]=='0' && str[1] =='\0') ) { match=atoi(str); } diff --git a/libraries/MySensors/examples/RainGauge/RainGauge.ino b/libraries/MySensors/examples/RainGauge/RainGauge.ino index 475eb0c..59b84a6 100644 --- a/libraries/MySensors/examples/RainGauge/RainGauge.ino +++ b/libraries/MySensors/examples/RainGauge/RainGauge.ino @@ -123,7 +123,7 @@ volatile int wasTippedBuffer = 0; int rainSensorThreshold = 50; //default rain sensor sensitivity in hundredths. Will be overwritten with msgTrippedVar2. byte state = 0; byte oldState = -1; -int lastRainRate = 0; +unsigned int lastRainRate = 0; int lastMeasure = 0; boolean gotTime = false; byte lastHour; diff --git a/libraries/MySensors/examples/RealTimeClockDisplaySensor/RealTimeClockDisplaySensor.ino b/libraries/MySensors/examples/RealTimeClockDisplaySensor/RealTimeClockDisplaySensor.ino index f0ca797..6db9727 100644 --- a/libraries/MySensors/examples/RealTimeClockDisplaySensor/RealTimeClockDisplaySensor.ino +++ b/libraries/MySensors/examples/RealTimeClockDisplaySensor/RealTimeClockDisplaySensor.ino @@ -88,8 +88,8 @@ void loop() // If no time has been received yet, request it every 10 second from controller // When time has been received, request update every hour - if ((!timeReceived && now-lastRequest > (unsigned long)(10*1000)) - || (timeReceived && now-lastRequest > (unsigned long)(60*1000*60))) { + if ((!timeReceived && (now-lastRequest) > (10UL*1000UL)) + || (timeReceived && (now-lastRequest) > (60UL*1000UL*60UL))) { // Request time from controller. Serial.println("requesting time"); gw.requestTime(receiveTime); diff --git a/libraries/MySensors/examples/SecretKnockSensor/SecretKnockSensor.ino b/libraries/MySensors/examples/SecretKnockSensor/SecretKnockSensor.ino index ec2a4ef..56374e5 100644 --- a/libraries/MySensors/examples/SecretKnockSensor/SecretKnockSensor.ino +++ b/libraries/MySensors/examples/SecretKnockSensor/SecretKnockSensor.ino @@ -298,7 +298,6 @@ boolean validateKnock(){ // reads the secret knock from EEPROM. (if any.) void readSecretKnock(){ byte reading; - int i; reading = gw.loadState(1); if (reading == eepromValid){ // only read EEPROM if the signature byte is correct. for (int i=0; i < maximumKnocks ;i++){ diff --git a/libraries/MySensors/examples/SecureActuator/SecureActuator.ino b/libraries/MySensors/examples/SecureActuator/SecureActuator.ino index ae40fad..cb69354 100644 --- a/libraries/MySensors/examples/SecureActuator/SecureActuator.ino +++ b/libraries/MySensors/examples/SecureActuator/SecureActuator.ino @@ -71,7 +71,7 @@ MySigningAtsha204 signer; #endif MySensor gw(radio, hw, signer); #else -#warning SecureActuator cannot possibly be secure without signing enabled +// WARNING! SecureActuator cannot possibly be secure without signing enabled MySensor gw(radio, hw); #endif diff --git a/libraries/MySensors/examples/Sha204Personalizer/Sha204Personalizer.ino b/libraries/MySensors/examples/Sha204Personalizer/Sha204Personalizer.ino index 92acedf..4c542df 100644 --- a/libraries/MySensors/examples/Sha204Personalizer/Sha204Personalizer.ino +++ b/libraries/MySensors/examples/Sha204Personalizer/Sha204Personalizer.ino @@ -237,7 +237,6 @@ void write_key(uint8_t* key) void dump_configuration() { - uint8_t config_word[4]; uint8_t tx_buffer[SHA204_CMD_SIZE_MAX]; uint8_t rx_buffer[SHA204_RSP_SIZE_MAX]; uint8_t ret_code; @@ -682,6 +681,8 @@ void setup() uint8_t lockConfig = 0; uint8_t lockValue = 0; uint16_t crc; + (void)crc; + Serial.begin(115200); Serial.println(F("ATSHA204 personalization sketch for MySensors usage.")); diff --git a/libraries/MySensors/examples/TimeAwareSensor/TimeAwareSensor.ino b/libraries/MySensors/examples/TimeAwareSensor/TimeAwareSensor.ino index 7dfe1b0..f546119 100644 --- a/libraries/MySensors/examples/TimeAwareSensor/TimeAwareSensor.ino +++ b/libraries/MySensors/examples/TimeAwareSensor/TimeAwareSensor.ino @@ -59,8 +59,8 @@ void loop() // If no time has been received yet, request it every 10 second from controller // When time has been received, request update every hour - if ((!timeReceived && now-lastRequest > 10*1000) - || (timeReceived && now-lastRequest > 60*1000*60)) { + if ((!timeReceived && (now-lastRequest) > (10UL*1000UL)) + || (timeReceived && (now-lastRequest) > (60UL*1000UL*60UL))) { // Request time from controller. Serial.println("requesting time"); gw.requestTime(receiveTime); diff --git a/libraries/MySensors/examples/UVSensor/UVSensor.ino b/libraries/MySensors/examples/UVSensor/UVSensor.ino index a00ed7f..7db2aae 100644 --- a/libraries/MySensors/examples/UVSensor/UVSensor.ino +++ b/libraries/MySensors/examples/UVSensor/UVSensor.ino @@ -53,7 +53,7 @@ MyMessage uvMsg(CHILD_ID_UV, V_UV); unsigned long lastSend =0; float uvIndex; float lastUV = -1; -int uvIndexValue [12] = { 50, 227, 318, 408, 503, 606, 696, 795, 881, 976, 1079, 1170}; +uint16_t uvIndexValue [12] = { 50, 227, 318, 408, 503, 606, 696, 795, 881, 976, 1079, 1170}; void setup() { @@ -98,7 +98,7 @@ void loop() //Serial.println(uvIndex,2); //Send value to gateway if changed, or at least every 5 minutes - if ((uvIndex != lastUV)||(currentTime-lastSend >= 5*60*1000)) { + if ((uvIndex != lastUV)||(currentTime-lastSend >= 5UL*60UL*1000UL)) { lastSend=currentTime; gw.send(uvMsg.set(uvIndex,2)); lastUV = uvIndex;