Created
March 5, 2011 05:38
-
-
Save hh/856157 to your computer and use it in GitHub Desktop.
This snippit allows me to look at the signal strength of the cell towers used by my ZTE usb modem.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# quick hack to monitor signal strength | |
# based on info from: http://www.pcurtis.com/ubuntu-mobile.htm#signal_strength | |
require 'rubygems' | |
require 'serialport' | |
require 'time' | |
class GSM | |
def initialize(options = {}) | |
@port = SerialPort.new(options[:port] || 3, options[:baud] || 38400, options[:bits] || 8, options[:stop] || 1, SerialPort::NONE) | |
@debug = options[:debug] | |
cmd("AT") | |
end | |
def close | |
@port.close | |
end | |
def cmd(cmd) | |
@port.write(cmd + "\r") | |
wait | |
end | |
def wait | |
buffer = '' | |
while IO.select([@port], [], [], 0.25) | |
chr = @port.getc.chr; | |
print chr if @debug == true | |
buffer += chr | |
end | |
buffer | |
end | |
end | |
gsm = GSM.new(:debug => false, :port => '/dev/tty.ZTEUSBATPort_') | |
while true | |
csq = gsm.cmd("AT+CSQ") | |
# RSSI (Received Signal Strength Indicator) | |
# 0 = 113 dBm or less | |
# 1 = 111 dBm | |
# 2 to 30 = 109 to 53 dBm | |
# 31 = 51 dBm or greater | |
# In practice, if the signal strength is below 10 then GPRS connections | |
# are unreliable. Values around 15 are good, 25 is excellent. | |
# mine hover between 9 and 12 in the Oropi | |
puts csq.scan(/\+CSQ\:\s*?(\d+),/) | |
gsm.wait() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Get's as low as 4, and often at 7 I'm still connected.... however the quality is poor.