mirror of https://github.com/ARMmbed/mbed-os.git
Allow ThreadInterface::device_eui64_get() before connect()
Perform necessary driver initialisation so that we can read the EUI-64 before connecting. Fixes #7391.pull/7818/head
parent
3a238bd7bd
commit
e014104258
|
@ -102,15 +102,20 @@ int InterfaceNanostack::disconnect()
|
|||
|
||||
nsapi_error_t MeshInterfaceNanostack::initialize(NanostackRfPhy *phy)
|
||||
{
|
||||
if (_phy) {
|
||||
if (_phy && phy && _phy != phy) {
|
||||
error("Phy already set");
|
||||
return NSAPI_ERROR_IS_CONNECTED;
|
||||
}
|
||||
_phy = phy;
|
||||
return NSAPI_ERROR_OK;
|
||||
if (phy) {
|
||||
_phy = phy;
|
||||
}
|
||||
if (_phy) {
|
||||
return do_initialize();
|
||||
} else {
|
||||
return NSAPI_ERROR_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Nanostack::Interface::network_handler(mesh_connection_status_t status)
|
||||
{
|
||||
if ((status == MESH_CONNECTED || status == MESH_CONNECTED_LOCAL ||
|
||||
|
@ -148,7 +153,9 @@ nsapi_error_t Nanostack::Interface::register_phy()
|
|||
{
|
||||
NanostackLockGuard lock;
|
||||
|
||||
_device_id = interface_phy.phy_register();
|
||||
if (_device_id < 0) {
|
||||
_device_id = interface_phy.phy_register();
|
||||
}
|
||||
if (_device_id < 0) {
|
||||
return NSAPI_ERROR_DEVICE_ERROR;
|
||||
}
|
||||
|
|
|
@ -213,6 +213,10 @@ void ThreadInterface::device_eui64_set(const uint8_t *eui64)
|
|||
|
||||
void ThreadInterface::device_eui64_get(uint8_t *eui64)
|
||||
{
|
||||
memset(eui64, 0, 8);
|
||||
if (!get_interface()) {
|
||||
return;
|
||||
}
|
||||
get_interface()->device_eui64_get(eui64);
|
||||
}
|
||||
|
||||
|
@ -226,6 +230,9 @@ void Nanostack::ThreadInterface::device_eui64_get(uint8_t *eui64)
|
|||
{
|
||||
if (!eui64_set) {
|
||||
uint8_t eui64_buf[8];
|
||||
if (register_phy() < 0) {
|
||||
return;
|
||||
}
|
||||
get_phy().get_mac_address(eui64_buf);
|
||||
device_eui64_set(eui64_buf);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue