feat(cli): i2c -- scan the bus on a live node
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5486cc5439
commit
7ca5ba286a
2 files changed
+18
No files matched your search
@@ -378,6 +378,15 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, char* command, char* re
|
||||
*(dp-1) = 0; // remove last CR
|
||||
}
|
||||
}
|
||||
} else if (memcmp(command, "i2c", 3) == 0) {
|
||||
// Live bus scan. `sensor read` only shows what got initialised, so a
|
||||
// sensor that is absent and one whose address is wrong look identical
|
||||
// there; this separates the two.
|
||||
// 150 = what one LoRa packet carries, i.e. the smallest reply buffer any
|
||||
// caller of CommonCLI passes (the local console's is far bigger, but
|
||||
// CommonCLI is not told which one it got).
|
||||
int n = _sensors->scanI2C(reply, 150);
|
||||
if (n < 0) strcpy(reply, "no I2C bus on this build");
|
||||
} else if (memcmp(command, "sensor read", 11) == 0) {
|
||||
// Decode the live telemetry (the same CayenneLPP payload sent over the
|
||||
// mesh) into a human-readable line. `sensor list` only exposes settings
|
||||
|
||||
@@ -24,6 +24,15 @@ public:
|
||||
virtual bool setSettingValue(const char* name, const char* value) { return false; }
|
||||
virtual LocationProvider* getLocationProvider() { return NULL; }
|
||||
|
||||
// Live I2C scan, written into dest as text. Returns the number of devices
|
||||
// that answered, or -1 when the platform has no bus to scan.
|
||||
//
|
||||
// begin() already scans the bus, but only into a MESH_DEBUG log nobody has on
|
||||
// a deployed node -- so "is that sensor actually there?" was answerable only
|
||||
// by inference from telemetry, and inference is what produced a build flag
|
||||
// pointing INA226 at 0x40 to dodge a false detect at 0x44 (SHT41's address).
|
||||
virtual int scanI2C(char* dest, size_t max_len) { (void)dest; (void)max_len; return -1; }
|
||||
|
||||
// Helper functions to manage setting by keys (useful in many places ...)
|
||||
const char* getSettingByKey(const char* key) {
|
||||
int num = getNumSettings();
|
||||
|
||||
Reference in new issue
Block a user