Go Down

Topic: Problem att få bluetooth kommunikation till Arduino Uno med Visual Studio 2017. (Read 389 times) previous topic - next topic

Ken76

Jag har problem att få min Arduino Uno att kommunicera med Arduino Uno med Visual Studio 2017 under Windows 10.

Jag har programmerat Standard Firmata sketchen till Arduino Uno och provat både med 57600 och 115200 baudrate.

Här är min MainPage.xaml.cs kod.
Code: [Select]
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Microsoft.Maker.Serial;
using Microsoft.Maker.RemoteWiring;

// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409

namespace BluetoothTest
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        BluetoothSerial connection;
        RemoteDevice arduino;
        public MainPage()
        {
           this.InitializeComponent();

           connection = new BluetoothSerial("RNBT-07CE");
           arduino = new RemoteDevice(connection);
           connection.ConnectionEstablished += OnConectionEstablished;
         
        }

        private void OnConectionEstablished()
        {
            bluetoothTest.Text = "Connection is established ";
        }

        private void buttonBluetooth_Click(object sender, RoutedEventArgs e)
        {
            connection.begin(57600, SerialConfig.SERIAL_8N1);
        }
    }
}


Och här min Package.appxmanifest kod.
Code: [Select]
<?xml version="1.0" encoding="utf-8"?>
<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">
  <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" />
  <Properties>
    <DisplayName>BluetoothTest</DisplayName>
    <PublisherDisplayName>Admin</PublisherDisplayName>
    <Logo>Assets\StoreLogo.png</Logo>
  </Properties>
  <Dependencies>
    <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
  </Dependencies>
  <Resources>
    <Resource Language="x-generate" />
  </Resources>
  <Applications>
    <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="BluetoothTest.App">
      <uap:VisualElements DisplayName="BluetoothTest" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="BluetoothTest" BackgroundColor="transparent">
        <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png">
        </uap:DefaultTile>
        <uap:SplashScreen Image="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>


Referenserna för Visual Studio projektet finns, som en bifogad bild.

Är det nånting, som jag har missat eller gjort fel? Kan nån hjälpa mig?





Go Up