From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 7/9] ubloxmodem: add lte atom driver
Date: Wed, 09 Nov 2016 14:43:58 -0600 [thread overview]
Message-ID: <58238A8E.50402@gmail.com> (raw)
In-Reply-To: <1478713402-30780-8-git-send-email-dragos@endocode.com>
[-- Attachment #1: Type: text/plain, Size: 5419 bytes --]
Hi Dragos,
On 11/09/2016 11:43 AM, Dragos Tatulea wrote:
> Adds U-Blox Toby L2 driver for setting the default APN via the
> +UCGDFLT command. Currently only IPv4 is supported. APN is
> not stored to modem's non-volatile memory. oFono will manage this
> default APN via it's config storage.
>
> When receiving an empty default APN, the value is reset.
> ---
> drivers/ubloxmodem/lte.c | 125 ++++++++++++++++++++++++++++++++++++++++
> drivers/ubloxmodem/ubloxmodem.c | 3 +
> drivers/ubloxmodem/ubloxmodem.h | 5 ++
> 3 files changed, 133 insertions(+)
> create mode 100644 drivers/ubloxmodem/lte.c
>
> diff --git a/drivers/ubloxmodem/lte.c b/drivers/ubloxmodem/lte.c
> new file mode 100644
> index 0000000..8210329
> --- /dev/null
> +++ b/drivers/ubloxmodem/lte.c
> @@ -0,0 +1,125 @@
> +/*
> + *
> + * oFono - Open Source Telephony
> + *
> + * Copyright (C) 2016 Endocode AG. 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
> +
> +#define _GNU_SOURCE
> +#include <stdlib.h>
> +#include <stdio.h>
> +#include <string.h>
> +#include <errno.h>
> +
> +#include <glib.h>
> +
> +#include <ofono/modem.h>
> +#include <ofono/gprs-context.h>
> +#include <ofono/log.h>
> +#include <ofono/lte.h>
> +
> +#include "gatchat.h"
> +#include "gatresult.h"
> +
> +#include "ubloxmodem.h"
> +
> +struct lte_driver_data {
> + GAtChat *chat;
> +};
> +
> +static int ublox_lte_config(struct ofono_lte *lte,
> + struct ofono_lte_context_config *config,
> + ofono_lte_cb_t cb, void *data)
> +{
> + struct lte_driver_data *ldd = ofono_lte_get_data(lte);
> + char buf[32 + OFONO_GPRS_MAX_APN_LENGTH + 1];
> +
> + DBG("LTE config with APN: %s", config->apn);
> +
> + if (strlen(config->apn) > 0)
> + snprintf(buf, sizeof(buf), "AT+UCGDFLT=0,\"IP\",\"%s\"", config->apn);
> + else
> + snprintf(buf, sizeof(buf), "AT+UCGDFLT=0");
> +
> + /* We can't do much in case of failure so don't check response. */
> + g_at_chat_send(ldd->chat, buf, NULL, NULL, NULL, NULL);
Core is providing a callback, so you have to do something with it.
> +
> + return 0;
> +}
> +
> +static gboolean lte_delayed_register(gpointer user_data)
> +{
> + struct ofono_lte *lte = user_data;
> +
> + ofono_lte_register(lte);
> +
> + return FALSE;
> +}
> +
> +static int ublox_lte_probe(struct ofono_lte *lte, void *data)
> +{
> + GAtChat *chat = data;
> + struct lte_driver_data *ldd;
> +
> + DBG("ublox lte probe");
> +
> + ldd = g_try_new0(struct lte_driver_data, 1);
> + if (!ldd) {
> + return -ENOMEM;
> + }
No need for {}
> +
> + ldd->chat = g_at_chat_clone(chat);
> +
> + ofono_lte_set_data(lte, ldd);
> +
> + g_idle_add(lte_delayed_register, lte);
> +
> + return 0;
> +}
> +
> +static void ublox_lte_remove(struct ofono_lte *lte)
> +{
> + struct lte_driver_data *ldd = ofono_lte_get_data(lte);
> +
> + DBG("ublox lte remove");
> +
> + g_at_chat_unref(ldd->chat);
> +
> + ofono_lte_set_data(lte, NULL);
> +
> + g_free(ldd);
> +}
> +
> +static struct ofono_lte_driver driver = {
> + .name = UBLOXMODEM,
> + .probe = ublox_lte_probe,
> + .remove = ublox_lte_remove,
> + .config = ublox_lte_config,
> +};
> +
> +void ublox_lte_init(void)
> +{
> + ofono_lte_driver_register(&driver);
> +}
> +
> +void ublox_lte_exit(void)
> +{
> + ofono_lte_driver_unregister(&driver);
> +}
> diff --git a/drivers/ubloxmodem/ubloxmodem.c b/drivers/ubloxmodem/ubloxmodem.c
> index 7fc671e..93cb928 100644
> --- a/drivers/ubloxmodem/ubloxmodem.c
> +++ b/drivers/ubloxmodem/ubloxmodem.c
> @@ -29,12 +29,14 @@
> #define OFONO_API_SUBJECT_TO_CHANGE
> #include <ofono/plugin.h>
> #include <ofono/types.h>
> +#include <ofono/modem.h>
>
> #include "ubloxmodem.h"
>
> static int ubloxmodem_init(void)
> {
> ublox_gprs_context_init();
> + ublox_lte_init();
>
> return 0;
> }
> @@ -42,6 +44,7 @@ static int ubloxmodem_init(void)
> static void ubloxmodem_exit(void)
> {
> ublox_gprs_context_exit();
> + ublox_lte_exit();
> }
>
> OFONO_PLUGIN_DEFINE(ubloxmodem, "U-Blox Toby L2 high speed modem driver",
> diff --git a/drivers/ubloxmodem/ubloxmodem.h b/drivers/ubloxmodem/ubloxmodem.h
> index 0c8a621..cf66412 100644
> --- a/drivers/ubloxmodem/ubloxmodem.h
> +++ b/drivers/ubloxmodem/ubloxmodem.h
> @@ -21,5 +21,10 @@
>
> #include <drivers/atmodem/atutil.h>
>
> +#define UBLOXMODEM "ubloxmodem"
> +
> extern void ublox_gprs_context_init(void);
> extern void ublox_gprs_context_exit(void);
> +
> +extern void ublox_lte_init(void);
> +extern void ublox_lte_exit(void);
>
Regards,
-Denis
next prev parent reply other threads:[~2016-11-09 20:43 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-09 17:43 [PATCH 0/9] RFC: add LTE atom Dragos Tatulea
2016-11-09 17:43 ` [PATCH 1/9] include: add header file for lte atom Dragos Tatulea
2016-11-09 20:19 ` Denis Kenzior
2016-11-09 17:43 ` [PATCH 2/9] src: ofono.h: add LTE atom define Dragos Tatulea
2016-11-09 20:20 ` Denis Kenzior
2016-11-09 17:43 ` [PATCH 3/9] lte: add implementation for LTE atom Dragos Tatulea
2016-11-09 20:37 ` Denis Kenzior
2016-11-09 17:43 ` [PATCH 4/9] build: add lte atom support Dragos Tatulea
2016-11-09 17:43 ` [PATCH 5/9] test: add script for setting lte atom properties Dragos Tatulea
2016-11-09 17:43 ` [PATCH 6/9] doc: add lte atom documentation Dragos Tatulea
2016-11-09 20:41 ` Denis Kenzior
2016-11-09 17:43 ` [PATCH 7/9] ubloxmodem: add lte atom driver Dragos Tatulea
2016-11-09 20:43 ` Denis Kenzior [this message]
2016-11-09 17:43 ` [PATCH 8/9] build: add support for ublox " Dragos Tatulea
2016-11-09 17:43 ` [PATCH 9/9] plugins: ublox: enable lte driver for tobyl2 Dragos Tatulea
-- strict thread matches above, loose matches on Subject: below --
2016-11-10 16:55 [PATCH v2 0/9] add LTE atom Dragos Tatulea
2016-11-10 16:55 ` [PATCH 7/9] ubloxmodem: add lte atom driver Dragos Tatulea
2016-11-11 16:58 ` Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=58238A8E.50402@gmail.com \
--to=denkenz@gmail.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox