Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.

GATT Server and Client on HoloLens

Hi guys,

I want to implement a GATT server and client on the HoloLens.
As a prep I used this example project: https://github.com/Microsoft/Windows-universal-samples/blob/master/Samples/BluetoothLE/cs/Scenario1_Discovery.xaml.cs.
I tried to implement the DeviceWatcher, the GATT Client and the GATT Server in a Unity scene with buttons and dropdown menus.
But when I run the server on the HoloLens, I got an DataType Exception.

Greetings,
Chris

Comments

  • I got following error code:

    Exception thrown: 'System.TypeLoadException' in Assembly-CSharp.dll
    "BLE_Test_HoloLEns.exe" (CoreCLR: CoreCLR_UWP_Domain): "C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\BLETestHoloLEnsVS.Debug_x86.chris\System.Diagnostics.StackTrace.dll" geladen. Das Laden von Symbolen wurde übersprungen. Das Modul ist optimiert, und die Debugoption "Nur eigenen Code" ist aktiviert.
    TypeLoadException: Requested Windows Runtime type 'Windows.Devices.Bluetooth.GenericAttributeProfile.GattServiceProvider' is not registered.
    at System.StubHelpers.StubHelpers.GetWinRTFactoryObject(IntPtr pCPCMD)
    at Windows.Devices.Bluetooth.GenericAttributeProfile.GattServiceProvider.CreateAsync(Guid serviceUuid)
    at GATT_Server.d__8.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.b__6_0(Object state)
    at UnityEngine.UnitySynchronizationContext.WorkRequest.Invoke()
    at UnityEngine.UnitySynchronizationContext.Exec()
    at UnityEngine.UnitySynchronizationContext.ExecuteTasks()
    at UnityEngine.UnitySynchronizationContext.$Invoke1ExecuteTasks(Int64 instance, Int64* args)
    at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method)
    (Filename: Line: 0)

    when I run this code:

    using System;
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    if NETFX_CORE

    using Windows.Devices.Bluetooth;
    using Windows.Devices.Bluetooth.GenericAttributeProfile;
    using Windows.Devices.Enumeration;
    using Windows.Storage.Streams;
    using System.Threading.Tasks;

    endif

    public class GATT_Server : MonoBehaviour {

    if NETFX_CORE

    public  Guid uuid = Guid.Parse("3B0FF8A7-9691-4753-B7D6-CCB20C729B62");  //Server
    public  Guid uuid1 = Guid.Parse("A6CD68C5-E2B8-4BFD-8C24-2775784972F8");  //Write {A6CD68C5-E2B8-4BFD-8C24-2775784972F8}
    public  Guid uuid2 = Guid.Parse("CAB83326-C23C-46C9-9ADA-482DC086A43A");   //Read {CAB83326-C23C-46C9-9ADA-482DC086A43A}
    
    GattServiceProvider serviceProvider;
    private GattLocalCharacteristic WriteCharacteristic;
    private GattLocalCharacteristic ReadCharacteristic;
    
    private bool peripheralSupported;
    

    endif

    private void Start()
    {
    

    if NETFX_CORE

        Start_Server();
    

    endif

    }
    
    private async void Start_Server()
    {
        GattServiceProviderResult serviceResult = await GattServiceProvider.CreateAsync(uuid);
        if (serviceResult.Error == BluetoothError.Success)
        {
            serviceProvider = serviceResult.ServiceProvider;
            Debug.Log("1");
        }
        else
        {
            Debug.Log("3");
            return;
        }
    }
    

    }

    The funny thing is that only when I use the HoloLens this error appears.

  • Is it possible to run a GATT server on the HoloLens (14393) or is it only possible to run the client?

Sign In or Register to comment.