verision

coolnameismy edited this page May 5, 2016 · 4 revisions

0.7.0

  • setBlockOnReadValueForDescriptors 委托中的一个参数命名错误,把参数名 CBDescriptor *descriptorNSError 改为 CBDescriptor *descriptor
  • 一些方法细节修改,增加代码的兼容性和健壮性
  • 添加一个新的方法enjoy() ,相当于链式方法中的 connectToPeripherals().discoverServices().discoverCharacteristics().readValueForCharacteristic().discoverDescriptorsForCharacteristic().readValueForDescriptors().begin(); 简写,这个方法是一个语法糖,可以减少代码量。
  • 完善测试用例
  • 提取Babybluetooth中一些默认行为的常量,统一放在BabyDefine.h文件中
  • 修复findConnectPeripheral中的一个bug fixed #35
  • 添加一个开关,控制Babybluetooth中打印的日志是否开启 ,使用方式可以通过修改源码 BabyDefine.h #define BABY_IS_SHOW_LOG 1 0为不打印,1为打印日志
  • 修复一个当discoveryPeripheral block未设置时会导致discoveryPeripheralFilter不起作用的bug"
  • 添加蓝牙中心模式各种事件的委托,使用notification方式做广播,开发者现在不但可以使用block实现委托,也可以使用notification实现各种事件的委托监听,从而得到更为灵活的开发方式,通知类型:
//centralManager status did change notification
#define BabyNotificationAtCentralManagerDidUpdateState @"BabyNotificationAtCentralManagerDidUpdateState"
//did discover peripheral notification
#define BabyNotificationAtDidDiscoverPeripheral @"BabyNotificationAtDidDiscoverPeripheral"
//did connection peripheral notification
#define BabyNotificationAtDidConnectPeripheral @"BabyNotificationAtDidConnectPeripheral"
//did filed connect peripheral notification
#define BabyNotificationAtDidFailToConnectPeripheral @"BabyNotificationAtDidFailToConnectPeripheral"
//did disconnect peripheral notification
#define BabyNotificationAtDidDisconnectPeripheral @"BabyNotificationAtDidDisconnectPeripheral"
//did discover service notification
#define BabyNotificationAtDidDiscoverServices @"BabyNotificationAtDidDiscoverServices"
//did discover characteristics notification
#define BabyNotificationAtDidDiscoverCharacteristicsForService @"BabyNotificationAtDidDiscoverCharacteristicsForService"
//did read or notify characteristic when received value  notification
#define BabyNotificationAtDidUpdateValueForCharacteristic @"BabyNotificationAtDidUpdateValueForCharacteristic"
//did write characteristic and response value notification
#define BabyNotificationAtDidWriteValueForCharacteristic @"BabyNotificationAtDidWriteValueForCharacteristic"
//did change characteristis notify status notification
#define BabyNotificationAtDidUpdateNotificationStateForCharacteristic @"BabyNotificationAtDidUpdateNotificationStateForCharacteristic"
//did read rssi and receiced value notification
#define BabyNotificationAtDidReadRSSI @"BabyNotificationAtDidReadRSSI"

//蓝牙扩展通知
// did centralManager enable notification
#define BabyNotificationAtCentralManagerEnable @"BabyNotificationAtCentralManagerEnable"
  • 添加了一个方法:根据外设UUID对应的string获取已配对的外设
/**
 根据外设UUID对应的string获取已配对的外设
 
 通过方法获取外设后可以直接连接外设,跳过扫描过程
 */
- (CBPeripheral *)retrievePeripheralWithUUIDString:(NSString *)UUIDString;

一个工具方法,用来根据UUIDString获取外设,使用示例:

//快速获取外设
CBPeripheral *p = [baby retrievePeripheralWithUUIDString:@"B19A6ED7-29D5-67EF-0207-6F5AE8BC337B"];
//直接根据外设连接
baby.having(p).connectToPeripherals().begin();

