Accessing Ambient Light Sensor on Microsoft Band

2020-05-24 17:38发布

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 value.

How can I access the ALS?

4条回答
戒情不戒烟
2楼-- · 2020-05-24 18:13

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/

查看更多
贼婆χ
3楼-- · 2020-05-24 18:15

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();
}
查看更多
家丑人穷心不美
4楼-- · 2020-05-24 18:30

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.

查看更多
聊天终结者
5楼-- · 2020-05-24 18:37

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

查看更多
登录 后发表回答