Chat freely about anything...

User avatar
By Houser636
#10477 Hello,

I can not seem to get any info from this website. What is the GET command to read the HTML from
http://www.daqduino.com/update/index.htm

AT+CIPSEND=54 ( I have no clue how to find the length. I thought it was just byte count, but thats not working)

I am trying GET / HTTP/1.1 Host: daqduino.com/update/index.htm\r\n

here is what I get -

Code: Select allGET / HTTP/1.1 Host: daqduino.com/update/index.htm


SEND OK

+IPD,1452:HTTP/1.1 400 Bad Request
Date: Mon, 23 Feb 2015 03:06:33 GMT
Server: Apache/2.4.12 (Unix) OpenSSL/1.0.1e-fp o_wimtd14md_ci/..0dv
Acp-ags:bts
oncto:coe
CnetTp:tx/hm

<DOTP tlPBLC"/WC/DDXTL10Tasiinl/N htp/www.ogT/hm1/T/hm1tantinldd><hm> <ed
  <il>00BdRqet/tte
  mt tt-qi=Cntn-ye onet"ethml hre=t-" >  <tl tp=tx/ss>    bdy{       otfaiy edn, ra,Hletc,sn-eif
    fn-sz:1p;     bcgondclr#6E8;       colbrbs-oor 057;     srlbr-ro-oo: F90;       srlbrDrShdwClr #000
       oo:#FFF
      agn0
    }       oo:02f5 etdcrainnn}     1{     fn-ie:1p;       olr F90;     pdig-otm 0x;       akrun-mg:ulsy_pnliagsbtobdyjg;       acgon-eea:rpa-;     pdig:p  0x1p;      mri:;     
    #oycnet 
    pain-et 5x;       adigrgt 5x;       ie-igt 8x
       adn-tp p;     pdigbttm p;     
    2{
    fn-sz:1p;     fn-egt bl;     clr F900
    pddn-et 5x
    }  <stl> <had
 b
K

+P,9:d>   dvi=bd-cnet> <!-satcnen->
!-
isea fRQET_R,w ol so boue R i: tp/HTPHS/EUETUI  bt hti t hts/ roheprtcl
 
  EVRPRTSCR os'tse ob ue
  EVRPRTlgcwud ra fte ueatrae ot
-
<140 a eus<h1
pYu rosrsn  rqetta hssevrcudno nesad</> <lcqut>  (oe/(pr 0
 /lokut>
p>  Pes oradti rrrsre osaedp16234.rdpx.ecrsre.e's
  ahe=milohsigx@oad.o?sbetErrmesg 40 0 BdRqetfr nn) ot 0o udy 2-e-052:6:3MT>  WeMse<a.</><r/

<- n otnt->  <dv
 <bd><hml

K

OK
Unlink



Thanks for any help.
User avatar
By dpwhittaker
#10482 Try GET /update/index.htm HTTP/1.1 Host: daqduino.com

Also, it looks like you are dropping characters when reading the response. What do you have hooked up to the serial? A computer or an arduino or something similar? You may need to use a lower baud rate.
User avatar
By Houser636
#10579 Hello,

I tried that GET command and I am not getting anything back using it.

I have a arduino Mega hooked up. I am trying to control an LED strip from the website. I have reset the baud to 9600. The update speed sucks too. It takes about 5 seconds to update using the AT commands. Would Lua be better at this? Here is my current code

Code: Select all#include <SoftwareSerial.h>




int flag=0;
SoftwareSerial mySerial(10, 11); // RX, TX
const int ledPin =  13;      // the number of the LED pin

int ledState = LOW;             // ledState used to set the LED
unsigned long previousMillis = 0; 


const unsigned long update_interval = 1000;   //was set to 1000 (10 secs.)  interval of updating color values from server  (Changed to 1 sec 2/1/2015 by Zach Houser)
unsigned long hold_last_millis = 0;

const long interval = 2000;           // interval at which data is sent to wifi module

int redPin = 2;
int greenPin = 3;
int bluePin = 4;
int whitePin = 5;


int colorRED = 0;
int colorGREEN = 0;
int colorBLUE = 0;
int whitness = 0;

void setup()
{
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
  pinMode(whitePin, OUTPUT);

  Serial.begin(9600);
  while (!Serial)
  {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  Serial.println("Connecting to wifi...");
  mySerial.begin(9600);
  mySerial.print("AT+CWJAP=");
  mySerial.print('"');
  mySerial.print("CenturyLink");
  mySerial.print('"');
  mySerial.print(",");
  mySerial.print('"');
  mySerial.print("XXX");
  mySerial.println('"');

  get_response(1000);  //show the response recieved from wifi module.

  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);
}

void loop()
{
  unsigned long currentMillis = millis();
  if(currentMillis - previousMillis >= interval)
  {
    previousMillis = currentMillis;   
    if (ledState == HIGH && flag == 0)
    {
      Serial.println("Connecting to server...");
      ledState = LOW;
      mySerial.print("AT+CIPSTART=");
      mySerial.print('"');
      mySerial.print("TCP");
      mySerial.print('"');
      mySerial.print(",");
      mySerial.print('"');
      mySerial.print("www.daqduino.com");
      mySerial.print('"');
      mySerial.print(",");
      mySerial.println("80");

      flag = 1;
    }
    if (ledState == HIGH && flag == 1)
    {
      Serial.println("Sending data length...");
      ledState = LOW;
      mySerial.println("AT+CIPSEND=49");

      flag = 2;
    }

    if (ledState == HIGH && flag == 2)
    {
      Serial.println("Sending GET request...");
      ledState = LOW;
      mySerial.println("GET /update/index.htm HTTP/1.1 Host: daqduino.com");

      flag = 3;
    }
    else
    {
      ledState = HIGH;
    }


    digitalWrite(ledPin, ledState);
  }

  if(flag==3)    //case of expecting response from wifi module
  {
    Serial.println("Recieving response...");
    String resp = get_response(2000);    //2000 is the timeout in ms

    //resp = "c44444444444444444444444444444\r\n344343324444444\nolor%Color#R:11;G:233;B:112;W:255;$wwwwwwww";  //only for debug
    if(resp.length()>0)
    {
      if(parse_colors(resp))
      {
        Serial.println("Setting colors");
        setColor(colorRED, colorGREEN, colorBLUE, whitness);
      }
      else
      {
        Serial.println("Invailed Response.");
      }

    }
    else
    {
      Serial.println("No Response");     
    }
    Serial.println("Closing Connection.");
    mySerial.println("AT+CIPCLOSE");
    hold_last_millis = millis();
    flag=4;
  }
  else
  {
    get_response(100);
  }

  if((flag==4)&&((millis() - hold_last_millis)>update_interval))
  {
    Serial.println("\r\n\r\n");
    Serial.println("Again...");
    flag=0;
  }

}



String get_response(int msecs)
{
  int dsecs = (msecs/10);
  int delayer = 0;

  String resp = "";
  while(delayer<dsecs)
  {
    while (mySerial.available())
    {
      char c = mySerial.read();
      resp += c;
    }
    delay(10);
    delayer++;
  }

  if(resp.length()>0)
  {
    Serial.println("Response:\r\n" + resp);
  }
  return resp;
}

boolean parse_colors(String resp)
{
  String ssf = resp;
  boolean found = false;
  int tries = 0;

  while((found==false)&&(tries<50))
  {
    String s = ssf.substring(ssf.indexOf('%'));
    if((s.indexOf('#')==6)&&(s.indexOf('l')==3)&&(s.indexOf('$')>20)&&(s.indexOf('$')<50))
    {
      found = true;
      s = s.substring(0, s.indexOf('$'));
      //Serial.println(s);
      colorRED = s.substring(s.indexOf('R') +2 , s.indexOf(';')).toInt();
      Serial.println("R: " + String(colorRED));
      s = s.substring(s.indexOf(';')+1);
      colorGREEN = s.substring(s.indexOf('G') + 2, s.indexOf(';')).toInt();
      Serial.println("G: " + String(colorGREEN));
      s = s.substring(s.indexOf(';')+1);
      colorBLUE = s.substring(s.indexOf('B') + 2, s.indexOf(';')).toInt();
      Serial.println("B: " + String(colorBLUE));
      s = s.substring(s.indexOf(';')+1);
      whitness = s.substring(s.indexOf('W') + 2, s.indexOf(';')).toInt();
      Serial.println("W: " + String(whitness));
    }
    else
    {
      ssf = s;
      tries++;
    }
  }

  if(found==false)
  {
    Serial.println("Couldn't find color codes in response from server");
  }

  return found;
}


void setColor(int red, int green, int blue, int white)
{
  /*
  #ifdef COMMON_ANODE
   red = 255 - red;
   green = 255 - green;
   blue = 255 - blue;
   #endif
   */
  analogWrite(redPin, red);
  analogWrite(greenPin, green);
  analogWrite(bluePin, blue); 
  analogWrite(whitePin, white);
}



Thanks for the help