Skip to content
coolnameismy edited this page Oct 24, 2015 · 19 revisions

=======================添加当前扫描到的设备变化的委托 =======================增加对rssi的支持

  • (void)peripheralDidUpdateRSSI:(CBPeripheral *)peripheral error:(nullable NSError *)error NS_DEPRECATED(NA, NA, 5_0, 8_0);
  • (void)peripheral:(CBPeripheral *)peripheral didReadRSSI:(NSNumber *)RSSI error:(nullable NSError *)error NS_AVAILABLE(NA, 8_0);

=======================完善代码中英文注释和方法注释 =======================去掉无用的变量 =======================修改babyBluetooch的子类类名 =======================增加对复杂操作的支持 =======================测试用例 =======================蓝牙桩程序 stub app of osx 1:添加重启设备功能 2:添加ui,点击进入教程,github蓝牙库 =======================支持断线重连 =======================peripheralManager的支持

当一系列操作后执行的方法

//方法声明
-(void)until:(void (^)())step
       then:(void(^)(CBCentralManager *manager,CBPeripheral *peripheral))then;
-(void)until:(void (^)())step
        step:(void (^)())step;
//方法调用

 [baby 
     until:^() {
        //获取characteristic
        fetchC(characteristicc1,"ff01");
        //characteristic write操作
        writeC(characteristicc1,"ff01");
        writeC(characteristicc2,characteristicc1);
        //检查是否写成功,默认write就会检查是否写成功
        ckeckValueEqual(characteristicc1,characteristicc2);
        //check Block检查

        
     }
     then:^(CBCentralManager *manager,CBPeripheral *peripheral) {
        //do when step done
        notity(c3,c4,onBlock());
     }
 ];

 [baby until:^{
        //
    } step:^{
        //
    } then:^(CBCentralManager *manager, CBPeripheral *peripheral) {
        
  }];

//#warning 测试数据 ////个性化,读取设备养护数据 //-(void)readPlantAssistantData{ // //写入当前系统时间 //
// CBCharacteristic *currentTime = [BabyToy findCharacteristicFormServices:self.services UUIDString:@"FFA8"]; //
// if (currentTime) { // NSMutableData *data = [NSMutableData data]; // NSDateFormatter *df = [[NSDateFormatter alloc]init]; // [df setDateFormat:@"yyyy/MM/dd/hh/mm"]; // NSArray *dateArray = df stringFromDate:[NSDate date componentsSeparatedByString:@"/"]; // for (NSString *item in dateArray) { // int intItem = [item intValue]; // if (intItem > 1000) { // int hPart = intItem/100; // int lPart = intItem%2000; // [data appendData:[NSData dataWithBytes:&hPart length:1]]; // [data appendData:[NSData dataWithBytes:&lPart length:1]]; // } // else{ // [data appendData:[NSData dataWithBytes:&intItem length:1]]; // } //
// } // // [self.currPeripheral writeValue:data forCharacteristic:currentTime type:CBCharacteristicWriteWithResponse]; // } // // //读取当前RecordStartTime(FFA2)RecordPeriod(FFAB) CurrentTime(FFA8),ReadID(FFA4),ReadOT(FFA5) //
// //设置ReadID,ReadOT //
// //TransferStatus(FFA9) 写1 // CBCharacteristic *transferStatus = [BabyToy findCharacteristicFormServices:self.services UUIDString:@"FFA9"]; // // if (transferStatus) { // int i = 1; // NSData *value = [NSData dataWithBytes:&i length:sizeof(i)]; // [self.currPeripheral writeValue:value forCharacteristic:transferStatus type:CBCharacteristicWriteWithResponse]; // } // //订阅RecordBuf(FFA1)数据 // CBCharacteristic *recordBuf = [BabyToy findCharacteristicFormServices:self.services UUIDString:@"FFA1"]; // // if (recordBuf) { // [self.currPeripheral setNotifyValue:YES forCharacteristic:recordBuf]; // } // //}