Ejemplo n.º 1
0
		internal MyoNotifications (BleConnector ble, MyoController controller, int sleep = 0, bool auto = false)
		{
			_ble = ble;
			_controller = controller;
			_auto = auto;
			_threadSleep = sleep;
		}
Ejemplo n.º 2
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="port">The port with the bluegiga ble adapter</param>
		/// <param name="notificationMode">Can't be changed after initialization!</param>
		/// <param name="config">Must be suplied when choosing EasyConfigurable notificatoin mode. Otherwise - ignored!</param>
		private void ConnectToDevice (string port, NotificationSubscriptionMode notificationMode, NotificationAutoConfigurableValues config = null)
		{
			// connect
			_ble = new BleConnector (new BleConnectorInitData (port, ProtocolServices.MYO_INFO_SERVICE, _config.Debug, _config.PortThreadSleep));
			_ble.Disconnected += DisconnectedHandler;
			BlePeripheralMap clientMap = _ble.Connect ();

			// init functionallity object
			this.Controller = new MyoController (_ble);

			// validate
			this.ValidateClientMap (clientMap);

			FirmwareVersion fv = this.Controller.GetFirmwareVersion ();
			if (fv.Major < ProtocolRevision.MAJOR_VERSION ||
			    (fv.Major == ProtocolRevision.MAJOR_VERSION && fv.Minor < ProtocolRevision.MINOR_VERSION))
			{
				throw new Exception ("Not supported protocol version. Please upgrade!");
			}

			// handle notification events
			this.InitializeNotificationSystem (notificationMode, config, _config.NotificationThreadSleep);
		}
Ejemplo n.º 3
0
		private void Dispose (bool disposing)
		{
			if (disposing)
			{
				if (_ble != null)
				{
					this.Notifications.StopModule ();
					_ble.Disconnect ();
					_ble = null;
				}
			}
		}
Ejemplo n.º 4
0
		internal MyoController (BleConnector ble)
		{
			_ble = ble;
		}