-
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.
- Loading branch information
Showing
3 changed files
with
79 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,16 @@ | ||
[package] | ||
name = "rust-gcoap" | ||
version = "0.1.0" | ||
authors = ["Christian Amsüss <[email protected]>"] | ||
edition = "2018" | ||
resolver = "2" | ||
|
||
[lib] | ||
crate-type = ["staticlib"] | ||
|
||
[dependencies] | ||
riot-wrappers = { version = "^0.7", features = [ "with_coap_message", "with_coap_handler" ] } | ||
|
||
coap-message-demos = { git = "https://gitlab.com/chrysn/coap-message-demos/", default-features = false, features = [ "with-log" ] } | ||
coap-handler-implementations = "0.1" | ||
riot-coap-handler-demos = { git = "https://gitlab.com/etonomy/riot-module-examples" } |
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,29 @@ | ||
# name of your application | ||
APPLICATION = rust_gcoap | ||
|
||
# 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)/../.. | ||
|
||
# Basic networking, and gcoap | ||
USEMODULE += gcoap | ||
USEMODULE += gnrc_netdev_default | ||
USEMODULE += auto_init_gnrc_netif | ||
USEMODULE += gnrc_ipv6_default | ||
USEMODULE += gnrc_icmpv6_echo | ||
|
||
# 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 | ||
|
||
# The name of crate (as per Cargo.toml package name, but with '-' replaced with '_') | ||
APPLICATION_RUST_MODULE = rust_gcoap | ||
BASELIBS += $(APPLICATION_RUST_MODULE).module | ||
|
||
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,34 @@ | ||
// Copyright (C) 2020 Christian Amsüss | ||
// | ||
// 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. | ||
#![no_std] | ||
|
||
use riot_wrappers::riot_main; | ||
use riot_wrappers::{gcoap, thread, cstr::cstr}; | ||
|
||
use coap_handler_implementations::HandlerBuilder; | ||
|
||
riot_main!(main); | ||
|
||
fn main() { | ||
|
||
let handler = coap_message_demos::full_application_tree(None) | ||
.at(&["ps", ""], riot_coap_handler_demos::ps::ps()) | ||
.at(&["netif", ""], riot_coap_handler_demos::netif::netif()) | ||
.at(&["stdio", "write"], riot_coap_handler_demos::stdio::write()) | ||
.at(&["stdio", "read"], riot_coap_handler_demos::stdio::read()) | ||
; | ||
let mut handler = riot_wrappers::coap_handler::GcoapHandler(handler); | ||
|
||
let mut listener = gcoap::SingleHandlerListener::new_catch_all(&mut handler); | ||
|
||
gcoap::scope(|greg| { | ||
greg.register(&mut listener); | ||
|
||
// Sending main thread to sleep; can't return or the Gcoap handler would need to be | ||
// deregistered (which it can't). | ||
loop { thread::sleep(); } | ||
}) | ||
} |