standalone Wifi Bee disconnecting

Hi,

I bought a Wifi Bee for a remote control project. Using the Arduino >V1 IDE I used the user contrib library linked in the product wiki page.
As the module disconnected from the network after some time and didn’t come back online without a reset (and I mean “power down”, wait some seconds, “power up”), I first thought my code was doing something nasty. But as I tried again the simple server demo I encountered the same issue.

  • I power it on
  • the blue LED shines after a few seconds (using the 32 byte precalculate WPA/WPA2 key system)
  • it works :sunglasses: for some time… :frowning:
  • the blue LED turns off after a while, the module is not reacheable, and nevers comes back online.

So I have 2 questions:

  • is it a known issue ? The library states that there is none…
  • how to workaround it ? I could reset it every once in a while or when connection is lost (I would have to detect it in the code) but a simple reset doesn’t bring it back online, I have to power it off and on again.

Of course it is intended to be ON and reacheable all the time.

Am I the only person having this problem ?
Am I the only person having this board ? :slight_smile:

Ok here is what I found, if someone encounter the same issue :
I software-reset the controller in case of a disconnection. The connection state is available by the zg_get_conn_state() function returning 1 if connected, 0 otherwise. The software reset is possible when defining a null function.

[code]
extern “C” {
#include <g2100.h>
}
[…]
void setup() {
WiServer.init(sendMyPage);
}
[…]
void(* resetFunc) (void) = 0; //declare reset function @ address 0
void loop(){
if (zg_get_conn_state() == 0){ // disconnected
resetFunc(); //call reset
}
// Run WiServer
WiServer.server_task();

delay(10);
}[/code]

Trying to call WiServer.init in case of a disconnection was not sufficient.

I don’t know if that solution is good enough in the long run but it seems to work on a small test (reset after a while and see if the connection comes back)

EDIT: I does NOT work, still loosing connection after some time :frowning:

Though I feel a little alone here… I made a test using the simple server example. I just write a message every minute and try to reconnect if the connection is lost.
What I see is that either the reconnection never ends or the controller just hangs because “heartbeat” messages stop after this connection loss.

#define DEBUG
#define DEBUG_VERBOSE
#include <WiServer.h>

extern "C" {
#include <g2100.h>
}

// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[]    = {
  192,168,1,87};   // IP address of WiShield
unsigned char gateway_ip[]  = {
  192,168,1,1};   // router or gateway IP address
unsigned char subnet_mask[] = {
  255,255,255,0}; // subnet mask for the local network
char ssid[]                 = {
  "MyNetwork"};   // max 32 bytes

unsigned char security_type = 4;	// 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2; 4 - WPA Precalc; 5 - WPA2 Precalc

// Depending on your security_type, uncomment the appropriate type of security_data
// 0 - None (open)
//const prog_char security_data[] PROGMEM = {
//};

// 1 - WEP 
// UIP_WEP_KEY_LEN. 5 bytes for 64-bit key, 13 bytes for 128-bit key
// Only supply the appropriate key, do not specify 4 keys and then try to specify which to use
//const prog_char security_data[] PROGMEM = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, };

// 2, 3 - WPA/WPA2 Passphrase
// 8 to 63 characters which will be used to generate the 32 byte calculated key
// Expect the g2100 to take 30 seconds to calculate the key from a passphrase
//const prog_char security_data[] PROGMEM = {"xxxxxxxxxx"};

// 4, 5 - WPA/WPA2 Precalc
// The 32 byte precalculate WPA/WPA2 key. This can be calculated in advance to save boot time
// http://jorisvr.nl/wpapsk.html
const prog_char security_data[] PROGMEM = {
  MYPASSWD
};

// setup the wireless mode
// WIRELESS_MODE_INFRA - connect to AP
// WIRELESS_MODE_ADHOC - connect to another WiFi device
unsigned char wireless_mode = WIRELESS_MODE_INFRA;
// End of wireless configuration parameters ----------------------------------------

long heartbeat = 60000;
long nextHeartbeat = 0;

// This is our page serving function that generates web pages
boolean sendMyPage(char* URL) {
  
    // Check if the requested URL matches "/"
    if (strcmp(URL, "/") == 0) {
        // Use WiServer's print and println functions to write out the page content
        WiServer.print("<html>");
        WiServer.print("Hello World!");
        WiServer.print("</html>");
        
        // URL was recognized
        return true;
    }
    // URL not found
    return false;
}


void setup() {
  Serial.begin(9600);
  // Initialize WiServer and have it use the sendMyPage function to serve pages
  Serial.println("Connecting");
  WiServer.init(sendMyPage);
  Serial.println("Connected");
  
}

void loop(){
  if (nextHeartbeat < millis()){
    Serial.print("Still alive after ");
    Serial.print(millis()/60000);
    Serial.println("mn");
    nextHeartbeat = millis() + heartbeat;
  }
  if (zg_get_conn_state() == 0){ // disconnected
    Serial.println("Disconnected...");
    WiServer.init(sendMyPage);
  }
  
  // Run WiServer
  WiServer.server_task(); 
  delay(10);
}

After some time here is what I see:

Connecting
Connected
Still alive after 0mn
Still alive after 1mn
Still alive after 2mn
[...]
Still alive after 105mn
Disconnected...

I made no connection to the server, it’s just looping happily. I left it all day, and when I came back I saw no other print (meaning no print for 4h).