Exemple #1
0
        public override async void Initialize()
        {
            try
            {
                await accelerometer.Initialize(accelerometer.SensorServiceUuid);

                await accelerometer.EnableSensor();

                await accelerometer.EnableNotifications();

                Debug.WriteLine("Accelerometer enabled");

                await humidity.Initialize(humidity.SensorServiceUuid);

                await humidity.EnableSensor();

                await humidity.EnableNotifications();

                Debug.WriteLine("Humidity enabled");

                await pressure.Initialize(pressure.SensorServiceUuid);

                await pressure.EnableSensor();

                await pressure.EnableNotifications();

                Debug.WriteLine("Pressure enabled");

                await temperature.Initialize(temperature.SensorServiceUuid);

                await temperature.EnableSensor();

                await temperature.EnableNotifications();

                Debug.WriteLine("Temperature enabled");

                await key.Initialize(key.SensorServiceUuid);

                await key.EnableSensor();

                await key.EnableNotifications();

                Debug.WriteLine("Simple Key Service enabled");
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
Exemple #2
0
        public override async void Initialize()
        {
            Debug.WriteLine("*CC2541Sensor::Initialize: enter");
            try
            {
                if (await accelerometer.Initialize(accelerometer.SensorServiceUuid))
                {
                    await accelerometer.EnableSensor();

                    await accelerometer.EnableNotifications();

                    Debug.WriteLine("Accelerometer enabled");
                }
                else
                {
                    Debug.WriteLine("accelerometer doesn't exists");
                }

                if (await humidity.Initialize(humidity.SensorServiceUuid))
                {
                    await humidity.EnableSensor();

                    await humidity.EnableNotifications();

                    Debug.WriteLine("Humidity enabled");
                }
                else
                {
                    Debug.WriteLine("humidity doesn't exists");
                }

                if (await pressure.Initialize(pressure.SensorServiceUuid))
                {
                    await pressure.EnableSensor();

                    await pressure.EnableNotifications();

                    Debug.WriteLine("Pressure enabled");
                }
                else
                {
                    Debug.WriteLine("pressure doesn't exists");
                }

                if (await temperature.Initialize(temperature.SensorServiceUuid))
                {
                    await temperature.EnableSensor();

                    await temperature.EnableNotifications();

                    Debug.WriteLine("Temperature enabled");
                }
                else
                {
                    Debug.WriteLine("temperature doesn't exists");
                }

                if (await key.Initialize(key.SensorServiceUuid))
                {
                    await key.EnableSensor();

                    await key.EnableNotifications();

                    Debug.WriteLine("Simple Key Service enabled");
                }
                else
                {
                    Debug.WriteLine("Simple Key doesn't exists");
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
            Debug.WriteLine("*CC2541Sensor::Initialize: exit");
        }