Merge pull request #14443 from s-hadinger/remove_ld_warnings

Remove WiFiUDP32 to solve linker warnings
This commit is contained in:
s-hadinger 2022-01-14 23:10:17 +01:00 committed by GitHub
commit 9136a7d3aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 32 additions and 42 deletions

View File

@ -77,7 +77,14 @@ void ESPKNXIP::send(address_t const &receiver, knx_command_type_t ct, uint8_t da
DEBUG_PRINTLN(F("")); DEBUG_PRINTLN(F(""));
#endif #endif
#ifdef ESP8266
udp.beginPacketMulticast(MULTICAST_IP, MULTICAST_PORT, WiFi.localIP()); udp.beginPacketMulticast(MULTICAST_IP, MULTICAST_PORT, WiFi.localIP());
#else
if (0 == udp.beginMulticastPacket()) {
udp.beginMulticast(MULTICAST_IP, MULTICAST_PORT);
udp.beginMulticastPacket();
}
#endif
udp.write(buf, len); udp.write(buf, len);
udp.endPacket(); udp.endPacket();
delay(1); delay(1);

View File

@ -95,7 +95,11 @@ void ESPKNXIP::__start()
#endif #endif
server->begin(); server->begin();
} }
#ifdef ESP8266
udp.beginMulticast(WiFi.localIP(), MULTICAST_IP, MULTICAST_PORT); udp.beginMulticast(WiFi.localIP(), MULTICAST_IP, MULTICAST_PORT);
#else
udp.beginMulticast(MULTICAST_IP, MULTICAST_PORT);
#endif
} }
void ESPKNXIP::save_to_eeprom() void ESPKNXIP::save_to_eeprom()

View File

@ -53,37 +53,3 @@ void wifi_station_disconnect();
void wifi_station_dhcpc_start(); void wifi_station_dhcpc_start();
extern WiFiClass32 WiFi32; extern WiFiClass32 WiFi32;
#define WiFi WiFi32 #define WiFi WiFi32
class WiFiUDP32 : public WiFiUDP
{
public:
size_t write(const char*s)
{
return WiFiUDP::write((const uint8_t *)s, strlen(s));
}
size_t write(const uint8_t *buf, size_t n)
{
return WiFiUDP::write(buf, n);
}
static void stopAll()
{
}
static void forceSleepWake()
{
}
uint8_t beginMulticast(IPAddress interfaceAddr, IPAddress multicast, uint16_t port)
{
return WiFiUDP::beginMulticast(multicast, port);
}
void beginPacketMulticast(IPAddress multicast, uint16_t port, IPAddress interfaceAddr)
{
if (0 == WiFiUDP::beginMulticastPacket()) {
WiFiUDP::beginMulticast(multicast, port);
}
WiFiUDP::beginMulticastPacket();
}
};
#define WiFiUDP WiFiUDP32

View File

@ -2410,7 +2410,7 @@ void SyslogAsync(bool refresh) {
line_start += 1460; line_start += 1460;
} }
#else #else
PortUdp.write(header); PortUdp.write((const uint8_t*)header, strlen(header));
PortUdp.write((uint8_t*)line_start, len -mxtime -1); PortUdp.write((uint8_t*)line_start, len -mxtime -1);
PortUdp.endPacket(); PortUdp.endPacket();
#endif #endif

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

