@@ -156,8 +156,6 @@ WipperSnapper_Component_I2C::scanAddresses() {
156
156
// those that respond.
157
157
WS_DEBUG_PRINTLN (" EXEC: I2C Scan" );
158
158
for (uint8_t address = 1 ; address < 127 ; ++address) {
159
- WS_DEBUG_PRINT (" Address: 0x" );
160
- WS_DEBUG_PRINTLN (address);
161
159
_i2c->beginTransmission (address);
162
160
uint8_t endTransmissionRC = _i2c->endTransmission ();
163
161
@@ -170,24 +168,35 @@ WipperSnapper_Component_I2C::scanAddresses() {
170
168
}
171
169
#if defined(ARDUINO_ARCH_ESP32)
172
170
// Check endTransmission()'s return code (Arduino-ESP32 ONLY)
173
- else if (endTransmissionRC == 1 ) {
174
- WS_DEBUG_PRINTLN (" [i2c] ERROR: data too long to fit in transmit buffer!" );
171
+ else if (endTransmissionRC == 3 ) {
172
+ // NOTE: The printf below is commented out for performance, this is the
173
+ // default case and should typically be hit if the address is not found.
174
+ // WS_DEBUG_PRINTLN("[i2c] ERROR: received NACK on transmit of data!");
175
175
continue ;
176
176
} else if (endTransmissionRC == 2 ) {
177
177
WS_DEBUG_PRINTLN (" [i2c] ERROR: received NACK on transmit of address!" );
178
+ scanResp.bus_response =
179
+ wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_UNSPECIFIED;
178
180
continue ;
179
181
} else if (endTransmissionRC == 3 ) {
180
- WS_DEBUG_PRINTLN (" [i2c] ERROR: received NACK on transmit of data!" );
182
+ WS_DEBUG_PRINTLN (" [i2c] ERROR: data too long to fit in transmit buffer!" );
183
+ scanResp.bus_response =
184
+ wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_UNSPECIFIED;
181
185
continue ;
182
186
} else if (endTransmissionRC == 4 ) {
183
- WS_DEBUG_PRINTLN (" [i2c] ERROR: Other error!" );
187
+ WS_DEBUG_PRINTLN (" [i2c] ERROR: Unspecified bus error occured!" );
188
+ scanResp.bus_response =
189
+ wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_UNSPECIFIED;
184
190
continue ;
185
191
} else if (endTransmissionRC == 5 ) {
186
192
WS_DEBUG_PRINTLN (" [i2c] ERROR: I2C Bus has timed out!" );
187
- scanResp.bus_response = wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_ERROR_HANG;
193
+ scanResp.bus_response =
194
+ wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_ERROR_HANG;
188
195
continue ;
189
196
} else {
190
- WS_DEBUG_PRINTLN (" [i2c] ERROR: Unknown error!" );
197
+ WS_DEBUG_PRINTLN (" [i2c] ERROR: An unknown bus error has occured!" );
198
+ scanResp.bus_response =
199
+ wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_UNSPECIFIED;
191
200
continue ;
192
201
}
193
202
#endif
0 commit comments