mirror of git://git.sysmocom.de/ofono
dunmodem: Add support for dialup network registration
This commit is contained in:
parent
a159a0f9fc
commit
5a3a691199
|
@ -247,7 +247,8 @@ builtin_sources += drivers/atmodem/atutil.h \
|
||||||
builtin_modules += dunmodem
|
builtin_modules += dunmodem
|
||||||
builtin_sources += drivers/atmodem/atutil.h \
|
builtin_sources += drivers/atmodem/atutil.h \
|
||||||
drivers/dunmodem/dunmodem.h \
|
drivers/dunmodem/dunmodem.h \
|
||||||
drivers/dunmodem/dunmodem.c
|
drivers/dunmodem/dunmodem.c \
|
||||||
|
drivers/dunmodem/network-registration.c
|
||||||
|
|
||||||
builtin_modules += hfpmodem
|
builtin_modules += hfpmodem
|
||||||
builtin_sources += drivers/atmodem/atutil.h \
|
builtin_sources += drivers/atmodem/atutil.h \
|
||||||
|
|
|
@ -34,11 +34,14 @@
|
||||||
|
|
||||||
static int dunmodem_init(void)
|
static int dunmodem_init(void)
|
||||||
{
|
{
|
||||||
|
dun_netreg_init();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dunmodem_exit(void)
|
static void dunmodem_exit(void)
|
||||||
{
|
{
|
||||||
|
dun_netreg_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
OFONO_PLUGIN_DEFINE(dunmodem, "Dialup modem driver", VERSION,
|
OFONO_PLUGIN_DEFINE(dunmodem, "Dialup modem driver", VERSION,
|
||||||
|
|
|
@ -20,3 +20,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <drivers/atmodem/atutil.h>
|
#include <drivers/atmodem/atutil.h>
|
||||||
|
|
||||||
|
extern void dun_netreg_init(void);
|
||||||
|
extern void dun_netreg_exit(void);
|
||||||
|
|
|
@ -0,0 +1,126 @@
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* oFono - Open Source Telephony
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||||
|
*
|
||||||
|
* 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 <errno.h>
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <gatchat.h>
|
||||||
|
#include <gatresult.h>
|
||||||
|
|
||||||
|
#include <ofono/log.h>
|
||||||
|
#include <ofono/modem.h>
|
||||||
|
#include <ofono/netreg.h>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
#include "dunmodem.h"
|
||||||
|
|
||||||
|
static const char *cops_prefix[] = { "+COPS:", NULL };
|
||||||
|
|
||||||
|
struct netreg_data {
|
||||||
|
GAtChat *chat;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void dun_registration_status(struct ofono_netreg *netreg,
|
||||||
|
ofono_netreg_status_cb_t cb, void *data)
|
||||||
|
{
|
||||||
|
int status = NETWORK_REGISTRATION_STATUS_REGISTERED;
|
||||||
|
|
||||||
|
DBG("");
|
||||||
|
|
||||||
|
CALLBACK_WITH_SUCCESS(cb, status, -1, -1, -1, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dun_current_operator(struct ofono_netreg *netreg,
|
||||||
|
ofono_netreg_operator_cb_t cb, void *data)
|
||||||
|
{
|
||||||
|
struct ofono_network_operator op;
|
||||||
|
|
||||||
|
DBG("");
|
||||||
|
|
||||||
|
op.name[0] = '\0';
|
||||||
|
op.mcc[0] = '\0';
|
||||||
|
op.mnc[0] = '\0';
|
||||||
|
op.status = 2;
|
||||||
|
op.tech = -1;
|
||||||
|
|
||||||
|
CALLBACK_WITH_SUCCESS(cb, &op, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void cops_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
||||||
|
{
|
||||||
|
struct ofono_netreg *netreg = user_data;
|
||||||
|
|
||||||
|
if (!ok)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ofono_netreg_register(netreg);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int dun_netreg_probe(struct ofono_netreg *netreg,
|
||||||
|
unsigned int vendor, void *user_data)
|
||||||
|
{
|
||||||
|
GAtChat *chat = user_data;
|
||||||
|
struct netreg_data *nd;
|
||||||
|
|
||||||
|
nd = g_try_new0(struct netreg_data, 1);
|
||||||
|
if (nd == NULL)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
nd->chat = g_at_chat_clone(chat);
|
||||||
|
|
||||||
|
ofono_netreg_set_data(netreg, nd);
|
||||||
|
|
||||||
|
g_at_chat_send(nd->chat, "AT+COPS=0", cops_prefix,
|
||||||
|
cops_cb, netreg, NULL);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dun_netreg_remove(struct ofono_netreg *netreg)
|
||||||
|
{
|
||||||
|
struct netreg_data *nd = ofono_netreg_get_data(netreg);
|
||||||
|
|
||||||
|
ofono_netreg_set_data(netreg, NULL);
|
||||||
|
|
||||||
|
g_free(nd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct ofono_netreg_driver driver = {
|
||||||
|
.name = "dunmodem",
|
||||||
|
.probe = dun_netreg_probe,
|
||||||
|
.remove = dun_netreg_remove,
|
||||||
|
.registration_status = dun_registration_status,
|
||||||
|
.current_operator = dun_current_operator,
|
||||||
|
};
|
||||||
|
|
||||||
|
void dun_netreg_init(void)
|
||||||
|
{
|
||||||
|
ofono_netreg_driver_register(&driver);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dun_netreg_exit(void)
|
||||||
|
{
|
||||||
|
ofono_netreg_driver_unregister(&driver);
|
||||||
|
}
|
Loading…
Reference in New Issue