Windows 10下Visual Studio 2017的蓝牙连接问题。 [英] Bluetooth connection problem with Visual Studio 2017 under Windows 10.

查看:283
本文介绍了Windows 10下Visual Studio 2017的蓝牙连接问题。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!

我有问题让我的Arduino Uno连接通过蓝牙与Visual Studio。我用StandardFirmata草图编程了Arduino。我试过两个
57600和115200波特率。

这是我的MainPage.xaml.cs代码。


using System;

usingSystem;


使用 System .Collections.Generic;

usingSystem.Collections.Generic;


使用 System.IO;

usingSystem.IO;


使用 System.Linq;

usingSystem.Linq;


使用 System.Runtime.InteropServices.WindowsRuntime;

usingSystem.Runtime.InteropServices.WindowsRuntime;


使用 Windows.Foundation;

usingWindows.Foundation;


使用 Windows.Foundation.Collections;

usingWindows.Foundation.Collections;


使用 Windows.UI.Xaml;

usingWindows.UI.Xaml;


使用 Windows.UI.Xaml.Controls;

usingWindows.UI.Xaml.Controls;


使用 Windows.UI.Xaml.Controls.Primitives;

usingWindows.UI.Xaml.Controls.Primitives;


使用 Windows.UI.Xaml.Data;

usingWindows.UI.Xaml.Data;


使用 Windows.UI.Xaml.Input;

usingWindows.UI.Xaml.Input;


使用 Windows.UI.Xaml.Media;

usingWindows.UI.Xaml.Media;


使用 Windows.UI.Xaml.Navigation;

usingWindows.UI.Xaml.Navigation;


使用 Microsoft.Maker.Serial;

usingMicrosoft.Maker.Serial;


使用 Microsoft.Maker.RemoteWiring;

usingMicrosoft.Maker.RemoteWiring;




namespace 蓝牙测试

namespaceBluetoothTest


{


   
///
<摘要>

    /// <summary>


   
/// 一个空页面,可单独使用或导航到
a Frame。

    ///An empty page that can be used on its own or navigated to within a Frame.


   
///
< / summary>

    /// </summary>


   
公共
密封
部分

MainPage :页面

    public sealed partial class MainPage: Page


   
{

    {


       
BluetoothSerial连接;

        BluetoothSerial connection;


       
RemoteDevice arduino;

        RemoteDevice arduino;


       
公共 MainPage()

        publicMainPage()


       
{

        {


          
.InitializeComponent();

           this.InitializeComponent();



          
connection =
< span lang ="EN-US"style ="font-size:9.5pt; FONT-FAMILY:索拉;颜色:蓝色"> BluetoothSerial( " RNBT-07CE" ) ;

           connection = newBluetoothSerial("RNBT-07CE");


          
arduino =
< span lang ="EN-US"style ="font-size:9.5pt; FONT-FAMILY:索拉;颜色:蓝色"> RemoteDevice(连接);

           arduino = newRemoteDevice(connection);


          
connection.ConnectionEstablished + = OnConectionEstablished;

           connection.ConnectionEstablished += OnConectionEstablished;


        


       
}

        }



       
私人
无效 OnConectionEstablished()

        private voidOnConectionEstablished()


       
{

        {


           
bluetoothTest.Text =
"建立连接" ;

            bluetoothTest.Text = "Connection is established ";


       
}

        }



       
私人
无效 buttonBluetooth_Click( 对象 sender,
RoutedEventArgs e)

        private voidbuttonBluetooth_Click(objectsender, RoutedEventArgs e)


       
{

        {


           
connection.begin(57600,SerialConfig.SERIAL_8N1 );

            connection.begin(57600, SerialConfig.SERIAL_8N1);


       
}

        }


   
}

    }

}

这个我的Package.appxmanifest代码



<? xml
版本 = " 1.0 "
编码 = " utf-8 " ?>

<?xml version="1.0" encoding="utf-8"?>


< 包装
xmlns = " http://schemas.microsoft.com/appx/manifest/foundation/windows10 "
xmlns:mp = " http://schemas.microsoft.com/appx/2014/phone/manifest "
xmlns:uap = " http://schemas.microsoft.com/appx/manifest/uap/windows10 "
IgnorableNamespaces = " uap
mp
" >

<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">


 
<
身份
名称 = " 6c432575-8521-4dff-9470-acfe546cee7a "
Publisher = " CN = Admin "
版本 = " 1.0.0.0 "
/>

  <Identity Name="6c432575-8521-4dff-9470-acfe546cee7a" Publisher="CN=Admin" Version="1.0.0.0" />


 
<
mp:PhoneIdentity
PhoneProductId = " 6c432575-8521-4dff-9470-acfe546cee7a "
PhonePublisherId = " 00000000-0000-0000-0000-000000000000 "
/>

  <mp:PhoneIdentity PhoneProductId="6c432575-8521-4dff-9470-acfe546cee7a" PhonePublisherId="00000000-0000-0000-0000-000000000000" />


 
<
属性 >


   
<
DisplayName > 蓝牙测试 < / DisplayName >

    <DisplayName>BluetoothTest</DisplayName>


   
<
PublisherDisplayName > 管理员 < / PublisherDisplayName >

    <PublisherDisplayName>Admin</PublisherDisplayName>


   
< 徽标 > Assets \StoreLogo.png < / 徽标 >


 
< / 属性 >


 
<
依赖关系 >


   
<
TargetDeviceFamily
名称 = " Windows.Universal "
MinVersion = " 10.0.0.0 "
MaxVersionTested = " 10.0.0.0 "
/>

    <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />


 
< /
依赖关系 >


 
<
资源 >


   
<
资源
语言 = " x-generate "
/>

    <Resource Language="x-generate" />


 
< /
资源 >


 
<
应用 >


   
<
应用
Id = " 应用 "
可执行 = " $ targetnametoken $ .exe "
EntryPoint = " BluetoothTest.App " >

    <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="BluetoothTest.App">


     
<
uap:VisualElements
DisplayName = " 蓝牙测试 "
Square150x150Logo = " Assets\Square150x150Logo.png "
Square44x44Logo = " Assets\Square44x44Logo.png "
描述 = " 蓝牙测试 "
BackgroundColor = " 透明 " >

      <uap:VisualElements DisplayName="BluetoothTest" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="BluetoothTest" BackgroundColor="transparent">


       
<
uap:DefaultTile
Wide310x150Logo = " Assets\Wide310x150Logo.png " >

        <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png">


       
< /
uap:DefaultTile >


       
<
uap:SplashScreen
图像 = "Assets\SplashScreen.png"
/>


     
</
uap:VisualElements>


   
</
Application>


 
</
Applications>


 
<
Capabilities>


   
<
Capability
Name="internetClient"
/>


   
<
DeviceCapability
Name="bluetooth.rfcomm">


     
<
Device
Id="any">


       
<
Function
Type="name:serialPort"
/>


     
</Device>


     
</
DeviceCapability>


 
</
Capabilities>

</Package>

Here is my references

Is there something missing or what have I done wrong, when I can’t get it to work with Bluetooth communication. Can someone help me?




推荐答案

Hello, friend

Hello, friend

I have two suggestions for you.

I have two suggestions for you.

1. Do you use the support Bluetooth device -  SparkFun Bluetooth Mate Silver as it reported on the official
docs: https://github.com/ms-iot/remote-wiring/blob/develop/bluetooth.md

1. Do you use the support Bluetooth device -  SparkFun Bluetooth Mate Silver as it reported on the official docs: https://github.com/ms-iot/remote-wiring/blob/develop/bluetooth.md

2. If you just want to transmit data between Windows and Arduino, you can use this demo app with ordinary Bluetooth module, please refer to

2. If you just want to transmit data between Windows and Arduino, you can use this demo app with ordinary Bluetooth module, please refer to

https://www.hackster.io/JiongShi/a-pm2-5-and-pm-10-detector-design-for-windows-10-uwp-app-1f3427


这篇关于Windows 10下Visual Studio 2017的蓝牙连接问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