Bluetoothを使用して2つ以上のデバイスを1つのデバイスに接続しようとしましたが、のC#でプログラムするのに最適な方法は何ですか?Bluetoothを使用して複数のデバイスを接続する方法
public BluetoothDeviceInfo[] DiscoverDevices();
Bluetoothを使用して2つ以上のデバイスを1つのデバイスに接続しようとしましたが、のC#でプログラムするのに最適な方法は何ですか?Bluetoothを使用して複数のデバイスを接続する方法
public BluetoothDeviceInfo[] DiscoverDevices();
使用可能なデバイスの数を取得することができ、その後、BluetoothClient
クラスを使用するすべてのデバイスのList
をループ:
int maxDevices = 10;
List<Device> devices = new List<Device>();
BluetoothClient bc = new BluetoothClient();
BluetoothDeviceInfo[] array = bc.DiscoverDevices(maxDevices);
int count = array.Length;
for (int i = 0; i < count; i++)
{
Device device = new Device(array[i]);
devices.Add(device);
// the variable device will now hold a detected BT device.
// Now you can connect to the device:
bc.Connect(new BluetoothEndPoint((BluetoothAddress)adres,service));
// Send a message to the device
System.Net.Sockets.NetworkStream stream = bc.GetStream();
StreamWriter streamWriter = new StreamWriter(stream);
streamWriter.WriteLine("! 0 200 200 210 1");
}
// the variable devices will now hold an array of all detected BT devices.
注:DiscoverDevices
が完了するまでに約20〜30秒かかります。
以上で、配列をループして情報を送ることができますか? –
@ B.kどういう意味ですか? –
申し訳ありません。 私はすべてのデバイスにmessegeを送信したいので、リスト "デバイス"をループする必要がありますか? どうすればデバイスに情報を送信できますか? –
何か試したことがありますか?あなたの署名はちょうど言う:私は方法が必要です。私たちはあなたの仕事をするためにここにいません。 – HimBromBeere