CBCentralManagerStatePoweredOn と CBPeripheralManagerState の違いは何ですか? これらの変数をどのような状況で使用する必要がありますか? Objective-C のサンプル/コードを通じて、誰かが私に理解してもらえますか?
Objective-Cを介してiPhoneデバイスのBluetooth電源ステータスを知る必要があるアプリを開発しています。Bluetoothの電源ステータス(ON / OFF)が欲しいだけです。
CBCentralManagerStatePoweredOn と CBPeripheralManagerState の違いは何ですか? これらの変数をどのような状況で使用する必要がありますか? Objective-C のサンプル/コードを通じて、誰かが私に理解してもらえますか?
Objective-Cを介してiPhoneデバイスのBluetooth電源ステータスを知る必要があるアプリを開発しています。Bluetoothの電源ステータス(ON / OFF)が欲しいだけです。
基本的な概要:
CBCentralManagerStateの現在の状態を表す列挙型CBCentralManagerです。はCBCentralManager、外部デバイスのスキャンと接続を担当します。これはCBCentralManagerStatePoweredOn、デバイスに LE 対応ハードウェアがあり、ユーザーがアプリに許可を与えている場合にのみ発生します。
CBCentralManagerStateUnknown State unknown, update imminent.
CBCentralManagerStateResetting The connection with the system service was momentarily lost, update imminent.
CBCentralManagerStateUnsupported The platform doesn't support the Bluetooth Low Energy Central/Client role.
CBCentralManagerStateUnauthorized The application is not authorized to use the Bluetooth Low Energy Central/Client role.
CBCentralManagerStatePoweredOff Bluetooth is currently powered off.
CBCentralManagerStatePoweredOn Bluetooth is currently powered on and available to use.
CBPeripheralManagerStateの状態を表す列挙型CBPeripheralManagerです。はCBPeripheralManager、エリア内の他の LE デバイスに電話自体をアドバタイズして表示する機能を制御します。(つまり、CBPeripheralManagerをエミュレートできますCBPeripheral)。同様にCBPeripheralManagerStatePoweredOn、ユーザーが以前に明示的に許可を与えており、デバイスに LE 対応ハードウェアがある場合にのみ発生します。
CBPeripheralManagerStateUnknown State unknown, update imminent.
CBPeripheralManagerStateResetting The connection with the system service was momentarily lost, update imminent.
CBPeripheralManagerStateUnsupported The platform doesn't support the Bluetooth Low Energy Peripheral/Server role.
CBPeripheralManagerStateUnauthorized The application is not authorized to use the Bluetooth Low Energy Peripheral/Server role.
CBPeripheralManagerStatePoweredOff Bluetooth is currently powered off.
CBPeripheralManagerStatePoweredOn Bluetooth is currently powered on and available to use.
CBPeripheralManager重要な注意:およびCBCentralManagerデリゲートを設定していない場合、これらの状態はいずれも更新されません。セントラルとペリフェラルの状態を確認できるそれぞれのデリゲート コールバックを受信するのは、そのときだけです。
- (void)centralManagerDidUpdateState:(CBCentralManager *)central
と
- (void)peripheralManagerDidUpdateState:(CBPeripheralManager *)peripheral;