2014年2月20日 星期四

bluetooth ble開發經驗

1.Scan到的peripheral一定要先把它指向一個strong CBPeripheral Property

2.這個strong Property不能去new它,不然就會出現用zombie也找不到的error

3.iOS跟android都不一定會收到所有的廣播,例如固定device每4秒發一次廣播,iOS實際收到的頻率可能是4,4,16,4,8,12,4,4,4,68,4,4,用lightBlue app看也是如此。

4.
-(id)init {
self = [super init];
if ( self )
{
//創一個thread專門給CentralManager使用
_centralQueue = dispatch_queue_create("forCentralManagerOnly", DISPATCH_QUEUE_SERIAL);
//It works without Warning message.
_centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:_centralQueue];

//用nil的話,預設是給它main queue
//_centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];

_receivedData = [[NSMutableData alloc] init];
//self.activePeripheral = [CBPeripheral new];
self.peripherals = [NSMutableArray new];

}

return self;

}

沒有留言:

張貼留言