modem-helpers: provide list of scanned networks in a list of structs
We provide the result of the +COPS=? parsing in a GList of MM3gppNetworkInfo structures. We avoid the previous hash table, or using a dictionary, as a list of structs with a predefined set of elements, which should be easier for plugins wanting to make their own version
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
|
||||
#include <ModemManager.h>
|
||||
#include <mm-errors-types.h>
|
||||
#include <mm-enums-types.h>
|
||||
|
||||
#include "mm-modem-helpers.h"
|
||||
#include "mm-log.h"
|
||||
@@ -46,10 +47,20 @@ mm_strip_tag (const char *str, const char *cmd)
|
||||
/*************************************************************************/
|
||||
|
||||
static void
|
||||
save_scan_value (GHashTable *hash, const char *key, GMatchInfo *info, guint32 num)
|
||||
mm_3gpp_network_info_free (MM3gppNetworkInfo *info)
|
||||
{
|
||||
char *quoted;
|
||||
size_t len;
|
||||
g_free (info->operator_long);
|
||||
g_free (info->operator_short);
|
||||
g_free (info->operator_code);
|
||||
g_free (info);
|
||||
}
|
||||
|
||||
void
|
||||
mm_3gpp_network_info_list_free (GList *info_list)
|
||||
{
|
||||
g_list_foreach (info_list, (GFunc)mm_3gpp_network_info_free, NULL);
|
||||
g_list_free (info_list);
|
||||
}
|
||||
|
||||
static MMModemAccessTech
|
||||
get_mm_access_tech_from_etsi_access_tech (guint act)
|
||||
@@ -77,11 +88,15 @@ get_mm_access_tech_from_etsi_access_tech (guint act)
|
||||
}
|
||||
}
|
||||
|
||||
g_return_if_fail (info != NULL);
|
||||
static gchar *
|
||||
get_unquoted_scan_value (GMatchInfo *info, guint32 num)
|
||||
{
|
||||
gchar *quoted;
|
||||
gsize len;
|
||||
|
||||
quoted = g_match_info_fetch (info, num);
|
||||
if (!quoted)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
len = strlen (quoted);
|
||||
|
||||
@@ -94,24 +109,53 @@ get_mm_access_tech_from_etsi_access_tech (guint act)
|
||||
|
||||
if (!strlen (quoted)) {
|
||||
g_free (quoted);
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
g_hash_table_insert (hash, g_strdup (key), quoted);
|
||||
return quoted;
|
||||
}
|
||||
|
||||
/* If the response was successfully parsed (even if no valid entries were
|
||||
* found) the pointer array will be returned.
|
||||
*/
|
||||
GPtrArray *
|
||||
mm_gsm_parse_scan_response (const char *reply, GError **error)
|
||||
static MMModem3gppNetworkAvailability
|
||||
parse_network_status (const gchar *str)
|
||||
{
|
||||
/* Expecting a value between '0' and '3' inclusive */
|
||||
if (!str ||
|
||||
strlen (str) != 1 ||
|
||||
str[0] < '0' ||
|
||||
str[0] > '3') {
|
||||
mm_warn ("Cannot parse network status: '%s'", str);
|
||||
return MM_MODEM_3GPP_NETWORK_AVAILABILITY_UNKNOWN;
|
||||
}
|
||||
|
||||
return (MMModem3gppNetworkAvailability) (str[0] - '0');
|
||||
}
|
||||
|
||||
static MMModemAccessTech
|
||||
parse_access_tech (const gchar *str)
|
||||
{
|
||||
/* Recognized access technologies are between '0' and '7' inclusive... */
|
||||
if (!str ||
|
||||
strlen (str) != 1 ||
|
||||
str[0] < '0' ||
|
||||
str[0] > '7') {
|
||||
mm_warn ("Cannot parse access tech: '%s'", str);
|
||||
return MM_MODEM_ACCESS_TECH_UNKNOWN;
|
||||
}
|
||||
|
||||
return get_mm_access_tech_from_etsi_access_tech (str[0] - '0');
|
||||
}
|
||||
|
||||
GList *
|
||||
mm_3gpp_parse_scan_response (const gchar *reply,
|
||||
GError **error)
|
||||
{
|
||||
/* Got valid reply */
|
||||
GPtrArray *results = NULL;
|
||||
GRegex *r;
|
||||
GList *info_list = NULL;
|
||||
GMatchInfo *match_info;
|
||||
GError *err = NULL;
|
||||
gboolean umts_format = TRUE;
|
||||
GEnumClass *network_availability_class;
|
||||
GEnumClass *access_tech_class;
|
||||
GError *inner_error = NULL;
|
||||
|
||||
g_return_val_if_fail (reply != NULL, NULL);
|
||||
if (error)
|
||||
@@ -140,13 +184,13 @@ mm_gsm_parse_scan_response (const char *reply, GError **error)
|
||||
* +COPS: (2,"","T-Mobile","31026",0),(1,"AT&T","AT&T","310410"),0)
|
||||
*/
|
||||
|
||||
r = g_regex_new ("\\((\\d),([^,\\)]*),([^,\\)]*),([^,\\)]*)[\\)]?,(\\d)\\)", G_REGEX_UNGREEDY, 0, &err);
|
||||
if (err) {
|
||||
mm_err ("Invalid regular expression: %s", err->message);
|
||||
g_error_free (err);
|
||||
r = g_regex_new ("\\((\\d),([^,\\)]*),([^,\\)]*),([^,\\)]*)[\\)]?,(\\d)\\)", G_REGEX_UNGREEDY, 0, &inner_error);
|
||||
if (inner_error) {
|
||||
mm_err ("Invalid regular expression: %s", inner_error->message);
|
||||
g_error_free (inner_error);
|
||||
g_set_error_literal (error,
|
||||
MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
|
||||
"Could not parse scan results.");
|
||||
"Could not parse scan results");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -169,13 +213,13 @@ mm_gsm_parse_scan_response (const char *reply, GError **error)
|
||||
* +COPS: (2,"T - Mobile",,"31026"),(1,"Einstein PCS",,"31064"),(1,"Cingular",,"31041"),,(0,1,3),(0,2)
|
||||
*/
|
||||
|
||||
r = g_regex_new ("\\((\\d),([^,\\)]*),([^,\\)]*),([^\\)]*)\\)", G_REGEX_UNGREEDY, 0, &err);
|
||||
if (err) {
|
||||
mm_err ("Invalid regular expression: %s", err->message);
|
||||
g_error_free (err);
|
||||
r = g_regex_new ("\\((\\d),([^,\\)]*),([^,\\)]*),([^\\)]*)\\)", G_REGEX_UNGREEDY, 0, &inner_error);
|
||||
if (inner_error) {
|
||||
mm_err ("Invalid regular expression: %s", inner_error->message);
|
||||
g_error_free (inner_error);
|
||||
g_set_error_literal (error,
|
||||
MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
|
||||
"Could not parse scan results.");
|
||||
"Could not parse scan results");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -183,39 +227,43 @@ mm_gsm_parse_scan_response (const char *reply, GError **error)
|
||||
umts_format = FALSE;
|
||||
}
|
||||
|
||||
network_availability_class = G_ENUM_CLASS (g_type_class_ref (MM_TYPE_MODEM_3GPP_NETWORK_AVAILABILITY));
|
||||
access_tech_class = G_ENUM_CLASS (g_type_class_ref (MM_TYPE_MODEM_ACCESS_TECH));
|
||||
|
||||
/* Parse the results */
|
||||
results = g_ptr_array_new ();
|
||||
while (g_match_info_matches (match_info)) {
|
||||
GHashTable *hash;
|
||||
char *access_tech = NULL;
|
||||
const char *tmp;
|
||||
MM3gppNetworkInfo *info;
|
||||
gchar *tmp;
|
||||
gboolean valid = FALSE;
|
||||
|
||||
hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
||||
info = g_new0 (MM3gppNetworkInfo, 1);
|
||||
|
||||
save_scan_value (hash, MM_SCAN_TAG_STATUS, match_info, 1);
|
||||
save_scan_value (hash, MM_SCAN_TAG_OPER_LONG, match_info, 2);
|
||||
save_scan_value (hash, MM_SCAN_TAG_OPER_SHORT, match_info, 3);
|
||||
save_scan_value (hash, MM_SCAN_TAG_OPER_NUM, match_info, 4);
|
||||
tmp = get_unquoted_scan_value (match_info, 1);
|
||||
info->status = parse_network_status (tmp);
|
||||
g_free (tmp);
|
||||
|
||||
/* Only try for access technology with UMTS-format matches */
|
||||
if (umts_format)
|
||||
access_tech = g_match_info_fetch (match_info, 5);
|
||||
if (access_tech && (strlen (access_tech) == 1)) {
|
||||
/* Recognized access technologies are between '0' and '6' inclusive... */
|
||||
if ((access_tech[0] >= '0') && (access_tech[0] <= '6'))
|
||||
g_hash_table_insert (hash, g_strdup (MM_SCAN_TAG_ACCESS_TECH), access_tech);
|
||||
} else
|
||||
g_free (access_tech);
|
||||
info->operator_long = get_unquoted_scan_value (match_info, 2);
|
||||
info->operator_short = get_unquoted_scan_value (match_info, 3);
|
||||
info->operator_code = get_unquoted_scan_value (match_info, 4);
|
||||
|
||||
/* Only try for access technology with UMTS-format matches.
|
||||
* If none give, assume GSM */
|
||||
tmp = (umts_format ?
|
||||
get_unquoted_scan_value (match_info, 5) :
|
||||
NULL);
|
||||
info->access_tech = (tmp ?
|
||||
parse_access_tech (tmp) :
|
||||
MM_MODEM_ACCESS_TECH_GSM);
|
||||
g_free (tmp);
|
||||
|
||||
/* If the operator number isn't valid (ie, at least 5 digits),
|
||||
* ignore the scan result; it's probably the parameter stuff at the
|
||||
* end of the +COPS response. The regex will sometimes catch this
|
||||
* but there's no good way to ignore it.
|
||||
*/
|
||||
tmp = g_hash_table_lookup (hash, MM_SCAN_TAG_OPER_NUM);
|
||||
if (tmp && (strlen (tmp) >= 5)) {
|
||||
if (info->operator_code && (strlen (info->operator_code) >= 5)) {
|
||||
valid = TRUE;
|
||||
tmp = info->operator_code;
|
||||
while (*tmp) {
|
||||
if (!isdigit (*tmp) && (*tmp != '-')) {
|
||||
valid = FALSE;
|
||||
@@ -223,13 +271,28 @@ mm_gsm_parse_scan_response (const char *reply, GError **error)
|
||||
}
|
||||
tmp++;
|
||||
}
|
||||
|
||||
if (valid)
|
||||
g_ptr_array_add (results, hash);
|
||||
}
|
||||
|
||||
if (!valid)
|
||||
g_hash_table_destroy (hash);
|
||||
if (valid) {
|
||||
GEnumValue *network_availability;
|
||||
GEnumValue *access_tech;
|
||||
|
||||
network_availability = g_enum_get_value (network_availability_class,
|
||||
info->status);
|
||||
access_tech = g_enum_get_value (access_tech_class,
|
||||
info->access_tech);
|
||||
|
||||
mm_dbg ("Found network '%s' ('%s','%s'); availability: %s, access tech: %s",
|
||||
info->operator_code,
|
||||
info->operator_short ? info->operator_short : "no short name",
|
||||
info->operator_long ? info->operator_long : "no long name",
|
||||
network_availability->value_nick,
|
||||
access_tech->value_nick);
|
||||
|
||||
info_list = g_list_prepend (info_list, info);
|
||||
}
|
||||
else
|
||||
mm_3gpp_network_info_free (info);
|
||||
|
||||
g_match_info_next (match_info, NULL);
|
||||
}
|
||||
@@ -237,16 +300,10 @@ mm_gsm_parse_scan_response (const char *reply, GError **error)
|
||||
g_match_info_free (match_info);
|
||||
g_regex_unref (r);
|
||||
|
||||
return results;
|
||||
}
|
||||
g_type_class_unref (network_availability_class);
|
||||
g_type_class_unref (access_tech_class);
|
||||
|
||||
void
|
||||
mm_gsm_destroy_scan_data (gpointer data)
|
||||
{
|
||||
GPtrArray *results = (GPtrArray *) data;
|
||||
|
||||
g_ptr_array_foreach (results, (GFunc) g_hash_table_destroy, NULL);
|
||||
g_ptr_array_free (results, TRUE);
|
||||
return info_list;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
@@ -22,15 +22,19 @@
|
||||
#include "mm-modem-cdma.h"
|
||||
#include "mm-charsets.h"
|
||||
|
||||
#define MM_SCAN_TAG_STATUS "status"
|
||||
#define MM_SCAN_TAG_OPER_LONG "operator-long"
|
||||
#define MM_SCAN_TAG_OPER_SHORT "operator-short"
|
||||
#define MM_SCAN_TAG_OPER_NUM "operator-num"
|
||||
#define MM_SCAN_TAG_ACCESS_TECH "access-tech"
|
||||
/* Network scan results expected */
|
||||
typedef struct {
|
||||
MMModem3gppNetworkAvailability status;
|
||||
gchar *operator_long;
|
||||
gchar *operator_short;
|
||||
gchar *operator_code; /* mandatory */
|
||||
MMModemAccessTech access_tech;
|
||||
} MM3gppNetworkInfo;
|
||||
|
||||
GPtrArray *mm_gsm_parse_scan_response (const char *reply, GError **error);
|
||||
void mm_3gpp_network_info_list_free (GList *info_list);
|
||||
|
||||
void mm_gsm_destroy_scan_data (gpointer data);
|
||||
GList *mm_3gpp_parse_scan_response (const gchar *reply,
|
||||
GError **error);
|
||||
|
||||
GPtrArray *mm_gsm_creg_regex_get (gboolean solicited);
|
||||
|
||||
|
@@ -24,394 +24,373 @@ typedef struct {
|
||||
GPtrArray *unsolicited_creg;
|
||||
} TestData;
|
||||
|
||||
#define MM_SCAN_TAG_STATUS "status"
|
||||
#define MM_SCAN_TAG_OPER_LONG "operator-long"
|
||||
#define MM_SCAN_TAG_OPER_SHORT "operator-short"
|
||||
#define MM_SCAN_TAG_OPER_NUM "operator-num"
|
||||
#define MM_SCAN_TAG_ACCESS_TECH "access-tech"
|
||||
|
||||
typedef struct {
|
||||
const char *status;
|
||||
const char *oper_long;
|
||||
const char *oper_short;
|
||||
const char *oper_num;
|
||||
const char *tech;
|
||||
} OperEntry;
|
||||
|
||||
#define ARRAY_LEN(i) (sizeof (i) / sizeof (i[0]))
|
||||
|
||||
static void
|
||||
test_cops_results (const char *desc,
|
||||
const char *reply,
|
||||
OperEntry *expected_results,
|
||||
test_cops_results (const gchar *desc,
|
||||
const gchar *reply,
|
||||
MM3gppNetworkInfo *expected_results,
|
||||
guint32 expected_results_len)
|
||||
{
|
||||
guint i;
|
||||
GList *l;
|
||||
GError *error = NULL;
|
||||
GPtrArray *results;
|
||||
GList *results;
|
||||
|
||||
g_print ("\nTesting %s +COPS response...\n", desc);
|
||||
|
||||
results = mm_gsm_parse_scan_response (reply, &error);
|
||||
results = mm_3gpp_parse_scan_response (reply, &error);
|
||||
g_assert (results);
|
||||
g_assert (error == NULL);
|
||||
g_assert_no_error (error);
|
||||
g_assert_cmpuint (g_list_length (results), ==, expected_results_len);
|
||||
|
||||
g_assert (results->len == expected_results_len);
|
||||
for (l = results; l; l = g_list_next (l)) {
|
||||
MM3gppNetworkInfo *info = l->data;
|
||||
gboolean found = FALSE;
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < results->len; i++) {
|
||||
GHashTable *entry = g_ptr_array_index (results, i);
|
||||
const char *value;
|
||||
OperEntry *expected = &expected_results[i];
|
||||
for (i = 0; !found && i < expected_results_len; i++) {
|
||||
MM3gppNetworkInfo *expected;
|
||||
|
||||
value = g_hash_table_lookup (entry, MM_SCAN_TAG_STATUS);
|
||||
g_assert (value);
|
||||
g_assert (strcmp (value, expected->status) == 0);
|
||||
expected = &expected_results[i];
|
||||
if (g_str_equal (info->operator_code, expected->operator_code) &&
|
||||
info->access_tech == expected->access_tech) {
|
||||
found = TRUE;
|
||||
|
||||
value = g_hash_table_lookup (entry, MM_SCAN_TAG_OPER_LONG);
|
||||
if (expected->oper_long) {
|
||||
g_assert (value);
|
||||
g_assert (strcmp (value, expected->oper_long) == 0);
|
||||
} else
|
||||
g_assert (value == NULL);
|
||||
g_assert_cmpuint (info->status, ==, expected->status);
|
||||
|
||||
value = g_hash_table_lookup (entry, MM_SCAN_TAG_OPER_SHORT);
|
||||
if (expected->oper_short) {
|
||||
g_assert (value);
|
||||
g_assert (strcmp (value, expected->oper_short) == 0);
|
||||
} else
|
||||
g_assert (value == NULL);
|
||||
if (expected->operator_long)
|
||||
g_assert_cmpstr (info->operator_long, ==, expected->operator_long);
|
||||
else
|
||||
g_assert (info->operator_long == NULL);
|
||||
|
||||
value = g_hash_table_lookup (entry, MM_SCAN_TAG_OPER_NUM);
|
||||
g_assert (expected->oper_num);
|
||||
g_assert (value);
|
||||
g_assert (strcmp (value, expected->oper_num) == 0);
|
||||
if (expected->operator_short)
|
||||
g_assert_cmpstr (info->operator_short, ==, expected->operator_short);
|
||||
else
|
||||
g_assert (info->operator_short == NULL);
|
||||
|
||||
value = g_hash_table_lookup (entry, MM_SCAN_TAG_ACCESS_TECH);
|
||||
if (expected->tech) {
|
||||
g_assert (value);
|
||||
g_assert (strcmp (value, expected->tech) == 0);
|
||||
} else
|
||||
g_assert (value == NULL);
|
||||
g_debug ("info: %s, expected: %s", info->operator_code, expected->operator_code);
|
||||
}
|
||||
}
|
||||
|
||||
mm_gsm_destroy_scan_data (results);
|
||||
g_assert (found == TRUE);
|
||||
}
|
||||
|
||||
mm_3gpp_network_info_list_free (results);
|
||||
}
|
||||
|
||||
static void
|
||||
test_cops_response_tm506 (void *f, gpointer d)
|
||||
{
|
||||
const char *reply = "+COPS: (2,\"\",\"T-Mobile\",\"31026\",0),(2,\"T - Mobile\",\"T - Mobile\",\"310260\"),2),(1,\"AT&T\",\"AT&T\",\"310410\"),0)";
|
||||
static OperEntry expected[] = {
|
||||
{ "2", NULL, "T-Mobile", "31026", "0" },
|
||||
{ "2", "T - Mobile", "T - Mobile", "310260", "2" },
|
||||
{ "1", "AT&T", "AT&T", "310410", "0" }
|
||||
const gchar *reply = "+COPS: (2,\"\",\"T-Mobile\",\"31026\",0),(2,\"T - Mobile\",\"T - Mobile\",\"310260\"),2),(1,\"AT&T\",\"AT&T\",\"310410\"),0)";
|
||||
static MM3gppNetworkInfo expected[] = {
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_CURRENT, NULL, "T-Mobile", "31026", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_CURRENT, "T - Mobile", "T - Mobile", "310260", MM_MODEM_ACCESS_TECH_UMTS },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "AT&T", "AT&T", "310410", MM_MODEM_ACCESS_TECH_GSM }
|
||||
};
|
||||
|
||||
test_cops_results ("TM-506", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("TM-506", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
test_cops_response_gt3gplus (void *f, gpointer d)
|
||||
{
|
||||
const char *reply = "+COPS: (1,\"T-Mobile US\",\"TMO US\",\"31026\",0),(1,\"Cingular\",\"Cingular\",\"310410\",0),,(0, 1, 3),(0-2)";
|
||||
static OperEntry expected[] = {
|
||||
{ "1", "T-Mobile US", "TMO US", "31026", "0" },
|
||||
{ "1", "Cingular", "Cingular", "310410", "0" },
|
||||
static MM3gppNetworkInfo expected[] = {
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "T-Mobile US", "TMO US", "31026", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "Cingular", "Cingular", "310410", MM_MODEM_ACCESS_TECH_GSM },
|
||||
};
|
||||
|
||||
test_cops_results ("GlobeTrotter 3G+ (nozomi)", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("GlobeTrotter 3G+ (nozomi)", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
test_cops_response_ac881 (void *f, gpointer d)
|
||||
{
|
||||
const char *reply = "+COPS: (1,\"T-Mobile\",\"TMO\",\"31026\",0),(1,\"AT&T\",\"AT&T\",\"310410\",2),(1,\"AT&T\",\"AT&T\",\"310410\",0),,(0,1,2,3,4),)";
|
||||
static OperEntry expected[] = {
|
||||
{ "1", "T-Mobile", "TMO", "31026", "0" },
|
||||
{ "1", "AT&T", "AT&T", "310410", "2" },
|
||||
{ "1", "AT&T", "AT&T", "310410", "0" },
|
||||
static MM3gppNetworkInfo expected[] = {
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "T-Mobile", "TMO", "31026", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "AT&T", "AT&T", "310410", MM_MODEM_ACCESS_TECH_UMTS },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "AT&T", "AT&T", "310410", MM_MODEM_ACCESS_TECH_GSM },
|
||||
};
|
||||
|
||||
test_cops_results ("Sierra AirCard 881", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Sierra AirCard 881", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
test_cops_response_gtmax36 (void *f, gpointer d)
|
||||
{
|
||||
const char *reply = "+COPS: (2,\"T-Mobile US\",\"TMO US\",\"31026\",0),(1,\"AT&T\",\"AT&T\",\"310410\",2),(1,\"AT&T\",\"AT&T\",\"310410\",0),,(0, 1,)";
|
||||
static OperEntry expected[] = {
|
||||
{ "2", "T-Mobile US", "TMO US", "31026", "0" },
|
||||
{ "1", "AT&T", "AT&T", "310410", "2" },
|
||||
{ "1", "AT&T", "AT&T", "310410", "0" },
|
||||
static MM3gppNetworkInfo expected[] = {
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_CURRENT, "T-Mobile US", "TMO US", "31026", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "AT&T", "AT&T", "310410", MM_MODEM_ACCESS_TECH_UMTS },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "AT&T", "AT&T", "310410", MM_MODEM_ACCESS_TECH_GSM },
|
||||
};
|
||||
|
||||
test_cops_results ("Option GlobeTrotter MAX 3.6", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Option GlobeTrotter MAX 3.6", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
test_cops_response_ac860 (void *f, gpointer d)
|
||||
{
|
||||
const char *reply = "+COPS: (2,\"T-Mobile\",\"TMO\",\"31026\",0),(1,\"Cingular\",\"Cinglr\",\"310410\",2),(1,\"Cingular\",\"Cinglr\",\"310410\",0),,)";
|
||||
static OperEntry expected[] = {
|
||||
{ "2", "T-Mobile", "TMO", "31026", "0" },
|
||||
{ "1", "Cingular", "Cinglr", "310410", "2" },
|
||||
{ "1", "Cingular", "Cinglr", "310410", "0" },
|
||||
static MM3gppNetworkInfo expected[] = {
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_CURRENT, "T-Mobile", "TMO", "31026", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "Cingular", "Cinglr", "310410", MM_MODEM_ACCESS_TECH_UMTS },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "Cingular", "Cinglr", "310410", MM_MODEM_ACCESS_TECH_GSM },
|
||||
};
|
||||
|
||||
test_cops_results ("Sierra AirCard 860", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Sierra AirCard 860", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
test_cops_response_gtm378 (void *f, gpointer d)
|
||||
{
|
||||
const char *reply = "+COPS: (2,\"T-Mobile\",\"T-Mobile\",\"31026\",0),(1,\"AT&T\",\"AT&T\",\"310410\",2),(1,\"AT&T\",\"AT&T\",\"310410\",0),,(0, 1, 3),(0-2)";
|
||||
static OperEntry expected[] = {
|
||||
{ "2", "T-Mobile", "T-Mobile", "31026", "0" },
|
||||
{ "1", "AT&T", "AT&T", "310410", "2" },
|
||||
{ "1", "AT&T", "AT&T", "310410", "0" },
|
||||
static MM3gppNetworkInfo expected[] = {
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_CURRENT, "T-Mobile", "T-Mobile", "31026", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "AT&T", "AT&T", "310410", MM_MODEM_ACCESS_TECH_UMTS },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "AT&T", "AT&T", "310410", MM_MODEM_ACCESS_TECH_GSM },
|
||||
};
|
||||
|
||||
test_cops_results ("Option GTM378", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Option GTM378", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
test_cops_response_motoc (void *f, gpointer d)
|
||||
{
|
||||
const char *reply = "+COPS: (2,\"T-Mobile\",\"\",\"310260\"),(0,\"Cingular Wireless\",\"\",\"310410\")";
|
||||
static OperEntry expected[] = {
|
||||
{ "2", "T-Mobile", NULL, "310260", NULL },
|
||||
{ "0", "Cingular Wireless", NULL, "310410", NULL },
|
||||
static MM3gppNetworkInfo expected[] = {
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_CURRENT, "T-Mobile", NULL, "310260", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_UNKNOWN, "Cingular Wireless", NULL, "310410", MM_MODEM_ACCESS_TECH_GSM },
|
||||
};
|
||||
|
||||
test_cops_results ("BUSlink SCWi275u (Motorola C-series)", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("BUSlink SCWi275u (Motorola C-series)", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
test_cops_response_mf627a (void *f, gpointer d)
|
||||
{
|
||||
const char *reply = "+COPS: (2,\"AT&T@\",\"AT&TD\",\"310410\",0),(3,\"Voicestream Wireless Corporation\",\"VSTREAM\",\"31026\",0),";
|
||||
static OperEntry expected[] = {
|
||||
{ "2", "AT&T@", "AT&TD", "310410", "0" },
|
||||
{ "3", "Voicestream Wireless Corporation", "VSTREAM", "31026", "0" },
|
||||
static MM3gppNetworkInfo expected[] = {
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_CURRENT, "AT&T@", "AT&TD", "310410", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_FORBIDDEN, "Voicestream Wireless Corporation", "VSTREAM", "31026", MM_MODEM_ACCESS_TECH_GSM },
|
||||
};
|
||||
|
||||
test_cops_results ("ZTE MF627 (A)", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("ZTE MF627 (A)", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
test_cops_response_mf627b (void *f, gpointer d)
|
||||
{
|
||||
const char *reply = "+COPS: (2,\"AT&Tp\",\"AT&T@\",\"310410\",0),(3,\"\",\"\",\"31026\",0),";
|
||||
static OperEntry expected[] = {
|
||||
{ "2", "AT&Tp", "AT&T@", "310410", "0" },
|
||||
{ "3", NULL, NULL, "31026", "0" },
|
||||
static MM3gppNetworkInfo expected[] = {
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_CURRENT, "AT&Tp", "AT&T@", "310410", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_FORBIDDEN, NULL, NULL, "31026", MM_MODEM_ACCESS_TECH_GSM },
|
||||
};
|
||||
|
||||
test_cops_results ("ZTE MF627 (B)", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("ZTE MF627 (B)", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
test_cops_response_e160g (void *f, gpointer d)
|
||||
{
|
||||
const char *reply = "+COPS: (2,\"T-Mobile\",\"TMO\",\"31026\",0),(1,\"AT&T\",\"AT&T\",\"310410\",0),,(0,1,2,3,4),(0,1,2)";
|
||||
static OperEntry expected[] = {
|
||||
{ "2", "T-Mobile", "TMO", "31026", "0" },
|
||||
{ "1", "AT&T", "AT&T", "310410", "0" },
|
||||
static MM3gppNetworkInfo expected[] = {
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_CURRENT, "T-Mobile", "TMO", "31026", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "AT&T", "AT&T", "310410", MM_MODEM_ACCESS_TECH_GSM },
|
||||
};
|
||||
|
||||
test_cops_results ("Huawei E160G", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Huawei E160G", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
test_cops_response_mercury (void *f, gpointer d)
|
||||
{
|
||||
const char *reply = "+COPS: (2,\"\",\"\",\"310410\",2),(1,\"AT&T\",\"AT&T\",\"310410\",0),(1,\"T-Mobile\",\"TMO\",\"31026\",0),,(0,1,2,3,4),(0,1,2)";
|
||||
static OperEntry expected[] = {
|
||||
{ "2", NULL, NULL, "310410", "2" },
|
||||
{ "1", "AT&T", "AT&T", "310410", "0" },
|
||||
{ "1", "T-Mobile", "TMO", "31026", "0" },
|
||||
static MM3gppNetworkInfo expected[] = {
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_CURRENT, NULL, NULL, "310410", MM_MODEM_ACCESS_TECH_UMTS },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "AT&T", "AT&T", "310410", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "T-Mobile", "TMO", "31026", MM_MODEM_ACCESS_TECH_GSM },
|
||||
};
|
||||
|
||||
test_cops_results ("Sierra AT&T USBConnect Mercury", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Sierra AT&T USBConnect Mercury", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
test_cops_response_quicksilver (void *f, gpointer d)
|
||||
{
|
||||
const char *reply = "+COPS: (2,\"AT&T\",\"\",\"310410\",0),(2,\"\",\"\",\"3104100\",2),(1,\"AT&T\",\"\",\"310260\",0),,(0-4),(0-2)";
|
||||
static OperEntry expected[] = {
|
||||
{ "2", "AT&T", NULL, "310410", "0" },
|
||||
{ "2", NULL, NULL, "3104100", "2" },
|
||||
{ "1", "AT&T", NULL, "310260", "0" },
|
||||
static MM3gppNetworkInfo expected[] = {
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_CURRENT, "AT&T", NULL, "310410", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_CURRENT, NULL, NULL, "3104100", MM_MODEM_ACCESS_TECH_UMTS },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "AT&T", NULL, "310260", MM_MODEM_ACCESS_TECH_GSM },
|
||||
};
|
||||
|
||||
test_cops_results ("Option AT&T Quicksilver", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Option AT&T Quicksilver", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
test_cops_response_icon225 (void *f, gpointer d)
|
||||
{
|
||||
const char *reply = "+COPS: (2,\"T-Mobile US\",\"TMO US\",\"31026\",0),(1,\"AT&T\",\"AT&T\",\"310410\",0),,(0, 1, 3),(0-2)";
|
||||
static OperEntry expected[] = {
|
||||
{ "2", "T-Mobile US", "TMO US", "31026", "0" },
|
||||
{ "1", "AT&T", "AT&T", "310410", "0" },
|
||||
static MM3gppNetworkInfo expected[] = {
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_CURRENT, "T-Mobile US", "TMO US", "31026", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "AT&T", "AT&T", "310410", MM_MODEM_ACCESS_TECH_GSM },
|
||||
};
|
||||
|
||||
test_cops_results ("Option iCON 225", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Option iCON 225", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
test_cops_response_icon452 (void *f, gpointer d)
|
||||
{
|
||||
const char *reply = "+COPS: (1,\"T-Mobile US\",\"TMO US\",\"31026\",0),(2,\"T-Mobile\",\"T-Mobile\",\"310260\",2),(1,\"AT&T\",\"AT&T\",\"310410\",2),(1,\"AT&T\",\"AT&T\",\"310410\",0),,(0,1,2,3,4),(0,1,2)";
|
||||
static OperEntry expected[] = {
|
||||
{ "1", "T-Mobile US", "TMO US", "31026", "0" },
|
||||
{ "2", "T-Mobile", "T-Mobile", "310260", "2" },
|
||||
{ "1", "AT&T", "AT&T", "310410", "2" },
|
||||
{ "1", "AT&T", "AT&T", "310410", "0" }
|
||||
static MM3gppNetworkInfo expected[] = {
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "T-Mobile US", "TMO US", "31026", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_CURRENT, "T-Mobile", "T-Mobile", "310260", MM_MODEM_ACCESS_TECH_UMTS },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "AT&T", "AT&T", "310410", MM_MODEM_ACCESS_TECH_UMTS },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "AT&T", "AT&T", "310410", MM_MODEM_ACCESS_TECH_GSM }
|
||||
};
|
||||
|
||||
test_cops_results ("Option iCON 452", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Option iCON 452", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
test_cops_response_f3507g (void *f, gpointer d)
|
||||
{
|
||||
const char *reply = "+COPS: (2,\"T - Mobile\",\"T - Mobile\",\"31026\",0),(1,\"AT&T\",\"AT&T\",\"310410\",0),(1,\"AT&T\",\"AT&T\",\"310410\",2)";
|
||||
static OperEntry expected[] = {
|
||||
{ "2", "T - Mobile", "T - Mobile", "31026", "0" },
|
||||
{ "1", "AT&T", "AT&T", "310410", "0" },
|
||||
{ "1", "AT&T", "AT&T", "310410", "2" }
|
||||
static MM3gppNetworkInfo expected[] = {
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_CURRENT, "T - Mobile", "T - Mobile", "31026", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "AT&T", "AT&T", "310410", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "AT&T", "AT&T", "310410", MM_MODEM_ACCESS_TECH_UMTS }
|
||||
};
|
||||
|
||||
test_cops_results ("Ericsson F3507g", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Ericsson F3507g", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
test_cops_response_f3607gw (void *f, gpointer d)
|
||||
{
|
||||
const char *reply = "+COPS: (2,\"T - Mobile\",\"T - Mobile\",\"31026\",0),(1,\"AT&T\",\"AT&T\",\"310410\"),2),(1,\"AT&T\",\"AT&T\",\"310410\"),0)";
|
||||
static OperEntry expected[] = {
|
||||
{ "2", "T - Mobile", "T - Mobile", "31026", "0" },
|
||||
{ "1", "AT&T", "AT&T", "310410", "2" },
|
||||
{ "1", "AT&T", "AT&T", "310410", "0" }
|
||||
static MM3gppNetworkInfo expected[] = {
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_CURRENT, "T - Mobile", "T - Mobile", "31026", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "AT&T", "AT&T", "310410", MM_MODEM_ACCESS_TECH_UMTS },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "AT&T", "AT&T", "310410", MM_MODEM_ACCESS_TECH_GSM }
|
||||
};
|
||||
|
||||
test_cops_results ("Ericsson F3607gw", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Ericsson F3607gw", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
test_cops_response_mc8775 (void *f, gpointer d)
|
||||
{
|
||||
const char *reply = "+COPS: (2,\"T-Mobile\",\"T-Mobile\",\"31026\",0),(1,\"AT&T\",\"AT&T\",\"310410\",2),(1,\"AT&T\",\"AT&T\",\"310410\",0),,(0,1,2,3,4),(0,1,2)";
|
||||
static OperEntry expected[] = {
|
||||
{ "2", "T-Mobile", "T-Mobile", "31026", "0" },
|
||||
{ "1", "AT&T", "AT&T", "310410", "2" },
|
||||
{ "1", "AT&T", "AT&T", "310410", "0" }
|
||||
static MM3gppNetworkInfo expected[] = {
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_CURRENT, "T-Mobile", "T-Mobile", "31026", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "AT&T", "AT&T", "310410", MM_MODEM_ACCESS_TECH_UMTS },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "AT&T", "AT&T", "310410", MM_MODEM_ACCESS_TECH_GSM }
|
||||
};
|
||||
|
||||
test_cops_results ("Sierra MC8775", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Sierra MC8775", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
test_cops_response_n80 (void *f, gpointer d)
|
||||
{
|
||||
const char *reply = "+COPS: (2,\"T - Mobile\",,\"31026\"),(1,\"Einstein PCS\",,\"31064\"),(1,\"Cingular\",,\"31041\"),,(0,1,3),(0,2)";
|
||||
static OperEntry expected[] = {
|
||||
{ "2", "T - Mobile", NULL, "31026", NULL },
|
||||
{ "1", "Einstein PCS", NULL, "31064", NULL },
|
||||
{ "1", "Cingular", NULL, "31041", NULL },
|
||||
static MM3gppNetworkInfo expected[] = {
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_CURRENT, "T - Mobile", NULL, "31026", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "Einstein PCS", NULL, "31064", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "Cingular", NULL, "31041", MM_MODEM_ACCESS_TECH_GSM },
|
||||
};
|
||||
|
||||
test_cops_results ("Nokia N80", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Nokia N80", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
test_cops_response_e1550 (void *f, gpointer d)
|
||||
{
|
||||
const char *reply = "+COPS: (2,\"T-Mobile\",\"TMO\",\"31026\",0),(1,\"AT&T\",\"AT&T\",\"310410\",0),,(0,1,2,3,4),(0,1,2)";
|
||||
static OperEntry expected[] = {
|
||||
{ "2", "T-Mobile", "TMO", "31026", "0" },
|
||||
{ "1", "AT&T", "AT&T", "310410", "0" },
|
||||
static MM3gppNetworkInfo expected[] = {
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_CURRENT, "T-Mobile", "TMO", "31026", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "AT&T", "AT&T", "310410", MM_MODEM_ACCESS_TECH_GSM },
|
||||
};
|
||||
|
||||
test_cops_results ("Huawei E1550", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Huawei E1550", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
test_cops_response_mf622 (void *f, gpointer d)
|
||||
{
|
||||
const char *reply = "+COPS: (2,\"T-Mobile\",\"T-Mobile\",\"31026\",0),(1,\"\",\"\",\"310410\",0),";
|
||||
static OperEntry expected[] = {
|
||||
{ "2", "T-Mobile", "T-Mobile", "31026", "0" },
|
||||
{ "1", NULL, NULL, "310410", "0" },
|
||||
static MM3gppNetworkInfo expected[] = {
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_CURRENT, "T-Mobile", "T-Mobile", "31026", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, NULL, NULL, "310410", MM_MODEM_ACCESS_TECH_GSM },
|
||||
};
|
||||
|
||||
test_cops_results ("ZTE MF622", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("ZTE MF622", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
test_cops_response_e226 (void *f, gpointer d)
|
||||
{
|
||||
const char *reply = "+COPS: (1,\"\",\"\",\"31026\",0),(1,\"\",\"\",\"310410\",2),(1,\"\",\"\",\"310410\",0),,(0,1,3,4),(0,1,2)";
|
||||
static OperEntry expected[] = {
|
||||
{ "1", NULL, NULL, "31026", "0" },
|
||||
{ "1", NULL, NULL, "310410", "2" },
|
||||
{ "1", NULL, NULL, "310410", "0" },
|
||||
static MM3gppNetworkInfo expected[] = {
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, NULL, NULL, "31026", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, NULL, NULL, "310410", MM_MODEM_ACCESS_TECH_UMTS },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, NULL, NULL, "310410", MM_MODEM_ACCESS_TECH_GSM },
|
||||
};
|
||||
|
||||
test_cops_results ("Huawei E226", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Huawei E226", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
test_cops_response_xu870 (void *f, gpointer d)
|
||||
{
|
||||
const char *reply = "+COPS: (0,\"AT&T MicroCell\",\"AT&T MicroCell\",\"310410\",2)\r\n+COPS: (1,\"AT&T MicroCell\",\"AT&T MicroCell\",\"310410\",0)\r\n+COPS: (1,\"T-Mobile\",\"TMO\",\"31026\",0)\r\n";
|
||||
static OperEntry expected[] = {
|
||||
{ "0", "AT&T MicroCell", "AT&T MicroCell", "310410", "2" },
|
||||
{ "1", "AT&T MicroCell", "AT&T MicroCell", "310410", "0" },
|
||||
{ "1", "T-Mobile", "TMO", "31026", "0" },
|
||||
static MM3gppNetworkInfo expected[] = {
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_UNKNOWN, "AT&T MicroCell", "AT&T MicroCell", "310410", MM_MODEM_ACCESS_TECH_UMTS },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "AT&T MicroCell", "AT&T MicroCell", "310410", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "T-Mobile", "TMO", "31026", MM_MODEM_ACCESS_TECH_GSM },
|
||||
};
|
||||
|
||||
test_cops_results ("Novatel XU870", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Novatel XU870", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
test_cops_response_gtultraexpress (void *f, gpointer d)
|
||||
{
|
||||
const char *reply = "+COPS: (2,\"T-Mobile US\",\"TMO US\",\"31026\",0),(1,\"AT&T\",\"AT&T\",\"310410\",2),(1,\"AT&T\",\"AT&T\",\"310410\",0),,(0,1,2,3,4),(0,1,2)";
|
||||
static OperEntry expected[] = {
|
||||
{ "2", "T-Mobile US", "TMO US", "31026", "0" },
|
||||
{ "1", "AT&T", "AT&T", "310410", "2" },
|
||||
{ "1", "AT&T", "AT&T", "310410", "0" },
|
||||
static MM3gppNetworkInfo expected[] = {
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_CURRENT, "T-Mobile US", "TMO US", "31026", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "AT&T", "AT&T", "310410", MM_MODEM_ACCESS_TECH_UMTS },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "AT&T", "AT&T", "310410", MM_MODEM_ACCESS_TECH_GSM },
|
||||
};
|
||||
|
||||
test_cops_results ("Option GlobeTrotter Ultra Express", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Option GlobeTrotter Ultra Express", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
test_cops_response_n2720 (void *f, gpointer d)
|
||||
{
|
||||
const char *reply = "+COPS: (2,\"T - Mobile\",,\"31026\",0),\r\n(1,\"AT&T\",,\"310410\",0),,(0,1,3),(0,2)";
|
||||
static OperEntry expected[] = {
|
||||
{ "2", "T - Mobile", NULL, "31026", "0" },
|
||||
{ "1", "AT&T", NULL, "310410", "0" },
|
||||
static MM3gppNetworkInfo expected[] = {
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_CURRENT, "T - Mobile", NULL, "31026", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "AT&T", NULL, "310410", MM_MODEM_ACCESS_TECH_GSM },
|
||||
};
|
||||
|
||||
test_cops_results ("Nokia 2720", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Nokia 2720", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
test_cops_response_gobi (void *f, gpointer d)
|
||||
{
|
||||
const char *reply = "+COPS: (2,\"T-Mobile\",\"T-Mobile\",\"31026\",0),(1,\"AT&T\",\"AT&T\",\"310410\",2),(1,\"AT&T\",\"AT&T\",\"310410\",0),,(0,1,2,3,4),(0,1,2)";
|
||||
static OperEntry expected[] = {
|
||||
{ "2", "T-Mobile", "T-Mobile", "31026", "0" },
|
||||
{ "1", "AT&T", "AT&T", "310410", "2" },
|
||||
{ "1", "AT&T", "AT&T", "310410", "0" },
|
||||
static MM3gppNetworkInfo expected[] = {
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_CURRENT, "T-Mobile", "T-Mobile", "31026", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "AT&T", "AT&T", "310410", MM_MODEM_ACCESS_TECH_UMTS },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_AVAILABLE, "AT&T", "AT&T", "310410", MM_MODEM_ACCESS_TECH_GSM },
|
||||
};
|
||||
|
||||
test_cops_results ("Qualcomm Gobi", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Qualcomm Gobi", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -422,41 +401,41 @@ test_cops_response_sek600i (void *f, gpointer d)
|
||||
* which is which...
|
||||
*/
|
||||
const char *reply = "+COPS: (2,\"blau\",\"\",\"26203\"),(2,\"blau\",\"\",\"26203\"),(3,\"\",\"\",\"26201\"),(3,\"\",\"\",\"26202\"),(3,\"\",\"\",\"26207\"),(3,\"\",\"\",\"26201\"),(3,\"\",\"\",\"26207\")";
|
||||
static OperEntry expected[] = {
|
||||
{ "2", "blau", NULL, "26203", NULL },
|
||||
{ "2", "blau", NULL, "26203", NULL },
|
||||
{ "3", NULL, NULL, "26201", NULL },
|
||||
{ "3", NULL, NULL, "26202", NULL },
|
||||
{ "3", NULL, NULL, "26207", NULL },
|
||||
{ "3", NULL, NULL, "26201", NULL },
|
||||
{ "3", NULL, NULL, "26207", NULL },
|
||||
static MM3gppNetworkInfo expected[] = {
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_CURRENT, "blau", NULL, "26203", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_CURRENT, "blau", NULL, "26203", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_FORBIDDEN, NULL, NULL, "26201", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_FORBIDDEN, NULL, NULL, "26202", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_FORBIDDEN, NULL, NULL, "26207", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_FORBIDDEN, NULL, NULL, "26201", MM_MODEM_ACCESS_TECH_GSM },
|
||||
{ MM_MODEM_3GPP_NETWORK_AVAILABILITY_FORBIDDEN, NULL, NULL, "26207", MM_MODEM_ACCESS_TECH_GSM },
|
||||
};
|
||||
|
||||
test_cops_results ("Sony-Ericsson K600i", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Sony-Ericsson K600i", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
test_cops_response_gsm_invalid (void *f, gpointer d)
|
||||
{
|
||||
const char *reply = "+COPS: (0,1,2,3),(1,2,3,4)";
|
||||
GPtrArray *results;
|
||||
const gchar *reply = "+COPS: (0,1,2,3),(1,2,3,4)";
|
||||
GList *results;
|
||||
GError *error = NULL;
|
||||
|
||||
results = mm_gsm_parse_scan_response (reply, &error);
|
||||
g_assert (results != NULL);
|
||||
g_assert (error == NULL);
|
||||
results = mm_3gpp_parse_scan_response (reply, &error);
|
||||
g_assert (results == NULL);
|
||||
g_assert_no_error (error);
|
||||
}
|
||||
|
||||
static void
|
||||
test_cops_response_umts_invalid (void *f, gpointer d)
|
||||
{
|
||||
const char *reply = "+COPS: (0,1,2,3,4),(1,2,3,4,5)";
|
||||
GPtrArray *results;
|
||||
GList *results;
|
||||
GError *error = NULL;
|
||||
|
||||
results = mm_gsm_parse_scan_response (reply, &error);
|
||||
g_assert (results != NULL);
|
||||
g_assert (error == NULL);
|
||||
results = mm_3gpp_parse_scan_response (reply, &error);
|
||||
g_assert (results == NULL);
|
||||
g_assert_no_error (error);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
@@ -1178,7 +1157,7 @@ test_cind_response_linktop_lw273 (void *f, gpointer d)
|
||||
{ "message", 0, 1 }
|
||||
};
|
||||
|
||||
test_cind_results ("LW273", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cind_results ("LW273", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1195,7 +1174,7 @@ test_cind_response_moto_v3m (void *f, gpointer d)
|
||||
{ "smsfull", 0, 1 }
|
||||
};
|
||||
|
||||
test_cind_results ("Motorola V3m", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cind_results ("Motorola V3m", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||
}
|
||||
|
||||
static TestData *
|
||||
@@ -1242,6 +1221,7 @@ int main (int argc, char **argv)
|
||||
gint result;
|
||||
DevidItem *item = &devids[0];
|
||||
|
||||
g_type_init ();
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
suite = g_test_get_root ();
|
||||
|
Reference in New Issue
Block a user