Is there a way to determine which network interface (WiFi, or Ethernet) is the current "active" or "primary" link? Thanks!
In Device OS 5.6.0 and later you can use Particle.connectionInterface() to find which interface the cloud is using for the cloud connection.
Prior to that you could query to see what interface is up (Ethernet.ready(), Cellular.ready(), etc.) but there wasn't a good way to see which one was used by the cloud if multiple interfaces were up.
perfect, thanks!
hmm, following the example linked there it seems to only report "Network" no matter which interface I've got connected.
String active_network;
if (Particle.connectionInterface() == WiFi)
{
active_network = "WiFi";
}
else if (Particle.connectionInterface() == Ethernet)
{
active_network = "Ethernet";
}
else if (Particle.connectionInterface() == Network)
{
active_network = "Network";
}
else
{
active_network = "Other";
}
am I holding that method wrong?
I'm switching by plugging/unplugging the ethernet, and turning the wifi network on/off. The connectivity is handled really well, it stays online as long as one of those interfaces is live, but I can't determine which one is "active" (Ethernet is set to "preferred")
I just realized that the API call was added in 5.6.0, but only worked on the M-SoM. Support for other platforms was added in Device OS 5.8.2.
What version of Device OS are you using?
5.6.0
I'll retry it now, but I'm unable to get the ethernet working on the 5.8.x, it seems to fail at the bootup/detect phase and when i get to Ethernet.isOn() it fails.
Yeah, can replicate, same code for ethernet initialization fails on 5.8.2 but works fine on 5.6.0, any chance I'm holding that wrong too?
The connectionInterface() method does appear to work as described in 5.8.2 so marking that as the solution, thanks!
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.