mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
tests/nanocoap_fs: add test for nanoCoAP fs
This commit is contained in:
parent
a87687c14e
commit
f42386587d
22
tests/net/nanocoap_fs/Makefile
Normal file
22
tests/net/nanocoap_fs/Makefile
Normal file
@ -0,0 +1,22 @@
|
||||
include ../Makefile.net_common
|
||||
|
||||
# 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
|
||||
USEMODULE += auto_init_gnrc_netif
|
||||
# Specify the mandatory networking modules
|
||||
USEMODULE += gnrc_ipv6_default
|
||||
|
||||
# Optionally include DNS support. This includes resolution of names at an
|
||||
# upstream DNS server and the handling of RDNSS options in Router Advertisements
|
||||
# to auto-configure that upstream DNS server.
|
||||
# USEMODULE += sock_dns # include DNS client
|
||||
# USEMODULE += gnrc_ipv6_nib_dns # include RDNSS option handling
|
||||
|
||||
USEMODULE += nanocoap_fs
|
||||
|
||||
# Required by test
|
||||
USEMODULE += shell
|
||||
USEMODULE += shell_cmds_default
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
38
tests/net/nanocoap_fs/Makefile.ci
Normal file
38
tests/net/nanocoap_fs/Makefile.ci
Normal file
@ -0,0 +1,38 @@
|
||||
BOARD_INSUFFICIENT_MEMORY := \
|
||||
arduino-duemilanove \
|
||||
arduino-leonardo \
|
||||
arduino-mega2560 \
|
||||
arduino-nano \
|
||||
arduino-uno \
|
||||
atmega328p \
|
||||
atmega328p-xplained-mini \
|
||||
atmega8 \
|
||||
atxmega-a3bu-xplained \
|
||||
bluepill-stm32f030c8 \
|
||||
i-nucleo-lrwan1 \
|
||||
msb-430 \
|
||||
msb-430h \
|
||||
nucleo-c031c6 \
|
||||
nucleo-f030r8 \
|
||||
nucleo-f031k6 \
|
||||
nucleo-f042k6 \
|
||||
nucleo-f303k8 \
|
||||
nucleo-f334r8 \
|
||||
nucleo-l011k4 \
|
||||
nucleo-l031k6 \
|
||||
nucleo-l053r8 \
|
||||
olimex-msp430-h1611 \
|
||||
olimex-msp430-h2618 \
|
||||
samd10-xmini \
|
||||
slstk3400a \
|
||||
stk3200 \
|
||||
stm32f030f4-demo \
|
||||
stm32f0discovery \
|
||||
stm32f7508-dk \
|
||||
stm32g0316-disco \
|
||||
stm32l0538-disco \
|
||||
telosb \
|
||||
waspmote-pro \
|
||||
weact-g030f6 \
|
||||
z1 \
|
||||
#
|
11
tests/net/nanocoap_fs/README.md
Normal file
11
tests/net/nanocoap_fs/README.md
Normal file
@ -0,0 +1,11 @@
|
||||
# nanoCoAP remote fs example
|
||||
|
||||
This allows to mount a remote fs that was exported via e.g. `nanocoap_fileserver`
|
||||
or `aiocoap-fileserver`.
|
||||
|
||||
The test provides a `mount` command to mount a remote fs at a local mount point:
|
||||
|
||||
mount coap://[fe80::607f:b1ff:fef7:689c]/vfs /coap
|
||||
|
||||
This will mount the `vfs/` resource on the remote server as a local `/coap/`
|
||||
directory. This can then be interacted with normal `vfs` commands such as `ls`.
|
89
tests/net/nanocoap_fs/main.c
Normal file
89
tests/net/nanocoap_fs/main.c
Normal file
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ML!PA Consulting GmbH
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup tests
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief nanoCoAP fs test app
|
||||
*
|
||||
* @author Benjamin Valentin <benjamin.valentin@ml-pa.com>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "msg.h"
|
||||
|
||||
#include "net/nanocoap/fs.h"
|
||||
#include "string_utils.h"
|
||||
#include "shell.h"
|
||||
|
||||
#define MAIN_QUEUE_SIZE (4)
|
||||
static msg_t _main_msg_queue[MAIN_QUEUE_SIZE];
|
||||
|
||||
static int _cmd_mount(int argc, char **argv)
|
||||
{
|
||||
static char url[64];
|
||||
static char mp[64];
|
||||
int res;
|
||||
|
||||
if (argc != 3) {
|
||||
printf("usage: %s <url> <path>\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((res = strscpy(mp, argv[2], sizeof(mp))) < 0) {
|
||||
return res;
|
||||
}
|
||||
if ((res = strscpy(url, argv[1], sizeof(url))) < 0) {
|
||||
return res;
|
||||
}
|
||||
|
||||
if (url[res] != '/') {
|
||||
url[res] = '/';
|
||||
if (res == sizeof(url)) {
|
||||
return -ENOBUFS;
|
||||
}
|
||||
url[++res] = 0;
|
||||
}
|
||||
|
||||
static nanocoap_fs_t nanocoap_fs_desc = {
|
||||
.url = url,
|
||||
};
|
||||
|
||||
static vfs_mount_t _mount = {
|
||||
.fs = &nanocoap_fs_file_system,
|
||||
.mount_point = mp,
|
||||
.private_data = &nanocoap_fs_desc,
|
||||
};
|
||||
|
||||
res = vfs_mount(&_mount);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static const shell_command_t shell_commands[] = {
|
||||
{ "mount", "Mount a remote fs", _cmd_mount },
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* for the thread running the shell */
|
||||
msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE);
|
||||
|
||||
/* start shell */
|
||||
puts("All up, running the shell now");
|
||||
char line_buf[SHELL_DEFAULT_BUFSIZE];
|
||||
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);
|
||||
|
||||
/* should never be reached */
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user