ESP32 SSDP

This commit is contained in:
Yuri Trikoz
2020-10-18 02:27:08 +03:00
parent cd9a6c98fa
commit 6426959060
4 changed files with 27 additions and 13 deletions

View File

@@ -2,6 +2,8 @@
#include <Arduino.h>
#include "Global.h"
uint32_t ESP_getChipId();
const String getChipId();
void setLedStatus(LedStatus_t status);

View File

@@ -36,6 +36,7 @@ lib_deps =
AsyncTCP
ESP32Servo
LITTLEFS
luc-github/ESP32SSDP
monitor_filters = esp32_exception_decoder
;upload_speed = 921600
monitor_speed = 115200

View File

@@ -33,7 +33,7 @@ void SsdpInit() {
ssdpDescription += xmlNode(F("modelURL"), F("https://github.com/IoTManagerProject/IoTManager/wiki"));
ssdpDescription += xmlNode(F("manufacturer"), F("Borisenko Dmitry"));
ssdpDescription += xmlNode(F("manufacturerURL"), F("https://github.com/IoTManagerProject/IoTManager"));
ssdpDescription += xmlNode(F("UDN"), "uuid:38323636-4558-4dda-9188-cda0e6" + decToHex(ESP.getChipId(), 6));
ssdpDescription += xmlNode(F("UDN"), "uuid:38323636-4558-4dda-9188-cda0e6" + decToHex(ESP_getChipId(), 6));
ssdpDescription = xmlNode("device", ssdpDescription);
ssdpHeder += ssdpDescription;
ssdpSend += ssdpHeder;

View File

@@ -3,23 +3,34 @@
#include "Global.h"
#include "Utils/PrintMessage.h"
const String getUniqueId(const char* name) {
return String(name) + getMacAddress();
}
const String getChipId() {
String res;
uint32_t ESP_getChipId(void) {
#ifdef ESP32
char buf[32] = {0};
uint32_t mac = ESP.getEfuseMac();
sprintf(buf, "%0X", mac);
res = String(buf);
uint32_t id = 0;
for (uint32_t i = 0; i < 17; i = i + 8) {
id |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i;
}
return id;
#else
return ESP.getChipId();
#endif
#ifdef ESP8266
res = String(ESP.getChipId()) + "-" + String(ESP.getFlashChipId());
}
uint32_t ESP_getFlashChipId(void) {
#ifdef ESP32
// Нет аналогичной (без доп.кода) функций в 32
// надо использовать другой id - варианты есть
return ESP_getChipId();
#else
return ESP.getFlashChipId();
#endif
return res;
}
const String getChipId() {
return String(ESP_getChipId()) + "-" + String(ESP_getFlashChipId());
}
void setChipId() {