Skip to content

Commit 0d44d5f

Browse files
committed
Fix receipt stats
1 parent e62b501 commit 0d44d5f

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

components/robusto/network/src/media/i2c/i2c_messaging_arduino_wire.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ rob_ret_val_t i2c_send_receipt(robusto_peer_t *peer, bool success, bool unknown)
295295
{
296296
if (peer)
297297
{
298-
peer->i2c_info.send_failures++; // TODO: Not sure how this should count, but probably it should
298+
peer->i2c_info.send_successes++;
299299
}
300300
i2c_arduino_receipt[0] = 0xff;
301301
i2c_arduino_receipt[1] = 0x00;
@@ -304,9 +304,14 @@ rob_ret_val_t i2c_send_receipt(robusto_peer_t *peer, bool success, bool unknown)
304304
{
305305
i2c_arduino_receipt[0] = 0x00;
306306
i2c_arduino_receipt[1] = 0xff;
307-
peer->i2c_info.last_send = r_millis();
308-
peer->i2c_info.send_successes++;
307+
if (peer)
308+
{
309+
peer->i2c_info.last_send = r_millis();
310+
peer->i2c_info.send_failures++; // TODO: Not sure how this should count, but probably it should
311+
}
312+
309313
}
314+
310315
return ROB_OK;
311316
}
312317

@@ -377,12 +382,12 @@ void i2c_compat_messaging_init(char *_log_prefix)
377382
incoming_data_length = 0;
378383
i2c_arduino_receipt[0] = 0;
379384
i2c_arduino_receipt[1] = 0;
380-
385+
381386
Wire.setSCL(CONFIG_I2C_SCL_IO);
382387
Wire.setSDA(CONFIG_I2C_SDA_IO);
383388

384-
Wire.onReceive(i2c_incoming_cb);
385-
Wire.onRequest(i2c_peripheral_request);
389+
Wire.onReceive(&i2c_incoming_cb);
390+
Wire.onRequest(&i2c_peripheral_request);
386391
i2c_set_master(false, true);
387392
}
388393

components/robusto/network/src/media/i2c/i2c_messaging_esp32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ void i2c_compat_messaging_init(char *_log_prefix)
432432
{
433433
// TODO: Implement detection and handling of these error states: https://arduino.stackexchange.com/questions/46680/i2c-packet-ocasionally-send-a-garbage-data
434434
i2c_esp32_messaging_log_prefix = _log_prefix;
435-
// This we have to set manually for some non-s3 cards
435+
// This we have to set manually for some non-s3 cards
436436
i2c_set_timeout((i2c_port_t)CONFIG_I2C_CONTROLLER_NUM, 1000 / portTICK_PERIOD_MS);
437437
}
438438

0 commit comments

Comments
 (0)