Go Down

Topic: WiFlySerial and WiFly RN-XV (Read 4 times) previous topic - next topic

PaulS

Quote
the slash is there on the MY_SERVER_GET

But that's not where it needs to be.

garrettlynch

I have tried

Code: [Select]
#define MY_SERVER_GET "http://www.mysite.com/"
#define MY_SERVER_GET_URL "in-progress/arduino-test/counter/index.php"


and this

Code: [Select]
#define MY_SERVER_GET "http://www.mysite.com"
#define MY_SERVER_GET_URL "/in-progress/arduino-test/counter/index.php"


Still no change, my php page doesnot get called.

garrettlynch

This

Code: [Select]
#define MY_SERVER_GET "www.mysite.com"
#define MY_SERVER_GET_URL "http://www.mysite.com/in-progress/arduino-test/counter/index.php"


without the http:// seems to be doing something.  In the Serial Monitor I'm now getting:

Code: [Select]
$$$open www.mysite.com 80
GET http://www.mysite.com/in-progress/arduino-test/counter/index.php?count=237 HTTP/1.1
Host: www.mysite.com
Connection: close


with the count number incrementing up each time.  My php counter however still doesn't seem to be called.  The full code is below again.

thanks
Garrett

Code: [Select]
#include <Arduino.h>
#include <Time.h>
#include <SoftwareSerial.h>
#include <Streaming.h>
#include <PString.h>
#include <WiFlySerial.h>


//various buffer sizes
#define REQUEST_BUFFER_SIZE 180
#define TEMP_BUFFER_SIZE 60

//server hosting GET example php script
#define MY_SERVER_GET "www.mysite.com"
#define MY_SERVER_GET_URL "http://www.mysite.com/in-progress/arduino-test/counter/index.php"

//xbee pro shiel uses pins 0, 1
WiFlySerial wifi(0, 1);
char bufRequest[REQUEST_BUFFER_SIZE];
char bufTemp[TEMP_BUFFER_SIZE];

//sotware serial pins for testing
//SoftwareSerial mySerial(4, 5);

//loop counter
int iLoopCounter = 0;

//start time
unsigned long startTime = 0;


void setup()
{
  //set up serial
  //Serial.begin(9600);
 
  //set the data rate for the SoftwareSerial port and send a message to test
  //mySerial.begin(9600);
  //mySerial.println("Software serial working");
 
  //start up WiFly
  wifi.begin();

  //mySerial.println("Joined");
}


void loop()
{
  //calculate the time since last time the cycle was completed
  unsigned long loopTime = millis() - startTime;

  //to test
  //mySerial.println("test 0");

  //if the timer is greater than or equal to 5 seconds (5000 milliseconds)
  if (loopTime >= 5000)
  {
    char bufRequest[REQUEST_BUFFER_SIZE];
    PString strRequest(bufRequest, REQUEST_BUFFER_SIZE);
     
    // Build GET expression
    strRequest << F("GET ") << MY_SERVER_GET_URL << F("?count=") << iLoopCounter
    << F(" HTTP/1.1") << "\n"
    << F("Host: ") << MY_SERVER_GET << "\n"
    << F("Connection: close") << "\n"
    << "\n\n";
    // send data via request
    // close connection
 
    //to see what the GET request looks like
    //mySerial << F("GET request:")  << strRequest << endl;
     
    //open connection, then send GET Request, and display response.
    if (wifi.openConnection(MY_SERVER_GET))
    {
      wifi <<  (const char*) strRequest << endl;
   
      //to test
      //mySerial.println("test 2");
   
      // Show server response

      //how long to wait before timing out on the GET request
      unsigned long TimeOut = millis() + 3000;

      while (millis()  < TimeOut && wifi.isConnectionOpen())
      {
        if (wifi.available() > 0)
        {
            wifi.read();
        }
      }

      //force-close connection
      wifi.closeConnection();
    }
    else
    {
      //failed to open
      //mySerial.println("Failed to open connection");
    }
 
    //restart timer
    startTime = millis();
  }

  //increment the loop counter
  iLoopCounter++;

  //to prevent spamming serial monitor too much
  delay(250);
}

pylon

This is not correct:

Code: [Select]
GET http://www.mysite.com/in-progress/arduino-test/counter/index.php?count=237 HTTP/1.1

On the GET line you must not supply a URL (with the http:// and the server) but the path (location) on the server. And use HTTP/1.0 as you don't use any HTTP 1.1 feature, some servers are a bit picky about that.

Have you checked if you WiFly gets an IP? And a DNS server? Does your www.mysite.com resolve on that DNS server?

Have tried doing the same request manually (using the telnet command on the command line)?

garrettlynch


On the GET line you must not supply a URL (with the http:// and the server) but the path (location) on the server.


You mean path client side not server side right?



Have you checked if you WiFly gets an IP? And a DNS server? Does your www.mysite.com resolve on that DNS server?


Through my router configuration panel yes.  It has the ip 192.168.1.68.  A DNS server, for my WiFly or for www.mysite.com?  Mysite.com works, I can access it through a browser.  If I type it's ip address it also works.



Have tried doing the same request manually (using the telnet command on the command line)?


Yes and it works fine.

Code: [Select]
telnet mysite.com 80
Trying 62.81.51.152...
Connected to mysite.com.


Go Up