This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

problems passing payload to AT#XHTTPCREQ in serial_lte_modem

When working with AT#XHTTPCREQ we have encountered the following provlems:

1. Sending AT Command `AT#XHTTPCREQ="POST","/upload","Content-Length:3357",3357` with the payload of size 3357 in one line, it breaks the serial_lte_modem app. This limit is not mentioned in the docs https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/applications/serial_lte_modem/doc/HTTPC_AT_commands.html I think it is caused by the handling of buffer overflow - it only drops the last character, but the app itself never recovers from it.

2. If we send the payload chunked, we encounter problems with unpaired double quotes - again, the app is deadlocked.

You can reproduce it by sending this: `{"data":"3582e2192900` as payload.

Caused by this line: https://github.com/nrfconnect/sdk-nrf/blob/master/applications/serial_lte_modem/src/slm_at_host.c#L565 

Parents Reply Children
  • Hi Martin,

    do you have any update on the official fix? In the meantime I have found the following workaround:

    1) Replace " with ` before passing them to XHTTPCREQ

    2) Replace them back in slm_at_httpc_parse like this:

    char* replace_char(char* str, char find, char replace){
        char *current_pos = strchr(str,find);
        while (current_pos){
            *current_pos = replace;
            current_pos = strchr(current_pos,find);
        }
        return str;
    }
    
    int slm_at_httpc_parse(const char *at_cmd, size_t length)
    {
    ...
    	/* Process input data as payload */
    	httpc.payload = replace_char((char *)at_cmd, '`', '"');
    ...
    }

    BR, Michal V.

Related