blob: 26092bceca7aedbbc9c258f3fbcbb26b8fd437e4 [file] [log] [blame]
James Kuszmaul0de4feb2022-04-15 12:16:59 -07001#include "aos/events/shm_event_loop.h"
2#include "aos/init.h"
3#include "aos/util/foxglove_websocket_lib.h"
4#include "gflags/gflags.h"
5
6DEFINE_string(config, "/app/aos_config.json", "Path to the config.");
7DEFINE_uint32(port, 8765, "Port to use for foxglove websocket server.");
8
9int main(int argc, char *argv[]) {
10 gflags::SetUsageMessage(
11 "Runs a websocket server that a foxglove instance can connect to in "
12 "order to view live data on a device.\n\n"
13 "Typical Usage: foxglove_websocket [--port 8765]\n"
14 "If the default port is not exposed directly, you can port-forward with "
15 "SSH by doing\n"
16 "$ ssh -L 8765:localhost:8765 ssh_target\n\n"
17 "When accessing this in foxglove:\n"
18 "1) Open a data source (this window may be open by default).\n"
19 "2) Select \"Open Connection\"\n"
20 "3) Select \"Foxglove WebSocket\" (do NOT select the rosbridge option)\n"
21 "4) Fill out the URL for the machine. If port forwarding, the default\n"
22 " ws://localhost:8765 should work.\n\n"
23 "Note that this does not start up a foxglove instance itself. You must "
24 "either have one locally on your laptop, or go to "
25 "https://studio.foxglove.dev, or use another application to serve the "
26 "foxglove HTML pages.\n"
27 "If you want to use the studio.foxglove.dev page to view data (which "
28 "won't send any of your data to foxglove.dev--it's just needed to load "
29 "the HTML files), you can also go directly to:\n"
30 "https://studio.foxglove.dev/?ds=foxglove-websocket&ds.url=ws://"
31 "localhost:8765\n"
32 "where localhost:8765 must be updated if you aren't port-forwarding "
33 "and/or are using a different port number. Similarly, if you are serving "
34 "the static foxglove files locally, you can update the "
35 "studio.foxglove.dev to point at your local webserver.\n");
36 aos::InitGoogle(&argc, &argv);
37
38 aos::FlatbufferDetachedBuffer<aos::Configuration> config =
39 aos::configuration::ReadConfig(FLAGS_config);
40
41 aos::ShmEventLoop event_loop(&config.message());
42
43 aos::FoxgloveWebsocketServer server(&event_loop, FLAGS_port);
44
45 event_loop.Run();
46}