Provider name and SID
v3 cover Provider name and SID
This version is mainly focused by naming changes for consistency.
Philippe.
Philippe Nunes (10):
cdma-provision: Add driver APIs header
ofono.h: add API to get cdma provider name
cdma-provision: Add driver APIs implementation
cdma-provision: Add cdma provisioning plugin
cdma-netreg: Add provider name and SID support
gatchat: Add g_at_chat_set_slave_qcdm / g_at_chat_get_slave_qcdm
huaweicdma: Open qcdm port to be used for network status and cell
location
huaweicdmamodem: Probe the QCDM port with the version info request
huaweicdmamodem: Add 'serving_system' entry point to get SID
udevng: Add a default assignment for Huawei QCDM port
Makefile.am | 4 +- drivers/huaweicdmamodem/network-registration.c | 247 ++++++++++++++++++++++- gatchat/gatchat.c | 26 +++ gatchat/gatchat.h | 4 + include/cdma-provision.h | 44 +++++ plugins/cdma-provision.c | 79 ++++++++ plugins/huaweicdma.c | 44 +++++ plugins/udevng.c | 30 ++- src/cdma-netreg.c | 40 ++++ src/cdma-provision.c | 80 ++++++++ src/ofono.h | 4 + 11 files changed, 580 insertions(+), 22 deletions(-) create mode 100644 include/cdma-provision.h create mode 100644 plugins/cdma-provision.c create mode 100644 src/cdma-provision.c
PATCH v3 1/10 cdma-provision: Add driver APIs header
--- include/cdma-provision.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-) create mode 100644 include/cdma-provision.h
include/cdma-provision.h new file +44 -0
@@ -0,0 +1,44 @@ +/* +* +* oFono - Open Source Telephony +* +* Copyright (C) 2008-2011 Intel Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +* +*/ + +#ifndef __OFONO_CDMA_PROVISION_H +#define __OFONO_CDMA_PROVISION_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct ofono_cdma_provision_driver { +const char *name; +int priority; +int (*get_provider_name)(const char *sid,char **name); +}; + +int ofono_cdma_provision_driver_register ( +const struct ofono_cdma_provision_driver *driver); +void ofono_cdma_provision_driver_unregister ( +const struct ofono_cdma_provision_driver *driver); + +#ifdef __cplusplus +} +#endif + +#endif /* __OFONO_CDMA_PROVISION_H */
Signature · 1 line
1.7.1
PATCH v3 2/10 ofono.h: add API to get cdma provider name
In reply to Philippe Nunes--- src/ofono.h | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
src/ofono.h +4 -0
@@ -487,6 +487,10 @@ void __ofono_gprs_provision_free_settings(#include <ofono/gnss.h> #include <ofono/cdma-sms.h> #include <ofono/cdma-netreg.h> + +#include <ofono/cdma-provision.h> +ofono_bool_t __ofono_cdma_provision_get_name (const char *sid,char **name); +#include <ofono/private-network.h> void __ofono_private_network_release (int id);
Signature · 1 line
1.7.1
PATCH v3 3/10 cdma-provision: Add driver APIs implementation
In reply to Philippe Nunes--- Makefile.am | 4 +- src/cdma-provision.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 src/cdma-provision.c
Makefile.am +2 -2
@@ -18,7 +18,7 @@ pkginclude_HEADERS = include/log.h include/plugin.h include/history.h \ include/location-reporting.h \ include/cdma-connman.h include/gnss.h \ include/private-network.h include/cdma-netreg.h \ - include/handsfree.h + include/cdma-provision.h include/handsfree.h nodist_pkginclude_HEADERS = include/version.h
@@ -430,7 +430,7 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) src/ofono.ver \ src/gnssagent.c src/gnssagent.h \ src/cdma-smsutil.h src/cdma-smsutil.c \ src/cdma-sms.c src/private-network.c src/cdma-netreg.c \ - src/handsfree.c + src/cdma-provision.c src/handsfree.c src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
src/cdma-provision.c new file +80 -0
80 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v3 4/10 cdma-provision: Add cdma provisioning plugin
In reply to Philippe Nunes--- plugins/cdma-provision.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 79 insertions(+), 0 deletions(-) create mode 100644 plugins/cdma-provision.c
plugins/cdma-provision.c new file +79 -0
@@ -0,0 +1,79 @@ +/* +* +* oFono - Open Source Telephony +* +* Copyright (C) 2008-2011 Intel Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +* +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <errno.h> +#include <string.h> + +#include <glib.h> + +#define OFONO_API_SUBJECT_TO_CHANGE +#include <ofono/types.h> +#include <ofono/log.h> +#include <ofono/plugin.h> +#include <ofono/modem.h> +#include <ofono/gprs-provision.h> +#include <ofono/cdma-provision.h> + +#include "mbpi.h" + +static int cdma_provision_get_provider_name (const char *sid,char **name) +{ +GError *error =NULL ; + +DBG ("Search provider name for SID %s" , sid); + + *name =mbpi_lookup_cdma_provider_name (sid, &error); +if (*name ==NULL ) { +if (error !=NULL ) { +ofono_error ("%s" , error->message); +g_error_free (error); + } + +return -ENOENT ; + } + +DBG ("Found provider name: %s" , *name); + +return 0 ; +} + +static struct ofono_cdma_provision_driver provision_driver = { + .name ="CDMA provisioning" , + .get_provider_name = cdma_provision_get_provider_name +}; + +static int cdma_provision_init (void ) +{ +return ofono_cdma_provision_driver_register (&provision_driver); +} + +static void cdma_provision_exit (void ) +{ +ofono_cdma_provision_driver_unregister (&provision_driver); +} + +OFONO_PLUGIN_DEFINE (cdma_provision,"CDMA provisioning Plugin" ,VERSION , +OFONO_PLUGIN_PRIORITY_DEFAULT , + cdma_provision_init, cdma_provision_exit)
Signature · 1 line
1.7.1
PATCH v3 5/10 cdma-netreg: Add provider name and SID support
In reply to Philippe Nunes--- src/cdma-netreg.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 40 insertions(+), 0 deletions(-)
src/cdma-netreg.c +40 -0
@@ -24,6 +24,7 @@#endif #include <errno.h> +#include <string.h> #include <gdbus.h>
@@ -38,6 +39,8 @@ struct ofono_cdma_netreg {const struct ofono_cdma_netreg_driver *driver;void *driver_data;struct ofono_atom *atom; +char *provider_name; +char *sid; };static const char *cdma_netreg_status_to_string (enum cdma_netreg_status status)
@@ -90,6 +93,15 @@ static DBusMessage *network_get_properties(DBusConnection *conn, &strength); } +if (cdma_netreg->sid) +ofono_dbus_dict_append (&dict,"SystemIdentifier" , +DBUS_TYPE_STRING , + &cdma_netreg->sid); + +if (cdma_netreg->provider_name) +ofono_dbus_dict_append (&dict,"Name" ,DBUS_TYPE_STRING , + &cdma_netreg->provider_name); +dbus_message_iter_close_container (&iter, &dict);return reply;
@@ -108,6 +120,8 @@ static void serving_system_callback(const struct ofono_error *error, const char *sid, void *data) { struct ofono_cdma_netreg *cdma_netreg = data; +const char *path =__ofono_atom_get_path (cdma_netreg->atom); +DBusConnection *conn =ofono_dbus_get_connection (); if (cdma_netreg->status != CDMA_NETWORK_REGISTRATION_STATUS_REGISTERED && cdma_netreg->status !=
@@ -120,6 +134,30 @@ static void serving_system_callback(const struct ofono_error *error, }DBG ("Serving system Identifier: %s" , sid); + +if (cdma_netreg->sid !=NULL && !strcmp (cdma_netreg->sid, sid)) +return ; + +g_free (cdma_netreg->provider_name); +g_free (cdma_netreg->sid); + cdma_netreg->provider_name =NULL ; + cdma_netreg->sid =g_strdup (sid); + +ofono_dbus_signal_property_changed (conn, path, +OFONO_CDMA_NETWORK_REGISTRATION_INTERFACE , +"SystemIdentifier" ,DBUS_TYPE_STRING , + &cdma_netreg->sid); + +if (__ofono_cdma_provision_get_name (sid, + &cdma_netreg->provider_name) == FALSE) { +ofono_warn ("Provider name not found" ); +return ; + } + +ofono_dbus_signal_property_changed (conn, path, +OFONO_CDMA_NETWORK_REGISTRATION_INTERFACE , +"Name" ,DBUS_TYPE_STRING , + &cdma_netreg->provider_name); } static void set_registration_status(struct ofono_cdma_netreg *cdma_netreg,
@@ -251,6 +289,8 @@ static void cdma_netreg_remove(struct ofono_atom *atom)if (cdma_netreg->driver && cdma_netreg->driver->remove) cdma_netreg->driver->remove (cdma_netreg); +g_free (cdma_netreg->sid); +g_free (cdma_netreg->provider_name);g_free (cdma_netreg); }
Signature · 1 line
1.7.1
PATCH v3 6/10 gatchat: Add g_at_chat_set_slave_qcdm / g_at_chat_get_slave_qcdm
In reply to Philippe Nunes--- gatchat/gatchat.c | 26 ++++++++++++++++++++++++++ gatchat/gatchat.h | 4 ++++ 2 files changed, 30 insertions(+), 0 deletions(-)
gatchat/gatchat.c +26 -0
@@ -35,6 +35,7 @@#include "ringbuffer.h" #include "gatchat.h" #include "gatio.h" +#include "gathdlc.h" /* #define WRITE_SCHEDULER_DEBUG 1 */
@@ -110,6 +111,7 @@ struct _GAtChat {struct at_chat *parent;guint group;GAtChat *slave; +GAtHDLC *qcdm; };struct terminator_info {
@@ -1354,6 +1356,30 @@ GAtChat *g_at_chat_get_slave(GAtChat *chat)return chat->slave; } +GAtHDLC *g_at_chat_set_slave_qcdm (GAtChat *chat,GAtHDLC *diag) +{ +if (chat ==NULL ) +return NULL ; + +if (chat->qcdm !=NULL ) +g_at_hdlc_unref (chat->qcdm); + +if (diag !=NULL ) + chat->qcdm =g_at_hdlc_ref (diag); +else + chat->qcdm =NULL ; + +return chat->qcdm; +} + +GAtHDLC *g_at_chat_get_slave_qcdm (GAtChat *chat) +{ +if (chat ==NULL ) +return NULL ; + +return chat->qcdm; +} +GIOChannel *g_at_chat_get_channel (GAtChat *chat) {if (chat ==NULL || chat->parent->io ==NULL )
gatchat/gatchat.h +4 -0
@@ -30,6 +30,7 @@ extern "C" {#include "gatsyntax.h" #include "gatutil.h" #include "gatio.h" +#include "gathdlc.h" struct _GAtChat ;
@@ -68,6 +69,9 @@ GAtChat *g_at_chat_clone(GAtChat *chat);GAtChat *g_at_chat_set_slave (GAtChat *chat,GAtChat *slave);GAtChat *g_at_chat_get_slave (GAtChat *chat); +GAtHDLC *g_at_chat_set_slave_qcdm (GAtChat *chat,GAtHDLC *diag); +GAtHDLC *g_at_chat_get_slave_qcdm (GAtChat *chat); +void g_at_chat_suspend (GAtChat *chat);void g_at_chat_resume (GAtChat *chat);
Signature · 1 line
1.7.1
PATCH v3 7/10 huaweicdma: Open qcdm port to be used for network status and cell location
In reply to Philippe Nunes--- plugins/huaweicdma.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-)
plugins/huaweicdma.c +44 -0
@@ -43,6 +43,7 @@struct huaweicdma_data {GAtChat *modem;GAtChat *pcui; +GAtHDLC *diag; };static void huaweicdma_debug (const char *str,void *data)
@@ -77,6 +78,7 @@ static void huaweicdma_remove(struct ofono_modem *modem)/* Cleanup after hot-unplug */ g_at_chat_unref (data->pcui); +g_at_hdlc_unref (data->diag);g_free (data); }
@@ -94,6 +96,9 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)g_at_chat_unref (data->pcui); data->pcui =NULL ; + +g_at_hdlc_unref (data->diag); + data->diag =NULL ; }ofono_modem_set_powered (modem, ok);
@@ -132,6 +137,38 @@ static GAtChat *open_device(struct ofono_modem *modem,return chat; } +static GAtHDLC *open_qcdm (struct ofono_modem *modem) +{ +const char *device; +GIOChannel *channel; +GAtHDLC *hdlc; + + device =ofono_modem_get_string (modem,"Diag" ); +if (device ==NULL ) +return NULL ; + +DBG ("Diagnostic Monitor %s" , device); + + channel =g_at_tty_open_qcdm (device); +if (channel ==NULL ) +return NULL ; + + hdlc =g_at_hdlc_new (channel); + +g_io_channel_unref (channel); + +if (hdlc ==NULL ) +return NULL ; + +if (getenv ("OFONO_AT_DEBUG" )) +g_at_hdlc_set_debug (hdlc, huaweicdma_debug,"DIAG: " ); + +g_at_hdlc_set_xmit_accm (hdlc,0 ); +g_at_hdlc_set_recv_accm (hdlc,0 ); + +return hdlc; +} +static int huaweicdma_enable (struct ofono_modem *modem) {struct huaweicdma_data *data =ofono_modem_get_data (modem);
@@ -149,6 +186,10 @@ static int huaweicdma_enable(struct ofono_modem *modem)return -EIO ; } + data->diag =open_qcdm (modem); +if (data->diag !=NULL ) +g_at_chat_set_slave_qcdm (data->pcui, data->diag); +g_at_chat_set_slave (data->modem, data->pcui);g_at_chat_send (data->modem,"ATE0 &C0 +CMEE=1" ,NULL ,NULL ,NULL ,NULL );
@@ -186,6 +227,9 @@ static int huaweicdma_disable(struct ofono_modem *modem)g_at_chat_unref (data->modem); data->modem =NULL ; +g_at_hdlc_unref (data->diag); + data->diag =NULL ; +g_at_chat_cancel_all (data->pcui);g_at_chat_unregister_all (data->pcui);
Signature · 1 line
1.7.1
PATCH v3 8/10 huaweicdmamodem: Probe the QCDM port with the version info request
In reply to Philippe Nunes--- drivers/huaweicdmamodem/network-registration.c | 106 +++++++++++++++++++++--- 1 files changed, 95 insertions(+), 11 deletions(-)
drivers/huaweicdmamodem/network-registration.c +95 -11
@@ -24,6 +24,8 @@#endif #define _GNU_SOURCE +#include <string.h> +#include <stdio.h> #include <glib.h> #include <errno.h>
@@ -35,8 +37,32 @@#include "huaweicdmamodem.h" +#define DIAG_CMD_VERSION_INFO 0/* Version info */ +static const char *sysinfo_prefix[] = {"^SYSINFO:" ,NULL }; +struct netreg_data { +GAtChat *chat; +GAtHDLC *diag; +guint8 cmd; +}; + +struct version_info { +guint8 code; +char comp_date[11 ]; +char comp_time[8 ]; +char rel_date[11 ]; +char rel_time[8 ]; +char model[8 ]; +guint8 scm; +guint8 mob_cai_rev; +guint8 mob_model; +guint16 mob_firmware_rev; +guint8 slot_cycle_index; +guint8 msm_ver; +guint8 unknown; +} __attribute__ ((packed)); +static gboolean parse_sysinfo (GAtResult *result,gint *status) {GAtResultIter iter;
@@ -107,12 +133,56 @@ static void sysinfo_cb(gboolean ok, GAtResult *result, gpointer user_data)ofono_cdma_netreg_status_notify (netreg, status); } +static void send_command (GAtHDLC *hdlc,guint8 cmd) +{ +unsigned char cmdbuf[1 ]; + + cmdbuf[0 ] = cmd; + +g_at_hdlc_send (hdlc, cmdbuf,sizeof (cmdbuf)); +} + +static void hdlc_receive (const unsigned char *buf,gsize len,void *user_data) +{ +struct ofono_cdma_netreg *netreg = user_data; +struct netreg_data *nd =ofono_cdma_netreg_get_data (netreg); + +if (nd->cmd ==DIAG_CMD_VERSION_INFO ) { +struct version_info *verinfo; +char str[12 ]; + +if (len <1 || len >sizeof (struct version_info ) || + nd->cmd != buf[0 ]) { +/* This is probably not a QCDM port */ +g_at_hdlc_unref (nd->diag); + nd->diag =NULL ; +return ; + } + +DBG ("Version information\n" ); + verinfo = (struct version_info *)buf; +snprintf (str,12 ,"%s" , verinfo->comp_date); +DBG ("Compiled Date: %s\n" , str); +snprintf (str,9 ,"%s" , verinfo->comp_time); +DBG ("Compiled Time: %s\n" , str); +snprintf (str,12 ,"%s" , verinfo->rel_date); +DBG ("Release Date: %s\n" , str); +snprintf (str,9 ,"%s" , verinfo->rel_time); +DBG ("Release Time: %s\n" , str); +snprintf (str,9 ,"%s" , verinfo->model); +DBG ("Model: %s\n" , str); +DBG ("MSM version: %d\n" , verinfo->msm_ver); + } + +return ; +} +static void mode_notify (GAtResult *result,gpointer user_data) {struct ofono_cdma_netreg *netreg = user_data; -GAtChat *chat =ofono_cdma_netreg_get_data (netreg); +struct netreg_data *nd =ofono_cdma_netreg_get_data (netreg); -g_at_chat_send (chat,"AT^SYSINFO" , sysinfo_prefix, +g_at_chat_send (nd->chat,"AT^SYSINFO" , sysinfo_prefix, sysinfo_cb, netreg,NULL ); }
@@ -169,20 +239,20 @@ error:static void probe_cb (gboolean ok,GAtResult *result,gpointer user_data) {struct ofono_cdma_netreg *netreg = user_data; -GAtChat *chat =ofono_cdma_netreg_get_data (netreg); +struct netreg_data *nd =ofono_cdma_netreg_get_data (netreg);if (!ok) {ofono_cdma_netreg_remove (netreg);return ; } -g_at_chat_register (chat,"^MODE:" , +g_at_chat_register (nd->chat,"^MODE:" , mode_notify, FALSE, netreg,NULL ); -g_at_chat_register (chat,"^RSSILVL:" , +g_at_chat_register (nd->chat,"^RSSILVL:" , rssilvl_notify, FALSE, netreg,NULL ); -g_at_chat_register (chat,"^HRSSILVL:" , +g_at_chat_register (nd->chat,"^HRSSILVL:" , hrssilvl_notify, FALSE, netreg,NULL );ofono_cdma_netreg_register (netreg);
@@ -191,23 +261,37 @@ static void probe_cb(gboolean ok, GAtResult *result, gpointer user_data)static int huaweicdma_netreg_probe (struct ofono_cdma_netreg *netreg,unsigned int vendor,void *data) { -GAtChat *chat =g_at_chat_clone (data); +struct netreg_data *nd; + + nd = g_new0(struct netreg_data, 1); + + nd->chat =g_at_chat_clone (data); + nd->diag =g_at_chat_get_slave_qcdm (data); -ofono_cdma_netreg_set_data (netreg, chat); +ofono_cdma_netreg_set_data (netreg, nd); -g_at_chat_send (chat,"AT^SYSINFO" , sysinfo_prefix, +g_at_chat_send (nd->chat,"AT^SYSINFO" , sysinfo_prefix, probe_cb, netreg,NULL ); +if (nd->diag) { +g_at_hdlc_set_receive (nd->diag, hdlc_receive, netreg); +/* Request version info to probe the QCDM port */ + nd->cmd =DIAG_CMD_VERSION_INFO ; +send_command (nd->diag, nd->cmd); + } +return 0 ; }static void huaweicdma_netreg_remove (struct ofono_cdma_netreg *netreg) { -GAtChat *chat =ofono_cdma_netreg_get_data (netreg); +struct netreg_data *nd =ofono_cdma_netreg_get_data (netreg);ofono_cdma_netreg_set_data (netreg,NULL ); -g_at_chat_unref (chat); +g_at_chat_unref (nd->chat); +g_at_hdlc_unref (nd->diag); +g_free (nd); }static struct ofono_cdma_netreg_driver driver = {
Signature · 1 line
1.7.1
PATCH v3 9/10 huaweicdmamodem: Add 'serving_system' entry point to get SID
In reply to Philippe Nunes--- drivers/huaweicdmamodem/network-registration.c | 141 ++++++++++++++++++++++++ 1 files changed, 141 insertions(+), 0 deletions(-)
drivers/huaweicdmamodem/network-registration.c +141 -0
@@ -36,8 +36,10 @@#include "gatchat.h" #include "huaweicdmamodem.h" +#include <drivers/atmodem/atutil.h> #define DIAG_CMD_VERSION_INFO 0/* Version info */ +#define DIAG_CMD_STATUS 12/* Station status */ static const char *sysinfo_prefix[] = {"^SYSINFO:" ,NULL };
@@ -45,6 +47,8 @@ struct netreg_data {GAtChat *chat;GAtHDLC *diag;guint8 cmd; +void *cb; +void *cb_data; };struct version_info {
@@ -63,6 +67,32 @@ struct version_info {guint8 unknown; } __attribute__ ((packed)); +struct cdma_status { +guint8 code; +guint8 _unknown[3 ]; +guint8 esn[4 ]; +guint16 rf_mode; +guint8 min1_analog[4 ]; +guint8 min1_cdma[4 ]; +guint8 min2_analog[2 ]; +guint8 min2_cdma[2 ]; +guint8 _unknown1; +guint16 cdma_rx_state; +guint8 good_frames; +guint16 analog_corrected_frames; +guint16 analog_bad_frames; +guint16 analog_word_syncs; +guint16 entry_reason; +guint16 curr_chan; +guint8 cdma_code_chan; +guint16 pilot_base; +guint16 sid; +guint16 nid; +guint16 analog_locaid; +guint16 analog_rssi; +guint8 analog_power; +} __attribute__ ((packed)); +static gboolean parse_sysinfo (GAtResult *result,gint *status) {GAtResultIter iter;
@@ -133,6 +163,66 @@ static void sysinfo_cb(gboolean ok, GAtResult *result, gpointer user_data)ofono_cdma_netreg_status_notify (netreg, status); } +static gboolean parse_css (GAtResult *result,const char **sid) +{ +GAtResultIter iter; +/* +* According TIA/EIA/IS-707, CSS query returns <AB>,<SID> but +* according TIA/EIA/IS-707-A , it returns <Band_Class>,<Band>,<SID>. +* PREV field which has been added afterward is ignored +*/ + +g_at_result_iter_init (&iter, result); + +g_at_result_iter_next (&iter,NULL ); + +/* Skip first field since we are not interested in this */ +if (!g_at_result_iter_skip_next (&iter)) +return FALSE; + +if (!g_at_result_iter_next_unquoted_string (&iter, sid)) +return FALSE; +/* +* As CSS answer may differ according which revision of TIA/EIA/IS-707 +* the modem is compliant, we need to check if this field is Band or SID +*/ +if ((*sid[0 ] >='A' && *sid[0 ] <='F' ) || (*sid[0 ] =='Z' )) +/* This is the band field, the next field is the SID*/ +if (!g_at_result_iter_next_unquoted_string (&iter, sid)) +return FALSE; + +if (!strcmp (*sid,"99999" )) +/* The mobile station is not registered.*/ +return FALSE; + +return TRUE; +} + +static void serving_system_cb (gboolean ok,GAtResult *result, +gpointer user_data) +{ +struct cb_data *cbd = user_data; +ofono_cdma_netreg_serving_system_cb_t cb = cbd->cb; +struct ofono_error error; +const char *sid; + +decode_at_error (&error,g_at_result_final_response (result)); + +if (!ok) { +cb (&error,NULL , cbd->data); +return ; + } + +if (parse_css (result, &sid) == FALSE) { +CALLBACK_WITH_FAILURE (cb,NULL , cbd->data); +return ; + } + +DBG ("serving system: SID %s" , sid); + +cb (&error, sid, cbd->data); +} +static void send_command (GAtHDLC *hdlc,guint8 cmd) {unsigned char cmdbuf[1 ];
@@ -172,6 +262,35 @@ static void hdlc_receive(const unsigned char *buf, gsize len, void *user_data)snprintf (str,9 ,"%s" , verinfo->model);DBG ("Model: %s\n" , str);DBG ("MSM version: %d\n" , verinfo->msm_ver); + }else if (nd->cmd ==DIAG_CMD_STATUS ) { +ofono_cdma_netreg_serving_system_cb_t cb = nd->cb; +struct cdma_status *status; +char str[6 ]; + +if (len <1 || len >sizeof (struct cdma_status ) || + nd->cmd != buf[0 ]) { +/* fall back to use +CSS */ +if (g_at_chat_send (nd->chat,"AT+CSS=?" ,NULL , + serving_system_cb, netreg,NULL ) >0 ) +return ; + +CALLBACK_WITH_FAILURE (cb,NULL , nd->cb_data); +return ; + } + +DBG ("Status command response\n" ); + status = (struct cdma_status *) (buf); +DBG ("Serving Identification number: SID %d" , status->sid); +DBG ("Network Identification number NID: %d" , status->nid); + +/* check if network is registered */ +if (status->cdma_rx_state ==0 ) { +CALLBACK_WITH_FAILURE (cb,NULL , nd->cb_data); +return ; + } + +snprintf (str,6 ,"%d" , status->sid); +CALLBACK_WITH_SUCCESS (cb, str, nd->cb_data); }return ;
@@ -294,10 +413,32 @@ static void huaweicdma_netreg_remove(struct ofono_cdma_netreg *netreg)g_free (nd); } +static void huaweicdma_netreg_serving_system (struct ofono_cdma_netreg *netreg, +ofono_cdma_netreg_serving_system_cb_t cb,void *data) +{ +struct netreg_data *nd =ofono_cdma_netreg_get_data (netreg); + + nd->cb = cb; + nd->cb_data = data; + +/* First use QCDM port if any */ +if (nd->diag) { +/* Request Station status */ + nd->cmd =0x0c ; +send_command (nd->diag, nd->cmd); +return ; + }else if (g_at_chat_send (nd->chat,"AT+CSS=?" ,NULL , + serving_system_cb, netreg,NULL ) >0 ) +return ; + +CALLBACK_WITH_FAILURE (cb,NULL , data); +} +static struct ofono_cdma_netreg_driver driver = { .name ="huaweicdmamodem" , .probe = huaweicdma_netreg_probe, .remove = huaweicdma_netreg_remove, + .serving_system = huaweicdma_netreg_serving_system, };void huaweicdma_netreg_init (void )
Signature · 1 line
1.7.1
PATCH v3 10/10 udevng: Add a default assignment for Huawei QCDM port
In reply to Philippe Nunes--- plugins/udevng.c | 30 +++++++++++++++++++++--------- 1 files changed, 21 insertions(+), 9 deletions(-)
plugins/udevng.c +21 -9
@@ -235,6 +235,7 @@ static gboolean setup_sierra(struct modem_info *modem)static gboolean setup_huawei (struct modem_info *modem) {const char *mdm =NULL , *pcui =NULL , *diag =NULL ; +const char *default_pcui =NULL ;GSList *list;DBG ("%s" , modem->syspath);
@@ -264,22 +265,33 @@ static gboolean setup_huawei(struct modem_info *modem)if (mdm !=NULL && pcui !=NULL )break ; }else if (g_strcmp0 (info->interface,"255/255/255" ) ==0 ) { -if (g_strcmp0 (info->number,"00" ) ==0 ) +if (mdm ==NULL &&g_strcmp0 (info->number,"00" ) ==0 ) mdm = info->devnode; -else if (g_strcmp0 (info->number,"01" ) ==0 ) - pcui = info->devnode; -else if (g_strcmp0 (info->number,"02" ) ==0 ) - pcui = info->devnode; -else if (g_strcmp0 (info->number,"03" ) ==0 ) - pcui = info->devnode; -else if (g_strcmp0 (info->number,"04" ) ==0 ) - pcui = info->devnode; +else if (diag ==NULL ) { +if (g_strcmp0 (info->number,"01" ) ==0 ) + diag = info->devnode; + }else if (pcui ==NULL ) { +if (g_strcmp0 (info->number,"01" ) ==0 ) + default_pcui = info->devnode; +else if (g_strcmp0 (info->number,"02" ) ==0 ) + default_pcui = info->devnode; +else if (g_strcmp0 (info->number,"03" ) ==0 ) + default_pcui = info->devnode; +else if (g_strcmp0 (info->number,"04" ) ==0 ) + default_pcui = info->devnode; + } } } +if (pcui ==NULL && default_pcui !=NULL ) + pcui = default_pcui; +if (mdm ==NULL || pcui ==NULL )return FALSE; +if (diag !=NULL &&g_strcmp0 (diag, pcui) ==0 ) + diag =NULL ; +DBG ("modem=%s pcui=%s diag=%s" , mdm, pcui, diag);ofono_modem_set_string (modem->modem,"Modem" , mdm);
Signature · 1 line
1.7.1
Re: [PATCH v3 05/10] cdma-netreg: Add provider name and SID support
In reply to Philippe NunesHi Philippe,
Quoted 18 lines
src/cdma-netreg.c +14
-0@@ -120,6 +134,30 @@ static void serving_system_callback(const struct ofono_error *error, }DBG ("Serving system Identifier: %s" , sid); + +if (cdma_netreg->sid !=NULL && !strcmp (cdma_netreg->sid, sid)) +return ; + +g_free (cdma_netreg->provider_name); +g_free (cdma_netreg->sid); + cdma_netreg->provider_name =NULL ; + cdma_netreg->sid =g_strdup (sid); + +ofono_dbus_signal_property_changed (conn, path, +OFONO_CDMA_NETWORK_REGISTRATION_INTERFACE , +"SystemIdentifier" ,DBUS_TYPE_STRING , + &cdma_netreg->sid); +
src/cdma-netreg.c static void serving_system_callback(const struct ofono_error *error, · line 160
Quoted 10 lines
src/cdma-netreg.c +10
-0+if (__ofono_cdma_provision_get_name (sid, + &cdma_netreg->provider_name) == FALSE) { +ofono_warn ("Provider name not found" ); +return ; + } + +ofono_dbus_signal_property_changed (conn, path, +OFONO_CDMA_NETWORK_REGISTRATION_INTERFACE , +"Name" ,DBUS_TYPE_STRING , + &cdma_netreg->provider_name);
So in theory the Name might not have changed since there can be multiple SIDs associated with a name. Something that should probably be fixed in a follow-on patch.
src/cdma-netreg.c static void serving_system_callback(const struct ofono_error *error, · line 163
Quoted 3 lines
src/cdma-netreg.c +0
-0} static void set_registration_status(struct ofono_cdma_netreg *cdma_netreg,
the first 5 patches in this series have been applied, thanks.
Regards,
-Denis
Re: [PATCH v3 08/10] huaweicdmamodem: Probe the QCDM port with the version info request
In reply to Philippe NunesHi Philippe,
Quoted 4 lines · Philippe Nunes
--- drivers/huaweicdmamodem/network-registration.c | 106 +++++++++++++++++++++--- 1 files changed, 95 insertions(+), 11 deletions(-)
so the huawecdmamodem tree no longer exists, and I'm not sure that the QCDM pieces really belong here, perhaps we need a separate helper library for parsing this information.
Quoted 68 lines
drivers/huaweicdmamodem/network-registration.c +44
-0@@ -24,6 +24,8 @@#endif #define _GNU_SOURCE +#include <string.h> +#include <stdio.h> #include <glib.h> #include <errno.h> @@ -35,8 +37,32 @@#include "huaweicdmamodem.h" +#define DIAG_CMD_VERSION_INFO 0/* Version info */ +static const char *sysinfo_prefix[] = {"^SYSINFO:" ,NULL }; +struct netreg_data { +GAtChat *chat; +GAtHDLC *diag; +guint8 cmd; +}; + +struct version_info { +guint8 code; +char comp_date[11 ]; +char comp_time[8 ]; +char rel_date[11 ]; +char rel_time[8 ]; +char model[8 ]; +guint8 scm; +guint8 mob_cai_rev; +guint8 mob_model; +guint16 mob_firmware_rev; +guint8 slot_cycle_index; +guint8 msm_ver; +guint8 unknown; +} __attribute__ ((packed)); +static gboolean parse_sysinfo (GAtResult *result,gint *status) {GAtResultIter iter;@@ -107,12 +133,56 @@ static void sysinfo_cb(gboolean ok, GAtResult *result, gpointer user_data)ofono_cdma_netreg_status_notify (netreg, status); } +static void send_command (GAtHDLC *hdlc,guint8 cmd) +{ +unsigned char cmdbuf[1 ]; + + cmdbuf[0 ] = cmd; + +g_at_hdlc_send (hdlc, cmdbuf,sizeof (cmdbuf)); +} + +static void hdlc_receive (const unsigned char *buf,gsize len,void *user_data) +{ +struct ofono_cdma_netreg *netreg = user_data; +struct netreg_data *nd =ofono_cdma_netreg_get_data (netreg); + +if (nd->cmd ==DIAG_CMD_VERSION_INFO ) { +struct version_info *verinfo; +char str[12 ]; +
drivers/huaweicdmamodem/network-registration.c static void sysinfo_cb(gboolean ok, GAtResult *result, gpointer user_data) · line 163
Quoted 10 lines
drivers/huaweicdmamodem/network-registration.c +10
-0+if (len <1 || len >sizeof (struct version_info ) || + nd->cmd != buf[0 ]) { +/* This is probably not a QCDM port */ +g_at_hdlc_unref (nd->diag); + nd->diag =NULL ; +return ; + } + +DBG ("Version information\n" ); + verinfo = (struct version_info *)buf;
You really can't do this since the endian-ness of QCDM is likely always little-endian, while oFono might be running on big-endian machine.
Quoted 85 lines
drivers/huaweicdmamodem/network-registration.c +38
-10+snprintf (str,12 ,"%s" , verinfo->comp_date); +DBG ("Compiled Date: %s\n" , str); +snprintf (str,9 ,"%s" , verinfo->comp_time); +DBG ("Compiled Time: %s\n" , str); +snprintf (str,12 ,"%s" , verinfo->rel_date); +DBG ("Release Date: %s\n" , str); +snprintf (str,9 ,"%s" , verinfo->rel_time); +DBG ("Release Time: %s\n" , str); +snprintf (str,9 ,"%s" , verinfo->model); +DBG ("Model: %s\n" , str); +DBG ("MSM version: %d\n" , verinfo->msm_ver); + } + +return ; +} +static void mode_notify (GAtResult *result,gpointer user_data) {struct ofono_cdma_netreg *netreg = user_data; -GAtChat *chat =ofono_cdma_netreg_get_data (netreg); +struct netreg_data *nd =ofono_cdma_netreg_get_data (netreg); -g_at_chat_send (chat,"AT^SYSINFO" , sysinfo_prefix, +g_at_chat_send (nd->chat,"AT^SYSINFO" , sysinfo_prefix, sysinfo_cb, netreg,NULL ); }@@ -169,20 +239,20 @@ error:static void probe_cb (gboolean ok,GAtResult *result,gpointer user_data) {struct ofono_cdma_netreg *netreg = user_data; -GAtChat *chat =ofono_cdma_netreg_get_data (netreg); +struct netreg_data *nd =ofono_cdma_netreg_get_data (netreg);if (!ok) {ofono_cdma_netreg_remove (netreg);return ; } -g_at_chat_register (chat,"^MODE:" , +g_at_chat_register (nd->chat,"^MODE:" , mode_notify, FALSE, netreg,NULL ); -g_at_chat_register (chat,"^RSSILVL:" , +g_at_chat_register (nd->chat,"^RSSILVL:" , rssilvl_notify, FALSE, netreg,NULL ); -g_at_chat_register (chat,"^HRSSILVL:" , +g_at_chat_register (nd->chat,"^HRSSILVL:" , hrssilvl_notify, FALSE, netreg,NULL );ofono_cdma_netreg_register (netreg);@@ -191,23 +261,37 @@ static void probe_cb(gboolean ok, GAtResult *result, gpointer user_data)static int huaweicdma_netreg_probe (struct ofono_cdma_netreg *netreg,unsigned int vendor,void *data) { -GAtChat *chat =g_at_chat_clone (data); +struct netreg_data *nd; + + nd = g_new0(struct netreg_data, 1); + + nd->chat =g_at_chat_clone (data); + nd->diag =g_at_chat_get_slave_qcdm (data); -ofono_cdma_netreg_set_data (netreg, chat); +ofono_cdma_netreg_set_data (netreg, nd); -g_at_chat_send (chat,"AT^SYSINFO" , sysinfo_prefix, +g_at_chat_send (nd->chat,"AT^SYSINFO" , sysinfo_prefix, probe_cb, netreg,NULL ); +if (nd->diag) { +g_at_hdlc_set_receive (nd->diag, hdlc_receive, netreg); +/* Request version info to probe the QCDM port */ + nd->cmd =DIAG_CMD_VERSION_INFO ; +send_command (nd->diag, nd->cmd); + } +return 0 ; }static void huaweicdma_netreg_remove (struct ofono_cdma_netreg *netreg) { -GAtChat *chat =ofono_cdma_netreg_get_data (netreg); +struct netreg_data *nd =ofono_cdma_netreg_get_data (netreg);
drivers/huaweicdmamodem/network-registration.c static void probe_cb(gboolean ok, GAtResult *result, gpointer user_data) · line 297
Quoted 10 lines
drivers/huaweicdmamodem/network-registration.c +3
-1ofono_cdma_netreg_set_data (netreg,NULL ); -g_at_chat_unref (chat); +g_at_chat_unref (nd->chat); +g_at_hdlc_unref (nd->diag); +g_free (nd); }static struct ofono_cdma_netreg_driver driver = {
Regards,
-Denis
Re: [PATCH v3 09/10] huaweicdmamodem: Add 'serving_system' entry point to get SID
In reply to Philippe NunesHi Philippe,
Quoted 89 lines · Philippe Nunes
--- drivers/huaweicdmamodem/network-registration.c | 141 ++++++++++++++++++++++++ 1 files changed, 141 insertions(+), 0 deletions(-)drivers/huaweicdmamodem/network-registration.c +54
-0@@ -36,8 +36,10 @@#include "gatchat.h" #include "huaweicdmamodem.h" +#include <drivers/atmodem/atutil.h> #define DIAG_CMD_VERSION_INFO 0/* Version info */ +#define DIAG_CMD_STATUS 12/* Station status */ static const char *sysinfo_prefix[] = {"^SYSINFO:" ,NULL };@@ -45,6 +47,8 @@ struct netreg_data {GAtChat *chat;GAtHDLC *diag;guint8 cmd; +void *cb; +void *cb_data; };struct version_info {@@ -63,6 +67,32 @@ struct version_info {guint8 unknown; } __attribute__ ((packed)); +struct cdma_status { +guint8 code; +guint8 _unknown[3 ]; +guint8 esn[4 ]; +guint16 rf_mode; +guint8 min1_analog[4 ]; +guint8 min1_cdma[4 ]; +guint8 min2_analog[2 ]; +guint8 min2_cdma[2 ]; +guint8 _unknown1; +guint16 cdma_rx_state; +guint8 good_frames; +guint16 analog_corrected_frames; +guint16 analog_bad_frames; +guint16 analog_word_syncs; +guint16 entry_reason; +guint16 curr_chan; +guint8 cdma_code_chan; +guint16 pilot_base; +guint16 sid; +guint16 nid; +guint16 analog_locaid; +guint16 analog_rssi; +guint8 analog_power; +} __attribute__ ((packed)); +static gboolean parse_sysinfo (GAtResult *result,gint *status) {GAtResultIter iter;@@ -133,6 +163,66 @@ static void sysinfo_cb(gboolean ok, GAtResult *result, gpointer user_data)ofono_cdma_netreg_status_notify (netreg, status); } +static gboolean parse_css (GAtResult *result,const char **sid) +{ +GAtResultIter iter; +/* +* According TIA/EIA/IS-707, CSS query returns <AB>,<SID> but +* according TIA/EIA/IS-707-A , it returns <Band_Class>,<Band>,<SID>. +* PREV field which has been added afterward is ignored +*/ + +g_at_result_iter_init (&iter, result); + +g_at_result_iter_next (&iter,NULL ); + +/* Skip first field since we are not interested in this */ +if (!g_at_result_iter_skip_next (&iter)) +return FALSE; + +if (!g_at_result_iter_next_unquoted_string (&iter, sid)) +return FALSE; +/* +* As CSS answer may differ according which revision of TIA/EIA/IS-707 +* the modem is compliant, we need to check if this field is Band or SID +*/ +if ((*sid[0 ] >='A' && *sid[0 ] <='F' ) || (*sid[0 ] =='Z' ))
drivers/huaweicdmamodem/network-registration.c static void sysinfo_cb(gboolean ok, GAtResult *result, gpointer user_data) · line 199
Quoted 10 lines
drivers/huaweicdmamodem/network-registration.c +10
-0+/* This is the band field, the next field is the SID*/ +if (!g_at_result_iter_next_unquoted_string (&iter, sid)) +return FALSE; + +if (!strcmp (*sid,"99999" )) +/* The mobile station is not registered.*/ +return FALSE; + +return TRUE; +}
Are you sure you need this fallback? I'd really rather leave this out due to already discussed problems with CSS. I don't know is better than the wrong result...
Quoted 52 lines
drivers/huaweicdmamodem/network-registration.c +45
-0+ +static void serving_system_cb (gboolean ok,GAtResult *result, +gpointer user_data) +{ +struct cb_data *cbd = user_data; +ofono_cdma_netreg_serving_system_cb_t cb = cbd->cb; +struct ofono_error error; +const char *sid; + +decode_at_error (&error,g_at_result_final_response (result)); + +if (!ok) { +cb (&error,NULL , cbd->data); +return ; + } + +if (parse_css (result, &sid) == FALSE) { +CALLBACK_WITH_FAILURE (cb,NULL , cbd->data); +return ; + } + +DBG ("serving system: SID %s" , sid); + +cb (&error, sid, cbd->data); +} +static void send_command (GAtHDLC *hdlc,guint8 cmd) {unsigned char cmdbuf[1 ];@@ -172,6 +262,35 @@ static void hdlc_receive(const unsigned char *buf, gsize len, void *user_data)snprintf (str,9 ,"%s" , verinfo->model);DBG ("Model: %s\n" , str);DBG ("MSM version: %d\n" , verinfo->msm_ver); + }else if (nd->cmd ==DIAG_CMD_STATUS ) { +ofono_cdma_netreg_serving_system_cb_t cb = nd->cb; +struct cdma_status *status; +char str[6 ]; + +if (len <1 || len >sizeof (struct cdma_status ) || + nd->cmd != buf[0 ]) { +/* fall back to use +CSS */ +if (g_at_chat_send (nd->chat,"AT+CSS=?" ,NULL , + serving_system_cb, netreg,NULL ) >0 ) +return ; + +CALLBACK_WITH_FAILURE (cb,NULL , nd->cb_data); +return ; + } + +DBG ("Status command response\n" ); + status = (struct cdma_status *) (buf); +DBG ("Serving Identification number: SID %d" , status->sid);
drivers/huaweicdmamodem/network-registration.c static void hdlc_receive(const unsigned char *buf, gsize len, void *user_data) · line 293
Quoted 10 lines
drivers/huaweicdmamodem/network-registration.c +10
-0+DBG ("Network Identification number NID: %d" , status->nid); + +/* check if network is registered */ +if (status->cdma_rx_state ==0 ) { +CALLBACK_WITH_FAILURE (cb,NULL , nd->cb_data); +return ; + } + +snprintf (str,6 ,"%d" , status->sid); +CALLBACK_WITH_SUCCESS (cb, str, nd->cb_data);
This structure is really not maintainable long term, there needs to be a proper framework for executing commands and receiving results, not a giant if/else statement. Also, all the comments from the previous patch apply, you have to pay attention to endianness here or the results you will get will be wrong.
Quoted 26 lines
drivers/huaweicdmamodem/network-registration.c +19
-0}return ;@@ -294,10 +413,32 @@ static void huaweicdma_netreg_remove(struct ofono_cdma_netreg *netreg)g_free (nd); } +static void huaweicdma_netreg_serving_system (struct ofono_cdma_netreg *netreg, +ofono_cdma_netreg_serving_system_cb_t cb,void *data) +{ +struct netreg_data *nd =ofono_cdma_netreg_get_data (netreg); + + nd->cb = cb; + nd->cb_data = data; + +/* First use QCDM port if any */ +if (nd->diag) { +/* Request Station status */ + nd->cmd =0x0c ; +send_command (nd->diag, nd->cmd); +return ; + }else if (g_at_chat_send (nd->chat,"AT+CSS=?" ,NULL , + serving_system_cb, netreg,NULL ) >0 ) +return ; + +CALLBACK_WITH_FAILURE (cb,NULL , data);
drivers/huaweicdmamodem/network-registration.c static void huaweicdma_netreg_remove(struct ofono_cdma_netreg *netreg) · line 444
Quoted 10 lines
drivers/huaweicdmamodem/network-registration.c +3
-0+} +static struct ofono_cdma_netreg_driver driver = { .name ="huaweicdmamodem" , .probe = huaweicdma_netreg_probe, .remove = huaweicdma_netreg_remove, + .serving_system = huaweicdma_netreg_serving_system, };void huaweicdma_netreg_init (void )
Regards,
-Denis