Event DEBUG after flashing

Dear all,
flashed my Phonton with Firmware v6.0 the first time and got this error-log message:
Failed to find expected HTTP/1.1 response! every second.

Any ideas how so solve?

Breathing is “normal”,
Best regards,
Ingo

More background please.
Where does this log come from?
What’s the code you flashed?

Hey ScruffR,
the errors I get from Tinker-App and also in the online log.
{“data”:“Failed to find expected HTTP/1.1 response!”,“ttl”:“60”,“published_at”:“2017-02-09T21:33:07.834Z”,“coreid”:…

I flashed first time my new photon code from an hackster.io project:
https://www.hackster.io/nick-stanley/bed-underglow-958476?ref=search&ref_id=bed&offset=0
I copied the (3) Files into web IDE and flashed.

Now the LED Strip is flashed, errors in the log and I lost control,
Ingo

That message comes from the Adafruit_IO_Particle library.
If you look in the code of that you may find the reason for it, but my immediate question would be: “Have you set your own AIO_KEY?”

#define AIO_KEY "0000000000000000000000000000000000000000" // <-- this needs to be your own key

Dear ScruffR,
you are right; I saw this also: I created an account under io.adafruit.com, used the key and put it into the code. After flashing I got the same problems as before:
a.) LED Stripe is always on
b.) the error message furtherin appears.

Ingo

There are two places in the lib where that message is published

    // Now wait to read response (up to the client's configured stream timeout).
    // First read the HTTP/1.1 response.
    char recvbuffer[IO_RECV_LENGTH] = {0};
    if ((_client.readBytesUntil(' ', recvbuffer, sizeof(recvbuffer)) != 8) ||
        (strcmp_P(recvbuffer, PSTR("HTTP/1.1")) != 0)) {
        DEBUG_PRINTLN(F("Failed to find expected HTTP/1.1 response!"));
        _client.stop();
        return false;
    }

and

    // Parse HTTP GET response.
    // First read the HTTP/1.1 response.
    char recvbuffer[IO_RECV_LENGTH] = {0};
    if ((_client.readBytesUntil(' ', recvbuffer, sizeof(recvbuffer)) != 8) ||
        (strcmp_P(recvbuffer, PSTR("HTTP/1.1")) != 0)) {
        DEBUG_PRINTLN(F("Failed to find expected HTTP/1.1 response!"));
        _client.stop();
        return FeedData();
    }

And with that knowledge you may get an idea why this is happening.
It’s difficult to debug that for us without actually building the whole project, but you could narrow things down a bit.
Assuming you are using the Web IDE:
You could even copy-paste the lib files into seperate file tabs in your project and add extra Serial.print() statements to narrow down further.

Yup, found this in the lib. Sorry, but I cant handle this. Its an valid lib v1.0.1 which I included over WebIde.
I cant change the code without Adafruit IO; so I havent a chance.
Ingo

Yes, you can - I have done it tons of times.

Hi ScruffR,
thx for your motivation.

So I follow and copy the lib into my project.
I changed a bit the debug output text and now I know thats the problem source is the second if-statement from top.
Since I can not estimate what the program code is good I probably come at this point so no further.

In addition, I tried not to include the Library adafruit IO. Unfortunately, I did not get any further.
Would someone be so nice to help?

Once you removed one of the two suspects from the list, you can concentrate on the other.
In that case you may want to check what the contents of recvbuffer and the actual received length is and why the check fails.

e.g. like this

    int dbgLen;
    //char recvbuffer[IO_RECV_LENGTH] = {0};
    char recvbuffer[64];  // just to be sure we have a big enough buffer
    memset(recvbuffer, 0, sizeof(recvbuffer)); // that's a safer way to clear a buffer
    if (( dbgLen = _client.readBytesUntil(' ', recvbuffer, sizeof(recvbuffer)) != 8 ) ||
        (strcmp_P(recvbuffer, PSTR("HTTP/1.1")) != 0)) {
        Log.info("Len %d: <%s>", dbgLen, recvbuffer);
        Log.info("strcmp_P() == %d vs. strcmp() == %d", strcmp_P(recvbuffer, PSTR("HTTP/1.1")), strcmp(recvbuffer, "HTTP/1.1") );
     
        DEBUG_PRINTLN(F("Failed to find expected HTTP/1.1 response!"));
        _client.stop();
        return FeedData();
    }

One additional thing to consider is the timeout of readBytesUntil(). If the expected terminator (' ') doesn’t appear in time the function bails out. Increasing the timeout may help.

I changed the original adafruit io v1.0.1 code with your code-suggestion on the identified position (before I copied the lib into tab-sheets) and: it works! No I havent longer DEBUG-Messanges into the error log.

Now I can focus on void setup/loop, because my second problem “the led stripe is always on” is not solved.

The reason why it works now might be the way I cleared that buffer.
To confirm that, you could just comment that memset() line and see if this was the actual cure.

