From 42963ecee07698b5c3239e09ccd5b26a61f22845 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Tue, 14 Aug 2018 21:13:53 +0200 Subject: [PATCH] daemon: make TCP default if not HAVE_UNIX_SOCKETS --- platform/daemon/src/btstack.c | 12 ++++++++++++ platform/daemon/src/daemon.c | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/platform/daemon/src/btstack.c b/platform/daemon/src/btstack.c index e27b1fa6a..9354c78e7 100644 --- a/platform/daemon/src/btstack.c +++ b/platform/daemon/src/btstack.c @@ -87,6 +87,16 @@ static int socket_packet_handler(connection_t *connection, uint16_t packet_type, // init BTstack library int bt_open(void){ +#ifndef HAVE_UNIX_SOCKETS + // without unix sockets, default to TCP + if (!daemon_tcp_address){ + daemon_tcp_address = "127.0.0.1"; + } + if (!daemon_tcp_port){ + daemon_tcp_port = BTSTACK_PORT; + } +#endif + socket_connection_init(); socket_connection_register_packet_callback(socket_packet_handler); @@ -95,7 +105,9 @@ int bt_open(void){ if (daemon_tcp_address) { btstack_connection = socket_connection_open_tcp(daemon_tcp_address,daemon_tcp_port); } else { +#ifdef HAVE_UNIX_SOCKETS btstack_connection = socket_connection_open_unix(); +#endif } if (!btstack_connection) return -1; diff --git a/platform/daemon/src/daemon.c b/platform/daemon/src/daemon.c index 442f56b89..dac0b630d 100644 --- a/platform/daemon/src/daemon.c +++ b/platform/daemon/src/daemon.c @@ -1955,6 +1955,11 @@ int main (int argc, char * const * argv){ } } +#ifndef HAVE_UNIX_SOCKETS + // TCP is default if there are no unix sockets + tcp_flag = 1; +#endif + if (tcp_flag){ printf("BTstack Daemon started on port %u\n", BTSTACK_PORT); } else { @@ -2096,7 +2101,9 @@ int main (int argc, char * const * argv){ if (tcp_flag) { socket_connection_create_tcp(BTSTACK_PORT); } else { +#ifdef HAVE_UNIX_SOCKETS socket_connection_create_unix(BTSTACK_UNIX); +#endif } #endif socket_connection_register_packet_callback(&daemon_client_handler);