Commit Graph
163 Commits
Author SHA1 Message Date
Carsten Schoenert 1043892391 rename the example binaries to more strict naming schema
To normalize (and in preparation for manpages) the currently used files
for the example implementation of a CoAP based client, server and a
resource directory various files and variables are rename to coap-*.
2015-06-19 20:53:47 +02:00
Carsten Schoenert f0f271778f drop previous renamed *.in files
With commit cda3b72 the migration to a fully Autotools controled build
environment was started which is now finished. The previous used *.in
files was renamed to *.in.old to hold some maybe usefull informations
from the old system. We don't need this renamed files any longer so kill
it with fire.
2015-06-19 20:52:47 +02:00
Olaf Bergmann ee931e8f37 examples/client.c: Removed multicast join
As the client can send to multicast groups without explicitly joining,
this code is not required here and instead moved to the server
implementation.
2015-06-10 18:10:43 +02:00
Olaf Bergmann b9bcdc10ff examples/server.c: added flag -g to join multicast groups
This code is taken from client.c where it makes no sense.

TODO: leave group when the server is stopped.
2015-06-10 18:08:33 +02:00
Carsten Schoenert 21431bcb2f examples/Makefile.am: small fix for the path declaration 2015-06-02 20:41:37 +02:00
Carsten Schoenert 47e0c25c38 examples/Makefile.am: changing header includes
The build of the examples is complaining about a function that are not
inline'd. The compiler is mentioned this because we use the '-I'
directive for pointing to the header files. Just say the compiler also
that the header files are system headers so the false positive is going
away.
2015-03-22 14:38:36 +01:00
Carsten Schoenert da3570cb41 examples/Makefile.am: fix not needed target
The target 'install-exec-am' is obviosly wrong and not really needed.
2015-03-22 13:37:28 +01:00
Olaf Bergmann d9d20d906b rd.c: Fixed type-specifier warning
For POSIX, coap_tick_t is defined as unsigned long to support
timestamps in wallclock time. The rd uses ticks to make node
identifiers locally unique. As this is just one part of the
generated identifier, the timestamp's lower 32 bits are
sufficient.
2015-03-12 13:05:56 +01:00
Olaf Bergmann 41e3247c9b rd.c: Fixed a bunch of compiler warnings 2015-03-12 12:30:57 +01:00
Carsten Schoenert 60030d0fb4 examples: adding the examples folder to the build
After including the doc/ and the tests/ folder under the hood of the
autotools now adding the examples/ foolder too.
The user is now able to add the build of the example binarys if
configure is called with '--enable-examples' as option. The example
binarys will not be build by default!

Currently only 'coap-client', 'coap-server' and 'rd' is build.
2015-03-12 11:25:26 +01:00
Olaf Bergmann d55bd85e14 examples/contiki/server.c: Define clock_offset locally
The global variable clock_offset has been removed from libcoap, so
we have to define our own.
2015-03-11 14:37:18 +01:00
Olaf Bergmann f1b36046f2 Contiki: Make sure that COAP_RESOURCES_NOHASH is defined 2015-03-11 14:34:06 +01:00
Olaf Bergmann b9adebec93 client.c: Fixed signed/unsigned in comparisons 2015-03-10 13:47:38 +01:00
Olaf Bergmann 005d00bf5b client.c: Declare unused parameters to make -Wunused quiet 2015-03-10 13:42:40 +01:00
Olaf Bergmann 445849d5ba client.c: Made private functions static to quiet compiler warnings 2015-03-10 13:41:02 +01:00
Olaf Bergmann c38a6d9ca4 Made private functions static to quiet compiler warnings 2015-03-10 13:25:08 +01:00
Olaf Bergmann 9b1ab5eef3 server.c: Declare unused parameters to make -Wunused quiet 2015-03-10 13:06:03 +01:00
Olaf Bergmann 4ca91190d6 Revised time-related functions to get rid of clock_offset for POSIX platform.
* Removed tne preprocessor defines for coap_tick() and coap_clock_init() --
  this made the code less readable and seemed to be of little use.

* Introduced the new type coap_time_t to represent wall clock time. On POSIX,
  this is the number of seconds since the epoch, while on embedded systems
  without a real time clock, this could be the number of seconds since the
  last reboot. The new function coap_ticks_to_rt() is used to convert
  coap_tick_t to coap_time.h. Currently, this is a division by COAP_TICKS_PER_SECOND
  on all platforms.

* POSIX: coap_tick_t is now defined as unsigned long to avoid overflows in
  coap_ticks().
2015-03-08 15:14:43 +01:00
Olaf Bergmann a31981b95b Implement decode_segment() and check_segment(), LWS cleanup
The helper functions decode_segment() and check_segment() are private
functions in uri.c and thus should not be accessible from outside. For
simplicity, these functions have been copied to client.c.
2015-03-08 15:09:22 +01:00
Olaf Bergmann 78b96e606d Fix lwip example 2015-03-03 22:03:37 +01:00
Olaf Bergmann 124d871cc8 Fixed path to source and header path
Made vpath %.c point to ../../src and repaired include path.

The common part of the Makefile has been moved to Makefile.common
to leverage Makefile creation for other platforms such as econotag.
2015-03-03 21:53:26 +01:00
Olaf Bergmann 8d664dd475 Fixed Contiki-specific Makefile 2015-03-03 12:30:42 +01:00
Olaf Bergmann 9d673c8cfd moved platform-specific Makefile.contiki into examples/contiki 2015-03-03 12:30:42 +01:00
Olaf Bergmann 7e300c04d9 fix CoAP RFC number in comments 2015-03-03 12:29:13 +01:00
Olaf Bergmann a81a37b29d bugfix: CLIENT_OBJS in Makefile.in unknown
This variable has been renamed to client_OBJECTS but the change was
missing in target coap-client.
2015-02-21 16:32:35 +01:00
Olaf Bergmann aa3a050641 Replaced custom list implementation with linked lists from utlist.h
coap_insert() now appends every item at the list's end, sorting must
be done explicitly using LL_SORT. As a side-effect, the new
implementation makes valgrind happy :-)
2015-02-20 13:30:32 +01:00
Olaf Bergmann f4f4ffd900 Moved coap_list.[hc] to examples
The list implementation in coap_list.c is only used in client.c
hence it was moved into the examples sub-directory.
2015-02-20 13:10:04 +01:00
Olaf Bergmann b87f45eeb2 remove unused code from Contiki server example 2015-02-16 17:04:57 +01:00
Olaf Bergmann 9898a1627f Moved the observing client coap-observer.c into examples/contiki 2015-02-16 16:41:01 +01:00
Olaf Bergmann af4aeb2042 Added sample radvd.conf for testing the minimal-net server 2015-02-16 16:31:20 +01:00
Olaf Bergmann 4635435771 Created a self-contained Contiki server example
Directory examples/contiki now contains a small example server for
Contiki and a Makefile for platform minimal-net.

Build:

  make contiki     # clones Contiki
  make server      # creates the minimal-net coap server

Run:

Unfortunately, you have to run the server with sudo unless you
set CAP_NET_ADMIN for both, the server executable, and ifconfig
(sudo setcap cap_net_admin+pei ...).

  sudo ./server

Then, add the server's interface address to the tap0 device and
optionally set a default route:

  sudo ip -6 a a aaaa::1000 dev tap0
  sudo ip -6 r a aaaa::/64 dev tap0

Although everything should work now, it does not. I had to send
router advertisements on tap0:

  sudo radvd -C ./radvd.conf

Note that on Debian (and Ubuntu, and ...), radvd will not start
when IPv6 forwarding is disabled (which is usually the case on
end systems). Trying to enable like this did not work for me:

  sudo sysctl -w net.ipv6.conf.tap0.forwarding=1
  sudo sysctl -w net.ipv6.conf.tap0.mc_forwarding=1

Workaround (ugly): get the radvd sources, compile them and use that.
2015-02-16 16:30:28 +01:00
Olaf Bergmann 8c3cdf5e72 renamed config.h to coap_config.h.lwip, part 2 2015-02-15 22:51:42 +01:00
Olaf Bergmann e46961a5a2 changed config.h.lwip to coap_config.h.lwip 2015-02-15 22:47:54 +01:00
Olaf Bergmann 8ca0840b41 changed name of config.h to coap_config.h 2015-02-15 22:45:51 +01:00
chrysn 330014445a lwip example updates
* resolve file resolution conflicts between lwip and libcoap in favor of
  lwip by rearranging the makefile

* cover the config.h of a configured base libcoap with the local one
  using the deprecated -I- gcc switch

* enable etharp (no idea why it wouldn't work ootb, the complete
  server.c lwip-contrib copy needs to be reviewed)

* disable optimizations for easier debugging, enable -g3 for macro
  expansions
2015-01-15 13:34:21 +01:00
chrysn 003c78bfdb lwip example: no explicit call to coap_dispatch
this was done for posix in d5dc48d
2015-01-13 10:50:03 +01:00
Olaf Bergmann d48ab449fd added client option -a
This option allows to bind the client's listen interface.
2014-11-06 15:14:15 +01:00
Olaf Bergmann ea270b0e60 bugfix: Block1 handling broken
This change contains a quick and dirty workaround for the following
bug that has been reported by Andrea Azzarà:

  "When sending a file with a POST to a CoAP server, such as

  ./coap-client -m post coap://vs0.inf.ethz.ch:5683/large-create/ -b 64
  -t 0 -f test

  the M bit is not correctly set to 1."
2014-08-27 18:44:52 +02:00
Olaf Bergmann 3552419496 even more strict-prototypes 2014-08-07 23:32:13 +02:00
Olaf Bergmann 91a20eb67f fix request handler signature
Since the local_interface was added to the request handler callback,
the examples rd.c and etsi_iot_01.c were broken. This change fixes
rd.c and abandons etsi_iot_01.c (as it is very outdated).
2014-07-05 22:11:51 +02:00
Olaf Bergmann f2e132df23 resolved conflict 2014-06-19 15:22:07 +02:00
Maciej Wasilak 3d66bbb8e3 Fix message handler for client example
Fix 2 bugs in message handler:
- problem with sending confirmable next block requests
- problem with deleting pdu after sending
2014-06-17 18:33:05 +02:00
Olaf Bergmann d5dc48d97a Track local network interface for received packets.
Changed various functions to pass the local interface using the
new coap_endpoint_t abstraction. This change uses the functions
implemented earlier in commit 786ca6da (branch dcaf) but does not
use callback functions for network I/O.

This change closes bug #23 "server responds from wrong endpoint
(ipv6 address)" (POSIX only, CONTIKI and LWIP tbd).
2014-03-21 18:12:40 +01:00
Olaf Bergmann a3fae3ce3a Support cancellation of observe relationships using GET w/ Observe: 1.
Adding and removal of observes is now handled by libcoap. The application's
GET handler only needs to add the Observe option (see server.c:hnd_get_time()).
2014-03-09 02:27:52 +00:00
Olaf Bergmann ed9c7ee560 bugfix: #25 async example creates short packet
Increased packet size by 5.
2014-02-25 19:15:52 +01:00
Olaf Bergmann 909cccd05d Support for response code 7.31 to cancel observation relationships.
This new behavior is described in Section 4.6 of draft-ietf-core-observe-12.
The idea is to send a response with code 7.31 and the token to identify
the subscription.
2014-02-25 19:00:10 +01:00
Olaf Bergmann a3a17fcb1d use coap_opt_block_num() instead of COAP_OPT_BLOCK_NUM 2014-02-04 17:55:56 +01:00
Olaf Bergmann 3f69cd1e9b Use log levels from syslog.h when available.
Thanks to Dag Björklund for pointing this out.
2013-12-30 01:15:11 +01:00
chrysn af2096a047 add coap to the lwip example 2013-12-09 15:38:55 +01:00
chrysn 691a87d812 minimal server for lwip demo (no coap yet) 2013-12-09 15:38:49 +01:00