Skip to content

Instantly share code, notes, and snippets.

Created May 12, 2012 10:17
Show Gist options
  • Select an option

  • Save anonymous/2665662 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/2665662 to your computer and use it in GitHub Desktop.
huawei_status.pl
#!/usr/bin/perl
local @modes = ("No service", "AMPS", "CDMA", "GPRS", "HDR", "WCDMA");
local @submodes = ("No service", "GSM", "GPRS", "EDGE", "WCDMA", "HSDPA", "HSUPA", "HSDPA+HSUPA");
local $mode, $submode, $rssi;
open MODEM, "</dev/ttyUSB2";
while (<MODEM>) {
# print;
if (/^\^MODE:(\d),(\d)/) {
$mode = @modes[$1];
$submode = @submodes[$2];
}
if (/^\^RSSI:(.*)$/) {
if ($1 == 0) {
$rssi = "< -113 dBm";
}
elsif ($1 == 31) {
$rssi = "≥ -51 dBm";
}
elsif ($1 == 99) {
$rssi = "Unknown";
}
else {
$rssi = int(-111 + 53 * ($1-2)/28) . " dBm";
}
}
print "$rssi, $submode\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment