Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1a4663f

Browse filesBrowse files
authored
Add virtual beginMulticast(...) stub to UDP class (#8969)
* - Same UDP API of ESP32 core * - PR review
1 parent f2da54d commit 1a4663f
Copy full SHA for 1a4663f

File tree

Expand file treeCollapse file tree

4 files changed

+10
-2
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+10
-2
lines changed

‎cores/esp8266/Udp.h

Copy file name to clipboardExpand all lines: cores/esp8266/Udp.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class UDP: public Stream {
4343
public:
4444
virtual ~UDP() {};
4545
virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use
46+
virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure
4647
virtual void stop() =0; // Finish with the UDP socket
4748

4849
// Sending UDP packets

‎doc/esp8266wifi/udp-class.rst

Copy file name to clipboardExpand all lines: doc/esp8266wifi/udp-class.rst
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ Multicast UDP
2626

2727
.. code:: cpp
2828
29-
uint8_t beginMulticast (IPAddress interfaceAddr, IPAddress multicast, uint16_t port)
29+
uint8_t beginMulticast (IPAddress multicast, uint16_t port)
3030
virtual int beginPacketMulticast (IPAddress multicastAddress, uint16_t port, IPAddress interfaceAddress, int ttl=1)
3131
IPAddress destinationIP ()
3232
uint16_t localPort ()
3333
34-
The ``WiFiUDP`` class supports sending and receiving multicast packets on STA interface. When sending a multicast packet, replace ``udp.beginPacket(addr, port)`` with ``udp.beginPacketMulticast(addr, port, WiFi.localIP())``. When listening to multicast packets, replace ``udp.begin(port)`` with ``udp.beginMulticast(WiFi.localIP(), multicast_ip_addr, port)``. You can use ``udp.destinationIP()`` to tell whether the packet received was sent to the multicast or unicast address.
34+
The ``WiFiUDP`` class supports sending and receiving multicast packets on STA interface. When sending a multicast packet, replace ``udp.beginPacket(addr, port)`` with ``udp.beginPacketMulticast(addr, port, WiFi.localIP())``. When listening to multicast packets, replace ``udp.begin(port)`` with ``udp.beginMulticast(multicast_ip_addr, port)``. You can use ``udp.destinationIP()`` to tell whether the packet received was sent to the multicast or unicast address.
3535

3636
For code samples please refer to separate section with `examples <udp-examples.rst>`__ dedicated specifically to the UDP Class.

‎libraries/ESP8266WiFi/src/WiFiUdp.cpp

Copy file name to clipboardExpand all lines: libraries/ESP8266WiFi/src/WiFiUdp.cpp
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ uint8_t WiFiUDP::begin(uint16_t port)
8484
return (_ctx->listen(IPAddress(), port)) ? 1 : 0;
8585
}
8686

87+
uint8_t WiFiUDP::beginMulticast(IPAddress multicast, uint16_t port)
88+
{
89+
return beginMulticast(IP_ADDR_ANY, multicast, port);
90+
}
91+
8792
uint8_t WiFiUDP::beginMulticast(IPAddress interfaceAddr, IPAddress multicast, uint16_t port)
8893
{
8994
if (_ctx) {

‎libraries/ESP8266WiFi/src/WiFiUdp.h

Copy file name to clipboardExpand all lines: libraries/ESP8266WiFi/src/WiFiUdp.h
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ class WiFiUDP : public UDP, public SList<WiFiUDP> {
4747
// Finish with the UDP connection
4848
void stop() override;
4949
// join a multicast group and listen on the given port
50+
virtual uint8_t beginMulticast(IPAddress interfaceAddr, uint16_t port);
51+
// join a multicast group and listen on the given port, using a specific interface address
5052
uint8_t beginMulticast(IPAddress interfaceAddr, IPAddress multicast, uint16_t port);
5153

5254
// Sending UDP packets

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.