BusScanner

This commit is contained in:
Yuri Trikoz
2020-06-25 17:57:17 +03:00
parent a1bd008867
commit d0c6d34f4a
19 changed files with 398 additions and 155 deletions

View File

@@ -1,6 +1,10 @@
#include "Utils/SysUtils.h"
#include "Utils/StringUtils.h"
#include "Global.h"
const String getUniqueId(const char* name) {
return String(name) + getMacAddress();
}
const String getChipId() {
String res;
@@ -62,6 +66,19 @@ String getHeapStats() {
}
#endif
const String getMacAddress() {
uint8_t mac[6];
char buf[13] = {0};
#if defined(ESP8266)
WiFi.macAddress(mac);
sprintf(buf, MACSTR, MAC2STR(mac));
#else
esp_read_mac(mac, ESP_MAC_WIFI_STA);
sprintf(buf, MACSTR, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
#endif
return String(buf);
}
//===================================================================
/*
void web_print (String text) {

View File

@@ -1,30 +0,0 @@
#include "Utils/i2c_bus.h"
#include "Global.h"
void do_i2c_scanning() {
String tmp = i2c_scan();
if (tmp == "error") {
tmp = i2c_scan();
}
jsonWriteStr(configLiveJson, "i2c", tmp);
}
const String i2c_scan() {
String out;
byte count = 0;
Wire.begin();
for (byte i = 8; i < 120; i++) {
Wire.beginTransmission(i);
if (Wire.endTransmission() == 0) {
count++;
out += String(count) + ". 0x" + String(i, HEX) + "; ";
delay(1);
}
}
if (count == 0) {
return "error";
} else {
return out;
}
}