mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-20 18:40:31 +00:00
added handler to shutdown on CTRL-C
This commit is contained in:
parent
e7a9bb06bb
commit
623c593c7d
20
TODO.txt
20
TODO.txt
@ -5,21 +5,30 @@ Last milestone reached: Restart client app without restarting BTdaemon possible
|
||||
NEXT:
|
||||
- turn off Bluetooth on ctrl-c
|
||||
- extend hci_logger to write to /var/hci_dump.txt as text
|
||||
- client/server part using unix domain sockets (portable and fast)
|
||||
- iPhone status icon support
|
||||
- create BTstack icon. Flipped B in red, or blue on orange
|
||||
- bt_control_iphone.c -> bt_control_iphone.m // or objcSendMsg
|
||||
- call SpringBoard on/off BT
|
||||
- automatic start/stop of BTdaemon
|
||||
- start BTdaemon by client lib
|
||||
- e.g. use popen and wait for initial "I'm ready" message
|
||||
- autostart by launchd
|
||||
- stop BTdaemon after X minutes idle
|
||||
- iPhone status icon support
|
||||
- bt_control_iphone.c -> bt_control_iphone.m
|
||||
- call SpringBoard on/off BT
|
||||
- create BTstack icon. Flipped B in red
|
||||
- better deal with Apple stack
|
||||
- detect that it is running
|
||||
- figure out how to shut it down
|
||||
- user interface
|
||||
- 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
|
||||
- list of supported PSM
|
||||
- commands and events
|
||||
=== Incoming L2CAP supported
|
||||
- client/server part using unix domain sockets (portable and fast)
|
||||
- configuration: /etc/btstack
|
||||
- single Bluetooth module supported
|
||||
- transport type: H4, H5, USB
|
||||
@ -50,3 +59,4 @@ NEXT:
|
||||
- auto-generate code for sending commands from structured text input file
|
||||
- devise concept for access to event data
|
||||
- auto-generate event struct getter? STRUCTURE_get_FIELD
|
||||
- Bluetooth low-power modes useful
|
||||
|
15
src/daemon.c
15
src/daemon.c
@ -9,10 +9,11 @@
|
||||
|
||||
#include "../config.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <strings.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "hci.h"
|
||||
#include "hci_dump.h"
|
||||
@ -116,6 +117,13 @@ static int daemon_client_handler(connection_t *connection, uint16_t packet_type,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void daemon_sigint_handler(int param){
|
||||
printf(" <= SIGINT received, shutting down..\n");
|
||||
hci_power_control( HCI_POWER_OFF);
|
||||
printf("Good bye, see you.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main (int argc, const char * argv[]){
|
||||
|
||||
bt_control_t * control = NULL;
|
||||
@ -139,7 +147,7 @@ int main (int argc, const char * argv[]){
|
||||
|
||||
// use logger: format HCI_DUMP_PACKETLOGGER, HCI_DUMP_BLUEZ or HCI_DUMP_STDOUT
|
||||
// hci_dump_open("/tmp/hci_dump.pklg", HCI_DUMP_PACKETLOGGER);
|
||||
hci_dump_open(NULL, HCI_DUMP_STDOUT);
|
||||
// hci_dump_open(NULL, HCI_DUMP_STDOUT);
|
||||
|
||||
// init HCI
|
||||
hci_init(transport, &config, control);
|
||||
@ -155,6 +163,9 @@ int main (int argc, const char * argv[]){
|
||||
// create server
|
||||
socket_connection_create_tcp(BTSTACK_PORT);
|
||||
socket_connection_register_packet_callback(daemon_client_handler);
|
||||
|
||||
// handle CTRL-c
|
||||
signal(SIGINT, daemon_sigint_handler);
|
||||
|
||||
// go!
|
||||
run_loop_execute();
|
||||
|
Loading…
x
Reference in New Issue
Block a user