-
Notifications
You must be signed in to change notification settings - Fork 3k
Add NetworkInterface::get_default_instance() #6108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Provide an initial framework to make it easier to find a default network interface.
92fd4ec
to
dd8e531
Compare
I've put this on top of feature-emac, but it could be done without the feature-emac stuff to master as-is. Only difference would be the condition for selecting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does MESH, LOWPAN, ETHERNET, ... 0x2345 mean?
Why does Wi-Fi not get a default instance like MESH and THREAD?
@kjbracey-arm Please fix travis and jenkins CI |
The 0x2345 is just magic to let you do a "string comparison" in the C preprocessor.
Aim is to make this namespace open-ended - new code/systems can invent just new configuration names. Easy connect uses the same mechanism but closed, with:
Wi-fi doesn't get a default instance because we don't (yet) have (We also don't have NanostackRfPhy::get_default_instance() - needs to be done). I'm liking this pattern, but my main concern is how to indicate at compile time rather than link time that each of those definitions exist, to help probing for test etc. |
#define MBED_CONF_DEFAULT_CELLULAR_PASSWORD NULL | ||
#endif | ||
cellular.set_credentials(MBED_CONF_DEFAULT_CELLULAR_APN, MBED_CONF_DEFAULT_CELLULAR_USERNAME, MBED_CONF_DEFAULT_CELLULAR_PASSWORD); | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one endif missing here (see Travis failure)
I like the basic approach. Is the advanced usage (wifyish in the original comment) still in plans? Should we have a getInterfaceType() method, which would return if the interface is actually Wifi or Mesh etc? Thinking about the device that have e.g. Wifi and cellular, the app might want to know and act on the type of interface (cast the interface to correct class and use the methods?). |
The "wifyish" isn't that advanced, but yes. The "xxxInterface" methods function as the "get type" - it's equivalent to C++ If we had run-time type information enabled in the compilers that could have been this:
Little bit clunky. But one day in C++17(?) you could do:
|
@kjbracey-arm Is this still in progress? |
Yes, still work in progress. |
@kjbracey-arm Please reopen with an update |
Provide an initial framework to make it easier to find a default network
interface.
This is the germ of a concept. Follows the same pattern as just established for
EMAC::get_default_instance()
andOnboardNetworkStack::get_default_instance()
.Envisaged use: