mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-21 21:41:13 +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:
|
NEXT:
|
||||||
- turn off Bluetooth on ctrl-c
|
- turn off Bluetooth on ctrl-c
|
||||||
- extend hci_logger to write to /var/hci_dump.txt as text
|
- 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
|
- automatic start/stop of BTdaemon
|
||||||
- start BTdaemon by client lib
|
- start BTdaemon by client lib
|
||||||
- e.g. use popen and wait for initial "I'm ready" message
|
- e.g. use popen and wait for initial "I'm ready" message
|
||||||
|
- autostart by launchd
|
||||||
- stop BTdaemon after X minutes idle
|
- stop BTdaemon after X minutes idle
|
||||||
- iPhone status icon support
|
- better deal with Apple stack
|
||||||
- bt_control_iphone.c -> bt_control_iphone.m
|
- detect that it is running
|
||||||
- call SpringBoard on/off BT
|
- figure out how to shut it down
|
||||||
- create BTstack icon. Flipped B in red
|
- user interface
|
||||||
|
- Cocoa User Interface Components
|
||||||
|
- Alert and shutdown of Apple's stack
|
||||||
|
- Inquiry
|
||||||
|
- Detect iPhone sleep mode
|
||||||
=== BTdaemon can run always
|
=== BTdaemon can run always
|
||||||
- implement rest of L2CAP state machine
|
- implement rest of L2CAP state machine
|
||||||
- incoming connections
|
- incoming connections
|
||||||
- list of supported PSM
|
- list of supported PSM
|
||||||
- commands and events
|
- commands and events
|
||||||
=== Incoming L2CAP supported
|
=== Incoming L2CAP supported
|
||||||
- client/server part using unix domain sockets (portable and fast)
|
|
||||||
- configuration: /etc/btstack
|
- configuration: /etc/btstack
|
||||||
- single Bluetooth module supported
|
- single Bluetooth module supported
|
||||||
- transport type: H4, H5, USB
|
- transport type: H4, H5, USB
|
||||||
@ -50,3 +59,4 @@ NEXT:
|
|||||||
- auto-generate code for sending commands from structured text input file
|
- auto-generate code for sending commands from structured text input file
|
||||||
- devise concept for access to event data
|
- devise concept for access to event data
|
||||||
- auto-generate event struct getter? STRUCTURE_get_FIELD
|
- 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 "../config.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "hci.h"
|
#include "hci.h"
|
||||||
#include "hci_dump.h"
|
#include "hci_dump.h"
|
||||||
@ -116,6 +117,13 @@ static int daemon_client_handler(connection_t *connection, uint16_t packet_type,
|
|||||||
return 0;
|
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[]){
|
int main (int argc, const char * argv[]){
|
||||||
|
|
||||||
bt_control_t * control = NULL;
|
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
|
// 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("/tmp/hci_dump.pklg", HCI_DUMP_PACKETLOGGER);
|
||||||
hci_dump_open(NULL, HCI_DUMP_STDOUT);
|
// hci_dump_open(NULL, HCI_DUMP_STDOUT);
|
||||||
|
|
||||||
// init HCI
|
// init HCI
|
||||||
hci_init(transport, &config, control);
|
hci_init(transport, &config, control);
|
||||||
@ -155,6 +163,9 @@ int main (int argc, const char * argv[]){
|
|||||||
// create server
|
// create server
|
||||||
socket_connection_create_tcp(BTSTACK_PORT);
|
socket_connection_create_tcp(BTSTACK_PORT);
|
||||||
socket_connection_register_packet_callback(daemon_client_handler);
|
socket_connection_register_packet_callback(daemon_client_handler);
|
||||||
|
|
||||||
|
// handle CTRL-c
|
||||||
|
signal(SIGINT, daemon_sigint_handler);
|
||||||
|
|
||||||
// go!
|
// go!
|
||||||
run_loop_execute();
|
run_loop_execute();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user