Permalink
Browse files

bf01d status

  • Loading branch information...
1 parent 75252ef commit 4d8024b555c8c623348dae30de98d6fd704bb37b @sorah committed May 13, 2012
Showing with 30 additions and 0 deletions.
  1. +3 −0 .gitmodules
  2. +27 −0 bin/bf01d_status.rb
View
@@ -5,3 +5,6 @@
[submodule "script/cdd"]
path = script/cdd
url = https://github.com/m4i/cdd.git
+[submodule "tmux/osx-pasteboard"]
+ path = tmux/osx-pasteboard
+ url = https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard.git
View
@@ -0,0 +1,27 @@
+#!/usr/bin/env ruby
+require 'open-uri'
+require 'nokogiri'
+
+router, pass = ARGV[0..1]
+url = "http://#{router}:8888/status"
+
+begin
+ xml_ = open(url, http_basic_authentication: ['root', pass], &:read)
+rescue Exception; exit 1; end
+xml = Nokogiri::XML.parse(xml_)
+
+
+battery = xml.at('pwrStatus power battery').inner_text.to_i
+
+route = xml.at('pwrStatus routeInterface').inner_text.to_i
+routex = xml.at("pwrStatus interface[id='#{route}']")
+
+print "BF-01D #{battery}% - "
+case route
+when 0
+ puts " Wi-Fi: #{routex.at('ssid').inner_text} (#{routex.at('rssi').inner_text})"
+when 1
+ puts " #{routex.at('lte').inner_text == 'true' ? "LTE" : "3G"} (#{routex.at('rssi').inner_text})"
+when 2
+ puts " Ethernet"
+end

0 comments on commit 4d8024b

Please sign in to comment.