Reading strings from server with CC3000

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
tguidon
 
Posts: 6
Joined: Thu Oct 03, 2013 10:26 am

Reading strings from server with CC3000

Post by tguidon »

Hey guys,

So in our office we have some cool machines that interact with the web. Servers send strings down to various arduinos that then interact with the world.

Previously we were able to use "client.readString()" to read strings from the server with the ethernet shield. With the new CC3000 shield it doesn't compile with the ".readString()" function in the code. It looks like we can only use .read() but that will not accept strings as an input. The basic set up was:

Code: Select all

if (client.available()) {
    String s = client.readString();
    Serial.println(s);
}
Does anyone have a way to get this to work? Thanks!

User avatar
reevesl
 
Posts: 3
Joined: Mon Apr 15, 2013 2:38 pm

Re: Reading strings from server with CC3000

Post by reevesl »

I've been reading into a char instead of a string.

Code: Select all

char c;
if (client.available()) {
    while (c = client.read()){   
        Serial.print (c);
    }
}
You can feed the chars into a string or parse them one at a time.

Hope that helps,
Reeves

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”