mirror of git://git.sysmocom.de/ofono
linktop: reimplemented with minimum features
The device supports subset of ST-Ericsson AT command extensions but nither STE nor the MBM plugin works with these devices. Fixes MeeGo bug #14784
This commit is contained in:
parent
6aa70ebf6b
commit
c8b82018d3
|
@ -34,10 +34,6 @@
|
|||
#define OFONO_API_SUBJECT_TO_CHANGE
|
||||
#include <ofono/plugin.h>
|
||||
#include <ofono/modem.h>
|
||||
#include <ofono/call-barring.h>
|
||||
#include <ofono/call-forwarding.h>
|
||||
#include <ofono/call-meter.h>
|
||||
#include <ofono/call-settings.h>
|
||||
#include <ofono/devinfo.h>
|
||||
#include <ofono/message-waiting.h>
|
||||
#include <ofono/netreg.h>
|
||||
|
@ -45,22 +41,19 @@
|
|||
#include <ofono/cbs.h>
|
||||
#include <ofono/sms.h>
|
||||
#include <ofono/ussd.h>
|
||||
#include <ofono/call-volume.h>
|
||||
#include <ofono/voicecall.h>
|
||||
#include <ofono/gprs.h>
|
||||
#include <ofono/gprs-context.h>
|
||||
#include <ofono/phonebook.h>
|
||||
#include <ofono/radio-settings.h>
|
||||
#include <ofono/log.h>
|
||||
|
||||
#include <drivers/atmodem/vendor.h>
|
||||
#include <drivers/atmodem/atutil.h>
|
||||
|
||||
static const char *none_prefix[] = { NULL };
|
||||
|
||||
struct linktop_data {
|
||||
GAtChat *modem;
|
||||
GAtChat *control;
|
||||
GAtChat *aux;
|
||||
struct ofono_gprs *gprs;
|
||||
struct ofono_gprs_context *gc;
|
||||
};
|
||||
|
@ -89,16 +82,16 @@ static void linktop_remove(struct ofono_modem *modem)
|
|||
ofono_modem_set_data(modem, NULL);
|
||||
|
||||
g_at_chat_unref(data->modem);
|
||||
g_at_chat_unref(data->control);
|
||||
g_at_chat_unref(data->aux);
|
||||
|
||||
g_free(data);
|
||||
}
|
||||
|
||||
static void linktop_debug(const char *str, void *user_data)
|
||||
{
|
||||
const char *prefix = user_data;
|
||||
const char *prefix = user_data;
|
||||
|
||||
ofono_info("%s%s", prefix, str);
|
||||
ofono_info("%s%s", prefix, str);
|
||||
}
|
||||
|
||||
static GAtChat *open_device(struct ofono_modem *modem,
|
||||
|
@ -138,10 +131,9 @@ static void linktop_disconnect(gpointer user_data)
|
|||
struct ofono_modem *modem = user_data;
|
||||
struct linktop_data *data = ofono_modem_get_data(modem);
|
||||
|
||||
DBG("");
|
||||
DBG("%p, data->gc %p", modem, data->gc);
|
||||
|
||||
if (data->gc)
|
||||
ofono_gprs_context_remove(data->gc);
|
||||
ofono_gprs_context_remove(data->gc);
|
||||
|
||||
g_at_chat_unref(data->modem);
|
||||
data->modem = NULL;
|
||||
|
@ -176,31 +168,25 @@ static int linktop_enable(struct ofono_modem *modem)
|
|||
|
||||
DBG("%p", modem);
|
||||
|
||||
data->aux = open_device(modem, "Aux", "Aux: ");
|
||||
if (data->aux == NULL)
|
||||
return -EIO;
|
||||
|
||||
data->modem = open_device(modem, "Modem", "Modem: ");
|
||||
if (data->modem == NULL)
|
||||
return -EINVAL;
|
||||
if (data->modem == NULL) {
|
||||
g_at_chat_unref(data->aux);
|
||||
data->aux = NULL;
|
||||
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
g_at_chat_set_disconnect_function(data->modem,
|
||||
linktop_disconnect, modem);
|
||||
|
||||
data->control = open_device(modem, "Control", "Control: ");
|
||||
if (data->control == NULL) {
|
||||
g_at_chat_unref(data->modem);
|
||||
data->modem = NULL;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
g_at_chat_send(data->control, "ATE0 +CMEE=1", none_prefix,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
g_at_chat_send(data->modem, "AT", none_prefix,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
g_at_chat_send(data->modem, "AT &F", none_prefix,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
g_at_chat_send(data->control, "AT+CFUN=4", none_prefix,
|
||||
cfun_enable, modem, NULL);
|
||||
g_at_chat_send(data->aux, "ATE0 +CMEE=1", none_prefix,
|
||||
NULL, NULL, NULL);
|
||||
g_at_chat_send(data->aux, "AT+CFUN=4", none_prefix,
|
||||
cfun_enable, modem, NULL);
|
||||
|
||||
return -EINPROGRESS;
|
||||
}
|
||||
|
@ -212,8 +198,11 @@ static void cfun_disable(gboolean ok, GAtResult *result, gpointer user_data)
|
|||
|
||||
DBG("");
|
||||
|
||||
g_at_chat_unref(data->control);
|
||||
data->control = NULL;
|
||||
g_at_chat_unref(data->aux);
|
||||
data->aux = NULL;
|
||||
|
||||
g_at_chat_unref(data->modem);
|
||||
data->modem = NULL;
|
||||
|
||||
if (ok)
|
||||
ofono_modem_set_powered(modem, FALSE);
|
||||
|
@ -225,20 +214,12 @@ static int linktop_disable(struct ofono_modem *modem)
|
|||
|
||||
DBG("%p", modem);
|
||||
|
||||
if (data->modem) {
|
||||
g_at_chat_cancel_all(data->modem);
|
||||
g_at_chat_unregister_all(data->modem);
|
||||
g_at_chat_unref(data->modem);
|
||||
data->modem = NULL;
|
||||
}
|
||||
|
||||
if (data->control == NULL)
|
||||
if (data->aux == NULL)
|
||||
return 0;
|
||||
|
||||
g_at_chat_cancel_all(data->control);
|
||||
g_at_chat_unregister_all(data->control);
|
||||
g_at_chat_send(data->control, "AT+CFUN=4", none_prefix,
|
||||
cfun_disable, modem, NULL);
|
||||
g_at_chat_cancel_all(data->aux);
|
||||
g_at_chat_unregister_all(data->aux);
|
||||
g_at_chat_send(data->aux, "AT+CFUN=4", NULL, cfun_disable, modem, NULL);
|
||||
|
||||
return -EINPROGRESS;
|
||||
}
|
||||
|
@ -257,12 +238,14 @@ static void linktop_set_online(struct ofono_modem *modem, ofono_bool_t online,
|
|||
ofono_modem_online_cb_t cb, void *user_data)
|
||||
{
|
||||
struct linktop_data *data = ofono_modem_get_data(modem);
|
||||
GAtChat *chat = data->control;
|
||||
GAtChat *chat = data->aux;
|
||||
struct cb_data *cbd = cb_data_new(cb, user_data);
|
||||
char const *command = online ? "AT+CFUN=1" : "AT+CFUN=4";
|
||||
|
||||
DBG("modem %p %s", modem, online ? "online" : "offline");
|
||||
|
||||
cbd->user = data;
|
||||
|
||||
if (g_at_chat_send(chat, command, NULL, set_online_cb, cbd, g_free))
|
||||
return;
|
||||
|
||||
|
@ -278,9 +261,8 @@ static void linktop_pre_sim(struct ofono_modem *modem)
|
|||
|
||||
DBG("%p", modem);
|
||||
|
||||
ofono_devinfo_create(modem, 0, "atmodem", data->control);
|
||||
sim = ofono_sim_create(modem, 0, "atmodem", data->control);
|
||||
ofono_voicecall_create(modem, 0, "stemodem", data->control);
|
||||
ofono_devinfo_create(modem, 0, "atmodem", data->aux);
|
||||
sim = ofono_sim_create(modem, 0, "atmodem", data->aux);
|
||||
|
||||
if (sim)
|
||||
ofono_sim_inserted_notify(sim, TRUE);
|
||||
|
@ -292,35 +274,27 @@ static void linktop_post_sim(struct ofono_modem *modem)
|
|||
|
||||
DBG("%p", modem);
|
||||
|
||||
ofono_radio_settings_create(modem, 0, "stemodem", data->control);
|
||||
ofono_phonebook_create(modem, 0, "atmodem", data->control);
|
||||
ofono_sms_create(modem, 0, "atmodem", data->control);
|
||||
ofono_radio_settings_create(modem, 0, "stemodem", data->aux);
|
||||
ofono_phonebook_create(modem, 0, "atmodem", data->aux);
|
||||
ofono_sms_create(modem, 0, "atmodem", data->aux);
|
||||
}
|
||||
|
||||
static void linktop_post_online(struct ofono_modem *modem)
|
||||
{
|
||||
struct linktop_data *data = ofono_modem_get_data(modem);
|
||||
struct ofono_message_waiting *mw;
|
||||
struct ofono_gprs *gprs;
|
||||
struct ofono_gprs_context *gc;
|
||||
|
||||
DBG("%p", modem);
|
||||
|
||||
ofono_ussd_create(modem, 0, "atmodem", data->control);
|
||||
ofono_call_forwarding_create(modem, 0, "atmodem", data->control);
|
||||
ofono_call_settings_create(modem, 0, "atmodem", data->control);
|
||||
ofono_netreg_create(modem, OFONO_VENDOR_MBM, "atmodem", data->control);
|
||||
ofono_call_meter_create(modem, 0, "atmodem", data->control);
|
||||
ofono_call_barring_create(modem, 0, "atmodem", data->control);
|
||||
ofono_call_volume_create(modem, 0, "atmodem", data->control);
|
||||
ofono_cbs_create(modem, 0, "atmodem", data->control);
|
||||
ofono_netreg_create(modem, 0, "atmodem", data->aux);
|
||||
ofono_cbs_create(modem, 0, "atmodem", data->aux);
|
||||
ofono_ussd_create(modem, 0, "atmodem", data->aux);
|
||||
|
||||
gprs = ofono_gprs_create(modem, OFONO_VENDOR_MBM,
|
||||
"atmodem", data->control);
|
||||
gc = ofono_gprs_context_create(modem, 0, "atmodem", data->modem);
|
||||
data->gprs = ofono_gprs_create(modem, 0, "atmodem", data->aux);
|
||||
data->gc = ofono_gprs_context_create(modem, 0, "atmodem", data->modem);
|
||||
|
||||
if (gprs && gc)
|
||||
ofono_gprs_add_context(gprs, gc);
|
||||
if (data->gprs && data->gc)
|
||||
ofono_gprs_add_context(data->gprs, data->gc);
|
||||
|
||||
mw = ofono_message_waiting_create(modem);
|
||||
|
||||
|
|
Loading…
Reference in New Issue