Argon in Ethernet Featherwing using WiFi as a fallback option


#1

I would like to set up a mesh using an Argon as a gateway with a fallback option. My intention is that the Argon is connected to the internet through an Ethernet Featherwing (connected to network 1). In case the Ethernet (network 1) goes down (e.g. when regular checks with Particle.connected() returns false), I want the Argon to connect through WiFi to a different network.

I performed the initial setup of the Argon using the mobile app, selecting in the first setup screen the option “Use with Ethernet”. Further in the setup process the app also asked for a WiFi network AP and its password. I set up a new mesh network for experimental purposes and, after updating the device, the Argon connected to the Particle cloud (breathing cyan).

Checking in the app, I could confirm that the device is connected to the cloud and based on the assigned IP address of the Argon I knew that it had connected to network 2, i.e. using WiFi, and not to network 1 through the Ethernet Featherwing. I don’t know if this is the expected behaviour in this particular case, so I decided to upload some simple test code with which I tried to “force” the Argon to use Ethernet instead of WiFi (see code below). What I intend to achieve is simply to manually switch off the WiFi, switch on the Ethernet, and then connect through network 1 to the Particle cloud.

#define debugLED D7

STARTUP(System.enableFeature(FEATURE_ETHERNET_DETECTION));

void setup() {
    pinMode(debugLED, OUTPUT);
    digitalWrite(debugLED, LOW);
    WiFi.off();
    Ethernet.on();
    Ethernet.connect();
    Particle.connect();
    digitalWrite(debugLED, HIGH); 
}

void loop() {

}

(I guess the STARTUP(System.enableFeature(FEATURE_ETHERNET_DETECTION)); should be redundant because I have set up the Argon initially with the Ethernet option, so the flag should have been set already).

After uploading the code, the blue LED (D7) lights up confirming that the code has executed, but the Argon does not connect to the cloud. The Status LED remains in a state where it is rapidly blinking green (a state that this not explained in the Docs).

Now to my questions:
a) Is my intended “failsafe” setup (i.e. Argon switching between Ethernet and WiFi connection depending on network availability) at all possible?
b) If yes, what am I missing in my code in order to switch the Argon to use the Ethernet?
c) are there better ways of selecting the connection? Do I need to do this manually or is the device OS already smart enough to automatically switch to the available network in such a situation?


#2

I can’t say whether the Argon should or shouldn’t use Ethernet by default (it might not be implemented in the device OS version you are running on your Argan - stating what you have would be good), but as for your test code, I’d suggest you use SYSTEM_MODE(SEMI_AUTOMATIC) to prevent the system from preselecting any of the available interfaces and only your code being in charge.


#3

Thanks @ScruffR. Everything works now, there was actually no problem at all. I simply didn’t have the Argon inserted correctly in the Ethernet Featherwing (offset by one Pin). Stupidity has no limits! ;.)))