0

I am using a SIM808 with a atmega2560.

I have setup the endpoint in Azure and that works when I try a http post via postman and/or an online http post tool (I get a 202 as result and see data comming into Azure)

I want to send a json package to an Azure http endpoint (smart app) using the function httpPOST in the SIMCom library from itead.

I am connecting to the network:

logging (I printed all that is written to GSM):

AT+CIFSR
DB:STARTING NEW CONNECTION
AT+CIPSHUT
DB:SHUTTED OK
AT+CSTT="provider.net","","" DB:APN OK
AT+CIICR
DB:CONNECTION OK
AT+CIFSR
DB:ASSIGNED AN IP
GPRS status=ATTACHED
AT+CIPSTART="TCP","prod-13.westeurope.logic.azure.com",443
DB:RECVD CMD
DB:OK TCP

Then call the httpPost function from the library with the following variables:

const char server[35] = "prod-13.westeurope.logic.azure.com";
const int port = 443;
const char path[200] = "/workflows/someazureID/triggers/manual/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=someazuretoken";
const char parameters[100] = "{\"device\":\"alive\",\"timestamp\":\"09270845\"}";

Part of the httpPost function from the library for sending the data

    int InetGSM::httpPOST(const char* server, int port, const char* path, const char* parameters, char* result, int resultlength)
         ....
    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/json\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);
....

Which gives this output on the serial monitor (I printed all that is written to GSM):

AT+CIPSEND
DB:>
POST /workflows/someazureID/triggers/manual/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=someazuretoken HTTP/1.1
Host: prod-13.westeurope.logic.azure.com
User-Agent: Arduino
Content-Type: application/json
Content-Length: 55

{"device":"alive","timestamp":"09270845"}

DB:SENT

And then it is waiting for a response:

Starting read..
Waiting for Data............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 
CLOSED 

Done..
response:
10

CLOSED

which times out I guess.

And I see nothing coming into Azure.

(I am getting data when I try a httpGet on a random site. So hardware, sim and network is working ok I guess)

Any ideas? thx!

  • doesn't Azure use https? – Juraj Sep 27 '18 at 15:36
  • yes it does, I am connecting to port 443 'const char server[35] = "prod-13.westeurope.logic.azure.com"; const int port = 443;' But honestly I have never done this before so maybe I am forgetting/missing something – Jeroen Sep 27 '18 at 16:21
  • I don't know the AT commands for the GSM module, but it doesn't look like you would handle SSL – Juraj Sep 27 '18 at 16:51
1

Juraj's comments put me on the right track, for SSL you need to do more then just select the port.

I did some searching and got it to work using a different GSM library that also supports SSL: tinyGSM

in combination with ArduinoHttpClient

Jeroen

EDIT: It works, but there is a big downside. It looks like there is major overhead, each message seems to uses 13Kb of data...? I suspect this comes from the data that is returned by the endpoint. This is way too much over GPRS so now looking into MQTT.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.