mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-19 16:21:06 +00:00
feedback by ashikase and rpetrich: _delegate (assign) @property, @optional methods, and correct super init
This commit is contained in:
parent
7ae7581b45
commit
160f793aff
@ -38,7 +38,8 @@
|
|||||||
@class BTDevice;
|
@class BTDevice;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Information on devices is stored in a system-wide plist and maintained by BTstackManager
|
* Information on devices is stored in a system-wide plist
|
||||||
|
* it is maintained by BTstackManager
|
||||||
* this includes the link keys
|
* this includes the link keys
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -48,15 +49,12 @@ typedef int BTstackError;
|
|||||||
@protocol BTstackManagerDelegate;
|
@protocol BTstackManagerDelegate;
|
||||||
|
|
||||||
@interface BTstackManager : NSObject {
|
@interface BTstackManager : NSObject {
|
||||||
id<BTstackManagerDelegate> delegate;
|
id<BTstackManagerDelegate> _delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
// shared instance
|
// shared instance
|
||||||
+(BTstackManager *) sharedInstance;
|
+(BTstackManager *) sharedInstance;
|
||||||
|
|
||||||
// BTstackManagerDelegate protocol implemented by application
|
|
||||||
-(void) setDelegate:(id<BTstackManagerDelegate>) delegate;
|
|
||||||
|
|
||||||
// Activation
|
// Activation
|
||||||
-(void) activate;
|
-(void) activate;
|
||||||
-(void) deactivate;
|
-(void) deactivate;
|
||||||
@ -77,11 +75,16 @@ typedef int BTstackError;
|
|||||||
-(void) sendRFCOMMPacketForChannelID:(uint16_t)connectionID;
|
-(void) sendRFCOMMPacketForChannelID:(uint16_t)connectionID;
|
||||||
|
|
||||||
// TODO add l2cap and rfcomm incoming commands
|
// TODO add l2cap and rfcomm incoming commands
|
||||||
|
|
||||||
|
@property (nonatomic, assign) id<BTstackManagerDelegate> delegate;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
@protocol BTstackManagerDelegate
|
@protocol BTstackManagerDelegate
|
||||||
|
|
||||||
|
// Everything is optional but you should implement all methods of a group
|
||||||
|
@optional
|
||||||
|
|
||||||
// Activation events
|
// Activation events
|
||||||
-(void) activated;
|
-(void) activated;
|
||||||
-(void) activationFailed:(BTstackError)error;
|
-(void) activationFailed:(BTstackError)error;
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
#import <btstack/btstack.h>
|
#import <btstack/btstack.h>
|
||||||
#import "../../RFCOMM/rfcomm.h"
|
#import "../../RFCOMM/rfcomm.h"
|
||||||
|
|
||||||
static BTstackManager * btstackManager = NULL;
|
static BTstackManager * btstackManager = nil;
|
||||||
|
|
||||||
@interface BTstackManager (privat)
|
@interface BTstackManager (privat)
|
||||||
- (void) handlePacketWithType:(uint8_t) packet_type
|
- (void) handlePacketWithType:(uint8_t) packet_type
|
||||||
@ -52,12 +52,18 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
|||||||
|
|
||||||
@implementation BTstackManager
|
@implementation BTstackManager
|
||||||
|
|
||||||
|
@synthesize delegate = _delegate;
|
||||||
|
|
||||||
-(BTstackManager *) init {
|
-(BTstackManager *) init {
|
||||||
|
self = [super init];
|
||||||
|
if (!self) return self;
|
||||||
|
|
||||||
// Cocoa compatible run loop
|
// Cocoa compatible run loop
|
||||||
run_loop_init(RUN_LOOP_COCOA);
|
run_loop_init(RUN_LOOP_COCOA);
|
||||||
|
|
||||||
// our packet handler
|
// our packet handler
|
||||||
bt_register_packet_handler(packet_handler);
|
bt_register_packet_handler(packet_handler);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,10 +74,6 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
|||||||
return btstackManager;
|
return btstackManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) setDelegate:(id<BTstackManagerDelegate>) newDelegate {
|
|
||||||
delegate = newDelegate;
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void) activate {
|
-(void) activate {
|
||||||
bt_open();
|
bt_open();
|
||||||
bt_send_cmd(&btstack_set_power_mode, HCI_POWER_ON );
|
bt_send_cmd(&btstack_set_power_mode, HCI_POWER_ON );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user