MC60 - Open MCU HTTP Post

hi guys,
I’m use MC60 Open mcu to create application Https post with content type is json but it’s not working.

char data_post[] = {“POST /gps.json HTTP/1.1\r\nHost:webname.com\r\nContent-Type:application/json\r\nContent-Length: 61\r\n\r\n{“Long”:“106.666”,“Lat”:“10.804”,“Time”:“090712”,“Speed”:“0”}”};

can you help me issue this problem.
thanks!

Hi Kutyace
Our MC60 is to support POST specified length of json data, you failed may be your process error or incoming parameter error caused, please post more relevant logs to us.
In fact, your post is a json data, but your previous URL and other data can be uploaded as a custom header, you can refer to the 《Quectel_GSM_HTTP_AT_Commands_Manual》.There’s custom header instructions.
Ths.

thank for your answer,
here is my code
//---------------------------------------
#define HTTP_URL_ADDR “https://tracker-k.firebaseio.com\0”
char data_post[] = {“POST /gps.json HTTP/1.1\r\nHost:tracker-k.firebaseio.com\r\nContent-Type:application/json\r\nContent-Length: 61\r\n\r\n{“Long”:“106.666”,“Lat”:“10.804”,“Time”:“090712”,“Speed”:“0”}”};

ret = RIL_NW_SetGPRSContext(Ql_GPRS_GetPDPContextId());
// Set APN
ret = RIL_NW_SetAPN(1, APN_NAME, APN_USERID, APN_PASSWD);
APP_DEBUG("<-- Set GPRS APN, ret=%d -->\r\n", ret);
// Open/Activate PDP context
ret = RIL_NW_OpenPDPContext();
APP_DEBUG("<-- Open PDP context, ret=%d -->\r\n", ret);

Ql_memset(strAT,0,sizeof(strAT));
Ql_sprintf(strAT, "AT+QSSLCFG=\"sslversion\",1,4\0");
Ql_RIL_SendATCmd(strAT, Ql_strlen(strAT), ATRsp_ATCMD_Handler, &errCode, 0);

Ql_memset(strAT,0,sizeof(strAT));
Ql_sprintf(strAT, "AT+QSSLCFG=\"seclevel\",1,0\0");
Ql_RIL_SendATCmd(strAT, Ql_strlen(strAT), ATRsp_ATCMD_Handler, &errCode, 0);

Ql_memset(strAT,0,sizeof(strAT));
Ql_sprintf(strAT, "AT+QSSLCFG=\"https\",1\0");
Ql_RIL_SendATCmd(strAT, Ql_strlen(strAT), ATRsp_ATCMD_Handler, &errCode, 0);

Ql_memset(strAT,0,sizeof(strAT));
Ql_sprintf(strAT, "AT+QSSLCFG=\"httpsctxi\",1\0");
Ql_RIL_SendATCmd(strAT, Ql_strlen(strAT), ATRsp_ATCMD_Handler, &errCode, 0);

// Set HTTP server address (URL)
ret = RIL_HTTP_SetServerURL(HTTP_URL_ADDR, Ql_strlen(HTTP_URL_ADDR));
// post-request
ret = RIL_HTTP_RequestToPost(data_post, Ql_strlen((char*)data_post));
APP_DEBUG("<-- Send post-request, postMsg=%s, ret=%d -->\r\n", (char*)data_post, ret);
// Read response from server
ret = RIL_HTTP_ReadResponse(120, HTTP_RcvData);
APP_DEBUG("<-- Read http response data, ret=%d, dataLen=%d -->\r\n", ret, m_rcvDataLen);

thanks!

1 Like

dear dakai.xu,
can you help me this problem about current MC60 when sleep, i use example_system in SDK1.7, when MC60 go to sleep mode (Ql_SleepEnable()) then current is 15-17mA very high, i saw in document said current is 1.2mA when sleep and DRX = 5,
do you have any solution for this problem to reduce current of MC60.
thanks a lot

Dear kutyace
Are you running the whole machine? Our 1.2mA is measured for a single module without a peripheral.

yes, i has found problem here is, we need pull-up Rx pin to VCC , that will reduce current from 11mA to 2-4mA in my project

Hello Kutyace.
Do you solved the problem with post to https?
I have the same module MC60 and the same problem.
I can successfully post to http, but not to https.
I have this settings:

 // Set PDP context
ret = RIL_NW_SetGPRSContext(Ql_GPRS_GetPDPContextId());
echo("<-- Set GPRS PDP context, ret = %d -->\r\n", ret);
if (ret < 0) return;

// Set APN
ret = RIL_NW_SetAPN(1, APN_NAME, APN_USERID, APN_PASSWD);
echo("<-- Set GPRS APN, ret = %d -->\r\n", ret);
if (ret < 0) return;

// Open/Activate PDP context
ret = RIL_NW_OpenPDPContext();
echo("<-- Open PDP context, ret = %d -->\r\n", ret);
if (ret < 0) return;

// Set HTTP server address (URL)
ret = RIL_HTTP_SetServerURL(HTTP_URL_ADDR, Ql_strlen(HTTP_URL_ADDR));
echo("<-- Set http server URL, ret = %d -->\r\n", ret);
if (ret < 0) return;

Then I post message and get response:

prepareStringToSend(buff, sizeof(buff), utime);
echo ("Try to send to %s\n", HTTP_URL_ADDR);
ret = RIL_HTTP_RequestToPost(buff, Ql_strlen((char*)buff));

ret = RIL_HTTP_ReadResponse(120, HTTP_RcvData);

This code perfectly work for http.

As I understand to post https I need to setup SSL settings via QSSLCFG. I tried different variation of settings (like in this guide https://forums.quectel.com/uploads/short-url/bRyezKC52TxiZpsFq6yinZiGiCF.pdf, settings from the first message of this topic I tried too), but every time when I tried to post message I get some kind error like 3815 (http socket connection error) or 3818 (http socket close).

Can you show up your setup?
Thank you in advance!