mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-01 09:08:06 +00:00
add sleep mode handling to BTstackManager
This commit is contained in:
parent
381fbed89a
commit
8fd877559d
@ -57,6 +57,7 @@ typedef enum {
|
||||
kW4Activated,
|
||||
kActivated,
|
||||
kW4Deactivated,
|
||||
kSleeping,
|
||||
#if 0
|
||||
kW4DisoveryStopped,
|
||||
kW4AuthenticationEnableCommand
|
||||
@ -169,6 +170,10 @@ typedef enum {
|
||||
-(void) btstackManager:(BTstackManager*)manager activationFailed:(BTstackError)error;
|
||||
-(void) deactivatedBTstackManager:(BTstackManager*) manager;
|
||||
|
||||
// Power management events
|
||||
-(void) sleepModeEnterBTstackManager:(BTstackManager*) manager;
|
||||
-(void) sleepModeExtitBTstackManager:(BTstackManager*) manager;
|
||||
|
||||
// Discovery events: general
|
||||
-(void) btstackManager:(BTstackManager*)manager deviceInfo:(BTDevice*)device;
|
||||
-(void) btstackManager:(BTstackManager*)manager discoveryQueryRemoteName:(int)deviceIndex;
|
||||
|
@ -145,6 +145,20 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
}
|
||||
}
|
||||
}
|
||||
-(void) sendSleepEnter {
|
||||
for (NSObject<BTstackManagerListener>* listener in listeners) {
|
||||
if ([listener respondsToSelector:@selector(sleepModeEnterBTstackManager:)]){
|
||||
[listener sleepModeEnterBTstackManager:self];
|
||||
}
|
||||
}
|
||||
}
|
||||
-(void) sendSleepExit {
|
||||
for (NSObject<BTstackManagerListener>* listener in listeners) {
|
||||
if ([listener respondsToSelector:@selector(sleepModeExtitBTstackManager:)]){
|
||||
[listener sleepModeExtitBTstackManager:self];
|
||||
}
|
||||
}
|
||||
}
|
||||
-(void) sendDiscoveryStoppedEvent {
|
||||
for (NSObject<BTstackManagerListener>* listener in listeners) {
|
||||
if ([listener respondsToSelector:@selector(discoveryStoppedBTstackManager:)]){
|
||||
@ -320,11 +334,23 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
break;
|
||||
|
||||
case kW4Deactivated:
|
||||
if (packet[0] == BTSTACK_EVENT_STATE){
|
||||
if (packet[2] == HCI_STATE_OFF){
|
||||
state = kDeactivated;
|
||||
[self sendDeactivated];
|
||||
}
|
||||
if (packet[0] != BTSTACK_EVENT_STATE && packet[2] == HCI_STATE_OFF){
|
||||
state = kDeactivated;
|
||||
[self sendDeactivated];
|
||||
}
|
||||
break;
|
||||
|
||||
case kActivated:
|
||||
if (packet[0] != BTSTACK_EVENT_STATE && packet[2] == HCI_STATE_FALLING_ASLEEP){
|
||||
state = kSleeping;
|
||||
[self sendSleepEnter];
|
||||
}
|
||||
break;
|
||||
|
||||
case kSleeping:
|
||||
if (packet[0] != BTSTACK_EVENT_STATE && packet[2] == HCI_STATE_WORKING){
|
||||
state = kActivated;
|
||||
[self sendSleepExit];
|
||||
}
|
||||
break;
|
||||
|
||||
@ -554,6 +580,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
case kW4SysBTDisabled:
|
||||
case kW4Activated:
|
||||
case kW4Deactivated:
|
||||
case kSleeping:
|
||||
if (packet_type != HCI_EVENT_PACKET) break;
|
||||
[self activationHandleEvent:packet withLen:size];
|
||||
break;
|
||||
@ -562,6 +589,9 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
case kActivated:
|
||||
if (packet_type != HCI_EVENT_PACKET) break;
|
||||
switch (packet[0]){
|
||||
case BTSTACK_EVENT_STATE:
|
||||
[self activationHandleEvent:packet withLen:size];
|
||||
break;
|
||||
case HCI_EVENT_LINK_KEY_REQUEST:
|
||||
[self handleLinkKeyRequestEvent:packet withLen:size];
|
||||
break;
|
||||
|
25
TODO.txt
25
TODO.txt
@ -17,12 +17,26 @@
|
||||
|
||||
NEXT:
|
||||
- check apps for sleep mode/reactivated compatibility - see what happens on ACTIVATED event
|
||||
- WiiMote example
|
||||
- BTstackManager
|
||||
- WiiMote example
|
||||
- Keyboard
|
||||
- Mouse
|
||||
- WeBe++
|
||||
|
||||
- BTstackManager & new remote_db
|
||||
- don't keep device info
|
||||
- don't hanle link keys
|
||||
|
||||
- create Retina status bar icons
|
||||
|
||||
- bugs:
|
||||
- verify: if (hic?) disconnect fails, l2cap channels are never discarded
|
||||
|
||||
- get rid of BTInquireViewController
|
||||
- update WiiMoteExample to use BTstackManager
|
||||
- Update/rewrite BTstack Keyboard
|
||||
- delete BTInquireViewController
|
||||
|
||||
- clean up components
|
||||
- consolidate iOS code in port_ios.m (bt_control_iphone.m, platform_iphone.m)
|
||||
- consolidate cocoa/corefoundation code in port_corefoundation.c (remote_device_db)
|
||||
@ -31,11 +45,6 @@ NEXT:
|
||||
- decide on configure flags
|
||||
- dynamic link BTdaemon against libBTstack.dylist
|
||||
|
||||
- decide what to do with the CocoaTouch code. Options:
|
||||
- do nothing (potential problem with multiple dylibs in same process)
|
||||
- add it to libBTstack.dylib
|
||||
- provide a libBTstackCocoaTouch.dylib (less memory usage)
|
||||
|
||||
- move RFCOMM code into BTdaemon
|
||||
|
||||
- HCI CMD packet is limited to 1024 bytes payload. SDP records could be larger than that. Options:
|
||||
@ -63,6 +72,10 @@ NEXT:
|
||||
|
||||
== Objective-C Interface ==
|
||||
- have a look at External Accessory interface by Apple - it's quite similar
|
||||
- decide what to do with the CocoaTouch code. Options:
|
||||
- do nothing (potential problem with multiple dylibs in same process)
|
||||
- add it to libBTstack.dylib
|
||||
- provide a libBTstackCocoaTouch.dylib (less memory usage)
|
||||
- move connection methods to BTdevice (get more object oriented)
|
||||
- initWithAddress:(bd_addr_t *)addr
|
||||
- setters private
|
||||
|
Loading…
Reference in New Issue
Block a user