ペリフェラル モードの IOS デバイス (iPhone 4s、iOS 6.1.3) とセントラル モードの別の IOS デバイス (iPhone 4s、iOS 6.1.3) で LightBlue アプリを使用しました。
Apple のBTLE Transferサンプル コードを使用していますが、これら 2 つのデバイスで正しく動作しています。ただし、LightBlue では動作しません。Blood Pressure Device からデータを読み取る簡単なアプリを開発したいだけなので、Transfer.h ファイルで次のサービスと特性 UUID を変更しました。
TRANSFER_SERVICE_UUID @"1810" を定義
define TRANSFER_CHARACTERISTIC_UUID @"2A49" // 値を読み取るだけ
私の計画では、LightBlue で実際のデバイス構造を複製し、LightBlue 周辺機器に接続するための中央アプリを開発します (現時点では実際のデバイスがないため、実際のデバイスで動作すると思います)。デバイスを周辺機器として設定し、2 つ目のデバイスは変更されたアプリ (Apple サンプルから) をセントラルまたはクライアントとしてインストールします。
Apple が提供する次のデリゲート メソッド:
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
{
// Reject any where the value is above reasonable range
if (RSSI.integerValue > -15) {
return;
}
// Reject if the signal strength is too low to be close enough (Close is around -22dB)
if (RSSI.integerValue < -35) {
return;
}
NSLog(@"Discovered %@ at %@", peripheral.name, RSSI);
// Ok, it's in range - have we already seen it?
if (self.discoveredPeripheral != peripheral) {
// Save a local copy of the peripheral, so CoreBluetooth doesn't get rid of it
self.discoveredPeripheral = peripheral;
// And connect
NSLog(@"Connecting to peripheral %@", peripheral);
[self.centralManager connectPeripheral:peripheral options:nil];
self.connectingPeripheral=peripheral; // this line of code I have added as recommended from a member
}
}
問題は、このデリゲート メソッドが起動され、ログ パネルに "Discovered LightBlue at -32" が表示されることです。コード NSLog(@"Connecting toperipheral % @"、周辺);
すべての提案を歓迎し、高く評価します。