CoreBluetooth 名前空間
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
CoreBluetooth 名前空間は、Bluetooth通信のクラスを提供します。
クラス
| Name | 説明 |
|---|---|
| AdvertisementData |
CoreBluetooth 名前空間は、Bluetooth通信のクラスを提供します。 |
| CBAdvertisement |
DiscoveredPeripheral(CBCentralManager, CBPeripheral, NSDictionary, NSNumber)でパラメーターとして受け取った NSDictionary からディクショナリ値を検索するために使用されるキー。 |
| CBAncsAuthorizationUpdateEventArgs |
Objective-C プロトコル メソッドに基づいてイベントのデータを提供します。 |
| CBATTErrorExtensions |
CBATTError列挙体の拡張メソッド。 |
| CBATTRequest |
読み取りまたは書き込みのための属性プロトコル要求。 |
| CBATTRequestEventArgs |
Objective-C プロトコル メソッドに基づいてイベントのデータを提供します。 |
| CBATTRequestsEventArgs |
Objective-C プロトコル メソッドに基づいてイベントのデータを提供します。 |
| CBAttribute |
Bluetooth デバイスを一意に識別するクラス。 |
| CBCentral |
中央 (現在のデバイスではない) を識別するために使用されます。 |
| CBCentralInitOptions |
Bluetooth中央マネージャーを初期化するためのオプションが含まれています。 |
| CBCentralManager |
Bluetooth LE のローカル中央デバイスを表します。 CBCentralManager を使用して、リモート周辺機器のスキャン、検出、接続を行います。 |
| CBCentralManagerDelegate |
CBCentralManager オブジェクトのオブジェクトを委任します。 |
| CBCentralManagerDelegate_Extensions |
CBCentralManagerDelegate プロトコルのすべてのメソッドをサポートするために、 ICBCentralManagerDelegate インターフェイスへの拡張メソッド。 |
| CBChannelSoundingProcedureResults |
チャネルサウンディング手順の結果を格納します。 |
| CBChannelSoundingProcedureResultsEventArgs |
Objective-C プロトコル メソッドに基づいてイベントのデータを提供します。 |
| CBChannelSoundingSessionConfiguration |
周辺機器がチャネル サウンディング セッションで想定する役割を構成します。 |
| CBCharacteristic |
リモート周辺機器の特性。 |
| CBCharacteristicEventArgs |
Objective-C プロトコル メソッドに基づいてイベントのデータを提供します。 |
| CBConnectionEventMatchingOptions |
CoreBluetooth 名前空間は、Bluetooth通信のクラスを提供します。 |
| CBConnectPeripheralOptions |
CoreBluetooth 名前空間は、Bluetooth通信のクラスを提供します。 |
| CBDescriptor |
周辺機器の特性の変更できない説明。 CBMutableDescriptor も参照してください。 |
| CBDescriptorEventArgs |
Objective-C プロトコル メソッドに基づいてイベントのデータを提供します。 |
| CBDiscoveredPeripheralEventArgs |
Objective-C プロトコル メソッドに基づいてイベントのデータを提供します。 |
| CBErrorExtensions |
CBError列挙体の拡張メソッド。 |
| CBL2CapChannel |
CoreBluetooth 名前空間は、Bluetooth通信のクラスを提供します。 |
| CBManager |
CoreBluetooth 名前空間は、Bluetooth通信のクラスを提供します。 |
| CBMutableCharacteristic |
変更可能な CBCharacteristic。 |
| CBMutableDescriptor |
変更可能な CBDescriptor。 |
| CBMutableService |
変更可能な CBService。 |
| CBPeer |
中央または一時的なBluetoothデバイスを表すクラス。 |
| CBPeripheral |
CoreBluetooth 周辺機器を表します。 |
| CBPeripheralConnectionEventEventArgs |
Objective-C プロトコル メソッドに基づいてイベントのデータを提供します。 |
| CBPeripheralDelegate |
CBPeripheralのデリゲート オブジェクト。 リモート周辺機器の検出、探索、および操作に関連するイベントに対して呼び出されるメソッドを提供します。 |
| CBPeripheralDelegate_Extensions |
CBPeripheralDelegate プロトコルからのすべてのメソッドをサポートする、 ICBPeripheralDelegate インターフェイスへの拡張メソッド。 |
| CBPeripheralDiconnectionEventEventArgs |
Objective-C プロトコル メソッドに基づいてイベントのデータを提供します。 |
| CBPeripheralErrorEventArgs |
Objective-C プロトコル メソッドに基づいてイベントのデータを提供します。 |
| CBPeripheralEventArgs |
Objective-C プロトコル メソッドに基づいてイベントのデータを提供します。 |
| CBPeripheralManager |
CBPeripheral デバイスの GATT データベースごとに発行されたサービスを管理します。 |
| CBPeripheralManagerDelegate |
CBPeripheralManagerのデリゲート オブジェクト。 可用性、公開、広告、サブスクリプションに関連するイベントのメソッドを追加します。 |
| CBPeripheralManagerDelegate_Extensions |
CBPeripheralManagerDelegate プロトコルからのすべてのメソッドをサポートするために、 ICBPeripheralManagerDelegate インターフェイスへの拡張メソッド。 |
| CBPeripheralManagerL2CapChannelOperationEventArgs |
Objective-C プロトコル メソッドに基づいてイベントのデータを提供します。 |
| CBPeripheralManagerOpenL2CapChannelEventArgs |
Objective-C プロトコル メソッドに基づいてイベントのデータを提供します。 |
| CBPeripheralManagerServiceEventArgs |
Objective-C プロトコル メソッドに基づいてイベントのデータを提供します。 |
| CBPeripheralManagerSubscriptionEventArgs |
Objective-C プロトコル メソッドに基づいてイベントのデータを提供します。 |
| CBPeripheralOpenL2CapChannelEventArgs |
Objective-C プロトコル メソッドに基づいてイベントのデータを提供します。 |
| CBPeripheralServicesEventArgs |
Objective-C プロトコル メソッドに基づいてイベントのデータを提供します。 |
| CBRssiEventArgs |
Objective-C プロトコル メソッドに基づいてイベントのデータを提供します。 |
| CBService |
リモート周辺機器のサービスを表します。 |
| CBServiceEventArgs |
Objective-C プロトコル メソッドに基づいてイベントのデータを提供します。 |
| CBUUID |
Bluetooth スタックのユニバーサル一意識別子。 |
| CBWillRestoreEventArgs |
Objective-C プロトコル メソッドに基づいてイベントのデータを提供します。 |
| PeripheralConnectionOptions |
周辺機器接続オプション。 |
| PeripheralScanningOptions |
ScanForPeripherals(CBUUID[], NSDictionary)の呼び出しで options パラメーターに指定できる値。 |
| RestoredState |
CoreBluetooth 名前空間は、Bluetooth通信のクラスを提供します。 |
| StartAdvertisingOptions |
StartAdvertising(StartAdvertisingOptions)によって使用されるオプションへのアクセスを管理します。 |
インターフェイス
| Name | 説明 |
|---|---|
| ICBCentralManagerDelegate |
CBCentralManager オブジェクトのオブジェクトを委任します。 |
| ICBPeripheralDelegate |
CBPeripheralのデリゲート オブジェクト。 リモート周辺機器の検出、探索、および操作に関連するイベントに対して呼び出されるメソッドを提供します。 |
| ICBPeripheralManagerDelegate |
CBPeripheralManagerのデリゲート オブジェクト。 可用性、公開、広告、サブスクリプションに関連するイベントのメソッドを追加します。 |
列挙型
| Name | 説明 |
|---|---|
| CBATTError |
GATT サーバーによって返されるエラー。 |
| CBAttributePermissions |
特性の値の読み取り、書き込み、および暗号化のアクセス許可を列挙します。 |
| CBCentralManagerFeature |
CoreBluetooth 名前空間は、Bluetooth通信のクラスを提供します。 |
| CBCentralManagerState |
CBCentralManagerの考えられる状態を列挙します。 |
| CBChannelSoundingSessionConfigurationRole |
チャネル サウンディング セッションで周辺機器が想定する役割を指定します。 |
| CBCharacteristicProperties |
特性の可能なプロパティ。 特性には複数のプロパティが含まれる場合があります。 |
| CBCharacteristicWriteType |
特性の値に対して可能な書き込みの種類を列挙します。 |
| CBConnectionEvent |
CoreBluetooth 名前空間は、Bluetooth通信のクラスを提供します。 |
| CBError |
BLUETOOTH LE トランザクション中に発生する可能性のあるエラー。 |
| CBManagerAuthorization |
CoreBluetooth 名前空間は、Bluetooth通信のクラスを提供します。 |
| CBManagerState |
CoreBluetooth 名前空間は、Bluetooth通信のクラスを提供します。 |
| CBPeripheralManagerConnectionLatency |
CBPeripheralManagerの接続待機時間。 |
| CBPeripheralManagerState |
CBPeripheralManagerの考えられる状態を列挙します。 |
| CBPeripheralState |
CBPeripheralの使用可能な接続状態を列挙します。 |
注釈
CoreBluetooth 名前空間を使用すると、開発者は低エネルギー (Bluetooth LE) デバイスBluetooth操作できます。
Bluetooth LE モデルは、 CBPeer オブジェクトを中心に回転します。 CBPeerには、データをスキャンして使用するCBCentralオブジェクトと、データ提供Bluetooth LE デバイスに対応するCBPeripheralオブジェクトの 2 種類があります。
一般に、iOS デバイスは CBCentral ロールになりますが、デバイスが CBPeripheralであるアプリを作成することもできます。
次の例は、外部の Bluetooth LE デバイスからデータを使用するアプリの一般的な初期化動作を示しています。 CBCentralを持つアプリケーションには、デリゲート オブジェクトCBCentralManagerDelegate関連付けられている必要があり、そのUpdatedState メソッドをオーバーライドする必要があります。 オーバーライドでは、 CBCentralManager の状態を確認し、 PoweredOnされていることを確認する必要があります。
通常、アプリケーションはBLUETOOTH LE 周辺機器をスキャンする必要があります。 これはエネルギーの高い関数であるため、開発者は、関心のあるCBPeripheralを見つけた後、または一定の時間が経過した後に、StopScanを呼び出す必要があります。
public class MySimpleCBCentralManagerDelegate : CBCentralManagerDelegate
{
override public void UpdatedState (CBCentralManager mgr)
{
if (mgr.State == CBCentralManagerState.PoweredOn) {
//Passing in null scans for all peripherals. Peripherals can be targeted by using CBUIIDs
CBUUID[] cbuuids = null;
mgr.ScanForPeripherals (cbuuids); //Initiates async calls of DiscoveredPeripheral
//Timeout after 30 seconds
var timer = new Timer (30 * 1000);
timer.Elapsed += (sender, e) => mgr.StopScan();
} else {
//Invalid state -- Bluetooth powered down, unavailable, etc.
System.Console.WriteLine ("Bluetooth is not available");
}
}
public override void DiscoveredPeripheral (CBCentralManager central, CBPeripheral peripheral, NSDictionary advertisementData, NSNumber RSSI)
{
Console.WriteLine ("Discovered {0}, data {1}, RSSI {2}", peripheral.Name, advertisementData, RSSI);
}
}
public partial class HelloBluetoothCSharpViewController : UIViewController
{
MySimpleCBCentralManagerDelegate myDel;
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
//Important to retain reference, else will be GC'ed
myDel = new MySimpleCBCentralManagerDelegate ();
var myMgr = new CBCentralManager (myDel, DispatchQueue.CurrentQueue);
}
//...etc...
}
DiscoveredPeripheralメソッドは、1 つの物理デバイスに対して複数回呼び出すことができます。 アプリケーション開発者は、関心のある CBPeripheral への参照を取得したら、その参照を維持してさらに作業を行い、 StopScanを呼び出す必要があります。
検出された CBPeripheralへの参照を使用して、開発者は次の例に示すように、それに接続できます。
CBPeripheralには 0 個以上のCBServiceがあり、それぞれに 0 個以上のCBCharacteristicがあります。 特性が測定 (ハートビート、時間、温度など) を表す場合、値は Value プロパティになります。
public class SimplePeripheralDelegate : CBPeripheralDelegate
{
public override void DiscoveredService (CBPeripheral peripheral, NSError error)
{
System.Console.WriteLine ("Discovered a service");
foreach (var service in peripheral.Services) {
Console.WriteLine (service.ToString ());
peripheral.DiscoverCharacteristics (service);
}
}
public override void DiscoveredCharacteristic (CBPeripheral peripheral, CBService service, NSError error)
{
System.Console.WriteLine ("Discovered characteristics of " + peripheral);
foreach (var c in service.Characteristics) {
Console.WriteLine (c.ToString ());
peripheral.ReadValue (c);
}
}
public override void UpdatedValue (CBPeripheral peripheral, CBDescriptor descriptor, NSError error)
{
Console.WriteLine ("Value of characteristic " + descriptor.Characteristic + " is " + descriptor.Value);
}
public override void UpdatedCharacterteristicValue (CBPeripheral peripheral, CBCharacteristic characteristic, NSError error)
{
Console.WriteLine ("Value of characteristic " + characteristic.ToString () + " is " + characteristic.Value);
}
}
//...
mgr = new CBCentralManager (myCentralDelegate, DispatchQueue.CurrentQueue);
mgr.ConnectedPeripheral += (s, e) => {
activePeripheral = e.Peripheral;
System.Console.WriteLine ("Connected to " + activePeripheral.Name);
if (activePeripheral.Delegate == null) {
activePeripheral.Delegate = new SimplePeripheralDelegate ();
//Begins asynchronous discovery of services
activePeripheral.DiscoverServices ();
}
};
//Connect to peripheral, triggering call to ConnectedPeripheral event handled above
mgr.ConnectPeripheral (myPeripheral);