//EventHandler<CharacteristicReadEventArgs> valueUpdatedHandler; public CharacteristicDetail_Hrm(IAdapter adapter, IDevice device, IService service, ICharacteristic characteristic) { InitializeComponent(); _characteristic = characteristic; Title = characteristic.Name; if (characteristic.CanUpdate) { characteristic.ValueUpdated += (s, e) => { Debug.WriteLine("characteristic.ValueUpdated"); Device.BeginInvokeOnMainThread(() => { UpdateDisplay(characteristic); }); // IsBusy = false; // [thread issue] only spin until the first result is received }; IsBusy = true; characteristic.StartUpdates(); } }
protected override async void OnAppearing() { base.OnAppearing(); if (characteristic.CanUpdate) { // NOTIFY-UPDATE valueUpdatedHandler = (s, e) => { Debug.WriteLine("-- _valueUpdatedHandler: " + e.Characteristic.Value); Device.BeginInvokeOnMainThread(() => { UpdateDisplay(e.Characteristic); SensorValue.Text = Decode(e.Characteristic); }); }; characteristic.ValueUpdated += valueUpdatedHandler; // request the value to be read characteristic.StartUpdates(); } else if (characteristic.CanRead) { var c = await characteristic.ReadAsync(); UpdateDisplay(c); } }
private Task <byte[]> GetCharacteristicValue( ICharacteristic characteristic) { var taskCompletionSource = new TaskCompletionSource <byte[]>(); EventHandler <CharacteristicReadEventArgs> handler = null; handler = (sender, args) => { Platform.Current.RunOnMainThread(() => { characteristic.ValueUpdated -= handler; characteristic.StopUpdates(); if (!taskCompletionSource.Task.IsCompleted) { taskCompletionSource.SetResult( args.Characteristic.Value); } }); }; characteristic.ValueUpdated += handler; characteristic.StartUpdates(); return(taskCompletionSource.Task); }
async void _adapter_DeviceConnected(object sender, DeviceConnectionEventArgs e) { var service = await e.Device.GetServiceAsync(Guid.Parse("ffe0ecd2-3d16-4f8d-90de-e89e7fc396a5")); _characteristic = await service.GetCharacteristicAsync(Guid.Parse("d8de624e-140f-4a22-8594-e2216b84a5f2")); _characteristic.StartUpdates(); _characteristic.ValueUpdated += _characteristic_ValueUpdated; _device = e.Device; }
async void _adapter_DeviceConnected(object sender, DeviceConnectionEventArgs e) { var service = await e.Device.GetServiceAsync(Guid.Parse("ffe0ecd2-3d16-4f8d-90de-e89e7fc396a5")); _characteristic = await service.GetCharacteristicAsync(Guid.Parse("d8de624e-140f-4a22-8594-e2216b84a5f2")); _characteristic.StartUpdates(); _characteristic.ValueUpdated += _characteristic_ValueUpdated; _device = e.Device; }
//De sensor aanzetten en zorgen dat we updates krijgen public void Start() { characteristicConfig.Write(new byte[] { 0xF7, 0x00 }); //characteristicPeriod.Write(new byte[] { 0x0A }); if (characteristicData.CanUpdate) { characteristicData.ValueUpdated += CharacteristicData_ValueUpdated; } characteristicData.StartUpdates(); }
public void ProcessCommands() { Debug.WriteLine("SyncDeviceHandlerStriiv: ProcessCommands"); if (this.ProcessQeueue.Count > 0) { Command = this.ProcessQeueue.Dequeue(); } else { Debug.WriteLine("No more commands to be processed!"); return; } ICharacteristic chr = null; switch (Command) { case Constants.StriivSyncHandlerSequence.EnableFE23: Debug.WriteLine("SyncDeviceHandlerSTRIIV: Enabling FE23 characteristic"); CharFE23 = GetServicesCharacteristic(Constants.CharacteristicsUUID._FE23); if (CharFE23 == null) { Debug.WriteLine("FE23 is NULL. Disconnecting device."); this.Adapter.DisconnectDevice(Device); } else { CharFE23.StartUpdates(); } break; case Constants.StriivSyncHandlerSequence.RegisterRead: Debug.WriteLine("Register Read Command"); CommandRequest = new byte[] { 0x06 }; this.Adapter.SendCommand(Char9A0A, CommandRequest); break; case Constants.StriivSyncHandlerSequence.RegisterWrite: Debug.WriteLine("Register Write Time"); //CommandRequest = new byte[] { 0x81, 0x00, 0x00, 0x00, 0x30, 0x1E, 0x02, 0x16, 0x07, 0x07, 0xE0 }; CommandRequest = new byte[] { 0x00 }; this.Adapter.SendCommand(Char9A0A, CommandRequest); break; default: Debug.WriteLine("Invalid command request..."); break; } }
// <summary> // Enable all notifications for a device // </summary> // <param name="device">The device we want to enable all notifications</param> async Task EnableNotifications(IDevice device) { foreach (Sensor sensor in _sensorList) { IService service = await device.GetServiceAsync(sensor.sensorService); ICharacteristic characteristic = await service.GetCharacteristicAsync(sensor.sensorData); if (characteristic.CanUpdate) { characteristic.ValueUpdated += _valueUpdatedHandler; characteristic.StartUpdates(); } } }
async Task InitializeAsync () { Debug.WriteLine ("LEStream: Looking for service " + ServiceId + "..."); service = await device.GetServiceAsync (ServiceId); Debug.WriteLine ("LEStream: Got service: " + service.ID); Debug.WriteLine ("LEStream: Getting characteristics..."); receive = await service.GetCharacteristicAsync (ReceiveCharId); transmit = await service.GetCharacteristicAsync (TransmitCharId); reset = await service.GetCharacteristicAsync (ResetCharId); Debug.WriteLine ("LEStream: Got characteristics"); receive.ValueUpdated += HandleReceiveValueUpdated; receive.StartUpdates (); }
public CharacteristicDetail (IAdapter adapter, IDevice device, IService service, ICharacteristic characteristic) { InitializeComponent (); this.characteristic = characteristic; if (characteristic.CanUpdate) { characteristic.ValueUpdated += (s, e) => { Debug.WriteLine("characteristic.ValueUpdated"); Device.BeginInvokeOnMainThread( () => { UpdateDisplay(characteristic); }); }; characteristic.StartUpdates(); } }
public CharacteristicDetail(IAdapter adapter, IDevice device, IService service, ICharacteristic characteristic) { InitializeComponent(); this.characteristic = characteristic; if (characteristic.CanUpdate) { characteristic.ValueUpdated += (s, e) => { Debug.WriteLine("characteristic.ValueUpdated"); Device.BeginInvokeOnMainThread(() => { UpdateDisplay(characteristic); }); }; characteristic.StartUpdates(); } }
private async void _adapter_DeviceDiscovered(object sender, Plugin.BLE.Abstractions.EventArgs.DeviceEventArgs e) { if (_status == Status.STATUS_SCANNING_FOR_DEVICE) { _log("_adapter_DeviceDiscovered", $"Device {e.Device.Name}"); if (e.Device.Name == _deviceName) { try { _device = e.Device; await _adapter.ConnectToDeviceAsync(_device); _serviceHR = await e.Device.GetServiceAsync(SERVICE_HEARTRATE); _characteristicHR = await _serviceHR?.GetCharacteristicAsync(CHARACTERISTIC_HEARTRATE); _serviceBattery = await e.Device.GetServiceAsync(SERVICE_BATTERY); if (_serviceBattery != null) { _characteristicBatteryLevel = await _serviceBattery?.GetCharacteristicAsync(CHARACTERISTIC_BATTERYLEVEL); } else { _characteristicBatteryLevel = null; } if (_characteristicHR != null) { _status = Status.STATUS_CONNECTED; _cancelScanningForDevice(); _characteristicHR.ValueUpdated += CharacteristicHR_ValueUpdated; _characteristicHR.StartUpdates(); _log("_adapter_DeviceDiscovered", $"Device {e.Device.Name} STARTED"); } } catch (Exception err) { _log("_adapter_DeviceDiscovered", err.Message); } } } }
private async Task InitializeAsync() { Debug.WriteLine("LEStream: Looking for service " + ServiceId + "..."); service = await device.GetServiceAsync(ServiceId); Debug.WriteLine("LEStream: Got service: " + service.ID); Debug.WriteLine("LEStream: Getting characteristics..."); receive = await service.GetCharacteristicAsync(ReceiveCharId); transmit = await service.GetCharacteristicAsync(TransmitCharId); reset = await service.GetCharacteristicAsync(ResetCharId); Debug.WriteLine("LEStream: Got characteristics"); receive.ValueUpdated += HandleReceiveValueUpdated; receive.StartUpdates(); }
public CharacteristicDetail (IAdapter adapter, IDevice device, IService service, ICharacteristic characteristic) { InitializeComponent (); this.characteristic = characteristic; if (characteristic.CanUpdate) { characteristic.ValueUpdated += (s, e) => { Debug.WriteLine("characteristic.ValueUpdated"); Device.BeginInvokeOnMainThread( () => { IsBusy = false; // only spin until the first result is received UpdateDisplay(characteristic); }); }; IsBusy = true; characteristic.StartUpdates(); } }
private void CharacteristicsDiscovered(object sender, EventArgs e) { SerialBLEService.CharacteristicsDiscovered -= CharacteristicsDiscovered; foreach (var characteristic in SerialBLEService.Characteristics) { if (characteristic.Uuid.ToLower().Equals(CHARACTERISTIC_UUID_RX.ToLower())) { SerialRX = characteristic; SerialRX.StartUpdates(); SerialRX.ValueUpdated += CharacteristicValueUpdated; } if (characteristic.Uuid.ToLower().Equals(CHARACTERISTIC_UUID_TX.ToLower())) { SerialTX = characteristic;//this is used to write to the device } } bool temp = SerialRX.CanRead; bool temp1 = SerialTX.CanRead; }
public TxRx(ICharacteristic characteristic) { InitializeComponent(); this.characteristic = characteristic; var result = characteristic.Properties & CharacteristicPropertyType.Notify; if (characteristic.CanRead) { characteristic.StartUpdates(); characteristic.ValueUpdated += CharacteristicValueUpdated; } if ((characteristic.Properties & CharacteristicPropertyType.Notify) != 0) { } btnSend.Clicked += BtnSendClicked; }
protected override async void OnAppearing() { base.OnAppearing(); UserDialogs.Instance.ShowLoading("Read values..."); service = await device.GetServiceAsync(Guid.Parse("f0010200-f001-f001-f001-f001f001f001")); uuidCharacteristic = await service.GetCharacteristicAsync(Guid.Parse("f0010201-f001-f001-f001-f001f001f001")); uuidCharacteristic.ValueUpdated += UuidCharacteristic_ValueUpdated; if (uuidCharacteristic.CanUpdate) { uuidCharacteristic.StartUpdates(); } ReadUUID(); await Task.Delay(1000); majorCharacteristic = await service.GetCharacteristicAsync(Guid.Parse("f0010202-f001-f001-f001-f001f001f001")); majorCharacteristic.ValueUpdated += MajorCharacteristic_ValueUpdated; if (majorCharacteristic.CanUpdate) { majorCharacteristic.StartUpdates(); } ReadMajor(); await Task.Delay(1000); minorCharacteristic = await service.GetCharacteristicAsync(Guid.Parse("f0010203-f001-f001-f001-f001f001f001")); minorCharacteristic.ValueUpdated += MinorCharacteristic_ValueUpdated; if (minorCharacteristic.CanUpdate) { minorCharacteristic.StartUpdates(); } ReadMinor(); UserDialogs.Instance.HideLoading(); }
public void CheckMyCharacteristic(ICharacteristic characteristic) { characteristic.StartUpdates(); }
public void CheckMyCharacteristic(ICharacteristic characteristic) { characteristic.StartUpdates(); }
public override void ViewDidLoad() { base.ViewDidLoad(); Title = "CharacteristicDetail"; View.BackgroundColor = UIColor.White; _characteristicNameText = new UILabel(new RectangleF(10, 70, 300, 60)); _characteristicIDText = new UILabel(new RectangleF(10, 100, 300, 60)); _rawValueText = new UILabel(new RectangleF(10, 130, 300, 60)); _stringValueText = new UILabel(new RectangleF(10, 160, 300, 60)); //_valueUdpatedDateTime = new UILabel (new RectangleF (10, 190, 300, 60)); _rawValueText.Text = "raw"; _stringValueText.Text = "string"; //_valueUdpatedDateTime.Text = "-"; // populate our page this._characteristicNameText.Text = _characteristic.Name; this._characteristicIDText.Text = _characteristic.ID.ToString(); Add(_characteristicNameText); Add(_characteristicIDText); Add(_rawValueText); Add(_stringValueText); //Add (_valueUdpatedDateTime); // NOTIFY-UPDATE this._valueUpdatedHandler = (s, e) => { Console.WriteLine("-- _valueUpdatedHandler: " + e.Characteristic.Value); this.InvokeOnMainThread(() => { this.PopulateValueInfo(); }); }; // request the value to be read _characteristic.StartUpdates(); // READ var @type = new UILabel(new RectangleF(150, 250, 300, 60)); var read = UIButton.FromType(UIButtonType.System); read.Frame = new RectangleF(10, 250, 50, 30); read.SetTitle("Read", UIControlState.Normal); read.TouchUpInside += async(sender, e) => { @type.Text = "before"; var c = await _characteristic.ReadAsync(); @type.Text = "value:" + c.StringValue; }; if (_characteristic.CanRead) { Add(@type); Add(read); } // // WRITE // var write = UIButton.FromType (UIButtonType.System); // write.Frame = new RectangleF (10, 300, 100, 30); // write.SetTitle ("Write On", UIControlState.Normal); // write.TouchUpInside += (sender, e) => { // _characteristic.Write(new byte[] {0x01}); // }; // // var writeoff = UIButton.FromType (UIButtonType.System); // writeoff.Frame = new RectangleF (120, 300, 100, 30); // writeoff.SetTitle ("Write Off", UIControlState.Normal); // writeoff.TouchUpInside += (sender, e) => { // _characteristic.Write(new byte[] {0x00}); // }; // if (_characteristic.CanWrite) { // Add (write); // Add (writeoff); // } }
public override void ViewDidLoad() { base.ViewDidLoad(); Title = "CharacteristicDetail"; View.BackgroundColor = UIColor.White; var label = new UILabel(new RectangleF(10, 100, 300, 60)); label.Text = "Characteristic: " + _connectedDevice.Name + "\n" + _currentService.Name + "\n" + _characteristic.Name; label.Lines = 3; Add(label); var labelHR = new UILabel(new RectangleF(50, 200, 300, 100)); labelHR.Font = UIFont.BoldSystemFontOfSize(48); labelHR.TextColor = UIColor.Red; labelHR.Text = "- bpm"; labelHR.Lines = 3; Add(labelHR); // request the value to be read _characteristic.StartUpdates(); ((CBPeripheral)_connectedDevice.NativeDevice).UpdatedCharacterteristicValue += (object sender, CBCharacteristicEventArgs e) => { Console.WriteLine("UpdatedCharacterteristicValue:" + e.Characteristic.Description + " " + e.Characteristic.Value); if (e.Characteristic.Value != null) { var data = e.Characteristic.Value; byte[] dataBytes = new byte[data.Length]; System.Runtime.InteropServices.Marshal.Copy(data.Bytes, dataBytes, 0, Convert.ToInt32(data.Length)); if (dataBytes.Length == 1) { // position var position = dataBytes[0]; var locationString = "-"; Console.WriteLine("----------------------position:" + position); // https://developer.apple.com/library/mac/samplecode/HeartRateMonitor/Listings/HeartRateMonitor_HeartRateMonitorAppDelegate_m.html switch (position) { case 0: locationString = @"Other"; break; case 1: locationString = @"Chest"; break; case 2: locationString = @"Wrist"; break; case 3: locationString = @"Finger"; break; case 4: locationString = @"Hand"; break; case 5: locationString = @"Ear Lobe"; break; case 6: locationString = @"Foot"; break; default: locationString = @"Reserved"; break; } labelHR.Text = "on " + locationString; } else { // heartrate ushort bpm = 0; //http://www.raywenderlich.com/52080/introduction-core-bluetooth-building-heart-rate-monitor //https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.heart_rate_measurement.xml if ((dataBytes[0] & 0x01) == 0) { bpm = (ushort)dataBytes[1]; } else { bpm = (ushort)dataBytes [1]; bpm = (ushort)(((bpm >> 8) & 0xFF) | ((bpm << 8) & 0xFF00)); } Console.WriteLine("--------------------------hr:" + bpm); InvokeOnMainThread(() => { labelHR.Text = bpm + " bpm"; }); } } }; Console.WriteLine("ReadValue"); ((CBPeripheral)_connectedDevice.NativeDevice).ReadValue((CBCharacteristic)_characteristic.NativeCharacteristic); Console.WriteLine("SetNotifyValue"); ((CBPeripheral)_connectedDevice.NativeDevice).SetNotifyValue(true, ((CBCharacteristic)_characteristic.NativeCharacteristic)); }
public void ProcessCommands() { Debug.WriteLine("SyncHandler: ProcessCommands"); if (this.processQeueue.Count > 0) { command = this.processQeueue.Dequeue(); } else { Debug.WriteLine("No more commands to be processed!"); return; } switch (command) { case Constants.SyncHandlerSequence.EnableFF07: Debug.WriteLine("SyncDeviceHandler961: Enabling FF07 characteristic"); ff07Char = GetServicesCharacterisitic(Constants.CharacteristicsUUID._FF07); ff07Char.StartUpdates(); Task.Delay(500); ProcessCommands(); break; case Constants.SyncHandlerSequence.EnableFF08: Debug.WriteLine("SyncDeviceHandler961: Enabling FF08 characteristic"); ff08Char = GetServicesCharacterisitic(Constants.CharacteristicsUUID._FF08); ff08Char.StartUpdates(); Task.Delay(500); ProcessCommands(); break; case Constants.SyncHandlerSequence.ReadModel: Debug.WriteLine("SyncDeviceHandler961: Reading model from characteristic."); readChar = GetServicesCharacterisitic(Constants.CharacteristicsUUID._2A24); readChar.ReadAsync(); break; case Constants.SyncHandlerSequence.ReadSerial: Debug.WriteLine("SyncDeviceHandler961: Reading serial from characterisitic."); readChar = GetServicesCharacterisitic(Constants.CharacteristicsUUID._2A25); readChar.ReadAsync(); break; case Constants.SyncHandlerSequence.ReadFwVersion: Debug.WriteLine("SyncDeviceHandler961: Reading fw version from characteristic."); readChar = GetServicesCharacterisitic(Constants.CharacteristicsUUID._2A26); readChar.ReadAsync(); break; case Constants.SyncHandlerSequence.ReadManufacturer: Debug.WriteLine("SyncDeviceHandler961: Reading manufacturer from characteristic."); readChar = GetServicesCharacterisitic(Constants.CharacteristicsUUID._2A29); readChar.ReadAsync(); break; case Constants.SyncHandlerSequence.ReadBatteryLevel: Debug.WriteLine("SyncDeviceHandler961: Reading battery level from characteristic."); readChar = GetServicesCharacterisitic(Constants.CharacteristicsUUID._2A19); readChar.ReadAsync(); break; default: Debug.WriteLine("SyncDeviceHandler961: Unable to identify command."); break; } }
public void ProcessCommands() { Debug.WriteLine("SyncHandler: ProcessCommands"); if (this.processQeueue.Count > 0) { command = this.processQeueue.Dequeue(); } else { Debug.WriteLine("No more commands to be processed!"); return; } switch (command) { case Constants.SyncHandlerSequence.EnableFF07: Debug.WriteLine("SyncDeviceHandler961: Enabling FF07 characteristic"); ff07Char = GetServicesCharacterisitic(Constants.CharacteristicsUUID._FF07); ff07Char.StartUpdates(); Task.Delay(500); ProcessCommands(); break; case Constants.SyncHandlerSequence.EnableFF08: Debug.WriteLine("SyncDeviceHandler961: Enabling FF08 characteristic"); ff08Char = GetServicesCharacterisitic(Constants.CharacteristicsUUID._FF08); ff08Char.StartUpdates(); Task.Delay(500); ProcessCommands(); break; case Constants.SyncHandlerSequence.ReadModel: Debug.WriteLine("SyncDeviceHandler961: Reading model from characteristic."); readChar = GetServicesCharacterisitic(Constants.CharacteristicsUUID._2A24); readChar.ReadAsync(); break; case Constants.SyncHandlerSequence.ReadSerial: Debug.WriteLine("SyncDeviceHandler961: Reading serial from characterisitic."); readChar = GetServicesCharacterisitic(Constants.CharacteristicsUUID._2A25); readChar.ReadAsync(); break; case Constants.SyncHandlerSequence.ReadFwVersion: Debug.WriteLine("SyncDeviceHandler961: Reading fw version from characteristic."); readChar = GetServicesCharacterisitic(Constants.CharacteristicsUUID._2A26); readChar.ReadAsync(); break; case Constants.SyncHandlerSequence.ReadManufacturer: Debug.WriteLine("SyncDeviceHandler961: Reading manufacturer from characteristic."); readChar = GetServicesCharacterisitic(Constants.CharacteristicsUUID._2A29); readChar.ReadAsync(); break; case Constants.SyncHandlerSequence.ReadBatteryLevel: Debug.WriteLine("SyncDeviceHandler961: Reading battery level from characteristic."); readChar = GetServicesCharacterisitic(Constants.CharacteristicsUUID._2A19); readChar.ReadAsync(); break; default: Debug.WriteLine("SyncDeviceHandler961: Unable to identify command."); break; } }
public async void ProcessCommands() { Debug.WriteLine("SyncHandler: ProcessCommands"); if (this.ProcessQeueue.Count > 0) { Command = this.ProcessQeueue.Dequeue(); } else { Debug.WriteLine("No more commands to be processed! Disconnecting device."); this.Adapter.DisconnectDevice(this.Device); return; } ICharacteristic chr = null; switch (Command) { case Constants.SyncHandlerSequence.EnableFF07: Debug.WriteLine("SyncDeviceHandler961: Enabling FF07 characteristic"); Ff07Char = GetServicesCharacteristic(Constants.CharacteristicsUUID._FF07); if (Ff07Char == null) { Debug.WriteLine("FF07 is NULL. Disconnecting device."); this.Adapter.DisconnectDevice(Device); } else { Ff07Char.StartUpdates(); } break; case Constants.SyncHandlerSequence.EnableFF08: Debug.WriteLine("SyncDeviceHandler961: Enabling FF08 characteristic"); Ff08Char = GetServicesCharacteristic(Constants.CharacteristicsUUID._FF08); if (Ff08Char == null) { Debug.WriteLine("FF08 is NULL. Disconnecting device."); this.Adapter.DisconnectDevice(Device); } else { Ff08Char.StartUpdates(); } break; case Constants.SyncHandlerSequence.ReadModel: Debug.WriteLine("SyncDeviceHandler961: Reading model from characteristic."); ReadChar = GetServicesCharacteristic(Constants.CharacteristicsUUID._2A24); chr = await ReadChar.ReadAsync(); int num = 0; Debug.WriteLine("Model: " + num); int.TryParse(System.Text.Encoding.UTF8.GetString(chr.Value, 0, chr.Value.Length).Replace("PE", "").Replace("FT", ""), out num); this.TrioDeviceInformationInstance.ModelNumber = num; ProcessCommands(); break; case Constants.SyncHandlerSequence.ReadSerial: Debug.WriteLine("SyncDeviceHandler961: Reading serial from characterisitic."); ReadChar = GetServicesCharacteristic(Constants.CharacteristicsUUID._2A25); chr = await ReadChar.ReadAsync(); long serial = 0; long.TryParse(System.Text.Encoding.UTF8.GetString(chr.Value, 0, chr.Value.Length), out serial); Debug.WriteLine("Serial: " + serial); this.TrioDeviceInformationInstance.SerialNumber = serial; ProcessCommands(); break; case Constants.SyncHandlerSequence.ReadFwVersion: Debug.WriteLine("SyncDeviceHandler961: Reading fw version from characteristic."); ReadChar = GetServicesCharacteristic(Constants.CharacteristicsUUID._2A26); chr = await ReadChar.ReadAsync(); float fwVer = 0; float.TryParse(System.Text.Encoding.UTF8.GetString(chr.Value, 0, chr.Value.Length), out fwVer); Debug.WriteLine("Firmware Version: " + fwVer); this.TrioDeviceInformationInstance.FirmwareVersion = fwVer; ProcessCommands(); break; case Constants.SyncHandlerSequence.ReadManufacturer: Debug.WriteLine("SyncDeviceHandler961: Reading manufacturer from characteristic."); this.StartIncrementProgress = true; ReadChar = GetServicesCharacteristic(Constants.CharacteristicsUUID._2A29); chr = await ReadChar.ReadAsync(); Debug.WriteLine("Manufacturer: " + System.Text.Encoding.UTF8.GetString(chr.Value, 0, chr.Value.Length)); ProcessCommands(); break; case Constants.SyncHandlerSequence.ReadBatteryLevel: Debug.WriteLine("SyncDeviceHandler961: Reading battery level from characteristic."); ReadChar = GetServicesCharacteristic(Constants.CharacteristicsUUID._2A19); chr = await ReadChar.ReadAsync(); int battery = (int)chr.Value[0]; Debug.WriteLine("Battery Level: " + battery); this.TrioDeviceInformationInstance.BatteryLevel = battery; ProcessCommands(); break; case Constants.SyncHandlerSequence.ReadTallies: Debug.WriteLine("SyncDeviceHandler961: Read Device Tallies"); CommandRequest = new byte[] { 0x1B, 0x5D }; this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadDeviceInformation: Debug.WriteLine("SyncDeviceHandler961: Read Device Information"); CommandRequest = new byte[] { 0x1B, 0x40 }; this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadDeviceStatus: Debug.WriteLine("SyncDeviceHandler961: Read Device Status"); CommandRequest = new byte[] { 0x1B, 0x13 }; this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadDeviceSettings: Debug.WriteLine("SyncDeviceHandler961: Read Device Settings"); CommandRequest = new byte[] { 0x1B, 0x17 }; this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadUserSettings: Debug.WriteLine("SyncDeviceHandler961: Read User Settings"); //CommandRequest = new byte[] { 0x1B, 0x19 }; CommandRequest = await UserSettingsInstance.GetReadCommand(); Debug.WriteLine("Read User Settings: " + Motion.Mobile.Utilities.Utils.ByteArrayToHexString(CommandRequest)); this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadStepsHeader: Debug.WriteLine("SyncDeviceHandler961: Read Steps Header"); CommandRequest = new byte[] { 0x1B, 0x22 }; this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadSeizureTable: Debug.WriteLine("SyncDeviceHandler961: Read Seizure Table"); break; case Constants.SyncHandlerSequence.ReadHourlySteps: Debug.WriteLine("SyncDeviceHandler961: Read Steps Header"); //CommandRequest = new byte[] { 0x1B, 0x24, 0x }; this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadCurrentHour: Debug.WriteLine("SyncDeviceHandler961: Read Current Hour"); CommandRequest = new byte[] { 0x1B, 0x27 }; this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadSignature: Debug.WriteLine("SyncDeviceHandler961: Read Signature Data"); //CommandRequest = new byte[] { 0x1B, 0x27 }; this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadSeizure: Debug.WriteLine("SyncDeviceHandler961: Read seizure Data"); break; case Constants.SyncHandlerSequence.WriteStepsHeader: Debug.WriteLine("SyncDeviceHandler961: Writing steps header"); break; case Constants.SyncHandlerSequence.WriteDeviceSettings: Debug.WriteLine("SyncDeviceHandler961: Writing device settings"); break; case Constants.SyncHandlerSequence.WriteUserSettings: Debug.WriteLine("SyncDeviceHandler961: Writing user settings"); break; case Constants.SyncHandlerSequence.WriteExerciseSettings: Debug.WriteLine("SyncDeviceHandler961: Writing exercise settings"); break; case Constants.SyncHandlerSequence.WriteCompanySettings: Debug.WriteLine("SyncDeviceHandler961: Writing company settings"); break; case Constants.SyncHandlerSequence.WriteSignatureSettings: Debug.WriteLine("SyncDeviceHandler961: Writing signature settings"); break; case Constants.SyncHandlerSequence.WriteSeizureSettings: Debug.WriteLine("SyncDeviceHandler961: Writing seizure settings"); break; case Constants.SyncHandlerSequence.WriteScreenFlow: Debug.WriteLine("SyncDeviceHandler961: Writing screenflow settings"); break; case Constants.SyncHandlerSequence.WriteDeviceSensitivity: Debug.WriteLine("SyncDeviceHandler961: Writing device sensitivity settings"); break; case Constants.SyncHandlerSequence.WriteDeviceStatus: Debug.WriteLine("SyncDeviceHandler961: Writing device status settings"); break; case Constants.SyncHandlerSequence.WriteScreenDisplay: Debug.WriteLine("SyncDeviceHandler961: Writing screen display"); break; case Constants.SyncHandlerSequence.ClearEEProm: Debug.WriteLine("SyncDeviceHandler961: Clear eeprom"); break; case Constants.SyncHandlerSequence.WsGetDeviceInfo: Debug.WriteLine("SyncDeviceHandler961: WS Request GetDeviceInfo"); //to be replaced - start Dictionary <String, object> parameter = new Dictionary <String, object>(); parameter.Add("serno", "9999999894"); parameter.Add("fwver", "4.3"); parameter.Add("mdl", "961"); parameter.Add("aid", 16781); parameter.Add("ddtm", "16-08-12 14:15"); Dictionary <string, object> dictionary = await WebService.PostData("https://test.savvysherpa.com/DeviceServices/api/Pedometer/GetDeviceInfo", parameter); //to be replaced - end string status = null; if (dictionary.ContainsKey("status")) { status = dictionary["status"].ToString(); } if (status != null && status.ToUpper().CompareTo("OK") == 0) { Debug.WriteLine("Device is paired"); this.ProcessQeueue.Enqueue(Constants.SyncHandlerSequence.ReadTallies); this.ProcessCommands(); } else { Debug.WriteLine("Device is not paired"); this.Adapter.DisconnectDevice(this.Device); } break; case Constants.SyncHandlerSequence.WsUploadTallies: break; case Constants.SyncHandlerSequence.WsUploadSteps: break; case Constants.SyncHandlerSequence.WsUploadSignature: break; case Constants.SyncHandlerSequence.WsUploadProfile: break; case Constants.SyncHandlerSequence.WsUnpairDevice: break; case Constants.SyncHandlerSequence.WsUploadSeizure: break; case Constants.SyncHandlerSequence.WsSendNotifySettingsUpdate: break; default: Debug.WriteLine("SyncDeviceHandler961: Unable to identify command."); break; } }
public async void ProcessCommands() { Debug.WriteLine("SyncHandler: ProcessCommands"); if (this.ProcessQeueue.Count > 0) { Command = this.ProcessQeueue.Dequeue(); } else { Debug.WriteLine("No more commands to be processed!"); return; } ICharacteristic chr = null; switch (Command) { case Constants.SyncHandlerSequence.EnableFF07: Debug.WriteLine("SyncDeviceHandler939: Enabling FF07 characteristic"); Ff07Char = GetServicesCharacteristic(Constants.CharacteristicsUUID._FF07); if (Ff07Char == null) { Debug.WriteLine("FF07 is NULL. Disconnecting device."); this.Adapter.DisconnectDevice(Device); } else { Ff07Char.StartUpdates(); } break; case Constants.SyncHandlerSequence.EnableFF08: Debug.WriteLine("SyncDeviceHandler939: Enabling FF08 characteristic"); Ff08Char = GetServicesCharacteristic(Constants.CharacteristicsUUID._FF08); if (Ff08Char == null) { Debug.WriteLine("FF08 is NULL. Disconnecting device."); this.Adapter.DisconnectDevice(Device); } else { Ff08Char.StartUpdates(); } break; case Constants.SyncHandlerSequence.ReadModel: Debug.WriteLine("SyncDeviceHandler939: Reading model from characteristic."); ReadChar = GetServicesCharacteristic(Constants.CharacteristicsUUID._2A24); chr = await ReadChar.ReadAsync(); Debug.WriteLine("Model: " + System.Text.Encoding.UTF8.GetString(chr.Value, 0, chr.Value.Length)); ProcessCommands(); break; case Constants.SyncHandlerSequence.ReadSerial: Debug.WriteLine("SyncDeviceHandler939: Reading serial from characterisitic."); ReadChar = GetServicesCharacteristic(Constants.CharacteristicsUUID._2A25); chr = await ReadChar.ReadAsync(); Debug.WriteLine("Serial: " + System.Text.Encoding.UTF8.GetString(chr.Value, 0, chr.Value.Length)); ProcessCommands(); break; case Constants.SyncHandlerSequence.ReadFwVersion: Debug.WriteLine("SyncDeviceHandler939: Reading fw version from characteristic."); ReadChar = GetServicesCharacteristic(Constants.CharacteristicsUUID._2A26); chr = await ReadChar.ReadAsync(); Debug.WriteLine("Firmware Version: " + System.Text.Encoding.UTF8.GetString(chr.Value, 0, chr.Value.Length)); ProcessCommands(); break; case Constants.SyncHandlerSequence.ReadManufacturer: Debug.WriteLine("SyncDeviceHandler939: Reading manufacturer from characteristic."); this.StartIncrementProgress = true; ReadChar = GetServicesCharacteristic(Constants.CharacteristicsUUID._2A29); chr = await ReadChar.ReadAsync(); Debug.WriteLine("Manufacturer: " + System.Text.Encoding.UTF8.GetString(chr.Value, 0, chr.Value.Length)); ProcessCommands(); break; case Constants.SyncHandlerSequence.ReadBatteryLevel: Debug.WriteLine("SyncDeviceHandler939: Reading battery level from characteristic."); ReadChar = GetServicesCharacteristic(Constants.CharacteristicsUUID._2A19); chr = await ReadChar.ReadAsync(); Debug.WriteLine("Battery Level: " + (int)chr.Value[0]); ProcessCommands(); break; case Constants.SyncHandlerSequence.ReadDeviceStatus: Debug.WriteLine("SyncDeviceHandler939: Read Device Status"); CommandRequest = new byte[] { 0x1B, 0x13 }; this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadDeviceSettings: Debug.WriteLine("SyncDeviceHandler939: Read Device Settings"); CommandRequest = new byte[] { 0x1B, 0x17 }; this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadUserSettings: Debug.WriteLine("SyncDeviceHandler939: Read User Settings"); CommandRequest = new byte[] { 0x1B, 0x19 }; this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadStepsHeader: Debug.WriteLine("SyncDeviceHandler939: Read Steps Header"); CommandRequest = new byte[] { 0x1B, 0x22 }; this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadSeizureTable: Debug.WriteLine("SyncDeviceHandler939: Read Seizure Table"); break; case Constants.SyncHandlerSequence.ReadHourlySteps: Debug.WriteLine("SyncDeviceHandler939: Read Steps Header"); //CommandRequest = new byte[] { 0x1B, 0x24, 0x }; this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadCurrentHour: Debug.WriteLine("SyncDeviceHandler939: Read Current Hour"); CommandRequest = new byte[] { 0x1B, 0x27 }; this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadSignature: Debug.WriteLine("SyncDeviceHandler939: Read Signature Data"); //CommandRequest = new byte[] { 0x1B, 0x27 }; this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadSeizure: Debug.WriteLine("SyncDeviceHandler939: Read seizure Data"); break; case Constants.SyncHandlerSequence.WriteStepsHeader: Debug.WriteLine("SyncDeviceHandler939: Writing steps header"); break; case Constants.SyncHandlerSequence.WriteDeviceSettings: Debug.WriteLine("SyncDeviceHandler939: Writing device settings"); break; case Constants.SyncHandlerSequence.WriteUserSettings: Debug.WriteLine("SyncDeviceHandler939: Writing user settings"); break; case Constants.SyncHandlerSequence.WriteExerciseSettings: Debug.WriteLine("SyncDeviceHandler939: Writing exercise settings"); break; case Constants.SyncHandlerSequence.WriteCompanySettings: Debug.WriteLine("SyncDeviceHandler939: Writing company settings"); break; case Constants.SyncHandlerSequence.WriteSignatureSettings: Debug.WriteLine("SyncDeviceHandler939: Writing signature settings"); break; case Constants.SyncHandlerSequence.WriteSeizureSettings: Debug.WriteLine("SyncDeviceHandler939: Writing seizure settings"); break; case Constants.SyncHandlerSequence.WriteScreenFlow: Debug.WriteLine("SyncDeviceHandler939: Writing screenflow settings"); break; case Constants.SyncHandlerSequence.WriteDeviceSensitivity: Debug.WriteLine("SyncDeviceHandler936: Writing device sensitivity settings"); break; case Constants.SyncHandlerSequence.WriteDeviceStatus: Debug.WriteLine("SyncDeviceHandler939: Writing device status settings"); break; case Constants.SyncHandlerSequence.WriteScreenDisplay: Debug.WriteLine("SyncDeviceHandler939: Writing screen display"); break; case Constants.SyncHandlerSequence.ClearEEProm: Debug.WriteLine("SyncDeviceHandler939: Clear eeprom"); break; case Constants.SyncHandlerSequence.WsGetDeviceInfo: Debug.WriteLine("SyncDeviceHandler939: WS Request GetDeviceInfo"); Dictionary <String, object> parameter = new Dictionary <String, object>(); parameter.Add("serno", "9999999894"); parameter.Add("fwver", "4.3"); parameter.Add("mdl", "961"); parameter.Add("aid", 16781); parameter.Add("ddtm", "16-08-12 14:15"); await WebService.PostData("https://test.savvysherpa.com/DeviceServices/api/Pedometer/GetDeviceInfo", parameter); break; default: Debug.WriteLine("SyncDeviceHandler939: Unable to identify command."); break; } if (this.ProcessQeueue.Count == 0) { Debug.WriteLine("Queue is already empty. Device will be disconnected."); this.Adapter.DisconnectDevice(this.Device); this.SyncDone(this, new SyncDoneEventArgs { Status = true }); } }
public async void ProcessCommands() { Debug.WriteLine("SyncHandler: ProcessCommands"); if (this.ProcessQeueue.Count > 0) { Command = this.ProcessQeueue.Dequeue(); } else { Debug.WriteLine("No more commands to be processed!"); return; } ICharacteristic chr = null; switch (Command) { case Constants.SyncHandlerSequence.EnableFF07: Debug.WriteLine("SyncDeviceHandler936: Enabling FF07 characteristic"); Ff07Char = GetServicesCharacteristic(Constants.CharacteristicsUUID._FF07); if (Ff07Char == null) { Debug.WriteLine("FF07 is NULL. Disconnecting device."); this.Adapter.DisconnectDevice(Device); } else { Ff07Char.StartUpdates(); } break; case Constants.SyncHandlerSequence.EnableFF08: Debug.WriteLine("SyncDeviceHandler936: Enabling FF08 characteristic"); Ff08Char = GetServicesCharacteristic(Constants.CharacteristicsUUID._FF08); if (Ff08Char == null) { Debug.WriteLine("FF08 is NULL. Disconnecting device."); this.Adapter.DisconnectDevice(Device); } else { Ff08Char.StartUpdates(); } break; case Constants.SyncHandlerSequence.ReadModel: Debug.WriteLine("SyncDeviceHandler936: Reading model from characteristic."); ReadChar = GetServicesCharacteristic(Constants.CharacteristicsUUID._2A24); chr = await ReadChar.ReadAsync(); Debug.WriteLine("Model: " + System.Text.Encoding.UTF8.GetString(chr.Value, 0, chr.Value.Length)); ProcessCommands(); break; case Constants.SyncHandlerSequence.ReadSerial: Debug.WriteLine("SyncDeviceHandler936: Reading serial from characterisitic."); ReadChar = GetServicesCharacteristic(Constants.CharacteristicsUUID._2A25); chr = await ReadChar.ReadAsync(); Debug.WriteLine("Serial: " + System.Text.Encoding.UTF8.GetString(chr.Value, 0, chr.Value.Length)); ProcessCommands(); break; case Constants.SyncHandlerSequence.ReadFwVersion: Debug.WriteLine("SyncDeviceHandler936: Reading fw version from characteristic."); ReadChar = GetServicesCharacteristic(Constants.CharacteristicsUUID._2A26); chr = await ReadChar.ReadAsync(); Debug.WriteLine("Firmware Version: " + System.Text.Encoding.UTF8.GetString(chr.Value, 0, chr.Value.Length)); ProcessCommands(); break; case Constants.SyncHandlerSequence.ReadManufacturer: Debug.WriteLine("SyncDeviceHandler936: Reading manufacturer from characteristic."); this.StartIncrementProgress = true; ReadChar = GetServicesCharacteristic(Constants.CharacteristicsUUID._2A29); chr = await ReadChar.ReadAsync(); Debug.WriteLine("Manufacturer: " + System.Text.Encoding.UTF8.GetString(chr.Value, 0, chr.Value.Length)); ProcessCommands(); break; case Constants.SyncHandlerSequence.ReadBatteryLevel: Debug.WriteLine("SyncDeviceHandler936: Reading battery level from characteristic."); ReadChar = GetServicesCharacteristic(Constants.CharacteristicsUUID._2A19); chr = await ReadChar.ReadAsync(); Debug.WriteLine("Battery Level: " + (int)chr.Value[0]); ProcessCommands(); break; case Constants.SyncHandlerSequence.ReadDeviceStatus: Debug.WriteLine(": Read Device Status"); CommandRequest = new byte[] { 0x1B, 0x13 }; this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadDeviceSettings: Debug.WriteLine("SyncDeviceHandler936: Read Device Settings"); CommandRequest = new byte[] { 0x1B, 0x17 }; this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadUserSettings: Debug.WriteLine("SyncDeviceHandler936: Read User Settings"); CommandRequest = new byte[] { 0x1B, 0x19 }; this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadStepsHeader: Debug.WriteLine("SyncDeviceHandler936: Read Steps Header"); CommandRequest = new byte[] { 0x1B, 0x22 }; this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadSeizureTable: Debug.WriteLine("SyncDeviceHandler936: Read Seizure Table"); break; case Constants.SyncHandlerSequence.ReadHourlySteps: Debug.WriteLine("SyncDeviceHandler936: Read Steps Header"); //CommandRequest = new byte[] { 0x1B, 0x24, 0x }; this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadCurrentHour: Debug.WriteLine("SyncDeviceHandler936: Read Current Hour"); CommandRequest = new byte[] { 0x1B, 0x27 }; this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadSignature: Debug.WriteLine("SyncDeviceHandler936: Read Signature Data"); //CommandRequest = new byte[] { 0x1B, 0x27 }; this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadSeizure: Debug.WriteLine("SyncDeviceHandler936: Read seizure Data"); break; case Constants.SyncHandlerSequence.WriteStepsHeader: Debug.WriteLine("SyncDeviceHandler936: Writing steps header"); break; case Constants.SyncHandlerSequence.WriteDeviceSettings: Debug.WriteLine("SyncDeviceHandler936: Writing device settings"); break; case Constants.SyncHandlerSequence.WriteUserSettings: Debug.WriteLine("SyncDeviceHandler936: Writing user settings"); break; case Constants.SyncHandlerSequence.WriteExerciseSettings: Debug.WriteLine("SyncDeviceHandler936: Writing exercise settings"); break; case Constants.SyncHandlerSequence.WriteCompanySettings: Debug.WriteLine("SyncDeviceHandler936: Writing company settings"); break; case Constants.SyncHandlerSequence.WriteSignatureSettings: Debug.WriteLine("SyncDeviceHandler936: Writing signature settings"); break; case Constants.SyncHandlerSequence.WriteSeizureSettings: Debug.WriteLine("SyncDeviceHandler936: Writing seizure settings"); break; case Constants.SyncHandlerSequence.WriteScreenFlow: Debug.WriteLine("SyncDeviceHandler936: Writing screenflow settings"); break; case Constants.SyncHandlerSequence.WriteDeviceSensitivity: Debug.WriteLine("SyncDeviceHandler936: Writing device sensitivity settings"); break; case Constants.SyncHandlerSequence.WriteDeviceStatus: Debug.WriteLine("SyncDeviceHandler936: Writing device status settings"); break; case Constants.SyncHandlerSequence.WriteScreenDisplay: Debug.WriteLine("SyncDeviceHandler936: Writing screen display"); break; case Constants.SyncHandlerSequence.ClearEEProm: Debug.WriteLine("SyncDeviceHandler936: Clear eeprom"); break; case Constants.SyncHandlerSequence.WsGetDeviceInfo: Debug.WriteLine("SyncDeviceHandler936: WS Request GetDeviceInfo"); /*Dictionary<String, object> parameter = new Dictionary<String, object>(); parameter.Add("serno", "9999999894"); parameter.Add("fwver", "4.3"); parameter.Add("mdl", "961"); parameter.Add("aid", 16781); parameter.Add("ddtm", "16-08-12 14:15"); await WebService.PostData("https://test.savvysherpa.com/DeviceServices/api/Pedometer/GetDeviceInfo", parameter); */ break; default: Debug.WriteLine("SyncDeviceHandler936: Unable to identify command."); break; } if (this.ProcessQeueue.Count == 0) { Debug.WriteLine("Queue is already empty. Device will be disconnected."); this.Adapter.DisconnectDevice(this.Device); this.SyncDone(this, new SyncDoneEventArgs { Status = true }); } }
public void ProcessCommands() { Debug.WriteLine("SyncDeviceHandlerStriiv: ProcessCommands"); if (this.ProcessQeueue.Count > 0) { Command = this.ProcessQeueue.Dequeue(); } else { Debug.WriteLine("No more commands to be processed!"); return; } ICharacteristic chr = null; switch (Command) { case Constants.StriivSyncHandlerSequence.EnableFE23: Debug.WriteLine("SyncDeviceHandlerSTRIIV: Enabling FE23 characteristic"); CharFE23 = GetServicesCharacteristic(Constants.CharacteristicsUUID._FE23); if (CharFE23 == null) { Debug.WriteLine("FE23 is NULL. Disconnecting device."); this.Adapter.DisconnectDevice(Device); } else { CharFE23.StartUpdates(); } break; case Constants.StriivSyncHandlerSequence.Ack: Debug.WriteLine("Ack response"); CommandRequest = new byte[] { 0x08 }; this.Adapter.SendCommand(Char9A0A, CommandRequest); break; case Constants.StriivSyncHandlerSequence.DeviceInfo: Debug.WriteLine("Read Device Info"); CommandRequest = new byte[] { 0x06 }; this.Adapter.SendCommand(Char9A0A, CommandRequest); break; case Constants.StriivSyncHandlerSequence.RegisterRead: Debug.WriteLine("Register Read Command"); CommandRequest = new byte[] { 0x00 }; this.Adapter.SendCommand(Char9A0A, CommandRequest); break; case Constants.StriivSyncHandlerSequence.RegisterWrite: Debug.WriteLine("Register Write Time"); //CommandRequest = new byte[] { 0x01, 0x00, 0x00, 0x00, 0x30, 0x1E, 0x02, 0x16, 0x07, 0x07, 0xE0 }; CommandRequest = new byte[19]; CommandRequest[0] = 0x01; CommandRequest[1] = 0x00; CommandRequest[2] = 0x00; CommandRequest[3] = 0x01;//00 CommandRequest[4] = 0x1E;//01 CommandRequest[5] = 0x0F;//02 CommandRequest[6] = 0x0B;//03 CommandRequest[7] = 0x18;//04 CommandRequest[8] = 0x08;//05 CommandRequest[9] = 0x7E;//06 CommandRequest[10] = 0x00;//07 CommandRequest[11] = 0x00;//08 CommandRequest[12] = 0x00;//09 CommandRequest[13] = 0x00;//10 CommandRequest[14] = 0x00;//11 CommandRequest[15] = 0x00;//12 CommandRequest[16] = 0x00;//13 CommandRequest[17] = 0x00;//14 CommandRequest[18] = 0x00;//15 this.Adapter.SendCommand(Char9A0A, CommandRequest); break; case Constants.StriivSyncHandlerSequence.FileLoadList: Debug.WriteLine("Reading File Load List"); CommandRequest = new byte[] { 0x02, 0x01 }; this.Adapter.SendCommand(Char9A0A, CommandRequest); break; default: Debug.WriteLine("Invalid command request..."); break; } }
public void StartUpdates() => _characteristic.StartUpdates();
public async void ProcessCommands() { Debug.WriteLine("SyncHandler: ProcessCommands"); if (this.ProcessQeueue.Count > 0) { Command = this.ProcessQeueue.Dequeue(); } else { Debug.WriteLine("No more commands to be processed! Disconnecting device."); this.Adapter.DisconnectDevice(this.Device); return; } ICharacteristic chr = null; switch (Command) { case Constants.SyncHandlerSequence.EnableFF07: Debug.WriteLine("SyncDeviceHandler961: Enabling FF07 characteristic"); Ff07Char = GetServicesCharacteristic(Constants.CharacteristicsUUID._FF07); if (Ff07Char == null) { Debug.WriteLine("FF07 is NULL. Disconnecting device."); this.Adapter.DisconnectDevice(Device); } else { Ff07Char.StartUpdates(); } break; case Constants.SyncHandlerSequence.EnableFF08: Debug.WriteLine("SyncDeviceHandler961: Enabling FF08 characteristic"); Ff08Char = GetServicesCharacteristic(Constants.CharacteristicsUUID._FF08); if (Ff08Char == null) { Debug.WriteLine("FF08 is NULL. Disconnecting device."); this.Adapter.DisconnectDevice(Device); } else { Ff08Char.StartUpdates(); } break; case Constants.SyncHandlerSequence.ReadModel: Debug.WriteLine("SyncDeviceHandler961: Reading model from characteristic."); ReadChar = GetServicesCharacteristic(Constants.CharacteristicsUUID._2A24); chr = await ReadChar.ReadAsync(); int num = 0; int.TryParse(System.Text.Encoding.UTF8.GetString(chr.Value, 0, chr.Value.Length).Replace("PE", "").Replace("FT", ""), out num); Debug.WriteLine("Model: " + num); this.TrioDeviceInformationInstance.ModelNumber = num; string[] deviceNameComponents = this.Device.Name.Split(new Char[] {'-'}); if ( deviceNameComponents.Count() == 3) this.TrioDeviceInformationInstance.BroadcastType = deviceNameComponents[1]; else this.TrioDeviceInformationInstance.BroadcastType = ""; ProcessCommands(); break; case Constants.SyncHandlerSequence.ReadSerial: Debug.WriteLine("SyncDeviceHandler961: Reading serial from characterisitic."); ReadChar = GetServicesCharacteristic(Constants.CharacteristicsUUID._2A25); chr = await ReadChar.ReadAsync(); long serial = 0; long.TryParse(System.Text.Encoding.UTF8.GetString(chr.Value, 0, chr.Value.Length), out serial); Debug.WriteLine("Serial: " + serial); this.TrioDeviceInformationInstance.SerialNumber = serial; ProcessCommands(); break; case Constants.SyncHandlerSequence.ReadFwVersion: Debug.WriteLine("SyncDeviceHandler961: Reading fw version from characteristic."); ReadChar = GetServicesCharacteristic(Constants.CharacteristicsUUID._2A26); chr = await ReadChar.ReadAsync(); float fwVer = 0; float.TryParse(System.Text.Encoding.UTF8.GetString(chr.Value, 0, chr.Value.Length), out fwVer); Debug.WriteLine("Firmware Version: " + fwVer); this.TrioDeviceInformationInstance.FirmwareVersion = fwVer; ProcessCommands(); break; case Constants.SyncHandlerSequence.ReadManufacturer: Debug.WriteLine("SyncDeviceHandler961: Reading manufacturer from characteristic."); ReadChar = GetServicesCharacteristic(Constants.CharacteristicsUUID._2A29); chr = await ReadChar.ReadAsync(); Debug.WriteLine("Manufacturer: " + System.Text.Encoding.UTF8.GetString(chr.Value, 0, chr.Value.Length)); this.Adapter.CommandResponse += ReceiveResponse; //this.isGettingDeviceInformation = false; //if (this.ScanType == Constants.ScanType.SYNCING) // this.isGettingDeviceInformation = true; ProcessCommands(); break; case Constants.SyncHandlerSequence.ReadBatteryLevel: Debug.WriteLine("SyncDeviceHandler961: Reading battery level from characteristic."); ReadChar = GetServicesCharacteristic(Constants.CharacteristicsUUID._2A19); chr = await ReadChar.ReadAsync(); int battery = (int) chr.Value[0]; Debug.WriteLine("Battery Level: " + battery); this.TrioDeviceInformationInstance.BatteryLevel = battery; ProcessCommands(); break; case Constants.SyncHandlerSequence.ReadTallies: Debug.WriteLine("SyncDeviceHandler961: Read Device Tallies"); CommandRequest = new byte[] { 0x1B, 0x5D }; this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadDeviceInformation: Debug.WriteLine("SyncDeviceHandler961: Read Device Information"); CommandRequest = new byte[] { 0x1B, 0x40 }; this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadDeviceStatus: Debug.WriteLine("SyncDeviceHandler961: Read Device Status"); CommandRequest = await DeviceStatusInstance.GetReadCommand(); this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadDeviceSettings: Debug.WriteLine("SyncDeviceHandler961: Read Device Settings"); CommandRequest = await DeviceSettingsInstance.GetReadCommand(); this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadSeizureSettings: Debug.WriteLine("SyncDeviceHandler961: Read Seizure Settings"); CommandRequest = await SeizureSettingsInstance.GetReadCommand(); this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadUserSettings: Debug.WriteLine("SyncDeviceHandler961: Read User Settings"); CommandRequest = await UserSettingsInstance.GetReadCommand(); Debug.WriteLine("Read User Settings: " + Motion.Mobile.Utilities.Utils.ByteArrayToHexString(CommandRequest)); this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadStepsHeader: Debug.WriteLine("SyncDeviceHandler961: Read Steps Header"); CommandRequest = await StepsTableDataInstance.GetReadStepTableDataCommand(); this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadSeizureBlocks: Debug.WriteLine("SyncDeviceHandler961: Read Seizure Table"); CommandRequest = await SeizureBlocksDataInstance.GetReadSeizureBlocksDataCommand(); this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadHourlySteps: Debug.WriteLine("SyncDeviceHandler961: Read Hourly Steps"); DateTime dt = this.currentDateForStepTable; CommandRequest = await StepsDataInstance.getReadHourRangeCommand(dt, this.currentStartTimeForStepTable, currentEndTimeForStepTable); this.Adapter.SendCommand(Ff07Char, CommandRequest); Debug.WriteLine("Read Hour Range Settings: " + Motion.Mobile.Utilities.Utils.ByteArrayToHexString(CommandRequest)); break; case Constants.SyncHandlerSequence.ReadCurrentHour: Debug.WriteLine("SyncDeviceHandler961: Read Current Hour"); CommandRequest = await StepsDataInstance.getReadCurrentHourCommand(); this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ReadSignature: Debug.WriteLine("SyncDeviceHandler961: Read Signature Data"); StepsTableParameters sigData = this.SignatureToBeUploadedTableList.ElementAt(0); SignatureDataInstance.SDYear = sigData.dbYear; SignatureDataInstance.SDMonth = sigData.dbMonth; SignatureDataInstance.SDDay = sigData.dbDay; CommandRequest = await SignatureDataInstance.GetReadSignDataCommand(); this.Adapter.SendCommand(Ff07Char, CommandRequest); // insert timer here break; case Constants.SyncHandlerSequence.ReadSeizure: Debug.WriteLine("SyncDeviceHandler961: Read seizure Data"); SeizureBlockInfo seizureBlock = this.SeizureToBeUploadedList.ElementAt(0); SeizureDataInstance.SeizureRecToRead = seizureBlock.sbseizureRecordNo; SeizureDataInstance.BlockNumber = seizureBlock.sbSeizureBlock; CommandRequest = await SeizureDataInstance.GetReadCommand(); this.Adapter.SendCommand(Ff07Char, CommandRequest); // insert timer here break; case Constants.SyncHandlerSequence.WriteStepsHeader: Debug.WriteLine("SyncDeviceHandler961: Writing steps header"); CommandRequest = await StepsTableDataInstance.GetWriteStepTableDataCommand(StepTableParamInstance); this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.WriteDeviceSettings: Debug.WriteLine("SyncDeviceHandler961: Writing device settings"); CommandRequest = await DeviceSettingsInstance.GetWriteCommand(); this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.WriteUserSettings: Debug.WriteLine("SyncDeviceHandler961: Writing user settings"); CommandRequest = await UserSettingsInstance.GetWriteCommand(); this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.WriteExerciseSettings: Debug.WriteLine("SyncDeviceHandler961: Writing exercise settings"); CommandRequest = await ExerciseSettingsInstance.GetWriteCommand(); this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.WriteCompanySettings: Debug.WriteLine("SyncDeviceHandler961: Writing company settings"); CommandRequest = await CompanySettingsInstance.GetWriteCommand(); this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.WriteSignatureSettings: Debug.WriteLine("SyncDeviceHandler961: Writing signature settings"); CommandRequest = await SignatureSettingsInstance.GetWriteCommand(); this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.WriteSeizureSettings: Debug.WriteLine("SyncDeviceHandler961: Writing seizure settings"); CommandRequest = await SeizureSettingsInstance.GetWriteCommand(); this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.WriteScreenFlow: Debug.WriteLine("SyncDeviceHandler961: Writing screenflow settings"); CommandRequest = await FirmwareDisplaySequenceInstance.GetWriteCommand(this.ScreenFlowList); this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.WriteDeviceSensitivity: Debug.WriteLine("SyncDeviceHandler961: Writing device sensitivity settings"); SensitivitySettingsInstance.SensitivityOld = DeviceDataInstance.TrackerSensitivity; CommandRequest = await SensitivitySettingsInstance.GetWriteCommand(); this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.WriteDeviceStatus: Debug.WriteLine("SyncDeviceHandler961: Writing device status settings"); CommandRequest = await DeviceStatusInstance.GetWriteCommand(); this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.WriteDeviceMode: Debug.WriteLine("SyncDeviceHandler961: Writing device mode settings"); DeviceModeInstance.EnableBroadcastAlways = DeviceDataInstance.AdvertiseMode; CommandRequest = await DeviceModeInstance.GetWriteCommand(); this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.WriteScreenDisplay: Debug.WriteLine("SyncDeviceHandler961: Writing screen display"); this.ActivationCode = Utils.GetRandomDigits(4); //4 random digits to be generated // For testing purposes only this.ActivationCode[0] = 0x31; this.ActivationCode[1] = 0x32; this.ActivationCode[2] = 0x33; this.ActivationCode[3] = 0x34; // For testing purposes only Debug.WriteLine("Random digits: " + Motion.Mobile.Utilities.Utils.ByteArrayToHexString(this.ActivationCode)); CommandRequest = await DisplayOnScreenInstance.GetWriteCommand(this.ActivationCode); this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.ClearEEProm: Debug.WriteLine("SyncDeviceHandler961: Clear eeprom"); ClearEEPROMInstance.ExerciseData = this.clearMessagesOnly?false:true; ClearEEPROMInstance.SettingsData = false; ClearEEPROMInstance.SurveyQuestions = true; ClearEEPROMInstance.Tallies = true; ClearEEPROMInstance.MedicineAlarm = true; ClearEEPROMInstance.MotivationalQuotes = true; CommandRequest = await ClearEEPROMInstance.GetWriteCommand(); this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.WsActivateDeviceWithMember: Debug.WriteLine("SyncDeviceHandler961: WS Activate Device With Member"); WSActivateDeviceWithMemberInstance.request.TrackerModel = TrioDeviceInformationInstance.ModelNumber; WSActivateDeviceWithMemberInstance.request.TrackerSerialNumber = TrioDeviceInformationInstance.SerialNumber; WSActivateDeviceWithMemberInstance.request.TrackerBtAdd = ""; WSActivateDeviceWithMemberInstance.request.ApplicationID = UserInformationInstance.ApplicationID; WSActivateDeviceWithMemberInstance.request.MemberDermID = UserInformationInstance.MemberID; WSActivateDeviceWithMemberInstance.request.TrackerFirmwareVersion = TrioDeviceInformationInstance.FirmwareVersion; this.status = await WSActivateDeviceWithMemberInstance.PostRequest(); if (this.status == WebServiceRequestStatus.SUCCESS) { Debug.WriteLine("Success"); if (WSActivateDeviceWithMemberInstance.response != null) { this.SetSettingsFromActivateDeviceWithMemberResponseWS(WSActivateDeviceWithMemberInstance.response); ProcessCommands(); } } else { Debug.WriteLine("ActivateDeviceWithMemeber Response is " + WSActivateDeviceWithMemberInstance.response.ResponseMessage); this.Adapter.DisconnectDevice(this.Device); } //this.Adapter.SendCommand(Ff07Char, CommandRequest); break; case Constants.SyncHandlerSequence.WsGetDeviceInfo: Debug.WriteLine("SyncDeviceHandler961: WS Request GetDeviceInfo"); WSGetDeviceInformationInstance.request.TrackerModel = TrioDeviceInformationInstance.ModelNumber; WSGetDeviceInformationInstance.request.TrackerSerialNumber = TrioDeviceInformationInstance.SerialNumber; WSGetDeviceInformationInstance.request.DeviceDateTime = Motion.Mobile.Utilities.Utils.GetDeviceDateTimeWithFormat(DateTime.Now); WSGetDeviceInformationInstance.request.ApplicationID = UserInformationInstance.ApplicationID; WSGetDeviceInformationInstance.request.DevicePairingStatus = 1; WSGetDeviceInformationInstance.request.TrackerFirmwareVersion = TrioDeviceInformationInstance.FirmwareVersion; this.status = await WSGetDeviceInformationInstance.PostRequest(); this.ServerReadTimeDuration = 0; if (this.status == WebServiceRequestStatus.SUCCESS) { Debug.WriteLine("Success"); if (WSGetDeviceInformationInstance.response != null) { this.isResettingTrio = false; timerForServer = new Timer(timerCallBack, new object(), 0, 1000); timerForServer.Increment += TimerForServer_Increment; this.SetSettingsFromGetDeviceInfoResponseWS(WSGetDeviceInformationInstance.response); ProcessCommands(); } else { Debug.WriteLine("WS Request GetDeviceInfo Response is " + WSGetDeviceInformationInstance.response.ResponseMessage); this.Adapter.DisconnectDevice(this.Device); } } //else if Tobe Added? else if (string.Equals(WSGetDeviceInformationInstance.response.ResponseStatus, "reset")) { this.isResettingTrio = true; DeviceStatusInstance.PairingStatus = 1; this.ProcessQeueue.Enqueue(Constants.SyncHandlerSequence.WriteDeviceStatus); this.ProcessCommands(); Debug.WriteLine("Device Not Paired..."); } else { Debug.WriteLine("Get Device Info Failed :("); } break; case Constants.SyncHandlerSequence.WsUploadTallies: Debug.WriteLine("SyncDeviceHandler961: WS Upload Tallies"); WSUploadTalliesDataInstance.request.DeviceModel = TrioDeviceInformationInstance.ModelNumber; WSUploadTalliesDataInstance.request.DeviceSerial = TrioDeviceInformationInstance.SerialNumber; WSUploadTalliesDataInstance.request.MemberDeviceID = UserInformationInstance.MemberDeviceId; WSUploadTalliesDataInstance.request.ApplicationID = UserInformationInstance.ApplicationID; WSUploadTalliesDataInstance.request.PlatformID = UserInformationInstance.PlatformID; WSUploadTalliesDataInstance.request.DeviceDateTime = Motion.Mobile.Utilities.Utils.GetServerDateTimeFromString(MemberServerProfileInstance.ServerDateTime); WSUploadTalliesDataInstance.request.talliesData = TalliesDataInstance; this.status = await WSUploadTalliesDataInstance.PostRequest(); if (this.status == WebServiceRequestStatus.SUCCESS) { Debug.WriteLine("Success"); if (ApplicationInfoInstance.ApplicationID > 0 && ApplicationInfoInstance.PlatformID > 0) { if ((AppUpdateSettingsInstance.UpdateFlag && AppUpdateSettingsInstance.UpdateType != 2) || !AppUpdateSettingsInstance.UpdateFlag) { if (!this.clearTracker) { this.ProcessQeueue.Enqueue(Constants.SyncHandlerSequence.ReadSeizureSettings); this.ProcessCommands(); } } } else { this.isValidateAppInfo = true; this.ProcessQeueue.Enqueue(Constants.SyncHandlerSequence.WsSendAppInfo); this.ProcessCommands(); } } else { Debug.WriteLine("Upload Tallies Response is " + WSUploadTalliesDataInstance.response.ResponseStatus); this.Adapter.DisconnectDevice(this.Device); } break; case Constants.SyncHandlerSequence.WsUploadSteps: Debug.WriteLine("SyncDeviceHandler961: WS Upload Steps"); this.CreateUploadStepsDataRequest(WSUploadStepsDataInstance.request); this.status = await WSUploadStepsDataInstance.PostRequest(); if (this.status == WebServiceRequestStatus.SUCCESS) { Debug.WriteLine("Success"); if (this.isReadingCurrentHour) { //READ_DEVICE_SETTING this.checkTimeDifferenceAndUpdateDeviceTime(); } else { //UpdateStepDataTable StepTableParamInstance = this.UpdateStepDataTable(); this.ProcessQeueue.Enqueue(Constants.SyncHandlerSequence.WriteStepsHeader); this.ProcessCommands(); } } else { Debug.WriteLine("Upload Steps Response is " + WSUploadStepsDataInstance.response.ResponseMessage); this.Adapter.DisconnectDevice(this.Device); } break; case Constants.SyncHandlerSequence.WsUploadSignature: Debug.WriteLine("SyncDeviceHandler961: WS Upload Signature"); this.CreateUploadSignatureRequestData(WSUploadSignatureDataInstance.request); this.status = await WSUploadSignatureDataInstance.PostRequest(); if (this.status == WebServiceRequestStatus.SUCCESS) { Debug.WriteLine("Success"); if (this.SignatureToBeUploadedTableList.Count() > 0) { this.ProcessQeueue.Enqueue(Constants.SyncHandlerSequence.ReadSignature); this.ProcessCommands(); } else { if (this.MemberServerProfileInstance.UpdateFlag > 0) { this.UpdateSettingsFlag(Utils.USER_SETTINGS_BIT_LOC); } else { //if(READ SURVEY) //else // update settings //CLEAR_MESSAGES_SETTINGS_BIT_LOC this.UpdateSettingsFlag(Utils.CLEAR_MESSAGES_SETTINGS_BIT_LOC); } } } else { Debug.WriteLine("Upload Signature Response is " + WSUploadSignatureDataInstance.response.ResponseMessage); this.Adapter.DisconnectDevice(this.Device); } break; case Constants.SyncHandlerSequence.WsUploadProfile: break; case Constants.SyncHandlerSequence.WsUnpairDevice: Debug.WriteLine("SyncDeviceHandler961: WS Unpair Device"); WSUnpairMemberDeviceInstance.request.DeviceID = WSActivateDeviceWithMemberInstance.response.DeviceID; WSUnpairMemberDeviceInstance.request.MemberID = UserInformationInstance.MemberID; WSUnpairMemberDeviceInstance.request.MemberDeviceID = UserInformationInstance.MemberDeviceId; this.status = await WSUploadSeiureDataInstance.PostRequest(); if (this.status == WebServiceRequestStatus.SUCCESS) { Debug.WriteLine("Deactivating Device Successful"); } break; case Constants.SyncHandlerSequence.WsUploadSeizure: Debug.WriteLine("SyncDeviceHandler961: WS Upload Seizure"); this.CreateUploadSeizureRequestData(WSUploadSeiureDataInstance.request); this.status = await WSUploadSeiureDataInstance.PostRequest(); if (this.status == WebServiceRequestStatus.SUCCESS) { Debug.WriteLine("Success"); if (this.SeizureToBeUploadedList.Count() > 0) { this.ProcessQeueue.Enqueue(Constants.SyncHandlerSequence.ReadSeizure); this.ProcessCommands(); } else { if (this.SignatureToBeUploadedTableList.Count() > 0) { this.ProcessQeueue.Enqueue(Constants.SyncHandlerSequence.ReadSignature); this.ProcessCommands(); } else { if (this.MemberServerProfileInstance.UpdateFlag > 0) { this.UpdateSettingsFlag(Utils.USER_SETTINGS_BIT_LOC); } else { //if(READ SURVEY) //else // update settings //CLEAR_MESSAGES_SETTINGS_BIT_LOC this.UpdateSettingsFlag(Utils.CLEAR_MESSAGES_SETTINGS_BIT_LOC); } } } } else { Debug.WriteLine("Upload Seizure Response is " + WSUploadSeiureDataInstance.response.ResponseMessage); this.Adapter.DisconnectDevice(this.Device); } break; case Constants.SyncHandlerSequence.WsSendNotifySettingsUpdate: Debug.WriteLine("SyncDeviceHandler961: WS Notify Settings Update"); DateTime currentDateTime = DateTime.Now; long dateTimeInUnix = (long)Motion.Mobile.Utilities.Utils.DateTimeToUnixTimestamp(currentDateTime); DateTime dateTime = new DateTime(DeviceSettingsInstance.Year + 2000, DeviceSettingsInstance.Month, DeviceSettingsInstance.Day, DeviceSettingsInstance.Hour, DeviceSettingsInstance.Minute, DeviceSettingsInstance.Second); dateTime.AddSeconds(this.DeviceReadTimeDuration); WSNotifySettingsUpdateInstance.request.MemberID = UserInformationInstance.MemberID; WSNotifySettingsUpdateInstance.request.MemberDeviceID = UserInformationInstance.MemberDeviceId; WSNotifySettingsUpdateInstance.request.LastSyncSettingDateTime = dateTimeInUnix; WSNotifySettingsUpdateInstance.request.TrackerModel = TrioDeviceInformationInstance.ModelNumber; WSNotifySettingsUpdateInstance.request.UpdateFlag = MemberServerProfileInstance.UpdateFlag; WSNotifySettingsUpdateInstance.request.SettingType = MemberServerProfileInstance.UpdateFlagChanges; WSNotifySettingsUpdateInstance.request.DevicePairingStatus = DeviceStatusInstance.PairingStatus; WSNotifySettingsUpdateInstance.request.DeviceDateTime = Motion.Mobile.Utilities.Utils.GetDeviceDateTimeWithFormat(dateTime); WSNotifySettingsUpdateInstance.request.BatteryLevel = TrioDeviceInformationInstance.BatteryLevel; this.status = await WSNotifySettingsUpdateInstance.PostRequest(); if (this.status == WebServiceRequestStatus.SUCCESS) { Debug.WriteLine("WS Notify Settings Update Successful"); } else { Debug.WriteLine("WS Notify Settings Update Response is " + WSNotifySettingsUpdateInstance.response.ResponseMessage); this.Adapter.DisconnectDevice(this.Device); } break; case Constants.SyncHandlerSequence.WsUploadCommandResponse: Debug.WriteLine("SyncDeviceHandler961: WS Upload Command Response"); WSUploadCommandResponseInstance.request.commandRespData.UploadCommand = 0x58; WSUploadCommandResponseInstance.request.DeviceModel = TrioDeviceInformationInstance.ModelNumber; WSUploadCommandResponseInstance.request.DeviceSerial = TrioDeviceInformationInstance.SerialNumber; WSUploadCommandResponseInstance.request.MemberDeviceID = UserInformationInstance.MemberDeviceId; WSUploadCommandResponseInstance.request.ApplicationID = UserInformationInstance.ApplicationID; WSUploadCommandResponseInstance.request.PlatformID = UserInformationInstance.PlatformID; WSUploadCommandResponseInstance.request.SynchronizationID = this.MemberServerProfileInstance.SynchronizationID; this.status = await WSUploadCommandResponseInstance.PostRequest(); if (this.status == WebServiceRequestStatus.SUCCESS) { Debug.WriteLine("WS Upload Command Successful!"); } else { Debug.WriteLine("WS Upload Command Response is " + WSUploadCommandResponseInstance.response.ResponseMessage); this.Adapter.DisconnectDevice(this.Device); } break; case Constants.SyncHandlerSequence.WsSendAppInfo: Debug.WriteLine("SyncDeviceHandler961: WS Validate App Info"); WSSendAppInfoInstance.request.ApplicationName = ApplicationInfoInstance.ApplicationName; WSSendAppInfoInstance.request.ApplicationVersion = ApplicationInfoInstance.ApplicationVersion; WSSendAppInfoInstance.request.OperatingSystem = ApplicationInfoInstance.OperatingSystem; WSSendAppInfoInstance.request.OperatingSystemVersion = ApplicationInfoInstance.OperatingSystemVersion; WSSendAppInfoInstance.request.PlatformType = ApplicationInfoInstance.PlatformType; WSSendAppInfoInstance.request.Brand = ApplicationInfoInstance.Brand; WSSendAppInfoInstance.request.Model = ApplicationInfoInstance.Model; WSSendAppInfoInstance.request.Manufacturer = ApplicationInfoInstance.Manufacturer; WSSendAppInfoInstance.request.CommunicationType = ApplicationInfoInstance.CommunicationType; this.status = await WSSendAppInfoInstance.PostRequest(); if (this.status == WebServiceRequestStatus.SUCCESS) { Debug.WriteLine("WS Validate App Info Successful"); this.UserInformationInstance.ApplicationID = WSSendAppInfoInstance.response.ApplicationID; this.UserInformationInstance.PlatformID = WSSendAppInfoInstance.response.PlatformID; if (this.isValidateAppInfo) { this.ApplicationInfoInstance.ApplicationID = WSSendAppInfoInstance.response.ApplicationID; this.ApplicationInfoInstance.PlatformID = WSSendAppInfoInstance.response.PlatformID; if ((AppUpdateSettingsInstance.UpdateFlag && AppUpdateSettingsInstance.UpdateType != 2) || !AppUpdateSettingsInstance.UpdateFlag) { if (!this.clearTracker) this.ProcessCommands(); else { this.ProcessQeueue.Enqueue(Constants.SyncHandlerSequence.WriteDeviceSettings); this.ProcessCommands(); } } } else { this.AppUpdateSettingsInstance.UpdateType = WSSendAppInfoInstance.response.appUpdateInfo.UpdateType; } } else { Debug.WriteLine("WS Validate App Info Response is " + WSUploadCommandResponseInstance.response.ResponseMessage); this.Adapter.DisconnectDevice(this.Device); } break; default: Debug.WriteLine("SyncDeviceHandler961: Unable to identify command."); break; } }