diff --git a/TODO.txt b/TODO.txt index 10b883002..200d184d1 100644 --- a/TODO.txt +++ b/TODO.txt @@ -26,8 +26,8 @@ NEXT: - DONE: power down Bluetooth on sleep notifcation / turn on, if clients are connected - DONE: keep list of clients that requested Blueooth to be active - DONE: Bluetooth is on iff at least one client did request it. delay off by 10 seconds - - add enum POWER_EVENTS {POWER_WILL_SLEEP, POWER_WILL_WAKE_UP); - - add register_for_power_management_notifictations( void (*callback)(POWER_EVENTS event)); to bt_control.h + - DONE: add enum POWER_EVENTS {POWER_WILL_SLEEP, POWER_WILL_WAKE_UP); + - DONE: add register_for_power_management_notifictations( void (*callback)(POWER_EVENTS event)); to bt_control.h - move core foundation power event code to bt_control_iphone.m - add sleep() to bt_control.h (assumption: no off -> sleep transition) diff --git a/src/bt_control.h b/src/bt_control.h index 92fe62a35..180c638c5 100644 --- a/src/bt_control.h +++ b/src/bt_control.h @@ -42,9 +42,15 @@ #include +typedef enum { + POWER_WILL_SLEEP = 1, + POWER_WILL_WAKE_UP +} POWER_NOTIFICATION_t; + typedef struct { int (*on)(void *config); // <-- turn BT module on and configure int (*off)(void *config); // <-- turn BT module off + int (*sleep)(void *config); // <-- put BT module to sleep - only to be called after ON int (*valid)(void *config); // <-- test if hardware can be supported const char * (*name)(void *config); // <-- return hardware name @@ -53,4 +59,6 @@ typedef struct { */ uint8_t * (*next_command)(void *config); + void (*register_for_power_notifications)(void (*cb)(POWER_NOTIFICATION_t event)); + } bt_control_t; diff --git a/src/bt_control_iphone.m b/src/bt_control_iphone.m index 886d0d478..efc56719e 100644 --- a/src/bt_control_iphone.m +++ b/src/bt_control_iphone.m @@ -500,12 +500,17 @@ static int iphone_off (void *config){ return 0; } +static int iphone_sleep(void *config){ + return iphone_off(config); +} // single instance bt_control_t bt_control_iphone = { iphone_on, iphone_off, + iphone_sleep, iphone_valid, iphone_name, - NULL + NULL, // custom init sequence + NULL // register_for_power_notifications };