/*-----------------------------------------------------------------------------------*/ PROCESS_THREAD(wget_process, ev, data) { static char name[32]; static unsigned char i; PROCESS_BEGIN(); /* Allow other processes to initialize properly. */ for(i = 0; i < 10; ++i) { PROCESS_PAUSE(); } fputs("Get url:", stdout); if(contiki_argc > 1) { strcpy(url, contiki_argv[1]); puts(url); } else { gets(url); } fputs("Save as:", stdout); if(contiki_argc > 2) { strcpy(name, contiki_argv[2]); puts(name); } else { gets(name); } file = cfs_open(name, CFS_WRITE); if(file == -1) { printf("Open error with '%s'\n", name); app_quit(); } else { petsciiconv_toascii(url, sizeof(url)); start_get(); } while(1) { PROCESS_WAIT_EVENT(); if(ev == tcpip_event) { webclient_appcall(data); #if UIP_UDP } else if(ev == resolv_event_found) { /* Either found a hostname, or not. */ if((char *)data != NULL && resolv_lookup((char *)data, NULL) == RESOLV_STATUS_CACHED) { start_get(); } else { puts("Host not found"); app_quit(); } #endif /* UIP_UDP */ } } PROCESS_END(); }
response request::get(char const * url) { auto resp = start_get(url); resp.wait(); return resp; }
response request::start_get(std::string const & url) { return start_get(url.c_str()); }