|
説明 |
Bluetoothデバイスのスキャンを開始します。 スキャンにより検出されたデバイスの情報はイベントとして受け取ります。
Bluetoothデバイスのスキャンが開始するとBluetoothScanStartedイベントが発生します。 スキャンが終了、もしくはキャンセルされるとBluetoothScanFinishedイベントが発生します。スキャンをキャンセルするにはCancelBluetoothScanningメソッドを使用します。
Bluetoothデバイスが検出されるとBluetoothDeviceFoundイベントが発生します。イベントオブジェクトの子オブジェクトから、スキャン結果のデバイス情報を取得できます。 同一のデバイスが何度も検出される場合があります。BLEデバイスのRSSI値(Received Signal Strength Indication)の変化を見るために利用することができます。
|
||||||||||
|
呼出形式 |
Runtime.StartBluetoothScanning( type [, params ] )
|
||||||||||
|
戻り値 |
なし
|
||||||||||
|
引数 |
integer type |
スキャンするデバイスの種類を指定します。
|
|||||||||
|
|
Array params |
探索パラメータを、パラメーター名をキーとした連想配列で指定します。
|
|||||||||
|
例外 |
FUNC-4 |
引数の値が不正です |
|||||||||
|
|
RTM-54 |
端末のBluetooth機能へのアクセスに失敗しました。 |
|||||||||
|
|
RTM-83 |
Bluetoothが有効になっていません。 |
|||||||||
|
|
RTM-84 |
Bluetoothの使用が許可されていません。OSの設定でBluetoothの使用を許可してください。 *2 |
|||||||||
|
|
RTM-113 |
Bluetoothデバイス制御はサポートされていません。 |
|||||||||
|
|
RTM-119 |
BluetoothLE機能を利用できませんでした。 |
|||||||||
|
使用例 |
Form form1 {
Width = 424;
Height = 320;
Button btnStartScanning {
X = 16;
Y = 16;
Width = 120;
Height = 40;
Title = "デバイススキャン開始";
Function OnTouch( e ) {
try {
/* Bluetooth LEデバイスのスキャン開始 */
var params = new Array();
params["CONNECTABLE_DEVICE_ONLY"] = true;
Runtime.StartBluetoothScanning(Runtime.BLUETOOTH_LE, params);
} catch(e) {
MessageBox(e.Message);
}
}
}
Button btnStopScanning {
X = 184;
Y = 16;
Width = 120;
Height = 40;
Title = "デバイススキャン停止";
Function OnTouch( e ) {
Runtime.CancelBluetoothScanning();
}
}
}
Function OnBluetoothScanStarted(e) {
print("スキャン開始\n");
}
Function OnBluetoothScanFinished(e) {
print("スキャン終了\n");
}
Function OnBluetoothDeviceFound(e) {
print(e.DeviceID + "\n");
}
|
||||||||||
|
関連項目 |
|||||||||||