Esempio n. 1
0
    private void registerSensorsListeners()
    {
        int index = 1;

        foreach (SA.Fitness.DataSource source in dataSources)
        {
            Debug.Log("Data Source #" + index);
            Debug.Log(source.DataSourceType);
            Debug.Log(source.AppPackageName);
            Debug.Log(source.DataType);
            Debug.Log(source.Device);
            Debug.Log(source.Name);
            Debug.Log(source.StreamId);
            Debug.Log(source.StreamName);

            SA.Fitness.SensorListener.Builder builder = new SA.Fitness.SensorListener.Builder()
                                                        .SetDataType(source.DataType)
                                                        .SetSamplingRate(5U, SA.Fitness.TimeUnit.Seconds);
            SA.Fitness.SensorListener listener = builder.Build();
            listener.OnRegisterSuccess   += Listener_OnRegisterSuccess;
            listener.OnRegisterFail      += Listener_OnRegisterFail;
            listener.OnDataPointReceived += Listener_OnDataPointReceived;
            SA.Fitness.Sensors.Instance.RegisterSensorListener(listener);

            index++;
        }
    }
Esempio n. 2
0
        public void RegisterSensorListener(SensorListener listener)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append(listener.Id);
            builder.Append(Connection.SEPARATOR2);
            builder.Append(listener.DataType.Value);
            builder.Append(Connection.SEPARATOR2);
            builder.Append(listener.RateAmount.ToString());
            builder.Append(Connection.SEPARATOR2);
            builder.Append(listener.RateTimeUnit.ToString());

            listeners.Add(listener.Id, listener);
            Proxy.RegisterSensorListener(builder.ToString());
        }