Ejemplo n.º 1
0
        public async Task <bool> Start()
        {
            if (textBoxFilePath.Text == string.Empty)
            {
                return(false);
            }

            /* 启动OTA下载 */
            bool bRet = await m_flowSensor.StartOTADownloadAsync();

            if (!bRet)
            {
                return(false);
            }

            m_flowSensor.DataRecved += OnUartDataRecved;

            FileTransProtocol = new YModem(TransmitMode.Send, YModemType.YModem_1K, ReTryMax);
            FileTransProtocol.EndOfTransmit   += FileTransProtocol_EndOfTransmit;
            FileTransProtocol.AbortTransmit   += FileTransProtocol_AbortTransmit;
            FileTransProtocol.ReSendPacket    += FileTransProtocol_ReSendPacket;
            FileTransProtocol.SendNextPacket  += FileTransProtocol_SendNextPacket;
            FileTransProtocol.TransmitTimeOut += FileTransProtocol_TransmitTimeOut;
            FileTransProtocol.StartSend       += FileTransProtocol_StartSend;
            FileTransProtocol.SendToUartEvent += FileTransProtocol_SendToUartEvent;

            packetNo  = 1;
            fileIndex = 0;
            FileTransProtocol.Start();

            if (StartTransmitFile != null)
            {
                StartTransmitFile(this, null);
            }

            return(true);
        }