watch network connections with dbus and ruby 2
four portland area tech entrepreneurs launched shizzow.com. automatic checkin is an important way to get services like these to be used. the dbus message system on linux machines is a great way to passively detect connections to a wireless network. using the package 'ruby-dbus-0.2.1', this is all it takes to be notified of any change in network status. note this prints any change including signal strength. i believe the [3] value is association to a new network.
The output looks like:
require 'dbus'
bus = DBus::SystemBus.instance
# register for signals
#
mr = DBus::MatchRule.new
mr.type = "signal"
mr.interface = "org.freedesktop.NetworkManager"
mr.path = "/org/freedesktop/NetworkManager"
bus.add_match(mr) do |msg, first_param|
puts msg.params.inspect
end
# Main loop
main = DBus::Main.new
main << bus
main.run ["/org/freedesktop/NetworkManager/Devices/wlan0", 100] (using the applet, re-associate now) ["/org/freedesktop/NetworkManager/Devices/wlan0", 89] ["/org/freedesktop/NetworkManager/Devices/wlan0", 4] ["/org/freedesktop/NetworkManager/Devices/wlan0", 99] ["/org/freedesktop/NetworkManager/Devices/wlan0", 100] ["/org/freedesktop/NetworkManager/Devices/wlan0", 5] ["/org/freedesktop/NetworkManager/Devices/wlan0", 6] ["/org/freedesktop/NetworkManager/Devices/wlan0", 7] [3] (use this for network association hook?) ["/org/freedesktop/NetworkManager/Devices/wlan0", "www.personaltelco.net"] ["/org/freedesktop/NetworkManager/Devices/wlan0", "/org/freedesktop/NetworkManager/Devices/wlan0/Networks/www_2e_personaltelco_2e_net", 77]Using the [3] or the essid announcement as a trigger, an http post could be launched to report to shizzow or plazes of one's current location. This would be packaged into a .deb file for ubuntu and launched as a daemon at startup.
Comments
-
This is cool how do you plan on doing the mapping from essid to location? It would be handy if shizzow had a way of searching by essid.
-
Yeah thats a problem. I expect shizzow will add essid support of some sort. Or possibly a mapping of essid to street address is possible from some other service. Basically plazes will be supported first.