Dear ScruffR,
today I tested it again and got error message during I use your code…
I have received an additional error message, specifically
"Failed tro connect to service!" - I could put this on the source
FeedData Adafruit_IO_Client :: receive narrow.

Maybe it is not connected with the "Failed to find exptected http1.1 error, but already with the error in the Connect.

Why am I the first to catch an adafruit library with errors?


FeedData Adafruit_IO_Client :: receive (const char * feed, const char * key) {
    // Make HTTP GET request to read the latest feed item and then parse response
    // into FeedData object.

    // First make sure it is connected to the service is available.
    If (! Connected ()) {
        DEBUG_PRINTLN (F ("Failed to connect to service!"));
        Return FeedData ();
    }

    // Send HTTP GET and headers.
    _client.print (F ("GET / api / feeds /"));
    _client.print (feed);
    _client.print (F ("/ data / last.txt HTTP / 1.1 \ r \ n"));
    SendHeaders (key);
    _client.print (F ("Accept: text / plain \ r \ n"));

    // Parse HTTP GET response.
    // First read the HTTP / 1.1 response.
    
    // Original:
// char recvbuffer [IO_RECV_LENGTH] = {0};
// if ((_client.readBytesUntil ('', recvbuffer, sizeof (recvbuffer))! = 8) ||
// (strcmp_P (recvbuffer, PSTR ("HTTP / 1.1"))! = 0)) {
// DEBUG_PRINTLN (F ("Ingo2-Failed to find expected HTTP / 1.1 response!"));
// _client.stop ();
// return FeedData ();
//}
    
    Int dbgLen;
    // char recvbuffer [IO_RECV_LENGTH] = {0};
    Char recvbuffer [64]; // just to be sure we have a big enough buffer
    Memset (recvbuffer, 0, sizeof (recvbuffer)); // that's a safer way to clear a buffer
    If ((dbgLen = _client.readBytesUntil ('', recvbuffer, sizeof (recvbuffer))! = 8) ||
        (Strcmp_P (recvbuffer, PSTR ("HTTP / 1.1")) = 0)) {
        Log.info ("Len% d: <% s>", dbgLen, recvbuffer);
        Log.info ("strcmp_P () ==% d vs. strcmp () ==% d", strcmp_P (recvbuffer, PSTR ("HTTP / 1.1")), strcmp (recvbuffer, "HTTP / 1.1");
     
        DEBUG_PRINTLN ("Failed to find expected HTTP / 1.1 response!");
        _client.stop ();
        Return FeedData ();
    }

You copy-paste must have messed up the code. There are capital letters where they are not allowed and other syntax errors.

“Upsala!”

FeedData Adafruit_IO_Client::receive(const char* feed, const char* key) {
    // Make HTTP GET request to read latest feed item and then parse response
    // into FeedData object.

    // First make sure a connection to the service is available.
    if (!connected()) {
        DEBUG_PRINTLN(F("Failed to connect to service!")); 
        return FeedData();
    }

    // Send HTTP GET and headers.
    _client.print(F("GET /api/feeds/"));
    _client.print(feed);
    _client.print(F("/data/last.txt HTTP/1.1\r\n"));
    sendHeaders(key);
    _client.print(F("Accept: text/plain\r\n\r\n"));

    // Parse HTTP GET response.
    // First read the HTTP/1.1 response.
    
    // Original:
//    char recvbuffer[IO_RECV_LENGTH] = {0};
//    if ((_client.readBytesUntil(' ', recvbuffer, sizeof(recvbuffer)) != 8) ||
//        (strcmp_P(recvbuffer, PSTR("HTTP/1.1")) != 0)) {
//        DEBUG_PRINTLN(F("Ingo2-Failed to find expected HTTP/1.1 response!"));
//        _client.stop();
//        return FeedData();
//    }
    
    int dbgLen;
    //char recvbuffer[IO_RECV_LENGTH] = {0};
    char recvbuffer[64];  // just to be sure we have a big enough buffer
    memset(recvbuffer, 0, sizeof(recvbuffer)); // that's a safer way to clear a buffer
    if (( dbgLen = _client.readBytesUntil(' ', recvbuffer, sizeof(recvbuffer)) != 8 ) ||
        (strcmp_P(recvbuffer, PSTR("HTTP/1.1")) != 0)) {
        Log.info("Len %d: <%s>", dbgLen, recvbuffer);
        Log.info("strcmp_P() == %d vs. strcmp() == %d", strcmp_P(recvbuffer, PSTR("HTTP/1.1")), strcmp(recvbuffer, "HTTP/1.1") );
     
        DEBUG_PRINTLN(F("Failed to find expected HTTP/1.1 response!"));
        _client.stop();
        return FeedData();
    }

There is a function connected() that obviously returns false to throw that message.
You need to find why that is and the do something about that.

(code hase changed after my first reply :wink: )


in order to get code blocks formatted correctly wrap them in a set of these

 ```cpp
 // these are grave accent - not single quotes
 // 
 // your code block here
 //