예제 #1
0
        public async Task SelectedDevicePing()
        {
            IsBusyHeader = true;

            SelectedDeviceConnectionResult = PingConnectionResult.Busy;
            try
            {
                PingConnectionType connection = await SelectedDevice.PingAsync();

                SelectedDeviceConnectionResult = (connection != PingConnectionType.NoConnection) ? PingConnectionResult.Ok : PingConnectionResult.Error;
            }
            catch
            {
                SelectedDeviceConnectionResult = PingConnectionResult.Error;
            }
            finally
            {
                IsBusyHeader = false;
            }
        }
예제 #2
0
        /// <summary>
        /// Attempts to talk to the connected .Net Micro Framework device
        /// </summary>
        /// <returns>returns ConnectionType if the device was responsive, false otherwise</returns>
        public PingConnectionType Ping()
        {
            PingConnectionType ret = PingConnectionType.NoConnection;

            if (m_eng != null)
            {
                _WP.Commands.Monitor_Ping.Reply reply = m_eng.GetConnectionSource();

                if (reply != null)
                {
                    switch (reply.m_source)
                    {
                    case _WP.Commands.Monitor_Ping.c_Ping_Source_TinyCLR:
                        ret = PingConnectionType.TinyCLR;
                        break;

                    case _WP.Commands.Monitor_Ping.c_Ping_Source_TinyBooter:
                        ret = PingConnectionType.TinyBooter;
                        break;
                    }
                }
            }
            return(ret);
        }
예제 #3
0
        /// <summary>
        /// Updates the given public signature key
        /// </summary>
        /// <param name="newKeyInfo">Information that is used to update the key: including the new key,
        /// the new key signature (if the key has already been set), and the key index</param>
        /// <returns>true if successful false otherwise</returns>
        public bool UpdatePublicKey(PublicKeyUpdateInfo newKeyInfo)
        {
            bool fRequiresReboot = false;
            bool retVal          = false;

            _DBG.PublicKeyIndex keyIndex;

            if (!m_init)
            {
                InitializeConfigData();
            }

            if (!m_init)
            {
                throw new MFInvalidConfigurationSectorException();
            }
            if (!m_fStaticCfgOK)
            {
                throw new MFInvalidConfigurationSectorException();
            }
            if ((newKeyInfo.NewPublicKey.Length) != TINYBOOTER_KEY_CONFIG.c_RSAKeyLength)
            {
                throw new MFInvalidKeyLengthException();
            }

            if (newKeyInfo.PublicKeyIndex == PublicKeyUpdateInfo.KeyIndex.DeploymentKey)
            {
                keyIndex        = _DBG.PublicKeyIndex.DeploymentKey;
                fRequiresReboot = m_deployKeyLocked;
            }
            else
            {
                keyIndex        = _DBG.PublicKeyIndex.FirmwareKey;
                fRequiresReboot = m_firmwareKeyLocked;
            }

            if (m_device.DbgEngine.ConnectionSource != Microsoft.SPOT.Debugger.ConnectionSource.TinyBooter)
            {
                if (!m_device.ConnectToTinyBooter())
                {
                    throw new MFDeviceNoResponseException();
                }
            }

            if (m_device.DbgEngine.UpdateSignatureKey(keyIndex, newKeyInfo.NewPublicKeySignature, newKeyInfo.NewPublicKey, null))
            {
                // if the key was previously set it requires an erase and a write which requires a reboot on some devices
                if (fRequiresReboot)
                {
                    m_device.Reboot(true);
                }

                retVal = true;
            }

            PingConnectionType conn = m_device.Ping();

            if (PingConnectionType.TinyBooter == conn)
            {
                m_device.Execute(c_EnumerateAndLaunchAddr);
            }

            return(retVal);
        }