Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
27bb45fa
Commit
27bb45fa
authored
8 years ago
by
Martine Lenders
Browse files
Options
Downloads
Patches
Plain Diff
examples: port microcoap example to sock
parent
f6413ee5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/microcoap_server/Makefile
+1
-1
1 addition, 1 deletion
examples/microcoap_server/Makefile
examples/microcoap_server/main.c
+0
-6
0 additions, 6 deletions
examples/microcoap_server/main.c
examples/microcoap_server/microcoap_sock.c
+9
-9
9 additions, 9 deletions
examples/microcoap_server/microcoap_sock.c
with
10 additions
and
16 deletions
examples/microcoap_server/Makefile
+
1
−
1
View file @
27bb45fa
...
...
@@ -25,7 +25,7 @@ USEMODULE += gnrc_rpl
USEMODULE
+=
gnrc_icmpv6_echo
#
USEMODULE
+=
gnrc_
conn
_udp
USEMODULE
+=
gnrc_
sock
_udp
USEPKG
+=
microcoap
CFLAGS
+=
-DMICROCOAP_DEBUG
...
...
This diff is collapsed.
Click to expand it.
examples/microcoap_server/main.c
+
0
−
6
View file @
27bb45fa
...
...
@@ -21,9 +21,6 @@
#include
"msg.h"
#include
"xtimer.h"
#define MAIN_QUEUE_SIZE (8)
static
msg_t
_main_msg_queue
[
MAIN_QUEUE_SIZE
];
void
microcoap_server_loop
(
void
);
/* import "ifconfig" shell command, used for printing addresses */
...
...
@@ -33,9 +30,6 @@ int main(void)
{
puts
(
"RIOT microcoap example application"
);
/* microcoap_server uses conn which uses gnrc which needs a msg queue */
msg_init_queue
(
_main_msg_queue
,
MAIN_QUEUE_SIZE
);
puts
(
"Waiting for address autoconfiguration..."
);
xtimer_sleep
(
3
);
...
...
This diff is collapsed.
Click to expand it.
examples/microcoap_server/microcoap_
conn
.c
→
examples/microcoap_server/microcoap_
sock
.c
+
9
−
9
View file @
27bb45fa
...
...
@@ -7,7 +7,7 @@
*/
#include
"net/af.h"
#include
"net/
conn
/udp.h"
#include
"net/
sock
/udp.h"
#ifdef MICROCOAP_DEBUG
#define ENABLE_DEBUG (1)
...
...
@@ -33,18 +33,18 @@ coap_rw_buffer_t scratch_buf = { scratch_raw, sizeof(scratch_raw) };
void
microcoap_server_loop
(
void
)
{
uint8_t
laddr
[
16
]
=
{
0
};
uint8_t
raddr
[
16
]
=
{
0
};
size_t
raddr_len
;
uint16_t
rport
;
static
const
sock_udp_ep_t
local
=
{
.
family
=
AF_INET6
,
.
port
=
COAP_SERVER_PORT
};
sock_udp_ep_t
remote
;
conn
_udp_t
conn
;
sock
_udp_t
sock
;
int
rc
=
conn
_udp_create
(
&
conn
,
laddr
,
sizeof
(
laddr
),
AF_INET6
,
COAP_SERVER_PORT
);
int
rc
=
sock
_udp_create
(
&
sock
,
&
local
,
NULL
,
0
);
while
(
1
)
{
DEBUG
(
"Waiting for incoming UDP packet...
\n
"
);
rc
=
conn_udp_recvfrom
(
&
conn
,
(
char
*
)
_udp_buf
,
sizeof
(
_udp_buf
),
raddr
,
&
raddr_len
,
&
rport
);
rc
=
sock_udp_recv
(
&
sock
,
(
char
*
)
_udp_buf
,
sizeof
(
_udp_buf
),
SOCK_NO_TIMEOUT
,
&
remote
);
if
(
rc
<
0
)
{
DEBUG
(
"Error in conn_udp_recvfrom(). rc=%u
\n
"
,
rc
);
continue
;
...
...
@@ -82,7 +82,7 @@ void microcoap_server_loop(void)
coap_dumpPacket
(
&
rsppkt
);
/* send reply via UDP */
rc
=
conn
_udp_send
to
(
_udp_buf
,
rsplen
,
NULL
,
0
,
raddr
,
raddr_len
,
AF_INET6
,
COAP_SERVER_PORT
,
rport
);
rc
=
sock
_udp_send
(
&
sock
,
_udp_buf
,
rsplen
,
&
remote
);
if
(
rc
<
0
)
{
DEBUG
(
"Error sending CoAP reply via udp; %u
\n
"
,
rc
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment