Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
602b620
net/unicoap/rfc7252: add config for RFC 7252 messaging
carl-tud Jul 7, 2025
c078e80
net/unicoap/rfc7252: implement RFC 7252 messaging
carl-tud Jul 7, 2025
92318c0
net/unicoap: add private messaging interface
carl-tud Jul 7, 2025
fde948c
net/unicoap/rfc7252/udp: implement UDP driver
carl-tud Jul 7, 2025
dc75bc8
net/unicoap/rfc7252/dtls: implement DTLS driver
carl-tud Jul 7, 2025
c0216cf
net/unicoap: add transport abstraction
carl-tud Jul 7, 2025
d579ab0
net/unicoap: add sock dependencies
carl-tud Jul 7, 2025
ae32c8f
net/unicoap: implement state handling
carl-tud Jul 7, 2025
ad8ebd6
net/unicoap: implement basic server functionality
carl-tud Jul 7, 2025
755cdd8
net/unicoap: implement initialization
carl-tud Jul 7, 2025
98120ff
auto_init: enable auto-init for unicoap
carl-tud Jul 7, 2025
cc690df
net/unicoap: document server
carl-tud Jul 7, 2025
5503d4f
net/unicoap/rfc7252: add docs for UDP and DTLS drivers
carl-tud Jul 7, 2025
4d00949
examples/unicoap_server: add sample unicoap server application
carl-tud Jul 7, 2025
232a4e3
fixup: examples/unicoap_server: update Makefile.ci
carl-tud Jul 9, 2025
30a7f6e
fixup: net/unicoap: add interface note to server tutorial
carl-tud Jul 9, 2025
8d3db35
fixup: net/unicoap: server tutorial docs: remove trailing whitespace
carl-tud Jul 9, 2025
6e3c37b
fixup: examples/unicoap_server: add README, fix typos
carl-tud Jul 17, 2025
1d7061c
auto_init: fix indent in unicoap prio
carl-tud Jul 17, 2025
fd13630
net/unicoap: init: docs
carl-tud Jul 17, 2025
d623b0a
fixup: net/unicoap/rfc7252/udp (alongside): config.h: typo
carl-tud Jul 17, 2025
f2208cb
fixup: net/unicoap/application.h: docs, typos
carl-tud Jul 17, 2025
e848212
fixup: examples/unicoap_server: Add documentation to server example m…
carl-tud Sep 24, 2025
cad01e2
fixup: examples/unicoap_server: mind very very weird coding convetion
carl-tud Sep 24, 2025
3882e16
fixup: examples/unicoap_server: conditionally compile UDP-specific co…
carl-tud Sep 24, 2025
88e6d45
fixup: examples/unicoap_server: again, mind terrific coding convention
carl-tud Sep 24, 2025
ad68328
fixup: remove listener documentation comment regarding custom matchers
carl-tud Sep 24, 2025
8b9c225
fixup: typo
carl-tud Sep 24, 2025
eff8829
fixup: docs debugging logging deffault
carl-tud Sep 24, 2025
51d3a37
fixup: docs
carl-tud Sep 24, 2025
4345b6c
fixup: docs
carl-tud Sep 24, 2025
93d3379
fixup: docs
carl-tud Sep 24, 2025
6bb868c
fixup: docs
carl-tud Sep 24, 2025
5aafac3
remove feature check from preproc
carl-tud Sep 24, 2025
ca60a48
fixup: docs
carl-tud Sep 24, 2025
fc4ee20
fixup: i love the coding convention
carl-tud Sep 24, 2025
1861b3a
fixup: style and docs
carl-tud Sep 24, 2025
5e9bca9
fixup: remove mention of auto-init config constant
carl-tud Sep 24, 2025
8c69b0b
fixup: typo CONFIG_ in Kconfig
carl-tud Sep 24, 2025
12987d0
fixup: no tabs in makefile
carl-tud Sep 24, 2025
9d2bbdd
fixup: typos
carl-tud Sep 24, 2025
339d9ad
explain black magic
carl-tud Sep 24, 2025
3652c35
fixup: use correct code sample
carl-tud Sep 24, 2025
6a401f6
fixup: typos
carl-tud Sep 24, 2025
f0fe642
fixup: typos
carl-tud Sep 24, 2025
cc85bba
fixup: docs
carl-tud Sep 24, 2025
bff57dd
fixup: docs
carl-tud Sep 24, 2025
d4863b5
fixup: preproc indents
carl-tud Sep 24, 2025
b8dca8f
fixup: fix long lines in DTLS code
carl-tud Sep 24, 2025
1555fba
fixup: preprocessor indent fixes in drivers
carl-tud Sep 24, 2025
35787c4
fixup: docs
carl-tud Sep 24, 2025
5abe9e7
fixup: docs
carl-tud Sep 24, 2025
1c8483a
fixup: typo
carl-tud Sep 24, 2025
7223cd1
fixup: use _transmission_t instead
carl-tud Sep 24, 2025
17a74e2
fixup: do not indent top-level preprocessor directives
carl-tud Sep 24, 2025
4334c7d
fixup: typo
carl-tud Sep 24, 2025
fc5ff18
fixup: typos
carl-tud Sep 24, 2025
44ea8d3
fixup: _packet_get_dtls_session
carl-tud Sep 24, 2025
265f2cb
address messaging.c review comments
carl-tud Sep 24, 2025
be62ad8
naming
carl-tud Sep 24, 2025
ab2a99d
fixup: typo
carl-tud Sep 24, 2025
4aab839
fixup: preprocessor directive indents at top level
carl-tud Sep 24, 2025
0ffd285
fixup: typo
carl-tud Sep 24, 2025
d391e27
fixup: use correct callback type on scheduling fn
carl-tud Sep 24, 2025
9f99d5b
fixup: address review comments in messaging-related parts
carl-tud Sep 24, 2025
4b63e55
fixup: address review comments
carl-tud Sep 25, 2025
20dcf80
fixup: address review comments
carl-tud Sep 25, 2025
35bdd05
fixup: fix path string matching
carl-tud Sep 25, 2025
f1dd384
fixup: compile is_multicast helper when UDP support is missing
carl-tud Sep 26, 2025
57123e1
fixup: typos
carl-tud Oct 4, 2025
438ad7f
fixup: clarify atomic usage
carl-tud Oct 4, 2025
2f0e872
fixup: partially fix running loop on any thread
carl-tud Oct 10, 2025
9370c26
main.c
carl-tud Oct 12, 2025
0c5ed49
fixup: add unicoap_loop_enqueue to example app
carl-tud Oct 12, 2025
6a8f77c
fixup: restore unicoap_server config to defaults
carl-tud Oct 12, 2025
0cb5868
fixup: use unicoap_job_t proxy, typecheck macro expr
carl-tud Oct 12, 2025
35a0100
fixup: remove unused typecheck func from unicoap.h
carl-tud Oct 12, 2025
15f49c4
fixup: typo
carl-tud Oct 12, 2025
78e3da3
fixup: docs
carl-tud Oct 12, 2025
277b634
fixup: only use __has_builtin if available
carl-tud Oct 13, 2025
7cd0ff7
fixup: __typeof__?
carl-tud Oct 15, 2025
c307339
fixup: forgot to check in util_macros.h
carl-tud Oct 15, 2025
eee23ef
fixup: default config for server example
carl-tud Oct 19, 2025
a48ee62
fixup: timeout option in client.py (aiocoap issue)
carl-tud Oct 19, 2025
cf5df59
fixup: dtls debug logging
carl-tud Oct 19, 2025
95c0be4
fixup: proper asyncio timeout in client.py
carl-tud Oct 19, 2025
dc7b68f
docs: remove shell ifconfig hint
carl-tud Oct 19, 2025
20cf4d7
fixup: use event queue's detached init functions
carl-tud Oct 19, 2025
a0eacaa
fixup: docs
carl-tud Oct 19, 2025
4b118b1
fixup: remove job example from unicoap_server app
carl-tud Oct 19, 2025
1b7984d
fixup: assist wording sock support
carl-tud Oct 19, 2025
634a5d5
fixup: document dark compiler magic
carl-tud Oct 19, 2025
300f842
fixup: typo
carl-tud Oct 19, 2025
c7ad597
fixup: client.py now uses -mt and -to
carl-tud Oct 19, 2025
c8f4b65
fixup: use unicoap_message_code_is_* instead of unicoap_message_is_*
carl-tud Oct 19, 2025
0523502
fixup: remove erroneous assert(session) in DTLS transport driver
carl-tud Oct 19, 2025
af34573
fixup: add note on multiple consecutive slashes
carl-tud Oct 19, 2025
28ec273
fixup: fix various path matching issues (write tests!)
carl-tud Oct 19, 2025
eedc942
fixup: unittests: unicoap path matching
carl-tud Oct 19, 2025
cf3818c
fixup: return error when trying to unregister unknown listener
carl-tud Oct 19, 2025
fa1e31d
fixup: use packet->message
carl-tud Oct 19, 2025
ec11bfb
fixup: example: disable debug logging by default to save space
carl-tud Oct 19, 2025
dc097d0
fixup: forgot to check in tests
carl-tud Oct 19, 2025
47b3b00
fixup: typo
carl-tud Oct 19, 2025
e343b86
fixup: fix unresponsive CoAP over DTLS server
carl-tud Oct 22, 2025
a166aa8
fixup: dtls: style
carl-tud Oct 22, 2025
e7b4ef1
fixup: example: docs
carl-tud Oct 22, 2025
53c479e
fixup: client.py tells users that aiocoap DTLS error is expected
carl-tud Oct 22, 2025
a09f34a
fixup: naming
carl-tud Oct 23, 2025
d5578a3
fixup: comments
carl-tud Oct 23, 2025
01fe535
fixup: client.py: context.shutdown()
carl-tud Oct 24, 2025
3f8c798
fixup: use correct timeouts in CoAP over DTLS driver
carl-tud Oct 24, 2025
89580a5
fixup: WIP: sock->buf_ctx dtls (commented out)
carl-tud Oct 24, 2025
7aa791e
fixup: typo
carl-tud Oct 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/networking/coap/unicoap_message/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@

static void _example_handle_message(const unicoap_message_t* message)
{
/* Use unicoap_message_is_request, unicoap_message_is_response, unicoap_message_is_signal
* to determine what class of message you are dealing with.
/* Use unicoap_message_code_is_request, unicoap_message_code_is_response,
* unicoap_message_code_is_signal to determine what class of message you are dealing with.
* In this case, we expect a request. */
assert(unicoap_message_is_request(message->code));
assert(unicoap_message_code_is_request(message->code));

/* The unicoap message type supports different typed views of the CoAP message code:
* message->method, message->status, and message->signal.
Expand Down
63 changes: 63 additions & 0 deletions examples/networking/coap/unicoap_server/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Default Makefile, for simple unicoap server sample application

# name of your application
APPLICATION = unicoap_server

# If no BOARD is found in the environment, use this default:
BOARD ?= native

# This has to be the absolute path to the RIOT base directory:
RIOTBASE ?= $(CURDIR)/../../../..

# Include packages that pull up and auto-init the link layer.
# NOTE: 6LoWPAN will be included if IEEE802.15.4 devices are present
USEMODULE += netdev_default

# use GNRC by default
LWIP_IPV4 ?= 0
LWIP_IPV6 ?= 0

ifeq (,$(filter 1, $(LWIP_IPV4) $(LWIP_IPV6)))
USEMODULE += auto_init_gnrc_netif
# Specify the mandatory networking modules
USEMODULE += gnrc_ipv6_default
# Additional networking modules that can be dropped if not needed
USEMODULE += gnrc_icmpv6_echo
else
ifeq (1,$(LWIP_IPV4))
USEMODULE += ipv4_addr

USEMODULE += lwip_arp
USEMODULE += lwip_ipv4
USEMODULE += lwip_dhcp_auto
CFLAGS += -DETHARP_SUPPORT_STATIC_ENTRIES=1
endif

ifeq (1,$(LWIP_IPV6))
USEMODULE += ipv6_addr

USEMODULE += lwip_ipv6
USEMODULE += lwip_ipv6_autoconfig
endif
endif

USEMODULE += unicoap
USEMODULE += unicoap_resources_xfa

# This module is needed for CoAP over UDP
USEMODULE += unicoap_driver_udp

# This module is needed for CoAP over DTLS
USEMODULE += unicoap_driver_dtls

# It is okay to import only either of the CoAP over UDP and CoAP over DTLS drivers.

# Comment this out to disable code in RIOT that does safety checking
# which is not needed in a production environment but helps in the
# development process:
DEVELHELP ?= 1

# Change this to 0 show compiler invocation lines by default:
QUIET ?= 1

include $(RIOTBASE)/Makefile.include
58 changes: 58 additions & 0 deletions examples/networking/coap/unicoap_server/Makefile.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
BOARD_INSUFFICIENT_MEMORY := \
airfy-beacon \
arduino-duemilanove \
arduino-leonardo \
arduino-mega2560 \
arduino-nano \
arduino-uno \
atmega1284p \
atmega328p \
atmega328p-xplained-mini \
atmega8 \
atxmega-a3bu-xplained \
blackpill-stm32f103c8 \
bluepill-stm32f030c8 \
bluepill-stm32f103c8 \
calliope-mini \
derfmega128 \
hifive1 \
hifive1b \
i-nucleo-lrwan1 \
im880b \
mega-xplained \
microbit \
microduino-corerf \
msb-430 \
msb-430h \
nrf51dongle \
nucleo-c031c6 \
nucleo-f030r8 \
nucleo-f031k6 \
nucleo-f042k6 \
nucleo-f070rb \
nucleo-f072rb \
nucleo-f302r8 \
nucleo-f303k8 \
nucleo-f334r8 \
nucleo-l011k4 \
nucleo-l031k6 \
nucleo-l053r8 \
olimex-msp430-h1611 \
olimex-msp430-h2618 \
samd10-xmini \
saml10-xpro \
saml11-xpro \
slstk3400a \
stk3200 \
stm32f030f4-demo \
stm32f0discovery \
stm32f7508-dk \
stm32g0316-disco \
stm32l0538-disco \
stm32mp157c-dk2 \
telosb \
weact-g030f6 \
yunjia-nrf51822 \
z1 \
zigduino \
#
31 changes: 31 additions & 0 deletions examples/networking/coap/unicoap_server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Sample Server Application With `unicoap`

This a sample application demonstrating how you can define CoAP resources using `unicoap`,
the unified and modular CoAP suite in RIOT. Visit the
[`unicoap` server tutorial on doc.riot-os.org](http://doc.riot-os.org/group__net__unicoap__server__tutorial.html)
for a detailed code-level instructions.

## Running the Example on RIOT's Native Board

Create a tap interface (to which RIOT will connect):

```
$ sudo ip tuntap add tap0 mode tap user ${USER}
$ sudo ip link set tap0 up
```

To try this example on your host, run:
```sh
BOARD=native make flash term
```
This will compile and run the application.
The application will print a network-layer address.

In a second terminal session, you can run

```sh
python3 client.py -m GET -u "coap://[fe80::c0:ff:ee%tap0]/greeting?name=RIOTer"
```

to send a CoAP request through the tap interface to the CoAP server where `fe80::c0:ff:ee`
is the link-layer address printed by the application.
3 changes: 3 additions & 0 deletions examples/networking/coap/unicoap_server/app.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CONFIG_UNICOAP_DEBUG_LOGGING=n
CONFIG_UNICOAP_ASSIST=n
CONFIG_UNICOAP_CREATE_THREAD=y
140 changes: 140 additions & 0 deletions examples/networking/coap/unicoap_server/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
#!/usr/bin/env python3

import logging
import asyncio
from argparse import ArgumentParser

from aiocoap import CON, NON, GET, PUT, POST, DELETE, PATCH, iPATCH, FETCH, Context, Message
import aiocoap.resource as resource
from aiocoap.transports.tinydtls import DTLSClientConnection

Check failure on line 9 in examples/networking/coap/unicoap_server/client.py

View workflow job for this annotation

GitHub Actions / static-tests

F401 'aiocoap.transports.tinydtls.DTLSClientConnection' imported but unused

logging.basicConfig(level=logging.DEBUG)

print(
"usage: client.py" +
" -m <GET|PUT|POST|DELETE|PATCH|iPATCH|FETCH>" +
" -u <URI>" +
" [--type <NON|CON>] [--observe] [-p <PAYLOAD>]")


def _get(_list, i, default):
return _list[i] if len(_list) > i else default


def message_type(arg):
return {"CON": CON, "NON": NON}[arg]


def method(arg):
return {
"GET": GET,
"PUT": PUT,
"POST": POST,
"DELETE": DELETE,
"PATCH": PATCH,
"iPATCH": iPATCH,
"FETCH": FETCH
}[arg]


async def main():
parser = ArgumentParser()

parser.add_argument(
"-m", "--method",
help='GET|PUT|POST|DELETE|PATCH|iPATCH|FETCH',
required=True)

parser.add_argument(
"-u", "--uri",
help='URI',
required=True)

parser.add_argument(
"-mt", "--type",
help='NON|CON',
default="NON")

parser.add_argument(
"--observe",
action="store_true",
help='Register for notifications',
default=False)

parser.add_argument(
"--observe-cancel",
action="store_true",
help='Cancel notifications',
default=False)

parser.add_argument(
"-p", "--payload",
help='Payload',
default=None)

parser.add_argument(
"-to", "--timeout",
type=float,
help='Request timeout',
default="4")

args = parser.parse_args()

observeValue = None

if args.observe and args.observe_cancel:
raise ValueError("cannot register for and cancel notifications")

if args.observe:
observeValue = 0

elif args.observe_cancel:
observeValue = 1

print(f"using {message_type(args.type)} {method(args.method)} request")
print(f"timeout set to {args.timeout}s")

port = 5600
protocol = await Context.create_server_context(bind=("::", port), site=resource.Site())
protocol.client_credentials.load_from_dict({
'*': {
'dtls': {
'psk': b'secretPSK',
'client-identity': b'Client_identity',
}
}
})

request = Message(
mtype=message_type(args.type),
code=method(args.method),
uri=args.uri,
payload=bytes(args.payload, 'utf-8') if args.payload else "",
observe=observeValue
)

try:
pr = protocol.request(request)

async with asyncio.timeout(args.timeout):
r = await pr.response
print("response: %s\n%r" % (r.code, r.payload))

if args.observe:
print("waiting for resource notifications")

async for r in pr.observation:
print("notification: %s\n%r" % (r, r.payload))
break

await protocol.shutdown()

except TimeoutError:
print(f"error: timeout exceeded after waiting {args.timeout}s")

except Exception as e:
print("error:")
print(e)

if __name__ == "__main__":
asyncio.run(main())
Loading
Loading