-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMuzzley.cpp
61 lines (51 loc) · 1.55 KB
/
Muzzley.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <Arduino.h>
#include "Muzzley.h"
#include <FS.h>
#include <ArduinoJson.h>
#include "ESP8266SSDP.h" // for muzzley local discovery
#include "SupportFunctions.h"
#include <ESP8266WebServer.h>
#include "MuzzleyRegister.h"
#include <MQTTClient.h>
#include "config.h"
#include <ESP8266WiFi.h>
#include <WiFiManager.h>
SupportFunctions sfc;
ESP8266WebServer HTTP(80);
MuzzleyRegister muzzleyconfig;
Muzzley::Muzzley()
{
}
// ************** SSDP METHODS ***************** //
void Muzzley::init_local_discovery(String profile, String serialNumber, uint8_t mac[6], String deviceKey) {
// initialize SSD discovery
//Serial.println("Starting SSDP...\n");
SSDP.setDeviceType("urn:Muzzley:device:" + profile + ":1");
SSDP.setSchemaURL("description.xml");
SSDP.setHTTPPort(80);
SSDP.setName("Muzzley");
SSDP.setSerialNumber(serialNumber);
SSDP.setMACAddress(sfc.macToStr(mac));
SSDP.setURL("index.html");
SSDP.setModelName("Muzzley");
SSDP.setModelURL("http://www.muzzley.com");
SSDP.setManufacturer("Muzzley");
SSDP.setManufacturerURL("http://muzzley.com");
SSDP.setDeviceKey(deviceKey);
SSDP.begin();
}
void Muzzley::init_web_server(){
// initiliaze web server
HTTP.on("/index.html", HTTP_GET, [](){
Serial.println("HTTP index.html request");
HTTP.send(200, "text/plain", "Future Muzzley configuration tool!");
});
HTTP.on("/description.xml", HTTP_GET, [](){
//Serial.println("\ndescription.xml requested");
SSDP.schema(HTTP.client());
});
HTTP.begin();
}
void Muzzley::handle_httpserver(){
HTTP.handleClient();
}