0

我的 windows phone 连接到多个频段。我想读取传感器信号并记录所有波段。我想知道如何在 sensor_ReadingChanged 方法中获取波段 ID 或名称。还是有其他方法?我正在使用 C#。

    async void sensor_ReadingChanged(object sender, Microsoft.Band.Sensors.BandSensorReadingEventArgs<Microsoft.Band.Sensors.IBandHeartRateReading> e)
    {
        string bandname = "" //how to get the name/id of the band
        string msg = bandname + "\theartrate\t" + e.SensorReading.Timestamp.ToString() + "\t" + e.SensorReading.HeartRate.ToString() + Environment.NewLine;
        await SendSignal(msg); //record heart rate from this band
    }
4

1 回答 1

0

您可以尝试使用反射来发现乐队的身份;就像是:

        _bandClient.SensorManager.HeartRate.ReadingChanged += async (obj, ev) =>
        {
            var type = obj.GetType();
            var props = type.GetRuntimeProperties().Where(p => p.Name == "ClientHandle").First();
            var bc = (IBandClient)props.GetValue(obj);

            // compare with cached band client references
            if (object.ReferenceEquals(bc, _bandClient))
            {
            }
        }
于 2015-07-25T17:23:47.213 回答