cdmaphonesim: Add CDMA SMS Support
PATCH v3 7/7 cdmaphonesim: Add CDMA SMS Support
--- Makefile.am | 10 ++ plugins/cdmaphonesim.c | 328 ++++++++++++++++++++++++++++++++++++++++++++++++ plugins/phonesim.conf | 4 + 3 files changed, 342 insertions(+), 0 deletions(-) create mode 100644 plugins/cdmaphonesim.c
Makefile.am +10 -0
@@ -247,6 +247,16 @@ builtin_modules += cdma_atmodem builtin_sources += drivers/cdmamodem/cdmamodem.h \ drivers/cdmamodem/cdmamodem.c \ drivers/cdmamodem/sms.c + +if PHONESIM +builtin_modules += cdmaphonesim +builtin_sources += plugins/cdmaphonesim.c + +if DATAFILES +conf_DATA += plugins/phonesim.conf +endif +endif + endif builtin_modules += g1
plugins/cdmaphonesim.c new file +328 -0
328 lines not on this page · raw message
plugins/phonesim.conf +4 -0
@@ -12,3 +12,7 @@ #[phonesim] #Address=127.0.0.1 #Port=12345 + +#[cdmaphonesim] +#Address=127.0.0.1 +#Port=12345
Signature · 1 line
1.7.0.4
Hi Lei,
Quoted 13 lines · Lei Yu
--- Makefile.am | 10 ++ plugins/cdmaphonesim.c | 328 ++++++++++++++++++++++++++++++++++++++++++++++++ plugins/phonesim.conf | 4 + 3 files changed, 342 insertions(+), 0 deletions(-) create mode 100644 plugins/cdmaphonesim.cMakefile.am +0
-0@@ -247,6 +247,16 @@ builtin_modules += cdma_atmodem builtin_sources += drivers/cdmamodem/cdmamodem.h \
Makefile.am builtin_modules += cdma_atmodem · line 257
Quoted 10 lines
Makefile.am +8
-0drivers/cdmamodem/cdmamodem.c \ drivers/cdmamodem/sms.c + +if PHONESIM + +if DATAFILES +conf_DATA += plugins/phonesim.conf +endif +endif +
Yikes, you better check this logic. I suspect simply adding:
+builtin_modules += cdmaphonesim
+builtin_sources += plugins/cdmaphonesim.c
to the existing if PHONESIM block should be enough.
Quoted 342 lines
Makefile.am +0
-0endif builtin_modules += g1plugins/cdmaphonesim.c new file +328
-0@@ -0,0 +1,328 @@ +/* +* This file is part of oFono - Open Source Telephony +* +* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +* +* 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 <unistd.h> +#include <stdlib.h> +#include <string.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> + +#include <glib.h> +#include <gatmux.h> +#include <gatchat.h> + +#define OFONO_API_SUBJECT_TO_CHANGE +#include <ofono/plugin.h> +#include <ofono/log.h> +#include <ofono/modem.h> +#include <ofono/cdma-sms.h> +#include <drivers/atmodem/atutil.h> + +struct cdmaphonesim_data { +GAtChat *chat; +}; + +static int cdmaphonesim_probe (struct ofono_modem *modem) +{ +struct cdmaphonesim_data *data; + +DBG ("%p" , modem); + + data = g_try_new0(struct cdmaphonesim_data, 1); +if (data ==NULL ) +return -ENOMEM ; + +ofono_modem_set_data (modem, data); + +return 0 ; +} + +static void cdmaphonesim_remove (struct ofono_modem *modem) +{ +struct cdmaphonesim_data *data =ofono_modem_get_data (modem); + +DBG ("%p" , modem); + +g_free (data); +ofono_modem_set_data (modem,NULL ); +} + +static void cdmaphonesim_debug (const char *str,void *user_data) +{ +ofono_info ("%s" , str); +} + +static void cfun_set_on_cb (gboolean ok,GAtResult *result,gpointer user_data) +{ +struct ofono_modem *modem = user_data; + +DBG ("" ); + +ofono_modem_set_powered (modem, ok); +} + +static void cdmaphonesim_disconnected (gpointer user_data) +{ +struct ofono_modem *modem = user_data; +struct cdmaphonesim_data *data =ofono_modem_get_data (modem); + +DBG ("" ); + +ofono_modem_set_powered (modem, FALSE); + +g_at_chat_unref (data->chat); + data->chat =NULL ; +} + +static int cdmaphonesim_enable (struct ofono_modem *modem) +{ +struct cdmaphonesim_data *data =ofono_modem_get_data (modem); +GIOChannel *io; +GAtSyntax *syntax; +struct sockaddr_in addr; +const char *address; +int sk, err, port; + +DBG ("%p" , modem); + + address =ofono_modem_get_string (modem,"Address" ); +if (address ==NULL ) +return -EINVAL ; + + port =ofono_modem_get_integer (modem,"Port" ); +if (port <0 ) +return -EINVAL ; + + sk =socket (PF_INET ,SOCK_STREAM ,0 ); +if (sk <0 ) +return -EINVAL ; + +memset (&addr,0 ,sizeof (addr)); + addr.sin_family =AF_INET ; + addr.sin_addr.s_addr =inet_addr (address); + addr.sin_port =htons (port); + + err =connect (sk, (struct sockaddr *) &addr,sizeof (addr)); +if (err <0 ) { +close (sk); +return err; + } + + io =g_io_channel_unix_new (sk); +if (io ==NULL ) { +close (sk); +return -ENOMEM ; + } + + syntax =g_at_syntax_new_gsmv1 (); + + data->chat =g_at_chat_new (io, syntax); + +g_at_syntax_unref (syntax); +g_io_channel_unref (io); + +if (data->chat ==NULL ) +return -ENOMEM ; + +if (getenv ("OFONO_AT_DEBUG" )) +g_at_chat_set_debug (data->chat, cdmaphonesim_debug,NULL ); + +g_at_chat_set_disconnect_function (data->chat, + cdmaphonesim_disconnected, modem); + +g_at_chat_send (data->chat,"AT+CFUN=1" ,NULL , + cfun_set_on_cb, modem,NULL ); + +return -EINPROGRESS ; +} + +static int cdmaphonesim_disable (struct ofono_modem *modem) +{ +struct cdmaphonesim_data *data =ofono_modem_get_data (modem); + +DBG ("%p" , modem); + +g_at_chat_unref (data->chat); + data->chat =NULL ; + +return 0 ; +} + +static void cdmaphonesim_pre_sim (struct ofono_modem *modem) +{ +DBG ("%p" , modem); +} + +static void set_online_cb (gboolean ok,GAtResult *result,gpointer user_data) +{ +struct cb_data *cbd = user_data; +ofono_modem_online_cb_t callback = cbd->cb; +struct ofono_error error; + +decode_at_error (&error,g_at_result_final_response (result)); + +callback (&error, cbd->data); +} + +static void cdmaphonesim_set_online (struct ofono_modem *modem, +ofono_bool_t online, +ofono_modem_online_cb_t cb, +void *user_data) +{ +struct cdmaphonesim_data *data =ofono_modem_get_data (modem); +struct cb_data *cbd =cb_data_new (cb, user_data); +char const *command = online ?"AT+CFUN=1" :"AT+CFUN=4" ; + +DBG ("modem %p %s" , modem, online ?"online" :"offline" ); + +if (cbd ==NULL ) + goto error; + +if (g_at_chat_send (data->chat, command,NULL , + set_online_cb, cbd, g_free)) +return ; + +error: +g_free (cbd); + +CALLBACK_WITH_FAILURE (cb, cbd->data); +} + +static void cdmaphonesim_post_online (struct ofono_modem *modem) +{ +struct cdmaphonesim_data *data =ofono_modem_get_data (modem); + +ofono_cdma_sms_create (modem,0 ,"cdmamodem" , data->chat); +} + +static struct ofono_modem_driver cdmaphonesim_driver = { + .name ="cdmaphonesim" , + .probe = cdmaphonesim_probe, + .remove = cdmaphonesim_remove, + .enable = cdmaphonesim_enable, + .disable = cdmaphonesim_disable, + .pre_sim = cdmaphonesim_pre_sim, + .set_online = cdmaphonesim_set_online, + .post_online = cdmaphonesim_post_online, +}; + +static struct ofono_modem *create_modem (GKeyFile *keyfile,const char *group) +{ +struct ofono_modem *modem; +char *value; + +DBG ("group %s" , group); + + modem =ofono_modem_create (group,"cdmaphonesim" ); +if (modem ==NULL ) +return NULL ; + + value =g_key_file_get_string (keyfile, group,"Address" ,NULL ); +if (value ==NULL ) + goto error; + +ofono_modem_set_string (modem,"Address" , value); +g_free (value); + + value =g_key_file_get_string (keyfile, group,"Port" ,NULL ); +if (value ==NULL ) + goto error; + +ofono_modem_set_integer (modem,"Port" ,atoi (value)); +g_free (value); + +DBG ("%p" , modem); + +return modem; + +error: +ofono_error ("Missing address or port setting for %s" , group); + +ofono_modem_remove (modem); + +return NULL ; +} + +static GSList *modem_list; + +static void parse_config (const char *filename) +{ +GKeyFile *keyfile; +GError *err =NULL ; +char **modems; +int i; + +DBG ("filename %s" , filename); + + keyfile =g_key_file_new (); + +g_key_file_set_list_separator (keyfile,',' ); + +if (!g_key_file_load_from_file (keyfile, filename,0 , &err)) { +ofono_warn ("Reading of %s failed: %s" , filename, err->message); +g_error_free (err); + goto done; + } + + modems =g_key_file_get_groups (keyfile,NULL ); + +for (i =0 ; modems[i]; i++) { +struct ofono_modem *modem; + + modem =create_modem (keyfile, modems[i]); +if (modem ==NULL ) +continue ; + + modem_list =g_slist_prepend (modem_list, modem); + +ofono_modem_register (modem); + } + +g_strfreev (modems); + +done: +g_key_file_free (keyfile); +} + +static int cdmaphonesim_init (void ) +{ +int err; + + err =ofono_modem_driver_register (&cdmaphonesim_driver); +if (err <0 ) +return err; + +parse_config (CONFIGDIR "/phonesim.conf" ); +return 0 ; +} + +static void cdmaphonesim_exit (void ) +{ +ofono_modem_driver_unregister (&cdmaphonesim_driver); +} + +OFONO_PLUGIN_DEFINE (cdmaphonesim,"CDMA PhoneSIM driver" ,VERSION , +OFONO_PLUGIN_PRIORITY_DEFAULT , cdmaphonesim_init, cdmaphonesim_exit)plugins/phonesim.conf +0
-0
plugins/phonesim.conf line 18
Quoted 7 lines
plugins/phonesim.conf +4
-0@@ -12,3 +12,7 @@ #[phonesim] #Address=127.0.0.1 #Port=12345 + +#[cdmaphonesim] +#Address=127.0.0.1 +#Port=12345
If we have both phonesim and cdmaphonesim plugins active, we need to make sure they don't interfere with each other. Perhaps adding a Type=cdma and having cdmaphonesim look for that Type tag and ignore the rest would be a good idea?
Regards,
-Denis
Hi Denis,
Quoted 32 lines · ext Denis Kenzior
Hi Lei,
Quoted 13 lines · Lei Yu
--- Makefile.am | 10 ++ plugins/cdmaphonesim.c | 328 ++++++++++++++++++++++++++++++++++++++++++++++++ plugins/phonesim.conf | 4 + 3 files changed, 342 insertions(+), 0 deletions(-)create mode 100644
plugins/cdmaphonesim.cMakefile.am +0
-0@@ -247,6 +247,16 @@ builtin_modules += cdma_atmodem builtin_sources += drivers/cdmamodem/cdmamodem.h \Makefile.am builtin_modules += cdma_atmodem · line 257
Quoted 10 lines
Makefile.am +8
-0drivers/cdmamodem/cdmamodem.c \ drivers/cdmamodem/sms.c + +if PHONESIM + +if DATAFILES +conf_DATA += plugins/phonesim.conf +endif +endif +Yikes, you better check this logic. I suspect simply adding:
Makefile.am +2
-0+builtin_modules += cdmaphonesim +builtin_sources += plugins/cdmaphonesim.c
Quoted 2 lines
to the existing if PHONESIM block should be enough.
Yep. Will fix.
Quoted 346 lines
Quoted 346 lines
Makefile.am +0
-0endif builtin_modules += g1plugins/cdmaphonesim.c new file +328
-0@@ -0,0 +1,328 @@ +/* +* This file is part of oFono - Open Source Telephony +* +* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +* +* 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 <unistd.h> +#include <stdlib.h> +#include <string.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> + +#include <glib.h> +#include <gatmux.h> +#include <gatchat.h> + +#define OFONO_API_SUBJECT_TO_CHANGE +#include <ofono/plugin.h> +#include <ofono/log.h> +#include <ofono/modem.h> +#include <ofono/cdma-sms.h> +#include <drivers/atmodem/atutil.h> + +struct cdmaphonesim_data { +GAtChat *chat; +}; + +static int cdmaphonesim_probe (struct ofono_modem *modem) +{ +struct cdmaphonesim_data *data; + +DBG ("%p" , modem); + + data = g_try_new0(struct cdmaphonesim_data, 1); +if (data ==NULL ) +return -ENOMEM ; + +ofono_modem_set_data (modem, data); + +return 0 ; +} + +static void cdmaphonesim_remove (struct ofono_modem *modem) +{ +struct cdmaphonesim_data *data =ofono_modem_get_data (modem); + +DBG ("%p" , modem); + +g_free (data); +ofono_modem_set_data (modem,NULL ); +} + +static void cdmaphonesim_debug (const char *str,void *user_data) +{ +ofono_info ("%s" , str); +} + +static void cfun_set_on_cb (gboolean ok,GAtResult *result,gpointer user_data) +{ +struct ofono_modem *modem = user_data; + +DBG ("" ); + +ofono_modem_set_powered (modem, ok); +} + +static void cdmaphonesim_disconnected (gpointer user_data) +{ +struct ofono_modem *modem = user_data; +struct cdmaphonesim_data *data =ofono_modem_get_data (modem); + +DBG ("" ); + +ofono_modem_set_powered (modem, FALSE); + +g_at_chat_unref (data->chat); + data->chat =NULL ; +} + +static int cdmaphonesim_enable (struct ofono_modem *modem) +{ +struct cdmaphonesim_data *data =ofono_modem_get_data (modem); +GIOChannel *io; +GAtSyntax *syntax; +struct sockaddr_in addr; +const char *address; +int sk, err, port; + +DBG ("%p" , modem); + + address =ofono_modem_get_string (modem,"Address" ); +if (address ==NULL ) +return -EINVAL ; + + port =ofono_modem_get_integer (modem,"Port" ); +if (port<0 ) +return -EINVAL ; + + sk =socket (PF_INET ,SOCK_STREAM ,0 ); +if (sk<0 ) +return -EINVAL ; + +memset (&addr,0 ,sizeof (addr)); + addr.sin_family =AF_INET ; + addr.sin_addr.s_addr =inet_addr (address); + addr.sin_port =htons (port); + + err =connect (sk, (struct sockaddr *)&addr,sizeof (addr)); +if (err<0 ) { +close (sk); +return err; + } + + io =g_io_channel_unix_new (sk); +if (io ==NULL ) { +close (sk); +return -ENOMEM ; + } + + syntax =g_at_syntax_new_gsmv1 (); + + data->chat =g_at_chat_new (io, syntax); + +g_at_syntax_unref (syntax); +g_io_channel_unref (io); + +if (data->chat ==NULL ) +return -ENOMEM ; + +if (getenv ("OFONO_AT_DEBUG" )) +g_at_chat_set_debug (data->chat, cdmaphonesim_debug,NULL ); + +g_at_chat_set_disconnect_function (data->chat, + cdmaphonesim_disconnected, modem); + +g_at_chat_send (data->chat,"AT+CFUN=1" ,NULL , + cfun_set_on_cb, modem,NULL ); + +return -EINPROGRESS ; +} + +static int cdmaphonesim_disable (struct ofono_modem *modem) +{ +struct cdmaphonesim_data *data =ofono_modem_get_data (modem); + +DBG ("%p" , modem); + +g_at_chat_unref (data->chat); + data->chat =NULL ; + +return 0 ; +} + +static void cdmaphonesim_pre_sim (struct ofono_modem *modem) +{ +DBG ("%p" , modem); +} + +static void set_online_cb (gboolean ok,GAtResult *result,gpointer user_data) +{ +struct cb_data *cbd = user_data; +ofono_modem_online_cb_t callback = cbd->cb; +struct ofono_error error; + +decode_at_error (&error,g_at_result_final_response (result)); + +callback (&error, cbd->data); +} + +static void cdmaphonesim_set_online (struct ofono_modem *modem, +ofono_bool_t online, +ofono_modem_online_cb_t cb, +void *user_data) +{ +struct cdmaphonesim_data *data =ofono_modem_get_data (modem); +struct cb_data *cbd =cb_data_new (cb, user_data); +char const *command = online ?"AT+CFUN=1" :"AT+CFUN=4" ; + +DBG ("modem %p %s" , modem, online ?"online" :"offline" ); + +if (cbd ==NULL ) + goto error; + +if (g_at_chat_send (data->chat, command,NULL , + set_online_cb, cbd, g_free)) +return ; + +error: +g_free (cbd); + +CALLBACK_WITH_FAILURE (cb, cbd->data); +} + +static void cdmaphonesim_post_online (struct ofono_modem *modem) +{ +struct cdmaphonesim_data *data =ofono_modem_get_data (modem); + +ofono_cdma_sms_create (modem,0 ,"cdmamodem" , data->chat); +} + +static struct ofono_modem_driver cdmaphonesim_driver = { + .name ="cdmaphonesim" , + .probe = cdmaphonesim_probe, + .remove = cdmaphonesim_remove, + .enable = cdmaphonesim_enable, + .disable = cdmaphonesim_disable, + .pre_sim = cdmaphonesim_pre_sim, + .set_online = cdmaphonesim_set_online, + .post_online = cdmaphonesim_post_online, +}; + +static struct ofono_modem *create_modem (GKeyFile *keyfile,const char *group) +{ +struct ofono_modem *modem; +char *value; + +DBG ("group %s" , group); + + modem =ofono_modem_create (group,"cdmaphonesim" ); +if (modem ==NULL ) +return NULL ; + + value =g_key_file_get_string (keyfile, group,"Address" ,NULL ); +if (value ==NULL ) + goto error; + +ofono_modem_set_string (modem,"Address" , value); +g_free (value); + + value =g_key_file_get_string (keyfile, group,"Port" ,NULL ); +if (value ==NULL ) + goto error; + +ofono_modem_set_integer (modem,"Port" ,atoi (value)); +g_free (value); + +DBG ("%p" , modem); + +return modem; + +error: +ofono_error ("Missing address or port setting for %s" , group); + +ofono_modem_remove (modem); + +return NULL ; +} + +static GSList *modem_list; + +static void parse_config (const char *filename) +{ +GKeyFile *keyfile; +GError *err =NULL ; +char **modems; +int i; + +DBG ("filename %s" , filename); + + keyfile =g_key_file_new (); + +g_key_file_set_list_separator (keyfile,',' ); + +if (!g_key_file_load_from_file (keyfile, filename,0 ,&err)) { +ofono_warn ("Reading of %s failed: %s" , filename, err->message); +g_error_free (err); + goto done; + } + + modems =g_key_file_get_groups (keyfile,NULL ); + +for (i =0 ; modems[i]; i++) { +struct ofono_modem *modem; + + modem =create_modem (keyfile, modems[i]); +if (modem ==NULL ) +continue ; + + modem_list =g_slist_prepend (modem_list, modem); + +ofono_modem_register (modem); + } + +g_strfreev (modems); + +done: +g_key_file_free (keyfile); +} + +static int cdmaphonesim_init (void ) +{ +int err; + + err =ofono_modem_driver_register (&cdmaphonesim_driver); +if (err<0 ) +return err; + +parse_config (CONFIGDIR "/phonesim.conf" ); +return 0 ; +} + +static void cdmaphonesim_exit (void ) +{ +ofono_modem_driver_unregister (&cdmaphonesim_driver); +} + +OFONO_PLUGIN_DEFINE (cdmaphonesim,"CDMA PhoneSIM driver" ,VERSION , +OFONO_PLUGIN_PRIORITY_DEFAULT , cdmaphonesim_init, cdmaphonesim_exit)plugins/phonesim.conf +1
-0@@ -12,3 +12,7 @@ #[phonesim] #Address=127.0.0.1 #Port=12345 +
Quoted 9 lines
plugins/phonesim.conf line 18
Quoted 3 lines
plugins/phonesim.conf +3
-0+#[cdmaphonesim] +#Address=127.0.0.1 +#Port=12345If we have both phonesim and cdmaphonesim plugins active, we need to make sure they don't interfere with each other. Perhaps adding a Type=cdma and having cdmaphonesim look for that Type tag and ignore the rest would be a good idea?
If both phonesim and cdmaphonesim active, they should have to be configured with running with different port, right? If so,they should not interfere with each other. And, making sure ports are different is the job of the end-user, right?
I am a bit lost about the Type attribute. cdmaphonesim is currently defined as a separate plugin and by the time cdmaphonesim's parse_config() is invoked, it already knows that it is cdma. Thus, I don't see why needing another flag indicating this. When you say ignore the rest, could you pls be more specific about what to ignore and what's the intention of doing that? Sorry, still learning... :-)
Quoted 2 lines
Regards,
-Denis
Regards,
-Lei
Hi Lei,
Quoted 19 lines
Quoted 9 lines
Quoted 9 lines
plugins/phonesim.conf +1
-0@@ -12,3 +12,7 @@ #[phonesim] #Address=127.0.0.1 #Port=12345 +Quoted 9 lines
plugins/phonesim.conf line 18
Quoted 3 lines
plugins/phonesim.conf +3
-0+#[cdmaphonesim] +#Address=127.0.0.1 +#Port=12345If we have both phonesim and cdmaphonesim plugins active, we need to make sure they don't interfere with each other. Perhaps adding a Type=cdma and having cdmaphonesim look for that Type tag and ignore the rest would be a good idea?
Quoted 4 lines
If both phonesim and cdmaphonesim active, they should have to be configured with running with different port, right? If so,they should not interfere with each other. And, making sure ports are different is the job of the end-user, right?
That is correct and not what I was referring to.
Quoted 8 lines
I am a bit lost about the Type attribute. cdmaphonesim is currently defined as a separate plugin and by the time cdmaphonesim's
parse_config()is invoked, it already knows that it is cdma. Thus, I don't see why needing another flag indicating this. When you say ignore the rest, could you pls be more specific about what to ignore and what's the intention of doing that? Sorry, still learning... :-)
So correct me if I'm wrong, but there's a race between cdmaphonesim and phonesim plugins:
if phonesim starts first it reads phonesim.conf and creates both phonesim and cdmaphonesim modems. When cdmaphonesim starts, it tries to create the modems again, but fails. Similar situation vice-versa.
This is why I'm suggesting the Type attribute. Maybe I'm blind and this race does not happen?
Regards,
-Denis
Hi Denis,
Quoted 17 lines · ext Denis Kenzior
Quoted 6 lines
Quoted 6 lines
If we have both phonesim and cdmaphonesim plugins active, we need to make sure they don't interfere with each other. Perhaps adding a Type=cdma and having cdmaphonesim look for that Type tag and ignore the rest would be a good idea?
Quoted 7 lines
I am a bit lost about the Type attribute. cdmaphonesim is currently defined as a separate plugin and by the time cdmaphonesim's
parse_config()is invoked, it already knows that it is cdma. Thus, I don't see why needing another flag indicating this. When you say ignore the rest, could you pls be more specific about what to ignore and what's the intention of doing that? Sorry, still learning... :-)So correct me if I'm wrong, but there's a race between cdmaphonesim and phonesim plugins:
Quoted 7 lines
if phonesim starts first it reads phonesim.conf and creates both phonesim and cdmaphonesim modems. When cdmaphonesim starts, it tries to create the modems again, but fails. Similar situation vice-versa.
This is why I'm suggesting the Type attribute. Maybe I'm blind and this race does not happen?
Now, I understand your point. I checked the log, in my setup, cdmaphonsim will run first and it will create cdmaphonsim plugin. Next, phonesim will run and try to create cdmaphonsim plugin with wrong type:
"phonesim" but failed. I.e., we are lucky to have cdmaphonsim run first.
So, the way to fix this is to add a Type=cdma flag under [cdmaphonsim] and let cdmaphonsim.c only create modem if type is set to cdma. In addition to this, we also need to modify phonesim.c to ignore any modem group that has type set to cdma.
Could you pls clarify whether above solution will work?
Quoted 2 lines
Regards,
-Denis
Regards,
Lei