Class: KismetToKml::WifiNetwork
- Inherits:
-
Object
- Object
- KismetToKml::WifiNetwork
- Defined in:
- lib/kismet_to_kml/wifi_network.rb
Instance Method Summary collapse
- #add_point(gps_point_node) ⇒ Object
- #bssid ⇒ Object
-
#initialize(network_node) ⇒ WifiNetwork
constructor
A new instance of WifiNetwork.
- #kml_name ⇒ Object
- #kml_placement ⇒ Object
- #ssid ⇒ Object
Constructor Details
#initialize(network_node) ⇒ WifiNetwork
Returns a new instance of WifiNetwork.
5 6 7 8 |
# File 'lib/kismet_to_kml/wifi_network.rb', line 5 def initialize(network_node) @network_node = network_node @gps_points = [] end |
Instance Method Details
#add_point(gps_point_node) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/kismet_to_kml/wifi_network.rb', line 10 def add_point(gps_point_node) @gps_points << gps_point_node.attributes.values.map do |attr| [ attr.name.gsub("-", "_").to_sym, attr.value ] end.to_h end |
#bssid ⇒ Object
19 20 21 |
# File 'lib/kismet_to_kml/wifi_network.rb', line 19 def bssid @network_node.search(Consts::BSSID).first.text end |
#kml_name ⇒ Object
31 32 33 |
# File 'lib/kismet_to_kml/wifi_network.rb', line 31 def kml_name "#{ssid} (#{bssid})" end |
#kml_placement ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/kismet_to_kml/wifi_network.rb', line 35 def kml_placement total_weight = 0 lat_sum = 0 lon_sum = 0 alt_sum = 0 @gps_points.each do |point| lat = point[:lat].to_f lon = point[:lon].to_f dbm = point[:signal_dbm].to_i alt = point[:alt].to_f weight = 10 ** ( dbm / 10 ) lat_sum += lat * weight lon_sum += lon * weight alt_sum += alt total_weight += weight end center_lat = (lat_sum / total_weight).round(6) center_lon = (lon_sum / total_weight).round(6) avg_alt = (alt_sum / @gps_points.count).round(3) [center_lon, center_lat, avg_alt].join(",") end |
#ssid ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/kismet_to_kml/wifi_network.rb', line 23 def ssid begin @network_node.search(Consts::SSID).first&.search(Consts::ESSID).first&.text || Consts::UNKNOWN_SSID rescue Consts::UNKNOWN_SSID end end |