4#include <Arduino_JSON.h>
8typedef TinyWire TwoWire;
90 tID = pSched->
add([
this]() { this->loop(); }, name, 100000);
92 pSched->
subscribe(tID, name +
"/#", [
this](String topic, String msg, String originator) {
93 this->subsMsg(topic, msg, originator);
100 bool i2c_checkAddress(uint8_t address) {
101 pWire->beginTransmission(address);
102 byte error = pWire->endTransmission();
105 }
else if (error == 4) {
115 for (uint8_t address = 1; address < 127; address++) {
116 if (i2c_checkAddress(address)) {
118 sprintf(msg,
"0x%02x", address);
119 i2cinfo[
"addresses"][i2cDevs] = (
const char *)msg;
123 i2cinfo[
"device_count"] = i2cDevs;
124 i2cinfo[
"hardware_errors"] = hwErrs;
125 pSched->
publish(name +
"/i2cinfo", JSON.stringify(i2cinfo));
133 void subsMsg(String topic, String msg, String originator) {
134 if (topic == name +
"/i2cinfo/get") {
muwerk I2CDoctor Class
Definition i2cdoctor.h:54
void begin(Scheduler *_pSched, TwoWire *_pWire)
Definition i2cdoctor.h:78
I2CDoctor(String name="doctor")
Definition i2cdoctor.h:71
muwerk Scheduler Class
Definition scheduler.h:199
int add(T_TASK task, String name, unsigned long minMicroSecs=100000L, T_PRIO prio=PRIO_NORMAL)
Definition scheduler.h:475
bool publish(String topic, String msg="", String originator="")
Definition scheduler.h:367
int subscribe(int taskID, String topic, T_SUBS subs, String originator="")
Definition scheduler.h:395
The muwerk namespace.
Definition console.h:15