SimpleTweeter "Ended connection with twitter.com"?

Discussion about any of the included sketches (i.e. WebServer), or user-generated applications.

SimpleTweeter "Ended connection with twitter.com"?

Postby 3030vision » Fri Jul 30, 2010 3:52 pm

Hi,
I was excited to get WebServer running on my WiShield last night, and today I'm trying to make progress getting the SimpleTweeter sketch to work. I've used all my wireless parameter from WebServer, and tried both putting the base64 converted username/password and using base64encode to do the conversion.

The SimpleTweeter sketch seems to run, but then errors out (?) with "Ended connection to twitter.com". I'm trying to figure out the best way to debug this problem. It seems unlikely that it's related to my username/password. Perhaps there's more info on debugging on the wiki?

Thanks in advance.
3030vision
 
Posts: 8
Joined: Fri Jul 02, 2010 3:01 pm

Re: SimpleTweeter "Ended connection with twitter.com"?

Postby 3030vision » Sun Aug 01, 2010 4:18 am

I've looked into this a bit more but haven't made any progress. Again, I'm using the SimpleTweeter sketch with changes to accommodate my wireless network. I'm connecting to an Apple Time Capsule, which is essentially an Airport Extreme base station (on [url="http://asynclabs.com/wiki/index.php?title=AP_compatibility_list"]AP compatibility list[/url]).

I put a debug statement before and after the call to sendMyTweet, and I'm seeing those printed out once in the serial monitor, then the message I mentioned above "Ended connection with twitter.com"--that's it. I'm sure I can get more info in the serial monitor, but I'm not sure what variables would be helpful to print out.

I'll post my code here just in case. Thanks in advance for any suggestions.

Code: Select all
/*
* A simple sketch that uses WiServer to send a tweet with the current system time every 5 minutes
*/

#include <WiServer.h>

#define WIRELESS_MODE_INFRA   1
#define WIRELESS_MODE_ADHOC   2

// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {10,0,1,xx};   // IP address of WiShield
unsigned char gateway_ip[] = {67,xxx,xxx,1};   // router or gateway IP address
unsigned char subnet_mask[] = {255,255,255,0};   // subnet mask for the local network
const prog_char ssid[] PROGMEM = {"F&G"};   // max 32 bytes

unsigned char security_type = 3;   // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2

// WPA/WPA2 passphrase
const prog_char security_passphrase[] PROGMEM = {"__wireless password__"};   // max 64 characters

// WEP 128-bit keys
// sample HEX keys
prog_uchar wep_keys[] PROGMEM = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d,   // Key 0
              0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,   // Key 1
              0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,   // Key 2
              0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00   // Key 3
            };

// setup the wireless mode
// infrastructure - connect to AP
// adhoc - connect to another WiFi device
unsigned char wireless_mode = WIRELESS_MODE_INFRA;

unsigned char ssid_len;
unsigned char security_passphrase_len;
// End of wireless configuration parameters ----------------------------------------


// Auth string for the Twitter account
char* auth = "__encoded twitter username:password__"; // Base64 encoded USERNAME:PASSWORD
//char* auth = WiServer.base64encode("__unencoded twitter username:password__"); // Base64 encoded USERNAME:PASSWORD


// This function generates a message with the current system time
void currentTime() {
   WiServer.print("Running Arduino for ");
   WiServer.printTime(millis());
}

// A request that sends a Tweet using the currentTime function
TWEETrequest sentMyTweet(auth, currentTime);


void setup() {
    // Initialize WiServer (we'll pass NULL for the page serving function since we don't need to serve web pages)
  WiServer.init(NULL);
 
  // Enable Serial output and ask WiServer to generate log messages (optional)
  Serial.begin(57600);
  WiServer.enableVerboseMode(true);
}


// Time (in millis) when the next tweet should be sent
long tweetTime = 0;

void loop(){

  // Check if it's time to sent a tweet
  if (millis() >= tweetTime) {
  Serial.println("Before send");   
    sentMyTweet.submit();   
  Serial.println("After send");   
    // Send next tweet 5 minutes from now
    tweetTime += 1000 * 60 * 1;
  }
 
  // Run WiServer
  WiServer.server_task();

  delay(10);
}
3030vision
 
Posts: 8
Joined: Fri Jul 02, 2010 3:01 pm

Re: SimpleTweeter "Ended connection with twitter.com"?

Postby GregEigsti » Tue Aug 03, 2010 8:37 am

What happens if you try something really simple like this:
Code: Select all
void currentTime() {
   WiServer.print("Hello!");
}


Have you tried putting Serial.println()'s at the beginning and end of your currentTime() function to make sure that it is executing from beginning to end? Do you ever get your data to show up in twitter?

