| 1 | // +build !windows |
| 2 | |
| 3 | package ble |
| 4 | |
| 5 | import ( |
| 6 | "github.com/bettercap/bettercap/network" |
| 7 | ) |
| 8 | |
| 9 | type ByBLERSSISorter []*network.BLEDevice |
| 10 | |
| 11 | func (a ByBLERSSISorter) Len() int { return len(a) } |
| 12 | func (a ByBLERSSISorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] } |
| 13 | func (a ByBLERSSISorter) Less(i, j int) bool { |
| 14 | if a[i].RSSI == a[j].RSSI { |
| 15 | return a[i].Device.ID() < a[j].Device.ID() |
| 16 | } |
| 17 | return a[i].RSSI > a[j].RSSI |
| 18 | } |
| 19 | |
| 20 | type ByBLEMacSorter []*network.BLEDevice |
| 21 | |
| 22 | func (a ByBLEMacSorter) Len() int { return len(a) } |
| 23 | func (a ByBLEMacSorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] } |
| 24 | func (a ByBLEMacSorter) Less(i, j int) bool { |
| 25 | return a[i].Device.ID() < a[j].Device.ID() |
| 26 | } |
| 27 | |
| 28 | type ByBLESeenSorter []*network.BLEDevice |
| 29 | |
| 30 | func (a ByBLESeenSorter) Len() int { return len(a) } |
| 31 | func (a ByBLESeenSorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] } |
| 32 | func (a ByBLESeenSorter) Less(i, j int) bool { return a[i].LastSeen.Before(a[j].LastSeen) } |