README.rst
1.. zephyr:code-sample:: coap-server
2 :name: CoAP service
3 :relevant-api: coap coap_service
4
5 Use the CoAP server subsystem to register CoAP resources.
6
7Overview
8********
9
10This sample shows how to register CoAP resources to a main CoAP service.
11The CoAP server implementation expects all services and resources to be
12available at compile time, as they are put into dedicated sections.
13
14The resource is placed into the correct linker section based on the owning
15service's name. A linker file is required, see ``sections-ram.ld`` for an example.
16
17This demo assumes that the platform of choice has networking support,
18some adjustments to the configuration may be needed.
19
20The sample will listen for requests on the default CoAP UDP port
21(5683 or 5684 for secure CoAP) in the site-local IPv6 multicast address reserved
22for CoAP nodes.
23
24The sample exports the following resources:
25
26.. code-block:: none
27
28 /test
29 /seg1/seg2/seg3
30 /query
31 /separate
32 /large
33 /location-query
34 /large-update
35
36These resources allow a good part of the ETSI test cases to be run
37against coap-server.
38
39Building And Running
40********************
41Build the CoAP server sample application like this:
42
43.. zephyr-app-commands::
44 :zephyr-app: samples/net/sockets/coap_server
45 :board: <board to use>
46 :goals: build
47 :compact:
48
49Use :zephyr_file:`overlay-dtls.conf <samples/net/sockets/coap_server/overlay-dtls.conf>`
50to build the sample with CoAP secure resources instead.
51
52This project has no output in case of success, the correct
53functionality can be verified by using some external tool such as tcpdump
54or wireshark.
55
56See the `net-tools`_ project for more details
57
58This sample can be built and executed on QEMU or native_sim board as
59described in :ref:`networking_with_host`.
60
61Use this command on the host to run the `libcoap`_ implementation of
62the ETSI test cases:
63
64.. code-block:: console
65
66 sudo ./examples/etsi_coaptest.sh -i tap0 2001:db8::1
67
68To build the version supporting the TI CC2520 radio, use the supplied
69prj_cc2520.conf configuration file enabling IEEE 802.15.4.
70
71.. _`net-tools`: https://github.com/zephyrproject-rtos/net-tools
72
73.. _`libcoap`: https://github.com/obgm/libcoap
74
75Wi-Fi
76=====
77
78The IPv4 Wi-Fi support can be enabled in the sample with
79:ref:`Wi-Fi snippet <snippet-wifi-ipv4>`.
80