File tree Expand file tree Collapse file tree 2 files changed +19
-5
lines changed
features/nanostack/mbed-mesh-api/source Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -102,15 +102,20 @@ int InterfaceNanostack::disconnect()
102
102
103
103
nsapi_error_t MeshInterfaceNanostack::initialize (NanostackRfPhy *phy)
104
104
{
105
- if (_phy) {
105
+ if (_phy && phy && _phy != phy ) {
106
106
error (" Phy already set" );
107
107
return NSAPI_ERROR_IS_CONNECTED;
108
108
}
109
- _phy = phy;
110
- return NSAPI_ERROR_OK;
109
+ if (phy) {
110
+ _phy = phy;
111
+ }
112
+ if (_phy) {
113
+ return do_initialize ();
114
+ } else {
115
+ return NSAPI_ERROR_PARAMETER;
116
+ }
111
117
}
112
118
113
-
114
119
void Nanostack::Interface::network_handler (mesh_connection_status_t status)
115
120
{
116
121
if ((status == MESH_CONNECTED || status == MESH_CONNECTED_LOCAL ||
@@ -148,7 +153,9 @@ nsapi_error_t Nanostack::Interface::register_phy()
148
153
{
149
154
NanostackLockGuard lock;
150
155
151
- _device_id = interface_phy.phy_register ();
156
+ if (_device_id < 0 ) {
157
+ _device_id = interface_phy.phy_register ();
158
+ }
152
159
if (_device_id < 0 ) {
153
160
return NSAPI_ERROR_DEVICE_ERROR;
154
161
}
Original file line number Diff line number Diff line change @@ -213,6 +213,10 @@ void ThreadInterface::device_eui64_set(const uint8_t *eui64)
213
213
214
214
void ThreadInterface::device_eui64_get (uint8_t *eui64)
215
215
{
216
+ memset (eui64, 0 , 8 );
217
+ if (!get_interface ()) {
218
+ return ;
219
+ }
216
220
get_interface ()->device_eui64_get (eui64);
217
221
}
218
222
@@ -226,6 +230,9 @@ void Nanostack::ThreadInterface::device_eui64_get(uint8_t *eui64)
226
230
{
227
231
if (!eui64_set) {
228
232
uint8_t eui64_buf[8 ];
233
+ if (register_phy () < 0 ) {
234
+ return ;
235
+ }
229
236
get_phy ().get_mac_address (eui64_buf);
230
237
device_eui64_set (eui64_buf);
231
238
}
You can’t perform that action at this time.
0 commit comments