Restored Connection With shard7

Discussions related to the WiServer add-on code for WiShield. WiServer is a friendly, easy-to-use front end for webserver and webclient usages.

Moderator: shard7

Re: Restored Connection With shard7

Postby GregEigsti » Wed Oct 20, 2010 8:42 pm

If you take a look at the source for WiFi.init() (in WiShield.cpp) you will see what it does to "bootstrap" the WiShield - in addition to zg_init() I'd recommend also calling stack_init() to make sure that the stack gets reset to a clean place as well. In cases like this I have just called WiFi.init() to reset everything and that has worked for my needs - I don't believe there is any harm in calling the interrupt assignment code a second, third, fourth, ..., time - but I have been wrong before.

For even more fun take a look at WiFi.init() in the user contrib branch; it returns a bool indicating whether or not a connection was made and it (optionally) takes a param that indicates the number of seconds to try connecting.

WiFi.init() from the regular (non user contrib) branch
Code: Select all
void WiShield::init()
{
   zg_init();

#ifdef USE_DIG0_INTR
   attachInterrupt(0, zg_isr, LOW);
#endif

#ifdef USE_DIG8_INTR
   // set digital pin 8 on Arduino
   // as ZG interrupt pin
   PCICR |= (1<<PCIE0);
   PCMSK0 |= (1<<PCINT0);
#endif

   while(zg_get_conn_state() != 1) {
      zg_drv_process();
   }

   stack_init();
}
Check out the wiki!
uIP Stack Docs
Compatible Access Point List
WiShield user contrib branch - DNS, DHCP, AP Scanning, bug fixes, etc.
SlackLab.org - My geek projects blog.
User avatar
GregEigsti
 
Posts: 1067
Joined: Sun Aug 02, 2009 5:23 pm
Location: Sammamish WA USA (near Seattle)
  • Website

Previous

Return to WiServer

Who is online

Users browsing this forum: No registered users and 2 guests