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:
Abtin Keshavarzian
2016-07-29 17:53:40 -07:00
committed by Jonathan Hui
parent 440ea46775
commit 9a1a6206d0
+17 -3
View File
@@ -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)
{