Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
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
micropython
Commits
5a860312
Commit
5a860312
authored
Jan 04, 2022
by
iabdalkader
Committed by
Damien George
Jan 06, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extmod/network_ninaw10: Make recv/recvfrom interchangeable.
parent
73a6b53d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
6 deletions
+20
-6
extmod/network_ninaw10.c
extmod/network_ninaw10.c
+20
-6
No files found.
extmod/network_ninaw10.c
View file @
5a860312
...
...
@@ -446,7 +446,15 @@ STATIC mp_uint_t network_ninaw10_socket_send(mod_network_socket_obj_t *socket, c
}
STATIC
mp_uint_t
network_ninaw10_socket_recv
(
mod_network_socket_obj_t
*
socket
,
byte
*
buf
,
mp_uint_t
len
,
int
*
_errno
)
{
int
ret
=
nina_socket_recv
(
socket
->
fileno
,
buf
,
len
,
socket
->
timeout
);
int
ret
=
0
;
if
(
socket
->
type
==
MOD_NETWORK_SOCK_DGRAM
)
{
byte
ip
[
4
];
uint16_t
port
;
ret
=
nina_socket_recvfrom
(
socket
->
fileno
,
buf
,
len
,
ip
,
&
port
,
socket
->
timeout
);
}
else
{
ret
=
nina_socket_recv
(
socket
->
fileno
,
buf
,
len
,
socket
->
timeout
);
}
if
(
ret
==
NINA_ERROR_TIMEOUT
)
{
// The socket is Not closed on timeout when calling functions that accept a timeout.
*
_errno
=
MP_ETIMEDOUT
;
...
...
@@ -493,12 +501,18 @@ STATIC mp_uint_t network_ninaw10_socket_sendto(mod_network_socket_obj_t *socket,
STATIC
mp_uint_t
network_ninaw10_socket_recvfrom
(
mod_network_socket_obj_t
*
socket
,
byte
*
buf
,
mp_uint_t
len
,
byte
*
ip
,
mp_uint_t
*
port
,
int
*
_errno
)
{
// Auto-bind the socket first if the socket is unbound.
if
(
network_ninaw10_socket_auto_bind
(
socket
,
_errno
)
!=
0
)
{
return
-
1
;
int
ret
=
0
;
if
(
socket
->
type
==
MOD_NETWORK_SOCK_STREAM
)
{
*
port
=
0
;
*
((
uint32_t
*
)
ip
)
=
0
;
ret
=
nina_socket_recv
(
socket
->
fileno
,
buf
,
len
,
socket
->
timeout
);
}
else
{
// Auto-bind the socket first if the socket is unbound.
if
(
network_ninaw10_socket_auto_bind
(
socket
,
_errno
)
!=
0
)
{
return
-
1
;
}
ret
=
nina_socket_recvfrom
(
socket
->
fileno
,
buf
,
len
,
ip
,
(
uint16_t
*
)
port
,
socket
->
timeout
);
}
int
ret
=
nina_socket_recvfrom
(
socket
->
fileno
,
buf
,
len
,
ip
,
(
uint16_t
*
)
port
,
socket
->
timeout
);
if
(
ret
==
NINA_ERROR_TIMEOUT
)
{
// The socket is Not closed on timeout when calling functions that accept a timeout.
*
_errno
=
MP_ETIMEDOUT
;
...
...
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