I've been struggling with a particular issue - sometimes, sending a POST request will cause the program to get stuck.
I delved into the Adafruit_CC3000 library to check it out. I found the place we're getting stuck!
It's a function called SpiWrite located in Adafruit_CC3000/ccspi.cpp. The offending while(1) loop is found here:
Code: Select all
long SpiWrite(unsigned char *pUserBuffer, unsigned short usLength)
{
.
.
.
/* The magic number that resides at the end of the TX/RX buffer (1 byte after the allocated size)
* for the purpose of overrun detection. If the magic number is overwritten - buffer overrun
* occurred - and we will be stuck here forever! */
if (wlan_tx_buffer[CC3000_TX_BUFFER_SIZE - 1] != CC3000_BUFFER_MAGIC_NUMBER)
{
DEBUGPRINT_F("\tCC3000: Error - No magic number found in SpiWrite\n\r");
while (1);
}
Here are my questions:
1. Why is the user purposefully being sent into a while(1) loop with no indication of the cause? I don't see this being documented anywhere, and we've already established that none of the DEBUG statements are supposed to be visible to users.
2. Can the location of CC3000_BUFFER_MAGIC_NUMBER be changed? I want to send a postdata string longer than 105 characters, and every time I go over this limit I overrun the buffer. I'm using a standard size POST header generated by this code:
Code: Select all
www.fastrprint(F("POST "));
www.fastrprint(WEBPAGE);
www.fastrprint(F(" HTTP/1.1\r\nHost: "));
www.fastrprint(WEBSITE); www.fastrprint(F("\r\n"));
www.fastrprint(F("User-Agent: Arduino/1.0\r\n"));
www.fastrprint(F("Connection: close\r\n"));
www.fastrprint(F("Content-Type: application/x-www-form-urlencoded\r\n"));
www.fastrprint(F("Content-Length: ")); www.fastrprint(len_c); www.fastrprint(F("\r\n"));
www.fastrprint(F("\r\n")); // Extra empty line for post argument
www.fastrprint(data_c); www.fastrprint(F("\r\n"));
www.fastrprint(F("\r\n"));
www.println(); Serial.println();