No Bridge.end() ????

I am having some trouble with an Amazon SNS project I am doing with YUN. Arduino 1.5.6-r2 on Mac OS X.

Basically, after I close the AWS connection, I still get a pile of characters coming at me across the bridge, so I can't do other commands like Process.begin("date"); Process.run().

Anyway, I thought I'd try resetting the Bridge by ending it and beginning again. However, there is no Bridge.end(), even though the Library documentation says there is.

How can I reset the bridge and get back to a clean state?

My mistake. There is no end() defined in the library.

Any other way to clean up this connection?

Ther eis the code but it's not wrapped into a function. https://github.com/arduino/Arduino/blob/ide-1.5.x/libraries/Bridge/src/Bridge.cpp#L40-L42

Consider submitting a PR implementing Bridge.end, it should be fairly easy

Yes, but it may not solve ,my problem.

After I receive HTTP/1.1 200 OK
from AWS, there should be nothing else in the connection. And yet I constantly read what appears to be repeating garbage. I don't think Amazon is sending this stuff. I would have thought YunClient.flush() would get rid of any more chars in the bridge channel, but it doesn't seem to.

I think it's better if you share your sketch code: I'm not sure I got the point of your problem

I'll try to summarize.

Every ten seconds I do this;
p.begin("date"); <<<<<<<<<< Get Linux date/time
p.run();
while(p.available() > 0)
{
char c = p.read();
Serial.print(c);
}

When a moisture sensor signal becomes active I do this

YunClient www;
www.connect(AWS_HOST, 80);
if (www.connected())
{ Create and send Amazon SNS message }
/* Get and print response from amazon. Should be "HTTP/1.1 200 OK" */
while (www.connected() && ( (prevRead = millis()) - lastRead < TIMEOUT_MS))
{
while (www.available())
{
char c = www.read();
Serial.print©;
}
if (!strncmp(rspBuffer, OK_RESPONSE, sizeof(OK_RESPONSE)-1) ) // got a good response
Serial.println("\nResponse OK");
else
Serial.println("\nResponse BAD");
break;
}
}
www.flush();
www.stop();
if (!www.connected())
Serial.println("Disconnected from AWS");

I see the request works OK and I do get my text message notification from AWS SNS.
I also see that the www.stop() appears to close the connection.

OUTPUT:
15: 182
Fri Jul 4 15:18:36 EDT 2014
Fri 7/4/2014 15:18:36
AWS response:
HTTP/1.1 200 OK
x-amzn-RequestId: addaa534-3c3c-58b5-9268-e905rAk5qRLifbLRVJREYdiLX5anbU4%3D
Response OK
Disconnected from AWS
16: 0
17: 0
18: 0
19: 0 <<<<<<<<<<<<<< The next time I get the date, I get all these characters and they repeat forever.
HTTP/1.1 200 OK
x-amzn-RequestId: addaa534-3c3c-58b5-9268-e905Ê
x?aaFri÷?e÷!efghijklmnopqrstuvwxyz{|}~ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨?ÆØ?±??¥µ?????ªº?æø¿¡¬?ƒ??«»… ÀÃÕŒœ–—“”‘’÷?ÿŸ?€‹›??‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔ?ÒÚÛÙ?ˆ˜¯???¸??HTTP/1.1 200 OK
x-amzn-RequestId: addaa534-3c3c-58b5-9268-e905Ê
x?aaFri÷?e÷!efghijklmnopqrstuvwxyz{|}~ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨?ÆØ?±??¥µ?????ªº?æø¿¡¬?ƒ??«»… ÀÃÕŒœ–—“”‘’÷?ÿŸ?€‹›??‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔ?ÒÚÛÙ?ˆ˜¯???¸??HTTP/1.1 200 OK
x-amzn-RequestId: addaa534-3c3c-58b5-9268-e905Ê
x?aaFri÷?e÷!efghijklmnopqrstuvwxyz{|}~ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨?ÆØ?±??¥µ?????ªº?æø¿¡¬?ƒ??«»… ÀÃÕŒœ–—“”‘’÷?ÿŸ?€‹›??‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔ?ÒÚÛÙ?ˆ˜¯???¸??HTTP/1.1 200 OK
x-amzn-RequestId: addaa534-3c3c-58b5-9268-e905Ê
x?aaFri÷?e÷!efghijklmnopqrstuvwxyz{|}~ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨?ÆØ?±??¥µ?????ªº?æø¿¡¬?ƒ??«»… ÀÃÕŒœ–—“”‘’÷?ÿŸ?€‹›??‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔ?ÒÚÛÙ?ˆ˜¯???¸??HTTP/1.1 200 OK
x-amzn-RequestId: addaa534-3c3c-58b5-9268-e905Ê
x?aaFri÷?e÷!efghijklmnopqrstuvwxyz{|}~ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨?ÆØ?±??¥µ?????ªº?æø¿¡¬?ƒ??«»… ÀÃÕŒœ–—“”‘’÷?ÿŸ?€‹›??‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔ?ÒÚÛÙ?ˆ˜¯???¸??HTTP/1.1 200 OK
x-amzn-RequestId: addaa534-3c3c-58b5-9268-e905Ê
x?aaFri÷?e÷!efghijklmnopqrstuvwxyz{|}~ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨?ÆØ?±??¥µ?????ªº?æø¿¡¬?ƒ??«»… ÀÃÕŒœ–—“”‘’÷?ÿŸ?€‹›??‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔ?ÒÚÛÙ?ˆ˜¯???¸??HTTP/1.1 200 OK
x-amzn-RequestId: addaa534-3c3c-58b5-9268-e905Ê
x?aaFri÷?e÷!efghijklmnopqrstuvwxyz{|}~ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨?ÆØ?±??¥µ?????ªº?æø¿¡¬?ƒ??«»… ÀÃÕŒœ–—“”‘’÷?ÿŸ?€‹›??‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔ?ÒÚÛÙ?ˆ˜¯???¸??HTTP/1.1 200 OK
x-amzn-RequestId: addaa534-3c3c-58b5-9268-e905Ê

Is it o.k., that you always get the same x-amzn-RequestId? If not, the problem starts not at the garbage, but even earlier.

You should strip down your code to a minimum, that still produces the problem, and then post that code without any further reduction.

Different runs of the program give different transaction IDs. It's just that the response data gets stuck in Linux and keeps getting sent back to me no matter what I do.

The code I posted is pretty much the whole story. I can't post the entire working code since its pretty large and contains my secret amazon keys.

The main issue is that closing the connection somehow does not flush out all the buffers in the bridge and I can't get them cleaned out.

Apparently upgrading the Yun / Lineo software resolves this problem.