aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Baverstock <weasel@google.com>2010-12-15 17:31:13 +0000
committerTim Baverstock <weasel@google.com>2010-12-15 17:38:20 +0000
commit4c6b10a4f385c04dbd7226e10a86a1f5cbd34f2a (patch)
treee73efe5f81db32825b318da31cb211926ee95a7c
parent09425494d2b9cce6a6c5725bbc320ca1a1440ad3 (diff)
downloadexternal_qemu-4c6b10a4f385c04dbd7226e10a86a1f5cbd34f2a.zip
external_qemu-4c6b10a4f385c04dbd7226e10a86a1f5cbd34f2a.tar.gz
external_qemu-4c6b10a4f385c04dbd7226e10a86a1f5cbd34f2a.tar.bz2
Add 'gsm signal' command, to set rssi and ber
Change-Id: I24d4738f6e5135437af25d22e2fa68617f5632fa
-rw-r--r--android/console.c65
-rw-r--r--telephony/android_modem.c20
-rw-r--r--telephony/android_modem.h3
3 files changed, 86 insertions, 2 deletions
diff --git a/android/console.c b/android/console.c
index 5e37060..68b9480 100644
--- a/android/console.c
+++ b/android/console.c
@@ -1385,6 +1385,65 @@ do_gsm_accept( ControlClient client, char* args )
return 0;
}
+static int
+do_gsm_signal( ControlClient client, char* args )
+{
+ enum { SIGNAL_RSSI = 0, SIGNAL_BER, NUM_SIGNAL_PARAMS };
+ char* p = args;
+ int top_param = -1;
+ int params[ NUM_SIGNAL_PARAMS ];
+
+ static int last_ber = 99;
+
+ if (!p)
+ p = "";
+
+ /* tokenize */
+ while (*p) {
+ char* end;
+ int val = strtol( p, &end, 10 );
+
+ if (end == p) {
+ control_write( client, "KO: argument '%s' is not a number\n", p );
+ return -1;
+ }
+
+ params[++top_param] = val;
+ if (top_param + 1 == NUM_SIGNAL_PARAMS)
+ break;
+
+ p = end;
+ while (*p && (p[0] == ' ' || p[0] == '\t'))
+ p += 1;
+ }
+
+ /* sanity check */
+ if (top_param < SIGNAL_RSSI) {
+ control_write( client, "KO: not enough arguments: see 'help gsm signal' for details\r\n" );
+ return -1;
+ }
+
+ int rssi = params[SIGNAL_RSSI];
+ if ((rssi < 0 || rssi > 31) && rssi != 99) {
+ control_write( client, "KO: invalid RSSI - must be 0..31 or 99\r\n");
+ return -1;
+ }
+
+ /* check ber is 0..7 or 99 */
+ if (top_param >= SIGNAL_BER) {
+ int ber = params[SIGNAL_BER];
+ if ((ber < 0 || ber > 7) && ber != 99) {
+ control_write( client, "KO: invalid BER - must be 0..7 or 99\r\n");
+ return -1;
+ }
+ last_ber = ber;
+ }
+
+ amodem_set_signal_strength( android_modem, rssi, last_ber );
+
+ return 0;
+ }
+
#if 0
static const CommandDefRec gsm_in_commands[] =
@@ -1458,6 +1517,12 @@ static const CommandDefRec gsm_commands[] =
"'gsm status' displays the current state of the GSM emulation\r\n", NULL,
do_gsm_status, NULL },
+ { "signal", "set sets the rssi and ber",
+ "'gsm signal <rssi> [<ber>]' changes the reported strength and error rate on next (15s) update.\r\n"
+ "rssi range is 0..31 and 99 for unknown\r\n"
+ "ber range is 0..7 percent and 99 for unknown\r\n",
+ NULL, do_gsm_signal, NULL },
+
{ NULL, NULL, NULL, NULL, NULL, NULL }
};
diff --git a/telephony/android_modem.c b/telephony/android_modem.c
index 009b5af..dd9f78d 100644
--- a/telephony/android_modem.c
+++ b/telephony/android_modem.c
@@ -235,6 +235,9 @@ typedef struct AModemRec_
int cell_id;
int base_port;
+ int rssi;
+ int ber;
+
/* SMS */
int wait_sms;
@@ -465,6 +468,9 @@ amodem_reset( AModem modem )
modem->radio_state = A_RADIO_STATE_OFF;
modem->wait_sms = 0;
+ modem->rssi= 7; // Two signal strength bars
+ modem->ber = 99; // Means 'unknown'
+
modem->oper_name_index = amodem_nvram_get_int(modem, NV_OPER_NAME_INDEX, 2);
modem->oper_selection_mode = amodem_nvram_get_int(modem, NV_SELECTION_MODE, A_SELECTION_AUTOMATIC);
modem->oper_index = amodem_nvram_get_int(modem, NV_OPER_INDEX, 0);
@@ -877,6 +883,12 @@ amodem_find_call_by_number( AModem modem, const char* number )
return NULL;
}
+void
+amodem_set_signal_strength( AModem modem, int rssi, int ber )
+{
+ modem->rssi = rssi;
+ modem->ber = ber;
+}
static void
acall_set_state( AVoiceCall call, ACallState state )
@@ -2135,7 +2147,6 @@ int android_snapshot_update_time_request = 0;
static const char*
handleSignalStrength( const char* cmd, AModem modem )
{
- /* XXX: TODO: implement variable signal strength and error rates */
amodem_begin_line( modem );
#if CONFIG_ANDROID_SNAPSHOTS
/* Sneak time updates into the SignalStrength request, because it's periodic.
@@ -2149,7 +2160,12 @@ handleSignalStrength( const char* cmd, AModem modem )
#endif
// rssi = 0 (<-113dBm) 1 (<-111) 2-30 (<-109--53) 31 (>=-51) 99 (?!)
// ber (bit error rate) - always 99 (unknown), apparently.
- amodem_add_line( modem, "+CSQ: %i,99\r\n", 27 );
+ // TODO: return 99 if modem->radio_state==A_RADIO_STATE_OFF, once radio_state is in snapshot.
+ int rssi = modem->rssi;
+ int ber = modem->ber;
+ rssi = (0 > rssi && rssi > 31) ? 99 : rssi ;
+ ber = (0 > ber && ber > 7 ) ? 99 : ber;
+ amodem_add_line( modem, "+CSQ: %i,%i\r\n", rssi, ber );
return amodem_end_line( modem );
}
diff --git a/telephony/android_modem.h b/telephony/android_modem.h
index 4409a7d..cbe8f46 100644
--- a/telephony/android_modem.h
+++ b/telephony/android_modem.h
@@ -42,6 +42,9 @@ typedef enum {
extern ARadioState amodem_get_radio_state( AModem modem );
extern void amodem_set_radio_state( AModem modem, ARadioState state );
+/* Set the received signal strength indicator and bit error rate */
+extern void amodem_set_signal_strength( AModem modem, int rssi, int ber );
+
/** SIM CARD STATUS
**/
extern ASimCard amodem_get_sim( AModem modem );