Troubleshooting "Tutorial: MetaWear C# Programming Part 1"

Hi,

Let me preface this by saying that I am relatively new to BLE in C#. I am running Windows 10 on my Alienware laptop. I am attempting to do the "Tutorial: MetaWear C# Programming Part 1" (see video here:  ).

I followed the instructions exactly following errors: 
CS0246 The type or namespace "MbientLab" could not be found
CS0103 "Device Information does not exist in the current context"
I used the Nuget to install the library but perhaps I've done something wrong. Any help would be greatly appreciated

Cheers,
Jim

Comments

  • Ah, that video is for the old C# library that was just a wrapper around a shared C++ library and should have been removed.  Samples projects for VS2017 can be found here:
  • Thanks Eric.

    So does that mean this tutorial https://github.com/mbientlab/MetaWear-SDK-CSharp is also obsolete?

    Additional question: does the link you just sent me have instructions somewhere or am I just supposed to build the solution and cross my fingers?

    Thanks again,
    Jim
  • So I've cloned the repository you've linked me to and I'm looking at the following issues:
    1. When I attempt to open the "MetaWear Tutorials.sln" with Visual Studio 2015, BtleDeviceScanner loads but neither FreeFall Detector nor StarterApp load. The output window shows the message: "C:\Users\EquipUser\source\repos\metaWear_experiments\metaWear_experiments\MetaWear-Tutorial-CSharp-master\StarterApp\StarterApp.csproj : error  : The imported project "C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\XamlCompiler\Microsoft.Windows.UI.Xaml.Common.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.  C:\Program Files (x86)\MSBuild\Microsoft\WindowsXaml\v14.0\8.21\Microsoft.Windows.UI.Xaml.Common.targets"
    2. In the readme file the instructions state that I must "Then, after you have obtained the [BluetoothLEDevice](https://docs.microsoft.com/en-us/uwp/api/windows.devices.bluetooth.bluetoothledevice) object corresponding to your MetaWear device, call 
    **GetMetaWearBoard** to retrieve an **IMetaWearBoard** reference for the device." could you clarify what exactly that means?
    • Which tutorial are you referring to?  The link you provided is the source code of the current C# SDK.

    • The solution is for Visual Studio 2017, not 2015.

    • Which part exactly is unclear to you?  The tutorial solution I linked has full working code.
  • Ok thanks for pointing out these facts Eric. I ran the tutorial code and I'm running into the following sequences of events:
    Running StarterApp:
    1. I run the app in Visual Studio 2017 on my local machine
    2. The app screen pops up and identifies my metawearRG along with its MAC address. I click on the device
    3. A screen pops up saying "Initializing API"
    4. The app screen goes blank white and after several minutes still displays no content. What am I supposed to be seeing on the StarterApp?

    Running Freefall Detector App:
    1. I run the app in Visual Studio 2017 on my local machine
    2. The app screen pops up and identifies my metawearRG along with its MAC address. I click on the device in the app.
    3. A screen pops up saying "Initializing API"
    4. Visual Studio stops in its tracks and displays to me the message "FreeFall Detector.pdb" not detected.

    Please advise.
  • The "StarterApp" project is a template for creating UWP apps with the C# SDK.  It pairs with the tutorial that shows you how to stream accelerometer data (https://mbientlab.com/tutorials/CSAPIs.html#xaml-layout) and serves as a general starting point for new developers.

    Mm, the free fall project works fine on my laptop.  I've updated the tutorial projects to use the latest C# SDK so try using the latest commit on the master branch and make sure Visual Studio has been updated to 15.4.0.
  • I am also running FreeFall detector on Visual Studio 15.4.0 with the most recent version of the master branch.

    Unfortunately once I click on my metaWearRG device in the application, the application goes into run mode and shows a "System.TimeoutException while trying to create the data processor" on line 43 of DetecterSetup.xaml.cs. Any idea what the issue could be here?
  • *debug mode not run mode
  • I've narrowed down the issue to some timeouts that apparently are now not long enough by default for the current Windows 10 builds.  For now, skip the free fall tutorial and follow the accelerometer streaming tutorial I linked in my previous post.
  • OK. I got the StarterApp working after many trials and banging my head on a concrete wall a few times...

    Some tips I would give to others are the following:
    1. Make sure you include the line "using MbientLab.MetaWear.Sensor;" at the beginning of the program
    2. Change the line: "System.Diagnostics.Debug.WriteLine(data.Value<Acceleration>())" into:
    System.Diagnostics.Debug.WriteLine(data.Value<MbientLab.MetaWear.Data.Acceleration>())
    3. Be aware that the accelerometer data will appear in the "output" window of the Visual Studio console and NOT in the app window itself.

    Cheers and happy hunting,
    Jimbo
  • OK. I got the StarterApp working after many trials and banging my head on a concrete wall a few times...

    Some tips I would give to others are the following:
    1. Make sure you include the line "using MbientLab.MetaWear.Sensor;" at the beginning of the program
    2. Change the line: "System.Diagnostics.Debug.WriteLine(data.Value<Acceleration>())" into:
    System.Diagnostics.Debug.WriteLine(data.Value<MbientLab.MetaWear.Data.Acceleration>())
    3. Be aware that the accelerometer data will appear in the "output" window of the Visual Studio console and NOT in the app window itself.

    Cheers and happy hunting,
    Jimbo
This discussion has been closed.