mirror of
https://github.com/espressif/openthread.git
synced 2026-09-04 00:00:06 +00:00
Do not allow enabling Thread protocols when PAN ID is set to broadcast. (#405)
This commit is contained in:
@@ -23,6 +23,12 @@ $ cd <path-to-openthread>/output/<platform>/bin
|
|||||||
$ ./ot-cli 1
|
$ ./ot-cli 1
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Set the PAN ID:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
> panid 0x1234
|
||||||
|
```
|
||||||
|
|
||||||
Bring up the IPv6 interface:
|
Bring up the IPv6 interface:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -65,6 +71,12 @@ $ cd <path-to-openthread>/output/<platform>/bin
|
|||||||
$ ./ot-cli 2
|
$ ./ot-cli 2
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Set the PAN ID:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
> panid 0x1234
|
||||||
|
```
|
||||||
|
|
||||||
Bring up the IPv6 interface:
|
Bring up the IPv6 interface:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
+12
-1
@@ -276,7 +276,17 @@ otPanId otGetPanId(void)
|
|||||||
|
|
||||||
ThreadError otSetPanId(otPanId aPanId)
|
ThreadError otSetPanId(otPanId aPanId)
|
||||||
{
|
{
|
||||||
return sThreadNetif->GetMac().SetPanId(aPanId);
|
ThreadError error = kThreadError_None;
|
||||||
|
|
||||||
|
// do not allow setting PAN ID to broadcast if Thread is running
|
||||||
|
VerifyOrExit(aPanId != Mac::kPanIdBroadcast ||
|
||||||
|
sThreadNetif->GetMle().GetDeviceState() != Mle::kDeviceStateDisabled,
|
||||||
|
error = kThreadError_InvalidState);
|
||||||
|
|
||||||
|
error = sThreadNetif->GetMac().SetPanId(aPanId);
|
||||||
|
|
||||||
|
exit:
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool otIsRouterRoleEnabled(void)
|
bool otIsRouterRoleEnabled(void)
|
||||||
@@ -894,6 +904,7 @@ ThreadError otThreadStart(void)
|
|||||||
ThreadError error = kThreadError_None;
|
ThreadError error = kThreadError_None;
|
||||||
|
|
||||||
VerifyOrExit(mEnabled, error = kThreadError_InvalidState);
|
VerifyOrExit(mEnabled, error = kThreadError_InvalidState);
|
||||||
|
VerifyOrExit(sThreadNetif->GetMac().GetPanId() != Mac::kPanIdBroadcast, error = kThreadError_InvalidState);
|
||||||
|
|
||||||
error = sThreadNetif->GetMle().Start();
|
error = sThreadNetif->GetMle().Start();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user