CC3000 with Teensy3.1

Status
Not open for further replies.
Great news!

I didn't quite understand what solved the problem. Just the println or is the energia library also required?
 
Was just rambling. :)

So the Energia library is required in place of the adafruit one. With several tweaks required to it as detailed in an earlier post, and then another tweak required to the TCPclient write method.
This currently goes into a loop and counts down the number of bytes to send, however if a SPI error happens the HCI driver returns a -1 to indicate that an error occurred, the code then add's that to the index which is wrong as it will skew the pointer and potentially buffer underrun. Which is not good.

Eg
Code:
   int strlen = size,i = 0;

	if(size == 0) return 0;

	do{

		if(strlen-i<TX_BUF_SIZE){
			i += send(((long)clientSocket)&0xFF, buf+i, strlen-i, 0);
		}
		else {
			[COLOR="#FF0000"]i +=[/COLOR] send(((long)clientSocket)&0xFF, buf+i, TX_BUF_SIZE, 0);
		}

	}while( i < strlen);

	return strlen;

So the highlighted red would be bad if the send errors as a -1 is sent, but the code doesn't check for errors.

So instead It would need to be
Code:
int strlen = size,i = 0,r = 0, retry = 3;

	if(size == 0) return 0;

	do{
		if(strlen-i<TX_BUF_SIZE){
			r=send(((long)clientSocket)&0xFF, buf+i, strlen-i, 0);
		}
		else {
			r=send(((long)clientSocket)&0xFF, buf+i, TX_BUF_SIZE, 0);
		}
		if (r<0) retry--;
		else {
		  i+=r;
		  retry=3;
		}
	}while( i < strlen && retry>0);


	return strlen;

But aside from that, it still not entirely fixed. I've seen it get stuck somewhere in the socket accept and still need to find out why the send is erroring.

But I will get there. Once I do I will release my copy of the library (need to check if I can do that, license wise). And hopefully we'll have a stable WifiLink library for the teensy.
 
Status
Not open for further replies.
Back
Top