Example #1
0
        /// <summary>
        ///     Updates the BLE settings.
        /// </summary>
        public async void UpdateBLESettings(BLEChar blechar)
        {
            try {
                if (Settings != null && _temperatureService != null && _measurementScaleChar != null &&
                    _measurementTimeChar != null && _autooffIntervalChar != null && _sleepTimeChar != null)
                {
                    switch (blechar)
                    {
                    case BLEChar.Scale:
                        _measurementScaleChar.Write(Settings.Scale == 0 ? new byte[] { 0x43 } : new byte[] { 0x46 });
                        break;

                    case BLEChar.Time:
                        StopTemperatureReading = true;
                        _measurementTimeChar.Write(new[] { Convert.ToByte(Settings.MeasurementLevel) });
                        break;

                    case BLEChar.AutoOff:
                        _autooffIntervalChar.Write(new[] { Convert.ToByte(Settings.AutoOff) });
                        break;

                    case BLEChar.Sleep:
                        _sleepTimeChar.Write(new[] { Convert.ToByte(Settings.Sleep) });
                        break;

                    case BLEChar.Prob:
                        var bytes = HACCPUtil.GetBytesFromString(Settings.Prob);
                        _probeNameChar.Write(bytes);
                        break;
                    }
                }
            } catch (Exception) {
                Debug.WriteLine("Error on updating BLE settings");
            }
        }
Example #2
0
        /// <summary>
        ///     Method for updating ble settings
        /// </summary>
        /// <param name="chr"></param>
        /// <param name="value"></param>
        public async Task UpdateBLESettings(BLEChar chr, string value)
        {
            try
            {
                switch (chr)
                {
                case BLEChar.Scale:
                    if (measurementScaleChar != null)
                    {
                        await measurementScaleChar.WriteMessageAsync(value);
                    }
                    break;

                case BLEChar.Time:
                    if (measurementTimeChar != null)
                    {
                        await measurementTimeChar.WriteMessageAsync(value);
                    }
                    break;

                case BLEChar.AutoOff:
                    if (autooffChar != null)
                    {
                        await autooffChar.WriteMessageAsync(value);
                    }
                    break;

                case BLEChar.Sleep:
                    if (sleepChar != null)
                    {
                        await sleepChar.WriteMessageAsync(value);
                    }
                    break;

                case BLEChar.Prob:
                    if (probChar != null)
                    {
                        probChar.UpdateProbe(value);
                    }
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error UpdateBLESettings : {0}", ex.Message);
            }
        }
Example #3
0
        /// <summary>
        /// Update BLE Settings
        /// </summary>
        /// <param name="blechar"></param>
        /// <returns></returns>
        public async Task UpdateBLESettings(BLEChar blechar)
        {
            if (Settings == null)
            {
                return;
            }

            switch (blechar)
            {
            case BLEChar.Scale:
                await
                GlobalSettings.UpdateBLESettings(blechar,
                                                 SharedInstance.Settings.Scale == (short)0? "67" : "70");

                break;

            case BLEChar.Time:
                await GlobalSettings.UpdateBLESettings(blechar, SharedInstance.Settings.MeasurementLevel.ToString());

                break;

            case BLEChar.AutoOff:
                await GlobalSettings.UpdateBLESettings(blechar, SharedInstance.Settings.AutoOff.ToString());

                break;

            case BLEChar.Sleep:
                await GlobalSettings.UpdateBLESettings(blechar, SharedInstance.Settings.Sleep.ToString());

                break;

            case BLEChar.Prob:
                await GlobalSettings.UpdateBLESettings(blechar, SharedInstance.Settings.Prob);

                break;
            }
        }