Skip to content

Commit 40141de

Browse files
authored
Merge pull request #2 from osaether/fix-wpanctl
Only call wpanctl when command line arg asks for it
2 parents 3ec0fe2 + 4593ec8 commit 40141de

File tree

2 files changed

+70
-20
lines changed

2 files changed

+70
-20
lines changed

README.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,17 @@ docker run --name otbr-mqtt-sn -p 8080:80 --dns=127.0.0.1 -it --privileged otbr-
1919
The most common network parameters can be set on the docker command line. The default values are taken from the [Nordic Semiconductor border router](https://www.nordicsemi.com/Software-and-tools/Software/nRF5-SDK-for-Thread-and-Zigbee/Download#infotabs) such that it works with the examples in the [nRF5 SDK for Thread and Zigbee](https://www.nordicsemi.com/Software-and-tools/Software/nRF5-SDK-for-Thread-and-Zigbee).
2020
The command line options with default values are shown in the following table.
2121

22-
| Parameter | Command line option | Default value | Note |
23-
|----------------------|:--------------------------------|:---------------------------------|:--------|
24-
| Network Name | --network-name | OTBR-MQTT-SN | |
25-
| NCP Serial Port | --ncp-path | /dev/ttyACM0 | |
26-
| PAN ID | --panid | 0xABCD | 1 |
27-
| Extended PAN ID | --xpanid | DEAD00BEEF00CAFE | 1 |
28-
| NCP Channel | --ncp-channel | 11 | 1 |
29-
| Network Key | --network-key | 00112233445566778899AABBCCDDEEFF | 1 |
30-
| Network PSKc | --pskc | E00F739803E92CB42DAA7CCE1D2A394D | 1 |
31-
| TUN Interface Name | --interface | wpan0 | |
32-
| NAT64 Prefix | --nat64-prefix | 64:ff9b::/96 | |
33-
| Default prefix route | --disable-default-prefix-route | Enabled | |
34-
| Default prefix slaac | --disable-default-prefix-slaac | Enabled | |
35-
| MQTT Broker | --broker | mqtt.eclipse.org | |
36-
37-
1: These are changed only when the Network Name is changed. To force a change you must change the Network Name.
22+
| Parameter | Command line option | Default value |
23+
|----------------------|:--------------------------------|:---------------------------------|
24+
| Network Name | --network-name | OTBR-MQTT-SN |
25+
| NCP Serial Port | --ncp-path | /dev/ttyACM0 |
26+
| PAN ID | --panid | 0xABCD |
27+
| Extended PAN ID | --xpanid | DEAD00BEEF00CAFE |
28+
| NCP Channel | --ncp-channel | 11 |
29+
| Network Key | --network-key | 00112233445566778899AABBCCDDEEFF |
30+
| Network PSKc | --pskc | E00F739803E92CB42DAA7CCE1D2A394D |
31+
| TUN Interface Name | --interface | wpan0 |
32+
| NAT64 Prefix | --nat64-prefix | 64:ff9b::/96 |
33+
| Default prefix route | --disable-default-prefix-route | Enabled |
34+
| Default prefix slaac | --disable-default-prefix-slaac | Enabled |
35+
| MQTT Broker | --broker | mqtt.eclipse.org |

docker_entrypoint.sh

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ parse_args "$@"
109109
[ -n "$AUTO_PREFIX_ROUTE" ] || AUTO_PREFIX_ROUTE=true
110110
[ -n "$AUTO_PREFIX_SLAAC" ] || AUTO_PREFIX_SLAAC=true
111111
[ -n "$NAT64_PREFIX" ] || NAT64_PREFIX="64:ff9b::/96"
112-
[ -n "$NETWORK_NAME" ] || NETWORK_NAME="OTBR-MQTT_SN"
112+
[ -n "$NETWORK_NAME" ] || NETWORK_NAME="OTBR-MQTT-SN"
113113
# Use same default network configuration as the Nordic Semiconductor Raspberry PI
114114
# borderrouter (see /etc/border_router.conf on the RPI)
115115
[ -n "$NETWORK_KEY" ] || NETWORK_KEY="00112233445566778899AABBCCDDEEFF"
@@ -153,23 +153,75 @@ nohup 2>&1 /app/borderrouter/MQTT-SNGateway &
153153
# Atach to the Thread network.
154154
###############################################################################
155155

156+
CNK=0
157+
if !(wpanctl getprop Network:Key | grep -q "Network:Key = \[\"$NETWORK_KEY\"\]"); then
158+
CNK=1
159+
fi
160+
161+
CNN=0
156162
if !(wpanctl getprop Network:Name | grep -q "Network:Name = \"$NETWORK_NAME\""); then
163+
CNN=1
164+
fi
165+
166+
CNP=0
167+
if !(wpanctl getprop Network:PANID | grep -q "Network:PANID = \"$NETWORK_PANID\""); then
168+
CNP=1
169+
fi
170+
171+
CNX=0
172+
if !(wpanctl getprop Network:XPANID | grep -q "Network:XPANID = \"$NETWORK_XPANID\""); then
173+
CNX=1
174+
fi
175+
176+
CNC=0
177+
if !(wpanctl getprop NCP:Channel | grep -q "NCP:Channel = \"$NCP_CHANNEL\""); then
178+
CNC=1
179+
fi
180+
181+
CNS=0
182+
if !(wpanctl getprop Network:PSKc | grep -q "Network:PSKc = \[\"$NETWORK_PSKC\"\]"); then
183+
CNS=1
184+
fi
185+
186+
if (( $CNK==1 )) || (( $CNN==1 )) || (( $CNP==1 )) || (( $CNX==1 )) || (( $CNC==1 )) || (( $CNS==1 )); then
157187
wpanctl leave
158188
sleep 1
159189

160190
wpanctl reset
161191
sleep 2
192+
fi
162193

194+
if (( $CNK==1 )); then
163195
wpanctl setprop Network:Key --data $NETWORK_KEY
196+
fi
197+
198+
if (( $CNN==1 )); then
199+
wpanctl setprop Network:Name $NETWORK_NAME
200+
fi
201+
202+
if (( $CNP==1 )); then
164203
wpanctl setprop Network:PANID $NETWORK_PANID
204+
fi
205+
206+
if (( $CNX==1 )); then
165207
wpanctl setprop Network:XPANID $NETWORK_XPANID
208+
fi
209+
210+
if (( $CNC==1 )); then
166211
wpanctl setprop NCP:Channel $NCP_CHANNEL
167-
wpanctl setprop Network:Name $NETWORK_NAME
212+
fi
213+
214+
if (( $CNS==1 )); then
168215
wpanctl setprop Network:PSKc $NETWORK_PSKC
216+
fi
217+
218+
if (( $CNK==1 )) || (( $CNN==1 )) || (( $CNP==1 )) || (( $CNX==1 )) || (( $CNC==1 )) || (( $CNS==1 )); then
169219
wpanctl attach
170220
sleep 3
171-
wpanctl status
172-
fi
221+
fi
222+
223+
wpanctl status
224+
173225

174226
while [ $? = 0 ]
175227
do

0 commit comments

Comments
 (0)