2009-09-02 10:19:02 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* oFono - Open Source Telephony
|
|
|
|
*
|
2011-10-10 20:39:54 +00:00
|
|
|
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
2009-09-02 10:19:02 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdlib.h>
|
2010-07-15 14:05:02 +00:00
|
|
|
#include <string.h>
|
2009-09-02 10:19:02 +00:00
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <gatchat.h>
|
2009-10-01 22:01:15 +00:00
|
|
|
#include <gattty.h>
|
2009-09-02 10:19:02 +00:00
|
|
|
|
|
|
|
#define OFONO_API_SUBJECT_TO_CHANGE
|
|
|
|
#include <ofono/plugin.h>
|
|
|
|
#include <ofono/modem.h>
|
|
|
|
#include <ofono/devinfo.h>
|
|
|
|
#include <ofono/netreg.h>
|
2009-09-03 17:07:20 +00:00
|
|
|
#include <ofono/sim.h>
|
2010-05-12 01:22:03 +00:00
|
|
|
#include <ofono/stk.h>
|
2009-10-02 11:22:09 +00:00
|
|
|
#include <ofono/cbs.h>
|
2010-06-15 12:16:43 +00:00
|
|
|
#include <ofono/sms.h>
|
2009-10-02 11:22:09 +00:00
|
|
|
#include <ofono/ussd.h>
|
2009-10-23 20:17:33 +00:00
|
|
|
#include <ofono/gprs.h>
|
|
|
|
#include <ofono/gprs-context.h>
|
2011-01-31 08:30:51 +00:00
|
|
|
#include <ofono/radio-settings.h>
|
2009-09-02 10:19:02 +00:00
|
|
|
#include <ofono/log.h>
|
2011-02-22 18:35:13 +00:00
|
|
|
#include <ofono/location-reporting.h>
|
2017-10-26 15:22:56 +00:00
|
|
|
#include <ofono/sim-auth.h>
|
2010-06-15 12:16:43 +00:00
|
|
|
|
2010-09-06 18:46:16 +00:00
|
|
|
#include <drivers/atmodem/atutil.h>
|
2010-03-26 20:28:00 +00:00
|
|
|
#include <drivers/atmodem/vendor.h>
|
2009-09-02 10:19:02 +00:00
|
|
|
|
2009-10-29 17:50:52 +00:00
|
|
|
static const char *cfun_prefix[] = { "+CFUN:", NULL };
|
|
|
|
static const char *none_prefix[] = { NULL };
|
|
|
|
|
2010-08-25 17:13:16 +00:00
|
|
|
enum mbm_variant {
|
|
|
|
MBM_GENERIC,
|
|
|
|
MBM_DELL_D5530, /* OEM of F3507g */
|
|
|
|
};
|
|
|
|
|
2012-08-16 16:39:22 +00:00
|
|
|
#define MBM_FLAG_HAVE_SIM 0x1
|
|
|
|
#define MBM_FLAG_SAW_EMRDY 0x2
|
|
|
|
|
2009-09-02 10:19:02 +00:00
|
|
|
struct mbm_data {
|
2010-03-31 23:36:21 +00:00
|
|
|
GAtChat *modem_port;
|
|
|
|
GAtChat *data_port;
|
2012-08-16 16:39:22 +00:00
|
|
|
unsigned int flags;
|
2011-02-22 18:35:13 +00:00
|
|
|
struct ofono_location_reporting *lr;
|
2010-08-25 17:13:16 +00:00
|
|
|
enum mbm_variant variant;
|
2011-07-22 13:24:46 +00:00
|
|
|
struct at_util_sim_state_query *sim_state_query;
|
2009-09-02 10:19:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int mbm_probe(struct ofono_modem *modem)
|
|
|
|
{
|
|
|
|
struct mbm_data *data;
|
|
|
|
|
2009-09-03 02:04:21 +00:00
|
|
|
DBG("%p", modem);
|
2009-09-02 10:19:02 +00:00
|
|
|
|
|
|
|
data = g_try_new0(struct mbm_data, 1);
|
2010-11-27 19:39:02 +00:00
|
|
|
if (data == NULL)
|
2009-09-02 10:19:02 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
ofono_modem_set_data(modem, data);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mbm_remove(struct ofono_modem *modem)
|
|
|
|
{
|
|
|
|
struct mbm_data *data = ofono_modem_get_data(modem);
|
|
|
|
|
2009-09-03 02:04:21 +00:00
|
|
|
DBG("%p", modem);
|
2009-09-02 10:19:02 +00:00
|
|
|
|
2009-09-02 22:22:30 +00:00
|
|
|
ofono_modem_set_data(modem, NULL);
|
|
|
|
|
2011-08-03 12:31:56 +00:00
|
|
|
/* Cleanup potential SIM state polling */
|
|
|
|
at_util_sim_state_query_free(data->sim_state_query);
|
|
|
|
|
2010-03-31 23:36:21 +00:00
|
|
|
g_at_chat_unref(data->data_port);
|
|
|
|
g_at_chat_unref(data->modem_port);
|
2010-07-15 14:05:02 +00:00
|
|
|
|
2009-09-02 10:19:02 +00:00
|
|
|
g_free(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mbm_debug(const char *str, void *user_data)
|
|
|
|
{
|
2010-03-31 23:36:21 +00:00
|
|
|
const char *prefix = user_data;
|
|
|
|
|
2010-09-24 05:14:04 +00:00
|
|
|
ofono_info("%s%s", prefix, str);
|
2009-09-02 10:19:02 +00:00
|
|
|
}
|
|
|
|
|
2010-08-25 17:13:16 +00:00
|
|
|
static void d5530_notify(GAtResult *result, gpointer user_data)
|
|
|
|
{
|
|
|
|
DBG("D5530");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mbm_quirk_d5530(struct ofono_modem *modem)
|
|
|
|
{
|
|
|
|
struct mbm_data *data = ofono_modem_get_data(modem);
|
|
|
|
|
|
|
|
data->variant = MBM_DELL_D5530;
|
|
|
|
|
|
|
|
/* This Dell modem sends some unsolicated messages when it boots. */
|
|
|
|
/* Try to ignore them. */
|
|
|
|
g_at_chat_register(data->modem_port, "D5530", d5530_notify,
|
|
|
|
FALSE, NULL, NULL);
|
2010-08-30 13:36:31 +00:00
|
|
|
g_at_chat_register(data->modem_port, "+GCAP:", d5530_notify,
|
2010-08-25 17:13:16 +00:00
|
|
|
FALSE, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2011-07-22 13:24:46 +00:00
|
|
|
static void sim_state_cb(gboolean present, gpointer user_data)
|
|
|
|
{
|
|
|
|
struct ofono_modem *modem = user_data;
|
|
|
|
struct mbm_data *data = ofono_modem_get_data(modem);
|
|
|
|
|
|
|
|
at_util_sim_state_query_free(data->sim_state_query);
|
|
|
|
data->sim_state_query = NULL;
|
|
|
|
|
2012-11-07 13:59:57 +00:00
|
|
|
if (present)
|
|
|
|
data->flags |= MBM_FLAG_HAVE_SIM;
|
|
|
|
|
2011-07-22 13:24:46 +00:00
|
|
|
ofono_modem_set_powered(modem, TRUE);
|
|
|
|
}
|
|
|
|
|
2011-01-06 06:28:19 +00:00
|
|
|
static void check_model(gboolean ok, GAtResult *result, gpointer user_data)
|
2010-08-25 17:13:16 +00:00
|
|
|
{
|
|
|
|
struct ofono_modem *modem = user_data;
|
2011-07-22 13:24:46 +00:00
|
|
|
struct mbm_data *data = ofono_modem_get_data(modem);
|
2010-08-25 17:13:16 +00:00
|
|
|
GAtResultIter iter;
|
2011-01-06 06:28:19 +00:00
|
|
|
char const *model;
|
2010-08-25 17:13:16 +00:00
|
|
|
|
|
|
|
DBG("");
|
|
|
|
|
|
|
|
if (!ok)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
g_at_result_iter_init(&iter, result);
|
|
|
|
|
|
|
|
while (g_at_result_iter_next(&iter, NULL)) {
|
|
|
|
if (!g_at_result_iter_next_unquoted_string(&iter, &model))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (g_str_equal(model, "D5530"))
|
|
|
|
mbm_quirk_d5530(modem);
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
2011-07-22 13:24:46 +00:00
|
|
|
data->sim_state_query = at_util_sim_state_query_new(data->modem_port,
|
|
|
|
1, 5,
|
|
|
|
sim_state_cb,
|
2012-04-18 12:16:09 +00:00
|
|
|
modem, NULL);
|
2010-08-25 17:13:16 +00:00
|
|
|
}
|
|
|
|
|
2010-07-15 14:05:02 +00:00
|
|
|
static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
|
|
|
|
{
|
|
|
|
struct ofono_modem *modem = user_data;
|
2010-08-25 17:13:16 +00:00
|
|
|
struct mbm_data *data = ofono_modem_get_data(modem);
|
2010-07-15 14:05:02 +00:00
|
|
|
|
2010-05-12 01:22:38 +00:00
|
|
|
DBG("");
|
|
|
|
|
|
|
|
if (!ok) {
|
|
|
|
ofono_modem_set_powered(modem, FALSE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-08-25 17:13:16 +00:00
|
|
|
g_at_chat_send(data->modem_port, "AT+CGMM", NULL,
|
2011-01-06 06:28:19 +00:00
|
|
|
check_model, modem, NULL);
|
2010-05-12 01:22:38 +00:00
|
|
|
}
|
|
|
|
|
2009-10-29 17:50:52 +00:00
|
|
|
static void cfun_query(gboolean ok, GAtResult *result, gpointer user_data)
|
|
|
|
{
|
|
|
|
struct ofono_modem *modem = user_data;
|
|
|
|
struct mbm_data *data = ofono_modem_get_data(modem);
|
|
|
|
GAtResultIter iter;
|
|
|
|
int status;
|
|
|
|
|
2009-11-05 17:00:57 +00:00
|
|
|
DBG("%d", ok);
|
|
|
|
|
|
|
|
if (!ok)
|
|
|
|
return;
|
2009-10-29 17:50:52 +00:00
|
|
|
|
|
|
|
g_at_result_iter_init(&iter, result);
|
|
|
|
|
|
|
|
if (g_at_result_iter_next(&iter, "+CFUN:") == FALSE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_at_result_iter_next_number(&iter, &status);
|
|
|
|
|
2013-01-21 16:22:45 +00:00
|
|
|
g_at_chat_send(data->modem_port, "AT&F E0 V1 X4 &C0 +CMEE=1", NULL,
|
|
|
|
NULL, NULL, NULL);
|
|
|
|
g_at_chat_send(data->data_port, "AT&F E0 V1 X4 &C0 +CMEE=1", NULL,
|
|
|
|
NULL, NULL, NULL);
|
|
|
|
|
|
|
|
g_at_chat_send(data->modem_port, "AT*E2CFUN=1", none_prefix,
|
|
|
|
NULL, NULL, NULL);
|
|
|
|
|
2010-09-06 18:46:16 +00:00
|
|
|
if (status != 4) {
|
|
|
|
g_at_chat_send(data->modem_port, "AT+CFUN=4", none_prefix,
|
2009-10-29 17:50:52 +00:00
|
|
|
cfun_enable, modem, NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-05-12 01:22:38 +00:00
|
|
|
cfun_enable(TRUE, NULL, modem);
|
2009-10-29 17:50:52 +00:00
|
|
|
}
|
|
|
|
|
2017-11-09 03:19:03 +00:00
|
|
|
static void epev_notify(GAtResult *result, gpointer user_data)
|
|
|
|
{
|
|
|
|
struct ofono_modem *modem = user_data;
|
|
|
|
struct ofono_sim *sim = ofono_modem_get_sim(modem);
|
|
|
|
|
|
|
|
if (sim)
|
|
|
|
ofono_sim_initialized_notify(sim);
|
|
|
|
}
|
|
|
|
|
2009-10-29 17:50:52 +00:00
|
|
|
static void emrdy_notifier(GAtResult *result, gpointer user_data)
|
|
|
|
{
|
|
|
|
struct ofono_modem *modem = user_data;
|
|
|
|
struct mbm_data *data = ofono_modem_get_data(modem);
|
|
|
|
GAtResultIter iter;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
DBG("");
|
|
|
|
|
2012-08-16 16:39:22 +00:00
|
|
|
if (data->flags & MBM_FLAG_SAW_EMRDY)
|
|
|
|
return;
|
|
|
|
|
2009-10-29 17:50:52 +00:00
|
|
|
g_at_result_iter_init(&iter, result);
|
|
|
|
|
|
|
|
if (g_at_result_iter_next(&iter, "*EMRDY:") == FALSE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_at_result_iter_next_number(&iter, &status);
|
|
|
|
|
|
|
|
if (status != 1)
|
|
|
|
return;
|
|
|
|
|
2012-08-16 16:39:22 +00:00
|
|
|
data->flags |= MBM_FLAG_SAW_EMRDY;
|
|
|
|
|
2010-03-31 23:36:21 +00:00
|
|
|
g_at_chat_send(data->modem_port, "AT+CFUN?", cfun_prefix,
|
2009-10-29 17:50:52 +00:00
|
|
|
cfun_query, modem, NULL);
|
2009-09-03 02:18:41 +00:00
|
|
|
}
|
|
|
|
|
2009-11-05 17:00:57 +00:00
|
|
|
static void emrdy_query(gboolean ok, GAtResult *result, gpointer user_data)
|
|
|
|
{
|
|
|
|
struct ofono_modem *modem = user_data;
|
|
|
|
struct mbm_data *data = ofono_modem_get_data(modem);
|
|
|
|
|
|
|
|
DBG("%d", ok);
|
|
|
|
|
|
|
|
if (ok)
|
|
|
|
return;
|
|
|
|
|
2013-10-17 20:24:56 +00:00
|
|
|
/* Sometimes we query EMRDY just as the EMRDY notifier is fired */
|
|
|
|
if (data->flags & MBM_FLAG_SAW_EMRDY)
|
|
|
|
return;
|
|
|
|
|
2009-11-05 17:00:57 +00:00
|
|
|
/* On some MBM hardware the EMRDY cannot be queried, so if this fails
|
|
|
|
* we try to run CFUN? to check the state. CFUN? will fail unless
|
|
|
|
* EMRDY: 1 has been sent, in which case the emrdy_notifier should be
|
|
|
|
* triggered eventually and we send CFUN? again.
|
|
|
|
*/
|
2010-03-31 23:36:21 +00:00
|
|
|
g_at_chat_send(data->modem_port, "AT+CFUN?", cfun_prefix,
|
2009-11-05 17:00:57 +00:00
|
|
|
cfun_query, modem, NULL);
|
2012-08-16 16:20:45 +00:00
|
|
|
}
|
2009-11-05 17:00:57 +00:00
|
|
|
|
2019-05-31 16:44:54 +00:00
|
|
|
static GAtChat *open_device(struct ofono_modem *modem, const char *key,
|
|
|
|
char *debug)
|
2009-09-03 02:18:41 +00:00
|
|
|
{
|
2019-05-31 16:44:54 +00:00
|
|
|
return at_util_open_device(modem, key, mbm_debug, debug,
|
|
|
|
"Baud", "115200",
|
|
|
|
NULL);
|
2010-03-31 23:36:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int mbm_enable(struct ofono_modem *modem)
|
|
|
|
{
|
|
|
|
struct mbm_data *data = ofono_modem_get_data(modem);
|
|
|
|
const char *modem_dev;
|
|
|
|
const char *data_dev;
|
|
|
|
|
|
|
|
DBG("%p", modem);
|
|
|
|
|
|
|
|
modem_dev = ofono_modem_get_string(modem, "ModemDevice");
|
|
|
|
data_dev = ofono_modem_get_string(modem, "DataDevice");
|
|
|
|
|
|
|
|
DBG("%s, %s", modem_dev, data_dev);
|
|
|
|
|
|
|
|
if (modem_dev == NULL || data_dev == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2019-05-31 16:44:54 +00:00
|
|
|
data->modem_port = open_device(modem, "ModemDevice", "Modem: ");
|
2010-03-31 23:36:21 +00:00
|
|
|
if (data->modem_port == NULL)
|
2009-09-03 02:18:41 +00:00
|
|
|
return -EIO;
|
2009-09-02 10:19:02 +00:00
|
|
|
|
2019-05-31 16:44:54 +00:00
|
|
|
data->data_port = open_device(modem, "DataDevice", "Data: ");
|
2010-03-31 23:36:21 +00:00
|
|
|
if (data->data_port == NULL) {
|
|
|
|
g_at_chat_unref(data->modem_port);
|
|
|
|
data->modem_port = NULL;
|
2009-09-02 10:19:02 +00:00
|
|
|
|
2010-03-31 23:36:21 +00:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_at_chat_register(data->modem_port, "*EMRDY:", emrdy_notifier,
|
2009-10-29 17:50:52 +00:00
|
|
|
FALSE, modem, NULL);
|
|
|
|
|
2010-03-31 23:36:21 +00:00
|
|
|
g_at_chat_send(data->modem_port, "AT*EMRDY?", none_prefix,
|
2009-11-05 17:00:57 +00:00
|
|
|
emrdy_query, modem, NULL);
|
2009-09-02 10:19:02 +00:00
|
|
|
|
2017-11-09 03:19:03 +00:00
|
|
|
g_at_chat_send(data->modem_port, "AT*EPEE=1", NULL, NULL, NULL, NULL);
|
|
|
|
g_at_chat_register(data->modem_port, "*EPEV", epev_notify,
|
|
|
|
FALSE, modem, NULL);
|
|
|
|
|
2009-10-29 17:50:28 +00:00
|
|
|
return -EINPROGRESS;
|
2009-09-02 10:19:02 +00:00
|
|
|
}
|
|
|
|
|
2009-09-03 02:18:41 +00:00
|
|
|
static void cfun_disable(gboolean ok, GAtResult *result, gpointer user_data)
|
2009-09-02 10:19:02 +00:00
|
|
|
{
|
2009-09-03 02:18:41 +00:00
|
|
|
struct ofono_modem *modem = user_data;
|
2009-11-18 18:08:26 +00:00
|
|
|
struct mbm_data *data = ofono_modem_get_data(modem);
|
2009-09-02 10:19:02 +00:00
|
|
|
|
2009-09-03 02:18:41 +00:00
|
|
|
DBG("");
|
2009-09-02 10:19:02 +00:00
|
|
|
|
2010-03-31 23:36:21 +00:00
|
|
|
g_at_chat_unref(data->modem_port);
|
|
|
|
data->modem_port = NULL;
|
|
|
|
|
|
|
|
g_at_chat_unref(data->data_port);
|
|
|
|
data->data_port = NULL;
|
2009-11-18 18:08:26 +00:00
|
|
|
|
2009-09-03 02:18:41 +00:00
|
|
|
if (ok)
|
|
|
|
ofono_modem_set_powered(modem, FALSE);
|
2009-09-02 10:19:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int mbm_disable(struct ofono_modem *modem)
|
|
|
|
{
|
|
|
|
struct mbm_data *data = ofono_modem_get_data(modem);
|
|
|
|
|
2009-09-03 02:04:21 +00:00
|
|
|
DBG("%p", modem);
|
2009-09-02 10:19:02 +00:00
|
|
|
|
2010-11-27 19:39:02 +00:00
|
|
|
if (data->modem_port == NULL)
|
2009-09-02 10:19:02 +00:00
|
|
|
return 0;
|
|
|
|
|
2010-03-31 23:36:21 +00:00
|
|
|
g_at_chat_cancel_all(data->modem_port);
|
|
|
|
g_at_chat_unregister_all(data->modem_port);
|
2011-07-24 13:27:00 +00:00
|
|
|
|
2010-03-31 23:36:21 +00:00
|
|
|
g_at_chat_send(data->modem_port, "AT+CFUN=4", NULL,
|
2009-09-03 02:18:41 +00:00
|
|
|
cfun_disable, modem, NULL);
|
2009-09-02 10:19:02 +00:00
|
|
|
|
2009-10-29 17:50:28 +00:00
|
|
|
return -EINPROGRESS;
|
2009-09-02 10:19:02 +00:00
|
|
|
}
|
|
|
|
|
2010-09-06 18:46:16 +00:00
|
|
|
static void set_online_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
|
|
|
{
|
|
|
|
struct cb_data *cbd = user_data;
|
|
|
|
ofono_modem_online_cb_t cb = cbd->cb;
|
2011-06-27 14:58:02 +00:00
|
|
|
struct ofono_error error;
|
2010-09-06 18:46:16 +00:00
|
|
|
|
2011-06-27 14:58:02 +00:00
|
|
|
decode_at_error(&error, g_at_result_final_response(result));
|
|
|
|
cb(&error, cbd->data);
|
2010-09-06 18:46:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void mbm_set_online(struct ofono_modem *modem, ofono_bool_t online,
|
|
|
|
ofono_modem_online_cb_t cb, void *user_data)
|
|
|
|
{
|
|
|
|
struct mbm_data *data = ofono_modem_get_data(modem);
|
|
|
|
GAtChat *chat = data->modem_port;
|
|
|
|
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");
|
|
|
|
|
2011-07-24 13:27:00 +00:00
|
|
|
if (g_at_chat_send(chat, command, none_prefix,
|
|
|
|
set_online_cb, cbd, g_free) > 0)
|
2010-09-06 18:46:16 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
CALLBACK_WITH_FAILURE(cb, cbd->data);
|
2011-07-24 13:27:00 +00:00
|
|
|
|
|
|
|
g_free(cbd);
|
2010-09-06 18:46:16 +00:00
|
|
|
}
|
|
|
|
|
2009-09-17 15:15:34 +00:00
|
|
|
static void mbm_pre_sim(struct ofono_modem *modem)
|
2009-09-02 10:19:02 +00:00
|
|
|
{
|
|
|
|
struct mbm_data *data = ofono_modem_get_data(modem);
|
2010-04-09 06:48:50 +00:00
|
|
|
struct ofono_sim *sim;
|
2009-09-02 10:19:02 +00:00
|
|
|
|
2009-09-03 02:04:21 +00:00
|
|
|
DBG("%p", modem);
|
2009-09-02 10:19:02 +00:00
|
|
|
|
2010-03-31 23:36:21 +00:00
|
|
|
ofono_devinfo_create(modem, 0, "atmodem", data->modem_port);
|
2010-08-20 12:09:55 +00:00
|
|
|
sim = ofono_sim_create(modem, OFONO_VENDOR_MBM,
|
|
|
|
"atmodem", data->modem_port);
|
2010-04-09 06:48:50 +00:00
|
|
|
|
2012-08-16 16:39:22 +00:00
|
|
|
if ((data->flags & MBM_FLAG_HAVE_SIM) && sim)
|
2010-04-09 06:48:50 +00:00
|
|
|
ofono_sim_inserted_notify(sim, TRUE);
|
2009-09-17 15:15:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void mbm_post_sim(struct ofono_modem *modem)
|
|
|
|
{
|
|
|
|
struct mbm_data *data = ofono_modem_get_data(modem);
|
|
|
|
|
|
|
|
DBG("%p", modem);
|
|
|
|
|
2010-06-17 13:42:12 +00:00
|
|
|
ofono_stk_create(modem, 0, "mbmmodem", data->modem_port);
|
2011-01-31 08:30:51 +00:00
|
|
|
ofono_radio_settings_create(modem, 0, "stemodem", data->modem_port);
|
2011-01-29 09:28:47 +00:00
|
|
|
|
|
|
|
ofono_sms_create(modem, 0, "atmodem", data->modem_port);
|
2017-11-09 17:52:17 +00:00
|
|
|
ofono_sim_auth_create(modem);
|
2010-09-06 18:46:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void mbm_post_online(struct ofono_modem *modem)
|
|
|
|
{
|
|
|
|
struct mbm_data *data = ofono_modem_get_data(modem);
|
2011-07-24 13:27:00 +00:00
|
|
|
struct ofono_gprs *gprs;
|
2010-09-06 18:46:16 +00:00
|
|
|
struct ofono_gprs_context *gc;
|
2011-02-22 18:35:13 +00:00
|
|
|
const char *gps_dev;
|
2010-09-06 18:46:16 +00:00
|
|
|
|
|
|
|
DBG("%p", modem);
|
2010-06-17 13:42:12 +00:00
|
|
|
|
2011-02-22 18:35:13 +00:00
|
|
|
gps_dev = ofono_modem_get_string(modem, "GPSDevice");
|
|
|
|
if (gps_dev)
|
|
|
|
data->lr = ofono_location_reporting_create(modem, 0,
|
|
|
|
"mbmmodem", data->modem_port);
|
|
|
|
|
2010-08-20 12:09:55 +00:00
|
|
|
ofono_netreg_create(modem, OFONO_VENDOR_MBM,
|
|
|
|
"atmodem", data->modem_port);
|
2010-06-15 12:16:43 +00:00
|
|
|
|
2010-08-25 17:13:16 +00:00
|
|
|
switch (data->variant) {
|
2010-10-26 23:18:42 +00:00
|
|
|
case MBM_GENERIC:
|
|
|
|
ofono_cbs_create(modem, 0, "atmodem", data->modem_port);
|
|
|
|
break;
|
2010-08-25 17:13:16 +00:00
|
|
|
case MBM_DELL_D5530:
|
|
|
|
/* DELL D5530 crashes when it processes CBSs */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-06-15 12:16:43 +00:00
|
|
|
ofono_ussd_create(modem, 0, "atmodem", data->modem_port);
|
2010-03-31 23:36:21 +00:00
|
|
|
|
2011-07-24 13:27:00 +00:00
|
|
|
gprs = ofono_gprs_create(modem, OFONO_VENDOR_MBM,
|
2010-08-20 12:09:55 +00:00
|
|
|
"atmodem", data->modem_port);
|
2011-07-24 13:27:00 +00:00
|
|
|
if (gprs == NULL)
|
2010-10-26 23:17:10 +00:00
|
|
|
return;
|
|
|
|
|
2010-08-20 12:12:01 +00:00
|
|
|
gc = ofono_gprs_context_create(modem, 0,
|
|
|
|
"mbmmodem", data->modem_port);
|
2010-10-27 09:37:17 +00:00
|
|
|
if (gc) {
|
2010-10-27 09:53:13 +00:00
|
|
|
ofono_gprs_context_set_type(gc,
|
2010-10-27 09:37:17 +00:00
|
|
|
OFONO_GPRS_CONTEXT_TYPE_INTERNET);
|
2011-07-24 13:27:00 +00:00
|
|
|
ofono_gprs_add_context(gprs, gc);
|
2010-10-27 09:37:17 +00:00
|
|
|
}
|
2009-10-23 20:17:33 +00:00
|
|
|
|
2011-07-24 13:27:00 +00:00
|
|
|
gc = ofono_gprs_context_create(modem, 0,
|
2010-10-26 23:17:10 +00:00
|
|
|
"atmodem", data->data_port);
|
2011-07-24 13:27:00 +00:00
|
|
|
if (gc) {
|
|
|
|
ofono_gprs_context_set_type(gc,
|
2010-10-27 09:37:17 +00:00
|
|
|
OFONO_GPRS_CONTEXT_TYPE_MMS);
|
2011-07-24 13:27:00 +00:00
|
|
|
ofono_gprs_add_context(gprs, gc);
|
2010-10-27 09:37:17 +00:00
|
|
|
}
|
2009-09-02 10:19:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct ofono_modem_driver mbm_driver = {
|
|
|
|
.name = "mbm",
|
|
|
|
.probe = mbm_probe,
|
|
|
|
.remove = mbm_remove,
|
|
|
|
.enable = mbm_enable,
|
|
|
|
.disable = mbm_disable,
|
2011-08-09 17:30:01 +00:00
|
|
|
.set_online = mbm_set_online,
|
2009-09-17 15:15:34 +00:00
|
|
|
.pre_sim = mbm_pre_sim,
|
|
|
|
.post_sim = mbm_post_sim,
|
2011-08-09 17:30:01 +00:00
|
|
|
.post_online = mbm_post_online,
|
2009-09-02 10:19:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int mbm_init(void)
|
|
|
|
{
|
|
|
|
return ofono_modem_driver_register(&mbm_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mbm_exit(void)
|
|
|
|
{
|
|
|
|
ofono_modem_driver_unregister(&mbm_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
OFONO_PLUGIN_DEFINE(mbm, "Ericsson MBM modem driver", VERSION,
|
|
|
|
OFONO_PLUGIN_PRIORITY_DEFAULT, mbm_init, mbm_exit)
|