另外,如果不适用最新的api,也可以使用下面的方式达到同样的效果。

  NSUUID *uuid = [[NSUUID alloc]initWithUUIDString:@"B19A6ED7-29D5-67EF-0207-6F5AE8BC337B"];
   CBPeripheral *p = [self.baby.centralManager retrievePeripheralsWithIdentifiers:@[uuid]][0];
baby.having(p).connectToPeripherals().begin();

0.6.0

  • optimize for codeing Style
  • add default for peripheral name in peripheral model
  • modify a wrong word : setFilterOnConnetToPeripherals to setFilterOnConnectToPeripherals
  • add version for baby in BabyBluetooth.h file
  • every Babybluetooth add a brift for role
  • add unit test
  • new method for reconnect peripheral
/**
 添加断开自动重连的外设
 */
- (void)AutoReconnect:(CBPeripheral *)peripheral;

/**
 删除断开自动重连的外设
 */
- (void)AutoReconnectCancel:(CBPeripheral *)peripheral;
  • new parameter of rssi & advertisementData for filter
//v0.5.0
/**
设置查找Peripherals的规则
|  filter of discover peripherals 
*/
- (void)setFilterOnDiscoverPeripherals:(BOOL (^)(NSString *peripheralName))filter;
/**
设置连接Peripherals的规则
|  setting filter of connect to peripherals  peripherals 
*/
- (void)setFilterOnConnectToPeripherals:(BOOL (^)(NSString *peripheralName))filter;
/**
设置查找Peripherals的规则
|  filter of discover peripherals 
*/
- (void)setFilterOnDiscoverPeripheralsAtChannel:(NSString *)channel
                                      filter:(BOOL (^)(NSString *peripheralName))filter;
/**
设置连接Peripherals的规则
|  setting filter of connect to peripherals  peripherals 
*/
- (void)setFilterOnConnectToPeripheralsAtChannel:(NSString *)channel
                                     filter:(BOOL (^)(NSString *peripheralName))filter;


//0.6.0
/**
设置查找Peripherals的规则
|  filter of discover peripherals 
*/
- (void)setFilterOnDiscoverPeripherals:(BOOL (^)(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI))filter;
/**
设置连接Peripherals的规则
|  setting filter of connect to peripherals  peripherals 
*/
- (void)setFilterOnConnectToPeripherals:(BOOL (^)(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI))filter;
/**
设置查找Peripherals的规则
|  filter of discover peripherals 
*/
- (void)setFilterOnDiscoverPeripheralsAtChannel:(NSString *)channel
                                      filter:(BOOL (^)(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI))filter;
/**
设置连接Peripherals的规则
|  setting filter of connect to peripherals  peripherals 
*/
- (void)setFilterOnConnectToPeripheralsAtChannel:(NSString *)channel
                                     filter:(BOOL (^)(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI))filter;

0.5.0

  • add note for babybluetooth.h
  • add ability for peripheral model
    //配置第一个服务s1
    CBMutableService *s1 = makeCBService(@"FFF0");
    //配置s1的3个characteristic
    makeCharacteristicToService(s1, @"FFF1", @"r", @"hello1");//
    makeCharacteristicToService(s1, @"FFF2", @"w", @"hello2");//
    makeCharacteristicToService(s1, genUUID(), @"rw", @"hello3");//读写,自动生成uuid
    makeCharacteristicToService(s1, @"FFF4", nil, @"hello4");//默认读写字段
    makeCharacteristicToService(s1, @"FFF5", @"n", @"hello5");//notify字段
    //配置第一个服务s2
    CBMutableService *s2 = makeCBService(@"FFE0");
    makeStaticCharacteristicToService(s2, genUUID(), @"hello6", [@"a" dataUsingEncoding:NSUTF8StringEncoding]);//一个含初值的字段,该字段权限只能是只读
    //实例化baby
    baby = [BabyBluetooth shareBabyBluetooth];
    //配置委托
    [self babyDelegate];
    //添加服务和启动外设
    baby.bePeripheral().addServices(@[s1,s2]).startAdvertising();
  • new block for support peripheralManager
