[PATCH 5/7] cdmamodem: Add Signal Strength Support
by Dara Spieker-Doyle
---
Makefile.am | 3 +-
drivers/cdmamodem/cdmamodem.c | 2 +
drivers/cdmamodem/cdmamodem.h | 2 +
drivers/cdmamodem/network-registration.c | 211 ++++++++++++++++++++++++++++++
4 files changed, 217 insertions(+), 1 deletions(-)
create mode 100644 drivers/cdmamodem/network-registration.c
diff --git a/Makefile.am b/Makefile.am
index c245b4c..272e28d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -257,7 +257,8 @@ builtin_modules += cdmamodem
builtin_sources += drivers/cdmamodem/cdmamodem.h \
drivers/cdmamodem/cdmamodem.c \
drivers/cdmamodem/voicecall.c \
- drivers/cdmamodem/devinfo.c
+ drivers/cdmamodem/devinfo.c \
+ drivers/cdmamodem/network-registration.c
endif
builtin_modules += g1
diff --git a/drivers/cdmamodem/cdmamodem.c b/drivers/cdmamodem/cdmamodem.c
index 9eddd88..492f1f0 100644
--- a/drivers/cdmamodem/cdmamodem.c
+++ b/drivers/cdmamodem/cdmamodem.c
@@ -36,6 +36,7 @@ static int cdmamodem_init(void)
{
cdma_voicecall_init();
cdma_devinfo_init();
+ cdma_netreg_init();
return 0;
}
@@ -44,6 +45,7 @@ static void cdmamodem_exit(void)
{
cdma_voicecall_exit();
cdma_devinfo_exit();
+ cdma_netreg_exit();
}
OFONO_PLUGIN_DEFINE(cdmamodem, "CDMA AT modem driver", VERSION,
diff --git a/drivers/cdmamodem/cdmamodem.h b/drivers/cdmamodem/cdmamodem.h
index 4365bec..a1fbf65 100644
--- a/drivers/cdmamodem/cdmamodem.h
+++ b/drivers/cdmamodem/cdmamodem.h
@@ -25,3 +25,5 @@ extern void cdma_voicecall_init(void);
extern void cdma_voicecall_exit(void);
extern void cdma_devinfo_init(void);
extern void cdma_devinfo_exit(void);
+extern void cdma_netreg_init(void);
+extern void cdma_netreg_exit(void);
diff --git a/drivers/cdmamodem/network-registration.c b/drivers/cdmamodem/network-registration.c
new file mode 100644
index 0000000..4135fe1
--- /dev/null
+++ b/drivers/cdmamodem/network-registration.c
@@ -0,0 +1,211 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2011 Nokia 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
+
+#define _GNU_SOURCE
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <glib.h>
+
+#include <ofono/log.h>
+#include <ofono/modem.h>
+#include <ofono/cdma-netreg.h>
+
+#include "gatchat.h"
+#include "gatresult.h"
+
+#include "cdmamodem.h"
+
+/* Time interval in seconds between CSQ polls */
+#define CSQ_INTERVAL 5
+
+struct cdma_netreg_data {
+ GAtChat *chat;
+ unsigned int vendor;
+ unsigned int csq_source;
+};
+
+static gboolean cdma_get_next_number(const char *line, gint *number)
+{
+ int pos;
+ int end;
+ int len;
+ int value = 0;
+
+ len = strlen(line);
+
+ pos = 0;
+ end = pos;
+
+ while (line[end] >= '0' && line[end] <= '9') {
+ value = value * 10 + (int)(line[end] - '0');
+ end += 1;
+ }
+
+ if (pos == end)
+ return FALSE;
+
+ pos = skip_to_next_field(line, end, len);
+
+ if (number)
+ *number = value;
+
+ return TRUE;
+}
+
+static void cdma_csq_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ ofono_cdma_netreg_strength_cb_t cb = cbd->cb;
+ const char *prefix = cbd->user;
+ struct ofono_error error;
+ const char *attr;
+ int strength = -1;
+
+ decode_at_error(&error, g_at_result_final_response(result));
+
+ if (!ok) {
+ cb(&error, -1, cbd->data);
+ return;
+ }
+
+ if (at_util_parse_attr(result, prefix, &attr) == FALSE) {
+ CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
+ return;
+ }
+
+ cdma_get_next_number(attr, &strength);
+
+ DBG("csq_cb: %d", strength);
+
+ cb(&error, at_util_convert_signal_strength(strength), cbd->data);
+}
+
+static void cdma_signal_strength(struct ofono_cdma_netreg *netreg,
+ ofono_cdma_netreg_strength_cb_t cb, void *data)
+{
+ struct cdma_netreg_data *nd = ofono_cdma_netreg_get_data(netreg);
+ struct cb_data *cbd = cb_data_new(cb, data);
+
+ cbd->user = "AT+CSQ";
+
+ if (g_at_chat_send(nd->chat, "AT+CSQ", NULL,
+ cdma_csq_cb, cbd, g_free) > 0)
+ return;
+
+ g_free(cbd);
+
+ CALLBACK_WITH_FAILURE(cb, -1, data);
+}
+
+static gboolean cdma_poll_csq(gpointer user_data);
+
+static void cdma_poll_csq_cb(const struct ofono_error *error, int strength,
+ void *data)
+{
+ struct ofono_cdma_netreg *netreg = data;
+ struct cdma_netreg_data *nd = ofono_cdma_netreg_get_data(netreg);
+
+ if(error->type == OFONO_ERROR_TYPE_NO_ERROR)
+ ofono_cdma_netreg_strength_notify(netreg, strength);
+
+ /* Initiate the next poll */
+ nd->csq_source = g_timeout_add_seconds(CSQ_INTERVAL, cdma_poll_csq, netreg);
+}
+
+static gboolean cdma_poll_csq(gpointer user_data)
+{
+ struct ofono_cdma_netreg *netreg = user_data;
+ struct cdma_netreg_data *nd = ofono_cdma_netreg_get_data(netreg);
+ struct cb_data *cbd = cb_data_new(cdma_poll_csq_cb, netreg);
+
+ cbd->user = "AT+CSQ";
+
+ g_at_chat_send(nd->chat, "AT+CSQ", NULL, cdma_csq_cb, cbd, g_free);
+
+ nd->csq_source = 0;
+
+ return FALSE;
+}
+
+static gboolean cdma_netreg_register(gpointer user_data)
+{
+ struct ofono_cdma_netreg *netreg = user_data;
+ struct cdma_netreg_data *nd = ofono_cdma_netreg_get_data(netreg);
+
+ ofono_cdma_netreg_register(netreg);
+
+ nd->csq_source = g_timeout_add_seconds(CSQ_INTERVAL, cdma_poll_csq, netreg);
+
+ return FALSE;
+}
+
+static int cdma_netreg_probe(struct ofono_cdma_netreg *netreg,
+ unsigned int vendor, void *data)
+{
+ GAtChat *chat = data;
+ struct cdma_netreg_data *nd;
+
+ nd = g_new0(struct cdma_netreg_data, 1);
+
+ nd->chat = g_at_chat_clone(chat);
+ nd->vendor = vendor;
+
+ ofono_cdma_netreg_set_data(netreg, nd);
+ g_idle_add(cdma_netreg_register, netreg);
+
+ return 0;
+}
+
+static void cdma_netreg_remove(struct ofono_cdma_netreg *netreg)
+{
+ struct cdma_netreg_data *nd = ofono_cdma_netreg_get_data(netreg);
+
+ if (nd->csq_source)
+ g_source_remove(nd->csq_source);
+
+ ofono_cdma_netreg_set_data(netreg, NULL);
+
+ g_at_chat_unref(nd->chat);
+ g_free(nd);
+}
+
+static struct ofono_cdma_netreg_driver driver = {
+ .name = "cdmamodem",
+ .probe = cdma_netreg_probe,
+ .remove = cdma_netreg_remove,
+ .strength = cdma_signal_strength,
+};
+
+void cdma_netreg_init(void)
+{
+ ofono_cdma_netreg_driver_register(&driver);
+}
+
+void cdma_netreg_exit(void)
+{
+ ofono_cdma_netreg_driver_unregister(&driver);
+}
--
1.7.0.4
11 years, 7 months
[PATCH] doc: Assisted Satellite Navigation API and Agent API
by Sjur Brændeland
From: Simon Lethbridge <simon.lethbridge(a)stericsson.com>
This patch introduces support for Global Satellite Navigation System (GNSS),
using the AT commands AT+CPOS and +CPOSR as specified 3GPP 27.007.
---
Hi Denis,
2010/11/30 Denis Kenzior <denkenz(a)gmail.com>:
>> +AssistedSatelliteNavigation hierarchy
>What do you think of naming this AssistedNavigation? I think the
>current name might be a bit too long.
See mail previous mail on this topic, I think we'd like to keep
it as is for now.
>> +Methods void SendPositioningControl(string xml_element)
>What do you think of SendPositioningElement?
Fixed,
>> +Methods void PositioningRequest(string xml_element)
>I think that 'Request' will be sufficient. Positioning is already part
>of the agent name.
Fixed,
>> + void AssistanceDataReset()
>I suggest ResetAssistanceData here.
Fixed,
>The only other change I'd make is to mark the entire interface
>'experimental', but I can take care of that as well.
Fixed,
>Otherwise the proposal looks good to me.
Sorry for taking so long before responding on this.
Let us know if you have any issues with this patch.
Regards,
Sjur and Simon.
doc/assisted-sattelite-navigation.txt | 56 +++++++++++++++++++++++++++++++++
1 files changed, 56 insertions(+), 0 deletions(-)
create mode 100644 doc/assisted-sattelite-navigation.txt
diff --git a/doc/assisted-sattelite-navigation.txt b/doc/assisted-sattelite-navigation.txt
new file mode 100644
index 0000000..abacf54
--- /dev/null
+++ b/doc/assisted-sattelite-navigation.txt
@@ -0,0 +1,56 @@
+Assisted Satellite Navigation hierarchy [experimental]
+==========================================================
+
+Service org.ofono
+Interface org.ofono.AssistedSatelliteNavigation
+Object path [variable prefix]/{modem0,modem1,...}
+
+Methods void SendPositioningElement(string xml_element)
+
+ Send an XML element conforming to the XML DTD for <pos>
+ as defined in 3GPP 27.007 Table 8.55-2. This xml is
+ used for transferring data associated with positioning
+ requests received via control plane from the network.
+ This includes assistance data requests and the results
+ of positioning procedures. This method maps directly to
+ the 3GPP 27.007 AT+CPOS command.
+
+ void RegisterPositioningRequestAgent(object path)
+
+ Registers an agent which will be called whenever a
+ CPOSR AT response is received. The Agent must respond
+ to requests using SendPositioningControl.
+
+ void UnregisterPositioningRequestAgent(object path)
+
+ Un-registers the agent.
+
+PositioningRequestAgent hierarchy
+==================================
+
+Service unique name
+Interface org.ofono.PositioningRequestAgent
+Object path freely definable
+
+Methods void Request(string xml_element)
+
+ Receive an XML element conforming to the XML DTD for
+ <pos> in 3GPP 27.007. This xml is used for transferring
+ data associated with positioning requests received, via
+ control plane, from the network. This includes
+ measurement requests and assistance data. This method
+ maps directly to the 3GPP defined +CPOSR unsolicited
+ result code.
+
+ void ResetAssistanceData()
+
+ A request has been received from the network that all
+ assistance data should be reset. This is used for 3gpp
+ performance tests.
+
+ void Release()
+
+ Agent is being released, possibly because of oFono
+ terminating, AssistedSatelliteNavigation interface
+ is being torn down or modem off.
+ No UnregisterAgent call is needed.
--
1.7.0.4
11 years, 7 months
[PATCH 0/3 v5] Network Time Plugin
by Antti Paila
This series of patches introduces the network time part of
the NITZ feature as outlined in 3GPP spec 22.042.
The plugin is for delivering network indicated time information
to timed process which is responsible for maintaining the system
time. The delivery is achieved by timed implementing an interface
with a method that is called by the nettime plugin with time related
info as a parameter of the method.
Antti Paila (3):
nettime: Network time plugin implementation
nettime: Makefile.am modification
nettime: Mock Timed for testing
Makefile.am | 6 +-
plugins/meego-nettime.c | 321 +++++++++++++++++++++++++++++++++++++++++++++++
test/test-nettime | 35 +++++
3 files changed, 361 insertions(+), 1 deletions(-)
create mode 100644 plugins/meego-nettime.c
create mode 100755 test/test-nettime
11 years, 7 months
[PATCH 1/7] gprs: remove RoamingAllowed property
by Rémi Denis-Courmont
No roaming policies need to be enforced per GPRS context rather than
for the whole GPRS service. Otherwise, you would not be able to receive
an MMS or even register to the IMS SIP while roaming.
---
src/gprs.c | 52 +++-------------------------------------------------
1 files changed, 3 insertions(+), 49 deletions(-)
diff --git a/src/gprs.c b/src/gprs.c
index 33711dc..ee66b2a 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -76,7 +76,6 @@ struct ofono_gprs {
GSList *contexts;
ofono_bool_t attached;
ofono_bool_t driver_attached;
- ofono_bool_t roaming_allowed;
ofono_bool_t powered;
ofono_bool_t suspended;
int status;
@@ -1427,10 +1426,8 @@ static void gprs_netreg_update(struct ofono_gprs *gprs)
{
ofono_bool_t attach;
- attach = gprs->netreg_status == NETWORK_REGISTRATION_STATUS_REGISTERED;
-
- attach = attach || (gprs->roaming_allowed &&
- gprs->netreg_status == NETWORK_REGISTRATION_STATUS_ROAMING);
+ attach = gprs->netreg_status == NETWORK_REGISTRATION_STATUS_REGISTERED
+ || NETWORK_REGISTRATION_STATUS_ROAMING;
attach = attach && gprs->powered;
@@ -1493,10 +1490,6 @@ static DBusMessage *gprs_get_properties(DBusConnection *conn,
DBUS_TYPE_STRING, &bearer);
}
- value = gprs->roaming_allowed;
- ofono_dbus_dict_append(&dict, "RoamingAllowed",
- DBUS_TYPE_BOOLEAN, &value);
-
value = gprs->powered;
ofono_dbus_dict_append(&dict, "Powered", DBUS_TYPE_BOOLEAN, &value);
@@ -1538,27 +1531,7 @@ static DBusMessage *gprs_set_property(DBusConnection *conn,
dbus_message_iter_recurse(&iter, &var);
- if (!strcmp(property, "RoamingAllowed")) {
- if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_BOOLEAN)
- return __ofono_error_invalid_args(msg);
-
- dbus_message_iter_get_basic(&var, &value);
-
- if (gprs->roaming_allowed == (ofono_bool_t) value)
- return dbus_message_new_method_return(msg);
-
- gprs->roaming_allowed = value;
-
- if (gprs->settings) {
- g_key_file_set_integer(gprs->settings, SETTINGS_GROUP,
- "RoamingAllowed",
- gprs->roaming_allowed);
- storage_sync(gprs->imsi, SETTINGS_STORE,
- gprs->settings);
- }
-
- gprs_netreg_update(gprs);
- } else if (!strcmp(property, "Powered")) {
+ if (!strcmp(property, "Powered")) {
if (gprs->driver->set_attached == NULL)
return __ofono_error_not_implemented(msg);
@@ -2001,10 +1974,6 @@ void ofono_gprs_status_notify(struct ofono_gprs *gprs, int status)
if (gprs->powered == FALSE)
goto detach;
- if (gprs->roaming_allowed == FALSE &&
- status == NETWORK_REGISTRATION_STATUS_ROAMING)
- goto detach;
-
gprs->driver_attached = TRUE;
gprs_attached_update(gprs);
@@ -2509,7 +2478,6 @@ static void gprs_load_settings(struct ofono_gprs *gprs, const char *imsi)
/*
* If any error occurs, simply switch to defaults.
* Default to Powered = True
- * and RoamingAllowed = False
*/
if (error) {
g_error_free(error);
@@ -2518,20 +2486,6 @@ static void gprs_load_settings(struct ofono_gprs *gprs, const char *imsi)
"Powered", gprs->powered);
}
- error = NULL;
- gprs->roaming_allowed = g_key_file_get_boolean(gprs->settings,
- SETTINGS_GROUP,
- "RoamingAllowed",
- &error);
-
- if (error) {
- g_error_free(error);
- gprs->roaming_allowed = FALSE;
- g_key_file_set_boolean(gprs->settings, SETTINGS_GROUP,
- "RoamingAllowed",
- gprs->roaming_allowed);
- }
-
groups = g_key_file_get_groups(gprs->settings, NULL);
for (i = 0; groups[i]; i++) {
--
1.7.1
11 years, 7 months
[PATCHv2 0/7] Move GPRS attach logic to the modem
by Rémi Denis-Courmont
Hello,
This series moves responsibility for GPRS attach to the modem.
In most cases, the modem will attach on-demand when a first context is
activated. This simplifies the oFono interface and implementation.
Some operators require the device be always attached. This is managed
by a new driver callback to set the attach policy.
TBD: configuration option for the policy
Changes since version 1:
- rebased
--
Rémi Denis-Courmont
Nokia Devices R&D, Maemo Software, Helsinki
11 years, 7 months
[PATCH] TODO: Add vCard export to SM/ME stores
by Jaakko Kiviluoto
---
TODO | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/TODO b/TODO
index bf2305b..9dcb43f 100644
--- a/TODO
+++ b/TODO
@@ -496,3 +496,14 @@ Miscellaneous
Priority: Low
Complexity: C4
+
+- Enable exporting contact information from vCard data to SM and ME stores.
+ Need to implement a robust vCard parser that can extract at least the
+ fields supported by the existing phonebook module. Functionality should
+ be analoguous to existing import functionality.
+
+ Implements feature request http://bugs.meego.com/show_bug.cgi?id=4476
+
+ Priority: Low
+ Complexity: C1
+ Owner: Jaakko Kiviluoto <jaakko.j.kiviluoto(a)intel.com>
--
1.7.0.4
---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki
Business Identity Code: 0357606 - 4
Domiciled in Helsinki
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
11 years, 7 months
[PATCH] Fix Uplink data transfer in RawIP mode
by Carlos Pargada
Fix Uplink Data transfer in RawIP mode with IFX Modem
Change Data flow from stream mode to Packet mode between GatRawIP and GatMux.
---
gatchat/gatio.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++-
gatchat/gatio.h | 1 +
gatchat/gatrawip.c | 75 ++++++++++++++++++++++++++++++---------
3 files changed, 155 insertions(+), 19 deletions(-)
diff --git a/gatchat/gatio.c b/gatchat/gatio.c
index 9d44a78..5ad640d 100644
--- a/gatchat/gatio.c
+++ b/gatchat/gatio.c
@@ -77,7 +77,7 @@ static void read_watcher_destroy_notify(gpointer user_data)
io->user_disconnect(io->user_disconnect_data);
}
-static gboolean received_data(GIOChannel *channel, GIOCondition cond,
+static gboolean stream_received_data(GIOChannel *channel, GIOCondition cond,
gpointer data)
{
unsigned char *buf;
@@ -132,6 +132,51 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond,
return TRUE;
}
+static gboolean packet_received_data(GIOChannel *channel, GIOCondition cond,
+ gpointer data)
+{
+ unsigned char *buf;
+ GAtIO *io = data;
+ GIOStatus status;
+ gsize rbytes;
+ gsize toread;
+
+
+ if (cond & G_IO_NVAL)
+ return FALSE;
+
+ toread= 2048;
+ rbytes = 0;
+
+ ring_buffer_reset(io->buf);
+ buf = ring_buffer_write_ptr(io->buf, 0);
+
+ if (buf == NULL)
+ return FALSE;
+
+ status = g_io_channel_read_chars(channel, (char *) buf,
+ toread, &rbytes, NULL);
+
+ if (status == G_IO_STATUS_ERROR)
+ return FALSE;
+
+ if (rbytes > 0)
+ ring_buffer_write_advance(io->buf, rbytes);
+
+
+
+ if (rbytes > 0 && io->read_handler)
+ io->read_handler(io->buf, io->read_data);
+
+ if (cond & (G_IO_HUP | G_IO_ERR))
+ return FALSE;
+
+ if (rbytes == 0 && status != G_IO_STATUS_AGAIN)
+ return FALSE;
+
+ return TRUE;
+}
+
gsize g_at_io_write(GAtIO *io, const gchar *data, gsize count)
{
GIOStatus status;
@@ -175,6 +220,50 @@ static gboolean can_write_data(GIOChannel *channel, GIOCondition cond,
}
+static GAtIO *create_packet_io(GIOChannel *channel, GIOFlags flags)
+{
+ GAtIO *io;
+
+ if (channel == NULL)
+ return NULL;
+
+ io = g_try_new0(GAtIO, 1);
+
+ if (io == NULL)
+ return io;
+
+ io->ref_count = 1;
+ io->debugf = NULL;
+
+
+ io->max_read_attempts = 1;
+ io->use_write_watch = TRUE;
+
+ io->buf = ring_buffer_new(2048);
+
+ if (!io->buf)
+ goto error;
+
+ if (!g_at_util_setup_io(channel, flags))
+ goto error;
+
+ io->channel = channel;
+ io->read_watch = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT,
+ G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+ packet_received_data, io,
+ read_watcher_destroy_notify);
+
+ return io;
+
+error:
+ if (io->buf)
+ ring_buffer_free(io->buf);
+
+ g_free(io);
+
+ return NULL;
+}
+
static GAtIO *create_io(GIOChannel *channel, GIOFlags flags)
{
GAtIO *io;
@@ -208,7 +297,7 @@ static GAtIO *create_io(GIOChannel *channel, GIOFlags flags)
io->channel = channel;
io->read_watch = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT,
G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
- received_data, io,
+ stream_received_data, io,
read_watcher_destroy_notify);
return io;
@@ -222,6 +311,11 @@ error:
return NULL;
}
+GAtIO *g_raw_io_new(GIOChannel *channel)
+{
+ return create_packet_io(channel, G_IO_FLAG_NONBLOCK);
+}
+
GAtIO *g_at_io_new(GIOChannel *channel)
{
return create_io(channel, G_IO_FLAG_NONBLOCK);
diff --git a/gatchat/gatio.h b/gatchat/gatio.h
index 5a9f9f9..4b8bc00 100644
--- a/gatchat/gatio.h
+++ b/gatchat/gatio.h
@@ -37,6 +37,7 @@ struct ring_buffer;
typedef void (*GAtIOReadFunc)(struct ring_buffer *buffer, gpointer user_data);
typedef gboolean (*GAtIOWriteFunc)(gpointer user_data);
+GAtIO *g_raw_io_new(GIOChannel *channel);
GAtIO *g_at_io_new(GIOChannel *channel);
GAtIO *g_at_io_new_blocking(GIOChannel *channel);
diff --git a/gatchat/gatrawip.c b/gatchat/gatrawip.c
index 539f71f..ab72035 100644
--- a/gatchat/gatrawip.c
+++ b/gatchat/gatrawip.c
@@ -42,10 +42,17 @@ struct _GAtRawIP {
char *ifname;
struct ring_buffer *write_buffer;
struct ring_buffer *tun_write_buffer;
+ GQueue *packet_queue;
GAtDebugFunc debugf;
gpointer debug_data;
};
+struct PacketRaw {
+ unsigned char *buf;
+ int len;
+};
+
+
GAtRawIP *g_at_rawip_new(GIOChannel *channel)
{
GAtRawIP *rawip;
@@ -112,24 +119,22 @@ void g_at_rawip_unref(GAtRawIP *rawip)
static gboolean can_write_data(gpointer data)
{
GAtRawIP *rawip = data;
- unsigned int len;
- unsigned char *buf;
- gsize bytes_written;
+ gsize bytes_written;
+ struct PacketRaw *packetbuf;
- if (rawip->write_buffer == NULL)
+ if (rawip->packet_queue == NULL)
return FALSE;
+
+ while(g_queue_is_empty(rawip->packet_queue)!= TRUE)
+ {
+ packetbuf= g_queue_pop_head(rawip->packet_queue);
+ bytes_written = g_at_io_write(rawip->io, (gchar *) packetbuf->buf, packetbuf->len);
+
+ g_free(packetbuf->buf);
+ g_free(packetbuf);
- len = ring_buffer_len_no_wrap(rawip->write_buffer);
- buf = ring_buffer_read_ptr(rawip->write_buffer, 0);
-
- bytes_written = g_at_io_write(rawip->io, (gchar *) buf, len);
- ring_buffer_drain(rawip->write_buffer, bytes_written);
-
- if (ring_buffer_len(rawip->write_buffer) > 0)
- return TRUE;
-
- rawip->write_buffer = NULL;
-
+ }
+ return TRUE;
return FALSE;
}
@@ -169,9 +174,22 @@ static void new_bytes(struct ring_buffer *rbuf, gpointer user_data)
static void tun_bytes(struct ring_buffer *rbuf, gpointer user_data)
{
GAtRawIP *rawip = user_data;
+ struct PacketRaw *packetbuf;
+
- rawip->write_buffer = rbuf;
+ packetbuf= g_try_new0(struct PacketRaw, 1);
+ if (packetbuf == NULL)
+ return;
+
+ packetbuf-> len= ring_buffer_len_no_wrap(rbuf);
+ packetbuf->buf= g_try_malloc(packetbuf-> len);
+ if (packetbuf->buf == NULL)
+ return;
+
+ ring_buffer_read(rbuf, packetbuf->buf, 2048);
+
+ g_queue_push_head(rawip->packet_queue, packetbuf);
g_at_io_set_write_handler(rawip->io, can_write_data, rawip);
}
@@ -203,7 +221,11 @@ static void create_tun(GAtRawIP *rawip)
return;
}
- rawip->tun_io = g_at_io_new(channel);
+ rawip->tun_io = g_raw_io_new(channel);
+
+ rawip->packet_queue = g_queue_new();
+ if (rawip->packet_queue == NULL)
+ return;
g_io_channel_unref(channel);
}
@@ -224,6 +246,8 @@ void g_at_rawip_open(GAtRawIP *rawip)
void g_at_rawip_shutdown(GAtRawIP *rawip)
{
+ struct PacketRaw *packetbuf;
+
if (rawip == NULL)
return;
@@ -238,6 +262,23 @@ void g_at_rawip_shutdown(GAtRawIP *rawip)
g_at_io_unref(rawip->tun_io);
rawip->tun_io = NULL;
+
+ if(rawip->packet_queue == NULL)
+ return;
+
+ while(g_queue_is_empty(rawip->packet_queue)!= TRUE)
+ {
+ packetbuf= g_queue_pop_head(rawip->packet_queue);
+ if(packetbuf->buf != NULL)
+ g_free(packetbuf->buf);
+
+ g_free(packetbuf);
+ }
+
+ g_queue_free(rawip->packet_queue);
+ rawip->packet_queue= NULL;
+
+
}
const char *g_at_rawip_get_interface(GAtRawIP *rawip)
--
1.6.6.1
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number: 302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
11 years, 7 months
[PATCH -v3 1/7] bluetooth: Add bluetooth server support
by Gustavo F. Padovan
From: Frédéric Danis <frederic.danis(a)linux.intel.com>
---
Makefile.am | 1 +
plugins/bluetooth.c | 247 ++++++++++++++++++++++++++++++++++++++++++++++++++-
plugins/bluetooth.h | 9 ++
3 files changed, 254 insertions(+), 3 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 758fb10..e402de4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -321,6 +321,7 @@ builtin_sources += plugins/bluetooth.c plugins/bluetooth.h
builtin_modules += hfp
builtin_sources += plugins/hfp.c plugins/bluetooth.h
+builtin_sources += $(btio_sources)
builtin_cflags += @BLUEZ_CFLAGS@
builtin_libadd += @BLUEZ_LIBS@
endif
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 13f3b3b..d17e056 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -35,12 +35,30 @@
#include <ofono/dbus.h>
+#include <btio.h>
#include "bluetooth.h"
static DBusConnection *connection;
static GHashTable *uuid_hash = NULL;
static GHashTable *adapter_address_hash = NULL;
static gint bluetooth_refcount;
+static GSList *server_list = NULL;
+
+struct server {
+ guint8 channel;
+ char *sdp_record;
+ GIOChannel *io;
+ GHashTable *adapter_hash;
+ ConnectFunc connect_cb;
+ gpointer user_data;
+ GSList *client_list;
+};
+
+struct cb_data {
+ struct server *server;
+ char *path;
+ guint source;
+};
void bluetooth_create_path(const char *dev_addr, const char *adapter_addr,
char *buf, int size)
@@ -417,6 +435,166 @@ static void get_adapter_properties(const char *path, const char *handle,
g_strdup(path), g_free, -1, DBUS_TYPE_INVALID);
}
+static void remove_record(char *path, guint handle, struct server *server)
+{
+ DBusMessage *msg;
+
+ msg = dbus_message_new_method_call(BLUEZ_SERVICE, path,
+ BLUEZ_SERVICE_INTERFACE,
+ "RemoveRecord");
+ if (msg == NULL) {
+ ofono_error("Unable to allocate D-Bus RemoveRecord message");
+ return;
+ }
+
+ dbus_message_append_args(msg, DBUS_TYPE_UINT32, &handle,
+ DBUS_TYPE_INVALID);
+ g_dbus_send_message(connection, msg);
+
+ ofono_info("Unregistered handle for %s, channel %d: 0x%x", path,
+ server->channel, handle);
+}
+
+static void server_stop(struct server *server)
+{
+ /* Remove all client sources related to server */
+ while (server->client_list) {
+ g_source_remove(GPOINTER_TO_UINT(server->client_list->data));
+ server->client_list = g_slist_remove(server->client_list,
+ server->client_list->data);
+ }
+
+ g_hash_table_foreach_remove(server->adapter_hash,
+ (GHRFunc) remove_record, server);
+
+ if (server->io != NULL) {
+ g_io_channel_shutdown(server->io, TRUE, NULL);
+ g_io_channel_unref(server->io);
+ server->io = NULL;
+ }
+}
+
+static void cb_data_destroy(gpointer data)
+{
+ struct cb_data *cb_data = data;
+
+ if (cb_data->path != NULL)
+ g_free(cb_data->path);
+ g_free(cb_data);
+}
+
+static gboolean client_event(GIOChannel *chan, GIOCondition cond, gpointer data)
+{
+ struct cb_data *cb_data = data;
+ struct server *server = cb_data->server;
+
+ server->client_list = g_slist_remove(server->client_list,
+ GUINT_TO_POINTER(cb_data->source));
+
+ cb_data_destroy(cb_data);
+
+ return FALSE;
+}
+
+static void new_connection(GIOChannel *io, gpointer user_data)
+{
+ struct server *server = user_data;
+ struct cb_data *client_data;
+ GError *err = NULL;
+ char laddress[18], raddress[18];
+ guint8 channel;
+
+ bt_io_get(io, BT_IO_RFCOMM, &err, BT_IO_OPT_SOURCE, laddress,
+ BT_IO_OPT_DEST, raddress,
+ BT_IO_OPT_CHANNEL, &channel,
+ BT_IO_OPT_INVALID);
+ if (err) {
+ ofono_error("%s", err->message);
+ g_error_free(err);
+ return;
+ }
+
+ ofono_info("New connection for %s on channel %u from: %s,", laddress,
+ channel, raddress);
+
+ if (!bt_io_accept(io, server->connect_cb, server->user_data,
+ NULL, &err)) {
+ ofono_error("%s", err->message);
+ g_error_free(err);
+ g_io_channel_unref(io);
+ return;
+ }
+
+ client_data = g_try_new0(struct cb_data, 1);
+ if (client_data == NULL) {
+ ofono_error("Unable to allocate client cb_data structure");
+ return;
+ }
+
+ client_data->server = server;
+ client_data->source = g_io_add_watch(io,
+ G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+ client_event, client_data);
+ server->client_list = g_slist_prepend(server->client_list,
+ GUINT_TO_POINTER(client_data->source));
+}
+
+static void add_record_cb(DBusPendingCall *call, gpointer user_data)
+{
+ struct cb_data *cb_data = user_data;
+ DBusMessage *reply = dbus_pending_call_steal_reply(call);
+ DBusError derr;
+ guint32 handle;
+
+ dbus_error_init(&derr);
+
+ if (dbus_set_error_from_message(&derr, reply)) {
+ ofono_error("Replied with an error: %s, %s",
+ derr.name, derr.message);
+ dbus_error_free(&derr);
+ g_free(cb_data->path);
+ goto done;
+ }
+
+ dbus_message_get_args(reply, NULL, DBUS_TYPE_UINT32, &handle,
+ DBUS_TYPE_INVALID);
+
+ g_hash_table_insert(cb_data->server->adapter_hash, cb_data->path,
+ GUINT_TO_POINTER(handle));
+
+ ofono_info("Registered handle for %s, channel %d: 0x%x", cb_data->path,
+ cb_data->server->channel, handle);
+
+done:
+ /* Do not free cb_data->path, it is used in adapter_hash */
+ g_free(cb_data);
+ dbus_message_unref(reply);
+}
+
+static void add_record(gpointer data, gpointer user_data)
+{
+ struct server *server = data;
+ const char *path = user_data;
+ struct cb_data *cb_data;
+
+ if (server->sdp_record == NULL)
+ return;
+
+ cb_data = g_try_new0(struct cb_data, 1);
+ if (cb_data == NULL) {
+ ofono_error("Unable to allocate cb_data structure");
+ return;
+ }
+
+ cb_data->server = server;
+ cb_data->path = g_strdup(path);
+
+ bluetooth_send_with_reply(path, BLUEZ_SERVICE_INTERFACE, "AddRecord",
+ add_record_cb, cb_data, NULL, -1,
+ DBUS_TYPE_STRING, &server->sdp_record,
+ DBUS_TYPE_INVALID);
+}
+
static gboolean adapter_added(DBusConnection *connection, DBusMessage *message,
void *user_data)
{
@@ -430,6 +608,8 @@ static gboolean adapter_added(DBusConnection *connection, DBusMessage *message,
"GetProperties", adapter_properties_cb, g_strdup(path),
g_free, -1, DBUS_TYPE_INVALID);
+ g_slist_foreach(server_list, add_record,(gpointer) path);
+
return TRUE;
}
@@ -437,11 +617,19 @@ static gboolean adapter_removed(DBusConnection *connection,
DBusMessage *message, void *user_data)
{
const char *path;
+ GSList *l;
if (dbus_message_get_args(message, NULL, DBUS_TYPE_OBJECT_PATH, &path,
DBUS_TYPE_INVALID) == TRUE)
g_hash_table_remove(adapter_address_hash, path);
+ for (l = server_list; l; l = l->next) {
+ struct server *server = l->data;
+
+ /* Handle have already been removed, so removing related path */
+ g_hash_table_remove(server->adapter_hash, path);
+ }
+
return TRUE;
}
@@ -468,6 +656,8 @@ static void parse_adapters(DBusMessageIter *array, gpointer user_data)
"GetProperties", adapter_properties_cb,
g_strdup(path), g_free, -1, DBUS_TYPE_INVALID);
+ g_slist_foreach(server_list, add_record, (gpointer) path);
+
dbus_message_iter_next(&value);
}
}
@@ -583,9 +773,6 @@ int bluetooth_register_uuid(const char *uuid, struct bluetooth_profile *profile)
{
bluetooth_ref();
- if (bluetooth_refcount == 0)
- return -EIO;
-
g_hash_table_insert(uuid_hash, g_strdup(uuid), profile);
g_hash_table_foreach(adapter_address_hash,
@@ -601,5 +788,59 @@ void bluetooth_unregister_uuid(const char *uuid)
bluetooth_unref();
}
+struct server *bluetooth_register_server(guint8 channel, const char *sdp_record,
+ ConnectFunc cb, gpointer user_data)
+{
+ struct server *server;
+ GError *err;
+ GHashTableIter iter;
+ gpointer key, value;
+
+ server = g_try_new0(struct server, 1);
+ if (!server)
+ return NULL;
+
+
+ server->channel = channel;
+ server->io = bt_io_listen(BT_IO_RFCOMM, NULL, new_connection,
+ server, NULL, &err,
+ BT_IO_OPT_CHANNEL, server->channel,
+ BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM,
+ BT_IO_OPT_INVALID);
+ if (server->io == NULL) {
+ g_error_free(err);
+ g_free(server);
+ return NULL;
+ }
+
+ bluetooth_ref();
+
+ if (sdp_record != NULL)
+ server->sdp_record = g_strdup(sdp_record);
+ server->connect_cb = cb;
+ server->user_data = user_data;
+ server->adapter_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
+ g_free, NULL);
+
+ g_hash_table_iter_init(&iter, adapter_address_hash);
+ while (g_hash_table_iter_next(&iter, &key, &value))
+ add_record(server, key);
+
+ server_list = g_slist_prepend(server_list, server);
+
+ return server;
+}
+
+void bluetooth_unregister_server(struct server *server)
+{
+ server_list = g_slist_remove(server_list, server);
+ server_stop(server);
+ g_hash_table_destroy(server->adapter_hash);
+ g_free(server->sdp_record);
+ g_free(server);
+
+ bluetooth_unref();
+}
+
OFONO_PLUGIN_DEFINE(bluetooth, "Bluetooth Utils Plugins", VERSION,
OFONO_PLUGIN_PRIORITY_DEFAULT, NULL, NULL)
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index 42b0d13..505d908 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -23,6 +23,7 @@
#define BLUEZ_MANAGER_INTERFACE BLUEZ_SERVICE ".Manager"
#define BLUEZ_ADAPTER_INTERFACE BLUEZ_SERVICE ".Adapter"
#define BLUEZ_DEVICE_INTERFACE BLUEZ_SERVICE ".Device"
+#define BLUEZ_SERVICE_INTERFACE BLUEZ_SERVICE ".Service"
#define DBUS_TIMEOUT 15
@@ -39,10 +40,18 @@ struct bluetooth_profile {
void (*set_alias)(const char *device, const char *);
};
+struct server;
+
+typedef void (*ConnectFunc)(GIOChannel *io, GError *err, gpointer user_data);
+
int bluetooth_register_uuid(const char *uuid,
struct bluetooth_profile *profile);
void bluetooth_unregister_uuid(const char *uuid);
+struct server *bluetooth_register_server(guint8 channel, const char *sdp_record,
+ ConnectFunc cb, gpointer user_data);
+void bluetooth_unregister_server(struct server *server);
+
void bluetooth_create_path(const char *dev_addr, const char *adapter_addr,
char *buf, int size);
--
1.7.4
11 years, 7 months
[PATCH 0/5 v3] Neighbor Cell Info Atom
by Antti Paila
This series of patches implements an interface for client
applications to fetch the ECID information of neighboring
cells using DBUS. Since the 1st version the DBUS api has
been refactored to use new naming for method and to use
flat data format for the cell information. Also, the
internal datatypes have been optimized. Since the 2nd
version MNC and MCC are converted to strings and CPICH-RSCP
re-typed.
Antti Paila (5):
Cell-info: CellInfo DBUS interface definition
Cell-info: Header file for Neighbor cell info
Cell-info: Atom for obtaining ECID info of cells
Cell-info: New files included in compilation
Cell-info: Documentation
Makefile.am | 8 +-
doc/cell-info.txt | 121 +++++++++++++
include/cell-info.h | 128 ++++++++++++++
include/dbus.h | 1 +
src/cell-info.c | 485 +++++++++++++++++++++++++++++++++++++++++++++++++++
src/ofono.h | 1 +
6 files changed, 741 insertions(+), 3 deletions(-)
create mode 100644 doc/cell-info.txt
create mode 100644 include/cell-info.h
create mode 100644 src/cell-info.c
11 years, 7 months
[PATCH 0/3] gprs-provision: Add SPN to provision API
by Jukka Saunamaki
Hello
This patchset adds Service Provider Name (SPN) into GPRS context provisioning API.
SPN is read (asynchronously) in the middle of gprs atom registration, if provisioning is needed.
--Jukka
Jukka Saunamaki (3):
gprs-provision: add SPN to provisioning API header
gprs,gprs-provision: add SPN to provisioning API
gprs-provision: update example with SPN
examples/provision.c | 8 +++--
include/gprs-provision.h | 2 +-
src/gprs-provision.c | 4 +-
src/gprs.c | 87 ++++++++++++++++++++++++++++++++++-----------
src/ofono.h | 2 +-
5 files changed, 74 insertions(+), 29 deletions(-)
11 years, 7 months