Skip to content
This repository was archived by the owner on May 24, 2019. It is now read-only.

API to get network and WiFi interfaces w/o connecting #61

Merged
merged 1 commit into from
Dec 19, 2017
Merged

Conversation

JanneKiiskila
Copy link
Contributor

These might be useful, if you want to for example scan the WiFi
for access points BEFORE connecting.

Any device with UI/keyboard or some external input method would
likely use that, rather than have some hard-coded value.

These might be useful, if you want to for example scan the WiFi
for access points BEFORE connecting.

Any device with UI/keyboard or some external input method would
likely use that, rather than have some hard-coded value.
@JanneKiiskila
Copy link
Contributor Author

This would enable then mbed-os-example-wifi to use the easy-connect as well.... :-)
(Changes done already in my work area).

@kjbracey
Copy link

Yes, makes sense. If mbed OS had something equivalent, it would be a "get default interface" call, not "connect default interface". Having "get specific type" is a good idea - makes sense.

It would be useful for the default interface returned from the generic call to be preconfigured with set_credentials if possible such that connect() with no parameters did something sensible. (As connect with no parameters is the only thing you can do on a generic NetworkInterface).

I wonder now, should we have a "get_type" call on NetworkInterface? RTTI is disabled in the compilers, so there's no other way to check if the default interface is actually wifi, as opposed to asking specifically for a wifi interface. Maybe a bit late...

@SeppoTakalo
Copy link
Contributor

By printing error messages, instead of just returning NULL, you are forcing inclusion of whole C stdio libraries.
Most of the applications use them anyway, but there might be cases where we wan't to really minimise the flash usage.

@janjongboom
Copy link
Contributor

Yes, please use debug() from mbed_debug.h. Then stdio will not be included in release build.

@JanneKiiskila
Copy link
Contributor Author

Well, it's behind the boolean flag - if those are false the compiler should optimize it all out. Should, I know they fail sometimes. I'll try it out.

@JanneKiiskila JanneKiiskila merged commit b396fcf into master Dec 19, 2017
@JanneKiiskila JanneKiiskila deleted the getif branch December 19, 2017 09:18
@kjbracey
Copy link

I said:

I wonder now, should we have a "get_type" call on NetworkInterface?

I am actually going to add this - turns out I'm going to need it. It will allow code like this:

NetworkInterface *default_if = get_default_interface();
WiFiInterface *wifi = default_if->wifiInterface(); 
if (wifi) {
     wifi->set_credentials(...)
}

@JanneKiiskila
Copy link
Contributor Author

@kjbracey-arm - I was too fast? Anyways, feel free to make another PR and for sure we'll merge it in.
How would you know though if you get_default_interface, if it's a wifi or not? How can you know you can validly put it as wifi * ptr? Should there be some kind of "ask type" method and it would return from one enum?

@kjbracey
Copy link

No, your stuff is fine. What I'm working on was for the future EMAC work, over at ARMmbed/mbed-os#5558 - commit ARMmbed/mbed-os@d32c56d . But we could maybe accelerate that specific "check type" change if it's useful to you - the API could be added now on its own for 5.8.

The call works like dynamic_cast - you only get a WiFiInterface pointer if it actually is one. If it isn't, you get NULL. So it also functions as a "check type" call.

I think that's probably sufficient and you could live without a "type-id" enum. Only significant draw-back is that you wouldn't be able to neatly switch on the type-id, you'd have to have a chain of "if (wifi), if (cellular)".

bellashtiv added a commit that referenced this pull request Dec 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants