zephyr/samples/net/coaps_server
Anas Nashif ca0ad13a61 net: enable SLIP only on QEMU targets
In many networking tests we had to configure SLIP in the prj.conf
leaving those configurations Qemu specific. This change enables SLIP for
QEMU targets automatically and allows reuse of prj.conf for multiple
boards.

Additionally, the TUN options is removed. This option was not used
anywhere.

To enable self-contained networking tests that do not depend on SLIP, we
introduce the new option NET_TEST which disables TAP and allows testing
in QEMU without the need for a host interface.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-07-26 10:57:48 -04:00
..
src samples: net: fix stack definitions 2017-07-26 05:53:14 -04:00
Makefile samples/coaps_server CoAP over DTLS server example app using mbedTLS 2017-01-27 12:35:53 +02:00
README.rst samples: net: Fix README.rst file documentation 2017-06-09 09:55:37 +03:00
prj_arduino_101.conf net: fix wrong Kconfig 2017-07-05 12:43:13 -04:00
prj_frdm_k64f.conf samples: coaps_server: add prj_frdm_k64f.conf 2017-06-14 09:51:34 +03:00
prj_qemu_x86.conf net: enable SLIP only on QEMU targets 2017-07-26 10:57:48 -04:00
sample.yaml samples: coaps_server: Fix platforms to build coap_server test on 2017-06-23 16:03:21 -04:00

README.rst

.. _coap-server-sample:

CoAP over DTLS sample server
############################

Overview
********
This sample code shows a CoAP over DTLS server using mbedTLS on top of Zephyr.

Building and Running
********************

Follow the steps for testing :ref:`networking_with_qemu`.

In the application directory type:

.. code-block:: console

   $make run

In other terminal window, obtain the libcoap code from:

.. code-block:: console

	git clone --recursive -b dtls https://github.com/obgm/libcoap.git

and put it in a well known directory, in your Linux machine, this will be your
client. In order to compile libcoap you may need to install the following
libraries, for Ubuntu

.. code-block:: console

	sudo apt-get install libtool asciidoc

Move to that directory and compile the libcoap on your host machine

.. code-block:: console

	./autogen.sh
	./configure --disable-shared
	make all

Now you can run the client like

.. code-block:: console

	cd examples
	./coap-client -m get coaps://[2001:db8::1]/test -u Client_identity -k passwd

You will get the following output:

.. code-block:: console

	v:1 t:CON c:GET i:7154 {} [ ]
	decrypt_verify(): found 24 bytes cleartext
	decrypt_verify(): found 123 bytes cleartext
	Type: 0
	Code: 1
	MID: 29012

From the app directory type the screen should display

.. code-block:: console

	*******
	type: 0 code 1 id 29012
	*******
 	mbedtls_ssl_read returned -0x7780

If the server does not receive the  messages, restart the app and try to connect
the client again.

References
**********

* https://tls.mbed.org/
* https://libcoap.net/