Skip to content

Commit e06c29a

Browse files
committed
Refactor sensorsReturningFalse to existing no events block
1 parent 137ce64 commit e06c29a

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

src/components/i2c/WipperSnapper_I2C.cpp

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,6 @@ void WipperSnapper_Component_I2C::update() {
10351035
} else {
10361036
WS_DEBUG_PRINTLN(
10371037
"ERROR: Failed to get ambient temperature sensor reading!");
1038-
sensorsReturningFalse = true;
10391038
if (retries == 1) {
10401039
(*iter)->setSensorAmbientTempPeriodPrv(curTime);
10411040
}
@@ -1063,7 +1062,6 @@ void WipperSnapper_Component_I2C::update() {
10631062
} else {
10641063
WS_DEBUG_PRINTLN(
10651064
"ERROR: Failed to obtain ambient temp. (°F)) sensor reading!");
1066-
sensorsReturningFalse = true;
10671065
if (retries == 1) {
10681066
(*iter)->setSensorAmbientTempFPeriodPrv(curTime);
10691067
}
@@ -1092,7 +1090,6 @@ void WipperSnapper_Component_I2C::update() {
10921090
} else {
10931091
WS_DEBUG_PRINTLN(
10941092
"ERROR: Failed to get object temperature sensor (°C) reading!");
1095-
sensorsReturningFalse = true;
10961093
if (retries == 1) {
10971094
(*iter)->setSensorObjectTempPeriodPrv(curTime);
10981095
}
@@ -1121,7 +1118,6 @@ void WipperSnapper_Component_I2C::update() {
11211118
} else {
11221119
WS_DEBUG_PRINTLN(
11231120
"ERROR: Failed to get object temperature sensor (°F) reading!");
1124-
sensorsReturningFalse = true;
11251121
if (retries == 1) {
11261122
(*iter)->setSensorObjectTempFPeriodPrv(curTime);
11271123
}
@@ -1173,7 +1169,6 @@ void WipperSnapper_Component_I2C::update() {
11731169
(*iter)->setSensorPressurePeriodPrv(curTime);
11741170
} else {
11751171
WS_DEBUG_PRINTLN("ERROR: Failed to get Pressure sensor reading!");
1176-
sensorsReturningFalse = true;
11771172
if (retries == 1) {
11781173
(*iter)->setSensorPressurePeriodPrv(curTime);
11791174
}
@@ -1198,7 +1193,6 @@ void WipperSnapper_Component_I2C::update() {
11981193
(*iter)->setSensorCO2PeriodPrv(curTime);
11991194
} else {
12001195
WS_DEBUG_PRINTLN("ERROR: Failed to obtain CO2 sensor reading!");
1201-
sensorsReturningFalse = true;
12021196
if (retries == 1) {
12031197
(*iter)->setSensorCO2PeriodPrv(curTime);
12041198
}
@@ -1223,7 +1217,6 @@ void WipperSnapper_Component_I2C::update() {
12231217
(*iter)->setSensorECO2PeriodPrv(curTime);
12241218
} else {
12251219
WS_DEBUG_PRINTLN("ERROR: Failed to obtain eCO2 sensor reading!");
1226-
sensorsReturningFalse = true;
12271220
if (retries == 1) {
12281221
(*iter)->setSensorECO2PeriodPrv(curTime);
12291222
}
@@ -1248,7 +1241,6 @@ void WipperSnapper_Component_I2C::update() {
12481241
(*iter)->setSensorTVOCPeriodPrv(curTime);
12491242
} else {
12501243
WS_DEBUG_PRINTLN("ERROR: Failed to obtain TVOC sensor reading!");
1251-
sensorsReturningFalse = true;
12521244
if (retries == 1) {
12531245
(*iter)->setSensorTVOCPeriodPrv(curTime);
12541246
}
@@ -1276,7 +1268,6 @@ void WipperSnapper_Component_I2C::update() {
12761268
(*iter)->setSensorAltitudePeriodPrv(curTime);
12771269
} else {
12781270
WS_DEBUG_PRINTLN("ERROR: Failed to get altitude sensor reading!");
1279-
sensorsReturningFalse = true;
12801271
if (retries == 1) {
12811272
(*iter)->setSensorAltitudePeriodPrv(curTime);
12821273
}
@@ -1303,7 +1294,6 @@ void WipperSnapper_Component_I2C::update() {
13031294
(*iter)->setSensorLightPeriodPrv(curTime);
13041295
} else {
13051296
WS_DEBUG_PRINTLN("ERROR: Failed to get light sensor reading!");
1306-
sensorsReturningFalse = true;
13071297
if (retries == 1) {
13081298
(*iter)->setSensorLightPeriodPrv(curTime);
13091299
}
@@ -1331,7 +1321,6 @@ void WipperSnapper_Component_I2C::update() {
13311321
(*iter)->setSensorPM10_STDPeriodPrv(curTime);
13321322
} else {
13331323
WS_DEBUG_PRINTLN("ERROR: Failed to get PM1.0 sensor reading!");
1334-
sensorsReturningFalse = true;
13351324
if (retries == 1) {
13361325
(*iter)->setSensorPM10_STDPeriodPrv(curTime);
13371326
}
@@ -1359,7 +1348,6 @@ void WipperSnapper_Component_I2C::update() {
13591348
(*iter)->setSensorPM25_STDPeriodPrv(curTime);
13601349
} else {
13611350
WS_DEBUG_PRINTLN("ERROR: Failed to get PM2.5 sensor reading!");
1362-
sensorsReturningFalse = true;
13631351
if (retries == 1) {
13641352
(*iter)->setSensorPM25_STDPeriodPrv(curTime);
13651353
}
@@ -1387,7 +1375,6 @@ void WipperSnapper_Component_I2C::update() {
13871375
curTime); // try again in curTime seconds
13881376
} else {
13891377
WS_DEBUG_PRINTLN("ERROR: Failed to get PM10.0 sensor reading!");
1390-
sensorsReturningFalse = true;
13911378
if (retries == 1) {
13921379
(*iter)->setSensorPM100_STDPeriodPrv(curTime);
13931380
}
@@ -1414,7 +1401,6 @@ void WipperSnapper_Component_I2C::update() {
14141401
(*iter)->setSensorVoltagePeriodPrv(curTime);
14151402
} else {
14161403
WS_DEBUG_PRINTLN("ERROR: Failed to get voltage sensor reading!");
1417-
sensorsReturningFalse = true;
14181404
if (retries == 1) {
14191405
(*iter)->setSensorVoltagePeriodPrv(curTime);
14201406
}
@@ -1441,7 +1427,6 @@ void WipperSnapper_Component_I2C::update() {
14411427
(*iter)->setSensorCurrentPeriodPrv(curTime);
14421428
} else {
14431429
WS_DEBUG_PRINTLN("ERROR: Failed to get Current sensor reading!");
1444-
sensorsReturningFalse = true;
14451430
if (retries == 1) {
14461431
(*iter)->setSensorCurrentPeriodPrv(curTime);
14471432
}
@@ -1470,7 +1455,6 @@ void WipperSnapper_Component_I2C::update() {
14701455
} else {
14711456
WS_DEBUG_PRINTLN(
14721457
"ERROR: Failed to get unitless percent sensor reading!");
1473-
sensorsReturningFalse = true;
14741458
if (retries == 1) {
14751459
(*iter)->setSensorUnitlessPercentPeriodPrv(curTime);
14761460
}
@@ -1494,7 +1478,6 @@ void WipperSnapper_Component_I2C::update() {
14941478
(*iter)->setSensorRawPeriodPrv(curTime);
14951479
} else {
14961480
WS_DEBUG_PRINTLN("ERROR: Failed to obtain Raw sensor reading!");
1497-
sensorsReturningFalse = true;
14981481
if (retries == 1) {
14991482
(*iter)->setSensorRawPeriodPrv(curTime);
15001483
}
@@ -1521,7 +1504,6 @@ void WipperSnapper_Component_I2C::update() {
15211504
} else {
15221505
WS_DEBUG_PRINTLN(
15231506
"ERROR: Failed to obtain gas resistance sensor reading!");
1524-
sensorsReturningFalse = true;
15251507
if (retries == 1) {
15261508
(*iter)->setSensorGasResistancePeriodPrv(curTime);
15271509
}
@@ -1546,7 +1528,6 @@ void WipperSnapper_Component_I2C::update() {
15461528
(*iter)->setSensorNOxIndexPeriodPrv(curTime);
15471529
} else {
15481530
WS_DEBUG_PRINTLN("ERROR: Failed to obtain NOx index sensor reading!");
1549-
sensorsReturningFalse = true;
15501531
if (retries == 1) {
15511532
(*iter)->setSensorNOxIndexPeriodPrv(curTime);
15521533
}
@@ -1571,7 +1552,6 @@ void WipperSnapper_Component_I2C::update() {
15711552
(*iter)->setSensorVOCIndexPeriodPrv(curTime);
15721553
} else {
15731554
WS_DEBUG_PRINTLN("ERROR: Failed to obtain VOC index sensor reading!");
1574-
sensorsReturningFalse = true;
15751555
if (retries == 1) {
15761556
(*iter)->setSensorVOCIndexPeriodPrv(curTime);
15771557
}
@@ -1598,16 +1578,18 @@ void WipperSnapper_Component_I2C::update() {
15981578
(*iter)->setSensorProximityPeriodPrv(curTime);
15991579
} else {
16001580
WS_DEBUG_PRINTLN("ERROR: Failed to get proximity sensor reading!");
1601-
sensorsReturningFalse = true;
16021581
if (retries == 1) {
16031582
(*iter)->setSensorProximityPeriodPrv(curTime);
16041583
}
16051584
}
16061585
}
16071586

16081587
// Did this driver obtain data from sensors?
1609-
if (msgi2cResponse.payload.resp_i2c_device_event.sensor_event_count == 0)
1588+
if (msgi2cResponse.payload.resp_i2c_device_event.sensor_event_count ==
1589+
0) {
1590+
sensorsReturningFalse = true;
16101591
continue;
1592+
}
16111593

16121594
displayDeviceEventMessage(&msgi2cResponse, (*iter)->getI2CAddress());
16131595

0 commit comments

Comments
 (0)