diff --git a/unms.go b/unms.go index 0c479eb..1067de1 100644 --- a/unms.go +++ b/unms.go @@ -62,7 +62,7 @@ func processUNMSAPI() ([]node, []link) { // check if remote mac address is part of our published network for i := range airmaxes { if isRemoteMACpublished(airmaxes[i].DeviceIdentification.MAC, d.Devices) { - //links = UnmsAddLink(dev, airmaxes[i], links) + links = UnmsAddLink(dev, airmaxes[i], links) } } // END OF API CALL 3 @@ -321,3 +321,22 @@ func UnmsGetAddresses(ip string) []string { adresses = append(adresses, strings.Split(ip, "/")[0]) return adresses } + +func UnmsAddLink(dev unifiAPIResponse, airmaxes unifiAPIAirmax, links []link) []link { + for i := range links { + if links[i].SourceAddr == airmaxes.DeviceIdentification.MAC { + // link already exists + return links + } + } + links = append(links, link{ + Type: "wifi", + Source: strings.ReplaceAll(dev.Identification.MAC, ":", ""), + Target: strings.ReplaceAll(airmaxes.DeviceIdentification.MAC, ":", ""), + SourceTQ: airmaxes.Statistics.LinkScore, + TargetTQ: airmaxes.Statistics.LinkScore, + SourceAddr: dev.Identification.MAC, + TargetAddr: airmaxes.DeviceIdentification.MAC, + }) + return links +}