From c1f4fa97376ea30f68125fed160d3df78a81f1f7 Mon Sep 17 00:00:00 2001 From: "matthias.ringwald" Date: Thu, 20 Aug 2009 22:54:29 +0000 Subject: [PATCH] work on launchd plist --- TODO.txt | 9 +++++---- example/test.c | 6 +++++- resources/ch.ringwald.BTstack.plist | 4 ++++ src/daemon.c | 8 ++++---- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/TODO.txt b/TODO.txt index 5203ef692..d79d84deb 100644 --- a/TODO.txt +++ b/TODO.txt @@ -4,20 +4,21 @@ Last milestone reached: Restart client app without restarting BTdaemon possible NEXT: - autostart by launchd: ch.ringwald.BTstack.plist - - get to work + - get it to work on iPhone + - launchd check in neccessary? + - set path for stdout - better deal with Apple stack - - detect that it is running + - detect if it is running - figure out how to shut it down - user interface - iPhone status icon support - set BTstack SpringBoard icon from background deamon - possible without MobileSubstrate - MobileSubstrate used by veency -- extend hci_logger to write to /var/hci_dump.txt as text +- Detect and handle iPhone sleep mode - Cocoa User Interface Components - Alert and shutdown of Apple's stack - Inquiry - - Detect iPhone sleep mode === BTdaemon can run always - implement rest of L2CAP state machine - incoming connections diff --git a/example/test.c b/example/test.c index 8a4a4997a..356bec8a0 100644 --- a/example/test.c +++ b/example/test.c @@ -91,7 +91,11 @@ void event_handler(uint8_t *packet, uint16_t size){ } int main (int argc, const char * argv[]){ - bt_open(); + int err = bt_open(); + if (err) { + printf("Failed to open connection to BTdaemon\n"); + return err; + } bt_register_event_packet_handler(event_handler); bt_register_data_packet_handler(data_handler); bt_send_cmd(&btstack_set_power_mode, HCI_POWER_ON ); diff --git a/resources/ch.ringwald.BTstack.plist b/resources/ch.ringwald.BTstack.plist index c1b8fd39f..83b01e466 100644 --- a/resources/ch.ringwald.BTstack.plist +++ b/resources/ch.ringwald.BTstack.plist @@ -9,10 +9,14 @@ Program /usr/bin/BTdaemon ServiceIPC + + Debug ProgramArguments StandardErrorPath + /var/log/BTstack.err + StandardOutPath /var/log/BTstack.log Sockets diff --git a/src/daemon.c b/src/daemon.c index 75a6e6726..bdc8890ea 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -196,11 +196,11 @@ int main (int argc, const char * argv[]){ timeout.process = daemon_no_connections_timeout; // @TODO: make choice of socket server configurable (TCP and/or Unix Domain Socket) - // @TODO: make port and/or socket configurable per config.h // create server // socket_connection_create_tcp(BTSTACK_PORT); socket_connection_create_unix(BTSTACK_UNIX); + socket_connection_register_packet_callback(daemon_client_handler); // handle CTRL-c @@ -209,9 +209,9 @@ int main (int argc, const char * argv[]){ signal(SIGTERM, daemon_sigint_handler); // make stderr unbuffered setbuf(stderr, NULL); - - bluetooth_status_handler(BLUETOOTH_ACTIVE); - + setbuf(stdout, NULL); + printf("BTdaemon started - stdout\n"); + fprintf(stderr,"BTdaemon started - stderr\n"); // go! run_loop_execute();