Ejemplo n.º 1
0
		public PebbleViewer (ILogger logger, PebblePlugin plugin, PebbleSharp.Core.Pebble pebble, IZip appBundleZip, Action<Action<ISystemController, IRaceController>> queueCommand)
		{
			_queueCommand = queueCommand;
			_plugin = plugin;
			_logger = logger;
			_pebble = pebble;

			_pebble.ConnectAsync ().Wait ();
			_logger.Info ("Connected to pebble " + _pebble.PebbleID);
			
			_transactionId = 255;

			var progress = new Progress<ProgressValue> (pv => _logger.Debug ("Installing app on pebble " + pebble.PebbleID + ", " + pv.ProgressPercentage + "% complete. " + pv.Message));
			var bundle = new AppBundle ();
			bundle.Load (appBundleZip, _pebble.Firmware.HardwarePlatform.GetPlatform ());
			_uuid = bundle.AppMetadata.UUID;
			_pebble.InstallClient.InstallAppAsync (bundle, progress).Wait ();
			_logger.Info ("Installed app on pebble " + pebble.PebbleID);

			_pebble.RegisterCallback<AppMessagePacket> (Receive);

			InitializeViewer ();
		}
Ejemplo n.º 2
0
        /// <summary>
        /// initialize a given pebble and add it to the viewers if successful
        /// </summary>
        /// <param name="pebble"></param>
        /// <param name="zip"></param>
        /// <param name="queueCommand"></param>
        /// <param name="configuration"></param>
		private void InitializeViewer(PebbleSharp.Core.Pebble pebble,PebbleSharp.Core.IZip zip, Action<Action<ISystemController, IRaceController>> queueCommand,PluginConfiguration configuration)
		{
			try
			{
				var viewer = new PebbleViewer(_logger, this, pebble,zip,queueCommand);

				_components.Add(viewer);
				configuration.DashboardViewers.Add(viewer);
			}
			catch (Exception ex)
			{
				_logger.Error("Failed to connect to pebble "+pebble.PebbleID,ex);
			}
		}