//连接AP 路由器 void setCwjap() { staorap=1;//暂时连接wifi reset_value(); // ReadMultiBlockByte(Block_1,1,ReadBuffer); //readyByte(ReadBuffer); if(staorap==0) //说明当前连接的 热点 { printf("%s\r\n",APBuffer); }else{ //说明链接的是wifi printf("%s\r\n",STABuffer); } do { ptr1 = putstrstr(RxBuffer1, retrunok); //判断是否存在okstafllsr ptr2 = putstrstr(RxBuffer1, stafllsr); //判断是否存在okstafllsr if(ptr1!=NULL) { //printf("find ERROR !!\r\n"); status=0; Refresh_WWDG_Window(); } if(ptr2!=NULL) //说明链接失败 { //printf("find ERROR !!\r\n"); resetMCU();//复位MCU } // Delayms(1000); }while(status); }
//初始化 AP模式 开启 tcp 服务器 void setconfigAp() { int i=0; for(i;i<15;i++){ Refresh_WWDG_Window(); Delayms(30); Refresh_WWDG_Window(); Delayms(30); Refresh_WWDG_Window(); Delayms(30); Refresh_WWDG_Window(); } status=1; //reset_value(); //printf("AT+RST\r\n"); // wifi_rst(); setCwmode("2"); wifi_rst(); setCwsap(); wifi_rst(); findCwlif(); if(types==5) //需要重置 { resetMCU(); } do { if(types==1) { findCwlif(); }else { break; } }while(types); openTcpServier(); waitClientDate(); saveFlaceDate(); setCwmode("1"); wifi_rst(); // printf("=====%s\r\n",ReadBuffer); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), mUi(new Ui::MainWindow) { mUi->setupUi(this); mUi->b_disconnect->setEnabled(false); this->lockUI(true); mStlink = new stlinkv2(); mDevices = new DeviceInfoList(this); mTfThread = new transferThread(); mLastAction = ACTION_NONE; if (mDevices->IsLoaded()) { this->log(QString::number(mDevices->getDevicesCount())+" Device descriptions loaded."); QObject::connect(mUi->b_quit,SIGNAL(clicked()),this,SLOT(quit())); QObject::connect(mUi->b_connect, SIGNAL(clicked()), this, SLOT(connect())); QObject::connect(mUi->b_disconnect, SIGNAL(clicked()), this, SLOT(disconnect())); QObject::connect(mUi->b_send, SIGNAL(clicked()), this, SLOT(send())); QObject::connect(mUi->b_receive, SIGNAL(clicked()), this, SLOT(receive())); QObject::connect(mUi->b_verify, SIGNAL(clicked()), this, SLOT(verify())); QObject::connect(mUi->b_repeat, SIGNAL(clicked()), this, SLOT(repeat())); QObject::connect(mUi->b_halt, SIGNAL(clicked()), this, SLOT(haltMCU())); QObject::connect(mUi->b_run, SIGNAL(clicked()), this, SLOT(runMCU())); QObject::connect(mUi->b_reset, SIGNAL(clicked()), this, SLOT(resetMCU())); QObject::connect(mUi->r_jtag, SIGNAL(clicked()), this, SLOT(setModeJTAG())); QObject::connect(mUi->r_swd, SIGNAL(clicked()), this, SLOT(setModeSWD())); QObject::connect(mUi->b_hardReset, SIGNAL(clicked()), this, SLOT(hardReset())); // Thread QObject::connect(mTfThread, SIGNAL(sendProgress(quint32)), this, SLOT(updateProgress(quint32))); QObject::connect(mTfThread, SIGNAL(sendStatus(QString)), this, SLOT(updateStatus(QString))); QObject::connect(mTfThread, SIGNAL(sendLoaderStatus(QString)), this, SLOT(updateLoaderStatus(QString))); QObject::connect(mStlink, SIGNAL(bufferPct(quint32)), this, SLOT(updateLoaderPct(quint32))); QObject::connect(mTfThread, SIGNAL(sendLock(bool)), this, SLOT(lockUI(bool))); QObject::connect(mUi->b_stop, SIGNAL(clicked()), mTfThread, SLOT(halt())); QObject::connect(mTfThread, SIGNAL(sendLog(QString)), this, SLOT(log(QString))); // Help QObject::connect(mUi->b_help, SIGNAL(clicked()), this, SLOT(showHelp())); // Usb stuff QObject::connect(mStlink, SIGNAL(deviceDetected(QString)), this, SLOT(log(QString))); }
/** * 重构 查找 是否存在字符 */ char * putstrstr(char * rt,char * rx) { Delayms(10); Refresh_WWDG_Window(); char * rts = strstr(rt, rx); ptr3 = strstr (RxBuffer1,rest); if(ptr3 !=NULL) { resetMCU(); } if(rts!=NULL) { LED_Operation(LED_2, ON); }else { LED_Operation(LED_2, OFF); } return rts; }