예제 #1
0
        /// <summary>
        /// Call this method to close a conection to the Plantronics
        /// device. Pass the PLTConnection object reference that you
        /// wish to close. This method will close all the active
        /// subscriptions for the device and unattach from the device
        /// motion sensors.
        /// </summary>
        /// <param name="aConnection">Pass the PLTConnection object reference
        /// that you wish to close.</param>
        public void closeConnection(PLTConnection aConnection)
        {
            // TODO: get ALL the subscribed services
            // and UNSUBSCRIBE them - in particular STOP any periodic TIMERS
            // otherwise you will get exceptions
            aConnection.CloseAllSubscriptions();

            // unregister for raw data received event
            m_spokes.RawDataReceived -= m_spokes_RawDataReceived;
            m_isConnectToDevice       = false;
            m_activeConnection        = null;
            m_callbackhandler.ConnectionClosed(aConnection.m_device);
        }
예제 #2
0
        /// <summary>
        /// Call this method to instruct device to open a connection to the
        /// specified device. Once connected you will be able to subscribe
        /// to data services of the device.
        /// </summary>
        /// <param name="aDevice">Pass the PLTDevice object you want to connect to.</param>
        public void openConnection(PLTDevice aDevice)
        {
            if (m_activeConnection != null)
            {
                return;
            }

            // TODO in future instruct Spokes to change call control device
            // to passed PLTDevice (not currently available with Spokes 3.0
            // in which we are already attached to the 1 call control device)

            // just register for raw data received to receive sensor data
            m_spokes.RawDataReceived += new Spokes.RawDataReceivedEventHandler(m_spokes_RawDataReceived);

            m_isConnectToDevice = true;
            m_activeConnection  = new PLTConnection(m_spokes, this, aDevice);

            m_callbackhandler.ConnectionOpen(m_activeConnection);
        }
예제 #3
0
 public PLTServiceSubscription(PLTConnection aConnection, PLTService aService, PLTMode aMode, int aPeriodMilliseconds,
                               object aLastdata = null)
 {
     m_pltconnection      = aConnection;
     m_service            = aService;
     m_mode               = aMode;
     m_periodMilliseconds = aPeriodMilliseconds;
     m_lastData           = aLastdata; // last data or initial value
     if (aMode == PLTMode.Periodic)
     {
         if (aPeriodMilliseconds < 1)
         {
             throw new Exception("Sorry, for periodic service subscription you must specify the period in milliseconds!");
         }
         else
         {
             m_periodTimer          = new Timer();
             m_periodTimer.Interval = aPeriodMilliseconds;
             m_periodTimer.Elapsed += new ElapsedEventHandler(m_periodTimer_Elapsed);
             m_periodTimer.Start();
         }
     }
 }