-
Notifications
You must be signed in to change notification settings - Fork 3k
Add NetworkInterface::get_default_instance() #6855
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,13 @@ | |
class NanostackRfPhy : public NanostackPhy { | ||
public: | ||
|
||
/** Return the default on-board NanostackRfPhy | ||
* | ||
* Returns the default on-board NanostackRfPhy - this will be target-specific, and | ||
* may not be available on all targets. | ||
*/ | ||
static NanostackRfPhy &get_default_instance(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. curiosity why is this a reference and the rest pointers? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Slightly different approach to "does it exist" handling. This version aligns with what For all the app-level end - So:
This doesn't quite align - the upper style is closer to what the "HAL" does, but the lower is more flexible. First approach was the initial, and is long-existing on feature-emac. We ultimately had to do the second to solve various build problems for the higher levels, and it didn't seem worth going back to change the |
||
|
||
/** Register this physical interface with Nanostack | ||
* | ||
* @return Device driver ID or a negative error | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* LWIP implementation of NetworkInterfaceAPI | ||
* Copyright (c) 2015 ARM Limited | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "EthernetInterface.h" | ||
|
||
/* No actual interface implementation here, as EthernetInterface is | ||
* just an EMACInterface. But we can be the default EthInterface - step up | ||
* if the target has a default EMAC. | ||
*/ | ||
#if DEVICE_EMAC | ||
MBED_WEAK EthInterface *EthInterface::get_target_default_instance() | ||
{ | ||
static EthernetInterface ethernet; | ||
return ðernet; | ||
} | ||
#else | ||
MBED_WEAK EthInterface *EthInterface::get_target_default_instance() | ||
{ | ||
return NULL; | ||
} | ||
#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.
Should this macro comparison magic be commented somewhere, eg. here? On #6108 (comment) there was a good explanation for it.