Zigbee Protocol Controller 1.6.0
zigpc_neighbor_table_metric.hpp
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
15#include "zigpc_common_zigbee.h"
16#include "zigpc_gateway.h"
17#include <nlohmann/json.hpp>
18#include "vector"
19#include "array"
20
22{
23 private:
24 uint8_t value;
25 static constexpr char LOG_TAG[] = "diagnostics_neighbor_table";
26
27 public:
29 std::string metric_id) :
31 {}
32
34 {
35 size_t count = zigpc_gateway_get_neighbor_count();
36 nlohmann::json jsn;
37 std::vector<std::array<uint8_t, ZIGBEE_EUI64_SIZE>> neighbor_eui64_v;
38
39 for (uint8_t i = 0U; i < count; i++) {
40 zigbee_eui64_t neighbor;
42
43 //Convert to std::array
44 std::array<uint8_t, ZIGBEE_EUI64_SIZE> neighbor_array;
45 std::copy(neighbor, neighbor + ZIGBEE_EUI64_SIZE, neighbor_array.begin());
46
47 neighbor_eui64_v.push_back(neighbor_array);
48 }
49
50 // Serialize to JSON
51 nlohmann::json j_vec(neighbor_eui64_v);
52
53 // Export
54 serialized_value = j_vec.dump();
55
57 }
58};
Abstract top level metric from which all diagnostic metric derive from.
Definition: zigpc_diagnostics_metric.hpp:25
zigpc_diagnostics_notification & on_update_complete
Definition: zigpc_diagnostics_metric.hpp:28
std::string serialized_value
Definition: zigpc_diagnostics_metric.hpp:30
std::string metric_id
Definition: zigpc_diagnostics_metric.hpp:29
Definition: zigpc_diagnostics_notification.hpp:20
virtual void notify(std::string metric_id)
Definition: zigpc_diagnostics_notification.hpp:22
Definition: zigpc_neighbor_table_metric.hpp:22
zigpc_neighbor_metric(zigpc_diagnostics_notification &notif, std::string metric_id)
Definition: zigpc_neighbor_table_metric.hpp:28
void update_value()
Definition: zigpc_neighbor_table_metric.hpp:33
uint8_t value
Definition: zigpc_neighbor_table_metric.hpp:24
static constexpr char LOG_TAG[]
Definition: zigpc_neighbor_table_metric.hpp:25
uint8_t zigbee_eui64_t[ZIGBEE_EUI64_SIZE]
Zigbee Device EUI64 ID.
Definition: zigpc_common_zigbee.h:193
#define ZIGBEE_EUI64_SIZE
Size of EUI64 (an IEEE address) in bytes (8)
Definition: zigpc_common_zigbee.h:39
uint8_t zigpc_gateway_get_neighbor_count()
Get current active count in the neighbor adress table.
sl_status_t zigpc_gateway_get_neighbor_eui64(uint8_t index, zigbee_eui64_t eui64)
Get a specific neighbor EUI64 from its index.