Beispiel #1
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);
		}
Beispiel #2
0
		public static Myo ConnectEasyPreConfigured (string port, NotificationAutoConfigurableValues config, MyoConfig cfg = null)
		{
			Myo myo = new Myo (cfg);
			myo.ConnectToDevice (port, NotificationSubscriptionMode.EasyConfigurable, config);
			return myo;
		}
Beispiel #3
0
		private void InitializeNotificationSystem (NotificationSubscriptionMode notificationMode, NotificationAutoConfigurableValues config, int threadSleep)
		{
			switch (notificationMode)
			{
			case NotificationSubscriptionMode.EasyConfigurable:
				{
					if (config == null)
					{
						throw new ArgumentNullException ("config");
					}

					this.Controller.IssueCommand_SetReceiveDataMode (config.Emg, config.Imu, config.Pose);

					this.Notifications = new MyoNotifications (_ble, this.Controller, threadSleep, true);
					break;
				}
			case NotificationSubscriptionMode.FullControl:
				{
					this.Notifications = new MyoNotifications (_ble, this.Controller, threadSleep);
					break;
				}
			}

			this.Notifications.StartModule ();
		}