/**
 PeripheralManager did update state block
 */
-(void)peripheralModelBlockOnPeripheralManagerDidUpdateState:(void(^)(CBPeripheralManager *peripheral))block;
/**
 PeripheralManager did add service block
 */
-(void)peripheralModelBlockOnDidAddService:(void(^)(CBPeripheralManager *peripheral,CBService *service,NSError *error))block;
/**
 PeripheralManager did start advertising block
 */
-(void)peripheralModelBlockOnDidStartAdvertising:(void(^)(CBPeripheralManager *peripheral,NSError *error))block;
/**
 peripheralManager did receive read request block
 */
-(void)peripheralModelBlockOnDidReceiveReadRequest:(void(^)(CBPeripheralManager *peripheral,CBATTRequest *request))block;
/**
 peripheralManager did receive write request block
 */
-(void)peripheralModelBlockOnDidReceiveWriteRequests:(void(^)(CBPeripheralManager *peripheral,NSArray *requests))block;
/**
 peripheralManager did subscribe to characteristic block
 */
-(void)peripheralModelBlockOnDidSubscribeToCharacteristic:(void(^)(CBPeripheralManager *peripheral,CBCentral *central,CBCharacteristic *characteristic))block;
/**
peripheralManager did subscribe to characteristic block
*/
-(void)peripheralModelBlockOnDidUnSubscribeToCharacteristic:(void(^)(CBPeripheralManager *peripheral,CBCentral *central,CBCharacteristic *characteristic))block;
  • add new demo BabyBluetoothExamples/BluetoothStubOnIOS for show babybluetooth peripheral model

  • add new method for generate uuid

genUUID()

  • channge perivate var name ,from babysiter to babyCentralManager

0.4.0

  • add new demo which is a peripheral stub,and can has discover, read ,write ,notiy 's characteristic
  • support for cocoapods
  • add method for get rssi
  • modify paramter in delegate when peripheral disconnected
//方法从 方法调用后的立刻回调 改为-》 方法执行后并且全部设备断开后的回调
-(void)setBlockOnCancelAllPeripheralsConnectionBlock:(void(^)(CBCentralManager *centralManager))block;

//删除了````-(void)cancelPeripheralConnection:(CBPeripheral *)peripheral;````方法调用后的委托
-(void)setBlockOnCancelPeripheralConnectionBlock:(void(^)(CBCentralManager *centralManager,CBPeripheral *peripheral))block;
-(void)setBlockOnCancelPeripheralConnectionBlockAtChannel:(NSString *)channel
                                                         block:(void(^)(CBCentralManager *centralManager,CBPeripheral *peripheral))block;
//若想知道设备是否断开可以设置
/*
//断开Peripherals的连接的block
-(void)setBlockOnDisconnect:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error))block;
//或
//断开Peripherals的连接的block
-(void)setBlockOnDisconnectAtChannel:(NSString *)channel
                               block:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error))block;
*/
  • new method of get on connecting peripherals at centralManager
//获取当前连接的peripherals
-(NSArray *)findConnectedPeripherals;
//获取当前连接的peripheral
-(CBPeripheral *)findConnectedPeripheral:(NSString *)peripheralName;
//获取当前corebluetooth的centralManager对象
-(CBCentralManager *)centralManager;
  • 14 new delegate added in babybluetooth
//写Characteristic成功后的block
-(void)setBlockOnDidWriteValueForCharacteristic:(void (^)(CBCharacteristic *characteristic,NSError *error))block;
//写descriptor成功后的block
-(void)setBlockOnDidWriteValueForDescriptor:(void (^)(CBDescriptor *descriptor,NSError *error))block;
//characteristic订阅状态改变的block
-(void)setBlockOnDidUpdateNotificationStateForCharacteristic:(void (^)(CBCharacteristic *characteristic,NSError *error))block;
//读取RSSI的委托
-(void)setBlockOnDidReadRSSI:(void (^)(NSNumber *RSSI,NSError *error))block;
//discoverIncludedServices的回调,暂时在babybluetooth中无作用
-(void)setBlockOnDidDiscoverIncludedServicesForService:(void (^)(CBService *service,NSError *error))block;
//外设更新名字后的block
-(void)setBlockOnDidUpdateName:(void (^)(CBPeripheral *peripheral))block;
//外设更新服务后的block
-(void)setBlockOnDidModifyServices:(void (^)(CBPeripheral *peripheral,NSArray *invalidatedServices))block;

