Show Posts
Pages: [1]
1  Using Arduino / Networking, Protocols, and Devices / Re: Success! NeoCat Twitter Library. Tweet fails with code 500 on: July 20, 2012, 01:34:52 pm
Success! I was able to successfully stand up an instance ( http://arduino-tweet1.appspot.com/of NeoCat's terrific Twitter proxy on Google AppEngine. If anyone is interested in setting up their own I can help with the process (and help you not repeat the many mistakes I made smiley-wink. BTW, the code, available here https://github.com/NeoCat/ArduinoTweetLib-server , is distributed under GPLv2 (http://www.gnu.org/licenses/gpl-faq.html which means you can take, modify and use it according to the normal attribution provisions (and thanks to NeoCat!).

Drew
2  Using Arduino / Networking, Protocols, and Devices / Re: NeoCat Twitter Library. Tweet fails with code 500 on: July 18, 2012, 07:38:55 pm
Looks like the NeoCat web app is more stable now. I believe the author added some additional limiting code that should help keep the tweet hogs at bay.
BTW, I grabbed the arduino-tweet code from Github and attempted to stand up my own instance on Google AppEngine. Unfortunately, I am missing some critical clue (not a Python expert by any stretch) as I am getting "token not set" errors which seem to indicate that I am not successfully passing the Twitter Access token from Arduino to Google AppEngine, or I am overlooking some permission(s) I need to run the app on that platform. Will keep trying as it would be a good thing to know how to set up and operate such a service.

Drew
3  Using Arduino / Networking, Protocols, and Devices / Re: NeoCat Twitter Library. Tweet fails with code 500 on: July 12, 2012, 01:40:07 am
Arghhh...the app is down again, a victim of over-quota usage. We really do need to consider usage scenarios  for our Arduino testing as long as some are abusing the privilege of the very nice setup NeoCat has created for us. Although it reset last night at midnight PDT (and will again in 27 minutes), it will surely be down once again by tomorrow evening. Scanning several Arduino-Twitter apps, I see that many (including mine) have built-in Twitter throttles to deliberately limit tweets to a reasonable max, either though rate/hr or total number in a given period. It would seem that if we all were willing to do this we might all enjoy the continued use of a great resource. Perhaps NeoCat could even put something in his Google App that could detect over-use and either de-authorize that connection or do some throttling ala Verizon or At&T who face similar issues with bandwidth hogs in their wireless services. Thoughts?
4  Using Arduino / Networking, Protocols, and Devices / Re: NeoCat Twitter Library. Tweet fails with code 500 on: July 10, 2012, 10:13:43 pm
@Gizmojoe, just saw this Twitter post on @NeoCat:

NeoCat ‏@NeoCat
@mbuchelly Somebody seems sending too frequent requests. I rejected that and the server should recover in 5 hour. Thanks for your report.

6:58 PM - 9 Jul 12 via twicli · Details

So maybe this will recover sometime soon, but not sure how to manage over time if people are abusing the site. Perhaps a policy of some sort is in order, say, a limit on the number of tweets/day on this site. If you have a device that's really pounding the site then it's best to take it elsewhere, to a site that's purpose-built for that kind of sensor data stream. Thoughts?

 - Drew
5  Using Arduino / Networking, Protocols, and Devices / Re: NeoCat Twitter Library. Tweet fails with code 500 on: July 10, 2012, 09:05:19 pm
Not sure this is fixed. My tweets to http://twitter.com/vickisgarden1 are failing with code 503 for me.

</head>
<body text=#000000 bgcolor=#ffffff>
<table border=0 cellpadding=2 cellspacing=0 width=100%>
<tr><td bgcolor=#3366cc><font face=arial,sans-serif color=#ffffff><b>Error</b></td></tr>
<tr><td>&nbsp;</td></tr></table>
<blockquote>
<H1>Over Quota</H1>
This application is temporarily over its serving quota.  Please try again later.
<p>
</blockquote>
<table width=100% cellpadding=0 cellspacing=0><tr><td bgcolor=#3366cc><img alt="" width=1 height=4></td></tr></table>
</body></html>
tweet fail: code 503

Any ideas are most welcome!
6  Using Arduino / Networking, Protocols, and Devices / Re: CuHead WiFi Shield 2.0 on: June 29, 2012, 06:54:01 pm
Hi. I too use the little TL-Link router as a WiFi client to my Arduino and it works well in general as stated. But it does tend to cause issues with my AT&T RG  (Residential Gateway) aka cable modem. When I power up the TL while connected to my Arduino running a sketch that uses Ethernet.DHCP (I am including that detail in case in might be a clue as to the problem) it causes the RG to drop IP connectivity to all other WiFi devices such as laptops. When I power it off, IP returns most of the time, but many times I must reset the RG to get back to normal operation. Question: is operating the TL-Link in client mode causing an undesirable side-effect on home Internet gateways (which are really routers themselves of course)? I have heard talk on the AT&T fora that one cannot operate a router "behind" the RG router. Thanks.
7  Using Arduino / Networking, Protocols, and Devices / Re: Replacement DHCP functions for Ethernet in IDE 1.01 on: June 12, 2012, 01:56:28 pm
Just found the answers in this forum...but don't know where this is documented:


      EthernetDHCP.ipAddress() ==>   Ethernet.localIP()
   
      EthernetDHCP.gatewayIpAddress() ==>  Ethernet.gatewayIP()
     
      EthernetDHCP.dnsIpAddress()  ==> Ethernet.dnsServerIP()
     
     
8  Using Arduino / Networking, Protocols, and Devices / Replacement DHCP functions for Ethernet in IDE 1.01 on: June 12, 2012, 01:42:30 pm
hi...I'm upgrading my code to 1.01 Ethernet Library...does anyone know the replacement functions/syntax for the following Ethernet Library DHCP elements:

        EthernetDHCP.ipAddress()  ==>  Ethernet.localIP()
   
        EthernetDHCP.gatewayIpAddress()  ==> what is this one?
   
        EthernetDHCP.dnsIpAddress()  ==> what is this one?
9  Using Arduino / Networking, Protocols, and Devices / Re: App using DHCP/DNS failing with Neocat Twitter Library on: June 12, 2012, 02:45:16 am
Thanks so much for your suggestions...my code is now working! Very briefly, I substituted "Ethernet.begin()" and "Ethernet.maintain()" statements for the problematic "EthernetDHCP()" counterparts as follows (these are fragments..I have elided non-essential parts):
Code:
// EthernetDHCP.begin(mac, true); // start ethernet DHCP in non-blocking polling mode
     Ethernet.begin(mac); // start ethernet and obtain IP lease
...
  int ipState1 = Ethernet.maintain(); //  Check and maintain Ethernet lease
  if (millis() % 60000 == 0 && ipState1 != 2 && ipState1 != 4) {
 // dhcpCheck(); // check and update DHCP connection
 // if (millis() % 60000 == 0 && ipState != DhcpStateLeased && ipState != DhcpStateRenewing) {
    Serial.println("no IP");
   blinkLED(COMMLED,1,30); // quick blnk of COMM led if there's no ip address
...
 Serial.println("connect...");
 // if (ipState == DhcpStateLeased || ipState == DhcpStateRenewing) {
 //   Serial.println("Lease OK");
    if (twitter.post(message)) { // attempt to tweet the message
      int status = twitter.wait(&Serial); // receive the status + DEBUG
      digitalWrite(COMMLED,LOW); // turn off the communications LED
      delay(100);
      if (status == 200) {
        Serial.println("tweet ok");
      }
      else {
        Serial.print("tweet fail: code ");
        Serial.println(status); // if tweet fails, print the error code
        blinkLED(COMMLED,2,100); // ...and blink the communications LED twice
      }
      counter++; // iterate the message counter
      setCounter(counter); // store the message counter in EEPROM memory
    }
    else {
      Serial.println("connect fail"); // if connection fails entirely,
      blinkLED(COMMLED,4,100); // ...blink the communications LED 4 times
    }
 // }
//  else {
 //   Serial.println("DHCP fail"); // if connection fails entirely,
 //   blinkLED(COMMLED,6,100); // ...blink the communications LED 4 times
//  }
  free(message); // free the allocated string memory
  free(str2);
  free(str4);
}

Yes, it's not elegant and needs additional editing but it works well enough for me to continue the project. I still don't know why the original code is not working, but I'll have to leave that to the experts. Thanks again for your help.
10  Using Arduino / Networking, Protocols, and Devices / Re: App using DHCP/DNS failing with Neocat Twitter Library on: June 11, 2012, 04:59:57 pm
Again, some good ideas here. I am attaching both code fragments - the one that works and the one that fails.
Here's what works (the vanilla Twitter Library sample code):
Code:
    // Ethernet Shield Settings
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

// If you don't specify the IP address, DHCP is used(only in Arduino 1.0 or later).
byte ip[] = { 192, 168, 2, 250 };

// Your Token to Tweet (get it from http://arduino-tweet.appspot.com/)
Twitter twitter("YOUR-TOKEN-HERE");

// Message to post
char msg[] = "Hello, World! I'm Arduino!";

void setup()
{
  delay(1000);
  Ethernet.begin(mac, ip);
  // or you can use DHCP for automatic IP address configuration.
  // Ethernet.begin(mac);
  Serial.begin(9600);
 
  Serial.println("connecting ...");
  if (twitter.post(msg)) {
    // Specify &Serial to output received response to Serial.
    // If no output is required, you can just omit the argument, e.g.
    // int status = twitter.wait();
    int status = twitter.wait(&Serial);
    if (status == 200) {
      Serial.println("OK.");
    } else {
      Serial.print("failed : code ");
      Serial.println(status);
    }
  } else {
    Serial.println("connection failed.");
  }
}

void loop()
{
}

..and here's what isn't working:

Code:
// initialize Twitter object
Twitter twitter(TOKEN);

DhcpState ipState = DhcpStateNone; // a variable to store the DHCP state

void setup()  {
  serial = getSerial(); // create or obtain a serial number from EEPROM memory
  counter = getCounter(); // create or obtain a tweet count from EEPROM memory
  // Ethernet Shield Settings
  byte mac[] = { 0x31, 0x13, 0x31, 0x13, 0x31, 0x13 }; // use same MAC as Twitter examples
...
Serial.begin(9600);   // set the data rate for the hardware serial port
...
// start Ethernet
   EthernetDHCP.begin(mac, true); // start ethernet DHCP in non-blocking polling mode
...
 dhcpCheck(); // check and update DHCP connection
  if (millis() % 60000 == 0 && ipState != DhcpStateLeased && ipState != DhcpStateRenewing) {
    blinkLED(COMMLED,1,30); // quick blnk of COMM led if there's no ip address
...
posttweet(URGENT_WATER);   // Post it to Twitter
...
}
// post a tweet
void posttweet(char* msg) {
  digitalWrite(COMMLED,HIGH); // light the Communications LED
  // assemble a string for Twitter, appending a unique ID to prevent Twitter's repeat detection
  char *str1 = " [";
  char *str2;
  str2= (char*) calloc (5,sizeof(char)); // allocate memory to string 2
  itoa(serial,str2,16); // turn serial number into a string
  char *str3 = "-";
  char *str4;
  str4= (char*) calloc (5,sizeof(char)); // allocate memory to string 4
  itoa(counter%10000,str4,10); // turn message counter into a string
  char *str5 = "]";
  char *message;
  // allocate memory for the message
  message = (char*) calloc(strlen(msg) + strlen(str1) + strlen(str2) + strlen(str3) + strlen(str4) + strlen(str5) + 1, sizeof(char));
  strcat(message, msg); // assemble (concatenate) the strings into a message
  strcat(message, str1);
  strcat(message, str2);   
  strcat(message, str3);
  strcat(message, str4);
  strcat(message, str5);
  Serial.println("connect...");
  if (ipState == DhcpStateLeased || ipState == DhcpStateRenewing) {
    Serial.println("Lease OK");
    if (twitter.post(message)) { // attempt to tweet the message
      int status = twitter.wait(&Serial); // receive the status + DEBUG
      digitalWrite(COMMLED,LOW); // turn off the communications LED
      delay(100);
      if (status == 200) {
        Serial.println("tweet ok");
      }
      else {
        Serial.print("tweet fail: code ");
        Serial.println(status); // if tweet fails, print the error code
        blinkLED(COMMLED,2,100); // ...and blink the communications LED twice
      }
      counter++; // iterate the message counter
      setCounter(counter); // store the message counter in EEPROM memory
    }
    else {
      Serial.println("connect fail"); // if connection fails entirely,
      blinkLED(COMMLED,4,100); // ...blink the communications LED 4 times
    }
  }
  else {
    Serial.println("DHCP fail"); // if connection fails entirely,
    blinkLED(COMMLED,6,100); // ...blink the communications LED 4 times
  }
  free(message); // free the allocated string memory
  free(str2);
  free(str4);
}

Again, as in the first example, I am seeing valid IP, gateway and DNS addresses and can ping the Ethernet shield. But somehow I am not getting through to the Twitter API via the Neocat proxy site (http://arduino-tweet.appspot.com/). One thought I just had was that maybe the "EthernetDHCP.begin()" statement has been deprecated in favor of simply "Ethernet.begin() as DHCP capability has been folded into IDE 1.0.

As before, any help is appreciated!
11  Using Arduino / Networking, Protocols, and Devices / Re: App using DHCP/DNS failing with Neocat Twitter Library on: June 11, 2012, 11:00:33 am
Hi...good suggestion which I just tried...here's the code fragment and then the serial result:
Code:
...
Serial.println("connect...");
  if (ipState == DhcpStateLeased || ipState == DhcpStateRenewing) {
    if (twitter.post(message)) { // attempt to tweet the message
      [b] int status = twitter.wait(&Serial); // receive the status/stream to serial[/b]
      digitalWrite(COMMLED,LOW); // turn off the communications LED
      delay(100);
      if (status == 200) {
        Serial.println("tweet ok");
      }
      else {
        Serial.print("tweet fail: code ");
        Serial.println(status); // if tweet fails, print the error code
        blinkLED(COMMLED,2,100); // ...and blink the communications LED twice
      }
      counter++; // iterate the message counter
      setCounter(counter); // store the message counter in EEPROM memory
    }
    else {
      Serial.println("connect fail"); // if connection fails entirely,
      blinkLED(COMMLED,4,100); // ...blink the communications LED 4 times
    }
  }
  else {
    Serial.println("DHCP fail"); // if connection fails entirely,
    blinkLED(COMMLED,6,100); // ...blink the communications LED 4 times
  }
  free(message); // free the allocated string memory
  free(str2);
  free(str4);
}
...

...and the corresponding serial output:

mac: 31:13:31:13:31:13
token: 601291366-SUUChc6mPLhQR5Eamzfv1zVs3ywtkpzcPtI3b8w8
DHCP req
DHCP OK!
ip: 192.168.1.78
gw: 192.168.1.254
dns: 192.168.1.254
connect...
tweet fail: code 0

As you can see no difference from previous post. I had assumed that I would get some debug output...I suspect now that something is amis in the DHCP lease as the same basic code does work if I hardcode the IP...hmmmm...there is a piece of code in Twitter.CPP that checks for valid HOSTNAME...I suppose if it can't resolve the Twitter API page all will fail:

Code:
...
bool Twitter::post(const char *msg)
{
#if defined(ARDUINO) && ARDUINO < 100
DNSError err = EthernetDNS.resolveHostName(LIB_DOMAIN, server);
if (err != DNSSuccess) {
return false;
}
#endif
parseStatus = 0;
statusCode = 0;
...
12  Using Arduino / Networking, Protocols, and Devices / App using DHCP/DNS failing with Neocat Twitter Library on: June 10, 2012, 07:53:01 pm
Hi...I'm working on a Twitter app that tweets sensor data via an OAuth token (using Neocat's great Twitter proxy site). Running Arduino 1.1, the code uses DHCP/DNS and things seem to be working (i.e., DHCP OK, IP assigned, etc.), except that I am receiving an error status from Twitter: "status 0". Complete code is too long to post here, but here's an excerpt from the Twitter post section:

Code:
Serial.println("connect...");
  if (ipState == DhcpStateLeased || ipState == DhcpStateRenewing) {
    if (twitter.post(message)) { // attempt to tweet the message
      int status = twitter.wait(); // receive the status
      digitalWrite(COMMLED,LOW); // turn off the communications LED
      delay(100);
      if (status == 200) {
        Serial.println("tweet ok");
      }
      else {
        Serial.print("tweet fail: code ");
        Serial.println(status); // if tweet fails, print the error code
        blinkLED(COMMLED,2,100); // ...and blink the communications LED twice
      }
      counter++; // iterate the message counter
      setCounter(counter); // store the message counter in EEPROM memory
    }
    else {
      Serial.println("connect fail"); // if connection fails entirely,
      blinkLED(COMMLED,4,100); // ...blink the communications LED 4 times
    }
  }
  else {
    Serial.println("DHCP fail"); // if connection fails entirely,
    blinkLED(COMMLED,6,100); // ...blink the communications LED 4 times
  }
  free(message); // free the allocated string memory
  free(str2);
  free(str4);
}

Here is the relevant debug stream:
...
mac: 31:13:31:13:31:13
token: 601291366-SUUChc6mPLhQR5Eamzfv1zVs3ywtkpzcPtI3b8w8
DHCP req
DHCP OK!
ip: 192.168.1.78
gw: 192.168.1.254
dns: 192.168.1.254
connect...
tweet fail: code 0
...
So, instead of Twitter status "200" indicating a successful tweet, I am getting status "0". This error return from NeoCat's proxy site is not particularly helpful in debugging...thanks in advance for any ideas as to what I am doing wrong...
Pages: [1]