Accessing Ambient Light Sensor on Microsoft Band

前端 未结 4 1221
时光说笑
时光说笑 2021-02-04 22:16

There is an Ambient Light Sensor with Microsoft Band, and some apps in the Windows Store show the ALS value in Lux, But I can\'t find a way in the Band SDK to read the ALS Lux v

相关标签:
4条回答
  • 2021-02-04 22:55

    the Microsoft Band SDK (NuGet package v1.3.11121) now exposes the ambient light sensor.

    if (bandClient.SensorManager.AmbientLight.IsSupported)
    {
        bandClient.SensorManager.AmbientLight.ReadingChanged += (s, args) =>
        {
            Debug.WriteLine(bandClient.SensorManager.AmbientLight.Brightness);
        };
        await bandClient.SensorManager.AmbientLight.StartReadingsAsync();
        await Task.Delay(TimeSpan.FromSeconds(5));
        await bandClient.SensorManager.AmbientLight.StopReadingsAsync();
    }
    
    0 讨论(0)
  • 2021-02-04 23:01

    As mentioned, that sensor is not exposed by the public SDK - but it is apparently possible to get the information (and a heap of other stuff) by using the raw Bluetooth interface - the public API is a kind of wrapper around the raw Bluetooth protocol.

    So, if you're not afraid of reverse-engineering and fiddling around with raw bytes you may be able to figure out how to decode the sensor data. You can use the Windows.Devices.Bluetooth.Rfcomm library - there's a code sample from Microsoft that shows how to setup basic Bluetooth rfccomm communication: https://code.msdn.microsoft.com/windowsapps/Bluetooth-Rfcomm-Chat-afcee559

    0 讨论(0)
  • 2021-02-04 23:01

    If you're on Win or iOS use can you RFCOMM. But then you have to write everything by yourself. Subscribing for sensor data is easy, so is parsing the response. But it gets complicated if you need interaction with the device - communicating the tiles and so on. If you're on Android you get the support of MS Health app, but as it does not expose this functionality you cannot use it. Only if you disable (uninstall?) MS Health app and again write everything by yourself.

    0 讨论(0)
  • 2021-02-04 23:18

    The ALS is not currently exposed by the Public SDK for 3rd party apps. You can add a feature request for access to this sensor in a future version of the SDK at: http://microsofthealth.uservoice.com/

    0 讨论(0)
提交回复
热议问题