Skip to content
Snippets Groups Projects
Commit e10e5795 authored by Ken Bannister's avatar Ken Bannister
Browse files

gcoap: Update CLI example for rebase on sock

parent af1eca90
No related branches found
No related tags found
No related merge requests found
# Default Makefile, for host native networking
# Default Makefile, for host native GNRC-based networking
# name of your application
APPLICATION = gcoap
......@@ -29,8 +29,6 @@ BOARD_BLACKLIST := nrf52dk
USEPKG += nanocoap
# Required by nanocoap, but only due to issue #5959.
USEMODULE += posix
# Required by nanocoap to compile nanocoap_sock.
USEMODULE += gnrc_sock_udp
# Include packages that pull up and auto-init the link layer.
# NOTE: 6LoWPAN will be included if IEEE802.15.4 devices are present
......@@ -38,6 +36,7 @@ USEMODULE += gnrc_netdev_default
USEMODULE += auto_init_gnrc_netif
# Specify the mandatory networking modules
USEMODULE += gnrc_ipv6_default
USEMODULE += gnrc_sock_udp
USEMODULE += gcoap
# Additional networking modules that can be dropped if not needed
USEMODULE += gnrc_icmpv6_echo
......
# Border router Makefile for SLIP based networking
# Border router Makefile for GNRC and SLIP based networking
# Assumes use of SAMR21 board
# name of your application
......@@ -45,14 +45,13 @@ CFLAGS += -DSLIP_BAUDRATE=$(SLIP_BAUDRATE)
USEPKG += nanocoap
# Required by nanocoap, but only due to issue #5959.
USEMODULE += posix
# Required by nanocoap to compile nanocoap_sock.
USEMODULE += gnrc_sock_udp
# Include packages that pull up and auto-init the link layer.
# NOTE: 6LoWPAN will be included if IEEE802.15.4 devices are present
USEMODULE += gnrc_netdev_default
USEMODULE += auto_init_gnrc_netif
# Specify the mandatory networking modules
USEMODULE += gnrc_sock_udp
USEMODULE += gcoap
# Add a routing protocol
USEMODULE += gnrc_rpl
......
# gcoap Example
This application provides command line access to gcoap, a GNRC implementation of CoAP. See the [CoAP spec][1] for background, and the Modules>Networking>GNRC>CoAP topic in the source documentation for the structure of the implementation.
This application provides command line access to gcoap, a high-level API for CoAP messaging. See the [CoAP spec][1] for background, and the Modules>Networking>CoAP topic in the source documentation for detailed usage instructions and implementation notes.
We support two setup options for this example:
......
......@@ -96,22 +96,27 @@ static ssize_t _stats_handler(coap_pkt_t* pdu, uint8_t *buf, size_t len)
static size_t _send(uint8_t *buf, size_t len, char *addr_str, char *port_str)
{
ipv6_addr_t addr;
uint16_t port;
size_t bytes_sent;
sock_udp_ep_t remote;
remote.family = AF_INET6;
remote.netif = SOCK_ADDR_ANY_NETIF;
/* parse destination address */
if (ipv6_addr_from_str(&addr, addr_str) == NULL) {
puts("gcoap_cli: unable to parse destination address");
return 0;
}
memcpy(&remote.addr.ipv6[0], &addr.u8[0], sizeof(addr.u8));
/* parse port */
port = (uint16_t)atoi(port_str);
if (port == 0) {
remote.port = (uint16_t)atoi(port_str);
if (remote.port == 0) {
puts("gcoap_cli: unable to parse destination port");
return 0;
}
bytes_sent = gcoap_req_send(buf, len, &addr, port, _resp_handler);
bytes_sent = gcoap_req_send2(buf, len, &remote, _resp_handler);
if (bytes_sent > 0) {
req_count++;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment