Pages: 1 [2]   Go Down
Author Topic: [SOlved]GET/ requests Headache  (Read 1342 times)
0 Members and 1 Guest are viewing this topic.
Central MN, USA
Offline Offline
Tesla Member
***
Karma: 76
Posts: 7305
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

SurferTim,

Thank you for the detailed explanation here especially the real world situation. I will use your code in my project so it doesn't fall apart.
Logged


ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 12
Posts: 1619
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sir Liudr,

I think the Arduino WiFi shield doesn't have that kind UART communication facility everything needs to work through its library!
The biggest thing working with a ARduino WiFi shield is its cost at the very first time I was turned down with it, Learning to work with something which will hardly have any end product place is not good , and in case of Arduino WiFi shield this is the case because of its cost, I that's why picked up a RN-171 and Now im eyeing that very cheap TIcc3000 chip that can go upto $10 for 1000 pcs that's pretty cheap when it comes to connecting anything to the Internet!
Logged

"Real Men can Accomplish  Anything"
-  Website  
- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੂਂ !

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 76
Posts: 7305
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for your reply NI$HANT. I am working on a project that will be cost effective and potentially have more functionality if I used arduino wifi shield. I am more confident with Arduino team's ability to write a decent firmware and library than other makers also.
Logged


ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 12
Posts: 1619
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I am more confident with Arduino team's ability to write a decent firmware and library than other makers also.

RN-171 and other many flavors are from MicroChip and you know microchip is the best when it comes to good quantity manufacturing  and thus cost gets dropped, neverthless this is my analysis.
Logged

"Real Men can Accomplish  Anything"
-  Website  
- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੂਂ !

ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 12
Posts: 1619
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@ SurferTIM , I added your code and its below(just commented out>>    client.println("HOST: winacro.com")smiley-wink

Code:
/*
  
#include <SPI.h>
#include <Ethernet.h>

int relayPin = 9;
char Str[11];
int prevNum = 0;
int num = 0;
long onUntil = 0;
int connectLoop;

long pollingInterval = 5000; // in milliseconds
long onTime = 60000; // time, in milliseconds, for lights to be on after new email or comment

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = {  0x90, 0xA2, 0xDA, 0x0D, 0x78, 0xE1 };
char serverName[] = "winacro.com";



// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;

void setup() {
  Serial.begin(9600);
  pinMode(relayPin, OUTPUT);
  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }
  // give the Ethernet shield time to initialize:
  delay(2000);

}

void loop()
{
    Serial.println("connecting...");

  // if you get a connection, report back via serial:
  
  if (client.connect(serverName, 80)) {
    Serial.println("connected");
    // Make a HTTP request:
    client.println("GET /PHP/email.php HTTP/1.1");
    //client.println("HOST: winacro.com");
    client.println();
    int timer = millis();
    //delay(1000);
  }
  else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
    
  }
// if there's data ready to be read:
  while(client.connected())  {
    while(client.available())    {
      char inChar = client.read();
      Serial.write(inChar);
      // set connectLoop to zero if a packet arrives
      connectLoop = 0;
    }

    connectLoop++;

    // if more than 10000 milliseconds since the last packet
    if(connectLoop > 10000)    {
      // then close the connection from this end.
      Serial.println();
      Serial.println(F("Timeout"));
      client.stop();
    }
    // this is a delay for the connectLoop timing
    delay(1);
  }

  Serial.println();

  Serial.println(F("disconnecting."));
  // close client end
  client.stop();  
  if(num > prevNum) {
      Serial.println("New Comment.");
      digitalWrite(relayPin, HIGH);
      prevNum = num;
      onUntil = millis() + onTime;
    }
    else if(millis() > onUntil)
    {
     digitalWrite(relayPin, LOW);
    }
  //delay(pollingInterval);
}


and I get the following with it:
Code:
connecting...
connected
HTTP/1.1 400 Bad Request
Date: Thu, 18 Apr 2013 18:25:33 GMT
Server: Apache
Content-Length: 226
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
</body></html>

disconnecting.
connecting...

if i keep the     client.println("HOST: winacro.com"); then i'm not able to connect!
« Last Edit: April 18, 2013, 01:38:06 pm by NI$HANT » Logged

"Real Men can Accomplish  Anything"
-  Website  
- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੂਂ !

ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 12
Posts: 1619
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Now I'm able to find the file:

here's the error in Php file that IM getting now:

Code:

PHP Error Message

Warning: imap_open() [function.imap-open]: Couldn't open stream {imap.gmail.com:993/imap/ssl}INBOX in /home/a6194138/public_html/email_dante.php on line 8

Free Web Hosting
Cannot connect to Gmail: Can't connect to gmail-imap.l.google.com,993: Connection timed out
Logged

"Real Men can Accomplish  Anything"
-  Website  
- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੂਂ !

Pages: 1 [2]   Go Up
Jump to: