Configure SIM800H HTTP functionalities + a reading issue


hello everyone,


i encounter 2 little impediments in gsm quest  :p

so, first 1 http. i'm trying configure http functionalities nothing work.

here serial monitor :
code: [select]

>
> ok
> at+cmgf=1
> ok
>
> call ready    //boring urc
> at+httpinit
> ok
>
> sms ready    //boring urc
> at+httppara="cid",1
> ok
> at+httppara="url","http:\\www.google.com"
> ok
> at+httpact    //truncated answer...
> ok
>
> +cpin: ready    //boring urc
at+httpinitat+httppara="cid",1    //wtf
> at+hat+httpaction=0    //well
> ok    //i doubt




so before try http must solve second problem : how can better reading results ?
i tryed follow nice tutorial : https://forum.arduino.cc/index.php?topic=396450.0


here code :
code: [select]

#define sim800_reset_pin 77
#define pwkey 6
const byte nbchars = 64;
char receivedchars[nbchars];
boolean newdata = false;
string commandstringgsm;
string url = "http:\\\\www.google.com";
void setup() {
  serial.begin(9600);
  serial1.begin(9600);

  pinmode(sim800_reset_pin, output);
  pinmode(pwkey, output);
  digitalwrite(pwkey, high);
  delay(1000);
  digitalwrite(sim800_reset_pin, low);
  delay(100);
  digitalwrite(sim800_reset_pin, high);
  delay(2000);



}

void loop() {
     
      delay(2000);
      // network registration
      commandstringgsm = "at+creg=1";
      serial1.println(commandstringgsm);
      delay(50);
      readfromgsm();     
      shownewdata();
      delay(500);
     
      // set text mode
      commandstringgsm = "at+cmgf=1";
      serial1.println(commandstringgsm);
      delay(50);
      readfromgsm();
      shownewdata();
      delay(500);


      // init http service
      commandstringgsm = "at+httpinit";
      serial1.println(commandstringgsm);
      delay(50);
      readfromgsm();     
      shownewdata();
      delay(500);

     

      // init http service
      commandstringgsm = "at+httppara=\"cid\",1";
      serial1.println(commandstringgsm);
      delay(50);
      readfromgsm();     
      shownewdata();
      delay(500);

      // init http service
      commandstringgsm = "at+httppara=\"url\",\"" + url + "\"";
      delay(100);
      serial1.println(commandstringgsm);
      delay(100);
      readfromgsm();   
      shownewdata();
      delay(500);

     
      // start session
      commandstringgsm = "at+httpaction=0";
      serial1.println(commandstringgsm);
      delay(50);
      readfromgsm();     
      shownewdata();
      delay(500);     

      // start session
      commandstringgsm = "at+httpread";
      serial1.println(commandstringgsm);
      delay(50);
      readfromgsm();     
      shownewdata();
      delay(500);
   
      // read http status
      commandstringgsm = "at+httpstatus";
      delay(100);
      serial1.println(commandstringgsm);
      delay(100);
      readfromgsm();     
      shownewdata();
      delay(500);
}


void readfromgsm(){

    static byte ndx = 0;
    char endmarker = '\n';
    char rc;
    delay(200);
    while(serial1.available() > 0 && newdata == false && (receivedchars[ndx] != '\n' || receivedchars[ndx] != '\r')){
   
        rc = serial1.read();
        if (rc != endmarker){
          receivedchars[ndx] = rc;
          ndx++;
          if (ndx >= nbchars) {
            ndx = nbchars -1;
          }
        }else {
            receivedchars[ndx] = '\0'; // terminate string
            ndx = 0;
            newdata = true;
        }
    }
}

void shownewdata(){
    if (newdata == true) {
        serial.print("> ");
        serial.println(receivedchars);
        newdata = false;
    }
}


i have no idea i'm doing wrong in reading function...
unfortunately gsm.h library gsm shield doesn't work arduino due , sim800h guess have configure module alone commands... way i'm trying here ?

thank !



Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > Configure SIM800H HTTP functionalities + a reading issue


arduino

Comments

Popular posts from this blog

Flip address is out of range arduino uno r3

Arduino Uno not uploading

Indesign and MathType fonts