blob: 4a1992ab2522901fb66fed04928c98a517c2e444 [file] [log] [blame]
Austin Schuhe84c3ed2019-12-14 15:29:48 -08001#include "aos/events/shm_event_loop.h"
2#include "aos/init.h"
Sarah Newman45a64df2022-04-11 19:33:46 -07003#include "aos/logging/dynamic_logging.h"
Austin Schuh60e77942022-05-16 17:48:24 -07004#include "aos/network/message_bridge_client_lib.h"
Adam Snaider96a0f4b2023-05-18 20:41:19 -07005#include "aos/network/sctp_lib.h"
Austin Schuhb0e439d2023-05-15 10:55:40 -07006#include "aos/sha256.h"
Adam Snaider96a0f4b2023-05-18 20:41:19 -07007#include "aos/util/file.h"
Austin Schuhe84c3ed2019-12-14 15:29:48 -08008
Austin Schuhc5fa6d92022-02-25 14:36:28 -08009DEFINE_string(config, "aos_config.json", "Path to the config.");
Austin Schuha922ad02021-10-23 23:25:50 -070010DEFINE_int32(rt_priority, -1, "If > 0, run as this RT priority");
Adam Snaiderdd847fd2023-06-26 16:34:15 -070011DEFINE_bool(
12 wants_sctp_authentication, false,
13 "When set, try to use SCTP authentication if provided by the kernel");
Austin Schuhe84c3ed2019-12-14 15:29:48 -080014
Stephan Pleinesf63bde82024-01-13 15:59:33 -080015namespace aos::message_bridge {
Austin Schuhe84c3ed2019-12-14 15:29:48 -080016
Adam Snaider96a0f4b2023-05-18 20:41:19 -070017using ::aos::util::ReadFileToVecOrDie;
18
Austin Schuhe84c3ed2019-12-14 15:29:48 -080019int Main() {
20 aos::FlatbufferDetachedBuffer<aos::Configuration> config =
21 aos::configuration::ReadConfig(FLAGS_config);
22
23 aos::ShmEventLoop event_loop(&config.message());
Austin Schuha922ad02021-10-23 23:25:50 -070024 if (FLAGS_rt_priority > 0) {
25 event_loop.SetRuntimeRealtimePriority(FLAGS_rt_priority);
26 }
Austin Schuhe84c3ed2019-12-14 15:29:48 -080027
Adam Snaiderdd847fd2023-06-26 16:34:15 -070028 MessageBridgeClient app(&event_loop, Sha256(config.span()),
29 FLAGS_wants_sctp_authentication
30 ? SctpAuthMethod::kAuth
31 : SctpAuthMethod::kNoAuth);
Austin Schuhe84c3ed2019-12-14 15:29:48 -080032
Sarah Newman45a64df2022-04-11 19:33:46 -070033 logging::DynamicLogging dynamic_logging(&event_loop);
Austin Schuhe84c3ed2019-12-14 15:29:48 -080034 // TODO(austin): Save messages into a vector to be logged. One file per
35 // channel? Need to sort out ordering.
36 //
37 // TODO(austin): Low priority, "reliable" logging channel.
38
39 event_loop.Run();
40
41 return EXIT_SUCCESS;
42}
43
Stephan Pleinesf63bde82024-01-13 15:59:33 -080044} // namespace aos::message_bridge
Austin Schuhe84c3ed2019-12-14 15:29:48 -080045
46int main(int argc, char **argv) {
47 aos::InitGoogle(&argc, &argv);
48
49 return aos::message_bridge::Main();
50}