2023-10-06 17:24:48 -06:00
|
|
|
//#define NDEBUG
|
|
|
|
|
|
2023-10-07 01:03:15 -06:00
|
|
|
#include "Test/Test.h"
|
|
|
|
|
|
2023-10-06 17:24:48 -06:00
|
|
|
#include "Reticulum.h"
|
|
|
|
|
#include "Identity.h"
|
|
|
|
|
#include "Destination.h"
|
|
|
|
|
#include "Packet.h"
|
|
|
|
|
#include "Bytes.h"
|
|
|
|
|
|
|
|
|
|
#ifndef NATIVE
|
|
|
|
|
#include <Arduino.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <map>
|
|
|
|
|
//#include <sstream>
|
|
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
|
|
// Let's define an app name. We'll use this for all
|
|
|
|
|
// destinations we create. Since this basic example
|
|
|
|
|
// is part of a range of example utilities, we'll put
|
|
|
|
|
// them all within the app namespace "example_utilities"
|
|
|
|
|
const char* APP_NAME = "example_utilities";
|
|
|
|
|
|
|
|
|
|
// We initialise two lists of strings to use as app_data
|
|
|
|
|
const char* fruits[] = {"Peach", "Quince", "Date", "Tangerine", "Pomelo", "Carambola", "Grape"};
|
|
|
|
|
const char* noble_gases[] = {"Helium", "Neon", "Argon", "Krypton", "Xenon", "Radon", "Oganesson"};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setup() {
|
|
|
|
|
|
2023-10-07 01:03:15 -06:00
|
|
|
#ifndef NATIVE
|
2023-10-06 17:24:48 -06:00
|
|
|
Serial.begin(115200);
|
|
|
|
|
Serial.print("Hello from T-Beam on PlatformIO!\n");
|
2023-10-07 01:03:15 -06:00
|
|
|
#endif
|
|
|
|
|
|
2023-10-07 15:03:21 -06:00
|
|
|
try {
|
|
|
|
|
|
2023-10-07 01:03:15 -06:00
|
|
|
#ifndef NDEBUG
|
2023-10-07 15:03:21 -06:00
|
|
|
RNS::loglevel(RNS::LOG_WARNING);
|
|
|
|
|
//RNS::loglevel(RNS::LOG_EXTREME);
|
|
|
|
|
test();
|
2023-10-07 01:03:15 -06:00
|
|
|
#endif
|
2023-10-06 17:24:48 -06:00
|
|
|
|
2023-10-07 15:03:21 -06:00
|
|
|
//std::stringstream test;
|
|
|
|
|
// !!! just adding this single stringstream alone (not even using it) adds a whopping 17.1% !!!
|
|
|
|
|
// !!! JUST SAY NO TO STRINGSTREAM !!!
|
|
|
|
|
|
|
|
|
|
RNS::loglevel(RNS::LOG_EXTREME);
|
2023-10-06 17:24:48 -06:00
|
|
|
|
2023-10-07 15:03:21 -06:00
|
|
|
// 18.5% completely empty program
|
2023-10-06 17:24:48 -06:00
|
|
|
|
2023-10-07 15:03:21 -06:00
|
|
|
// 21.8% baseline here with serial
|
2023-10-06 17:24:48 -06:00
|
|
|
|
2023-10-07 15:03:21 -06:00
|
|
|
RNS::Reticulum reticulum;
|
|
|
|
|
// 21.9% (+0.1%)
|
2023-10-06 17:24:48 -06:00
|
|
|
|
2023-10-07 15:03:21 -06:00
|
|
|
RNS::Identity identity;
|
|
|
|
|
// 22.6% (+0.7%)
|
2023-10-06 17:24:48 -06:00
|
|
|
|
2023-10-07 15:03:21 -06:00
|
|
|
RNS::Destination destination(identity, RNS::Destination::IN, RNS::Destination::SINGLE, "test", "context");
|
|
|
|
|
// 23.0% (+0.4%)
|
2023-10-06 17:24:48 -06:00
|
|
|
|
2023-10-07 15:03:21 -06:00
|
|
|
//destination.announce(RNS::bytesFromString(fruits[rand() % 7]));
|
|
|
|
|
// test path
|
|
|
|
|
destination.announce(RNS::bytesFromString(fruits[rand() % 7]), true, nullptr, RNS::bytesFromString("test_tag"));
|
|
|
|
|
// 23.9% (+0.8%)
|
2023-10-06 17:24:48 -06:00
|
|
|
|
2023-10-07 15:03:21 -06:00
|
|
|
//zdestination.set_proof_strategy(RNS::Destination::PROVE_ALL);
|
2023-10-06 17:24:48 -06:00
|
|
|
|
2023-10-07 15:03:21 -06:00
|
|
|
//zannounce_handler = ExampleAnnounceHandler(
|
|
|
|
|
//z aspect_filter="example_utilities.announcesample.fruits";
|
|
|
|
|
//z)
|
2023-10-06 17:24:48 -06:00
|
|
|
|
2023-10-07 15:03:21 -06:00
|
|
|
//zRNS::Transport.register_announce_handler(announce_handler);
|
2023-10-06 17:24:48 -06:00
|
|
|
|
2023-10-07 15:03:21 -06:00
|
|
|
}
|
|
|
|
|
catch (std::exception& e) {
|
|
|
|
|
RNS::error(std::string("!!! Exception in main: ") + e.what() + " !!!");
|
|
|
|
|
}
|
2023-10-06 17:24:48 -06:00
|
|
|
|
2023-10-07 01:03:15 -06:00
|
|
|
#ifndef NATIVE
|
2023-10-06 17:24:48 -06:00
|
|
|
Serial.print("Goodbye from T-Beam on PlatformIO!\n");
|
2023-10-07 01:03:15 -06:00
|
|
|
#endif
|
2023-10-06 17:24:48 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void loop() {
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-07 01:03:15 -06:00
|
|
|
int main(void) {
|
2023-10-06 17:24:48 -06:00
|
|
|
printf("Hello from Native on PlatformIO!\n");
|
|
|
|
|
|
2023-10-07 01:03:15 -06:00
|
|
|
setup();
|
|
|
|
|
|
|
|
|
|
//while (true) {
|
|
|
|
|
// loop();
|
|
|
|
|
//}
|
2023-10-06 17:24:48 -06:00
|
|
|
|
|
|
|
|
printf("Goodbye from Native on PlatformIO!\n");
|
|
|
|
|
}
|