Dunno, just some ideas ;)
Greg
Check out the wiki!
uIP Stack Docs
Compatible Access Point List
WiShield user contrib branch - DNS, DHCP, AP Scanning, bug fixes, etc.
SlackLab.org - My geek projects blog.
User avatar
GregEigsti
 
Posts: 1067
Joined: Sun Aug 02, 2009 5:23 pm
Location: Sammamish WA USA (near Seattle)
  • Website

Re: SimpleTweeter "Ended connection with twitter.com"?

Postby 3030vision » Tue Aug 03, 2010 2:52 pm

Hi,
Thanks for your response. I tried simplifying the currentTime() function and adding Serial.println()s to it. I get the same debug results ("Before send/After send/Ended connection with twitter.com") then nothing. Oddly, I'm not getting any of the debug statements in currentTime() to print to the monitor.

So yeah, I'm at a loss. Is there another sample sketch that might be easier to troubleshoot the problem I'm having?

Oh and sorry, no, nothing posted to Twitter yet. That would be exciting!

Thanks again!
3030vision
 
Posts: 8
Joined: Fri Jul 02, 2010 3:01 pm

Re: SimpleTweeter "Ended connection with twitter.com"?

Postby GregEigsti » Tue Aug 03, 2010 3:51 pm

Oddly, I'm not getting any of the debug statements in currentTime() to print to the monitor.

Hmmmm, almost sounds like your currentTime() callback function is never being called by WiServer??? Could be due to the connection attempt to twitter falling over before sending (for instance during connection) - which could mean a bunch of different things.

Have you tried the other sample web client sketches a try? Can they connect and fetch data from a remote site? Can you ping your WiShield when it is up and running?

Greg
Check out the wiki!
uIP Stack Docs
Compatible Access Point List
WiShield user contrib branch - DNS, DHCP, AP Scanning, bug fixes, etc.
SlackLab.org - My geek projects blog.
User avatar
GregEigsti
 
Posts: 1067
Joined: Sun Aug 02, 2009 5:23 pm
Location: Sammamish WA USA (near Seattle)
  • Website

Re: SimpleTweeter "Ended connection with twitter.com"?

Postby 3030vision » Tue Aug 03, 2010 4:28 pm

Looks like I'm getting a similar error with SimpleClient-- it runs and eventually prints "Ended connection with http://www.weather.gov" to the monitor. I tried recompiling WebServer (which is the first sketch that I got working!) but now I'm getting these compile errors:

/Users/me/Documents/Arduino/libraries/WiShield/webserver.h:43: error: conflicting types for 'uip_tcp_appstate_t'

/Users/me/Documents/Arduino/libraries/WiShield/server.h:65: error: previous declaration of 'uip_tcp_appstate_t' was here

I can ping the WiShield although I get a few request timeouts. I feel like I'm missing something obvious here. Feeling dumb!
3030vision
 
Posts: 8
Joined: Fri Jul 02, 2010 3:01 pm

Re: SimpleTweeter "Ended connection with twitter.com"?

Postby GregEigsti » Tue Aug 03, 2010 4:36 pm

Ok, it looks like there is something going on more "basic" that the twitter; it would be interesting to see if you can get a webserver variant running on your WiShield to see if you can connect with it...

The compile errors are likely due to not having changed the app type in apps-conf.h.

Greg
Check out the wiki!
uIP Stack Docs
Compatible Access Point List
WiShield user contrib branch - DNS, DHCP, AP Scanning, bug fixes, etc.
SlackLab.org - My geek projects blog.
User avatar
GregEigsti
 
Posts: 1067
Joined: Sun Aug 02, 2009 5:23 pm
Location: Sammamish WA USA (near Seattle)
  • Website

Re: SimpleTweeter "Ended connection with twitter.com"?

Postby siliconghost » Wed Sep 29, 2010 4:56 pm

I'm having this same issue. I'm pretty sure it's related to a recent twitter.com API change that I know was a buzz in the development community last month because if people didn't update their apps and utilities, they broke.
http://www.pcworld.com/businesscenter/a ... ethod.html

I'd like to hear from someone that has been able to get this working recently...like in the past week.
siliconghost
 
Posts: 16
Joined: Wed Sep 29, 2010 5:15 am

Re: SimpleTweeter "Ended connection with twitter.com"?

Postby siliconghost » Wed Sep 29, 2010 5:43 pm

Ok, found a solution (and confirmation that it IS the change in the twitter API causing the problems).

See this thread: viewtopic.php?f=19&t=487

I followed the examples provided in this thread and modified the WebClient example. You also have to quickly setup an account on supertweet.net.

Note one thing, I had to change the IP that is referenced in the example that someone provided. Just ping api.supertweet.net and see which IP comes up for you.
siliconghost
 
Posts: 16
Joined: Wed Sep 29, 2010 5:15 am


Return to Sketches and Applications

Who is online

Users browsing this forum: No registered users and 1 guest