0

我将 RedBearLab 的 BLE_Framework 用于我的 iOS-BLE-Arduino 项目。我为 iOS 7 设计了一个应用程序,但 Xcode 显示 TableViewController.h 中的“isConnected”已弃用。我不是程序员,所以我需要一些帮助来编辑代码以保持其功能。谢谢你。以下是代码。

(IBAction)btnScanForPeripherals:(id)sender

{ if (ble.activePeripheral) if(ble.activePeripheral.isConnected ) //!' isConnect ' 已弃用。在 iOS 7.0 中首次弃用 { [[ble CM] cancelPeripheralConnection:[ble activePeripheral]]; [btnConnect setTitle:@"Connect" forState:UIControlStateNormal]; 返回; }

if (ble.peripherals)
    ble.peripherals = nil;

[btnConnect setEnabled:false];
[ble findBLEPeripherals:2];

[NSTimer scheduledTimerWithTimeInterval:(float)2.0 target:self selector:@selector(connectionTimer:) userInfo:nil repeats:NO];

[indConnecting startAnimating];

}

另一个问题是 UUID 在 iOS 7.0 中也被弃用了。

if (!service)
{
    printf("Could not find service with UUID %s on peripheral with UUID %s\r\n",[self CBUUIDToString:serviceUUID],[self UUIDToString:p.UUID]);
    return;
}

我能做些什么来解决它?谢谢

4

1 回答 1

0

有点晚了,但我找到了 .isconnected 的答案。但是我仍在处理 UUID

if(ble.activePeripheral.state == CBPeripheralStateConnected)
于 2014-02-08T02:08:50.253 回答