HTTP post for BG96

I need a sample/example code for http post. example is sdk is only for http get. IT will nice for any link or suggestion.

Tried to write http post, but have following queries regarding Quectel SDK ,Any help/suggestion will be very helpful :
i)I was trying to increase memory allocation in example_http, but unable to increase free_memory_http[] above 400KB, rest of the code/memory in example is hardly 25KB. What my understanding is BG96 supports 3MB RAM, but my process is unable to use them. Is there any restriction on usage of RAM for a specific thread or we need some configuration setup to use say some where near 3MB of RAM.

ii) I wrote small code to http post, something like:

http_hadle = qapi_Net_HTTPc_New_sess(20000, 0, http_client_cb, NULL, 70 *1024, 1 * 1024);

ret = qapi_Net_HTTPc_Add_Header_Field(http_hadle, “Content-Type”,“application/octet-stream”);
if (ret != QAPI_OK)
{
HTTP_UART_DBG(“qapi_Net_HTTPc_Add_Header_Field ERROR :%d”,ret);
return ret;
}

int data_size = 0;

http_store_read_from_data_file(FILE_PATH_UL,(size_t *)&data_size);

ret = qapi_Net_HTTPc_Add_Header_Field(http_hadle, “Content-Length”,&data_size); // Not sure if required
if (ret != QAPI_OK)
{
HTTP_UART_DBG(“qapi_Net_HTTPc_Add_Header_Field ERROR :%d”,ret);
return ret;
}

HTTP_UART_DBG(“http_store_read_from_data_file success :%d”, data_size);

ret = qapi_Net_HTTPc_Set_Body(http_hadle,file_buf,data_size);
if (ret != QAPI_OK)
{
HTTP_UART_DBG(“qapi_Net_HTTPc_Set_Body ERROR :%d”,ret);
return ret;
}

/* post content /
ret = qapi_Net_HTTPc_Request(http_hadle, QAPI_NET_HTTP_CLIENT_POST_E, (char
)file_name);
if (ret != QAPI_OK)
{
HTTP_UART_DBG(“qapi_Net_HTTPc_Request ERROR :%d”,ret);
return -5;
}

Point is so do I have to reserve memory as specified in qapi_Net_HTTPc_New_sess() or http post qapi_Net_HTTPc_Set_Body() re-use the memory provided in the call?

iii) Also, when I am reading data from a file, was unable to read more than 32KB at a time, again is there any restriction on size of data that can be read from a file in single go ?

1 Like

Hi,

You have to reserve the memory for qapi_Net_HTTPc_New_sess() and qapi_Net_HTTPc_Set_Body will use the same allocated memory.

1 Like