mirror of https://github.com/arendst/Tasmota.git
parent
27fd8f5830
commit
feb11dd49e
|
@ -210,7 +210,7 @@ bool XdrvRulesProcess(void)
|
||||||
#ifdef USE_DEBUG_DRIVER
|
#ifdef USE_DEBUG_DRIVER
|
||||||
void ShowFreeMem(const char *where)
|
void ShowFreeMem(const char *where)
|
||||||
{
|
{
|
||||||
char stemp[20];
|
char stemp[30];
|
||||||
snprintf_P(stemp, sizeof(stemp), where);
|
snprintf_P(stemp, sizeof(stemp), where);
|
||||||
XdrvMailbox.data = stemp;
|
XdrvMailbox.data = stemp;
|
||||||
XdrvCall(FUNC_FREE_MEM);
|
XdrvCall(FUNC_FREE_MEM);
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
#include <Ticker.h>
|
#include <Ticker.h>
|
||||||
Ticker TickerMSearch;
|
Ticker TickerMSearch;
|
||||||
|
|
||||||
char packet_buffer[UDP_BUFFER_SIZE]; // buffer to hold incoming UDP packet
|
|
||||||
IPAddress udp_remote_ip; // M-Search remote IP address
|
IPAddress udp_remote_ip; // M-Search remote IP address
|
||||||
uint16_t udp_remote_port; // M-Search remote port
|
uint16_t udp_remote_port; // M-Search remote port
|
||||||
|
|
||||||
|
@ -120,20 +119,20 @@ const char HUE_RESPONSE[] PROGMEM =
|
||||||
"HOST: 239.255.255.250:1900\r\n"
|
"HOST: 239.255.255.250:1900\r\n"
|
||||||
"CACHE-CONTROL: max-age=100\r\n"
|
"CACHE-CONTROL: max-age=100\r\n"
|
||||||
"EXT:\r\n"
|
"EXT:\r\n"
|
||||||
"LOCATION: http://{r1:80/description.xml\r\n"
|
"LOCATION: http://%s:80/description.xml\r\n"
|
||||||
"SERVER: Linux/3.14.0 UPnP/1.0 IpBridge/1.17.0\r\n"
|
"SERVER: Linux/3.14.0 UPnP/1.0 IpBridge/1.17.0\r\n"
|
||||||
"hue-bridgeid: {r2\r\n";
|
"hue-bridgeid: %s\r\n";
|
||||||
const char HUE_ST1[] PROGMEM =
|
const char HUE_ST1[] PROGMEM =
|
||||||
"ST: upnp:rootdevice\r\n"
|
"ST: upnp:rootdevice\r\n"
|
||||||
"USN: uuid:{r3::upnp:rootdevice\r\n"
|
"USN: uuid:%s::upnp:rootdevice\r\n"
|
||||||
"\r\n";
|
"\r\n";
|
||||||
const char HUE_ST2[] PROGMEM =
|
const char HUE_ST2[] PROGMEM =
|
||||||
"ST: uuid:{r3\r\n"
|
"ST: uuid:%s\r\n"
|
||||||
"USN: uuid:{r3\r\n"
|
"USN: uuid:%s\r\n"
|
||||||
"\r\n";
|
"\r\n";
|
||||||
const char HUE_ST3[] PROGMEM =
|
const char HUE_ST3[] PROGMEM =
|
||||||
"ST: urn:schemas-upnp-org:device:basic:1\r\n"
|
"ST: urn:schemas-upnp-org:device:basic:1\r\n"
|
||||||
"USN: uuid:{r3\r\n"
|
"USN: uuid:%s\r\n"
|
||||||
"\r\n";
|
"\r\n";
|
||||||
|
|
||||||
String HueBridgeId(void)
|
String HueBridgeId(void)
|
||||||
|
@ -165,26 +164,20 @@ void HueRespondToMSearch(void)
|
||||||
|
|
||||||
TickerMSearch.detach();
|
TickerMSearch.detach();
|
||||||
if (PortUdp.beginPacket(udp_remote_ip, udp_remote_port)) {
|
if (PortUdp.beginPacket(udp_remote_ip, udp_remote_port)) {
|
||||||
String response1 = FPSTR(HUE_RESPONSE);
|
char response[320];
|
||||||
response1.replace("{r1", WiFi.localIP().toString());
|
snprintf_P(response, sizeof(response), HUE_RESPONSE, WiFi.localIP().toString().c_str(), HueBridgeId().c_str());
|
||||||
response1.replace("{r2", HueBridgeId());
|
int len = strlen(response);
|
||||||
|
|
||||||
String response = response1;
|
snprintf_P(response + len, sizeof(response) - len, HUE_ST1, HueUuid().c_str());
|
||||||
response += FPSTR(HUE_ST1);
|
PortUdp.write(response);
|
||||||
response.replace("{r3", HueUuid());
|
|
||||||
PortUdp.write(response.c_str());
|
|
||||||
PortUdp.endPacket();
|
PortUdp.endPacket();
|
||||||
|
|
||||||
response = response1;
|
snprintf_P(response + len, sizeof(response) - len, HUE_ST2, HueUuid().c_str(), HueUuid().c_str());
|
||||||
response += FPSTR(HUE_ST2);
|
PortUdp.write(response);
|
||||||
response.replace("{r3", HueUuid());
|
|
||||||
PortUdp.write(response.c_str());
|
|
||||||
PortUdp.endPacket();
|
PortUdp.endPacket();
|
||||||
|
|
||||||
response = response1;
|
snprintf_P(response + len, sizeof(response) - len, HUE_ST3, HueUuid().c_str());
|
||||||
response += FPSTR(HUE_ST3);
|
PortUdp.write(response);
|
||||||
response.replace("{r3", HueUuid());
|
|
||||||
PortUdp.write(response.c_str());
|
|
||||||
PortUdp.endPacket();
|
PortUdp.endPacket();
|
||||||
|
|
||||||
snprintf_P(message, sizeof(message), PSTR(D_3_RESPONSE_PACKETS_SENT));
|
snprintf_P(message, sizeof(message), PSTR(D_3_RESPONSE_PACKETS_SENT));
|
||||||
|
@ -231,10 +224,10 @@ void PollUdp(void)
|
||||||
{
|
{
|
||||||
if (udp_connected && !udp_response_mutex && devices_present) {
|
if (udp_connected && !udp_response_mutex && devices_present) {
|
||||||
if (PortUdp.parsePacket()) {
|
if (PortUdp.parsePacket()) {
|
||||||
|
char packet_buffer[UDP_BUFFER_SIZE]; // buffer to hold incoming UDP/SSDP packet
|
||||||
|
|
||||||
int len = PortUdp.read(packet_buffer, UDP_BUFFER_SIZE -1);
|
int len = PortUdp.read(packet_buffer, UDP_BUFFER_SIZE -1);
|
||||||
if (len > 0) {
|
|
||||||
packet_buffer[len] = 0;
|
packet_buffer[len] = 0;
|
||||||
}
|
|
||||||
|
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR("UDP: Packet (%d)"), len);
|
AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR("UDP: Packet (%d)"), len);
|
||||||
// AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR("\n%s"), packet_buffer);
|
// AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR("\n%s"), packet_buffer);
|
||||||
|
@ -264,7 +257,7 @@ void PollUdp(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((strstr_P(packet_buffer, PSTR("urn:schemas-upnp-org:device:basic:1")) != nullptr) ||
|
if ((strstr_P(packet_buffer, PSTR(":device:basic:1")) != nullptr) ||
|
||||||
(strstr_P(packet_buffer, UPNP_ROOTDEVICE) != nullptr) ||
|
(strstr_P(packet_buffer, UPNP_ROOTDEVICE) != nullptr) ||
|
||||||
(strstr_P(packet_buffer, SSDPSEARCH_ALL) != nullptr) ||
|
(strstr_P(packet_buffer, SSDPSEARCH_ALL) != nullptr) ||
|
||||||
(strstr_P(packet_buffer, SSDP_ALL) != nullptr)) {
|
(strstr_P(packet_buffer, SSDP_ALL) != nullptr)) {
|
||||||
|
|
Loading…
Reference in New Issue