diff --git a/tools/mesh/keys.c b/tools/mesh/keys.c
index 0ce8ce8..77b32da 100644
--- a/tools/mesh/keys.c
+++ b/tools/mesh/keys.c
static struct l_queue *net_keys;
-static bool simple_match(const void *a, const void *b)
+static bool app_key_present(const struct net_key *key, uint16_t app_idx)
{
- return a == b;
+ const struct l_queue_entry *l;
+
+ for (l = l_queue_get_entries(key->app_keys); l; l = l->next) {
+ uint16_t idx = L_PTR_TO_UINT(l->data);
+
+ if (idx == app_idx)
+ return true;
+ }
+
+ return false;
}
static bool net_idx_match(const void *a, const void *b)
if (!key->app_keys)
key->app_keys = l_queue_new();
- if (l_queue_find(key->app_keys, simple_match, L_UINT_TO_PTR(app_idx)))
+ if (app_key_present(key, app_idx))
return;
l_queue_push_tail(key->app_keys, L_UINT_TO_PTR(app_idx));
if (!key->app_keys)
continue;
- if (l_queue_remove_if(key->app_keys, simple_match,
- L_UINT_TO_PTR(app_idx)))
+ if (l_queue_remove(key->app_keys, L_UINT_TO_PTR(app_idx)))
return;
}
}
if (!key->app_keys)
continue;
- if (l_queue_find(key->app_keys, simple_match,
- L_UINT_TO_PTR(app_idx)))
+ if (app_key_present(key, app_idx))
return key->idx;
}
{
uint16_t app_idx = L_PTR_TO_UINT(app_key);
- bt_shell_printf("%3.3x, ", app_idx);
+ bt_shell_printf("0x%3.3x, ", app_idx);
}
static void print_netkey(void *net_key, void *user_data)
{
struct net_key *key = net_key;
- bt_shell_printf(COLOR_YELLOW "NetKey: %3.3x\n" COLOR_OFF, key->idx);
+ bt_shell_printf(COLOR_YELLOW "NetKey: 0x%3.3x\n" COLOR_OFF, key->idx);
if (!key->app_keys || l_queue_isempty(key->app_keys))
return;
diff --git a/tools/mesh/remote.c b/tools/mesh/remote.c
index 673c7b0..25e8d23 100644
--- a/tools/mesh/remote.c
+++ b/tools/mesh/remote.c
static struct l_queue *nodes;
-static bool simple_match(const void *a, const void *b)
+static bool key_present(struct l_queue *keys, uint16_t app_idx)
{
- return a == b;
+ const struct l_queue_entry *l;
+
+ for (l = l_queue_get_entries(keys); l; l = l->next) {
+ uint16_t idx = L_PTR_TO_UINT(l->data);
+
+ if (idx == app_idx)
+ return true;
+ }
+
+ return false;
}
static int compare_unicast(const void *a, const void *b, void *user_data)
if (!rmt)
return false;
- if (l_queue_find(rmt->net_keys, simple_match, L_UINT_TO_PTR(net_idx)))
+ if (key_present(rmt->net_keys, net_idx))
return false;
l_queue_push_tail(rmt->net_keys, L_UINT_TO_PTR(net_idx));
if (!rmt->app_keys)
rmt->app_keys = l_queue_new();
- if (l_queue_find(rmt->app_keys, simple_match, L_UINT_TO_PTR(app_idx)))
+ if (key_present(rmt->app_keys, app_idx))
return false;
l_queue_push_tail(rmt->app_keys, L_UINT_TO_PTR(app_idx));