Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Luiz Henrique
#56720
martinayotte wrote:Do you mean that the body is empty ?
Did you try to print it ?
Which framework are you using ?
Maybe String initialisation isn't done properly, do it that way instead :
Code: Select allString tratado = String(resposta);


I think this only Body is empty, i try to receive all data, and receive the headers, but the data don't receive.
I will try this and i edit.
User avatar
By Luiz Henrique
#56722
martinayotte wrote:Do you mean that the body is empty ?
Did you try to print it ?
Which framework are you using ?
Maybe String initialisation isn't done properly, do it that way instead :
Code: Select allString tratado = String(resposta);


Doesn't work using String tratado = String(resposta).
I use Node.js, my code in Node is:

Code: Select all//SendInfo to Arduino
app.get('/StatusSaidas', function(req,res){
    res.charset = 'UTF-8';
    console.log('Send to Arduino: ' + statusArdu);
    res.send(statusArdu);
});


Above, is the return from node.js with the response:

http://imgur.com/a/z74D5

I think the node.js sends the data, i see this in number "15" with the length of my status "QTD1LAMP, ON". but Arduino don't receive that info
User avatar
By Luiz Henrique
#56724
martinayotte wrote:Try to print the "buffer" to figure out what is following the header.
If body is there after "\r\n\r\n", print "respota" to see if header removal code is good.


I print using this code:

Code: Select allSerial.print(resposta);


But receive nothing, no blank spaces, nothing.
Just another GET Request in Serial

Connection with HOST OK!
Connection with HOST OK!
Connection with HOST OK!
Connection with HOST OK!

Part in this code:

Code: Select all  uint8_t buffer[1024] = {0};

    if (wifi.createTCP(HOST_NAME, HOST_PORT)) {
        Serial.print("connection with host OK\r\n");
    } else {
        Serial.print("Error connection Host\r\n");
    }

    char *ComandoGET = "GET /StatusSaidas HTTP/1.1\r\nConnection: close\r\n\r\n";
    wifi.send((const uint8_t*)ComandoGET, strlen(ComandoGET));

    uint32_t len = wifi.recv(buffer, sizeof(buffer), 10000);
    char *resposta = buffer;
    for (int i = 0; i < len; i++)
    {
        if (strncmp(resposta++, "\r\n\r\n", 4) == 0) break;
    }
    resposta += 3;
    Serial.print(resposta);
}