uint8_t EtherShield::ES_dnslkup_haveanswer(void) { return( dnslkup_haveanswer() ); }
/*---------------------------------------------------------------------------*/ static PT_THREAD(www_client_thread(struct pt *pt)) { PT_BEGIN(pt); while(1) { /* TODO: Add debouncing ... */ PT_WAIT_UNTIL(pt,btn2_pressed()); PT_WAIT_UNTIL(pt,!btn2_pressed()); dbg(PSTR("> Web client starts.\r\n")); retry_count = 0; do { /* disable interrupts */ cli(); /* reset timeout counter */ www_client_counter = 0; /* re-enable interrupts */ sei(); /* make a dns request */ dnslkup_request(buf,URL_base_address,gwmac); /* wait an answer ... */ PT_WAIT_UNTIL(pt,dnslkup_haveanswer()||www_client_timeout()); if(dnslkup_haveanswer()) { /* exit the loop */ retry_count = 0xFF; } else { dbg(PSTR("> DNS lookup timeout!\r\n")); retry_count++; } } while(retry_count < 5); if(dnslkup_haveanswer()) { /* save the received IP to your userspace variable */ dnslkup_get_ip(otherside_www_ip); /* reset callback state */ www_callback_state = 0; /* reset retry count */ retry_count = 0; /* browsing action */ do { /* disable interrupts */ cli(); /* reset timeout counter */ www_client_counter = 0; /* re-enable interrupts */ sei(); /* increment the trial counter */ retry_count++; client_browse_url( PSTR("/ws.php?c="), /* constant part of the URL suffix */ "Samsun", /* variable part of the URL which comes after the constant suffix */ URL_base_address, /* base-name of the web page we want to browse */ &browserresult_callback, /* callback function for our URL browsing attempt */ otherside_www_ip, /* IP representation of the webpage host */ gwmac /* mac address of our gateway */ ); /* wait ... */ PT_WAIT_UNTIL(pt,www_client_failed() || www_client_timeout() || www_client_ok() || return_counter() ); if(www_client_ok()) { /* exit the loop */ retry_count = 0xFF; } else if(www_client_failed()) { dbg(PSTR("> Browsing problem!\r\n")); } else if(www_client_timeout()) { dbg(PSTR("> Browsing timeout!\r\n")); } } while(retry_count < 5); if(retry_count == 0xFF) { dbg(PSTR("> Browsing went ok!\r\n")); } else { dbg(PSTR("> Browsing failed!\r\n")); } dbg(PSTR("> -------------------------------------\r\n")); } else { dbg(PSTR("> Browsing failed!\r\n")); dbg(PSTR("> -------------------------------------\r\n")); } } PT_END(pt); }