cinterion: implement connection status monitoring via ^SWWAN?

And consolidate the connection status checks done during connection and
disconnection so that we re-use the same logic.
This commit is contained in:
Aleksander Morgado
2016-12-14 13:54:47 +01:00
parent 9f725bc96a
commit 11297bcc79
4 changed files with 181 additions and 110 deletions

View File

@@ -75,6 +75,90 @@ get_usb_interface_config_index (MMPort *data,
return -1; return -1;
} }
/*****************************************************************************/
/* Connection status loading
* NOTE: only CONNECTED or DISCONNECTED should be reported here.
*/
static MMBearerConnectionStatus
load_connection_status_finish (MMBaseBearer *bearer,
GAsyncResult *res,
GError **error)
{
gssize aux;
aux = g_task_propagate_int (G_TASK (res), error);
return (aux < 0 ? MM_BEARER_CONNECTION_STATUS_UNKNOWN : (MMBearerConnectionStatus) aux);
}
static void
swwan_check_status_ready (MMBaseModem *modem,
GAsyncResult *res,
GTask *task)
{
const gchar *response;
GError *error = NULL;
MMBearerConnectionStatus status;
guint cid;
cid = GPOINTER_TO_UINT (g_task_get_task_data (task));
response = mm_base_modem_at_command_finish (modem, res, &error);
if (!response) {
g_task_return_error (task, error);
goto out;
}
status = mm_cinterion_parse_swwan_response (response, cid, &error);
if (status == MM_BEARER_CONNECTION_STATUS_UNKNOWN) {
g_task_return_error (task, error);
goto out;
}
g_assert (status == MM_BEARER_CONNECTION_STATUS_DISCONNECTED ||
status == MM_BEARER_CONNECTION_STATUS_CONNECTED);
g_task_return_int (task, (gssize) status);
out:
g_object_unref (task);
}
static void
load_connection_status_by_cid (MMBroadbandBearerCinterion *bearer,
guint cid,
GAsyncReadyCallback callback,
gpointer user_data)
{
GTask *task;
MMBaseModem *modem;
task = g_task_new (bearer, NULL, callback, user_data);
g_task_set_task_data (task, GUINT_TO_POINTER (cid), NULL);
g_object_get (bearer,
MM_BASE_BEARER_MODEM, &modem,
NULL);
mm_base_modem_at_command (modem,
"^SWWAN?",
5,
FALSE,
(GAsyncReadyCallback) swwan_check_status_ready,
task);
g_object_unref (modem);
}
static void
load_connection_status (MMBaseBearer *bearer,
GAsyncReadyCallback callback,
gpointer user_data)
{
load_connection_status_by_cid (MM_BROADBAND_BEARER_CINTERION (bearer),
mm_broadband_bearer_get_3gpp_cid (MM_BROADBAND_BEARER (bearer)),
callback,
user_data);
}
/*****************************************************************************/ /*****************************************************************************/
/* Auth helpers */ /* Auth helpers */
@@ -186,39 +270,31 @@ dial_3gpp_finish (MMBroadbandBearer *self,
static void dial_3gpp_context_step (GTask *task); static void dial_3gpp_context_step (GTask *task);
static void static void
swwan_dial_check_status_ready (MMBaseModem *modem, dial_connection_status_ready (MMBroadbandBearerCinterion *self,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
MMBearerConnectionStatus status;
Dial3gppContext *ctx; Dial3gppContext *ctx;
const gchar *response;
GError *error = NULL; GError *error = NULL;
MMSwwanState state;
ctx = (Dial3gppContext *) g_task_get_task_data (task); ctx = (Dial3gppContext *) g_task_get_task_data (task);
response = mm_base_modem_at_command_full_finish (modem, res, &error); status = load_connection_status_finish (MM_BASE_BEARER (self), res, &error);
if (!response) { if (status == MM_BEARER_CONNECTION_STATUS_UNKNOWN) {
g_task_return_error (task, error); g_task_return_error (task, error);
g_object_unref (task); g_object_unref (task);
return; return;
} }
state = mm_cinterion_parse_swwan_response (response, ctx->cid, &error); if (status == MM_BEARER_CONNECTION_STATUS_DISCONNECTED) {
if (state == MM_SWWAN_STATE_UNKNOWN) {
g_task_return_error (task, error);
g_object_unref (task);
return;
}
if (state == MM_SWWAN_STATE_DISCONNECTED) {
g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"CID %u is reported disconnected", ctx->cid); "CID %u is reported disconnected", ctx->cid);
g_object_unref (task); g_object_unref (task);
return; return;
} }
g_assert (state == MM_SWWAN_STATE_CONNECTED); g_assert (status == MM_BEARER_CONNECTION_STATUS_CONNECTED);
/* Go to next step */ /* Go to next step */
ctx->step++; ctx->step++;
@@ -362,14 +438,9 @@ dial_3gpp_context_step (GTask *task)
case DIAL_3GPP_CONTEXT_STEP_VALIDATE_CONNECTION: case DIAL_3GPP_CONTEXT_STEP_VALIDATE_CONNECTION:
mm_dbg ("cinterion dial step %u/%u: checking SWWAN interface %u status...", mm_dbg ("cinterion dial step %u/%u: checking SWWAN interface %u status...",
ctx->step, DIAL_3GPP_CONTEXT_STEP_LAST, usb_interface_configs[ctx->usb_interface_config_index].swwan_index); ctx->step, DIAL_3GPP_CONTEXT_STEP_LAST, usb_interface_configs[ctx->usb_interface_config_index].swwan_index);
mm_base_modem_at_command_full (ctx->modem, load_connection_status_by_cid (ctx->self,
ctx->primary, ctx->cid,
"^SWWAN?", (GAsyncReadyCallback) dial_connection_status_ready,
5,
FALSE,
FALSE,
NULL,
(GAsyncReadyCallback) swwan_dial_check_status_ready,
task); task);
return; return;
@@ -471,39 +542,34 @@ disconnect_3gpp_finish (MMBroadbandBearer *self,
static void disconnect_3gpp_context_step (GTask *task); static void disconnect_3gpp_context_step (GTask *task);
static void static void
swwan_disconnect_check_status_ready (MMBaseModem *modem, disconnect_connection_status_ready (MMBroadbandBearerCinterion *self,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
MMBearerConnectionStatus status;
Disconnect3gppContext *ctx; Disconnect3gppContext *ctx;
const gchar *response;
GError *error = NULL; GError *error = NULL;
MMSwwanState state;
ctx = (Disconnect3gppContext *) g_task_get_task_data (task); ctx = (Disconnect3gppContext *) g_task_get_task_data (task);
response = mm_base_modem_at_command_full_finish (modem, res, &error); status = load_connection_status_finish (MM_BASE_BEARER (self), res, &error);
if (error) { switch (status) {
g_task_return_error (task, error); case MM_BEARER_CONNECTION_STATUS_UNKNOWN:
g_object_unref (task); /* Assume disconnected */
return; mm_dbg ("couldn't get CID %u status, assume disconnected: %s", ctx->cid, error->message);
} g_clear_error (&error);
break;
state = mm_cinterion_parse_swwan_response (response, ctx->cid, &error); case MM_BEARER_CONNECTION_STATUS_DISCONNECTED:
if (state == MM_SWWAN_STATE_CONNECTED) { break;
case MM_BEARER_CONNECTION_STATUS_CONNECTED:
g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"CID %u is reported connected", ctx->cid); "CID %u is reported connected", ctx->cid);
g_object_unref (task); g_object_unref (task);
return; return;
default:
g_assert_not_reached ();
} }
if (state == MM_SWWAN_STATE_UNKNOWN) {
/* Assume disconnected */
mm_dbg ("couldn't get CID %u status, assume disconnected: %s", ctx->cid, error->message);
g_error_free (error);
} else
g_assert (state == MM_SWWAN_STATE_DISCONNECTED);
/* Go on to next step */ /* Go on to next step */
ctx->step++; ctx->step++;
disconnect_3gpp_context_step (task); disconnect_3gpp_context_step (task);
@@ -563,14 +629,9 @@ disconnect_3gpp_context_step (GTask *task)
mm_dbg ("cinterion disconnect step %u/%u: checking SWWAN interface %u status...", mm_dbg ("cinterion disconnect step %u/%u: checking SWWAN interface %u status...",
ctx->step, DISCONNECT_3GPP_CONTEXT_STEP_LAST, ctx->step, DISCONNECT_3GPP_CONTEXT_STEP_LAST,
usb_interface_configs[ctx->usb_interface_config_index].swwan_index); usb_interface_configs[ctx->usb_interface_config_index].swwan_index);
mm_base_modem_at_command_full (ctx->modem, load_connection_status_by_cid (MM_BROADBAND_BEARER_CINTERION (ctx->self),
ctx->primary, ctx->cid,
"^SWWAN?", (GAsyncReadyCallback) disconnect_connection_status_ready,
5,
FALSE,
FALSE,
NULL,
(GAsyncReadyCallback) swwan_disconnect_check_status_ready,
task); task);
return; return;
@@ -674,8 +735,12 @@ mm_broadband_bearer_cinterion_init (MMBroadbandBearerCinterion *self)
static void static void
mm_broadband_bearer_cinterion_class_init (MMBroadbandBearerCinterionClass *klass) mm_broadband_bearer_cinterion_class_init (MMBroadbandBearerCinterionClass *klass)
{ {
MMBaseBearerClass *base_bearer_class = MM_BASE_BEARER_CLASS (klass);
MMBroadbandBearerClass *broadband_bearer_class = MM_BROADBAND_BEARER_CLASS (klass); MMBroadbandBearerClass *broadband_bearer_class = MM_BROADBAND_BEARER_CLASS (klass);
base_bearer_class->load_connection_status = load_connection_status;
base_bearer_class->load_connection_status_finish = load_connection_status_finish;
broadband_bearer_class->dial_3gpp = dial_3gpp; broadband_bearer_class->dial_3gpp = dial_3gpp;
broadband_bearer_class->dial_3gpp_finish = dial_3gpp_finish; broadband_bearer_class->dial_3gpp_finish = dial_3gpp_finish;
broadband_bearer_class->disconnect_3gpp = disconnect_3gpp; broadband_bearer_class->disconnect_3gpp = disconnect_3gpp;

View File

@@ -512,7 +512,13 @@ mm_cinterion_parse_sind_response (const gchar *response,
* ^SWWAN: 3,1,1 - 3rd PDP Context, Activated, First WWAN Adaptor * ^SWWAN: 3,1,1 - 3rd PDP Context, Activated, First WWAN Adaptor
* +CME ERROR: ? - * +CME ERROR: ? -
*/ */
MMSwwanState
enum {
MM_SWWAN_STATE_DISCONNECTED = 0,
MM_SWWAN_STATE_CONNECTED = 1,
};
MMBearerConnectionStatus
mm_cinterion_parse_swwan_response (const gchar *response, mm_cinterion_parse_swwan_response (const gchar *response,
guint cid, guint cid,
GError **error) GError **error)
@@ -520,26 +526,26 @@ mm_cinterion_parse_swwan_response (const gchar *response,
GRegex *r; GRegex *r;
GMatchInfo *match_info; GMatchInfo *match_info;
GError *inner_error = NULL; GError *inner_error = NULL;
MMSwwanState state; MMBearerConnectionStatus status;
g_assert (response); g_assert (response);
/* If no WWAN connection is active, then ^SWWAN read command just returns OK /* If no WWAN connection is active, then ^SWWAN read command just returns OK
* (which we receive as an empty string) */ * (which we receive as an empty string) */
if (!response[0]) if (!response[0])
return MM_SWWAN_STATE_DISCONNECTED; return MM_BEARER_CONNECTION_STATUS_DISCONNECTED;
if (!g_str_has_prefix (response, "^SWWAN:")) { if (!g_str_has_prefix (response, "^SWWAN:")) {
g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Couldn't parse ^SWWAN response: '%s'", response); "Couldn't parse ^SWWAN response: '%s'", response);
return MM_SWWAN_STATE_UNKNOWN; return MM_BEARER_CONNECTION_STATUS_UNKNOWN;
} }
r = g_regex_new ("\\^SWWAN:\\s*(\\d+),\\s*(\\d+)(?:,\\s*(\\d+))?(?:\\r\\n)?", r = g_regex_new ("\\^SWWAN:\\s*(\\d+),\\s*(\\d+)(?:,\\s*(\\d+))?(?:\\r\\n)?",
G_REGEX_DOLLAR_ENDONLY | G_REGEX_RAW, 0, NULL); G_REGEX_DOLLAR_ENDONLY | G_REGEX_RAW, 0, NULL);
g_assert (r != NULL); g_assert (r != NULL);
state = MM_SWWAN_STATE_UNKNOWN; status = MM_BEARER_CONNECTION_STATUS_UNKNOWN;
g_regex_match_full (r, response, strlen (response), 0, 0, &match_info, &inner_error); g_regex_match_full (r, response, strlen (response), 0, 0, &match_info, &inner_error);
while (!inner_error && g_match_info_matches (match_info)) { while (!inner_error && g_match_info_matches (match_info)) {
guint read_state; guint read_state;
@@ -550,22 +556,26 @@ mm_cinterion_parse_swwan_response (const gchar *response,
else if (!mm_get_uint_from_match_info (match_info, 2, &read_state)) else if (!mm_get_uint_from_match_info (match_info, 2, &read_state))
mm_warn ("Couldn't read state in ^SWWAN response: '%s'", response); mm_warn ("Couldn't read state in ^SWWAN response: '%s'", response);
else if (read_cid == cid) { else if (read_cid == cid) {
if (read_state == MM_SWWAN_STATE_CONNECTED || read_state == MM_SWWAN_STATE_DISCONNECTED) { if (read_state == MM_SWWAN_STATE_CONNECTED) {
state = (MMSwwanState) read_state; status = MM_BEARER_CONNECTION_STATUS_CONNECTED;
break;
}
if (read_state == MM_SWWAN_STATE_DISCONNECTED) {
status = MM_BEARER_CONNECTION_STATUS_DISCONNECTED;
break; break;
} }
mm_warn ("Invalid state read in ^SWWAN response: %u", read_state); mm_warn ("Invalid state read in ^SWWAN response: %u", read_state);
break;
} }
g_match_info_next (match_info, &inner_error); g_match_info_next (match_info, &inner_error);
} }
g_match_info_free (match_info); g_match_info_free (match_info);
g_regex_unref (r); g_regex_unref (r);
if (state == MM_SWWAN_STATE_UNKNOWN) if (status == MM_BEARER_CONNECTION_STATUS_UNKNOWN)
g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"No state returned for CID %u", cid); "No state returned for CID %u", cid);
return state; return status;
} }

View File

@@ -18,7 +18,9 @@
#ifndef MM_MODEM_HELPERS_CINTERION_H #ifndef MM_MODEM_HELPERS_CINTERION_H
#define MM_MODEM_HELPERS_CINTERION_H #define MM_MODEM_HELPERS_CINTERION_H
#include "glib.h" #include <glib.h>
#include <mm-base-bearer.h>
/*****************************************************************************/ /*****************************************************************************/
/* ^SCFG test parser */ /* ^SCFG test parser */
@@ -68,13 +70,7 @@ gboolean mm_cinterion_parse_sind_response (const gchar *response,
/*****************************************************************************/ /*****************************************************************************/
/* ^SWWAN response parser */ /* ^SWWAN response parser */
typedef enum { MMBearerConnectionStatus mm_cinterion_parse_swwan_response (const gchar *response,
MM_SWWAN_STATE_UNKNOWN = -1,
MM_SWWAN_STATE_DISCONNECTED = 0,
MM_SWWAN_STATE_CONNECTED = 1,
} MMSwwanState;
MMSwwanState mm_cinterion_parse_swwan_response (const gchar *response,
guint swwan_index, guint swwan_index,
GError **error); GError **error);

View File

@@ -337,7 +337,7 @@ test_cnmi_phs8 (void)
typedef struct { typedef struct {
guint cid; guint cid;
MMSwwanState state; MMBearerConnectionStatus state;
} PdpContextState; } PdpContextState;
typedef struct { typedef struct {
@@ -352,8 +352,8 @@ static const SwwanTest swwan_tests[] = {
{ {
.response = "", .response = "",
.expected_items = { .expected_items = {
{ .cid = 2, .state = MM_SWWAN_STATE_DISCONNECTED }, { .cid = 2, .state = MM_BEARER_CONNECTION_STATUS_DISCONNECTED },
{ .cid = 3, .state = MM_SWWAN_STATE_DISCONNECTED } { .cid = 3, .state = MM_BEARER_CONNECTION_STATUS_DISCONNECTED }
}, },
/* Don't test other CIDs because for those we would also return /* Don't test other CIDs because for those we would also return
* DISCONNECTED, not UNKNOWN. */ * DISCONNECTED, not UNKNOWN. */
@@ -363,80 +363,80 @@ static const SwwanTest swwan_tests[] = {
{ {
.response = "^SWWAN: 3,1\r\n", .response = "^SWWAN: 3,1\r\n",
.expected_items = { .expected_items = {
{ .cid = 2, .state = MM_SWWAN_STATE_UNKNOWN }, { .cid = 2, .state = MM_BEARER_CONNECTION_STATUS_UNKNOWN },
{ .cid = 3, .state = MM_SWWAN_STATE_CONNECTED } { .cid = 3, .state = MM_BEARER_CONNECTION_STATUS_CONNECTED }
} }
}, },
/* Single PDP context active (long version with interface index) */ /* Single PDP context active (long version with interface index) */
{ {
.response = "^SWWAN: 3,1,1\r\n", .response = "^SWWAN: 3,1,1\r\n",
.expected_items = { .expected_items = {
{ .cid = 2, .state = MM_SWWAN_STATE_UNKNOWN }, { .cid = 2, .state = MM_BEARER_CONNECTION_STATUS_UNKNOWN },
{ .cid = 3, .state = MM_SWWAN_STATE_CONNECTED } { .cid = 3, .state = MM_BEARER_CONNECTION_STATUS_CONNECTED }
} }
}, },
/* Single PDP context inactive (short version without interface index) */ /* Single PDP context inactive (short version without interface index) */
{ {
.response = "^SWWAN: 3,0\r\n", .response = "^SWWAN: 3,0\r\n",
.expected_items = { .expected_items = {
{ .cid = 2, .state = MM_SWWAN_STATE_UNKNOWN }, { .cid = 2, .state = MM_BEARER_CONNECTION_STATUS_UNKNOWN },
{ .cid = 3, .state = MM_SWWAN_STATE_DISCONNECTED } { .cid = 3, .state = MM_BEARER_CONNECTION_STATUS_DISCONNECTED }
} }
}, },
/* Single PDP context inactive (long version with interface index) */ /* Single PDP context inactive (long version with interface index) */
{ {
.response = "^SWWAN: 3,0,1\r\n", .response = "^SWWAN: 3,0,1\r\n",
.expected_items = { .expected_items = {
{ .cid = 2, .state = MM_SWWAN_STATE_UNKNOWN }, { .cid = 2, .state = MM_BEARER_CONNECTION_STATUS_UNKNOWN },
{ .cid = 3, .state = MM_SWWAN_STATE_DISCONNECTED } { .cid = 3, .state = MM_BEARER_CONNECTION_STATUS_DISCONNECTED }
} }
}, },
/* Multiple PDP contexts active (short version without interface index) */ /* Multiple PDP contexts active (short version without interface index) */
{ {
.response = "^SWWAN: 2,1\r\n^SWWAN: 3,1\r\n", .response = "^SWWAN: 2,1\r\n^SWWAN: 3,1\r\n",
.expected_items = { .expected_items = {
{ .cid = 2, .state = MM_SWWAN_STATE_CONNECTED }, { .cid = 2, .state = MM_BEARER_CONNECTION_STATUS_CONNECTED },
{ .cid = 3, .state = MM_SWWAN_STATE_CONNECTED } { .cid = 3, .state = MM_BEARER_CONNECTION_STATUS_CONNECTED }
} }
}, },
/* Multiple PDP contexts active (long version with interface index) */ /* Multiple PDP contexts active (long version with interface index) */
{ {
.response = "^SWWAN: 2,1,3\r\n^SWWAN: 3,1,1\r\n", .response = "^SWWAN: 2,1,3\r\n^SWWAN: 3,1,1\r\n",
.expected_items = { .expected_items = {
{ .cid = 2, .state = MM_SWWAN_STATE_CONNECTED }, { .cid = 2, .state = MM_BEARER_CONNECTION_STATUS_CONNECTED },
{ .cid = 3, .state = MM_SWWAN_STATE_CONNECTED } { .cid = 3, .state = MM_BEARER_CONNECTION_STATUS_CONNECTED }
} }
}, },
/* Multiple PDP contexts inactive (short version without interface index) */ /* Multiple PDP contexts inactive (short version without interface index) */
{ {
.response = "^SWWAN: 2,0\r\n^SWWAN: 3,0\r\n", .response = "^SWWAN: 2,0\r\n^SWWAN: 3,0\r\n",
.expected_items = { .expected_items = {
{ .cid = 2, .state = MM_SWWAN_STATE_DISCONNECTED }, { .cid = 2, .state = MM_BEARER_CONNECTION_STATUS_DISCONNECTED },
{ .cid = 3, .state = MM_SWWAN_STATE_DISCONNECTED } { .cid = 3, .state = MM_BEARER_CONNECTION_STATUS_DISCONNECTED }
} }
}, },
/* Multiple PDP contexts inactive (long version with interface index) */ /* Multiple PDP contexts inactive (long version with interface index) */
{ {
.response = "^SWWAN: 2,0,3\r\n^SWWAN: 3,0,1\r\n", .response = "^SWWAN: 2,0,3\r\n^SWWAN: 3,0,1\r\n",
.expected_items = { .expected_items = {
{ .cid = 2, .state = MM_SWWAN_STATE_DISCONNECTED }, { .cid = 2, .state = MM_BEARER_CONNECTION_STATUS_DISCONNECTED },
{ .cid = 3, .state = MM_SWWAN_STATE_DISCONNECTED } { .cid = 3, .state = MM_BEARER_CONNECTION_STATUS_DISCONNECTED }
} }
}, },
/* Multiple PDP contexts active/inactive (short version without interface index) */ /* Multiple PDP contexts active/inactive (short version without interface index) */
{ {
.response = "^SWWAN: 2,0\r\n^SWWAN: 3,1\r\n", .response = "^SWWAN: 2,0\r\n^SWWAN: 3,1\r\n",
.expected_items = { .expected_items = {
{ .cid = 2, .state = MM_SWWAN_STATE_DISCONNECTED }, { .cid = 2, .state = MM_BEARER_CONNECTION_STATUS_DISCONNECTED },
{ .cid = 3, .state = MM_SWWAN_STATE_CONNECTED } { .cid = 3, .state = MM_BEARER_CONNECTION_STATUS_CONNECTED }
} }
}, },
/* Multiple PDP contexts active/inactive (long version with interface index) */ /* Multiple PDP contexts active/inactive (long version with interface index) */
{ {
.response = "^SWWAN: 2,0,3\r\n^SWWAN: 3,1,1\r\n", .response = "^SWWAN: 2,0,3\r\n^SWWAN: 3,1,1\r\n",
.expected_items = { .expected_items = {
{ .cid = 2, .state = MM_SWWAN_STATE_DISCONNECTED }, { .cid = 2, .state = MM_BEARER_CONNECTION_STATUS_DISCONNECTED },
{ .cid = 3, .state = MM_SWWAN_STATE_CONNECTED } { .cid = 3, .state = MM_BEARER_CONNECTION_STATUS_CONNECTED }
} }
} }
}; };
@@ -444,7 +444,7 @@ static const SwwanTest swwan_tests[] = {
static void static void
test_swwan_pls8 (void) test_swwan_pls8 (void)
{ {
MMSwwanState read_state; MMBearerConnectionStatus read_state;
GError *error = NULL; GError *error = NULL;
guint i; guint i;
@@ -455,7 +455,7 @@ test_swwan_pls8 (void)
/* Query for the expected items (CIDs 2 and 3) */ /* Query for the expected items (CIDs 2 and 3) */
for (j = 0; j < SWWAN_TEST_MAX_CIDS; j++) { for (j = 0; j < SWWAN_TEST_MAX_CIDS; j++) {
read_state = mm_cinterion_parse_swwan_response (swwan_tests[i].response, swwan_tests[i].expected_items[j].cid, &error); read_state = mm_cinterion_parse_swwan_response (swwan_tests[i].response, swwan_tests[i].expected_items[j].cid, &error);
if (swwan_tests[i].expected_items[j].state == MM_SWWAN_STATE_UNKNOWN) { if (swwan_tests[i].expected_items[j].state == MM_BEARER_CONNECTION_STATUS_UNKNOWN) {
g_assert_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED); g_assert_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED);
g_clear_error (&error); g_clear_error (&error);
} else } else
@@ -467,7 +467,7 @@ test_swwan_pls8 (void)
if (!swwan_tests[i].skip_test_other_cids) { if (!swwan_tests[i].skip_test_other_cids) {
read_state = mm_cinterion_parse_swwan_response (swwan_tests[i].response, 12, &error); read_state = mm_cinterion_parse_swwan_response (swwan_tests[i].response, 12, &error);
g_assert_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED); g_assert_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED);
g_assert_cmpint (read_state, ==, MM_SWWAN_STATE_UNKNOWN); g_assert_cmpint (read_state, ==, MM_BEARER_CONNECTION_STATUS_UNKNOWN);
g_clear_error (&error); g_clear_error (&error);
} }
} }
@@ -475,7 +475,7 @@ test_swwan_pls8 (void)
/* Additional tests for errors */ /* Additional tests for errors */
read_state = mm_cinterion_parse_swwan_response ("^GARBAGE", 2, &error); read_state = mm_cinterion_parse_swwan_response ("^GARBAGE", 2, &error);
g_assert_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED); g_assert_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED);
g_assert_cmpint (read_state, ==, MM_SWWAN_STATE_UNKNOWN); g_assert_cmpint (read_state, ==, MM_BEARER_CONNECTION_STATUS_UNKNOWN);
g_clear_error (&error); g_clear_error (&error);
} }