/*channel*/
//写Characteristic成功后的block
-(void)setBlockOnDidWriteValueForCharacteristicAtChannel:(NSString *)channel
                                                   block:(void (^)(CBCharacteristic *characteristic,NSError *error))block;
//写descriptor成功后的block
-(void)setBlockOnDidWriteValueForDescriptorAtChannel:(NSString *)channel
                                               block:(void (^)(CBDescriptor *descriptor,NSError *error))block;
//characteristic订阅状态改变的block
-(void)setBlockOnDidUpdateNotificationStateForCharacteristicAtChannel:(NSString *)channel
                                                                block:(void (^)(CBCharacteristic *characteristic,NSError *error))block;
//读取RSSI的委托
-(void)setBlockOnDidReadRSSIAtChannel:(NSString *)channel
                                block:(void (^)(NSNumber *RSSI,NSError *error))block;
//discoverIncludedServices的回调,暂时在babybluetooth中无作用
-(void)setBlockOnDidDiscoverIncludedServicesForServiceAtChannel:(NSString *)channel
                                                          block:(void (^)(CBService *service,NSError *error))block;
//外设更新名字后的block
-(void)setBlockOnDidUpdateNameAtChannel:(NSString *)channel 
                                  block:(void (^)(CBPeripheral *peripheral))block;
//外设更新服务后的block
-(void)setBlockOnDidModifyServicesAtChannel:(NSString *)channel
                                      block:(void (^)(CBPeripheral *peripheral,NSArray *invalidatedServices))block;

v0.3

  • add a new helper class :babyRhythm which can helper user to monitor Operation
  • ten new block about cancel sacn and disconnect peripheral and
     
    //when Peripherals FailToConnect
    -(void)setBlockOnFailToConnect:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error))block;

    //when disconnected Peripherals
    -(void)setBlockOnDisconnect:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error))block;

    //when Peripherals FailToConnect
    -(void)setBlockOnFailToConnectAtChannel:(NSString *)channel
                                      block:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error))block;
    //when disconnected Peripherals
    -(void)setBlockOnDisconnectAtChannel:(NSString *)channel
                                   block:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error))block; 
    

    /#pragma mark -babybluetooth Special

    //after babyBluettooth cancelScan
    -(void)setBlockOnCancelScanBlock:(void(^)(CBCentralManager *centralManager))block;
    //after babyBluettooth cancelAllPeripheralsConnectionBlock
    -(void)setBlockOnCancelAllPeripheralsConnectionBlock:(void(^)(CBCentralManager *centralManager))block;
    //after babyBluettooth cancelPeripheralConnection
    -(void)setBlockOnCancelPeripheralConnectionBlock:(void(^)(CBCentralManager *centralManager,CBPeripheral *peripheral))block;
    
    //after babyBluettooth cancelScan方
    -(void)setBlockOnCancelScanBlockAtChannel:(NSString *)channel
                                             block:(void(^)(CBCentralManager *centralManager))block;
    //after babyBluettooth cancelAllPeripheralsConnectionBlock 
    -(void)setBlockOnCancelAllPeripheralsConnectionBlockAtChannel:(NSString *)channel
                                                                 block:(void(^)(CBCentralManager *centralManager))block;
    //after babyBluettooth cancelPeripheralConnection 
    -(void)setBlockOnCancelPeripheralConnectionBlockAtChannel:(NSString *)channel
                                                             block:(void(^)(CBCentralManager *centralManager,CBPeripheral *peripheral))block;
  • fix xcode7 waring
  • simplify readme,move some content to wiki
  • add background model support and introductions
  • add runtime options for sacn,connect,discover service ...
