-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
examples/nanocoap_tool: add RIOT as a CLI tool
- Loading branch information
Showing
2 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# name of your application | ||
APPLICATION = nanocoap_tool | ||
|
||
# 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. | ||
USEMODULE += netdev_default | ||
USEMODULE += auto_init_gnrc_netif | ||
# Specify the mandatory networking modules for IPv6 | ||
USEMODULE += gnrc_ipv6_default | ||
# Additional networking modules that can be dropped if not needed | ||
USEMODULE += gnrc_icmpv6_echo | ||
|
||
USEMODULE += auto_init_sock_dns # add fall-back DNS server | ||
USEMODULE += sock_dns # include DNS client | ||
USEMODULE += gnrc_ipv6_nib_dns # include RDNSS option handling | ||
|
||
USEMODULE += nanocoap_sock | ||
USEMODULE += nanocoap_vfs | ||
|
||
USEMODULE += vfs_default | ||
|
||
USEMODULE += shell | ||
USEMODULE += shell_cmds_default | ||
|
||
# export the whole fs to RIOT | ||
CFLAGS += -DFS_NATIVE_DIR=\"/\" | ||
# mount it as '/' in RIOT to match the host | ||
CFLAGS += -DCONFIG_NATIVE_MOUNTPOINT=\"/\" | ||
# use the current working directory as download destination | ||
CFLAGS += -DCONFIG_NCGET_DEFAULT_DATA_DIR=\"/proc/self/cwd/\" | ||
|
||
# terminate RIOT with main() | ||
CFLAGS += -DCONFIG_CORE_EXIT_WITH_MAIN=1 | ||
# don't be verbose | ||
CFLAGS += -DCONFIG_SKIP_BOOT_MSG=1 | ||
|
||
RIOT_TERMINAL = native | ||
BOARD_WHITELIST = native native64 | ||
|
||
DEVELHELP ?= 1 | ||
|
||
include $(RIOTBASE)/Makefile.include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* 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 examples | ||
* @{ | ||
* | ||
* @file | ||
* @brief Example application to access RIOT shell commands from Linux | ||
* | ||
* @author Benjamin Valentin <[email protected]> | ||
* | ||
* @} | ||
*/ | ||
|
||
#include <errno.h> | ||
#include "shell.h" | ||
#include "ztimer.h" | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
if (argc < 1) { | ||
printf("usage: <command> [args]\n"); | ||
return 0; | ||
} | ||
|
||
shell_command_handler_t handler = shell_find_handler(NULL, argv[0]); | ||
if (handler == NULL) { | ||
return -EINVAL; | ||
} | ||
|
||
/* wait some time for the network to be ready */ | ||
ztimer_sleep(ZTIMER_MSEC, 1000); | ||
|
||
msg_t msg_queue[8]; | ||
msg_init_queue(msg_queue, ARRAY_SIZE(msg_queue)); | ||
|
||
return handler(argc, argv); | ||
} |