/// <summary> /// Reset the watch / timeline /// </summary> /// <returns></returns> public async Task <bool> Wipe() { try { if (await _pc.IsBackgroundTaskRunning()) { _Log.Add("Stop current activities"); _pc.StopBackgroundTask(PebbleConnector.Initiator.Manual); await _pc.WaitBackgroundTaskStopped(5); } await Connect(); String Message; //Get current watch face ID //WatchFaceMessage _wfm = new WatchFaceMessage(); Guid CurrentWatchFace = _pc.Pebble.CurrentWatchFace; //await _pc.Pebble.RequestWatchFaceMessageAsync(_wfm); WatchItem CurrentWatchFaceItem = _pc.WatchItems.Get(CurrentWatchFace); System.Diagnostics.Debug.WriteLine(String.Format("Current watch face: {0}", CurrentWatchFace)); if (CurrentWatchFaceItem != null) { _Log.Add(String.Format("Current watch face: {0}", CurrentWatchFaceItem.Name)); } else { _Log.Add(String.Format("Current watch face: {0}", CurrentWatchFace)); } _pc.StartReceivingMessages(); _pc.Pebble._protocol.MessageReceived += AppMessageReceived; //Set the watch face byte[] TicTocByte = new byte[16] { 0x8F, 0x3C, 0x86, 0x86, 0x31, 0xA1, 0x4F, 0x5F, 0x91, 0xF5, 0x01, 0x60, 0x0C, 0x9B, 0xDC, 0x59 }; Guid TicTocGuid = new Guid(TicTocByte); if (CurrentWatchFace != Guid.Empty && CurrentWatchFace != TicTocGuid) { WatchFaceSelectMessage _wsm = new WatchFaceSelectMessage(CurrentWatchFace, TicTocGuid); await _pc.Pebble.WriteMessageAsync(_wsm); System.Diagnostics.Debug.WriteLine(String.Format("TicToc Watch fase set as current")); } StandardV3Message _SV3M; for (int i = 1; i <= 9; i++) { _SV3M = new StandardV3Message(_pc.Pebble.GetNextMessageIdentifier(), (byte)i); await _pc.Pebble._protocol.WriteMessage(_SV3M); await WaitForMessage(_SV3M.Identifier); } /*Message = "00:04:b1:db:05:d0:11:01"; * await _pc.WriteMessage(Message); * await WaitForMessage("d0:11"); * * Message = "00:04:b1:db:05:65:54:02"; * await _pc.WriteMessage(Message); * await WaitForMessage("65:54"); * * Message = "00:04:b1:db:05:8c:b5:03"; * await _pc.WriteMessage(Message); * await WaitForMessage("8c:b5"); * * Message = "00:04:b1:db:05:8c:b6:04"; * await _pc.WriteMessage(Message); * await WaitForMessage("8c:b6"); * * Message = "00:04:b1:db:05:8c:b7:05"; * await _pc.WriteMessage(Message); * await WaitForMessage("8c:b7"); * * Message = "00:04:b1:db:05:8c:b8:06"; * await _pc.WriteMessage(Message); * await WaitForMessage("8c:b8"); * * Message = "00:04:b1:db:05:8c:b9:07"; * await _pc.WriteMessage(Message); * await WaitForMessage("8c:b9"); * * Message = "00:04:b1:db:05:8c:ba:08"; * await _pc.WriteMessage(Message); * await WaitForMessage("8c:ba"); * * Message = "00:04:b1:db:05:8c:b0:09"; * await _pc.WriteMessage(Message); * await WaitForMessage("8c:b0");*/ _Log.Add("Pebble Time wiped."); System.Diagnostics.Debug.WriteLine("Pebble Time wiped."); foreach (var item in _pc.Pebble.WatchItems) { WatchItemAddMessage _waam = new WatchItemAddMessage(_pc.Pebble.GetNextMessageIdentifier(), item); await _pc.Pebble._protocol.WriteMessage(_waam); await WaitForMessage(_waam.Transaction); switch (item.Type) { case WatchItemType.WatchFace: _Log.Add(String.Format("Watch face {0} added.", item.Name)); System.Diagnostics.Debug.WriteLine(String.Format("Watch face {0} added.", item.Name)); break; case WatchItemType.WatchApp: _Log.Add(String.Format("Watch app {0} added.", item.Name)); System.Diagnostics.Debug.WriteLine(String.Format("Watch app {0} added.", item.Name)); break; } } _Log.Add("Watch items restored"); System.Diagnostics.Debug.WriteLine("Watch items restored"); //Clear caches Weather.ClearCache(); await Calender.ClearCache(); _Log.Add("Cache cleared on phone"); System.Diagnostics.Debug.WriteLine("Cache cleared on phone"); //Update timeline await _TimeLineSynchronizer.Synchronize(); //Set the watch face if (CurrentWatchFace != Guid.Empty && CurrentWatchFace != TicTocGuid) { WatchFaceSelectMessage _wsm = new WatchFaceSelectMessage(TicTocGuid, CurrentWatchFace); await _pc.Pebble.WriteMessageAsync(_wsm); _Log.Add(String.Format("Selected watch face: {0}", CurrentWatchFace)); if (CurrentWatchFaceItem != null) { _Log.Add(String.Format("Current watch face: {0}", CurrentWatchFaceItem.Name)); } else { _Log.Add(String.Format("Current watch face: {0}", CurrentWatchFace)); } System.Diagnostics.Debug.WriteLine(String.Format("Selected watch face: {0}", CurrentWatchFace)); _pc.Pebble.ItemSend += Pebble_ItemSend; } else { Disconnect(); } return(true); } catch (Exception exp) { System.Diagnostics.Debug.WriteLine(String.Format("Wipe exception: {0}", exp.Message)); Disconnect(); } return(false); }