//set runtime option
-(void)setBabyOptionsWithScanForPeripheralsWithOptions:(NSDictionary *) scanForPeripheralsWithOptions
                          connectPeripheralWithOptions:(NSDictionary *) connectPeripheralWithOptions
                        scanForPeripheralsWithServices:(NSArray *)scanForPeripheralsWithServices
                                  discoverWithServices:(NSArray *)discoverWithServices
                           discoverWithCharacteristics:(NSArray *)discoverWithCharacteristics;

//set runtime option at channel
-(void)setBabyOptionsAtChannel:(NSString *)channel
 scanForPeripheralsWithOptions:(NSDictionary *) scanForPeripheralsWithOptions
  connectPeripheralWithOptions:(NSDictionary *) connectPeripheralWithOptions
scanForPeripheralsWithServices:(NSArray *)scanForPeripheralsWithServices
          discoverWithServices:(NSArray *)discoverWithServices
   discoverWithCharacteristics:(NSArray *)discoverWithCharacteristics;

exp:

    /*set babyOptions
        use in those function,if no option set nil
        - [centralManager scanForPeripheralsWithServices:scanForPeripheralsWithServices options:scanForPeripheralsWithOptions];
        - [centralManager connectPeripheral:peripheral options:connectPeripheralWithOptions];
        - [peripheral discoverServices:discoverWithServices];
        - [peripheral discoverCharacteristics:discoverWithCharacteristics forService:service];
        
        at channel function:
            [baby setBabyOptionsAtChannel:<#(NSString *)#> scanForPeripheralsWithOptions:<#(NSDictionary *)#> connectPeripheralWithOptions:<#(NSDictionary *)#> scanForPeripheralsWithServices:<#(NSArray *)#> discoverWithServices:<#(NSArray *)#> discoverWithCharacteristics:<#(NSArray *)#>]
     */
    
    //sacnfor options->CBCentralManagerScanOptionAllowDuplicatesKey:忽略同一个Peripheral端的多个发现事件被聚合成一个发现事件
    NSDictionary *scanForPeripheralsWithOptions = @{CBCentralManagerScanOptionAllowDuplicatesKey:@YES};
    /*connect options-> only works in non-background model
     CBConnectPeripheralOptionNotifyOnConnectionKey 
     CBConnectPeripheralOptionNotifyOnDisconnectionKey 
     CBConnectPeripheralOptionNotifyOnNotificationKey
    */
     NSDictionary *connectOptions = @{CBConnectPeripheralOptionNotifyOnConnectionKey:@YES,
     CBConnectPeripheralOptionNotifyOnDisconnectionKey:@YES,
     CBConnectPeripheralOptionNotifyOnNotificationKey:@YES};
    
    [baby setBabyOptionsAtChannel:channelOnPeropheralView scanForPeripheralsWithOptions:scanForPeripheralsWithOptions connectPeripheralWithOptions:connectOptions scanForPeripheralsWithServices:nil discoverWithServices:nil discoverWithCharacteristics:nil];
    

##v0.2

  • 1:add block for connectFaild and disconnectToPeripheral
  • 2:new begin() method can execute after init, not need to with status of PoweredOn
  • 3:rename group of set channel method from xxxOnChannel to xxxAtChannel
    //v0.1
    baby = [BabyBluetooth shareBabyBluetooth];
    //...setting delegate block of babyBluetooth
    //wait for status of PoweredOn
    [baby setBlockOnCentralManagerDidUpdateState:^(CBCentralManager *central) {
        if (central.state == CBCentralManagerStatePoweredOn) { 
            baby.scanForPeripherals().begin();
        }
    }];

    //v0.2
    baby = [BabyBluetooth shareBabyBluetooth];
    //...setting delegate block of babyBluetooth
    //not need to with status of PoweredOn
    baby.scanForPeripherals().begin();

update:2015/09/12

##v0.1 1:complete all BlayBluetooch base function 2:serial of method 3:channel for switch group of block

update:2015/09/06

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.