void main_menu() { // main loop while (1) { led1=led2=led3=led4=0; mnu->SetScreen(1); while (1) {; mnu->Handle(); Net::poll(); if (srv->State() != listen) { GetFile(); char myname[32]; srv->getFilename(myname); if (isFirmware(myname)) { installFirmware(myname); mnu->SetScreen(1); } else { if (strcmp("config.txt", myname) == 0) { // it's a config file! mnu->SetScreen(1); } else { if (isLaosFile(myname)) { mnu->SetFileName(myname); mnu->SetScreen(2); } } } } } } }
void main_menu() { // main loop led1=led2=led3=led4=0; mnu->SetScreen(1); while (1) { int filecnt = srv->fileCnt(); mnu->Handle(); srv->poll(); if (srv->State() != listen) { mnu->SetScreen("Receive file"); while ((! mnu->Cancel()) && (srv->State() != listen)) srv->poll(); } if (filecnt < srv->fileCnt()) { char myname[32]; srv->getFilename(myname); if (isFirmware(myname)) { installFirmware(myname); mnu->SetScreen(1); } else { if (strcmp("config.txt", myname) == 0) { // it's a config file! mnu->SetScreen(1); } else { if (isLaosFile(myname)) { mnu->SetFileName(myname); mnu->SetScreen(2); } } } } } }
char* getLaosFile() { extern LaosFileSystem sd; DIR *d; struct dirent *p; d = opendir("/sd"); if (d != NULL) while ((p=readdir(d)) != NULL) if (isLaosFile(p->d_name)) { char *name = new char[strlen(p->d_name)+1]; strcpy(name, p->d_name); closedir(d); return name; } closedir(d); return NULL; }