I have a simple little sketch that samples temperature and humidity every few minutes and sends the data to a web server via wifi, using an Async Labs shield. It runs for while happily transmitting, sometimes for several days but it will eventually crash hard and need a manual reset.
I have long suspected that there was a problem in the shield library and today I found it. In g2100.c I found this snippet:
case ZG_INTR_ST_RD_CTRL_REG:
{
U16 rx_byte_cnt = (0x0000 | (hdr[1] << 8) | hdr[2]) & 0x0fff;
zg_buf[0] = ZG_CMD_RD_FIFO;
spi_transfer(zg_buf, rx_byte_cnt + 1, 1);
hdr[0] = ZG_CMD_RD_FIFO_DONE;
spi_transfer(hdr, 1, 1);
intr_valid = 1;
intr_state = 0;
break;
}
zg_buf's size is 400 bytes. Verizon kindly broadcast packets to me that are over 600 and so when one arrives, there is going to be massive buffer overflow. I'm a little surprised that it runs as long as it did. I note that this problem has been observed before, but didn't find this out until I had found this and then knew to search for ZG_INTR_ST_RD_CTRL_REG. I don't see any solution though.
Before I dig into the details of talking to the ZG2100 over SPI to try and repair this, does anyone know of an existing fix?