问题
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