Accessing Ambient Light Sensor on Microsoft Band

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 10:58:12

问题


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?


回答1:


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




回答2:


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.




回答3:


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/




回答4:


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();
}


来源:https://stackoverflow.com/questions/31140539/accessing-ambient-light-sensor-on-microsoft-band

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!