13 Replies Latest reply on Dec 23, 2014 2:56 PM by AdamMiltonBarker

    Issues with Ethernet after change to static IP

    AdamMiltonBarker

      Hi guys I have had an issue that can't get out of without reverting back to a dynamic IP which I don't want to do. Here is the code I was using which prior to the IP change did actually work. Can anyone see any reasons why this would not connect anymore, it is failing at if (client.connect(server, 80)) towards the bottom end of the script. It is the first script I have modified for the Intel I am just in my learning stages, any help would be great and if its something stupid please let me know what it is thanks in advance guys. ( All the parameters etc do work the page that this script calls is still available, the issue is definitely related to the IP change some how, I think )

       

       

      #include <SPI.h>

       

      #include <Ethernet.h>

       

       

       

      byte mac[] = {  0x##, 0x##, 0x##, 0x##, 0x##, 0x## };

       

      EthernetClient client;

       

      char server[] = "####.##########.com";

       

       

       

      int led = 13;

       

       

       

      unsigned long lastConnectionTime = 0;         

       

      boolean lastConnected = false;                 

       

      const unsigned long postingInterval = 10L*1000L;

       

       

       

      void setup() {

       

        pinMode(led, OUTPUT);   

       

        Serial.begin(9600);

       

         while (!Serial) {

       

          ;

       

        }

       

        Serial.print("oIsIoT Smart Security Galileo Protect Server Initiated\n");

       

        delay(1000);

       

        if (Ethernet.begin(mac) == 0) {

       

          Serial.println("oIsIoT Smart Security Galileo Protect Server ailed to configure Ethernet\n");

       

          for(;;)

       

            ;

       

        }

       

        Serial.print("oIsIoT Smart Security Galileo Protect Server Searching for conection...\n ");

       

      }

       

       

       

      void loop() {

       

       

       

        if (client.available()) {

       

          char c = client.read();

       

          Serial.print(c);

       

        }

       

       

       

        if((millis() - lastConnectionTime > postingInterval)) {

       

          httpRequest();

       

          Serial.println("oIsIoT Smart Security Galileo Protect Server Connected Data Request Sent!\n");

       

        }

       

        lastConnected = client.connected();

       

      }

       

       

       

      void httpRequest() {

       

          if (client.connect(server, 80)) {

       

            Serial.println("connecting..."

       

      );

            client.println("GET /#########/receiver?requesting_ip=##&requesting_device=oIsGalileo_1 HTTP/1.0");

            //Serial.println("GET /#########/receiver?requesting_ip=##&requesting_device=oIsGalileo_1 HTTP/1.0");

            client.println();

            blinkLED();

            lastConnectionTime = millis();

          }

          else {

            Serial.println("oIsIoT Smart Security Galileo Protect Server Failed\n");

            Serial.println("oIsIoT Smart Security Galileo Protect Server LED Disconnecting\n"); 

            client.stop();

          }

      }

       

       

       

      void blinkLED(void)

      {

        Serial.println("oIsIoT Smart Security Galileo Protect Server LED Indicator Initiated\n");

        digitalWrite(led, HIGH);

        delay(500);

        digitalWrite(led, LOW);

        delay(500);

        digitalWrite(led, HIGH);

        delay(500);

        digitalWrite(led, LOW);

        delay(500);

        digitalWrite(led, HIGH);

        delay(500);

        digitalWrite(led, LOW);

        delay(500);

        Serial.println("oIsIoT Smart Security Galileo Protect Server LED Indicator Terminated\n");

        return;

      }