@@ -38,7 +38,7 @@ template<>
38
38
WiFiUDP* SList<WiFiUDP>::_s_first = 0 ;
39
39
40
40
/* Constructor */
41
- WiFiUDP::WiFiUDP () : _ctx(0 ) {
41
+ WiFiUDP::WiFiUDP () : _ctx(0 ), _multicast( false ) {
42
42
WiFiUDP::_add (this );
43
43
}
44
44
@@ -48,6 +48,7 @@ WiFiUDP::WiFiUDP(const WiFiUDP& other) {
48
48
_ctx->ref ();
49
49
}
50
50
WiFiUDP::_add (this );
51
+ _multicast = other._multicast ;
51
52
}
52
53
53
54
WiFiUDP& WiFiUDP::operator =(const WiFiUDP& rhs) {
@@ -97,6 +98,12 @@ uint8_t WiFiUDP::beginMulticast(IPAddress interfaceAddr, IPAddress multicast, ui
97
98
return 1 ;
98
99
}
99
100
101
+ uint8_t WiFiUDP::beginMulticast (IPAddress addr, uint16_t port) {
102
+ auto ret = beginMulticast (IP_ADDR_ANY, addr, port);
103
+ _multicast = true ;
104
+ return ret;
105
+ }
106
+
100
107
/* return number of bytes available in the current packet,
101
108
will return zero if parsePacket hasn't been called yet */
102
109
int WiFiUDP::available () {
@@ -137,7 +144,13 @@ int WiFiUDP::beginPacket(IPAddress ip, uint16_t port) {
137
144
_ctx = new UdpContext;
138
145
_ctx->ref ();
139
146
}
140
- return (_ctx->connect (ip, port)) ? 1 : 0 ;
147
+ auto ret = (_ctx->connect (ip, port)) ? 1 : 0 ;
148
+ if (_multicast) {
149
+ _ctx->setMulticastInterface (IP_ADDR_ANY);
150
+ _ctx->setMulticastTTL (255 );
151
+ }
152
+ return ret;
153
+
141
154
}
142
155
143
156
int WiFiUDP::beginPacketMulticast (IPAddress multicastAddress, uint16_t port,
0 commit comments