* [PATCH 0/6] Add oFono DUN emulator
@ 2010-07-05 5:45 Zhenhua Zhang
2010-07-05 5:45 ` [PATCH 1/6] emulator: Add ofono_emulator framework Zhenhua Zhang
0 siblings, 1 reply; 14+ messages in thread
From: Zhenhua Zhang @ 2010-07-05 5:45 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 523 bytes --]
Hi,
This series are the initial patches for ofono DUN emulator.
1. src/emulator.c handles emulator create, remove, enable, disable and etc..
2. plugins/dun_gw.c is the plugin similar to hfp.c. It's the interface with BlueZ serial DUN agent.
3. gatchat/test-emulator.c is the test case to test emulator without BlueZ interface.
Emulator driver is registered statically once ofonod starts up. It probes BlueZ adapter properties to create emulator on active modem that having GPRS interface.
Thanks,
Zhenhua
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 1/6] emulator: Add ofono_emulator framework
2010-07-05 5:45 [PATCH 0/6] Add oFono DUN emulator Zhenhua Zhang
@ 2010-07-05 5:45 ` Zhenhua Zhang
2010-07-05 5:45 ` [PATCH 2/6] bluetooth: Add register service for bluetooth Zhenhua Zhang
2010-07-13 17:56 ` [PATCH 1/6] emulator: Add ofono_emulator framework Denis Kenzior
0 siblings, 2 replies; 14+ messages in thread
From: Zhenhua Zhang @ 2010-07-05 5:45 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 11505 bytes --]
Each type of emulator can be register through emulator drivers
statically. When modem powers up, oFono probes emulator driver to create
emulator for each modem.
---
Makefile.am | 4 +-
include/dbus.h | 1 +
include/emulator.h | 63 ++++++++++++
src/emulator.c | 271 ++++++++++++++++++++++++++++++++++++++++++++++++++++
src/modem.c | 1 +
src/ofono.h | 6 +
6 files changed, 344 insertions(+), 2 deletions(-)
create mode 100644 include/emulator.h
create mode 100644 src/emulator.c
diff --git a/Makefile.am b/Makefile.am
index 96116a5..8ecb2d9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -13,7 +13,7 @@ include_HEADERS = include/log.h include/plugin.h include/history.h \
include/cbs.h include/call-volume.h \
include/gprs.h include/gprs-context.h \
include/radio-settings.h include/stk.h \
- include/nettime.h
+ include/nettime.h include/emulator.h
nodist_include_HEADERS = include/version.h
@@ -272,7 +272,7 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) \
src/storage.c src/cbs.c src/watch.c src/call-volume.c \
src/gprs.c src/idmap.h src/idmap.c \
src/radio-settings.c src/stkutil.h src/stkutil.c \
- src/nettime.c
+ src/nettime.c src/emulator.c
src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
diff --git a/include/dbus.h b/include/dbus.h
index d988760..281be80 100644
--- a/include/dbus.h
+++ b/include/dbus.h
@@ -49,6 +49,7 @@ extern "C" {
#define OFONO_VOICECALL_MANAGER_INTERFACE "org.ofono.VoiceCallManager"
#define OFONO_DATA_CONNECTION_MANAGER_INTERFACE "org.ofono.DataConnectionManager"
#define OFONO_DATA_CONTEXT_INTERFACE "org.ofono.PrimaryDataContext"
+#define OFONO_EMULATOR_INTERFACE "org.ofono.Emulator"
/* Essentially a{sv} */
#define OFONO_PROPERTIES_ARRAY_SIGNATURE DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING \
diff --git a/include/emulator.h b/include/emulator.h
new file mode 100644
index 0000000..0c87b13
--- /dev/null
+++ b/include/emulator.h
@@ -0,0 +1,63 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2010 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
+ *
+ */
+
+#ifndef __OFONO_EMULATOR_H
+#define __OFONO_EMULATOR_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <ofono/types.h>
+
+struct ofono_emulator;
+
+enum ofono_emulator_type {
+ OFONO_EMULATOR_TYPE_NONE,
+ OFONO_EMULATOR_TYPE_DUN,
+};
+
+struct ofono_emulator_driver {
+ const char *name;
+ enum ofono_emulator_type type;
+ int (*probe)(struct ofono_emulator *e);
+ void (*remove)(struct ofono_emulator *e);
+ int (*enable)(struct ofono_emulator *e, int fd);
+ int (*disable)(struct ofono_emulator *e);
+};
+
+const char *ofono_emulator_get_path(struct ofono_emulator *e);
+void ofono_emulator_set_data(struct ofono_emulator *e, void *user_data);
+void *ofono_emulator_get_data(struct ofono_emulator *e);
+
+struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
+ struct ofono_emulator_driver *driver);
+void ofono_emulator_remove(struct ofono_emulator *e);
+
+int ofono_emulator_driver_register(const struct ofono_emulator_driver *driver);
+void ofono_emulator_driver_unregister(
+ const struct ofono_emulator_driver *driver);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OFONO_EMULATOR_H */
diff --git a/src/emulator.c b/src/emulator.c
new file mode 100644
index 0000000..6b63398
--- /dev/null
+++ b/src/emulator.c
@@ -0,0 +1,271 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2010 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 <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <glib.h>
+#include <gdbus.h>
+
+#include "ofono.h"
+#include "common.h"
+
+struct ofono_emulator {
+ struct ofono_emulator_driver *driver;
+ struct ofono_modem *modem;
+ struct ofono_atom *atom;
+ unsigned int id;
+ void *user_data;
+};
+
+static GSList *emulator_list;
+static GSList *ofono_emulator_drivers;
+static unsigned int ofono_emulator_ids;
+
+static unsigned int ofono_emulator_next_id()
+{
+ unsigned int i;
+
+ for (i = 1; i < sizeof(ofono_emulator_ids) * 8; i++) {
+ if (ofono_emulator_ids & (0x1 << i))
+ continue;
+
+ ofono_emulator_ids |= (0x1 << i);
+
+ return i;
+ }
+
+ return 0;
+}
+
+static void ofono_emulator_release_id(int id)
+{
+ ofono_emulator_ids &= ~(0x1 << id);
+}
+
+static enum ofono_atom_type ofono_emulator_atom_type(
+ enum ofono_emulator_type type)
+{
+ switch (type) {
+ case OFONO_EMULATOR_TYPE_DUN:
+ return OFONO_ATOM_TYPE_EMULATOR_DUN;
+ default:
+ return 0;
+ }
+}
+
+static const char *ofono_emulator_type_to_str(enum ofono_emulator_type type)
+{
+ switch (type) {
+ case OFONO_EMULATOR_TYPE_DUN:
+ return "dun";
+ default:
+ return "";
+ }
+}
+
+const char *ofono_emulator_get_path(struct ofono_emulator *e)
+{
+ static char path[256];
+
+ snprintf(path, sizeof(path), "%s/%s_emulator",
+ ofono_modem_get_path(e->modem),
+ ofono_emulator_type_to_str(e->driver->type));
+
+ return path;
+}
+
+void ofono_emulator_set_data(struct ofono_emulator *e, void *user_data)
+{
+ if (!e)
+ return;
+
+ e->user_data = user_data;
+}
+
+void *ofono_emulator_get_data(struct ofono_emulator *e)
+{
+ if (!e)
+ return NULL;
+
+ return e->user_data;
+}
+
+static void emulator_remove(struct ofono_atom *atom)
+{
+ struct ofono_emulator *e = __ofono_atom_get_data(atom);
+
+ DBG("");
+
+ emulator_list = g_slist_remove(emulator_list, e);
+
+ if (e->driver->remove)
+ e->driver->remove(e);
+
+ ofono_emulator_release_id(e->id);
+ g_free(e);
+ e = NULL;
+}
+
+static struct ofono_emulator *create_emulator(struct ofono_modem *modem,
+ struct ofono_emulator_driver *driver)
+{
+ struct ofono_emulator *e;
+
+ DBG("");
+
+ e = g_try_new0(struct ofono_emulator, 1);
+ if (!e)
+ goto error;
+
+ e->modem = modem;
+ e->driver = driver;
+ e->id = ofono_emulator_next_id();
+
+ return e;
+error:
+ g_free(e);
+ return NULL;
+}
+
+static DBusMessage *emulator_get_properties(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ return dbus_message_new_method_return(msg);
+}
+
+static GDBusMethodTable ofono_emulator_methods[] = {
+ { "GetProperties", "", "a{sv}", emulator_get_properties },
+ { }
+};
+
+static GDBusSignalTable ofono_emulator_signals[] = {
+ { "PropertyChanged", "sv" },
+};
+
+static void ofono_emulator_dbus_unregister(struct ofono_atom *atom)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ struct ofono_emulator *e = __ofono_atom_get_data(atom);
+ const char *path;
+
+ path = ofono_emulator_get_path(e);
+
+ g_dbus_unregister_interface(conn, path, OFONO_EMULATOR_INTERFACE);
+
+ return;
+}
+
+static gboolean ofono_emulator_dbus_register(struct ofono_modem *modem,
+ struct ofono_emulator *e)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ const char *path = ofono_emulator_get_path(e);
+
+ if (!g_dbus_register_interface(conn, path, OFONO_EMULATOR_INTERFACE,
+ ofono_emulator_methods, ofono_emulator_signals,
+ NULL, e, NULL)) {
+ ofono_error("Could not create ofono_emulator %s", path);
+ ofono_emulator_remove(e);
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
+ struct ofono_emulator_driver *driver)
+{
+ struct ofono_emulator *e;
+ enum ofono_atom_type type;
+
+ DBG("");
+
+ e = create_emulator(modem, driver);
+ if (!e)
+ return NULL;
+
+ type = ofono_emulator_atom_type(driver->type);
+ e->atom = __ofono_modem_add_atom(modem, type, emulator_remove, e);
+
+ if (!ofono_emulator_dbus_register(modem, e)) {
+ ofono_emulator_remove(e);
+ return NULL;
+ }
+
+ __ofono_atom_register(e->atom, ofono_emulator_dbus_unregister);
+
+ if (driver->probe(e) < 0) {
+ ofono_emulator_remove(e);
+ return NULL;
+ }
+
+ return e;
+}
+
+void __ofono_emulator_probe_drivers(struct ofono_modem *modem)
+{
+ GSList *l;
+ struct ofono_emulator *e;
+
+ for (l = ofono_emulator_drivers; l; l = l->next) {
+ struct ofono_emulator_driver *driver = l->data;
+
+ e = ofono_emulator_create(modem, driver);
+ if (!e)
+ continue;
+
+ emulator_list = g_slist_prepend(emulator_list, e);
+ }
+}
+
+void ofono_emulator_remove(struct ofono_emulator *e)
+{
+ DBG("");
+
+ if (!e)
+ return;
+
+ __ofono_atom_free(e->atom);
+}
+
+int ofono_emulator_driver_register(const struct ofono_emulator_driver *driver)
+{
+ DBG("driver: %p name: %s", driver, driver->name);
+
+ ofono_emulator_drivers = g_slist_prepend(ofono_emulator_drivers,
+ (void *)driver);
+
+ return 0;
+}
+
+void ofono_emulator_driver_unregister(
+ const struct ofono_emulator_driver *driver)
+{
+ DBG("driver: %p name: %s", driver, driver->name);
+
+ ofono_emulator_drivers = g_slist_remove(ofono_emulator_drivers, driver);
+}
diff --git a/src/modem.c b/src/modem.c
index 43e4a6d..8137f97 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -396,6 +396,7 @@ static void modem_change_state(struct ofono_modem *modem,
driver->post_sim(modem);
__ofono_history_probe_drivers(modem);
__ofono_nettime_probe_drivers(modem);
+ __ofono_emulator_probe_drivers(modem);
}
break;
diff --git a/src/ofono.h b/src/ofono.h
index e2271e6..ac2a5b0 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -117,6 +117,7 @@ enum ofono_atom_type {
OFONO_ATOM_TYPE_RADIO_SETTINGS = 18,
OFONO_ATOM_TYPE_STK = 19,
OFONO_ATOM_TYPE_NETTIME = 20,
+ OFONO_ATOM_TYPE_EMULATOR_DUN = 21,
};
enum ofono_atom_watch_condition {
@@ -273,3 +274,8 @@ void __ofono_nettime_probe_drivers(struct ofono_modem *modem);
void __ofono_nettime_info_received(struct ofono_modem *modem,
struct ofono_network_time *info);
+
+#include <ofono/emulator.h>
+
+void __ofono_emulator_probe_drivers(struct ofono_modem *modem);
+
--
1.6.3.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 2/6] bluetooth: Add register service for bluetooth
2010-07-05 5:45 ` [PATCH 1/6] emulator: Add ofono_emulator framework Zhenhua Zhang
@ 2010-07-05 5:45 ` Zhenhua Zhang
2010-07-05 5:45 ` [PATCH 3/6] dun_gw: Add DUN emulator plugin Zhenhua Zhang
2010-07-09 14:20 ` [PATCH 2/6] bluetooth: Add register service for bluetooth Gustavo F. Padovan
2010-07-13 17:56 ` [PATCH 1/6] emulator: Add ofono_emulator framework Denis Kenzior
1 sibling, 2 replies; 14+ messages in thread
From: Zhenhua Zhang @ 2010-07-05 5:45 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 6695 bytes --]
Add bluetooth_register_service() and bluetooth_unregister_service()
where bluetooth profiles plugins like DUN GW can register themselves per
adapter. It shares existing bluetooth framework to listen bluetooth
events (new adapters, bluetoothd shutdown, etc..)
---
plugins/bluetooth.c | 125 ++++++++++++++++++++++++++++++++++++++++++---------
plugins/bluetooth.h | 8 +++
2 files changed, 112 insertions(+), 21 deletions(-)
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 5a85eaa..3a3b5e6 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -38,8 +38,19 @@
static DBusConnection *connection;
static GHashTable *uuid_hash = NULL;
+static GHashTable *service_hash = NULL;
static GHashTable *adapter_address_hash = NULL;
+static char *bluetooth_service_type_to_str(enum bluetooth_service_type type)
+{
+ switch (type) {
+ case DUN_GATEWAY:
+ return "DUN";
+ default:
+ return "";
+ }
+}
+
void bluetooth_create_path(const char *dev_addr, const char *adapter_addr,
char *buf, int size)
{
@@ -376,6 +387,9 @@ static void adapter_properties_cb(DBusPendingCall *call, gpointer user_data)
GSList *device_list = NULL;
GSList *l;
const char *addr;
+ GHashTableIter hash_iter;
+ gpointer key, value;
+ struct bluetooth_profile *profile;
reply = dbus_pending_call_steal_reply(call);
@@ -393,6 +407,12 @@ static void adapter_properties_cb(DBusPendingCall *call, gpointer user_data)
g_hash_table_insert(adapter_address_hash,
g_strdup(path), g_strdup(addr));
+ g_hash_table_iter_init(&hash_iter, service_hash);
+ while (g_hash_table_iter_next(&hash_iter, &key, &value)) {
+ profile = value;
+ profile->create(path, NULL, addr, NULL);
+ }
+
for (l = device_list; l; l = l->next) {
const char *device = l->data;
@@ -492,10 +512,13 @@ static void bluetooth_remove_all_modem(gpointer key, gpointer value,
static void bluetooth_disconnect(DBusConnection *connection, void *user_data)
{
- if (!uuid_hash)
- return;
+ if (uuid_hash)
+ g_hash_table_foreach(uuid_hash, bluetooth_remove_all_modem,
+ NULL);
- g_hash_table_foreach(uuid_hash, bluetooth_remove_all_modem, NULL);
+ if (service_hash)
+ g_hash_table_foreach(service_hash, bluetooth_remove_all_modem,
+ NULL);
}
static guint bluetooth_watch;
@@ -503,12 +526,12 @@ static guint adapter_added_watch;
static guint adapter_removed_watch;
static guint property_watch;
-int bluetooth_register_uuid(const char *uuid, struct bluetooth_profile *profile)
+static int bluetooth_init()
{
int err;
- if (uuid_hash)
- goto done;
+ if (adapter_address_hash)
+ return 0;
connection = ofono_dbus_get_connection();
@@ -536,19 +559,9 @@ int bluetooth_register_uuid(const char *uuid, struct bluetooth_profile *profile)
goto remove;
}
- uuid_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
- g_free, NULL);
-
adapter_address_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, g_free);
-done:
- g_hash_table_insert(uuid_hash, g_strdup(uuid), profile);
-
- bluetooth_send_with_reply("/", BLUEZ_MANAGER_INTERFACE, "GetProperties",
- manager_properties_cb, NULL, NULL, -1,
- DBUS_TYPE_INVALID);
-
return 0;
remove:
@@ -556,14 +569,13 @@ remove:
g_dbus_remove_watch(connection, adapter_added_watch);
g_dbus_remove_watch(connection, adapter_removed_watch);
g_dbus_remove_watch(connection, property_watch);
+
return err;
}
-void bluetooth_unregister_uuid(const char *uuid)
+static void bluetooth_exit()
{
- g_hash_table_remove(uuid_hash, uuid);
-
- if (g_hash_table_size(uuid_hash))
+ if (uuid_hash != NULL || service_hash != NULL)
return;
g_dbus_remove_watch(connection, bluetooth_watch);
@@ -571,9 +583,80 @@ void bluetooth_unregister_uuid(const char *uuid)
g_dbus_remove_watch(connection, adapter_removed_watch);
g_dbus_remove_watch(connection, property_watch);
- g_hash_table_destroy(uuid_hash);
g_hash_table_destroy(adapter_address_hash);
+}
+
+
+int bluetooth_register_uuid(const char *uuid, struct bluetooth_profile *profile)
+{
+ int err;
+
+ err = bluetooth_init();
+ if (err)
+ return err;
+
+ if (!uuid_hash)
+ uuid_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
+ g_free, NULL);
+
+ g_hash_table_insert(uuid_hash, g_strdup(uuid), profile);
+
+ bluetooth_send_with_reply("/", BLUEZ_MANAGER_INTERFACE, "GetProperties",
+ manager_properties_cb, NULL, NULL, -1,
+ DBUS_TYPE_INVALID);
+
+ return 0;
+}
+
+void bluetooth_unregister_uuid(const char *uuid)
+{
+ g_hash_table_remove(uuid_hash, uuid);
+
+ if (g_hash_table_size(uuid_hash) > 0)
+ return;
+
+ g_hash_table_destroy(uuid_hash);
uuid_hash = NULL;
+ bluetooth_exit();
+}
+
+int bluetooth_register_service(enum bluetooth_service_type type,
+ struct bluetooth_profile *profile)
+{
+ int err;
+ char *type_str;
+
+ err = bluetooth_init();
+ if (err)
+ return err;
+
+ type_str = bluetooth_service_type_to_str(type);
+
+ if (!service_hash)
+ service_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
+ g_free, NULL);
+
+ g_hash_table_insert(service_hash, g_strdup(type_str), profile);
+
+ bluetooth_send_with_reply("/", BLUEZ_MANAGER_INTERFACE, "GetProperties",
+ manager_properties_cb, NULL, NULL, -1,
+ DBUS_TYPE_INVALID);
+
+ return 0;
+}
+
+void bluetooth_unregister_service(enum bluetooth_service_type type)
+{
+ char *type_str = bluetooth_service_type_to_str(type);
+
+ g_hash_table_remove(service_hash, type_str);
+
+ if (g_hash_table_size(service_hash) > 0)
+ return;
+
+ g_hash_table_destroy(service_hash);
+ service_hash = NULL;
+ bluetooth_exit();
}
OFONO_PLUGIN_DEFINE(bluetooth, "Bluetooth Utils Plugins", VERSION,
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index fb0d841..84707a9 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -28,6 +28,10 @@
/* Profiles bitfield */
#define HFP_AG 0x01
+enum bluetooth_service_type {
+ DUN_GATEWAY,
+};
+
struct bluetooth_profile {
const char *name;
int (*create)(const char *device, const char *dev_addr,
@@ -40,6 +44,10 @@ int bluetooth_register_uuid(const char *uuid,
struct bluetooth_profile *profile);
void bluetooth_unregister_uuid(const char *uuid);
+int bluetooth_register_service(enum bluetooth_service_type type,
+ struct bluetooth_profile *profile);
+void bluetooth_unregister_service(enum bluetooth_service_type type);
+
void bluetooth_create_path(const char *dev_addr, const char *adapter_addr,
char *buf, int size);
--
1.6.3.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 3/6] dun_gw: Add DUN emulator plugin
2010-07-05 5:45 ` [PATCH 2/6] bluetooth: Add register service for bluetooth Zhenhua Zhang
@ 2010-07-05 5:45 ` Zhenhua Zhang
2010-07-05 5:45 ` [PATCH 4/6] emulator: Add Enable/Disable for oFono emulator Zhenhua Zhang
2010-07-09 14:20 ` [PATCH 2/6] bluetooth: Add register service for bluetooth Gustavo F. Padovan
1 sibling, 1 reply; 14+ messages in thread
From: Zhenhua Zhang @ 2010-07-05 5:45 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 7612 bytes --]
It implements DUN server role and register itself as agent to BlueZ
interface.
---
Makefile.am | 3 +
plugins/dun_gw.c | 274 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 277 insertions(+), 0 deletions(-)
create mode 100644 plugins/dun_gw.c
diff --git a/Makefile.am b/Makefile.am
index 8ecb2d9..908e945 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -244,6 +244,9 @@ builtin_sources += plugins/bluetooth.c plugins/bluetooth.h
builtin_modules += hfp
builtin_sources += plugins/hfp.c plugins/bluetooth.h
+builtin_modules += dun_gw
+builtin_sources += plugins/dun_gw.c
+
builtin_modules += palmpre
builtin_sources += plugins/palmpre.c
diff --git a/plugins/dun_gw.c b/plugins/dun_gw.c
new file mode 100644
index 0000000..95b176c
--- /dev/null
+++ b/plugins/dun_gw.c
@@ -0,0 +1,274 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2010 Intel Corporation. All rights reserved.
+ * Copyright (C) 2010 Gustavo F. Padovan <gustavo@padovan.org>
+ *
+ * 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 <string.h>
+#include <errno.h>
+#include <glib.h>
+#include <ofono.h>
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include <ofono/plugin.h>
+#include <ofono/log.h>
+#include <ofono/modem.h>
+
+#include <ofono/dbus.h>
+
+#include "gdbus.h"
+#include "bluetooth.h"
+
+#ifndef DBUS_TYPE_UNIX_FD
+#define DBUS_TYPE_UNIX_FD -1
+#endif
+
+#define BLUEZ_DUN_INTERFACE BLUEZ_SERVICE ".SerialDUN"
+#define DUN_AGENT_INTERFACE "org.bluez.DUNAgent"
+
+static DBusConnection *connection;
+static GHashTable *adapter_hash;
+
+struct dun_data {
+ char *adapter;
+ char *path;
+ gboolean agent_registered;
+ struct ofono_emulator *e;
+};
+
+static struct ofono_emulator_driver dun_gw_driver;
+
+static int dun_gw_create_adapter(const char *path, const char *dev_addr,
+ const char *adapter, const char *alias)
+{
+ GSList *l;
+ struct dun_data *data;
+
+ /* Ignore if we already have this adapter */
+ l = g_hash_table_lookup(adapter_hash, (char *)adapter);
+ if (l != NULL)
+ return -EALREADY;
+
+ DBG("Adding adapter: %s", adapter);
+
+ data = g_try_new0(struct dun_data, 1);
+ if (!data)
+ return -ENOMEM;
+
+ data->adapter = g_strdup(adapter);
+ data->path = g_strdup(path);
+ data->agent_registered = FALSE;
+
+ g_hash_table_insert(adapter_hash, g_strdup(adapter), data);
+
+ return 0;
+}
+
+static gboolean remove_adapter(gpointer key, gpointer value, gpointer user_data)
+{
+ struct dun_data *data = value;
+
+ if (data) {
+ g_free(data->adapter);
+ g_free(data->path);
+ g_free(data);
+ data = NULL;
+ }
+
+ return TRUE;
+}
+
+static void dun_gw_remove_all_adapter()
+{
+ if (adapter_hash == NULL)
+ return;
+
+ DBG("");
+
+ g_hash_table_foreach_remove(adapter_hash, remove_adapter, NULL);
+}
+
+static DBusMessage *dun_agent_new_connection(DBusConnection *conn,
+ DBusMessage *msg,
+ void *user_data)
+{
+ DBusMessage *reply;
+ int fd;
+
+ if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_UNIX_FD, &fd,
+ DBUS_TYPE_INVALID)) {
+ reply = g_dbus_create_error(msg, DUN_AGENT_INTERFACE, ".Failed",
+ "Invalid File Descriptor");
+ goto error;
+ }
+
+ return dbus_message_new_method_return(msg);
+
+error:
+ return reply;
+}
+
+static DBusMessage *dun_agent_release(DBusConnection *conn,
+ DBusMessage *msg, void *user_data)
+{
+ struct dun_data *data = user_data;
+ struct ofono_emulator *e = data->e;
+ const char *obj_path = ofono_emulator_get_path(e);
+
+ g_dbus_unregister_interface(connection, obj_path, DUN_AGENT_INTERFACE);
+ data->agent_registered = FALSE;
+
+ ofono_emulator_remove(e);
+
+ return dbus_message_new_method_return(msg);
+}
+
+static GDBusMethodTable agent_methods[] = {
+ { "NewConnection", "h", "", dun_agent_new_connection,
+ G_DBUS_METHOD_FLAG_ASYNC },
+ { "Release", "", "", dun_agent_release },
+ { NULL, NULL, NULL, NULL }
+};
+
+static int dun_gw_probe(struct ofono_emulator *e)
+{
+ char *adapter = NULL;
+ struct dun_data *data = NULL;
+ const char *obj_path = ofono_emulator_get_path(e);
+ GHashTableIter hash_iter;
+ gpointer key, value;
+
+ DBG("%p", e);
+
+ if (g_hash_table_size(adapter_hash) == 0) {
+ DBG("No Bluetooth adapater found in system");
+ return -EINVAL;
+ }
+
+ g_hash_table_iter_init(&hash_iter, adapter_hash);
+ while (g_hash_table_iter_next(&hash_iter, &key, &value)) {
+ adapter = key;
+ data = value;
+
+ /* Find the adapter that has no DUN GW register yet */
+ if (data->agent_registered == FALSE)
+ break;
+ }
+
+ if (!adapter || !data)
+ return -EINVAL;
+
+ /* Register dbus interface */
+ g_dbus_register_interface(connection, obj_path, DUN_AGENT_INTERFACE,
+ agent_methods, NULL, NULL, data, NULL);
+
+ data->e = e;
+ ofono_emulator_set_data(e, data);
+
+ return 0;
+}
+
+static void dun_gw_remove(struct ofono_emulator *e)
+{
+ struct dun_data *data = ofono_emulator_get_data(e);
+ const char *obj_path = ofono_emulator_get_path(e);
+
+ DBG("%p", e);
+
+ if (!data)
+ return;
+
+ g_dbus_unregister_interface(connection, obj_path, DUN_AGENT_INTERFACE);
+
+ g_hash_table_remove(adapter_hash, data->adapter);
+ remove_adapter(data->adapter, data, NULL);
+
+ ofono_emulator_set_data(e, NULL);
+
+ return;
+}
+
+static int dun_gw_enable(struct ofono_emulator *e, int fd)
+{
+ DBG("%p", e);
+
+ return 0;
+}
+
+static int dun_gw_disable(struct ofono_emulator *e)
+{
+ DBG("%p", e);
+
+ return 0;
+}
+
+static struct ofono_emulator_driver dun_gw_driver = {
+ .name = "dun_gw",
+ .type = OFONO_EMULATOR_TYPE_DUN,
+ .probe = dun_gw_probe,
+ .remove = dun_gw_remove,
+ .enable = dun_gw_enable,
+ .disable = dun_gw_disable,
+};
+
+static struct bluetooth_profile dun_gw_profile = {
+ .name = "dun_gw",
+ .create = dun_gw_create_adapter,
+ .remove_all = dun_gw_remove_all_adapter,
+ .set_alias = NULL,
+};
+
+static int dun_gw_init()
+{
+ int err;
+
+ if (DBUS_TYPE_UNIX_FD < 0)
+ return -EBADF;
+
+ connection = ofono_dbus_get_connection();
+
+ err = ofono_emulator_driver_register(&dun_gw_driver);
+ if (err < 0)
+ return err;
+
+ err = bluetooth_register_service(DUN_GATEWAY, &dun_gw_profile);
+ if (err < 0) {
+ ofono_emulator_driver_unregister(&dun_gw_driver);
+ return err;
+ }
+
+ adapter_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
+ g_free, NULL);
+
+ return 0;
+}
+
+static void dun_gw_exit()
+{
+ bluetooth_unregister_service(DUN_GATEWAY);
+ ofono_emulator_driver_unregister(&dun_gw_driver);
+ dun_gw_remove_all_adapter();
+ g_hash_table_destroy(adapter_hash);
+}
+
+OFONO_PLUGIN_DEFINE(dun_gw, "Dial-up Networking Profile Plugins", VERSION,
+ OFONO_PLUGIN_PRIORITY_DEFAULT, dun_gw_init, dun_gw_exit)
--
1.6.3.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 4/6] emulator: Add Enable/Disable for oFono emulator
2010-07-05 5:45 ` [PATCH 3/6] dun_gw: Add DUN emulator plugin Zhenhua Zhang
@ 2010-07-05 5:45 ` Zhenhua Zhang
2010-07-05 5:45 ` [PATCH 5/6] emulator: Add test case for ofono emulator Zhenhua Zhang
0 siblings, 1 reply; 14+ messages in thread
From: Zhenhua Zhang @ 2010-07-05 5:45 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 6273 bytes --]
Use tty descriptor passed from BlueZ agent to enable emulator. It uses
gatserver to handle incoming AT commands.
In disable or remove emulator stage, we shutdown the gatserver.
---
include/emulator.h | 3 +
plugins/dun_gw.c | 15 ++++++
src/emulator.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 145 insertions(+), 0 deletions(-)
diff --git a/include/emulator.h b/include/emulator.h
index 0c87b13..9d96d67 100644
--- a/include/emulator.h
+++ b/include/emulator.h
@@ -52,6 +52,9 @@ struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
struct ofono_emulator_driver *driver);
void ofono_emulator_remove(struct ofono_emulator *e);
+ofono_bool_t ofono_emulator_enable(struct ofono_emulator *e, int fd);
+void ofono_emulator_disable(struct ofono_emulator *e);
+
int ofono_emulator_driver_register(const struct ofono_emulator_driver *driver);
void ofono_emulator_driver_unregister(
const struct ofono_emulator_driver *driver);
diff --git a/plugins/dun_gw.c b/plugins/dun_gw.c
index 95b176c..43a0b0a 100644
--- a/plugins/dun_gw.c
+++ b/plugins/dun_gw.c
@@ -111,6 +111,8 @@ static DBusMessage *dun_agent_new_connection(DBusConnection *conn,
DBusMessage *msg,
void *user_data)
{
+ struct dun_data *data = user_data;
+ struct ofono_emulator *e = data->e;
DBusMessage *reply;
int fd;
@@ -121,6 +123,14 @@ static DBusMessage *dun_agent_new_connection(DBusConnection *conn,
goto error;
}
+ if (!ofono_emulator_enable(e, fd)) {
+ reply = g_dbus_create_error(msg, DUN_AGENT_INTERFACE, ".Failed",
+ "Failed to enable DUN Server");
+ goto error;
+ }
+
+ DBG("Accept new DUN connection");
+
return dbus_message_new_method_return(msg);
error:
@@ -211,6 +221,9 @@ static int dun_gw_enable(struct ofono_emulator *e, int fd)
{
DBG("%p", e);
+ if (!ofono_emulator_enable(e, fd))
+ return -EINVAL;
+
return 0;
}
@@ -218,6 +231,8 @@ static int dun_gw_disable(struct ofono_emulator *e)
{
DBG("%p", e);
+ ofono_emulator_disable(e);
+
return 0;
}
diff --git a/src/emulator.c b/src/emulator.c
index 6b63398..1155769 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -30,6 +30,7 @@
#include <gdbus.h>
#include "ofono.h"
+#include "gatserver.h"
#include "common.h"
struct ofono_emulator {
@@ -38,12 +39,19 @@ struct ofono_emulator {
struct ofono_atom *atom;
unsigned int id;
void *user_data;
+ GAtServer *server;
+ ofono_bool_t powered;
};
static GSList *emulator_list;
static GSList *ofono_emulator_drivers;
static unsigned int ofono_emulator_ids;
+static void ofono_emulator_debug(const char *str, void *data)
+{
+ g_print("%s: %s\n", (char *)data, str);
+}
+
static unsigned int ofono_emulator_next_id()
{
unsigned int i;
@@ -121,6 +129,9 @@ static void emulator_remove(struct ofono_atom *atom)
emulator_list = g_slist_remove(emulator_list, e);
+ if (e->powered)
+ e->driver->disable(e);
+
if (e->driver->remove)
e->driver->remove(e);
@@ -129,6 +140,78 @@ static void emulator_remove(struct ofono_atom *atom)
e = NULL;
}
+void ofono_emulator_disable(struct ofono_emulator *e)
+{
+ if (e->server == NULL)
+ return;
+
+ g_at_server_shutdown(e->server);
+ g_at_server_unref(e->server);
+ e->server = NULL;
+
+ e->powered = FALSE;
+}
+
+static int set_powered(struct ofono_emulator *e, ofono_bool_t powered, int fd)
+{
+ int val;
+
+ if (powered == TRUE && e->driver->enable)
+ val = e->driver->enable(e, fd);
+ else if (powered == FALSE && e->driver->disable)
+ val = e->driver->disable(e);
+ else
+ return -EINVAL;
+
+ e->powered = powered;
+
+ return val;
+}
+
+static void emulator_disconnect(gpointer data)
+{
+ struct ofono_emulator *e = data;
+
+ set_powered(e, FALSE, 0);
+}
+
+ofono_bool_t ofono_emulator_enable(struct ofono_emulator *e, int fd)
+{
+ GAtServer *server;
+ GIOChannel *channel;
+
+ if (fd <= 0 || e->server != NULL)
+ return FALSE;
+
+ channel = g_io_channel_unix_new(fd);
+ server = g_at_server_new(channel);
+ if (!server)
+ goto error;
+
+ e->server = server;
+ g_at_server_set_debug(e->server, ofono_emulator_debug, "Server");
+ g_at_server_set_disconnect_function(e->server, emulator_disconnect, e);
+
+ g_io_channel_unref(channel);
+
+ e->powered = TRUE;
+
+ return TRUE;
+
+error:
+ if (channel) {
+ g_io_channel_shutdown(channel, FALSE, NULL);
+ g_io_channel_unref(channel);
+ }
+
+ if (server) {
+ g_at_server_shutdown(server);
+ g_at_server_unref(server);
+ }
+
+ return FALSE;
+}
+
static struct ofono_emulator *create_emulator(struct ofono_modem *modem,
struct ofono_emulator_driver *driver)
{
@@ -156,8 +239,52 @@ static DBusMessage *emulator_get_properties(DBusConnection *conn,
return dbus_message_new_method_return(msg);
}
+static DBusMessage *emulator_enable(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBusMessage *reply;
+ struct ofono_emulator *e = data;
+ const char *path;
+ int fd;
+ ofono_bool_t powered = TRUE;
+
+ if (!e)
+ return FALSE;
+
+ if (dbus_message_get_args(msg, NULL, DBUS_TYPE_UNIX_FD, &fd,
+ DBUS_TYPE_INVALID) == FALSE)
+ return __ofono_error_invalid_args(msg);
+
+ if (set_powered(e, TRUE, fd) < 0)
+ return __ofono_error_failed(msg);
+
+ reply = dbus_message_new_method_return(msg);
+ path = ofono_emulator_get_path(e);
+ dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &path,
+ DBUS_TYPE_INVALID);
+
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_EMULATOR_INTERFACE,
+ "Powered", DBUS_TYPE_BOOLEAN,
+ &powered);
+ return reply;
+}
+
+static DBusMessage *emulator_disable(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct ofono_emulator *e = data;
+
+ set_powered(e, FALSE, 0);
+
+ return dbus_message_new_method_return(msg);
+}
+
static GDBusMethodTable ofono_emulator_methods[] = {
{ "GetProperties", "", "a{sv}", emulator_get_properties },
+ { "Enable", "h", "", emulator_enable,
+ G_DBUS_METHOD_FLAG_ASYNC },
+ { "Disable", "", "", emulator_disable },
{ }
};
--
1.6.3.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 5/6] emulator: Add test case for ofono emulator
2010-07-05 5:45 ` [PATCH 4/6] emulator: Add Enable/Disable for oFono emulator Zhenhua Zhang
@ 2010-07-05 5:45 ` Zhenhua Zhang
2010-07-05 5:45 ` [PATCH 6/6] dun_gw: Probe emulator when we have new adapter Zhenhua Zhang
0 siblings, 1 reply; 14+ messages in thread
From: Zhenhua Zhang @ 2010-07-05 5:45 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 16548 bytes --]
Add gatchat/test-emulator to test DUN emulator.
1. Start ofonod and power on phonesim modem.
2. Run gatchat/test-emulator. It could find dun emulator and create pty
terminal. Use minicom to talk to the DUN emulator.
---
Makefile.am | 7 +-
gatchat/test-emulator.c | 654 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 660 insertions(+), 1 deletions(-)
create mode 100644 gatchat/test-emulator.c
diff --git a/Makefile.am b/Makefile.am
index 908e945..b5e53a9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -405,7 +405,8 @@ unit_test_caif_SOURCES = unit/test-caif.c $(gatchat_sources) \
unit_test_caif_LDADD = @GLIB_LIBS@
unit_objects += $(unit_test_caif_OBJECTS)
-noinst_PROGRAMS += gatchat/gsmdial gatchat/test-server gatchat/test-qcdm
+noinst_PROGRAMS += gatchat/gsmdial gatchat/test-server gatchat/test-qcdm \
+ gatchat/test-emulator
gatchat_gsmdial_SOURCES = gatchat/gsmdial.c $(gatchat_sources)
gatchat_gsmdial_LDADD = @GLIB_LIBS@
@@ -416,6 +417,10 @@ gatchat_test_server_LDADD = @GLIB_LIBS@ -lutil
gatchat_test_qcdm_SOURCES = gatchat/test-qcdm.c $(gatchat_sources)
gatchat_test_qcdm_LDADD = @GLIB_LIBS@
+gatchat_test_emulator_SOURCES = gatchat/test-emulator.c $(gatchat_sources) \
+ $(gdbus_sources)
+gatchat_test_emulator_LDADD = @GLIB_LIBS@ -lutil -ldbus-1
+
DISTCHECK_CONFIGURE_FLAGS = --disable-datafiles
diff --git a/gatchat/test-emulator.c b/gatchat/test-emulator.c
new file mode 100644
index 0000000..562d9e2
--- /dev/null
+++ b/gatchat/test-emulator.c
@@ -0,0 +1,654 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2010 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 <unistd.h>
+#include <stdio.h>
+#include <getopt.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <signal.h>
+#include <sys/signalfd.h>
+
+#include <gdbus.h>
+#include <glib.h>
+#include <utmp.h>
+#include <pty.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "gatserver.h"
+
+#define OFONO_SERVICE "org.ofono"
+#define OFONO_MANAGER_INTERFACE "org.ofono.Manager"
+#define OFONO_MODEM_INTERFACE "org.ofono.Modem"
+#define OFONO_GPRS_INTERFACE "org.ofono.DataConnectionManager"
+#define OFONO_EMULATOR_INTERFACE "org.ofono.Emulator"
+
+#define DEFAULT_TCP_PORT 12346
+#define DEFAULT_SOCK_PATH "./server_sock"
+
+struct sock_server{
+ int server_sock;
+};
+
+static GMainLoop *mainloop;
+static DBusConnection *connection;
+static GSList *modem_list;
+static char *modem_path;
+static unsigned int server_watch;
+const char *emulator = "DUN";
+
+typedef void (*DBusNotifyFunction) (DBusMessage *message, void *user_data);
+
+static gboolean send_method_call_with_block(const char *dest, const char *path,
+ const char *interface, const char *method,
+ DBusNotifyFunction cb,
+ void *user_data, int type, ...)
+{
+ DBusMessage *msg, *reply;
+ DBusError err;
+ va_list args;
+
+ msg = dbus_message_new_method_call(dest, path, interface, method);
+ if (!msg) {
+ g_print("Unable to allocate new D-Bus %s message\n", method);
+ return FALSE;
+ }
+
+ va_start(args, type);
+
+ if (!dbus_message_append_args_valist(msg, type, args)) {
+ dbus_message_unref(msg);
+ va_end(args);
+ return FALSE;
+ }
+
+ va_end(args);
+
+ dbus_error_init(&err);
+ reply = dbus_connection_send_with_reply_and_block(connection, msg, 100,
+ &err);
+ if (!reply) {
+ dbus_message_unref(msg);
+ g_print("ofono replied with an error: %s, %s\n",
+ err.name, err.message);
+ dbus_error_free(&err);
+ return FALSE;
+ }
+
+ cb(reply, user_data);
+
+ dbus_message_unref(msg);
+
+ return TRUE;
+}
+
+static gboolean server_cleanup()
+{
+ if (server_watch)
+ g_source_remove(server_watch);
+
+ g_free(modem_path);
+
+ if (modem_list) {
+ g_slist_foreach(modem_list, (GFunc)g_free, NULL);
+ g_slist_free(modem_list);
+ }
+
+ dbus_connection_unref(connection);
+
+ unlink(DEFAULT_SOCK_PATH);
+
+ g_main_loop_quit(mainloop);
+
+ return FALSE;
+}
+
+static void server_destroy(gpointer user)
+{
+ struct sock_server *data = user;
+
+ g_free(data);
+}
+
+static void enable_emulator_cb(DBusMessage *reply, gpointer user_data)
+{
+ DBusError derr;
+
+ dbus_error_init(&derr);
+
+ if (dbus_set_error_from_message(&derr, reply)) {
+ g_print("Failed to create emulator: %s\n", derr.message);
+ dbus_error_free(&derr);
+ }
+
+ dbus_message_unref(reply);
+}
+
+static void enable_emulator(int fd)
+{
+ char path[256];
+
+ if (!connection || !modem_path || !emulator)
+ return;
+
+ g_print("Enable %s emulator on %s\n", emulator, modem_path);
+
+ snprintf(path, sizeof(path), "%s/dun_emulator", modem_path);
+
+ send_method_call_with_block(OFONO_SERVICE, path,
+ OFONO_EMULATOR_INTERFACE,
+ "Enable", enable_emulator_cb,
+ NULL, DBUS_TYPE_UNIX_FD, &fd,
+ DBUS_TYPE_INVALID);
+}
+
+static void set_raw_mode(int fd)
+{
+ struct termios ti;
+
+ tcflush(fd, TCIOFLUSH);
+
+ memset(&ti, 0, sizeof(ti));
+ tcgetattr(fd, &ti);
+ cfmakeraw(&ti);
+ tcsetattr(fd, TCSANOW, &ti);
+}
+
+static gboolean create_tty()
+{
+ int master, slave;
+ char pty_name[256];
+
+ if (openpty(&master, &slave, pty_name, NULL, NULL) < 0)
+ return FALSE;
+
+ set_raw_mode(slave);
+
+ g_print("new pty is created@%s\n", pty_name);
+
+ enable_emulator(master);
+
+ close(master);
+
+ return TRUE;
+}
+
+static gboolean on_socket_connected(GIOChannel *chan, GIOCondition cond,
+ gpointer user)
+{
+ struct sockaddr saddr;
+ unsigned int len = sizeof(saddr);
+ int fd;
+ struct sock_server *data = user;
+
+ if (cond != G_IO_IN)
+ goto error;
+
+ fd = accept(data->server_sock, &saddr, &len);
+ if (fd == -1)
+ goto error;
+
+ enable_emulator(fd);
+
+ close(fd);
+
+ return TRUE;
+
+error:
+ g_free(data);
+
+ return FALSE;
+}
+
+static struct sock_server *socket_common(int sk, struct sockaddr *addr,
+ const char *modem_path)
+{
+ struct sock_server *sock;
+ int reuseaddr = 1;
+
+ setsockopt(sk, SOL_SOCKET, SO_REUSEADDR, &reuseaddr, sizeof(reuseaddr));
+
+ if (bind(sk, addr, sizeof(struct sockaddr)) < 0) {
+ g_print("Can't bind socket: %s (%d)", strerror(errno), errno);
+
+ close(sk);
+
+ return NULL;
+ }
+
+ if (listen(sk, 1) < 0) {
+ g_print("Can't listen on socket: %s (%d)",
+ strerror(errno), errno);
+
+ close(sk);
+
+ return NULL;
+ }
+
+ sock = g_try_new0(struct sock_server, 1);
+ if (!sock)
+ return FALSE;
+
+ sock->server_sock = sk;
+
+ return sock;
+}
+
+static gboolean create_tcp(int port)
+{
+ struct sockaddr_in addr;
+ int sk;
+ struct sock_server *server;
+ GIOChannel *server_io;
+
+ sk = socket(PF_INET, SOCK_STREAM, 0);
+ if (sk < 0) {
+ g_print("Can't create tcp/ip socket: %s (%d)\n",
+ strerror(errno), errno);
+ return FALSE;
+ }
+
+ memset(&addr, 0, sizeof(addr));
+
+ addr.sin_family = AF_INET;
+ addr.sin_addr.s_addr = INADDR_ANY;
+ addr.sin_port = htons(port);
+
+ server = socket_common(sk, (struct sockaddr *) &addr, modem_path);
+ if (!server)
+ return FALSE;
+
+ g_print("new tcp is created at tcp port %d\n", port);
+
+ server_io = g_io_channel_unix_new(sk);
+
+ g_io_channel_set_close_on_unref(server_io, TRUE);
+
+ server_watch = g_io_add_watch_full(server_io,
+ G_PRIORITY_DEFAULT,
+ G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+ on_socket_connected, server, server_destroy);
+
+ g_io_channel_unref(server_io);
+
+ return TRUE;
+}
+
+static gboolean create_unix(const char *sock_path)
+{
+ struct sockaddr_un addr;
+ int sk;
+ struct sock_server *server;
+ GIOChannel *server_io;
+
+ sk = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (sk < 0) {
+ g_print("Can't create unix socket: %s (%d)\n",
+ strerror(errno), errno);
+
+ return FALSE;
+ }
+
+ memset(&addr, 0, sizeof(addr));
+
+ addr.sun_family = AF_UNIX;
+ strncpy(addr.sun_path, sock_path, sizeof(addr.sun_path) - 1);
+
+ /* Unlink any existing socket for this session */
+ unlink(addr.sun_path);
+
+ server = socket_common(sk, (struct sockaddr *) &addr, modem_path);
+ if (!server)
+ return FALSE;
+
+ g_print("new unix socket is created at %s\n", sock_path);
+
+ server_io = g_io_channel_unix_new(sk);
+
+ g_io_channel_set_close_on_unref(server_io, TRUE);
+
+ server_watch = g_io_add_watch_full(server_io,
+ G_PRIORITY_DEFAULT,
+ G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+ on_socket_connected, server, server_destroy);
+
+ g_io_channel_unref(server_io);
+
+ return TRUE;
+}
+
+static gboolean test_emulator(int type)
+{
+ if (!connection || !modem_path || !emulator)
+ return FALSE;
+
+ switch (type) {
+ case 0:
+ if (create_tty() == FALSE)
+ return FALSE;
+ break;
+ case 1:
+ if (create_tcp(DEFAULT_TCP_PORT) == FALSE)
+ return FALSE;
+ break;
+ case 2:
+ if (create_unix(DEFAULT_SOCK_PATH) == FALSE)
+ return FALSE;
+ break;
+ }
+
+ return TRUE;
+}
+
+static gboolean signal_cb(GIOChannel *channel, GIOCondition cond, gpointer data)
+{
+ int signal_fd = GPOINTER_TO_INT(data);
+ struct signalfd_siginfo si;
+ ssize_t res;
+
+ if (cond & (G_IO_NVAL | G_IO_ERR))
+ return FALSE;
+
+ res = read(signal_fd, &si, sizeof(si));
+ if (res != sizeof(si))
+ return FALSE;
+
+ switch (si.ssi_signo) {
+ case SIGINT:
+ server_cleanup();
+ break;
+ case SIGTERM:
+ server_cleanup();
+ break;
+ default:
+ break;
+ }
+
+ return TRUE;
+}
+
+static int create_signal_io()
+{
+ sigset_t mask;
+ GIOChannel *signal_io;
+ int signal_fd, signal_source;
+
+ sigemptyset(&mask);
+ sigaddset(&mask, SIGTERM);
+ sigaddset(&mask, SIGINT);
+
+ if (sigprocmask(SIG_BLOCK, &mask, NULL) < 0) {
+ g_error("Can't set signal mask");
+ return 1;
+ }
+
+ signal_fd = signalfd(-1, &mask, 0);
+ if (signal_fd < 0) {
+ g_error("Can't create signal filedescriptor");
+ return 1;
+ }
+
+ signal_io = g_io_channel_unix_new(signal_fd);
+
+ g_io_channel_set_close_on_unref(signal_io, TRUE);
+
+ signal_source = g_io_add_watch(signal_io,
+ G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+ signal_cb, GINT_TO_POINTER(signal_fd));
+
+ g_io_channel_unref(signal_io);
+
+ return signal_source;
+}
+
+static void usage(void)
+{
+ g_print("test-emulator - oFono emulator testing\n"
+ "Usage:\n");
+ g_print("\ttest-emulator [-t type] [-e emulator] \n");
+ g_print("Types:\n"
+ "\t0: Pseudo TTY port (default)\n"
+ "\t1: TCP sock at port 12346)\n"
+ "\t2: Unix sock@./server_sock\n\n"
+ "Emulators:\n"
+ "\tDUN: Dial-up Network (default)\n");
+}
+
+static gboolean modem_has_gprs(DBusMessageIter *array)
+{
+ DBusMessageIter entry;
+
+ dbus_message_iter_recurse(array, &entry);
+
+ while (dbus_message_iter_get_arg_type(&entry) == DBUS_TYPE_STRING) {
+ const char *interface;
+
+ dbus_message_iter_get_basic(&entry, &interface);
+
+ if (g_strcmp0(OFONO_GPRS_INTERFACE, interface) == 0)
+ return TRUE;
+
+ dbus_message_iter_next(&entry);
+ }
+
+ return FALSE;
+}
+
+static void get_modem_properties_cb(DBusMessage *reply, gpointer user_data)
+{
+ DBusError err;
+ DBusMessageIter array, dict;
+ const char *path = user_data;
+
+ dbus_error_init(&err);
+ if (dbus_set_error_from_message(&err, reply)) {
+ g_print("ofono replied with an error: %s, %s\n",
+ err.name, err.message);
+ dbus_error_free(&err);
+ goto done;
+ }
+
+ if (dbus_message_iter_init(reply, &array) == FALSE)
+ goto done;
+
+ if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY)
+ goto done;
+
+ dbus_message_iter_recurse(&array, &dict);
+
+ while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
+ DBusMessageIter entry, value;
+ const char *key;
+ dbus_bool_t powered;
+
+ dbus_message_iter_recurse(&dict, &entry);
+ dbus_message_iter_get_basic(&entry, &key);
+
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &value);
+
+ if (g_str_equal(key, "Powered") == TRUE) {
+ dbus_message_iter_get_basic(&value, &powered);
+
+ if (powered == FALSE)
+ goto done;
+ }
+
+ if (g_str_equal(key, "Interfaces") == TRUE) {
+ if (modem_has_gprs(&value) == TRUE) {
+ modem_path = g_strdup(path);
+ goto done;
+ }
+ }
+
+ dbus_message_iter_next(&dict);
+ }
+
+done:
+ dbus_message_unref(reply);
+}
+
+static void get_modem_properties(const char *path)
+{
+
+ if (path == NULL)
+ return;
+
+ send_method_call_with_block(OFONO_SERVICE, path, OFONO_MODEM_INTERFACE,
+ "GetProperties",
+ get_modem_properties_cb,
+ (void *)path, DBUS_TYPE_INVALID);
+}
+
+static void get_properties_cb(DBusMessage *reply, gpointer user_data)
+{
+ DBusError err;
+ DBusMessageIter iter, iter_entry, iter_property, iter_arrary, sub;
+ char *property;
+
+ dbus_error_init(&err);
+ if (dbus_set_error_from_message(&err, reply)) {
+ g_print("ofono replied with an error: %s, %s\n",
+ err.name, err.message);
+ dbus_error_free(&err);
+ goto done;
+ }
+
+ dbus_message_iter_init(reply, &iter);
+
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY) {
+ g_print("Unexpected signature in ListModems return\n");
+ goto done;
+ }
+
+ dbus_message_iter_recurse(&iter, &iter_entry);
+
+ if (dbus_message_iter_get_arg_type(&iter_entry)
+ != DBUS_TYPE_DICT_ENTRY) {
+ g_print("Unexpected signature in ListModems return 2, %c\n",
+ dbus_message_iter_get_arg_type(&iter_entry));
+ goto done;
+ }
+
+ dbus_message_iter_recurse(&iter_entry, &iter_property);
+
+ dbus_message_iter_get_basic(&iter_property, &property);
+
+ dbus_message_iter_next(&iter_property);
+ dbus_message_iter_recurse(&iter_property, &iter_arrary);
+ dbus_message_iter_recurse(&iter_arrary, &sub);
+ while (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_INVALID) {
+ const char *path;
+
+ dbus_message_iter_get_basic(&sub, &path);
+ dbus_message_iter_next(&sub);
+
+ modem_list = g_slist_prepend(modem_list, g_strdup(path));
+ }
+
+done:
+ dbus_message_unref(reply);
+}
+
+int main(int argc, char **argv)
+{
+ int opt, signal_source;
+ int type = 0;
+ DBusError error;
+ GSList *l;
+
+ while ((opt = getopt(argc, argv, "ht:e:")) != EOF) {
+ switch (opt) {
+ case 't':
+ type = atoi(optarg);
+ break;
+ case 'e':
+ emulator = optarg;
+ break;
+ case 'h':
+ usage();
+ exit(1);
+ break;
+ default:
+ break;
+ }
+ }
+
+ dbus_error_init(&error);
+
+ connection = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, &error);
+ if (!connection) {
+ if (dbus_error_is_set(&error) == TRUE) {
+ g_print("Unable to hop onto D-Bus: %s\n",
+ error.message);
+ dbus_error_free(&error);
+ } else {
+ g_print("Unable to hop onto D-Bus\n");
+ }
+
+ return -1;
+ }
+
+ send_method_call_with_block(OFONO_SERVICE, "/", OFONO_MANAGER_INTERFACE,
+ "GetProperties", get_properties_cb,
+ NULL, DBUS_TYPE_INVALID);
+
+ for (l = modem_list; l; l = l->next) {
+ const char *path = l->data;
+
+ get_modem_properties(path);
+ }
+
+ if (!test_emulator(type)) {
+ if (modem_list) {
+ g_slist_foreach(modem_list, (GFunc)g_free, NULL);
+ g_slist_free(modem_list);
+ }
+
+ g_free(modem_path);
+ dbus_connection_unref(connection);
+
+ exit(1);
+ }
+
+ signal_source = create_signal_io();
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ g_main_loop_run(mainloop);
+
+ g_main_loop_unref(mainloop);
+
+ g_source_remove(signal_source);
+
+ return 0;
+}
--
1.6.3.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 6/6] dun_gw: Probe emulator when we have new adapter
2010-07-05 5:45 ` [PATCH 5/6] emulator: Add test case for ofono emulator Zhenhua Zhang
@ 2010-07-05 5:45 ` Zhenhua Zhang
0 siblings, 0 replies; 14+ messages in thread
From: Zhenhua Zhang @ 2010-07-05 5:45 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 4621 bytes --]
Create emulator when we receive Bluetooth adapter property changes. In
order to do that, we iterate all active modems. If it has GPRS atom and
has not associated DUN emulator yet, create new emulator for it.
---
include/emulator.h | 4 ++++
plugins/dun_gw.c | 29 +++++++++++++++++++++++++++++
src/emulator.c | 28 ++++++++++++++++++++++++++++
src/modem.c | 15 +++++++++++++++
src/ofono.h | 6 ++++++
5 files changed, 82 insertions(+), 0 deletions(-)
diff --git a/include/emulator.h b/include/emulator.h
index 9d96d67..2d23795 100644
--- a/include/emulator.h
+++ b/include/emulator.h
@@ -45,6 +45,10 @@ struct ofono_emulator_driver {
};
const char *ofono_emulator_get_path(struct ofono_emulator *e);
+
+struct ofono_emulator *ofono_emulator_find(struct ofono_modem *modem,
+ const char *type_str);
+
void ofono_emulator_set_data(struct ofono_emulator *e, void *user_data);
void *ofono_emulator_get_data(struct ofono_emulator *e);
diff --git a/plugins/dun_gw.c b/plugins/dun_gw.c
index 43a0b0a..8169228 100644
--- a/plugins/dun_gw.c
+++ b/plugins/dun_gw.c
@@ -57,6 +57,33 @@ struct dun_data {
static struct ofono_emulator_driver dun_gw_driver;
+static gboolean dun_gw_probe_emulator(struct ofono_modem *modem,
+ gpointer user_data)
+{
+ struct ofono_emulator *e;
+ ofono_bool_t powered;
+ struct ofono_atom *gprs_atom;
+
+ powered = ofono_modem_get_powered(modem);
+ if (!powered)
+ return TRUE;
+
+ /* Verify that modem has GPRS atom */
+ gprs_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_GPRS);
+ if (!gprs_atom || !__ofono_atom_get_registered(gprs_atom))
+ return TRUE;
+
+ /* Ignore if DUN already has associated adapter */
+ e = ofono_emulator_find(modem, "dun");
+ if (e)
+ return TRUE;
+
+ ofono_emulator_create(modem, &dun_gw_driver);
+
+ /* Only create DUN emulator on one modem */
+ return FALSE;
+}
+
static int dun_gw_create_adapter(const char *path, const char *dev_addr,
const char *adapter, const char *alias)
{
@@ -80,6 +107,8 @@ static int dun_gw_create_adapter(const char *path, const char *dev_addr,
g_hash_table_insert(adapter_hash, g_strdup(adapter), data);
+ __ofono_modem_foreach(dun_gw_probe_emulator, NULL);
+
return 0;
}
diff --git a/src/emulator.c b/src/emulator.c
index 1155769..c47152e 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -94,6 +94,14 @@ static const char *ofono_emulator_type_to_str(enum ofono_emulator_type type)
}
}
+static enum ofono_emulator_type ofono_emulator_str_to_type(const char *type)
+{
+ if (!strcmp(type, "dun"))
+ return OFONO_EMULATOR_TYPE_DUN;
+
+ return OFONO_EMULATOR_TYPE_NONE;
+}
+
const char *ofono_emulator_get_path(struct ofono_emulator *e)
{
static char path[256];
@@ -105,6 +113,26 @@ const char *ofono_emulator_get_path(struct ofono_emulator *e)
return path;
}
+struct ofono_emulator *ofono_emulator_find(struct ofono_modem *modem,
+ const char *type_str)
+{
+ GSList *l;
+ enum ofono_emulator_type type;
+
+ type = ofono_emulator_str_to_type(type_str);
+ if (type == OFONO_EMULATOR_TYPE_NONE)
+ return NULL;
+
+ for (l = emulator_list; l; l = l->next) {
+ struct ofono_emulator *e = l->data;
+
+ if (e->modem == modem && e->driver->type == type)
+ return e;
+ }
+
+ return NULL;
+}
+
void ofono_emulator_set_data(struct ofono_emulator *e, void *user_data)
{
if (!e)
diff --git a/src/modem.c b/src/modem.c
index 8137f97..697b068 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -1092,6 +1092,21 @@ void *ofono_devinfo_get_data(struct ofono_devinfo *info)
return info->driver_data;
}
+void __ofono_modem_foreach(ofono_modem_foreach_cb func, gpointer user_data)
+{
+ GSList *l;
+ struct ofono_modem *modem;
+ gboolean ret;
+
+ for (l = g_modem_list; l; l = l->next) {
+ modem = l->data;
+
+ ret = (*func)(modem, user_data);
+ if (!ret)
+ break;
+ }
+}
+
/* Clients only need to free *modems
*
* Note: this function will never return NULL. It will abort if it
diff --git a/src/ofono.h b/src/ofono.h
index ac2a5b0..b2f83c2 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -30,6 +30,12 @@ void __ofono_exit();
int __ofono_manager_init();
void __ofono_manager_cleanup();
+struct ofono_modem;
+
+typedef gboolean (*ofono_modem_foreach_cb)(struct ofono_modem *modem,
+ gpointer user_data);
+
+void __ofono_modem_foreach(ofono_modem_foreach_cb func, gpointer user_data);
const char **__ofono_modem_get_list();
void __ofono_modem_shutdown();
--
1.6.3.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 2/6] bluetooth: Add register service for bluetooth
2010-07-05 5:45 ` [PATCH 2/6] bluetooth: Add register service for bluetooth Zhenhua Zhang
2010-07-05 5:45 ` [PATCH 3/6] dun_gw: Add DUN emulator plugin Zhenhua Zhang
@ 2010-07-09 14:20 ` Gustavo F. Padovan
2010-07-12 3:27 ` Zhang, Zhenhua
1 sibling, 1 reply; 14+ messages in thread
From: Gustavo F. Padovan @ 2010-07-09 14:20 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 7658 bytes --]
Hi Zhenhua,
* Zhenhua Zhang <zhenhua.zhang@intel.com> [2010-07-05 13:45:05 +0800]:
> Add bluetooth_register_service() and bluetooth_unregister_service()
> where bluetooth profiles plugins like DUN GW can register themselves per
> adapter. It shares existing bluetooth framework to listen bluetooth
> events (new adapters, bluetoothd shutdown, etc..)
> ---
> plugins/bluetooth.c | 125 ++++++++++++++++++++++++++++++++++++++++++---------
> plugins/bluetooth.h | 8 +++
> 2 files changed, 112 insertions(+), 21 deletions(-)
>
> diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
> index 5a85eaa..3a3b5e6 100644
> --- a/plugins/bluetooth.c
> +++ b/plugins/bluetooth.c
> @@ -38,8 +38,19 @@
>
> static DBusConnection *connection;
> static GHashTable *uuid_hash = NULL;
> +static GHashTable *service_hash = NULL;
> static GHashTable *adapter_address_hash = NULL;
>
> +static char *bluetooth_service_type_to_str(enum bluetooth_service_type type)
> +{
> + switch (type) {
> + case DUN_GATEWAY:
> + return "DUN";
> + default:
> + return "";
> + }
> +}
> +
We actually don't need this function, you can put the
'enum bluetooth_service_type' value as hash key. Sounds better.
> void bluetooth_create_path(const char *dev_addr, const char *adapter_addr,
> char *buf, int size)
> {
> @@ -376,6 +387,9 @@ static void adapter_properties_cb(DBusPendingCall *call, gpointer user_data)
> GSList *device_list = NULL;
> GSList *l;
> const char *addr;
> + GHashTableIter hash_iter;
> + gpointer key, value;
> + struct bluetooth_profile *profile;
>
> reply = dbus_pending_call_steal_reply(call);
>
> @@ -393,6 +407,12 @@ static void adapter_properties_cb(DBusPendingCall *call, gpointer user_data)
> g_hash_table_insert(adapter_address_hash,
> g_strdup(path), g_strdup(addr));
>
> + g_hash_table_iter_init(&hash_iter, service_hash);
> + while (g_hash_table_iter_next(&hash_iter, &key, &value)) {
> + profile = value;
> + profile->create(path, NULL, addr, NULL);
You have to check if profile and profile->create is not NULL. It is more
safe.
> + }
> +
> for (l = device_list; l; l = l->next) {
> const char *device = l->data;
>
> @@ -492,10 +512,13 @@ static void bluetooth_remove_all_modem(gpointer key, gpointer value,
>
> static void bluetooth_disconnect(DBusConnection *connection, void *user_data)
> {
> - if (!uuid_hash)
> - return;
> + if (uuid_hash)
> + g_hash_table_foreach(uuid_hash, bluetooth_remove_all_modem,
> + NULL);
>
> - g_hash_table_foreach(uuid_hash, bluetooth_remove_all_modem, NULL);
> + if (service_hash)
> + g_hash_table_foreach(service_hash, bluetooth_remove_all_modem,
> + NULL);
> }
>
> static guint bluetooth_watch;
> @@ -503,12 +526,12 @@ static guint adapter_added_watch;
> static guint adapter_removed_watch;
> s.tatic guint property_watch;
>
> -int bluetooth_register_uuid(const char *uuid, struct bluetooth_profile *profile)
> +static int bluetooth_init()
> {
So I prefer a real refcount structure here, and call this
bluetooth_ref(). What do you think?
> int err;
>
> - if (uuid_hash)
> - goto done;
> + if (adapter_address_hash)
> + return 0;
>
> connection = ofono_dbus_get_connection();
>
> @@ -536,19 +559,9 @@ int bluetooth_register_uuid(const char *uuid, struct bluetooth_profile *profile)
> goto remove;
> }
>
> - uuid_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
> - g_free, NULL);
> -
> adapter_address_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
> g_free, g_free);
>
> -done:
> - g_hash_table_insert(uuid_hash, g_strdup(uuid), profile);
> -
> - bluetooth_send_with_reply("/", BLUEZ_MANAGER_INTERFACE, "GetProperties",
> - manager_properties_cb, NULL, NULL, -1,
> - DBUS_TYPE_INVALID);
> -
> return 0;
>
> remove:
> @@ -556,14 +569,13 @@ remove:
> g_dbus_remove_watch(connection, adapter_added_watch);
> g_dbus_remove_watch(connection, adapter_removed_watch);
> g_dbus_remove_watch(connection, property_watch);
> +
> return err;
> }
>
> -void bluetooth_unregister_uuid(const char *uuid)
> +static void bluetooth_exit()
and this one coul be bluetooth_unref()
> {
> - g_hash_table_remove(uuid_hash, uuid);
> -
> - if (g_hash_table_size(uuid_hash))
> + if (uuid_hash != NULL || service_hash != NULL)
> return;
>
> g_dbus_remove_watch(connection, bluetooth_watch);
> @@ -571,9 +583,80 @@ void bluetooth_unregister_uuid(const char *uuid)
> g_dbus_remove_watch(connection, adapter_removed_watch);
> g_dbus_remove_watch(connection, property_watch);
>
> - g_hash_table_destroy(uuid_hash);
> g_hash_table_destroy(adapter_address_hash);
> +}
> +
> +
> +int bluetooth_register_uuid(const char *uuid, struct bluetooth_profile *profile)
> +{
> + int err;
> +
> + err = bluetooth_init();
> + if (err)
> + return err;
> +
> + if (!uuid_hash)
> + uuid_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
> + g_free, NULL);
> +
> + g_hash_table_insert(uuid_hash, g_strdup(uuid), profile);
> +
> + bluetooth_send_with_reply("/", BLUEZ_MANAGER_INTERFACE, "GetProperties",
> + manager_properties_cb, NULL, NULL, -1,
> + DBUS_TYPE_INVALID);
> +
> + return 0;
> +}
> +
> +void bluetooth_unregister_uuid(const char *uuid)
> +{
> + g_hash_table_remove(uuid_hash, uuid);
> +
> + if (g_hash_table_size(uuid_hash) > 0)
> + return;
> +
> + g_hash_table_destroy(uuid_hash);
> uuid_hash = NULL;
> + bluetooth_exit();
> +}
> +
> +int bluetooth_register_service(enum bluetooth_service_type type,
> + struct bluetooth_profile *profile)
> +{
> + int err;
> + char *type_str;
> +
> + err = bluetooth_init();
> + if (err)
> + return err;
> +
> + type_str = bluetooth_service_type_to_str(type);
> +
> + if (!service_hash)
> + service_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
> + g_free, NULL);
> +
> + g_hash_table_insert(service_hash, g_strdup(type_str), profile);
> +
> + bluetooth_send_with_reply("/", BLUEZ_MANAGER_INTERFACE, "GetProperties",
> + manager_properties_cb, NULL, NULL, -1,
> + DBUS_TYPE_INVALID);
> +
> + return 0;
> +}
> +
> +void bluetooth_unregister_service(enum bluetooth_service_type type)
> +{
> + char *type_str = bluetooth_service_type_to_str(type);
> +
> + g_hash_table_remove(service_hash, type_str);
> +
> + if (g_hash_table_size(service_hash) > 0)
> + return;
> +
> + g_hash_table_destroy(service_hash);
> + service_hash = NULL;
> + bluetooth_exit();
> }
>
> OFONO_PLUGIN_DEFINE(bluetooth, "Bluetooth Utils Plugins", VERSION,
> diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
> index fb0d841..84707a9 100644
> --- a/plugins/bluetooth.h
> +++ b/plugins/bluetooth.h
> @@ -28,6 +28,10 @@
> /* Profiles bitfield */
> #define HFP_AG 0x01
>
> +enum bluetooth_service_type {
> + DUN_GATEWAY,
> +};
> +
> struct bluetooth_profile {
> const char *name;
> int (*create)(const char *device, const char *dev_addr,
> @@ -40,6 +44,10 @@ int bluetooth_register_uuid(const char *uuid,
> struct bluetooth_profile *profile);
> void bluetooth_unregister_uuid(const char *uuid);
>
> +int bluetooth_register_service(enum bluetooth_service_type type,
> + struct bluetooth_profile *profile);
> +void bluetooth_unregister_service(enum bluetooth_service_type type);
> +
> void bluetooth_create_path(const char *dev_addr, const char *adapter_addr,
> char *buf, int size);
>
> --
> 1.6.3.3
--
Gustavo F. Padovan
http://padovan.org
^ permalink raw reply [flat|nested] 14+ messages in thread
* RE: [PATCH 2/6] bluetooth: Add register service for bluetooth
2010-07-09 14:20 ` [PATCH 2/6] bluetooth: Add register service for bluetooth Gustavo F. Padovan
@ 2010-07-12 3:27 ` Zhang, Zhenhua
2010-07-12 13:03 ` Gustavo F. Padovan
0 siblings, 1 reply; 14+ messages in thread
From: Zhang, Zhenhua @ 2010-07-12 3:27 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 8593 bytes --]
Hi Padovan,
Gustavo F. Padovan wrote:
> Hi Zhenhua,
>
> * Zhenhua Zhang <zhenhua.zhang@intel.com> [2010-07-05 13:45:05 +0800]:
>
>> Add bluetooth_register_service() and bluetooth_unregister_service()
>> where bluetooth profiles plugins like DUN GW can register themselves
>> per adapter. It shares existing bluetooth framework to listen
>> bluetooth events (new adapters, bluetoothd shutdown, etc..)
>> ---
>> plugins/bluetooth.c | 125
> ++++++++++++++++++++++++++++++++++++++++++---------
>> plugins/bluetooth.h | 8 +++
>> 2 files changed, 112 insertions(+), 21 deletions(-)
>>
>> diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
>> index 5a85eaa..3a3b5e6 100644
>> --- a/plugins/bluetooth.c
>> +++ b/plugins/bluetooth.c
>> @@ -38,8 +38,19 @@
>>
>> static DBusConnection *connection;
>> static GHashTable *uuid_hash = NULL;
>> +static GHashTable *service_hash = NULL;
>> static GHashTable *adapter_address_hash = NULL;
>>
>> +static char *bluetooth_service_type_to_str(enum
>> bluetooth_service_type type) +{ + switch (type) {
>> + case DUN_GATEWAY:
>> + return "DUN";
>> + default:
>> + return "";
>> + }
>> +}
>> +
>
> We actually don't need this function, you can put the
> 'enum bluetooth_service_type' value as hash key. Sounds better.
Agree. It seems the type string is not used in other place except hash table insert/remove. So I will change that.
>> void bluetooth_create_path(const char *dev_addr, const char
>> *adapter_addr, char *buf, int size) {
>> @@ -376,6 +387,9 @@ static void
> adapter_properties_cb(DBusPendingCall *call, gpointer user_data)
>> GSList *device_list = NULL;
>> GSList *l;
>> const char *addr;
>> + GHashTableIter hash_iter;
>> + gpointer key, value;
>> + struct bluetooth_profile *profile;
>>
>> reply = dbus_pending_call_steal_reply(call);
>>
>> @@ -393,6 +407,12 @@ static void
> adapter_properties_cb(DBusPendingCall *call, gpointer user_data)
>> g_hash_table_insert(adapter_address_hash,
>> g_strdup(path), g_strdup(addr));
>>
>> + g_hash_table_iter_init(&hash_iter, service_hash);
>> + while (g_hash_table_iter_next(&hash_iter, &key, &value)) {
>> + profile = value; + profile->create(path, NULL, addr, NULL);
>
> You have to check if profile and profile->create is not NULL.
> It is more
> safe.
Sure. I will add check for both.
>> + }
>> +
>> for (l = device_list; l; l = l->next) {
>> const char *device = l->data;
>>
>> @@ -492,10 +512,13 @@ static void
> bluetooth_remove_all_modem(gpointer key, gpointer value,
>>
>> static void bluetooth_disconnect(DBusConnection *connection, void
>> *user_data) {
>> - if (!uuid_hash)
>> - return;
>> + if (uuid_hash)
>> + g_hash_table_foreach(uuid_hash, bluetooth_remove_all_modem,
>> + NULL);
>>
>> - g_hash_table_foreach(uuid_hash,
> bluetooth_remove_all_modem, NULL);
>> + if (service_hash)
>> + g_hash_table_foreach(service_hash, bluetooth_remove_all_modem,
>> + NULL); }
>>
>> static guint bluetooth_watch;
>> @@ -503,12 +526,12 @@ static guint adapter_added_watch;
>> static guint adapter_removed_watch;
>> s.tatic guint property_watch;
>>
>> -int bluetooth_register_uuid(const char *uuid, struct
>> bluetooth_profile *profile) +static int bluetooth_init() {
>
> So I prefer a real refcount structure here, and call this
> bluetooth_ref(). What do you think?
Good idea. Bluetooth_ref/unref makes more sense if we have both HFP and DUN existings on the system.
Actually I have an unrelated question here. Why we don't have something like DUN_GW_UUID string so that we can easily reuse your current code? For now, we need to register service and use a different hash table to record that.
>> int err;
>>
>> - if (uuid_hash)
>> - goto done;
>> + if (adapter_address_hash)
>> + return 0;
>>
>> connection = ofono_dbus_get_connection();
>>
>> @@ -536,19 +559,9 @@ int bluetooth_register_uuid(const char
> *uuid, struct bluetooth_profile *profile)
>> goto remove;
>> }
>>
>> - uuid_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
>> - g_free, NULL);
>> -
>> adapter_address_hash =
> g_hash_table_new_full(g_str_hash, g_str_equal,
>> g_free, g_free);
>>
>> -done:
>> - g_hash_table_insert(uuid_hash, g_strdup(uuid), profile); -
>> - bluetooth_send_with_reply("/", BLUEZ_MANAGER_INTERFACE,
>> "GetProperties",
>> - manager_properties_cb, NULL, NULL, -1,
>> - DBUS_TYPE_INVALID);
>> -
>> return 0;
>>
>> remove:
>> @@ -556,14 +569,13 @@ remove:
>> g_dbus_remove_watch(connection, adapter_added_watch);
>> g_dbus_remove_watch(connection, adapter_removed_watch);
>> g_dbus_remove_watch(connection, property_watch);
>> +
>> return err;
>> }
>>
>> -void bluetooth_unregister_uuid(const char *uuid)
>> +static void bluetooth_exit()
>
> and this one coul be bluetooth_unref()
>
>> {
>> - g_hash_table_remove(uuid_hash, uuid);
>> -
>> - if (g_hash_table_size(uuid_hash))
>> + if (uuid_hash != NULL || service_hash != NULL)
>> return;
>>
>> g_dbus_remove_watch(connection, bluetooth_watch);
>> @@ -571,9 +583,80 @@ void bluetooth_unregister_uuid(const char *uuid)
>> g_dbus_remove_watch(connection, adapter_removed_watch);
>> g_dbus_remove_watch(connection, property_watch);
>>
>> - g_hash_table_destroy(uuid_hash);
>> g_hash_table_destroy(adapter_address_hash);
>> +}
>> +
>> +
>> +int bluetooth_register_uuid(const char *uuid, struct
>> bluetooth_profile *profile) +{ + int err;
>> +
>> + err = bluetooth_init();
>> + if (err)
>> + return err;
>> +
>> + if (!uuid_hash)
>> + uuid_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
>> + g_free, NULL); +
>> + g_hash_table_insert(uuid_hash, g_strdup(uuid), profile); +
>> + bluetooth_send_with_reply("/", BLUEZ_MANAGER_INTERFACE,
>> "GetProperties", + manager_properties_cb, NULL, NULL, -1,
>> + DBUS_TYPE_INVALID);
>> +
>> + return 0;
>> +}
>> +
>> +void bluetooth_unregister_uuid(const char *uuid)
>> +{
>> + g_hash_table_remove(uuid_hash, uuid);
>> +
>> + if (g_hash_table_size(uuid_hash) > 0)
>> + return;
>> +
>> + g_hash_table_destroy(uuid_hash);
>> uuid_hash = NULL;
>> + bluetooth_exit();
>> +}
>> +
>> +int bluetooth_register_service(enum bluetooth_service_type type,
>> + struct
> bluetooth_profile *profile)
>> +{
>> + int err;
>> + char *type_str;
>> +
>> + err = bluetooth_init();
>> + if (err)
>> + return err;
>> +
>> + type_str = bluetooth_service_type_to_str(type);
>> +
>> + if (!service_hash)
>> + service_hash =
> g_hash_table_new_full(g_str_hash, g_str_equal,
>> + g_free, NULL);
>> +
>> + g_hash_table_insert(service_hash, g_strdup(type_str), profile); +
>> + bluetooth_send_with_reply("/", BLUEZ_MANAGER_INTERFACE,
>> "GetProperties", + manager_properties_cb, NULL, NULL, -1,
>> + DBUS_TYPE_INVALID);
>> +
>> + return 0;
>> +}
>> +
>> +void bluetooth_unregister_service(enum bluetooth_service_type type)
>> +{ + char *type_str = bluetooth_service_type_to_str(type); +
>> + g_hash_table_remove(service_hash, type_str);
>> +
>> + if (g_hash_table_size(service_hash) > 0)
>> + return;
>> +
>> + g_hash_table_destroy(service_hash);
>> + service_hash = NULL;
>> + bluetooth_exit();
>> }
>>
>> OFONO_PLUGIN_DEFINE(bluetooth, "Bluetooth Utils Plugins", VERSION,
>> diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
>> index fb0d841..84707a9 100644
>> --- a/plugins/bluetooth.h
>> +++ b/plugins/bluetooth.h
>> @@ -28,6 +28,10 @@
>> /* Profiles bitfield */
>> #define HFP_AG 0x01
>>
>> +enum bluetooth_service_type {
>> + DUN_GATEWAY,
>> +};
>> +
>> struct bluetooth_profile {
>> const char *name;
>> int (*create)(const char *device, const char *dev_addr,
>> @@ -40,6 +44,10 @@ int bluetooth_register_uuid(const char *uuid,
>> struct bluetooth_profile *profile);
>> void bluetooth_unregister_uuid(const char *uuid);
>>
>> +int bluetooth_register_service(enum bluetooth_service_type type,
>> + struct
> bluetooth_profile *profile);
>> +void bluetooth_unregister_service(enum bluetooth_service_type
>> type); + void bluetooth_create_path(const char *dev_addr, const
>> char *adapter_addr, char
> *buf, int size);
>>
>> --
>> 1.6.3.3
>
> --
> Gustavo F. Padovan
> http://padovan.org
> _______________________________________________
> ofono mailing list
> ofono(a)ofono.org
> http://lists.ofono.org/listinfo/ofono
Regards,
Zhenhua
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/6] bluetooth: Add register service for bluetooth
2010-07-12 3:27 ` Zhang, Zhenhua
@ 2010-07-12 13:03 ` Gustavo F. Padovan
0 siblings, 0 replies; 14+ messages in thread
From: Gustavo F. Padovan @ 2010-07-12 13:03 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 727 bytes --]
Hi Zhenhua,
> >>
> >> -int bluetooth_register_uuid(const char *uuid, struct
> >> bluetooth_profile *profile) +static int bluetooth_init() {
> >
> > So I prefer a real refcount structure here, and call this
> > bluetooth_ref(). What do you think?
>
> Good idea. Bluetooth_ref/unref makes more sense if we have both HFP and DUN existings on the system.
>
> Actually I have an unrelated question here. Why we don't have something like DUN_GW_UUID string so that we can easily reuse your current code? For now, we need to register service and use a different hash table to record that.
I'm fine with that, but you have to use the DUN Data Terminal UUID
instead.
--
Gustavo F. Padovan
http://padovan.org
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/6] emulator: Add ofono_emulator framework
2010-07-05 5:45 ` [PATCH 1/6] emulator: Add ofono_emulator framework Zhenhua Zhang
2010-07-05 5:45 ` [PATCH 2/6] bluetooth: Add register service for bluetooth Zhenhua Zhang
@ 2010-07-13 17:56 ` Denis Kenzior
2010-07-14 1:10 ` Zhang, Zhenhua
1 sibling, 1 reply; 14+ messages in thread
From: Denis Kenzior @ 2010-07-13 17:56 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2349 bytes --]
Hi Zhenhua,
> +#define OFONO_EMULATOR_INTERFACE "org.ofono.Emulator"
So my suggestion is to keep it simple and not include the D-Bus
interface for the emulator at all for now.
> +
> +#include <ofono/types.h>
> +
> +struct ofono_emulator;
> +
> +enum ofono_emulator_type {
> + OFONO_EMULATOR_TYPE_NONE,
Type NONE seems to be useless :)
> + OFONO_EMULATOR_TYPE_DUN,
> +};
> +
> +struct ofono_emulator_driver {
> + const char *name;
> + enum ofono_emulator_type type;
> + int (*probe)(struct ofono_emulator *e);
> + void (*remove)(struct ofono_emulator *e);
> + int (*enable)(struct ofono_emulator *e, int fd);
> + int (*disable)(struct ofono_emulator *e);
> +};
For the emulator we really don't need a driver, see below...
> +
> +const char *ofono_emulator_get_path(struct ofono_emulator *e);
> +void ofono_emulator_set_data(struct ofono_emulator *e, void *user_data);
> +void *ofono_emulator_get_data(struct ofono_emulator *e);
> +
If there's no driver, then these are not required...
> +struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
> + struct ofono_emulator_driver *driver);
So I think we should simply do it like this:
struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
enum ofono_emulator_type type, int fd);
Once we have the fd we really don't need anything else. If the fd goes
away we can safely remove the atom. If the modem is powered down, we
can safely shut down the connection.
> +void ofono_emulator_remove(struct ofono_emulator *e);
> +
This might or might not be necessary...
> +int ofono_emulator_driver_register(const struct ofono_emulator_driver *driver);
> +void ofono_emulator_driver_unregister(
> + const struct ofono_emulator_driver *driver);
> +
These won't be necessary...
We then treat the emulator atom the same as any atom. When the modem is
powered off the atom is removed. The bluetooth dun plugin can create
look at the list of modems, establish the state watch (e.g. off/on
pre_sim/offline/online) and register the DUN atom appropriately (most
likely when the modem is turned on)
It will be up to the plugin to figure out which Bluetooth adapter to
register on (perhaps always the default one) and which modems to expose
(maybe a configuration file?)
Regards,
-Denis
^ permalink raw reply [flat|nested] 14+ messages in thread
* RE: [PATCH 1/6] emulator: Add ofono_emulator framework
2010-07-13 17:56 ` [PATCH 1/6] emulator: Add ofono_emulator framework Denis Kenzior
@ 2010-07-14 1:10 ` Zhang, Zhenhua
2010-07-14 1:46 ` Denis Kenzior
0 siblings, 1 reply; 14+ messages in thread
From: Zhang, Zhenhua @ 2010-07-14 1:10 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3150 bytes --]
Hi Denis,
Denis Kenzior wrote:
> Hi Zhenhua,
>
>> +#define OFONO_EMULATOR_INTERFACE "org.ofono.Emulator"
>
> So my suggestion is to keep it simple and not include the D-Bus
> interface for the emulator at all for now.
That's fine. Will remove them.
>> +
>> +#include <ofono/types.h>
>> +
>> +struct ofono_emulator;
>> +
>> +enum ofono_emulator_type {
>> + OFONO_EMULATOR_TYPE_NONE,
>
> Type NONE seems to be useless :)
>
>> + OFONO_EMULATOR_TYPE_DUN,
>> +};
>> +
>> +struct ofono_emulator_driver {
>> + const char *name;
>> + enum ofono_emulator_type type;
>> + int (*probe)(struct ofono_emulator *e);
>> + void (*remove)(struct ofono_emulator *e);
>> + int (*enable)(struct ofono_emulator *e, int fd);
>> + int (*disable)(struct ofono_emulator *e);
>> +};
>
> For the emulator we really don't need a driver, see below...
My original idea is that we need support DUN/HFPAG/SPP types of emulators. So we need a good framework to support it. Remember we could have both DUN/HFPAG atoms co-exist at the same time.
Your idea is better. It might work.
>> +
>> +const char *ofono_emulator_get_path(struct ofono_emulator *e);
>> +void ofono_emulator_set_data(struct ofono_emulator *e, void
>> *user_data); +void *ofono_emulator_get_data(struct ofono_emulator
>> *e); +
>
> If there's no driver, then these are not required...
>
>> +struct ofono_emulator *ofono_emulator_create(struct ofono_modem
>> *modem, + struct
> ofono_emulator_driver *driver);
>
> So I think we should simply do it like this:
>
> struct ofono_emulator *ofono_emulator_create(struct ofono_modem
> *modem, enum ofono_emulator_type type, int fd);
>
> Once we have the fd we really don't need anything else. If the fd
> goes away we can safely remove the atom. If the modem is powered
> down, we can safely shut down the connection.
>
>> +void ofono_emulator_remove(struct ofono_emulator *e);
>> +
>
> This might or might not be necessary...
>
>> +int ofono_emulator_driver_register(const struct
> ofono_emulator_driver *driver);
>> +void ofono_emulator_driver_unregister(
>> + const struct
> ofono_emulator_driver *driver);
>> +
>
> These won't be necessary...
>
> We then treat the emulator atom the same as any atom. When
> the modem is
> powered off the atom is removed. The bluetooth dun plugin can create
> look at the list of modems, establish the state watch (e.g. off/on
> pre_sim/offline/online) and register the DUN atom appropriately (most
> likely when the modem is turned on)
>
> It will be up to the plugin to figure out which Bluetooth adapter to
> register on (perhaps always the default one) and which modems to
> expose (maybe a configuration file?)
I grabed code from obex to register&start DUN GW service when we parse adapter properties. From patch 6/6, you can see my current implementation is to find the first powered modem that having GRPS atom. Load settings from modem.conf could be another option. But what if the modem is detected from udev? It could be huawei0, huawei1 or huawei<N>.
> Regards,
> -Denis
Regards,
Zhenhua
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/6] emulator: Add ofono_emulator framework
2010-07-14 1:10 ` Zhang, Zhenhua
@ 2010-07-14 1:46 ` Denis Kenzior
2010-07-14 1:50 ` Zhang, Zhenhua
0 siblings, 1 reply; 14+ messages in thread
From: Denis Kenzior @ 2010-07-14 1:46 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 755 bytes --]
Hi Zhenhua,
> I grabed code from obex to register&start DUN GW service when we parse adapter properties. From patch 6/6, you can see my current implementation is to find the first powered modem that having GRPS atom. Load settings from modem.conf could be another option. But what if the modem is detected from udev? It could be huawei0, huawei1 or huawei<N>.
Doing it via .conf file is still possible. E.g. we might be able to
stipulate that only modems with a particular driver get exported (e.g.
driver="huawei" or driver="isi") Or perhaps a hardcoded path / first
modem available. I wouldn't worry about it for now, do whatever is
easiest. The more interesting part is getting the oFono core emulator
bits working.
Regards,
-Denis
^ permalink raw reply [flat|nested] 14+ messages in thread
* RE: [PATCH 1/6] emulator: Add ofono_emulator framework
2010-07-14 1:46 ` Denis Kenzior
@ 2010-07-14 1:50 ` Zhang, Zhenhua
0 siblings, 0 replies; 14+ messages in thread
From: Zhang, Zhenhua @ 2010-07-14 1:50 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 893 bytes --]
Hi Denis,
Denis Kenzior wrote:
> Hi Zhenhua,
>
>> I grabed code from obex to register&start DUN GW service
> when we parse adapter properties. From patch 6/6, you can see
> my current implementation is to find the first powered modem
> that having GRPS atom. Load settings from modem.conf could be
> another option. But what if the modem is detected from udev?
> It could be huawei0, huawei1 or huawei<N>.
>
> Doing it via .conf file is still possible. E.g. we might be able to
> stipulate that only modems with a particular driver get exported (e.g.
> driver="huawei" or driver="isi") Or perhaps a hardcoded path / first
> modem available. I wouldn't worry about it for now, do whatever is
> easiest. The more interesting part is getting the oFono core
> emulator bits working.
>
> Regards,
> -Denis
Sure. Will update the patches soon.
Regards,
Zhenhua
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2010-07-14 1:50 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-05 5:45 [PATCH 0/6] Add oFono DUN emulator Zhenhua Zhang
2010-07-05 5:45 ` [PATCH 1/6] emulator: Add ofono_emulator framework Zhenhua Zhang
2010-07-05 5:45 ` [PATCH 2/6] bluetooth: Add register service for bluetooth Zhenhua Zhang
2010-07-05 5:45 ` [PATCH 3/6] dun_gw: Add DUN emulator plugin Zhenhua Zhang
2010-07-05 5:45 ` [PATCH 4/6] emulator: Add Enable/Disable for oFono emulator Zhenhua Zhang
2010-07-05 5:45 ` [PATCH 5/6] emulator: Add test case for ofono emulator Zhenhua Zhang
2010-07-05 5:45 ` [PATCH 6/6] dun_gw: Probe emulator when we have new adapter Zhenhua Zhang
2010-07-09 14:20 ` [PATCH 2/6] bluetooth: Add register service for bluetooth Gustavo F. Padovan
2010-07-12 3:27 ` Zhang, Zhenhua
2010-07-12 13:03 ` Gustavo F. Padovan
2010-07-13 17:56 ` [PATCH 1/6] emulator: Add ofono_emulator framework Denis Kenzior
2010-07-14 1:10 ` Zhang, Zhenhua
2010-07-14 1:46 ` Denis Kenzior
2010-07-14 1:50 ` Zhang, Zhenhua
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.