Go Down

Topic: Arduino Yun - Change Default gateway by sketch (Read 3372 times) previous topic - next topic

robin_pitronot

Hello everyone,
I have a system connected to the internet by two mobile(cellular) routers with two different static IPs(both routers are on the same LAN).
On last version of my system I used Arduino UNO with an Ethernet shield and everything is working properly. Now I'm trying to upgrade my system by using Arduino Yun, the Arduino suppose to be able to change it's default gateway to second router(Local IP) if the current connection(by first router) is not working properly.

my function code which works fine with Ethernet shield is this:


void checkIfGatewayChangeIsNeeded() {
  retry++;
  if (maxRetry == retry) { 
    retry=0; 
    Console.print(F("Maximum retries set to:"));
    Console.println(maxRetry);
    Console.print(F("\nMaximum retries exceeded."));
    if (gatewayInUse == 1 ) {
      Console.println(F(" Switching to other gateway... "));
      Console.println(F("Using gateway #2.\nGateway is=192.168.1.2 "));
      IPAddress gateway(gateway2);
      gatewayInUse = 2;
      ipInUse = ip2;
    } else {
      Console.println(F(" Switching to other gateway... "));
      Console.println(F("Using gateway #1.\nGateway is=192.168.1.1 "));
      IPAddress gateway(gateway1);
      gatewayInUse = 1;
      ipInUse = ip1;
    }
  }
 
}

My problem is the " IPAdress gateway()" command is not working with the Arduino Yun,
I'm looking for another way to set the default gateway of my Arduino Yun by a sketch command.
Is it possible? I will appreciate any help or advice, thanks a lot and sorry for my bad English,
Robin

Go Up