나는 UWP 응용 프로그램을 통해 Bluetooth를 통해 Arduino를 찾고 연결하는 방법을 찾으려고 했으므로 두 가지 방법을 찾았습니다 (불행히도 공식 MS 설명서를 찾을 수 없었습니다) 그래서 하나의 방법은Arduino와 Windows 10 UWP Bluetooth 연결
DeviceInformationCollection availableDevices = await BluetoothSerial.listAvailableDevicesAsync();
foreach (DeviceInformation device in availableDevices)
{
deviceList.Add(device);
}
이 "데브 B"라는 이름의 블루투스 장치를 반환하고, 실제로 내 아두 이노의 블루투스 모듈입니다. 페어링/페어링이 불가능한 다른 장치가 있지만이 메서드는 항상 "Dev B"만 반환합니다.
그리고는 내가 아두 이노
var selectedDevice = (DeviceInformation)DeviceListView.SelectedItem;
uint BaudRate = 9600;
var connection = new BluetoothSerial(selectedDevice.Name);
arduino = new RemoteDevice(connection);
connection.begin(BaudRate, SerialConfig.SERIAL_8N1);
connection.ConnectionEstablished += OnConnectionEstablished;
ConnectedDeviceTextBox.Text = "Connected with Arduino.";
와 연결이 기능을 사용 그리고 훌륭하게 작동하고 연결됩니다. 나는이 날 모든 페어링 된 Bluetooth 장치를 제공하지만, 블루투스 모듈의 이름은 지금 HC 인 다음 방법
var selector = BluetoothDevice.GetDeviceSelectorFromPairingState(true);
var devices = await DeviceInformation.FindAllAsync(selector);
foreach (DeviceInformation device in devices)
{
deviceList.Add(device);
}
을 발견 사용할 수있는 모든 블루투스 장치를 발견 할 필요가 있기 때문에 모든 것이 이제
까지 좋은 -05 (이것은 실제로 Windows가 Bluetooth 설정 및 다른 모든 곳에서 표시하는 이름입니다). 하지만 위의 Connection 코드에이 장치 정보를 전달하면 연결되지 않습니다. 내가
var connection = new BluetoothSerial(selectedDevice.Name);
에서 장치 이름을 사용하여 시도했지만 작동하지 않습니다, 나는 또한 여전히
var connection = new BluetoothSerial(selectedDevice);
행운 장치 자체를 전달했습니다.
누군가가 이름의 차이점을 설명하고 두 번째 방법과 연결되지 않는 이유는 무엇입니까? 미리 감사드립니다.
감사합니다. Rita, Rfcomm과 BluetoothDevice 클래스의 차이점에 대해 알고 싶습니다. 이름에 관해서는 HC-05 블루투스 모듈의 이름을 바꾸려고 시도했지만, 앱의 첫 번째 방법으로 Dev B가 표시된 곳을 제외한 모든 곳에서 업데이트되었습니다. 나는 이것을 조사하고 내가 뭔가를 찾으면 쓰레드를 업데이트 할 것이다. –