Test of cc3000:Sketch sends data using PHP to web server
Moderators: adafruit_support_bill, adafruit

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

by sketchy on Fri Sep 20, 2013 5:15 pm

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
sketchy
 
Posts: 63
Joined: Thu Jun 28, 2012 10:37 pm

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

by adafruit_support_mike on Sat Sep 21, 2013 1:54 am

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

Code: Select all | TOGGLE FULL SIZE
    // 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.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 9133
Joined: Thu Feb 11, 2010 1:51 pm

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

by adafruit_support_rick on Sat Sep 21, 2013 6:13 am

The Arduino IDE now has an "Auto Format" command in the Tools menu. It works pretty well
User avatar
adafruit_support_rick
 
Posts: 11582
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

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

by sketchy on Sat Sep 21, 2013 8:06 am

Thank you both. I will fix the indentation and try "Auto Format" (I didn't know it existed - thanks!).
sketchy
 
Posts: 63
Joined: Thu Jun 28, 2012 10:37 pm