@@ -487,7 +487,7 @@ bool I2cController::PublishI2cDeviceAddedorReplaced(
487
487
bool I2cController::Handle_I2cDeviceRemove (pb_istream_t *stream) {
488
488
// Attempt to decode an I2cDeviceRemove message
489
489
WS_DEBUG_PRINTLN (" [i2c] Decoding I2cDeviceRemove message..." );
490
- if (!_i2c_model->DecodeI2cDeviceRemove (stream)) {
490
+ if (! _i2c_model->DecodeI2cDeviceRemove (stream)) {
491
491
WS_DEBUG_PRINTLN (" [i2c] ERROR: Unable to decode I2cDeviceRemove message!" );
492
492
return false ;
493
493
}
@@ -624,6 +624,9 @@ bool I2cController::Handle_I2cBusScan(pb_istream_t *stream) {
624
624
// Case 1: Scan the default I2C bus
625
625
if (_i2c_model->GetI2cBusScanMsg ()->scan_default_bus ) {
626
626
// Was the default bus initialized correctly and ready to scan?
627
+ WS_DEBUG_PRINT (" Bus State: " );
628
+ WS_DEBUG_PRINTLN (_i2c_bus_default->GetBusStatus ());
629
+ WS_DEBUG_PRINTLN (IsBusStatusOK ());
627
630
if (IsBusStatusOK ()) {
628
631
if (!_i2c_bus_default->ScanBus (scan_results)) {
629
632
WS_DEBUG_PRINTLN (" [i2c] ERROR: Failed to scan default I2C bus!" );
@@ -890,6 +893,7 @@ void I2cController::ConfigureMuxChannel(uint32_t mux_channel, bool is_alt_bus) {
890
893
*/
891
894
/* **********************************************************************/
892
895
void I2cController::update () {
896
+ // WS_DEBUG_PRINTLN("[i2c] Updating I2C controller...");
893
897
if (_i2c_drivers.size () == 0 )
894
898
return ; // bail out if no drivers exist
895
899
@@ -901,11 +905,13 @@ void I2cController::update() {
901
905
902
906
// Did driver's period elapse yet?
903
907
ulong cur_time = millis ();
904
- if (cur_time - drv->GetSensorPeriodPrv () < drv->GetSensorPeriod ())
908
+ if (cur_time - drv->GetSensorPeriodPrv () < drv->GetSensorPeriod ()) {
905
909
continue ; // bail out if the period hasn't elapsed yet
910
+ }
906
911
907
912
// Optionally configure the I2C MUX
908
913
uint32_t mux_channel = drv->GetMuxChannel ();
914
+ WS_DEBUG_PRINTLN (mux_channel);
909
915
if (drv->HasMux ())
910
916
ConfigureMuxChannel (mux_channel, drv->HasAltI2CBus ());
911
917
0 commit comments