Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making Asynchronous POST request #4

Open
solankigithub opened this issue Jul 18, 2016 · 0 comments
Open

Making Asynchronous POST request #4

solankigithub opened this issue Jul 18, 2016 · 0 comments

Comments

@solankigithub
Copy link

Hi,
Can you please suggest, how can i make an Asynchronous calls and POST data without any response.
I need to post the data every 2 seconds from my device to Server. At this moment, i don't want any acknowledgement, but rather just post the data.
Is there any way to achieve this?
I created my own method in the library as shown below, but its still taking 10 seconds.

int InetGSM::httpAsyncPOST(const char* server, int port, const char* path, const char* parameters, char* result, int resultlength)
{
     boolean connected=false;
     int n_of_at=0;
     char itoaBuffer[8];
     int num_char;
     char end_c[2];
     end_c[0]=0x1a;
     end_c[1]='\0';


     while(n_of_at<3) {
          if(!connectTCP(server, port)) {
#ifdef DEBUG_ON
               Serial.println("DB:NOT CONN");
#endif
               n_of_at++;
          } else {
               connected=true;
               n_of_at=3;
          }
     }


     if(!connected) return 0;

     gsm.SimpleWrite("POST ");
     gsm.SimpleWrite(path);
     gsm.SimpleWrite(" HTTP/1.1\r\nHost: ");
     gsm.SimpleWrite(server);
     gsm.SimpleWrite("\r\n");
     gsm.SimpleWrite("User-Agent: Arduino\r\n");
     gsm.SimpleWrite("Content-Type: application/x-www-form-urlencoded\r\n");
     gsm.SimpleWrite("Content-Length: ");
     itoa(strlen(parameters),itoaBuffer,10);
     gsm.SimpleWrite(itoaBuffer);
     gsm.SimpleWrite("\r\n\r\n");
     gsm.SimpleWrite(parameters);
     gsm.SimpleWrite("\r\n\r\n");
     gsm.SimpleWrite(end_c);

     return 1;
}

Can you please suggest more improvements ?
Also, is it mandatory to close the connection every time using AT+CIPCLOSE ?
Isn't there a way to make the connection open and send the packet to the server ?

You quick response will be highly appreciated !

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant