supla-device
Loading...
Searching...
No Matches
i2cscanner.h
1// SPDX-FileCopyrightText: malarz
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#ifndef SRC_SUPLA_NETWORK_HTML_I2CSCANNER_H_
5#define SRC_SUPLA_NETWORK_HTML_I2CSCANNER_H_
6
7#include <Wire.h>
8#include <stdio.h>
9
10namespace Supla {
11namespace Html {
12
20 public:
21 I2Cscanner() : HtmlElement(HTML_SECTION_DEVICE_INFO) {}
22
23 void send(Supla::WebSender* sender) {
24 sender->send("<span>");
25 sender->send("<br>I2C:");
26 for (uint8_t address = 1; address < 127; address++) {
27 Wire.beginTransmission(address);
28 uint8_t error = Wire.endTransmission();
29 char buffer[6];
30 if (error == 0) {
31 snprintf(buffer, sizeof(buffer), " 0x%2x", address);
32 sender->send(buffer, 5);
33 }
34 }
35 sender->send("</span>");
36 }
37}; // I2Cscanner
38
39} // namespace Html
40} // namespace Supla
41
42#endif // SRC_SUPLA_NETWORK_HTML_I2CSCANNER_H_
Definition html_element.h:22
HTML element that will scan I2C bus on each web page load and display all detected addresses on a web...
Definition i2cscanner.h:19
Definition web_sender.h:160