mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-28 07:02:17 +03:00
BusScanner
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user