BabyBluetooth v0.7.0 Release Notes

Release Date: 2016-05-06 // over 5 years ago
    • 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();
    

Previous changes from v0.6.0

    • 修改了设置读取到Descriptors方法参数的bug
    • 修改了私有变量名 babyBluetooth.m中,私有变量babysiter改名为babyCentralManager
    • 根据代码规范优化了代码
    • 外设模式中,当未指定外设名称时,增加一个默认名称
    • 因为单词拼错导致修改了一个方法名: setFilterOnConnetToPeripherals 改成 setFilterOnConnectToPeripherals
    • 在BabyBluetooth.h 文件头几行添加了当前版本号
    • 在BabyBluetooth的.h文件中为每个类的一句话的作用描述
    • 逐步补充测试用例
    • baby添加缓存所有搜索到的外设索引,解决在使用过程中由于未保存peripheral对象可以导致的未知错
    • 添加2个方法,用户管理外设的自动重连功能

      /** 添加断开自动重连的外设 */- (void)AutoReconnect:(CBPeripheral *)peripheral;/** 删除断开自动重连的外设 */- (void)AutoReconnectCancel:(CBPeripheral *)peripheral;

    • 搜索和连接的过滤器方法中添加了rssi和advertisementData两个参数

      //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;