mirror of
https://github.com/ratspeak/microReticulum
synced 2026-11-22 23:10:38 +00:00
WIP: Minor refactoring of examples.
This commit is contained in:
1 parent
0c902054db
commit
f155e39cf6
28 files changed
+326
-334
No files matched your search
+116
@@ -0,0 +1,116 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.14)
|
||||||
|
project(Reticulum LANGUAGES CXX)
|
||||||
|
|
||||||
|
# Set C++ standard (can be overridden via command line)
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
|
# Option to fetch external libraries
|
||||||
|
option(FETCH_EXTERNAL_LIBS "Download and include external dependencies" ON)
|
||||||
|
|
||||||
|
include(FetchContent)
|
||||||
|
|
||||||
|
# Fetch external libraries
|
||||||
|
if(FETCH_EXTERNAL_LIBS)
|
||||||
|
message(STATUS "Fetching external dependencies...")
|
||||||
|
|
||||||
|
# ArduinoJson
|
||||||
|
FetchContent_Declare(
|
||||||
|
arduinojson
|
||||||
|
GIT_REPOSITORY https://github.com/bblanchon/ArduinoJson.git
|
||||||
|
GIT_TAG v7.4.2
|
||||||
|
)
|
||||||
|
FetchContent_MakeAvailable(arduinojson)
|
||||||
|
|
||||||
|
# MsgPack (non-CMake library)
|
||||||
|
FetchContent_Declare(
|
||||||
|
msgpack
|
||||||
|
GIT_REPOSITORY https://github.com/hideakitai/MsgPack.git
|
||||||
|
GIT_TAG v0.4.2
|
||||||
|
)
|
||||||
|
FetchContent_MakeAvailable(msgpack)
|
||||||
|
|
||||||
|
# Crypto (non-CMake library)
|
||||||
|
FetchContent_Declare(
|
||||||
|
crypto
|
||||||
|
GIT_REPOSITORY https://github.com/attermann/Crypto.git
|
||||||
|
GIT_TAG master
|
||||||
|
)
|
||||||
|
FetchContent_MakeAvailable(crypto)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Include MsgPack (non-CMake library) library header files
|
||||||
|
set(MSGPACK_INCLUDE_DIR ${msgpack_SOURCE_DIR})
|
||||||
|
|
||||||
|
# Include Crypto (non-CMake library) library header files
|
||||||
|
set(CRYPTO_INCLUDE_DIR ${crypto_SOURCE_DIR})
|
||||||
|
|
||||||
|
# Include Crypto (non-CMake library) library source files
|
||||||
|
file(GLOB CRYPTO_SOURCES ${crypto_SOURCE_DIR}/*.cpp)
|
||||||
|
add_library(CryptoLib STATIC ${CRYPTO_SOURCES})
|
||||||
|
target_include_directories(CryptoLib PUBLIC ${CRYPTO_INCLUDE_DIR})
|
||||||
|
|
||||||
|
# Include directories
|
||||||
|
include_directories(src include)
|
||||||
|
|
||||||
|
# Gather source files
|
||||||
|
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS src/*.cpp)
|
||||||
|
|
||||||
|
# Create shared library
|
||||||
|
add_library(ReticulumShared SHARED ${SOURCES})
|
||||||
|
set_target_properties(ReticulumShared PROPERTIES OUTPUT_NAME "Reticulum")
|
||||||
|
|
||||||
|
# Create static library
|
||||||
|
add_library(ReticulumStatic STATIC ${SOURCES})
|
||||||
|
set_target_properties(ReticulumStatic PROPERTIES OUTPUT_NAME "Reticulum")
|
||||||
|
|
||||||
|
# Common compiler flags and defines
|
||||||
|
foreach(target ReticulumShared ReticulumStatic)
|
||||||
|
target_compile_options(${target} PRIVATE
|
||||||
|
-Wall
|
||||||
|
-Wno-missing-field-initializers
|
||||||
|
-Wno-format
|
||||||
|
-Wno-unused-parameter
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_definitions(${target} PRIVATE
|
||||||
|
LIBRARY_TEST
|
||||||
|
RNS_USE_FS
|
||||||
|
RNS_PERSIST_PATHS
|
||||||
|
NATIVE
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(${target} PUBLIC
|
||||||
|
${PROJECT_SOURCE_DIR}/src
|
||||||
|
${PROJECT_SOURCE_DIR}/include
|
||||||
|
)
|
||||||
|
|
||||||
|
# Include MsgPack (non-CMake library) headers
|
||||||
|
target_include_directories(${target} PUBLIC
|
||||||
|
${MSGPACK_INCLUDE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Include Crypto (non-CMake library) headers
|
||||||
|
target_include_directories(${target} PUBLIC
|
||||||
|
${CRYPTO_INCLUDE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Link external libraries if available
|
||||||
|
if(FETCH_EXTERNAL_LIBS)
|
||||||
|
target_link_libraries(${target} PRIVATE
|
||||||
|
ArduinoJson
|
||||||
|
msgpackc-cxx
|
||||||
|
crypto
|
||||||
|
CryptoLib
|
||||||
|
MsgPack
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Optional test executable
|
||||||
|
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp")
|
||||||
|
add_executable(ReticulumTest main.cpp)
|
||||||
|
target_link_libraries(ReticulumTest PRIVATE ReticulumStatic)
|
||||||
|
endif()
|
||||||
|
|
||||||
@@ -40,6 +40,8 @@ Instructions for command line builds and building of individual example applicat
|
|||||||
- [x] Successful testing of Transport of both Packets and Links
|
- [x] Successful testing of Transport of both Packets and Links
|
||||||
- [x] Implement memory management appropriate for memory constricted MCUs
|
- [x] Implement memory management appropriate for memory constricted MCUs
|
||||||
- [x] Implement Link
|
- [x] Implement Link
|
||||||
|
- [x] Implement AES256
|
||||||
|
- [ ] Implement Ratchets
|
||||||
- [ ] Implement Resource
|
- [ ] Implement Resource
|
||||||
- [ ] Implement Channel and Buffer
|
- [ ] Implement Channel and Buffer
|
||||||
- [x] Add example applications utilizing the C++ API
|
- [x] Add example applications utilizing the C++ API
|
||||||
|
|||||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,10 @@
|
|||||||
|
name=lora_interface
|
||||||
|
version=0.0.1
|
||||||
|
author=Chad Attermann <attermann@gmail.com>
|
||||||
|
maintainer=Chad Attermann <attermann@gmail.com>
|
||||||
|
sentence=LoRaInterface implementation common to all examples
|
||||||
|
paragraph=LoRaInterface implementation common to all examples
|
||||||
|
category=Communication
|
||||||
|
url=
|
||||||
|
architectures=*
|
||||||
|
depends=
|
||||||
File renamed without changes.
File renamed without changes.
+3
-3
@@ -1,9 +1,9 @@
|
|||||||
name=common
|
name=udp_interface
|
||||||
version=0.0.1
|
version=0.0.1
|
||||||
author=Chad Attermann <attermann@gmail.com>
|
author=Chad Attermann <attermann@gmail.com>
|
||||||
maintainer=Chad Attermann <attermann@gmail.com>
|
maintainer=Chad Attermann <attermann@gmail.com>
|
||||||
sentence=Boilerplate and implementations common to all examples
|
sentence=UDPInterface implementation common to all examples
|
||||||
paragraph=Boilerplate and implementations common to all examples
|
paragraph=UDPInterface implementation common to all examples
|
||||||
category=Communication
|
category=Communication
|
||||||
url=
|
url=
|
||||||
architectures=*
|
architectures=*
|
||||||
+1
-1
@@ -246,7 +246,7 @@ void UniversalFileSystem::listDir(const char* dir) {
|
|||||||
//File file = SPIFFS.open(file_path, mode);
|
//File file = SPIFFS.open(file_path, mode);
|
||||||
//if (!file) {
|
//if (!file) {
|
||||||
File* file = new File(SPIFFS.open(file_path, mode));
|
File* file = new File(SPIFFS.open(file_path, mode));
|
||||||
if (file == null || !(*file)) {
|
if (file == nullptr || !(*file)) {
|
||||||
ERRORF("open_file: failed to open output file %s", file_path);
|
ERRORF("open_file: failed to open output file %s", file_path);
|
||||||
return {RNS::Type::NONE};
|
return {RNS::Type::NONE};
|
||||||
}
|
}
|
||||||
File renamed without changes.
@@ -0,0 +1,10 @@
|
|||||||
|
name=universal_filesystem
|
||||||
|
version=0.0.1
|
||||||
|
author=Chad Attermann <attermann@gmail.com>
|
||||||
|
maintainer=Chad Attermann <attermann@gmail.com>
|
||||||
|
sentence=UniversalFilesystem implementation common to all examples
|
||||||
|
paragraph=UniversalFilesystem implementation common to all examples
|
||||||
|
category=Communication
|
||||||
|
url=
|
||||||
|
architectures=*
|
||||||
|
depends=
|
||||||
+77
-162
@@ -42,6 +42,10 @@
|
|||||||
// them all within the app namespace "example_utilities"
|
// them all within the app namespace "example_utilities"
|
||||||
#define APP_NAME "example_utilities"
|
#define APP_NAME "example_utilities"
|
||||||
|
|
||||||
|
RNS::Reticulum reticulum;
|
||||||
|
RNS::FileSystem universal_filesystem(RNS::Type::NONE);
|
||||||
|
RNS::Interface udp_interface(RNS::Type::NONE);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
##########################################################
|
##########################################################
|
||||||
@@ -96,10 +100,16 @@ void server_loop(RNS::Destination& destination) {
|
|||||||
// destination on the network, which will let clients
|
// destination on the network, which will let clients
|
||||||
// know how to create messages directed towards it.
|
// know how to create messages directed towards it.
|
||||||
while (true) {
|
while (true) {
|
||||||
int c;
|
reticulum.loop();
|
||||||
while ((c = getchar()) != '\n' && c != EOF);
|
udp_interface.loop();
|
||||||
destination.announce();
|
// Non-blocking input
|
||||||
RNS::log("Sent announce from "+destination.hash().toHex());
|
char ch;
|
||||||
|
while (read(STDIN_FILENO, &ch, 1) > 0) {
|
||||||
|
if (ch == '\n') {
|
||||||
|
destination.announce();
|
||||||
|
RNS::log("Sent announce from "+destination.hash().toHex());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,21 +117,6 @@ void server_loop(RNS::Destination& destination) {
|
|||||||
// to run as a server
|
// to run as a server
|
||||||
void server() {
|
void server() {
|
||||||
|
|
||||||
// Initialize and register filesystem
|
|
||||||
RNS::FileSystem universal_filesystem = new UniversalFileSystem();
|
|
||||||
universal_filesystem.init();
|
|
||||||
RNS::Utilities::OS::register_filesystem(universal_filesystem);
|
|
||||||
|
|
||||||
// Initialize and register interface
|
|
||||||
RNS::Interface udp_interface = new UDPInterface();
|
|
||||||
udp_interface.mode(RNS::Type::Interface::MODE_GATEWAY);
|
|
||||||
RNS::Transport::register_interface(udp_interface);
|
|
||||||
udp_interface.start();
|
|
||||||
|
|
||||||
// Initialize and start Reticulum
|
|
||||||
RNS::Reticulum reticulum = RNS::Reticulum();
|
|
||||||
reticulum.start();
|
|
||||||
|
|
||||||
// Randomly create a new identity for our link example
|
// Randomly create a new identity for our link example
|
||||||
RNS::Identity server_identity = RNS::Identity();
|
RNS::Identity server_identity = RNS::Identity();
|
||||||
|
|
||||||
@@ -142,33 +137,7 @@ void server() {
|
|||||||
|
|
||||||
// Everything's ready!
|
// Everything's ready!
|
||||||
// Let's Wait for client requests or user input
|
// Let's Wait for client requests or user input
|
||||||
//server_loop(server_destination);
|
server_loop(server_destination);
|
||||||
|
|
||||||
// Let the user know that everything is ready
|
|
||||||
RNS::log(
|
|
||||||
"Link example "+
|
|
||||||
server_destination.hash().toHex()+
|
|
||||||
" running, waiting for a connection."
|
|
||||||
);
|
|
||||||
|
|
||||||
RNS::log("Hit enter to manually send an announce (Ctrl-C to quit)");
|
|
||||||
|
|
||||||
// We enter a loop that runs until the users exits.
|
|
||||||
// If the user hits enter, we will announce our server
|
|
||||||
// destination on the network, which will let clients
|
|
||||||
// know how to create messages directed towards it.
|
|
||||||
while (true) {
|
|
||||||
reticulum.loop();
|
|
||||||
udp_interface.loop();
|
|
||||||
// Non-blocking input
|
|
||||||
char ch;
|
|
||||||
while (read(STDIN_FILENO, &ch, 1) > 0) {
|
|
||||||
if (ch == '\n') {
|
|
||||||
server_destination.announce();
|
|
||||||
RNS::log("Sent announce from "+server_destination.hash().toHex());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -221,54 +190,62 @@ void client_packet_received(const RNS::Bytes& message, const RNS::Packet& packet
|
|||||||
}
|
}
|
||||||
|
|
||||||
void client_loop() {
|
void client_loop() {
|
||||||
|
// Wait for the link to become active
|
||||||
// Wait for the link to become active
|
RNS::log("Waiting for link to become active...");
|
||||||
while (!server_link) {
|
while (!server_link) {
|
||||||
|
reticulum.loop();
|
||||||
|
udp_interface.loop();
|
||||||
RNS::Utilities::OS::sleep(0.1);
|
RNS::Utilities::OS::sleep(0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool should_quit = false;
|
std::string text;
|
||||||
|
printf("> ");
|
||||||
|
fflush(STDIN_FILENO);
|
||||||
|
bool should_quit = false;
|
||||||
while (!should_quit) {
|
while (!should_quit) {
|
||||||
try {
|
reticulum.loop();
|
||||||
printf("> ");
|
udp_interface.loop();
|
||||||
char *line = NULL;
|
|
||||||
size_t size;
|
|
||||||
if (getline(&line, &size, stdin) == -1) {
|
|
||||||
//printf("No line\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
std::string text(line);
|
|
||||||
|
|
||||||
// Check if we should quit the example
|
// Non-blocking input
|
||||||
if (text == "quit" || text == "q" || text == "exit") {
|
char ch;
|
||||||
should_quit = true;
|
while (read(STDIN_FILENO, &ch, 1) > 0) {
|
||||||
server_link.teardown();
|
if (ch == '\n') {
|
||||||
}
|
|
||||||
|
|
||||||
// If not, send the entered text over the link
|
// Check if we should quit the example
|
||||||
if (text != "") {
|
if (text == "quit" || text == "q" || text == "exit") {
|
||||||
RNS::Bytes data(text);
|
should_quit = true;
|
||||||
if (data.size() <= RNS::Type::Link::MDU) {
|
server_link.teardown();
|
||||||
// CBA TODO: Add Packet constructor that accepts Link but doesn't require Destination
|
|
||||||
//RNS::Packet(RNS::Type::NONE, server_link, data).send();
|
|
||||||
RNS::Packet(server_link, data).send();
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
RNS::log(
|
// If not, send the entered text over the link
|
||||||
"Cannot send this packet, the data size of "+
|
if (text != "") {
|
||||||
std::to_string(data.size())+" bytes exceeds the link packet MDU of "+
|
RNS::Bytes data(text);
|
||||||
std::to_string(RNS::Type::Link::MDU)+" bytes",
|
if (data.size() <= RNS::Type::Link::MDU) {
|
||||||
RNS::LOG_ERROR
|
printf("(sending data: %s)\n", text.c_str());
|
||||||
);
|
// CBA TODO: Add Packet constructor that accepts Link but doesn't require Destination
|
||||||
|
//RNS::Packet(RNS::Type::NONE, server_link, data).send();
|
||||||
|
RNS::Packet(server_link, data).send();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
RNS::log(
|
||||||
|
"Cannot send this packet, the data size of "+
|
||||||
|
std::to_string(data.size())+" bytes exceeds the link packet MDU of "+
|
||||||
|
std::to_string(RNS::Type::Link::MDU)+" bytes",
|
||||||
|
RNS::LOG_ERROR
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
text.clear();
|
||||||
|
|
||||||
|
printf("> ");
|
||||||
|
fflush(STDIN_FILENO);
|
||||||
|
} else {
|
||||||
|
text += ch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
|
||||||
//RNS::log("Error while sending data over the link: "+e.what());
|
RNS::Utilities::OS::sleep(0.1);
|
||||||
RNS::log("Error while sending data over the link: ");
|
|
||||||
should_quit = true;
|
|
||||||
server_link.teardown();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,21 +268,6 @@ void client(const char* destination_hexhash) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize and register filesystem
|
|
||||||
RNS::FileSystem universal_filesystem = new UniversalFileSystem();
|
|
||||||
universal_filesystem.init();
|
|
||||||
RNS::Utilities::OS::register_filesystem(universal_filesystem);
|
|
||||||
|
|
||||||
// Initialize and register interface
|
|
||||||
RNS::Interface udp_interface = new UDPInterface();
|
|
||||||
udp_interface.mode(RNS::Type::Interface::MODE_GATEWAY);
|
|
||||||
RNS::Transport::register_interface(udp_interface);
|
|
||||||
udp_interface.start();
|
|
||||||
|
|
||||||
// Initialize and start Reticulum
|
|
||||||
RNS::Reticulum reticulum = RNS::Reticulum();
|
|
||||||
reticulum.start();
|
|
||||||
|
|
||||||
// Check if we know a path to the destination
|
// Check if we know a path to the destination
|
||||||
if (!RNS::Transport::has_path(destination_hash)) {
|
if (!RNS::Transport::has_path(destination_hash)) {
|
||||||
RNS::log("Destination is not yet known. Requesting path and waiting for announce to arrive...");
|
RNS::log("Destination is not yet known. Requesting path and waiting for announce to arrive...");
|
||||||
@@ -348,68 +310,7 @@ void client(const char* destination_hexhash) {
|
|||||||
|
|
||||||
// Everything is set up, so let's enter a loop
|
// Everything is set up, so let's enter a loop
|
||||||
// for the user to interact with the example
|
// for the user to interact with the example
|
||||||
//client_loop();
|
client_loop();
|
||||||
|
|
||||||
// Wait for the link to become active
|
|
||||||
RNS::log("Waiting for link to become active...");
|
|
||||||
while (!server_link) {
|
|
||||||
reticulum.loop();
|
|
||||||
udp_interface.loop();
|
|
||||||
RNS::Utilities::OS::sleep(0.1);
|
|
||||||
}
|
|
||||||
RNS::log("Link is active");
|
|
||||||
|
|
||||||
std::string text;
|
|
||||||
printf("> ");
|
|
||||||
fflush(STDIN_FILENO);
|
|
||||||
bool should_quit = false;
|
|
||||||
while (!should_quit) {
|
|
||||||
//printf(".");
|
|
||||||
reticulum.loop();
|
|
||||||
udp_interface.loop();
|
|
||||||
|
|
||||||
// Non-blocking input
|
|
||||||
char ch;
|
|
||||||
while (read(STDIN_FILENO, &ch, 1) > 0) {
|
|
||||||
if (ch == '\n') {
|
|
||||||
//printf("Text: %s", text.c_str());
|
|
||||||
|
|
||||||
// Check if we should quit the example
|
|
||||||
if (text == "quit" || text == "q" || text == "exit") {
|
|
||||||
should_quit = true;
|
|
||||||
server_link.teardown();
|
|
||||||
}
|
|
||||||
|
|
||||||
// If not, send the entered text over the link
|
|
||||||
if (text != "") {
|
|
||||||
RNS::Bytes data(text);
|
|
||||||
if (data.size() <= RNS::Type::Link::MDU) {
|
|
||||||
printf("(sending data: %s)\n", text.c_str());
|
|
||||||
// CBA TODO: Add Packet constructor that accepts Link but doesn't require Destination
|
|
||||||
//RNS::Packet(RNS::Type::NONE, server_link, data).send();
|
|
||||||
RNS::Packet(server_link, data).send();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
RNS::log(
|
|
||||||
"Cannot send this packet, the data size of "+
|
|
||||||
std::to_string(data.size())+" bytes exceeds the link packet MDU of "+
|
|
||||||
std::to_string(RNS::Type::Link::MDU)+" bytes",
|
|
||||||
RNS::LOG_ERROR
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
text.clear();
|
|
||||||
|
|
||||||
printf("> ");
|
|
||||||
fflush(STDIN_FILENO);
|
|
||||||
} else {
|
|
||||||
text += ch;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RNS::Utilities::OS::sleep(0.1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -437,8 +338,8 @@ int main(int argc, char *argv[]) {
|
|||||||
#if defined(MEM_LOG)
|
#if defined(MEM_LOG)
|
||||||
RNS::loglevel(RNS::LOG_MEM);
|
RNS::loglevel(RNS::LOG_MEM);
|
||||||
#else
|
#else
|
||||||
//RNS::loglevel(RNS::LOG_NOTICE);
|
RNS::loglevel(RNS::LOG_NOTICE);
|
||||||
RNS::loglevel(RNS::LOG_TRACE);
|
//RNS::loglevel(RNS::LOG_TRACE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Register the signal handler for SIGINT
|
// Register the signal handler for SIGINT
|
||||||
@@ -448,6 +349,20 @@ int main(int argc, char *argv[]) {
|
|||||||
int flags = fcntl(STDIN_FILENO, F_GETFL, 0);
|
int flags = fcntl(STDIN_FILENO, F_GETFL, 0);
|
||||||
fcntl(STDIN_FILENO, F_SETFL, flags | O_NONBLOCK);
|
fcntl(STDIN_FILENO, F_SETFL, flags | O_NONBLOCK);
|
||||||
|
|
||||||
|
// Initialize and register filesystem
|
||||||
|
universal_filesystem = new UniversalFileSystem();
|
||||||
|
universal_filesystem.init();
|
||||||
|
RNS::Utilities::OS::register_filesystem(universal_filesystem);
|
||||||
|
|
||||||
|
// Initialize and register interface
|
||||||
|
udp_interface = new UDPInterface();
|
||||||
|
udp_interface.mode(RNS::Type::Interface::MODE_GATEWAY);
|
||||||
|
RNS::Transport::register_interface(udp_interface);
|
||||||
|
udp_interface.start();
|
||||||
|
|
||||||
|
// Initialize and start Reticulum
|
||||||
|
reticulum.start();
|
||||||
|
|
||||||
if (argc <= 1) {
|
if (argc <= 1) {
|
||||||
printf("\nMust specify a destination for client mode, or \"-s\" or \"--server\" for server mode.\n\n");
|
printf("\nMust specify a destination for client mode, or \"-s\" or \"--server\" for server mode.\n\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -9,9 +9,7 @@
|
|||||||
; https://docs.platformio.org/page/projectconf.html
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
[platformio]
|
[platformio]
|
||||||
;default_envs = native
|
default_envs = native
|
||||||
;include_dir = ../../src
|
|
||||||
;src_dir = ../../src
|
|
||||||
include_dir = .
|
include_dir = .
|
||||||
src_dir = .
|
src_dir = .
|
||||||
|
|
||||||
@@ -28,7 +26,8 @@ lib_deps =
|
|||||||
MsgPack@^0.4.2
|
MsgPack@^0.4.2
|
||||||
https://github.com/attermann/Crypto.git
|
https://github.com/attermann/Crypto.git
|
||||||
microReticulum=symlink://../..
|
microReticulum=symlink://../..
|
||||||
common=symlink://../common
|
universal_filesystem=symlink://../common/universal_filesystem
|
||||||
|
udp_interface=symlink://../common/udp_interface
|
||||||
|
|
||||||
[env:native]
|
[env:native]
|
||||||
platform = native
|
platform = native
|
||||||
|
|||||||
@@ -9,9 +9,7 @@
|
|||||||
; https://docs.platformio.org/page/projectconf.html
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
[platformio]
|
[platformio]
|
||||||
;default_envs = native
|
default_envs = native
|
||||||
;include_dir = ../../src
|
|
||||||
;src_dir = ../../src
|
|
||||||
include_dir = .
|
include_dir = .
|
||||||
src_dir = .
|
src_dir = .
|
||||||
|
|
||||||
@@ -31,7 +29,8 @@ lib_deps =
|
|||||||
https://github.com/attermann/Crypto.git
|
https://github.com/attermann/Crypto.git
|
||||||
https://github.com/hideakitai/MsgPack.git
|
https://github.com/hideakitai/MsgPack.git
|
||||||
microReticulum=symlink://../..
|
microReticulum=symlink://../..
|
||||||
impl=symlink://../impl
|
universal_filesystem=symlink://../common/universal_filesystem
|
||||||
|
lora_interface=symlink://../common/lora_interface
|
||||||
|
|
||||||
[env:native]
|
[env:native]
|
||||||
platform = native
|
platform = native
|
||||||
@@ -76,44 +75,6 @@ lib_deps =
|
|||||||
lib_extra_dirs = ../
|
lib_extra_dirs = ../
|
||||||
lib_compat_mode = off
|
lib_compat_mode = off
|
||||||
|
|
||||||
[env:cubecell-gps]
|
|
||||||
framework = arduino
|
|
||||||
platform = heltec-cubecell
|
|
||||||
board = cubecell_gps
|
|
||||||
;build_flags = -Wl,-Map,output.map
|
|
||||||
build_flags =
|
|
||||||
${env.build_flags}
|
|
||||||
-std=c++11
|
|
||||||
-Wall
|
|
||||||
-Wextra
|
|
||||||
-Wno-missing-field-initializers
|
|
||||||
-Wno-format
|
|
||||||
-I.
|
|
||||||
-DCUBECELL
|
|
||||||
lib_deps =
|
|
||||||
${env.lib_deps}
|
|
||||||
; CBA NOTE must undef min and max from Arduino.h
|
|
||||||
|
|
||||||
[env:heltec-tracker]
|
|
||||||
framework = arduino
|
|
||||||
platform = espressif32
|
|
||||||
board = heltec_wireless_tracker
|
|
||||||
upload_protocol = esp-builtin
|
|
||||||
;board_build.partitions = no_ota.csv
|
|
||||||
;board_build.partitions = huge_app.csv
|
|
||||||
build_flags =
|
|
||||||
${env.build_flags}
|
|
||||||
-Wall
|
|
||||||
-Wextra
|
|
||||||
-Wno-missing-field-initializers
|
|
||||||
-Wno-format
|
|
||||||
-I variants/heltec_wireless_tracker
|
|
||||||
-I.
|
|
||||||
-DBOARD_ESP32
|
|
||||||
lib_deps =
|
|
||||||
${env.lib_deps}
|
|
||||||
lovyan03/LovyanGFX@^1.1.8
|
|
||||||
|
|
||||||
[env:ttgo-lora32-v21]
|
[env:ttgo-lora32-v21]
|
||||||
framework = arduino
|
framework = arduino
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
@@ -169,23 +130,3 @@ build_flags =
|
|||||||
build_unflags = -fno-exceptions
|
build_unflags = -fno-exceptions
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${env.lib_deps}
|
${env.lib_deps}
|
||||||
|
|
||||||
[env:nrf52840_dk_adafruit]
|
|
||||||
framework = arduino
|
|
||||||
platform = nordicnrf52
|
|
||||||
board = nrf52840_dk_adafruit
|
|
||||||
monitor_speed = 115200
|
|
||||||
build_flags =
|
|
||||||
${env.build_flags}
|
|
||||||
lib_deps =
|
|
||||||
${env.lib_deps}
|
|
||||||
|
|
||||||
[env:nrf52_dk]
|
|
||||||
framework = arduino
|
|
||||||
;framework = zephyr
|
|
||||||
platform = nordicnrf52
|
|
||||||
board = nrf52_dk
|
|
||||||
build_flags =
|
|
||||||
${env.build_flags}
|
|
||||||
lib_deps =
|
|
||||||
${env.lib_deps}
|
|
||||||
@@ -9,9 +9,7 @@
|
|||||||
; https://docs.platformio.org/page/projectconf.html
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
[platformio]
|
[platformio]
|
||||||
;default_envs = native
|
default_envs = native
|
||||||
;include_dir = ../../src
|
|
||||||
;src_dir = ../../src
|
|
||||||
include_dir = .
|
include_dir = .
|
||||||
src_dir = .
|
src_dir = .
|
||||||
|
|
||||||
@@ -28,7 +26,8 @@ lib_deps =
|
|||||||
https://github.com/attermann/Crypto.git
|
https://github.com/attermann/Crypto.git
|
||||||
https://github.com/hideakitai/MsgPack.git
|
https://github.com/hideakitai/MsgPack.git
|
||||||
microReticulum=symlink://../..
|
microReticulum=symlink://../..
|
||||||
common=symlink://../common
|
universal_filesystem=symlink://../common/universal_filesystem
|
||||||
|
udp_interface=symlink://../common/udp_interface
|
||||||
|
|
||||||
[env:native]
|
[env:native]
|
||||||
platform = native
|
platform = native
|
||||||
@@ -73,74 +72,6 @@ lib_deps =
|
|||||||
lib_extra_dirs = ../
|
lib_extra_dirs = ../
|
||||||
lib_compat_mode = off
|
lib_compat_mode = off
|
||||||
|
|
||||||
[env:luckfox]
|
|
||||||
;platform = linux_arm
|
|
||||||
;board = raspberrypi_2b
|
|
||||||
;framework = arduino
|
|
||||||
;platform = https://github.com/geeksville/platform-native.git
|
|
||||||
platform = https://github.com/meshtastic/platform-native.git
|
|
||||||
;platform = https://github.com/meshtastic/platform-native/archive/6cb7a455b440dd0738e8ed74a18136ed5cf7ea63.zip
|
|
||||||
;board = cross_platform
|
|
||||||
board = linux_hardware
|
|
||||||
monitor_port = none
|
|
||||||
build_flags =
|
|
||||||
${env.build_flags}
|
|
||||||
-std=gnu17
|
|
||||||
-std=c++17
|
|
||||||
-g3
|
|
||||||
-ggdb
|
|
||||||
-Wall
|
|
||||||
-Wextra
|
|
||||||
-Wno-missing-field-initializers
|
|
||||||
-Wno-format
|
|
||||||
-Wno-unused-parameter
|
|
||||||
-O0
|
|
||||||
;-lgpiod
|
|
||||||
-I.
|
|
||||||
-DNATIVE
|
|
||||||
lib_deps =
|
|
||||||
${env.lib_deps}
|
|
||||||
lib_extra_dirs = ../
|
|
||||||
lib_compat_mode = off
|
|
||||||
|
|
||||||
[env:cubecell-gps]
|
|
||||||
framework = arduino
|
|
||||||
platform = heltec-cubecell
|
|
||||||
board = cubecell_gps
|
|
||||||
;build_flags = -Wl,-Map,output.map
|
|
||||||
build_flags =
|
|
||||||
${env.build_flags}
|
|
||||||
-std=c++11
|
|
||||||
-Wall
|
|
||||||
-Wextra
|
|
||||||
-Wno-missing-field-initializers
|
|
||||||
-Wno-format
|
|
||||||
-I.
|
|
||||||
-DCUBECELL
|
|
||||||
lib_deps =
|
|
||||||
${env.lib_deps}
|
|
||||||
; CBA NOTE must undef min and max from Arduino.h
|
|
||||||
|
|
||||||
[env:heltec-tracker]
|
|
||||||
framework = arduino
|
|
||||||
platform = espressif32
|
|
||||||
board = heltec_wireless_tracker
|
|
||||||
upload_protocol = esp-builtin
|
|
||||||
;board_build.partitions = no_ota.csv
|
|
||||||
;board_build.partitions = huge_app.csv
|
|
||||||
build_flags =
|
|
||||||
${env.build_flags}
|
|
||||||
-Wall
|
|
||||||
-Wextra
|
|
||||||
-Wno-missing-field-initializers
|
|
||||||
-Wno-format
|
|
||||||
-I variants/heltec_wireless_tracker
|
|
||||||
-I.
|
|
||||||
-DBOARD_ESP32
|
|
||||||
lib_deps =
|
|
||||||
${env.lib_deps}
|
|
||||||
lovyan03/LovyanGFX@^1.1.8
|
|
||||||
|
|
||||||
[env:ttgo-lora32-v21]
|
[env:ttgo-lora32-v21]
|
||||||
framework = arduino
|
framework = arduino
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
@@ -216,3 +147,33 @@ build_flags =
|
|||||||
${env.build_flags}
|
${env.build_flags}
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${env.lib_deps}
|
${env.lib_deps}
|
||||||
|
|
||||||
|
[env:luckfox]
|
||||||
|
;platform = linux_arm
|
||||||
|
;board = raspberrypi_2b
|
||||||
|
;framework = arduino
|
||||||
|
;platform = https://github.com/geeksville/platform-native.git
|
||||||
|
platform = https://github.com/meshtastic/platform-native.git
|
||||||
|
;platform = https://github.com/meshtastic/platform-native/archive/6cb7a455b440dd0738e8ed74a18136ed5cf7ea63.zip
|
||||||
|
;board = cross_platform
|
||||||
|
board = linux_hardware
|
||||||
|
monitor_port = none
|
||||||
|
build_flags =
|
||||||
|
${env.build_flags}
|
||||||
|
-std=gnu17
|
||||||
|
-std=c++17
|
||||||
|
-g3
|
||||||
|
-ggdb
|
||||||
|
-Wall
|
||||||
|
-Wextra
|
||||||
|
-Wno-missing-field-initializers
|
||||||
|
-Wno-format
|
||||||
|
-Wno-unused-parameter
|
||||||
|
-O0
|
||||||
|
;-lgpiod
|
||||||
|
-I.
|
||||||
|
-DNATIVE
|
||||||
|
lib_deps =
|
||||||
|
${env.lib_deps}
|
||||||
|
lib_extra_dirs = ../
|
||||||
|
lib_compat_mode = off
|
||||||
@@ -246,7 +246,7 @@ void FileSystem::listDir(const char* dir) {
|
|||||||
//File file = SPIFFS.open(file_path, mode);
|
//File file = SPIFFS.open(file_path, mode);
|
||||||
//if (!file) {
|
//if (!file) {
|
||||||
File* file = new File(SPIFFS.open(file_path, mode));
|
File* file = new File(SPIFFS.open(file_path, mode));
|
||||||
if (file == null || !(*file)) {
|
if (file == nullptr || !(*file)) {
|
||||||
ERRORF("open_file: failed to open output file %s", file_path);
|
ERRORF("open_file: failed to open output file %s", file_path);
|
||||||
return {RNS::Type::NONE};
|
return {RNS::Type::NONE};
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-13
@@ -9,7 +9,7 @@
|
|||||||
; https://docs.platformio.org/page/projectconf.html
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
[platformio]
|
[platformio]
|
||||||
;default_envs = native
|
default_envs = native
|
||||||
|
|
||||||
[env]
|
[env]
|
||||||
build_flags =
|
build_flags =
|
||||||
@@ -60,18 +60,6 @@ lib_deps =
|
|||||||
${env.lib_deps}
|
${env.lib_deps}
|
||||||
lib_compat_mode = off
|
lib_compat_mode = off
|
||||||
|
|
||||||
[env:cubecell-gps]
|
|
||||||
platform = heltec-cubecell
|
|
||||||
board = cubecell_gps
|
|
||||||
framework = arduino
|
|
||||||
monitor_speed = 115200
|
|
||||||
;build_flags = -Wl,-Map,output.map
|
|
||||||
build_flags =
|
|
||||||
${env.build_flags}
|
|
||||||
lib_deps =
|
|
||||||
${env.lib_deps}
|
|
||||||
; CBA NOTE must undef min and max from Arduino.h
|
|
||||||
|
|
||||||
[env:ttgo-lora32-v21]
|
[env:ttgo-lora32-v21]
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
board = ttgo-lora32-v21
|
board = ttgo-lora32-v21
|
||||||
@@ -80,6 +68,7 @@ framework = arduino
|
|||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
build_flags =
|
build_flags =
|
||||||
${env.build_flags}
|
${env.build_flags}
|
||||||
|
-DMSGPACK_USE_BOOST=OFF
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${env.lib_deps}
|
${env.lib_deps}
|
||||||
|
|
||||||
@@ -92,6 +81,7 @@ framework = arduino
|
|||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
build_flags =
|
build_flags =
|
||||||
${env.build_flags}
|
${env.build_flags}
|
||||||
|
-DMSGPACK_USE_BOOST=OFF
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${env.lib_deps}
|
${env.lib_deps}
|
||||||
|
|
||||||
@@ -106,5 +96,6 @@ build_flags =
|
|||||||
-fexceptions
|
-fexceptions
|
||||||
-DRNS_USE_ALLOCATOR=1
|
-DRNS_USE_ALLOCATOR=1
|
||||||
-DRNS_USE_TLSF=1
|
-DRNS_USE_TLSF=1
|
||||||
|
-DMSGPACK_USE_BOOST=OFF
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${env.lib_deps}
|
${env.lib_deps}
|
||||||
+1
-1
@@ -55,7 +55,7 @@ namespace RNS {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
FileStream(Type::NoneConstructor none) {
|
FileStream(Type::NoneConstructor none) {
|
||||||
MEMF("FileStream object NONE created, this: 0x%X, impl: 0x%X", this, _impl.get());
|
MEMF("FileStream NONE object created, this: 0x%X, impl: 0x%X", this, _impl.get());
|
||||||
}
|
}
|
||||||
FileStream(const FileStream& obj) : _impl(obj._impl), _crc(obj._crc) {
|
FileStream(const FileStream& obj) : _impl(obj._impl), _crc(obj._crc) {
|
||||||
MEMF("FileStream object copy created, this: 0x%X, impl: 0x%X", this, _impl.get());
|
MEMF("FileStream object copy created, this: 0x%X, impl: 0x%X", this, _impl.get());
|
||||||
|
|||||||
+1
-1
@@ -41,7 +41,7 @@ namespace RNS {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
FileSystem(Type::NoneConstructor none) {
|
FileSystem(Type::NoneConstructor none) {
|
||||||
MEMF("FileSystem object NONE created, this: 0x%X, impl: 0x%X", this, _impl.get());
|
MEMF("FileSystem NONE object created, this: 0x%X, impl: 0x%X", this, _impl.get());
|
||||||
}
|
}
|
||||||
FileSystem(const FileSystem& obj) : _impl(obj._impl) {
|
FileSystem(const FileSystem& obj) : _impl(obj._impl) {
|
||||||
MEMF("FileSystem object copy created, this: 0x%X, impl: 0x%X", this, _impl.get());
|
MEMF("FileSystem object copy created, this: 0x%X, impl: 0x%X", this, _impl.get());
|
||||||
|
|||||||
+1
-1
@@ -44,13 +44,13 @@ namespace RNS {
|
|||||||
static uint16_t _known_destinations_maxsize;
|
static uint16_t _known_destinations_maxsize;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Identity(bool create_keys = true);
|
||||||
Identity(Type::NoneConstructor none) {
|
Identity(Type::NoneConstructor none) {
|
||||||
MEM("Identity NONE object created, this: " + std::to_string((uintptr_t)this) + ", data: " + std::to_string((uintptr_t)_object.get()));
|
MEM("Identity NONE object created, this: " + std::to_string((uintptr_t)this) + ", data: " + std::to_string((uintptr_t)_object.get()));
|
||||||
}
|
}
|
||||||
Identity(const Identity& identity) : _object(identity._object) {
|
Identity(const Identity& identity) : _object(identity._object) {
|
||||||
MEM("Identity object copy created, this: " + std::to_string((uintptr_t)this) + ", data: " + std::to_string((uintptr_t)_object.get()));
|
MEM("Identity object copy created, this: " + std::to_string((uintptr_t)this) + ", data: " + std::to_string((uintptr_t)_object.get()));
|
||||||
}
|
}
|
||||||
Identity(bool create_keys = true);
|
|
||||||
virtual ~Identity() {
|
virtual ~Identity() {
|
||||||
MEM("Identity object destroyed, this: " + std::to_string((uintptr_t)this) + ", data: " + std::to_string((uintptr_t)_object.get()));
|
MEM("Identity object destroyed, this: " + std::to_string((uintptr_t)this) + ", data: " + std::to_string((uintptr_t)_object.get()));
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -98,7 +98,7 @@ namespace RNS {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Interface(Type::NoneConstructor none) {
|
Interface(Type::NoneConstructor none) {
|
||||||
MEMF("Interface object NONE created, this: 0x%X, impl: 0x%X", this, _impl.get());
|
MEMF("Interface NONE object created, this: 0x%X, impl: 0x%X", this, _impl.get());
|
||||||
}
|
}
|
||||||
Interface(const Interface& obj) : _impl(obj._impl) {
|
Interface(const Interface& obj) : _impl(obj._impl) {
|
||||||
MEMF("Interface object copy created, this: 0x%X, impl: 0x%X", this, _impl.get());
|
MEMF("Interface object copy created, this: 0x%X, impl: 0x%X", this, _impl.get());
|
||||||
|
|||||||
+5
-3
@@ -11,6 +11,7 @@
|
|||||||
#include "Cryptography/HKDF.h"
|
#include "Cryptography/HKDF.h"
|
||||||
#include "Cryptography/Token.h"
|
#include "Cryptography/Token.h"
|
||||||
#include "Cryptography/Random.h"
|
#include "Cryptography/Random.h"
|
||||||
|
#include "Utilities/OS.h"
|
||||||
|
|
||||||
#define MSGPACK_DEBUGLOG_ENABLE 0
|
#define MSGPACK_DEBUGLOG_ENABLE 0
|
||||||
#include <MsgPack.h>
|
#include <MsgPack.h>
|
||||||
@@ -119,7 +120,7 @@ Link::Link(const Destination& destination /*= {Type::NONE}*/, Callbacks::establi
|
|||||||
if (Link::ENABLED_MODES.find(mode) == Link::ENABLED_MODES.end()) throw std::runtime_error("Requested link mode "+std::to_string(mode)+" not enabled");
|
if (Link::ENABLED_MODES.find(mode) == Link::ENABLED_MODES.end()) throw std::runtime_error("Requested link mode "+std::to_string(mode)+" not enabled");
|
||||||
//p signalling_value = (mtu & Link.MTU_BYTEMASK)+(((mode<<5) & Link.MODE_BYTEMASK)<<16)
|
//p signalling_value = (mtu & Link.MTU_BYTEMASK)+(((mode<<5) & Link.MODE_BYTEMASK)<<16)
|
||||||
//p return struct.pack(">I", signalling_value)[1:]
|
//p return struct.pack(">I", signalling_value)[1:]
|
||||||
uint32_t signalling_value = htonl((mtu & MTU_BYTEMASK)+(((mode<<5) & MODE_BYTEMASK)<<16));
|
uint32_t signalling_value = OS::portable_htonl((mtu & MTU_BYTEMASK)+(((mode<<5) & MODE_BYTEMASK)<<16));
|
||||||
Bytes data(((uint8_t*)&signalling_value)+1, 3);
|
Bytes data(((uint8_t*)&signalling_value)+1, 3);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@@ -1576,8 +1577,9 @@ RequestReceipt::RequestReceipt(const Link& link, const PacketReceipt& packet_rec
|
|||||||
}
|
}
|
||||||
else if (_object->_resource) {
|
else if (_object->_resource) {
|
||||||
_object->_hash = resource.request_id();
|
_object->_hash = resource.request_id();
|
||||||
//const_cast<Resource&>(resource).set_concluded_callback(request_resource_concluded);
|
// CBA TODO Need to find cross-platform way of passing class method as callback
|
||||||
const_cast<Resource&>(resource).set_concluded_callback(std::bind(&RequestReceipt::request_resource_concluded, this, std::placeholders::_1));
|
//z const_cast<Resource&>(resource).set_concluded_callback(request_resource_concluded);
|
||||||
|
//z const_cast<Resource&>(resource).set_concluded_callback(std::bind(&RequestReceipt::request_resource_concluded, this, std::placeholders::_1));
|
||||||
}
|
}
|
||||||
_object->_link = link;
|
_object->_link = link;
|
||||||
_object->_request_id = _object->_hash;
|
_object->_request_id = _object->_hash;
|
||||||
|
|||||||
+1
-1
@@ -48,9 +48,9 @@ namespace RNS {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
PacketReceipt() : _object(new Object()) {}
|
||||||
PacketReceipt(Type::NoneConstructor none) {}
|
PacketReceipt(Type::NoneConstructor none) {}
|
||||||
PacketReceipt(const PacketReceipt& packet_receipt) : _object(packet_receipt._object) {}
|
PacketReceipt(const PacketReceipt& packet_receipt) : _object(packet_receipt._object) {}
|
||||||
PacketReceipt() : _object(new Object()) {}
|
|
||||||
PacketReceipt(const Packet& packet);
|
PacketReceipt(const Packet& packet);
|
||||||
|
|
||||||
inline PacketReceipt& operator = (const PacketReceipt& packet_receipt) {
|
inline PacketReceipt& operator = (const PacketReceipt& packet_receipt) {
|
||||||
|
|||||||
+3
-2
@@ -19,8 +19,9 @@ namespace RNS {
|
|||||||
public:
|
public:
|
||||||
class Callbacks {
|
class Callbacks {
|
||||||
public:
|
public:
|
||||||
//using concluded = void(*)(const Resource& resource);
|
// CBA std::function apparently not implemented in NRF52 framework
|
||||||
typedef std::function<void(const Resource& resource)> concluded;
|
//typedef std::function<void(const Resource& resource)> concluded;
|
||||||
|
using concluded = void(*)(const Resource& resource);
|
||||||
using progress = void(*)(const Resource& resource);
|
using progress = void(*)(const Resource& resource);
|
||||||
public:
|
public:
|
||||||
concluded _concluded = nullptr;
|
concluded _concluded = nullptr;
|
||||||
|
|||||||
+4
-3
@@ -69,9 +69,6 @@ void Reticulum::sigterm_handler(signal, frame):
|
|||||||
Reticulum::Reticulum() : _object(new Object()) {
|
Reticulum::Reticulum() : _object(new Object()) {
|
||||||
MEM("Reticulum default object creating..., this: " + std::to_string((uintptr_t)this) + ", data: " + std::to_string((uintptr_t)_object.get()));
|
MEM("Reticulum default object creating..., this: " + std::to_string((uintptr_t)this) + ", data: " + std::to_string((uintptr_t)_object.get()));
|
||||||
|
|
||||||
INFO("Total memory: " + std::to_string(OS::heap_size()));
|
|
||||||
INFO("Total flash: " + std::to_string(OS::storage_size()));
|
|
||||||
|
|
||||||
// Initialize random number generator
|
// Initialize random number generator
|
||||||
TRACE("Initializing RNG...");
|
TRACE("Initializing RNG...");
|
||||||
RNG.begin("Reticulum");
|
RNG.begin("Reticulum");
|
||||||
@@ -198,6 +195,10 @@ Reticulum::Reticulum() : _object(new Object()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Reticulum::start() {
|
void Reticulum::start() {
|
||||||
|
|
||||||
|
INFO("Total memory: " + std::to_string(OS::heap_size()));
|
||||||
|
INFO("Total flash: " + std::to_string(OS::storage_size()));
|
||||||
|
|
||||||
INFO("Starting Transport...");
|
INFO("Starting Transport...");
|
||||||
Transport::start(*this);
|
Transport::start(*this);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -47,13 +47,13 @@ namespace RNS {
|
|||||||
inline static const Reticulum& get_instance() { return _instance; }
|
inline static const Reticulum& get_instance() { return _instance; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Reticulum();
|
||||||
Reticulum(Type::NoneConstructor none) {
|
Reticulum(Type::NoneConstructor none) {
|
||||||
MEM("Reticulum NONE object created, this: " + std::to_string((uintptr_t)this) + ", data: " + std::to_string((uintptr_t)_object.get()));
|
MEM("Reticulum empty object created, this: " + std::to_string((uintptr_t)this) + ", data: " + std::to_string((uintptr_t)_object.get()));
|
||||||
}
|
}
|
||||||
Reticulum(const Reticulum& reticulum) : _object(reticulum._object) {
|
Reticulum(const Reticulum& reticulum) : _object(reticulum._object) {
|
||||||
MEM("Reticulum object copy created, this: " + std::to_string((uintptr_t)this) + ", data: " + std::to_string((uintptr_t)_object.get()));
|
MEM("Reticulum object copy created, this: " + std::to_string((uintptr_t)this) + ", data: " + std::to_string((uintptr_t)_object.get()));
|
||||||
}
|
}
|
||||||
Reticulum();
|
|
||||||
virtual ~Reticulum() {
|
virtual ~Reticulum() {
|
||||||
MEM("Reticulum object destroyed, this: " + std::to_string((uintptr_t)this) + ", data: " + std::to_string((uintptr_t)_object.get()));
|
MEM("Reticulum object destroyed, this: " + std::to_string((uintptr_t)this) + ", data: " + std::to_string((uintptr_t)_object.get()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,6 +78,42 @@ namespace RNS { namespace Utilities {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Detect endianness at runtime
|
||||||
|
static int is_big_endian(void) {
|
||||||
|
uint16_t test = 0x0102;
|
||||||
|
return ((uint8_t*)&test)[0] == 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Byte swap functions
|
||||||
|
static uint16_t swap16(uint16_t val) {
|
||||||
|
return (val << 8) | (val >> 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32_t swap32(uint32_t val) {
|
||||||
|
return ((val << 24) & 0xFF000000) |
|
||||||
|
((val << 8) & 0x00FF0000) |
|
||||||
|
((val >> 8) & 0x0000FF00) |
|
||||||
|
((val >> 24) & 0x000000FF);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Platform-independent replacements
|
||||||
|
|
||||||
|
static uint16_t portable_htons(uint16_t val) {
|
||||||
|
return is_big_endian() ? val : swap16(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32_t portable_htonl(uint32_t val) {
|
||||||
|
return is_big_endian() ? val : swap32(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint16_t portable_ntohs(uint16_t val) {
|
||||||
|
return is_big_endian() ? val : swap16(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32_t portable_ntohl(uint32_t val) {
|
||||||
|
return is_big_endian() ? val : swap32(val);
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(RNS_USE_ALLOCATOR)
|
#if defined(RNS_USE_ALLOCATOR)
|
||||||
static void dump_allocator_stats();
|
static void dump_allocator_stats();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+8
-1
@@ -1,6 +1,13 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef NATIVE
|
#ifdef ARDUINO
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
}
|
||||||
|
void loop() {
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
printf("\nSilly rabbit, microReticulum is a library!\n\nSee the examples directory for example programs that make use of this library.\n\n");
|
printf("\nSilly rabbit, microReticulum is a library!\n\nSee the examples directory for example programs that make use of this library.\n\n");
|
||||||
|
|||||||
Reference in new issue
Block a user