Test of cc3000:Sketch sends data using PHP to web server

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
sketchy
 
Posts: 285
Joined: Thu Jun 28, 2012 11:37 pm

Test of cc3000:Sketch sends data using PHP to web server

Post by sketchy »

In case this of interest to anyone.

I have been "playing around" with Adafruit's cc3000 in an attempt at growing my knowlege using this chip to send data (some day from many clients) to a web service.

Please help me reach my goal of "getting better" by letting me know how I could write or explain this sketch better.

Testing Connecting to Home Web Server Using cc3000

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Test of cc3000:Sketch sends data using PHP to web server

Post by adafruit_support_mike »

The code looks fairly straightforward overall. The only general comment I have is that your indentation is off in this section:

Code: Select all

    // Send request
     if (client.connected()) {
       Serial.println("Connected"); 
       String request = "GET "+ repository + "sensor.php?temp=" + temperature + "&hum=" + humidity + " HTTP/1.0\r\nConnection: close\r\n\r\n";
       Serial.print("...Sending request:");Serial.println(request);
       send_request(request);
  } else {
    Serial.println(F("Connection failed"));    
    return;
  }
The `else` clause needs to be shifted over so it's in line with the parent `if` statement.

Beyond that there isn't much I can suggest. The code does its job in simple and understandable terms, which is the main goal.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Test of cc3000:Sketch sends data using PHP to web server

Post by adafruit_support_rick »

The Arduino IDE now has an "Auto Format" command in the Tools menu. It works pretty well

User avatar
sketchy
 
Posts: 285
Joined: Thu Jun 28, 2012 11:37 pm

Re: Test of cc3000:Sketch sends data using PHP to web server

Post by sketchy »

Thank you both. I will fix the indentation and try "Auto Format" (I didn't know it existed - thanks!).

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

Return to “Arduino”