2017-08-28 16:25:30 +08:00
|
|
|
.. _coaps-client-sample:
|
2017-04-05 03:00:08 +08:00
|
|
|
|
2017-01-24 06:42:29 +08:00
|
|
|
CoAP over DTLS sample client
|
|
|
|
############################
|
|
|
|
|
|
|
|
Overview
|
2017-01-31 06:54:22 +08:00
|
|
|
********
|
2017-01-24 06:42:29 +08:00
|
|
|
This sample code shows a CoAP over DTLS client using mbedTLS on top of Zephyr.
|
|
|
|
|
|
|
|
Building and Running
|
2017-01-31 06:54:22 +08:00
|
|
|
********************
|
2017-01-24 06:42:29 +08:00
|
|
|
|
2017-06-07 18:18:03 +08:00
|
|
|
Follow the steps for testing :ref:`networking_with_qemu`.
|
2017-01-24 06:42:29 +08:00
|
|
|
|
|
|
|
Run the server application at samples/net/coaps_server, with the following
|
|
|
|
command:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
2017-07-31 21:18:11 +08:00
|
|
|
$ make server
|
2017-01-24 06:42:29 +08:00
|
|
|
|
|
|
|
In other terminal window, run this client application at samples/net/coaps_client:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
2017-07-31 21:18:11 +08:00
|
|
|
$ make client
|
2017-01-24 06:42:29 +08:00
|
|
|
|
|
|
|
You will get the following output:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
reply: 60 45 00 01 ff 54 79 70 65 3a 20 30 0a 43 6f 64 65 3a 20 31 0a 4d
|
|
|
|
49 44 3a 20 31 0a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
|
|
|
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
|
|
|
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
|
|
|
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
|
|
|
00 00 00 00 00 (123 bytes)
|
|
|
|
|
|
|
|
From the server application directory the screen should display
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
*******
|
|
|
|
type: 0 code 1 id 1
|
|
|
|
*******
|
|
|
|
connection was closed gracefully
|
|
|
|
done
|
|
|
|
|
|
|
|
If the server does not receive the messages, restart the app and try to connect
|
|
|
|
the client again.
|
|
|
|
|