zephyr/samples/net/coaps_server
Michael Scott 2fc554b8fc crypto: config: config-coap: add CONFIG for setting max content length
The CoAP samples use an MBEDTLS config "config-coap.h" which could be
re-used by the LwM2M sample, except that most servers use a larger
maximum content length setting of 1500 bytes.

Let's add a CONFIG to set this for users of the CoAP lib and set the
CONFIG value for the samples to the 256 size currently used.

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2017-12-15 17:52:13 -05:00
..
src kbuild: Removed KBuild 2017-11-08 20:00:22 -05:00
CMakeLists.txt Introduce cmake-based rewrite of KBuild 2017-11-08 20:00:22 -05:00
README.rst net: samples: Modify coaps_server to new CoAP api's 2017-10-06 22:07:37 -04:00
prj.conf crypto: config: config-coap: add CONFIG for setting max content length 2017-12-15 17:52:13 -05:00
sample.yaml tests/samples: fixed yaml syntax 2017-12-11 14:47:08 -05:00

README.rst

.. _coaps-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/