mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-02-26 17:04:20 +00:00
SSDP
This commit is contained in:
@@ -18,11 +18,13 @@
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <ESP8266HTTPClient.h>
|
||||
#include <ESP8266httpUpdate.h>
|
||||
#include <ESP8266SSDP.h>
|
||||
#elif defined(ESP32) // ARDUINO_ARCH_ESP32
|
||||
#include <WiFi.h>
|
||||
#include <WebServer.h>
|
||||
#include <HTTPClient.h>
|
||||
#include <HTTPUpdate.h>
|
||||
#include <ESP32SSDP.h>
|
||||
#else
|
||||
#warning "Unsupported board type"
|
||||
#endif
|
||||
@@ -120,6 +122,7 @@ private:
|
||||
void notFound();
|
||||
void redirectToMain();
|
||||
void robotstxt();
|
||||
void ssdpSchema();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -115,6 +115,8 @@ void AmsWebServer::setup(AmsConfiguration* config, GpioConfig* gpioConfig, Meter
|
||||
server.on(F("/library/test/success.html"), HTTP_GET, std::bind(&AmsWebServer::redirectToMain, this)); // Apple connectivity check: http://www.apple.com/library/test/success.html
|
||||
*/
|
||||
|
||||
server.on("/ssdp/schema.xml", HTTP_GET, std::bind(&AmsWebServer::ssdpSchema, this));
|
||||
|
||||
server.onNotFound(std::bind(&AmsWebServer::notFound, this));
|
||||
|
||||
server.begin(); // Web server start
|
||||
@@ -2329,4 +2331,8 @@ void AmsWebServer::configFileUpload() {
|
||||
void AmsWebServer::redirectToMain() {
|
||||
server.sendHeader(HEADER_LOCATION,F("/"));
|
||||
server.send(302);
|
||||
}
|
||||
|
||||
void AmsWebServer::ssdpSchema() {
|
||||
SSDP.schema(server.client());
|
||||
}
|
||||
@@ -17,7 +17,7 @@ build_flags =
|
||||
-fexceptions
|
||||
|
||||
[esp32]
|
||||
lib_deps = WiFi, ESPmDNS, WiFiClientSecure, HTTPClient, FS, Update, HTTPUpdate, WebServer, ${common.lib_deps}
|
||||
lib_deps = WiFi, ESPmDNS, WiFiClientSecure, HTTPClient, FS, Update, HTTPUpdate, WebServer, ESP32 Async UDP, ESP32SSDP, ${common.lib_deps}
|
||||
|
||||
[env:esp8266]
|
||||
platform = espressif8266@4.2.0
|
||||
@@ -27,7 +27,7 @@ board_build.ldscript = eagle.flash.4m2m.ld
|
||||
build_flags = ${common.build_flags}
|
||||
lib_ldf_mode = off
|
||||
lib_compat_mode = off
|
||||
lib_deps = ESP8266WiFi, ESP8266mDNS, ESP8266WebServer, ESP8266HTTPClient, ESP8266httpUpdate, ${common.lib_deps}
|
||||
lib_deps = ESP8266WiFi, ESP8266mDNS, ESP8266WebServer, ESP8266HTTPClient, ESP8266httpUpdate, ESP8266SSDP, ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
extra_scripts = ${common.extra_scripts}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
find -name firmware.bin | while read firmware;do
|
||||
dir=`dirname $firmware`
|
||||
env=`basename $dir`
|
||||
echo "Found firmware in $dir, using env '$env'"
|
||||
|
||||
if [ -f scripts/$env/mkzip.sh ];then
|
||||
echo "Building zip for env '$env'"
|
||||
chmod +x scripts/$env/mkzip.sh
|
||||
|
||||
@@ -1710,6 +1710,35 @@ void WiFi_post_connect() {
|
||||
mqttEnabled = strlen(mqttConfig.host) > 0;
|
||||
ws.setMqttEnabled(mqttEnabled);
|
||||
}
|
||||
|
||||
sprintf_P((char*) commonBuffer, PSTR("AMS reader %s"), wifi.hostname);
|
||||
|
||||
SSDP.setSchemaURL("ssdp/schema.xml");
|
||||
SSDP.setHTTPPort(80);
|
||||
SSDP.setName((char*) commonBuffer);
|
||||
//SSDP.setSerialNumber("0");
|
||||
SSDP.setURL("/");
|
||||
SSDP.setModelName("AMS reader");
|
||||
//SSDP.setModelNumber("929000226503");
|
||||
SSDP.setModelURL("https://amsleser.no");
|
||||
SSDP.setManufacturer("Utilitech AS");
|
||||
SSDP.setManufacturerURL("http://amsleser.no");
|
||||
SSDP.setDeviceType("rootdevice");
|
||||
sprintf_P((char*) commonBuffer, PSTR("amsreader/%s"), FirmwareVersion::VersionString);
|
||||
#if defined(ESP32)
|
||||
SSDP.setModelDescription("Device to read data from electric smart meters");
|
||||
SSDP.setServerName((char*) commonBuffer);
|
||||
//SSDP.setUUID("");
|
||||
SSDP.setIcons( "<icon>"
|
||||
"<mimetype>image/svg+xml</mimetype>"
|
||||
"<height>48</height>"
|
||||
"<width>48</width>"
|
||||
"<depth>24</depth>"
|
||||
"<url>favicon.svg</url>"
|
||||
"</icon>");
|
||||
#endif
|
||||
SSDP.setInterval(300);
|
||||
SSDP.begin();
|
||||
}
|
||||
|
||||
int16_t unwrapData(uint8_t *buf, DataParserContext &context) {
|
||||
|
||||
@@ -27,11 +27,13 @@
|
||||
#if defined(ESP8266)
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266mDNS.h>
|
||||
#include <ESP8266SSDP.h>
|
||||
#elif defined(ESP32)
|
||||
#include <WiFi.h>
|
||||
#include <WiFiClientSecure.h>
|
||||
#include <ESPmDNS.h>
|
||||
#include "Update.h"
|
||||
#include <Update.h>
|
||||
#include <ESP32SSDP.h>
|
||||
#endif
|
||||
|
||||
#include "LittleFS.h"
|
||||
|
||||
Reference in New Issue
Block a user