@ -69,7 +69,9 @@ bool UdpDisconnect(void)
PortUdp.stop(); PortUdp.stop();
#else // USE_DEVICE_GROUPS #else // USE_DEVICE_GROUPS
// stop all // stop all
WiFiUDP::stopAll(); #ifdef ESP8266
WiFiUDP::stopAll(); // only for ESP8266
#endif // ESP8266
#endif // !USE_DEVICE_GROUPS #endif // !USE_DEVICE_GROUPS
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPNP D_MULTICAST_DISABLED)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPNP D_MULTICAST_DISABLED));
udp_connected = false; udp_connected = false;
@ -92,7 +94,7 @@ bool UdpConnect(void)
} }
#endif // ESP8266 #endif // ESP8266
#ifdef ESP32 #ifdef ESP32
if (PortUdp.beginMulticast(WiFi.localIP(), IPAddress(239,255,255,250), 1900)) { if (PortUdp.beginMulticast(IPAddress(239,255,255,250), 1900)) {
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UPNP D_MULTICAST_REJOINED)); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UPNP D_MULTICAST_REJOINED));
udp_connected = true; udp_connected = true;
#endif // ESP32 #endif // ESP32

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

View File

@ -205,17 +205,17 @@ void HueRespondToMSearch(void)
String uuid = HueUuid(); String uuid = HueUuid();
snprintf_P(response + len, sizeof(response) - len, msg[HUE_RESP_ST1], uuid.c_str()); snprintf_P(response + len, sizeof(response) - len, msg[HUE_RESP_ST1], uuid.c_str());
PortUdp.write(response); PortUdp.write((const uint8_t*)response, strlen(response));
PortUdp.endPacket(); PortUdp.endPacket();
// AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_UPNP "UDP resp=%s"), response); // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_UPNP "UDP resp=%s"), response);
snprintf_P(response + len, sizeof(response) - len, msg[HUE_RESP_ST2], uuid.c_str(), uuid.c_str()); snprintf_P(response + len, sizeof(response) - len, msg[HUE_RESP_ST2], uuid.c_str(), uuid.c_str());
PortUdp.write(response); PortUdp.write((const uint8_t*)response, strlen(response));
PortUdp.endPacket(); PortUdp.endPacket();
// AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_UPNP "UDP resp=%s"), response); // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_UPNP "UDP resp=%s"), response);
snprintf_P(response + len, sizeof(response) - len, msg[HUE_RESP_ST3], uuid.c_str()); snprintf_P(response + len, sizeof(response) - len, msg[HUE_RESP_ST3], uuid.c_str());
PortUdp.write(response); PortUdp.write((const uint8_t*)response, strlen(response));
PortUdp.endPacket(); PortUdp.endPacket();
// AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_UPNP "UDP resp=%s"), response); // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_UPNP "UDP resp=%s"), response);

View File

@ -67,7 +67,7 @@ void WemoRespondToMSearch(int echo_type)
} }
char response[400]; char response[400];
snprintf_P(response, sizeof(response), WEMO_MSEARCH, WiFi.localIP().toString().c_str(), type, WemoUuid().c_str(), type); snprintf_P(response, sizeof(response), WEMO_MSEARCH, WiFi.localIP().toString().c_str(), type, WemoUuid().c_str(), type);
PortUdp.write(response); PortUdp.write((uint8_t*)response, strlen(response));
PortUdp.endPacket(); PortUdp.endPacket();
snprintf_P(message, sizeof(message), PSTR(D_RESPONSE_SENT)); snprintf_P(message, sizeof(message), PSTR(D_RESPONSE_SENT));
} else { } else {

View File

@ -291,7 +291,7 @@ public:
} }
char response[400]; char response[400];
snprintf_P(response, sizeof(response), WEMO_MSEARCH, WiFi.localIP().toString().c_str(), _localPort, type, WemoUuid().c_str(), type); snprintf_P(response, sizeof(response), WEMO_MSEARCH, WiFi.localIP().toString().c_str(), _localPort, type, WemoUuid().c_str(), type);
PortUdp.write(response); PortUdp.write((const uint8_t*)response, strlen(response));
PortUdp.endPacket(); PortUdp.endPacket();
// AddLog(LOG_LEVEL_DEBUG, PSTR("WMO: Sending packet device %d: %s"), _deviceId, response); // AddLog(LOG_LEVEL_DEBUG, PSTR("WMO: Sending packet device %d: %s"), _deviceId, response);