2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <uwb-private.h>
24 void _node_free_func(gpointer data)
26 uwb_node_s *node = (uwb_node_s *)data;
33 void uwb_util_destroy_network(uwb_network_s *network)
38 g_slist_free_full(network->remote_node_list, _node_free_func);
44 uwb_node_s *uwb_util_get_node_from_variant(GVariant *va)
46 GVariantIter *iter = NULL;
48 GVariant *key_value = NULL;
50 uwb_node_s *node = calloc(1, sizeof(uwb_node_s));
53 _ERR("Memory allocation failed");
58 g_variant_get(va, "a{sv}", &iter);
59 while (g_variant_iter_loop(iter, "{sv}", &key, &key_value)) {
60 if (g_strcmp0(key, "Distance") == 0)
61 node->distance = g_variant_get_uint64(key_value);
62 else if (g_strcmp0(key, "NodeID") == 0)
63 node->node_id = g_variant_get_uint64(key_value);
64 else if (g_strcmp0(key, "PanID") == 0)
65 node->pan_id = g_variant_get_uint16(key_value);
66 else if (g_strcmp0(key, "X") == 0)
67 node->x = g_variant_get_int32(key_value);
68 else if (g_strcmp0(key, "Y") == 0)
69 node->y = g_variant_get_int32(key_value);
70 else if (g_strcmp0(key, "Z") == 0)
71 node->z = g_variant_get_int32(key_value);
72 else if (g_strcmp0(key, "Range") == 0)
73 node->range = g_variant_get_int32(key_value);
74 else if (g_strcmp0(key, "Aoa") == 0)
75 node->aoa = g_variant_get_int32(key_value);
76 else if (g_strcmp0(key, "Pdoa") == 0)
77 node->pdoa = g_variant_get_int32(key_value);
78 else if (g_strcmp0(key, "FilteredRange") == 0)
79 node->filtered_range = g_variant_get_int32(key_value);
80 else if (g_strcmp0(key, "FilteredAoa") == 0)
81 node->filtered_aoa = g_variant_get_int32(key_value);
84 g_variant_iter_free(iter);