Skip to content

Commit f2051eb

Browse files
authored
Merge branch 'main' into task/thdubois/SWPROT-9430/update-get-node-nls-state
2 parents b536b05 + 6b552d4 commit f2051eb

File tree

7 files changed

+101
-81
lines changed

7 files changed

+101
-81
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
uses: robinraju/[email protected]
3636
with:
3737
repository: 'Z-Wave-Alliance/z-wave-stack-binaries'
38+
tag: 'v25.1.0-28-g7e0b50f'
3839
fileName: 'z-wave-stack-binaries-*-Linux.tar.gz'
3940
token: ${{ secrets.GH_ZWAVE_ACCESS_TOKEN }}
4041
latest: true

applications/zpc/components/network_monitor/src/network_monitor.cpp

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -716,49 +716,44 @@ static void
716716
network_initialized = true;
717717
}
718718

719-
static void network_monitor_handle_event_network_ready(network_data *event_data)
719+
static void network_monitor_handle_event_network_ready(network_data const &event_data)
720720
{
721721
// Make sure that UNID / ZPC UNID are configured correctly.
722-
zwave_unid_set_home_id(event_data->home_id);
723-
zwave_unid_from_node_id(event_data->node_id, zpc_unid);
722+
zwave_unid_set_home_id(event_data.home_id);
723+
zwave_unid_from_node_id(event_data.node_id, zpc_unid);
724724

725725
// Save our updated granted keys/KEX fail
726726
network_monitor_create_attribute_store_network_nodes(
727-
event_data->granted_keys,
728-
event_data->kex_fail_type);
727+
event_data.granted_keys,
728+
event_data.kex_fail_type);
729729

730730
// Pause node resolution on any other network than ours in the Attribute Store.
731731
network_monitor_activate_network_resolution(true);
732-
733-
delete event_data;
734732
}
735733

736734
static void network_monitor_handle_event_node_id_assigned(
737-
node_id_assigned_event_data *event_data)
735+
node_id_assigned_event_data const &event_data)
738736
{
739737
network_monitor_add_attribute_store_node(
740-
event_data->node_id,
738+
event_data.node_id,
741739
ZCL_NODE_STATE_NETWORK_STATUS_COMMISIONING_STARTED);
742-
zwave_store_inclusion_protocol(event_data->node_id,
743-
event_data->inclusion_protocol);
744-
745-
delete event_data;
740+
zwave_store_inclusion_protocol(event_data.node_id,
741+
event_data.inclusion_protocol);
746742
}
747743

748744
static void
749-
network_monitor_handle_event_node_added(node_added_event_data *event_data)
745+
network_monitor_handle_event_node_added(node_added_event_data const &event_data)
750746
{
751747
// Attribute store node should already exist, but in case NODE_ID_ASSIGNED_EVENT
752748
// did not happen before this event, we ensure the node exists in the attribute store.
753-
network_monitor_update_new_node_attribute_store(*event_data);
749+
network_monitor_update_new_node_attribute_store(event_data);
754750

755-
zwave_store_inclusion_protocol(event_data->node_id,
756-
event_data->inclusion_protocol);
751+
zwave_store_inclusion_protocol(event_data.node_id,
752+
event_data.inclusion_protocol);
757753

758754
// Finally we want to update our local cache of the node list:
759755
zwave_network_management_get_network_node_list(current_node_list);
760756
// TODO: Add timeout system to detect node interview failed
761-
delete event_data;
762757
}
763758

