Z-Wave Protocol Controller Reference
network_monitor_utils.h
Go to the documentation of this file.
1/******************************************************************************
2 * # License
3 * <b>Copyright 2022 Silicon Laboratories Inc. www.silabs.com</b>
4 ******************************************************************************
5 * The licensor of this software is Silicon Laboratories Inc. Your use of this
6 * software is governed by the terms of Silicon Labs Master Software License
7 * Agreement (MSLA) available at
8 * www.silabs.com/about-us/legal/master-software-license-agreement. This
9 * software is distributed to you in Source Code format and is governed by the
10 * sections of the MSLA applicable to Source Code.
11 *
12 *****************************************************************************/
13
14#ifndef NETWORK_MONITOR_UTILS_H
15#define NETWORK_MONITOR_UTILS_H
16
17// Unify components
18#include "attribute_store.h"
19
20// ZPC Components
21#include "zwave_utils.h"
22
23// Interfaces
24#include "zwave_generic_types.h"
25
26#ifdef __cplusplus
27#include <functional>
28
29// the following retain code should be moved to a c++ utility
30// library.
31namespace __private
32{
46template<class Sequence> void retain_recursive(
47 Sequence &sequence,
48 typename Sequence::iterator &begin,
49 const typename Sequence::iterator &end,
50 const std::function<bool(const typename Sequence::const_iterator &)> predicate)
51{
52 constexpr int delete_buffer_size = 16;
53 typename Sequence::const_iterator to_delete[delete_buffer_size] = {};
54 size_t delete_index = 0;
55
56 while (begin != end) {
57 if (delete_index < delete_buffer_size) {
58 if (!predicate(begin)) {
59 to_delete[++delete_index] = begin;
60 }
61 } else {
62 retain_recursive(sequence, begin, end, predicate);
63 break;
64 }
65 ++begin;
66 }
67
68 // remove from back to first in order to not invalidate iterators
69 for (size_t i = delete_index; i > 0; --i) {
70 sequence.erase(to_delete[i]);
71 }
72}
73} // namespace __private
74
84template<class Sequence> static void retain(
85 Sequence &sequence,
86 const std::function<bool(const typename Sequence::const_iterator &)> predicate)
87{
88 auto begin = sequence.begin();
89 const auto end = sequence.end();
90 __private::retain_recursive(sequence, begin, end, predicate);
91}
92
93extern "C" {
94#endif
95
107 attribute_store_node_t node_id_node, int32_t inactive_time);
108
117
118#ifdef __cplusplus
119}
120#endif
121#endif
enum zwave_operating_mode zwave_operating_mode_t
Z-Wave Operating Modes (AL, FL or NL). Refer to the Z-Wave Network Layer Specification for details.
zwave_operating_mode_t network_monitor_get_operating_mode(attribute_store_node_t node_id_node)
Gets the Z-Wave operating mode () from the Attribute Store Node for the NodeID.
bool network_monitor_is_node_asleep_due_to_inactivity(attribute_store_node_t node_id_node, int32_t inactive_time)
Checks if we had a long tx/rx inactivity that would result in an NL node falling asleep.
attribute_store_node_t node_id_node
Various Z-Wave related utilities.