mirror of git://git.sysmocom.de/ofono
sierra: Fix disable and enable error handling
This commit is contained in:
parent
6d9d9558fb
commit
1a23051d0f
|
@ -23,7 +23,6 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
@ -104,6 +103,7 @@ static GAtChat *open_device(struct ofono_modem *modem,
|
||||||
syntax = g_at_syntax_new_gsmv1();
|
syntax = g_at_syntax_new_gsmv1();
|
||||||
chat = g_at_chat_new(channel, syntax);
|
chat = g_at_chat_new(channel, syntax);
|
||||||
g_at_syntax_unref(syntax);
|
g_at_syntax_unref(syntax);
|
||||||
|
|
||||||
g_io_channel_unref(channel);
|
g_io_channel_unref(channel);
|
||||||
|
|
||||||
if (chat == NULL)
|
if (chat == NULL)
|
||||||
|
@ -118,9 +118,15 @@ static GAtChat *open_device(struct ofono_modem *modem,
|
||||||
static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
|
static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
|
||||||
{
|
{
|
||||||
struct ofono_modem *modem = user_data;
|
struct ofono_modem *modem = user_data;
|
||||||
|
struct sierra_data *data = ofono_modem_get_data(modem);
|
||||||
|
|
||||||
DBG("");
|
DBG("");
|
||||||
|
|
||||||
|
if (!ok) {
|
||||||
|
g_at_chat_unref(data->chat);
|
||||||
|
data->chat = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
ofono_modem_set_powered(modem, ok);
|
ofono_modem_set_powered(modem, ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +140,7 @@ static int sierra_enable(struct ofono_modem *modem)
|
||||||
if (data->chat == NULL)
|
if (data->chat == NULL)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
g_at_chat_send(data->chat, "ATE0 +CMEE=1", none_prefix,
|
g_at_chat_send(data->chat, "ATE0 &C0 +CMEE=1", NULL,
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
|
|
||||||
g_at_chat_send(data->chat, "AT+CFUN=4", none_prefix,
|
g_at_chat_send(data->chat, "AT+CFUN=4", none_prefix,
|
||||||
|
@ -163,9 +169,6 @@ static int sierra_disable(struct ofono_modem *modem)
|
||||||
|
|
||||||
DBG("%p", modem);
|
DBG("%p", modem);
|
||||||
|
|
||||||
if (data->chat == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
g_at_chat_cancel_all(data->chat);
|
g_at_chat_cancel_all(data->chat);
|
||||||
g_at_chat_unregister_all(data->chat);
|
g_at_chat_unregister_all(data->chat);
|
||||||
|
|
||||||
|
@ -179,11 +182,10 @@ static void set_online_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
||||||
{
|
{
|
||||||
struct cb_data *cbd = user_data;
|
struct cb_data *cbd = user_data;
|
||||||
ofono_modem_online_cb_t cb = cbd->cb;
|
ofono_modem_online_cb_t cb = cbd->cb;
|
||||||
|
struct ofono_error error;
|
||||||
|
|
||||||
if (ok)
|
decode_at_error(&error, g_at_result_final_response(result));
|
||||||
CALLBACK_WITH_SUCCESS(cb, cbd->data);
|
cb(&error, cbd->data);
|
||||||
else
|
|
||||||
CALLBACK_WITH_FAILURE(cb, cbd->data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sierra_set_online(struct ofono_modem *modem, ofono_bool_t online,
|
static void sierra_set_online(struct ofono_modem *modem, ofono_bool_t online,
|
||||||
|
@ -195,17 +197,13 @@ static void sierra_set_online(struct ofono_modem *modem, ofono_bool_t online,
|
||||||
|
|
||||||
DBG("modem %p %s", modem, online ? "online" : "offline");
|
DBG("modem %p %s", modem, online ? "online" : "offline");
|
||||||
|
|
||||||
if (data->chat == NULL)
|
if (g_at_chat_send(data->chat, command, none_prefix,
|
||||||
goto error;
|
set_online_cb, cbd, g_free) > 0)
|
||||||
|
|
||||||
if (g_at_chat_send(data->chat, command, NULL,
|
|
||||||
set_online_cb, cbd, g_free))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
error:
|
|
||||||
g_free(cbd);
|
|
||||||
|
|
||||||
CALLBACK_WITH_FAILURE(cb, cbd->data);
|
CALLBACK_WITH_FAILURE(cb, cbd->data);
|
||||||
|
|
||||||
|
g_free(cbd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sierra_pre_sim(struct ofono_modem *modem)
|
static void sierra_pre_sim(struct ofono_modem *modem)
|
||||||
|
|
Loading…
Reference in New Issue