From e9ecf8f447cd11d47c6db164253934e51d21c3a3 Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Mon, 4 Jun 2012 20:58:17 +0200 Subject: [PATCH] fix link quality again --- nodedb.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/nodedb.py b/nodedb.py index 0d328c8..f90ef02 100644 --- a/nodedb.py +++ b/nodedb.py @@ -19,7 +19,7 @@ except NameError: class NodeDB: def __init__(self): self._nodes = [] - self._links = set() + self._links = [] # fetch list of links def get_links(self): @@ -29,6 +29,15 @@ class NodeDB: def get_nodes(self): return self._nodes + def add_link(self, a, b, q): + l = tuple(sorted((a,b))) + for link in self._links: + if l == link[0]: + if link[1] != str(q): + link[1] += " / " + str(q) + return + self._links.append([l,str(q)]) + def maybe_node_by_mac(self, macs): for node in self._nodes: for mac in macs: @@ -96,7 +105,7 @@ class NodeDB: a = self._nodes.index(router) b = self._nodes.index(neighbor) - self._links.add(tuple((tuple(sorted((a,b))), x['label']))) + self.add_link(a, b, x['label']) for line in lines: x = json.loads(line)