Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-pico
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-pico
Commits
d2beb2da
Unverified
Commit
d2beb2da
authored
Aug 31, 2022
by
Earle F. Philhower, III
Committed by
GitHub
Aug 31, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add upsteam multicast compatibility APIs (#821)
Fixes #747 while remaining ESP8266 compatible
parent
7ef44d98
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
4 deletions
+22
-4
libraries/WiFi/src/WiFiUdp.cpp
libraries/WiFi/src/WiFiUdp.cpp
+15
-2
libraries/WiFi/src/WiFiUdp.h
libraries/WiFi/src/WiFiUdp.h
+7
-2
No files found.
libraries/WiFi/src/WiFiUdp.cpp
View file @
d2beb2da
...
...
@@ -38,7 +38,7 @@ template<>
WiFiUDP
*
SList
<
WiFiUDP
>::
_s_first
=
0
;
/* Constructor */
WiFiUDP
::
WiFiUDP
()
:
_ctx
(
0
)
{
WiFiUDP
::
WiFiUDP
()
:
_ctx
(
0
)
,
_multicast
(
false
)
{
WiFiUDP
::
_add
(
this
);
}
...
...
@@ -48,6 +48,7 @@ WiFiUDP::WiFiUDP(const WiFiUDP& other) {
_ctx
->
ref
();
}
WiFiUDP
::
_add
(
this
);
_multicast
=
other
.
_multicast
;
}
WiFiUDP
&
WiFiUDP
::
operator
=
(
const
WiFiUDP
&
rhs
)
{
...
...
@@ -97,6 +98,12 @@ uint8_t WiFiUDP::beginMulticast(IPAddress interfaceAddr, IPAddress multicast, ui
return
1
;
}
uint8_t
WiFiUDP
::
beginMulticast
(
IPAddress
addr
,
uint16_t
port
)
{
auto
ret
=
beginMulticast
(
IP_ADDR_ANY
,
addr
,
port
);
_multicast
=
true
;
return
ret
;
}
/* return number of bytes available in the current packet,
will return zero if parsePacket hasn't been called yet */
int
WiFiUDP
::
available
()
{
...
...
@@ -137,7 +144,13 @@ int WiFiUDP::beginPacket(IPAddress ip, uint16_t port) {
_ctx
=
new
UdpContext
;
_ctx
->
ref
();
}
return
(
_ctx
->
connect
(
ip
,
port
))
?
1
:
0
;
auto
ret
=
(
_ctx
->
connect
(
ip
,
port
))
?
1
:
0
;
if
(
_multicast
)
{
_ctx
->
setMulticastInterface
(
IP_ADDR_ANY
);
_ctx
->
setMulticastTTL
(
255
);
}
return
ret
;
}
int
WiFiUDP
::
beginPacketMulticast
(
IPAddress
multicastAddress
,
uint16_t
port
,
...
...
libraries/WiFi/src/WiFiUdp.h
View file @
d2beb2da
...
...
@@ -44,9 +44,12 @@ public:
// initialize, start listening on specified port.
// Returns 1 if successful, 0 if there are no sockets available to use
uint8_t
begin
(
uint16_t
port
)
override
;
virtual
uint8_t
begin
(
uint16_t
port
)
override
;
// initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 if there are no sockets available to use
virtual
uint8_t
beginMulticast
(
IPAddress
,
uint16_t
)
override
;
// Finish with the UDP connection
void
stop
()
override
;
v
irtual
v
oid
stop
()
override
;
// join a multicast group and listen on the given port
uint8_t
beginMulticast
(
IPAddress
interfaceAddr
,
IPAddress
multicast
,
uint16_t
port
);
...
...
@@ -110,4 +113,6 @@ public:
static
void
stopAll
();
static
void
stopAllExcept
(
WiFiUDP
*
exC
);
private:
bool
_multicast
;
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment