Fix multicast

This commit is contained in:
Stephan Hadinger 2022-01-14 23:02:05 +01:00
parent fffcf1c2df
commit d862ad1661
2 changed files with 11 additions and 0 deletions

View File

@ -177,10 +177,17 @@ void DeviceGroupsStart()
} }
// Subscribe to device groups multicasts. // Subscribe to device groups multicasts.
#ifdef ESP8266
if (!device_groups_udp.beginMulticast(WiFi.localIP(), IPAddress(DEVICE_GROUPS_ADDRESS), DEVICE_GROUPS_PORT)) { if (!device_groups_udp.beginMulticast(WiFi.localIP(), IPAddress(DEVICE_GROUPS_ADDRESS), DEVICE_GROUPS_PORT)) {
AddLog(LOG_LEVEL_ERROR, PSTR("DGR: Error subscribing")); AddLog(LOG_LEVEL_ERROR, PSTR("DGR: Error subscribing"));
return; return;
} }
#else
if (!device_groups_udp.beginMulticast(IPAddress(DEVICE_GROUPS_ADDRESS), DEVICE_GROUPS_PORT)) {
AddLog(LOG_LEVEL_ERROR, PSTR("DGR: Error subscribing"));
return;
}
#endif
device_groups_up = true; device_groups_up = true;
// The WiFi was down but now it's up and device groups is initialized. (Re-)discover devices in // The WiFi was down but now it's up and device groups is initialized. (Re-)discover devices in

View File

@ -1020,7 +1020,11 @@ void Script_Init_UDP() {
if (!glob_script_mem.udp_flags.udp_used) return; if (!glob_script_mem.udp_flags.udp_used) return;
if (glob_script_mem.udp_flags.udp_connected) return; if (glob_script_mem.udp_flags.udp_connected) return;
#ifdef ESP8266
if (glob_script_mem.Script_PortUdp.beginMulticast(WiFi.localIP(), IPAddress(239,255,255,250), SCRIPT_UDP_PORT)) { if (glob_script_mem.Script_PortUdp.beginMulticast(WiFi.localIP(), IPAddress(239,255,255,250), SCRIPT_UDP_PORT)) {
#else
if (glob_script_mem.Script_PortUdp.beginMulticast(IPAddress(239,255,255,250), SCRIPT_UDP_PORT)) {
#endif
#ifdef SCRIPT_DEBUG_UDP #ifdef SCRIPT_DEBUG_UDP
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPNP "SCRIPT UDP started")); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPNP "SCRIPT UDP started"));
#endif #endif