The open source OpenXR runtime
1// Copyright 2019-2020, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Lighthouse base station control tools.
6 * @author Jakob Bornecrantz <jakob@collabora.com>
7 */
8
9#include "xrt/xrt_config_have.h"
10
11#include "os/os_ble.h"
12
13#include "cli_common.h"
14
15#include <string.h>
16#include <stdio.h>
17
18
19#define P(...) fprintf(stderr, __VA_ARGS__)
20
21int
22cli_cmd_lighthouse(int argc, const char **argv)
23{
24#ifdef XRT_HAVE_DBUS
25 if (argc <= 2) {
26 fprintf(stderr, "Command needs [on|off] argument!\n");
27 return -1;
28 }
29
30 uint8_t value = 0;
31 const char *str = NULL;
32 if (strcmp(argv[2], "on") == 0) {
33 value = 1;
34 str = "on";
35 } else if (strcmp(argv[2], "off") == 0) {
36 value = 0;
37 str = "off";
38 } else {
39 P("Command needs [on|off] argument != '%s'!\n", argv[2]);
40 return -1;
41 }
42
43 P("Turning lighthouse %s!\n", str);
44 os_ble_broadcast_write_value("00001523-1212-efde-1523-785feabcd124", "00001525-1212-efde-1523-785feabcd124",
45 value);
46 return 0;
47#else
48 P("Command needs bluetooth support!\n");
49 return -1;
50#endif
51}