mirror of
https://github.com/espressif/openthread.git
synced 2026-09-21 00:17:37 +00:00
NcpBase: Change/Fix the set/get property handlers for NET_STAT (#305)
This commit addresses some issues with the set/get property handlers of `NET_STAT` to ensure that wpantund/wpanctl commands "join"/"leave" operate as expected.
This commit is contained in:
committed by
Jonathan Hui
parent
440ea46775
commit
9a1a6206d0
+17
-3
@@ -1354,7 +1354,7 @@ void NcpBase::GetPropertyHandler_NET_STATE(uint8_t header, spinel_prop_key_t key
|
||||
{
|
||||
spinel_net_state_t state(SPINEL_NET_STATE_OFFLINE);
|
||||
|
||||
if (!otInterfaceUp())
|
||||
if (!otIsInterfaceUp())
|
||||
{
|
||||
state = SPINEL_NET_STATE_OFFLINE;
|
||||
}
|
||||
@@ -2267,6 +2267,11 @@ void NcpBase::SetPropertyHandler_NET_STATE(uint8_t header, spinel_prop_key_t key
|
||||
errorCode = otInterfaceDown();
|
||||
}
|
||||
|
||||
if ((errorCode == kThreadError_None) && (otGetDeviceRole() != kDeviceRoleDisabled))
|
||||
{
|
||||
errorCode = otThreadStop();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SPINEL_NET_STATE_DETACHED:
|
||||
@@ -2289,9 +2294,18 @@ void NcpBase::SetPropertyHandler_NET_STATE(uint8_t header, spinel_prop_key_t key
|
||||
errorCode = otInterfaceUp();
|
||||
}
|
||||
|
||||
if ((errorCode == kThreadError_None) && (otGetDeviceRole() == kDeviceRoleDetached))
|
||||
if ((errorCode == kThreadError_None) &&
|
||||
((otGetDeviceRole() == kDeviceRoleDisabled) || (otGetDeviceRole() == kDeviceRoleDetached)))
|
||||
{
|
||||
errorCode = otThreadStart();
|
||||
if (otGetDeviceRole() == kDeviceRoleDetached)
|
||||
{
|
||||
errorCode = otThreadStop();
|
||||
}
|
||||
|
||||
if (errorCode == kThreadError_None)
|
||||
{
|
||||
errorCode = otThreadStart();
|
||||
}
|
||||
|
||||
if (errorCode == kThreadError_None)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user