764759
static void network_monitor_handle_event_node_interview_initiated(
@@ -1088,18 +1083,33 @@ PROCESS_THREAD(network_monitor_process, ev, data)
10881083
break;
10891084

10901085
case NETWORK_READY_EVENT:
1091-
network_monitor_handle_event_network_ready(
1092-
static_cast<network_data *>(data));
1086+
if (data) {
1087+
network_data const *event_data
1088+
= static_cast<network_data const *>(data);
1089+
data = NULL;
1090+
network_monitor_handle_event_network_ready(*event_data);
1091+
delete event_data; //< Allocated by network_monitor_on_network_ready
1092+
};
10931093
break;
10941094

10951095
case NODE_ID_ASSIGNED_EVENT:
1096-
network_monitor_handle_event_node_id_assigned(
1097-
static_cast<node_id_assigned_event_data *>(data));
1096+
if (data) {
1097+
node_id_assigned_event_data const *event_data
1098+
= static_cast<node_id_assigned_event_data const *>(data);
1099+
data = NULL;
1100+
network_monitor_handle_event_node_id_assigned(*event_data);
1101+
delete event_data; //< Allocated by network_monitor_on_node_id_assigned
1102+
};
10981103
break;
10991104

11001105
case NODE_ADDED_EVENT:
1101-
network_monitor_handle_event_node_added(
1102-
static_cast<node_added_event_data *>(data));
1106+
if (data) {
1107+
node_added_event_data const *event_data
1108+
= static_cast<node_added_event_data const *>(data);
1109+
data = NULL;
1110+
network_monitor_handle_event_node_added(*event_data);
1111+
delete event_data; //< Allocated by network_monitor_on_node_added
1112+
};
11031113
break;
11041114

11051115
case NODE_INTERVIEW_INITIATED_EVENT:

applications/zpc/components/zwave_api/external/ext_transport_security.c

Lines changed: 0 additions & 20 deletions
This file was deleted.

applications/zpc/components/zwave_api/external/ext_transport_security.h

Lines changed: 0 additions & 5 deletions
This file was deleted.

doc/protocol/zwave/zpc_introduction.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ readme_debug.md
1313
../../../applications/zpc/how_to_implement_zwave_command_classes.rst
1414
../../../applications/zpc/how_to_write_uam_files_for_the_zpc.md
1515
../../../applications/zpc/how_to_interact_with_clusters.rst
16-
../../../applications/zpc/doc/supported_command_classes.md
16+
../../../applications/zpc/doc/supported_command_classes.rst
1717
```
1818

1919
The [ZPC User Guide](../../../applications/zpc/readme_user.md) explains how to use and configure ZPC.
@@ -28,6 +28,6 @@ The guide [How to write UAM files for ZPC](../../../applications/zpc/how_to_writ
2828

2929
The guide [How to interact with clusters](../../../applications/zpc/how_to_interact_with_clusters.rst) goes into detail about the implementation of Cluster in Unify.
3030

31-
The guide [Supported Command Classes](../../../applications/zpc/doc/supported_command_classes.md) goes into detail about how the command class are implemented. This documents gives specifics about the attributes store and MQTT topics that can interact with the class.
31+
The guide [Supported Command Classes](../../../applications/zpc/doc/supported_command_classes.rst) goes into detail about how the command class are implemented. This documents gives specifics about the attributes store and MQTT topics that can interact with the class.
3232

3333
The doxygen generated <a href="../../../doxygen_zpc/index.html">ZPC API</a>

helper.mk

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,31 @@ test: ${build_dir}
243243

244244
check: test
245245

246+
zwa_project?=z-wave-stack-binaries
247+
zwa_ver?=25.1.0-28-g7e0b50f
248+
zwa_rev?=v${zwa_ver}
249+
zwa_file?=${zwa_project}-${zwa_ver}-Linux.tar.gz
250+
zwa_url?=https://github.com/Z-Wave-Alliance/${zwa_project}
251+
zwa_dir?=${zwa_project}
252+
253+
${CURDIR}/tmp/${zwa_file}:
254+
@echo "TODO: https://github.com/Z-Wave-Alliance/z-wave-stack-binaries/issues/2"
255+
mkdir -p ${@D} && cd ${@D} \
256+
&& gh release download \
257+
--repo "${zwa_url}" --pattern "${zwa_file}" \
258+
"${zwa_rev}"
259+
260+
${zwa_dir}: ${CURDIR}/tmp/${zwa_file}
261+
mkdir -p "$@"
262+
tar xfa "$<" -C "$@"
263+
264+
zwa/setup: ${zwa_project}
265+
ls ${zwa_project}
266+
246267
mapdir?=applications/zpc/components/dotdot_mapper/rules
247268
datastore_file?=tmp.db
248269
cache_path?=tmp/cache/ota
249-
devel/integration/test: ./scripts/tests/z-wave-stack-binaries-test.sh
270+
zwa/test: ./scripts/tests/z-wave-stack-binaries-test.sh ${zwa_dir}
250271
-reset
251272
rm -fv ${datastore_file} *.tmp
252273
mkdir -p ${cache_path}

scripts/tests/z-wave-stack-binaries-test.sh

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ set -o pipefail
1111

1212
# Default configuration can be overloaded from env
1313

14+
# To be explicilty added to env
15+
sudo="${sudo:=}"
16+
1417
duration=3 # Allocated time in mins until watchdog quit
1518

1619
ZPC_COMMAND="${ZPC_COMMAND:=/usr/bin/zpc}"
@@ -91,7 +94,8 @@ EOF
9194

9295
log_()
9396
{
94-
[ "$debug" != "" ] && echo || clear ||:
97+
[ "$debug" != "" ] && echo \
98+
|| clear >/dev/null 2>&1 || reset >/dev/null 2>&1 || :
9599
printf "${yellow}info: $@ ${nocol}\n"
96100
}
97101

@@ -103,18 +107,12 @@ exit_()
103107
sleep 10
104108
[ -z $debug ] || sleep 1000
105109
echo $code > $code_log
106-
screen -S "$name" -X "quit"
110+
screen -S "$name" -X "quit" ||:
111+
ls -l *.log.tmp && more *.log.tmp | cat
107112
exit $code
108113
}
109114

110115

111-
die_()
112-
{
113-
local code=$(( 1 + 0$code))
114-
exit_ $code
115-
}
116-
117-
118116
run_()
119117
{
120118
local task="$1" && shift
@@ -131,12 +129,13 @@ mqtt_()
131129
pidof mosquitto \
132130
&& mosquitto_sub \
133131
-v -t '#' --remove-retained --retained-only -W 1 \
134-
&& break
132+
|| [ 27 = $? ] && break ||: # Break on timeout
135133
sleep .1
136-
done > /dev/null 2>&1
134+
done
135+
log_ "mqtt: broker is ready, operating for ${duration} mins"
137136
mosquitto_sub -v -t '#' -W $((60 * ${duration}))
138137
log_ "mqtt: error: Should have finish before ${duration} may need to update it"
139-
die_
138+
exit_ 10
140139
}
141140

142141

@@ -159,7 +158,7 @@ sub_()
159158
| head -n1 | grep -F "$expect" 2>&1 > /dev/null \
160159
|| { printf "${red}exp: error:: ${expect}${nocol}\n" ;
161160
cat "$mqtt_sub_log" ;
162-
die_ ; }
161+
exit_ 11; }
163162
fi
164163
}
165164

@@ -179,7 +178,6 @@ pub_()
179178

180179
pubsub_()
181180
{
182-
# reset
183181
echo ""
184182
[ "" = "$debug" ] || log_ "pubsub_: $@"
185183
local pub="$1"
@@ -236,13 +234,10 @@ controller_cli_()
236234
| tail -n 1 | sed -e 's|PTY: \(.*\)|\1|g' )
237235
;;
238236
H)
239-
[ -z $debug ] || log_ "TODO: print HOME_ID: from device: https://github.com/Z-Wave-Alliance/z-wave-stack/issues/732"
240-
sleep 1
241-
while [ ! -e "${mqtt_log}" ] ; do sleep 1; done
242-
# [ "$homeid" != "" ]
243-
homeid=$(sed -n -e 's|ucl/by-unid/zw-\(.*\)-\([0-9]*\)/.*|\1|gp' "$mqtt_log" | tail -n1)
237+
homeid=$(grep 'HOME_ID: ' "${controller_log}" \
238+
| tail -n 1 | sed -e 's|HOME_ID: \(.*\)|\1|g' )
244239
echo "HOME_ID: ${homeid}"
245-
[ ! -z $homeid ] || die_
240+
[ ! -z $homeid ] || exit_ 19
246241
;;
247242
n)
248243
contid=$(grep 'NODE_ID: ' "${controller_log}" \
@@ -319,7 +314,7 @@ zpc_()
319314
sleep 1
320315
zpc_cli_ version
321316
zpc_cli_ help
322-
die_
317+
exit_ 13
323318
}
324319

325320

@@ -346,8 +341,8 @@ zpc_cli_()
346341
play_uic_net_add_node_()
347342
{
348343
log_ "net: controller: Add node (set in learn mode)"
349-
controller_cli_ H | grep "^HOME_ID: ........$" || die_
350-
controller_cli_ n | grep "^NODE_ID: " || die_
344+
controller_cli_ H | grep "^HOME_ID: ........$" || exit_ 14
345+
controller_cli_ n | grep "^NODE_ID: " || exit_ 15
351346

352347
sub="ucl/by-mqtt-client/zpc/ApplicationMonitoring/SupportedCommands"
353348
pub="$sub" # Can be anything
@@ -364,7 +359,7 @@ play_uic_net_add_node_()
364359
homeid=$(sed -n -e 's|ucl/by-unid/zw-\(.*\)-\([0-9]*\)/.*|\1|gp' "$mqtt_sub_log")
365360
contid=$(sed -n -e 's|ucl/by-unid/zw-\(.*\)-\([0-9]*\)/.*|\2|gp' "$mqtt_sub_log")
366361
contunid="zw-$homeid-$contid"
367-
node_cli_ n | grep 'NODE_ID: 0' || die_
362+
node_cli_ n | grep 'NODE_ID: 0' || exit_ 16
368363
node_cli_ l
369364

370365
log_ "net: cont: Add node"
@@ -374,7 +369,7 @@ play_uic_net_add_node_()
374369
count="2" # NODEID=0001 is controller , NODEID=0002 is expected node
375370
expect="State/SupportedCommands"
376371
pubsub_ "$pub" "$message" "$sub" "$expect"
377-
node_cli_ H | grep "HOME_ID: ${homeid}" || die_
372+
node_cli_ H | grep "HOME_ID: ${homeid}" || exit_ 17
378373
node_cli_ n # Should not be 0
379374
pub=''
380375
sub=$(echo "$sub" | sed -e "s|/+/|/$nodeunid/|g")
@@ -413,7 +408,7 @@ play_uic_net_remove_node_()
413408
expect=$(echo "$sub (null)" | sed -e "s|/+/|/$nodeunid/|g")
414409
node_cli_ l
415410
pubsub_ "$pub" "$message" "$sub" "$expect" 3
416-
node_cli_ n | grep '^NODE_ID: 0$' || die_
411+
node_cli_ n | grep '^NODE_ID: 0$' || exit_ 18
417412
}
418413

419414

@@ -487,7 +482,9 @@ play_uic_()
487482
play_()
488483
{
489484
log_ "play: Wait for zpc mqtt ready"
490-
while ! grep -- "mqtt_wrapper_mosquitto" "${zpc_log}" ; do sleep 1 ; done
485+
while ! grep -- "\[mqtt_wrapper_mosquitto\]" "${zpc_log}" ; do sleep 1 ; done
486+
while ! grep -- "\[mqtt_client\] Connection to MQTT broker" "${zpc_log}" ; do sleep 1 ; done
487+
491488
controller_cli_ h
492489
node_cli_ h
493490

@@ -501,12 +498,17 @@ setup_()
501498
local project="z-wave-stack-binaries"
502499
local url="https://github.com/Z-Wave-Alliance/${project}"
503500
local pattern="$project-*.tar.gz" # TODO: Bump latest release
504-
pattern="$project-25.1.0-25-g3b1e09d-Linux.tar.gz"
501+
local rev="25.1.0-26-g29d304"
502+
pattern="$project-${rev}-Linux.tar.gz"
505503

506504
mkdir -p "${project}" && cd "${project}"
507505
file -E "${pattern}" \
508506
|| gh release download -R "$url" --pattern "$pattern"
509507
tar xvfz "${project}"*.tar.gz
508+
# TODO: https://github.com/eclipse-mosquitto/mosquitto/issues/3267
509+
mosquitto_pub --version \
510+
|| which mosquitto_pub \
511+
|| $sudo apt install mosquitto-clients
510512
}
511513

512514

@@ -515,6 +517,17 @@ default_()
515517
usage_
516518
sleep 1
517519

520+
log_ "Setup check, if failing please setup using:"
521+
echo "sudo=sudo $0 setup_"
522+
523+
[ "" = "$debug" ] || set
524+
525+
screen --version
526+
527+
# TODO: https://github.com/eclipse-mosquitto/mosquitto/issues/3267
528+
mosquitto_pub --version \
529+
|| which mosquitto_pub
530+
518531
log_ "z-wave-stack-binaries: Check presence in ${z_wave_stack_binaries_bin_dir}"
519532
file -E "${z_wave_stack_binaries_bin_dir}/"*"REALTIME"*".elf"
520533
sleep 2
@@ -576,7 +589,7 @@ EOF
576589
cat "${mqtt_log}"
577590

578591
code=$(cat ${code_log} || echo 254)
579-
exit 0$code
592+
exit_ 0$code
580593
}
581594

582595

0 commit comments

Comments
 (0)