Resubmitting STE Driver patches.
v2 cover Resubmitting STE Driver patches.
Resubmitting based on rebase comments from Denis K. Changes:
o SIM-ready and Radio-Settings are now split in two parts, one patch for driver and one for plugin.
o Use MBM stk driver implementation (avoid copying code).
o Updated error handling for Radio Settings.
o Various Style issues (new line and tabs).
New patch:
o Added patch for plugins/ste using Socket stream mode for CAIF, and adding support for specifying CAIF interface to bind to.
Sjur Brændeland (7):
stemodem: Add support for STK by including MBM implementation.
atmodem: Enable STE usage of AT*EPEV and AT*EPEE for PIN handling.
stemodem: Add polling for SIM ready.
stemodem: Add Radio Settings to STE Modem
plugins/ste: Add Radio-Settings
stemodem: Use RTNL for creating CAIF interface plugins/ste: Use SOCK_STREAM for CAIF and enable interface
specification.
Makefile.am | 6 +- drivers/atmodem/sim.c | 9 +- drivers/stemodem/gprs-context.c | 51 +++++-- drivers/stemodem/radio-settings.c | 225 ++++++++++++++++++++++++++ drivers/stemodem/rtnl.c | 318 +++++++++++++++++++++++++++++++++++++ drivers/stemodem/rtnl.h | 24 +++ drivers/stemodem/stemodem.c | 4 + drivers/stemodem/stemodem.h | 5 + plugins/modem.conf | 5 + plugins/modemconf.c | 1 + plugins/ste.c | 79 +++++++++- 11 files changed, 706 insertions(+), 21 deletions(-) create mode 100644 drivers/stemodem/radio-settings.c create mode 100644 drivers/stemodem/rtnl.c create mode 100644 drivers/stemodem/rtnl.h
PATCH v2 1/7 stemodem: Add support for STK by including MBM implementation.
---
Changes:
o Use MBM stk driver implementation (avoid copying code).
Note: stemodm.h has to declare the mbm_stk_init/exit functions because
importing mbmdriver causes compile errors due to duplicated declarations.
drivers/stemodem/stemodem.c | 2 ++ drivers/stemodem/stemodem.h | 2 ++ plugins/ste.c | 2 ++ 3 files changed, 6 insertions(+), 0 deletions(-)
drivers/stemodem/stemodem.c +2 -0
@@ -38,6 +38,7 @@ static int stemodem_init(void) {ste_voicecall_init ();ste_gprs_context_init (); +mbm_stk_init ();return 0 ; }
@@ -46,6 +47,7 @@ static void stemodem_exit(void) {ste_voicecall_exit ();ste_gprs_context_exit (); +mbm_stk_exit (); } OFONO_PLUGIN_DEFINE(stemodem, "STE modem driver", VERSION,
drivers/stemodem/stemodem.h +2 -0
@@ -28,3 +28,5 @@ extern void ste_gprs_context_exit();extern void ste_voicecall_init ();extern void ste_voicecall_exit (); +extern void mbm_stk_init (); +extern void mbm_stk_exit ();
plugins/ste.c +2 -0
@@ -54,6 +54,7 @@#include <ofono/voicecall.h> #include <ofono/gprs.h> #include <ofono/gprs-context.h> +#include <ofono/stk.h> #include <drivers/atmodem/vendor.h> #include <drivers/stemodem/caif_socket.h>
@@ -241,6 +242,7 @@ static void ste_post_sim(struct ofono_modem *modem) gprs =ofono_gprs_create (modem,OFONO_VENDOR_STE ,"atmodem" , data->chat); +ofono_stk_create (modem,0 ,"mbmmodem" , data->chat); gc =ofono_gprs_context_create (modem,0 ,"stemodem" , data->chat);if (gprs && gc)
Signature · 1 line
1.7.0.4
Re: [PATCHv2 1/7] stemodem: Add support for STK by including MBM implementation.
Hi Sjur,
Quoted 37 lines
Changes:
o Use MBM stk driver implementation (avoid copying code).
Note:stemodm.hhas to declare the mbm_stk_init/exit functions because
importing mbmdriver causes compile errors due to duplicated declarations.drivers/stemodem/stemodem.c | 2 ++ drivers/stemodem/stemodem.h | 2 ++ plugins/ste.c | 2 ++ 3 files changed, 6 insertions(+), 0 deletions(-)drivers/stemodem/stemodem.c +2
-0@@ -38,6 +38,7 @@ static int stemodem_init(void) {ste_voicecall_init ();ste_gprs_context_init (); +mbm_stk_init ();return 0 ; }@@ -46,6 +47,7 @@ static void stemodem_exit(void) {ste_voicecall_exit ();ste_gprs_context_exit (); +mbm_stk_exit (); } OFONO_PLUGIN_DEFINE(stemodem, "STE modem driver", VERSION,drivers/stemodem/stemodem.h +0
-0
drivers/stemodem/stemodem.h extern void ste_gprs_context_exit(); · line 32
Quoted 5 lines
drivers/stemodem/stemodem.h +2
-0@@ -28,3 +28,5 @@ extern void ste_gprs_context_exit();extern void ste_voicecall_init ();extern void ste_voicecall_exit (); +extern void mbm_stk_init (); +extern void mbm_stk_exit ();
all the magic above is not needed. The build system builds the plugins properly and you can cross reference modem drivers from your modem plugin without any problems.
Quoted 13 lines
plugins/ste.c +1
-0@@ -54,6 +54,7 @@#include <ofono/voicecall.h> #include <ofono/gprs.h> #include <ofono/gprs-context.h> +#include <ofono/stk.h> #include <drivers/atmodem/vendor.h> #include <drivers/stemodem/caif_socket.h>
plugins/ste.c static void ste_post_sim(struct ofono_modem *modem) · line 248
Quoted 7 lines
plugins/ste.c +1
-0@@ -241,6 +242,7 @@ static void ste_post_sim(struct ofono_modem *modem) gprs =ofono_gprs_create (modem,OFONO_VENDOR_STE ,"atmodem" , data->chat); +ofono_stk_create (modem,0 ,"mbmmodem" , data->chat); gc =ofono_gprs_context_create (modem,0 ,"stemodem" , data->chat);if (gprs && gc)
Only these two changes are needed.
Regards
Marcel
Re: [PATCHv2 1/7] stemodem: Add support for STK by including MBM implementation.
Quoted 3 lines · Marcel Holtmann
all the magic above is not needed. The build system builds the plugins properly and you can cross reference modem drivers from your modem plugin without any problems.
Sure, I'll change this.
Regards
Sjur
PATCH v2 2/7 atmodem: Enable STE usage of AT*EPEV and AT*EPEE for PIN handling.
In reply to Sjur Brændeland--- drivers/atmodem/sim.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-)
drivers/atmodem/sim.c +6 -3
@@ -567,10 +567,12 @@ static void at_pin_send_cb(gboolean ok, GAtResult *result,decode_at_error (&error,g_at_result_final_response (result));/* -* On the MBM modem, AT+CPIN? keeps returning SIM PIN for a moment -* after successful AT+CPIN="..", but sends *EPEV when that changes. +* On the MBM and STE modem, AT+CPIN? keeps returning SIM PIN for a +* moment after successful AT+CPIN="..", but sends *EPEV when that +* changes. */ -if (ok && sd->vendor ==OFONO_VENDOR_MBM ) { +if (ok && (sd->vendor ==OFONO_VENDOR_MBM || + sd->vendor ==OFONO_VENDOR_STE )) { sd->epev_id =g_at_chat_register (sd->chat,"*EPEV" , at_epev_notify, FALSE, cbd, g_free);
@@ -817,6 +819,7 @@ static int at_sim_probe(struct ofono_sim *sim, unsigned int vendor,case OFONO_VENDOR_WAVECOM :g_at_chat_add_terminator (sd->chat,"+CPIN:" ,6 , TRUE);break ; +case OFONO_VENDOR_STE :case OFONO_VENDOR_MBM :g_at_chat_send (sd->chat,"AT*EPEE=1" ,NULL ,NULL ,NULL ,NULL );break ;
Signature · 1 line
1.6.3.3
Re: [PATCHv2 2/7] atmodem: Enable STE usage of AT*EPEV and AT*EPEE for PIN handling.
Hi Sjur,
Quoted 24 lines
drivers/atmodem/sim.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-)drivers/atmodem/sim.c +5
-3@@ -567,10 +567,12 @@ static void at_pin_send_cb(gboolean ok, GAtResult *result,decode_at_error (&error,g_at_result_final_response (result));/* -* On the MBM modem, AT+CPIN? keeps returning SIM PIN for a moment -* after successful AT+CPIN="..", but sends *EPEV when that changes. +* On the MBM and STE modem, AT+CPIN? keeps returning SIM PIN for a +* moment after successful AT+CPIN="..", but sends *EPEV when that +* changes. */ -if (ok && sd->vendor ==OFONO_VENDOR_MBM ) { +if (ok && (sd->vendor ==OFONO_VENDOR_MBM || + sd->vendor ==OFONO_VENDOR_STE )) { sd->epev_id =g_at_chat_register (sd->chat,"*EPEV" , at_epev_notify, FALSE, cbd, g_free);
drivers/atmodem/sim.c static int at_sim_probe(struct ofono_sim *sim, unsigned int vendor, · line 825
Quoted 7 lines
drivers/atmodem/sim.c +1
-0@@ -817,6 +819,7 @@ static int at_sim_probe(struct ofono_sim *sim, unsigned int vendor,case OFONO_VENDOR_WAVECOM :g_at_chat_add_terminator (sd->chat,"+CPIN:" ,6 , TRUE);break ; +case OFONO_VENDOR_STE :case OFONO_VENDOR_MBM :g_at_chat_send (sd->chat,"AT*EPEE=1" ,NULL ,NULL ,NULL ,NULL );break ;
do we really wanna create another vendor quirk here. If both modems behave identical then just pass OFONO_VENDOR_MBM in the SIM atom registration and be done with it.
Regards
Marcel
PATCH v2 3/7 stemodem: Add polling for SIM ready.
In reply to Sjur BrændelandInterim solution until support for SIM 'ready' notification is supported.
---
Changes:
o Fixed style issues (tabs and newlines)
plugins/ste.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 52 insertions(+), 3 deletions(-)
plugins/ste.c +52 -3
@@ -60,8 +60,13 @@#include <drivers/stemodem/caif_socket.h> #include <drivers/stemodem/if_caif.h> +static const char *cpin_prefix[] = {"+CPIN:" ,NULL }; +struct ste_data {GAtChat *chat; +guint cpin_poll_source; +guint cpin_poll_count; +gboolean have_sim; };static int ste_probe (struct ofono_modem *modem)
@@ -88,6 +93,10 @@ static void ste_remove(struct ofono_modem *modem)ofono_modem_set_data (modem,NULL );g_at_chat_unref (data->chat); + +if (data->cpin_poll_source >0 ) +g_source_remove (data->cpin_poll_source); +g_free (data); }
@@ -96,16 +105,55 @@ static void ste_debug(const char *str, void *user_data)ofono_info ("%s" , str); } +static gboolean init_simpin_check (gpointer user_data); + +static void simpin_check (gboolean ok,GAtResult *result,gpointer user_data) +{ +struct ofono_modem *modem = user_data; +struct ste_data *data =ofono_modem_get_data (modem); + +/* Modem returns +CME ERROR: 10 if SIM is not ready. */ +if (!ok && result->final_or_pdu && + !strcmp (result->final_or_pdu,"+CME ERROR: 10" ) && + data->cpin_poll_count++ <5 ) { + data->cpin_poll_source = +g_timeout_add_seconds (1 , init_simpin_check, modem); +return ; + } + + data->cpin_poll_count =0 ; + +/* Modem returns ERROR if there is no SIM in slot. */ + data->have_sim = ok; + +ofono_modem_set_powered (modem, TRUE); +} + +static gboolean init_simpin_check (gpointer user_data) +{ +struct ofono_modem *modem = user_data; +struct ste_data *data =ofono_modem_get_data (modem); + + data->cpin_poll_source =0 ; + +g_at_chat_send (data->chat,"AT+CPIN?" , cpin_prefix, + simpin_check, modem,NULL ); + +return FALSE; +} +static void cfun_enable (gboolean ok,GAtResult *result,gpointer user_data) {struct ofono_modem *modem = user_data;DBG ("" ); -if (!ok) +if (!ok) {ofono_modem_set_powered (modem, FALSE); +return ; + } -ofono_modem_set_powered (modem, TRUE); +init_simpin_check (modem); }static int ste_enable (struct ofono_modem *modem)
@@ -168,7 +216,8 @@ static int ste_enable(struct ofono_modem *modem)if (getenv ("OFONO_AT_DEBUG" ))g_at_chat_set_debug (data->chat, ste_debug,NULL ); -g_at_chat_send (data->chat,"ATE0 +CMEE=1" ,NULL ,NULL ,NULL ,NULL ); +g_at_chat_send (data->chat,"AT&F E0 V1 X4 &C1 +CMEE=1" , +NULL ,NULL ,NULL ,NULL );g_at_chat_send (data->chat,"AT+CFUN=1" ,NULL , cfun_enable, modem,NULL );return -EINPROGRESS ;
Signature · 1 line
1.6.3.3
PATCH v2 4/7 stemodem: Add Radio Settings to STE Modem
In reply to Sjur Brændeland---
Changes since last patch set:
o Moved updates to plugins/ste to separate patch.
o Updated error handling.
o Style issues.
Makefile.am | 4 +- drivers/stemodem/radio-settings.c | 223 +++++++++++++++++++++++++++++++++++++ drivers/stemodem/stemodem.c | 2 + drivers/stemodem/stemodem.h | 2 + 4 files changed, 230 insertions(+), 1 deletions(-) create mode 100644 drivers/stemodem/radio-settings.c
Makefile.am +3 -1
@@ -204,7 +204,9 @@ builtin_sources += drivers/atmodem/atutil.h \ drivers/stemodem/voicecall.c \ drivers/stemodem/gprs-context.c \ drivers/stemodem/caif_socket.h \ - drivers/stemodem/if_caif.h + drivers/stemodem/if_caif.h \ + drivers/stemodem/radio-settings.c + builtin_modules += phonesim builtin_sources += plugins/phonesim.c
drivers/stemodem/radio-settings.c new file +223 -0
223 lines not on this page · raw message
drivers/stemodem/stemodem.c +2 -0
@@ -39,6 +39,7 @@ static int stemodem_init(void)ste_voicecall_init ();ste_gprs_context_init ();mbm_stk_init (); +ste_radio_settings_init ();return 0 ; }
@@ -48,6 +49,7 @@ static void stemodem_exit(void)ste_voicecall_exit ();ste_gprs_context_exit ();mbm_stk_exit (); +ste_radio_settings_exit (); } OFONO_PLUGIN_DEFINE(stemodem, "STE modem driver", VERSION,
Signature · 1 line
1.6.3.3
Re: [PATCHv2 4/7] stemodem: Add Radio Settings to STE Modem
Hi Sjur,
Quoted 6 lines
Changes since last patch set:
o Moved updates to plugins/ste to separate patch.
o Updated error handling.
o Style issues.
Quoted 6 lines
Makefile.am | 4 +- drivers/stemodem/radio-settings.c | 223 +++++++++++++++++++++++++++++++++++++ drivers/stemodem/stemodem.c | 2 + drivers/stemodem/stemodem.h | 2 + 4 files changed, 230 insertions(+), 1 deletions(-) create mode 100644 drivers/stemodem/radio-settings.c
is this identical to how MBM does it? If yes, then I prefer we add this to drivers/mbmmodem/ and you just reference it. If not then I like to see the MBM version of this and where it actually differs. Maybe a MBM version with a STE quirk is better.
I prefer doing this in MBM since that modem driver was just the first. There is no other preference here ;)
Regards
Marcel
Re: [PATCHv2 4/7] stemodem: Add Radio Settings to STE Modem
Quoted 15 lines · Marcel Holtmann
Hi Sjur,
Quoted 6 lines
Changes since last patch set:
o Moved updates to plugins/ste to separate patch.
o Updated error handling.
o Style issues.Quoted 6 lines
Makefile.am | 4 +-
drivers/stemodem/radio-settings.c| 223 +++++++++++++++++++++++++++++++++++++drivers/stemodem/stemodem.c| 2 +drivers/stemodem/stemodem.h| 2 +4 files changed, 230 insertions(+), 1 deletions(-)create mode 100644
drivers/stemodem/radio-settings.c
Quoted 4 lines
is this identical to how MBM does it? If yes, then I prefer we add this to
drivers/mbmmodem/and you just reference it. If not then I like to see the MBM version of this and where it actually differs. Maybe a MBM version with a STE quirk is better.
Actually this is not yet implemented by MBM, so I guess STE is master this time ;-)
Quoted 2 lines
I prefer doing this in MBM since that modem driver was just the first. There is no other preference here ;)
This actually raises one question. How should we handle version variations from the same Modem vendor.
The differences will be larger as we start adding support for LTE, and support different
bearers (PC cards with USB and Modems with CAIF).
Should we create more entries in the vendor enum, or do you have something else in mind?
Regards
Sjur
Re: [PATCHv2 4/7] stemodem: Add Radio Settings to STE Modem
Hi Sjur,
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Changes since last patch set:
o Moved updates to plugins/ste to separate patch.
o Updated error handling.
o Style issues.Makefile.am | 4 +- drivers/stemodem/radio-settings.c | 223 +++++++++++++++++++++++++++++++++++++ drivers/stemodem/stemodem.c | 2 + drivers/stemodem/stemodem.h | 2 + 4 files changed, 230 insertions(+), 1 deletions(-) create mode 100644 drivers/stemodem/radio-settings.c
Quoted 7 lines
Quoted 4 lines
is this identical to how MBM does it? If yes, then I prefer we add this to
drivers/mbmmodem/and you just reference it. If not then I like to see the MBM version of this and where it actually differs. Maybe a MBM version with a STE quirk is better.Actually this is not yet implemented by MBM, so I guess STE is master this time ;-)
I thought that part would be similar in both cards. Then I am fine with this.
Quoted 10 lines
Quoted 2 lines
I prefer doing this in MBM since that modem driver was just the first. There is no other preference here ;)
This actually raises one question. How should we handle version variations from the same Modem vendor.
The differences will be larger as we start adding support for LTE, and support different
bearers (PC cards with USB and Modems with CAIF).
Should we create more entries in the vendor enum, or do you have something else in mind?
We cross that bridge when we get to it.
Regards
Marcel
PATCH v2 5/7 plugins/ste: Add Radio-Settings
In reply to Sjur Brændeland--- plugins/ste.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
plugins/ste.c +2 -0
@@ -55,6 +55,7 @@#include <ofono/gprs.h> #include <ofono/gprs-context.h> #include <ofono/stk.h> +#include <ofono/radio-settings.h> #include <drivers/atmodem/vendor.h> #include <drivers/stemodem/caif_socket.h>
@@ -292,6 +293,7 @@ static void ste_post_sim(struct ofono_modem *modem) gprs =ofono_gprs_create (modem,OFONO_VENDOR_STE ,"atmodem" , data->chat);ofono_stk_create (modem,0 ,"mbmmodem" , data->chat); +ofono_radio_settings_create (modem,0 ,"stemodem" , data->chat); gc =ofono_gprs_context_create (modem,0 ,"stemodem" , data->chat);if (gprs && gc)
Signature · 1 line
1.6.3.3
PATCH v2 6/7 stemodem: Use RTNL for creating CAIF interface
In reply to Sjur BrændelandCAIF in Linux kernel 2.6.35 must use RTNL for configuring CAIF interfaces.
--- Makefile.am | 4 +- drivers/stemodem/gprs-context.c | 51 +++++-- drivers/stemodem/rtnl.c | 318 +++++++++++++++++++++++++++++++++++++++ drivers/stemodem/rtnl.h | 24 +++ 4 files changed, 383 insertions(+), 14 deletions(-) create mode 100644 drivers/stemodem/rtnl.c create mode 100644 drivers/stemodem/rtnl.h
Makefile.am +3 -1
@@ -205,7 +205,9 @@ builtin_sources += drivers/atmodem/atutil.h \ drivers/stemodem/gprs-context.c \ drivers/stemodem/caif_socket.h \ drivers/stemodem/if_caif.h \ - drivers/stemodem/radio-settings.c + drivers/stemodem/radio-settings.c \ + drivers/stemodem/rtnl.h \ + drivers/stemodem/rtnl.c builtin_modules += phonesim
drivers/stemodem/gprs-context.c +38 -13
102 lines not on this page · raw message
drivers/stemodem/rtnl.c new file +318 -0
318 lines not on this page · raw message
drivers/stemodem/rtnl.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* +* oFono - Open Source Telephony +* +* Copyright (C) 2010 ST-Ericsson AB. +* +* 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 +* +*/ + +extern int rtnl_create_caif_interface (int type,int conn_id,char ifname[16 ], +int *ifindex); +extern int rtnl_delete_caif_interface (int ifid);
Signature · 1 line
1.6.3.3
PATCH v2 7/7 plugins/ste: Use SOCK_STREAM for CAIF and enable interface specification.
In reply to Sjur Brændeland--- plugins/modem.conf | 5 +++++ plugins/modemconf.c | 1 + plugins/ste.c | 20 +++++++++++++++++++- 3 files changed, 25 insertions(+), 1 deletions(-)
plugins/modem.conf +5 -0
@@ -44,3 +44,8 @@ #[n900] #Driver=n900modem #Interface=phonet0 + +# Sample STE modem +#[ste] +#Interface=cfttyS0 +#Driver=ste
plugins/modemconf.c +1 -0
@@ -138,6 +138,7 @@ static struct { { "g1", set_device }, { "wavecom", set_device }, { "ste", set_device }, + { "ste", set_interface }, { "calypso", set_device }, { "palmpre", set_device }, { "isimodem", set_interface },
plugins/ste.c +19 -1
@@ -30,6 +30,7 @@#include <stdlib.h> #include <string.h> #include <unistd.h> +#include <net/if.h> #include <glib.h> #include <gatchat.h>
@@ -171,14 +172,31 @@ static int ste_enable(struct ofono_modem *modem)if (!device) {struct sockaddr_caif addr;int err; +const char *interface;/* Create a CAIF socket for AT Service */ - fd =socket (AF_CAIF ,SOCK_SEQPACKET ,CAIFPROTO_AT ); + fd =socket (AF_CAIF ,SOCK_STREAM ,CAIFPROTO_AT );if (fd <0 ) {ofono_error ("Failed to create CAIF socket for AT" );return -EIO ; } +/* Bind CAIF socket to specified interface */ + interface =ofono_modem_get_string (modem,"Interface" ); +if (interface) { +struct ifreq ifreq; +memset (&ifreq,0 ,sizeof (ifreq)); +strcpy (ifreq.ifr_name, interface); + err =setsockopt (fd,SOL_SOCKET , +SO_BINDTODEVICE , &ifreq,sizeof (ifreq)); +if (err <0 ) { +ofono_error ("Failed to bind caif socket " +"to interface" ); +close (fd); +return err; + } + } +memset (&addr,0 ,sizeof (addr)); addr.family =AF_CAIF ; addr.u.at.type =CAIF_ATTYPE_PLAIN ;
Signature · 1 line
1.6.3.3
PATCH v3 1/7 plugins/ste: Include STK support from MBM driver.
In reply to Sjur BrændelandFrom: Sjur Brændeland <[email protected]>
---
Quoted 3 lines · Marcel Holtmann
... The build system builds the plugins
properly and you can cross reference modem drivers from your modem plugin without any problems.
Simply refering to MBM driver from ste.c
plugins/ste.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
plugins/ste.c +2 -0
@@ -54,6 +54,7 @@#include <ofono/voicecall.h> #include <ofono/gprs.h> #include <ofono/gprs-context.h> +#include <ofono/stk.h> #include <drivers/atmodem/vendor.h> #include <drivers/stemodem/caif_socket.h>
@@ -241,6 +242,7 @@ static void ste_post_sim(struct ofono_modem *modem) gprs =ofono_gprs_create (modem,OFONO_VENDOR_STE ,"atmodem" , data->chat); +ofono_stk_create (modem,0 ,"mbmmodem" , data->chat); gc =ofono_gprs_context_create (modem,0 ,"stemodem" , data->chat);if (gprs && gc)
Signature · 1 line
1.6.3.3
PATCH v3 2/7 plugins/ste: SIM - STE registers as MBM to utilize mbm quirks.
From: Sjur Brændeland <[email protected]>
---
Marcel Holtmann wrote:
...
Quoted 3 lines
do we really wanna create another vendor quirk here. If both modems behave identical then just pass
OFONO_VENDOR_MBMin the SIM atom registration and be done with it.
Re-use the MBM quirk rather than adding STE quirks in atmodem/sim.c
--- plugins/ste.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
plugins/ste.c +1 -1
@@ -214,7 +214,7 @@ static void ste_pre_sim(struct ofono_modem *modem)ofono_devinfo_create (modem,0 ,"atmodem" , data->chat); sim =ofono_sim_create (modem,0 ,"atmodem" , data->chat); -ofono_voicecall_create (modem,0 ,"stemodem" , data->chat); +ofono_voicecall_create (modem,OFONO_VENDOR_MBM ,"stemodem" , data->chat);if (sim)ofono_sim_inserted_notify (sim, TRUE);
Signature · 1 line
1.6.3.3
PATCH v3 3/7 stemodem: Add polling for SIM ready.
From: Sjur Brændeland <[email protected]>
Interim solution until support for SIM 'ready' notification is supported.
---
Changes:
o Fixed style issues (tabs and newlines)
plugins/ste.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 52 insertions(+), 3 deletions(-)
plugins/ste.c +52 -3
@@ -60,8 +60,13 @@#include <drivers/stemodem/caif_socket.h> #include <drivers/stemodem/if_caif.h> +static const char *cpin_prefix[] = {"+CPIN:" ,NULL }; +struct ste_data {GAtChat *chat; +guint cpin_poll_source; +guint cpin_poll_count; +gboolean have_sim; };static int ste_probe (struct ofono_modem *modem)
@@ -88,6 +93,10 @@ static void ste_remove(struct ofono_modem *modem)ofono_modem_set_data (modem,NULL );g_at_chat_unref (data->chat); + +if (data->cpin_poll_source >0 ) +g_source_remove (data->cpin_poll_source); +g_free (data); }
@@ -96,16 +105,55 @@ static void ste_debug(const char *str, void *user_data)ofono_info ("%s" , str); } +static gboolean init_simpin_check (gpointer user_data); + +static void simpin_check (gboolean ok,GAtResult *result,gpointer user_data) +{ +struct ofono_modem *modem = user_data; +struct ste_data *data =ofono_modem_get_data (modem); + +/* Modem returns +CME ERROR: 10 if SIM is not ready. */ +if (!ok && result->final_or_pdu && + !strcmp (result->final_or_pdu,"+CME ERROR: 10" ) && + data->cpin_poll_count++ <5 ) { + data->cpin_poll_source = +g_timeout_add_seconds (1 , init_simpin_check, modem); +return ; + } + + data->cpin_poll_count =0 ; + +/* Modem returns ERROR if there is no SIM in slot. */ + data->have_sim = ok; + +ofono_modem_set_powered (modem, TRUE); +} + +static gboolean init_simpin_check (gpointer user_data) +{ +struct ofono_modem *modem = user_data; +struct ste_data *data =ofono_modem_get_data (modem); + + data->cpin_poll_source =0 ; + +g_at_chat_send (data->chat,"AT+CPIN?" , cpin_prefix, + simpin_check, modem,NULL ); + +return FALSE; +} +static void cfun_enable (gboolean ok,GAtResult *result,gpointer user_data) {struct ofono_modem *modem = user_data;DBG ("" ); -if (!ok) +if (!ok) {ofono_modem_set_powered (modem, FALSE); +return ; + } -ofono_modem_set_powered (modem, TRUE); +init_simpin_check (modem); }static int ste_enable (struct ofono_modem *modem)
@@ -168,7 +216,8 @@ static int ste_enable(struct ofono_modem *modem)if (getenv ("OFONO_AT_DEBUG" ))g_at_chat_set_debug (data->chat, ste_debug,NULL ); -g_at_chat_send (data->chat,"ATE0 +CMEE=1" ,NULL ,NULL ,NULL ,NULL ); +g_at_chat_send (data->chat,"AT&F E0 V1 X4 &C1 +CMEE=1" , +NULL ,NULL ,NULL ,NULL );g_at_chat_send (data->chat,"AT+CFUN=1" ,NULL , cfun_enable, modem,NULL );return -EINPROGRESS ;
Signature · 1 line
1.6.3.3
PATCH v3 4/7 stemodem: Add Radio Settings to STE Modem
From: Sjur Brændeland <[email protected]>
--- Makefile.am | 3 +- drivers/stemodem/radio-settings.c | 225 +++++++++++++++++++++++++++++++++++++ drivers/stemodem/stemodem.c | 2 + drivers/stemodem/stemodem.h | 2 + 4 files changed, 231 insertions(+), 1 deletions(-) create mode 100644 drivers/stemodem/radio-settings.c
Makefile.am +2 -1
@@ -204,7 +204,8 @@ builtin_sources += drivers/atmodem/atutil.h \ drivers/stemodem/voicecall.c \ drivers/stemodem/gprs-context.c \ drivers/stemodem/caif_socket.h \ - drivers/stemodem/if_caif.h + drivers/stemodem/if_caif.h \ + drivers/stemodem/radio-settings.c builtin_modules += phonesim builtin_sources += plugins/phonesim.c
drivers/stemodem/radio-settings.c new file +225 -0
225 lines not on this page · raw message
drivers/stemodem/stemodem.c +2 -0
@@ -38,6 +38,7 @@ static int stemodem_init(void) {ste_voicecall_init ();ste_gprs_context_init (); +ste_radio_settings_init ();return 0 ; }
@@ -46,6 +47,7 @@ static void stemodem_exit(void) {ste_voicecall_exit ();ste_gprs_context_exit (); +ste_radio_settings_exit (); } OFONO_PLUGIN_DEFINE(stemodem, "STE modem driver", VERSION,
drivers/stemodem/stemodem.h +2 -0
@@ -28,3 +28,5 @@ extern void ste_gprs_context_exit();extern void ste_voicecall_init ();extern void ste_voicecall_exit (); +extern void ste_radio_settings_init (); +extern void ste_radio_settings_exit ();
Signature · 1 line
1.6.3.3
PATCH v3 5/7 plugins/ste: Add Radio-Settings
From: Sjur Brændeland <[email protected]>
--- plugins/ste.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
plugins/ste.c +2 -0
@@ -55,6 +55,7 @@#include <ofono/gprs.h> #include <ofono/gprs-context.h> #include <ofono/stk.h> +#include <ofono/radio-settings.h> #include <drivers/atmodem/vendor.h> #include <drivers/stemodem/caif_socket.h>
@@ -293,6 +294,7 @@ static void ste_post_sim(struct ofono_modem *modem) gprs =ofono_gprs_create (modem,OFONO_VENDOR_STE ,"atmodem" , data->chat);ofono_stk_create (modem,0 ,"mbmmodem" , data->chat); +ofono_radio_settings_create (modem,0 ,"stemodem" , data->chat); gc =ofono_gprs_context_create (modem,0 ,"stemodem" , data->chat);if (gprs && gc)
Signature · 1 line
1.6.3.3
PATCH v3 6/7 stemodem: Use RTNL for creating CAIF interface
From: Sjur Brændeland <[email protected]>
CAIF in Linux kernel 2.6.35 must use RTNL for configuring CAIF interfaces.
--- drivers/stemodem/gprs-context.c | 51 +++++-- drivers/stemodem/rtnl.c | 318 +++++++++++++++++++++++++++++++++++++++ drivers/stemodem/rtnl.h | 24 +++ 3 files changed, 380 insertions(+), 13 deletions(-) create mode 100644 drivers/stemodem/rtnl.c create mode 100644 drivers/stemodem/rtnl.h
drivers/stemodem/gprs-context.c +38 -13
@@ -43,8 +43,9 @@#include "gatchat.h" #include "gatresult.h" + +#include "rtnl.h" #include "stemodem.h" -#include "caif_socket.h" #include "if_caif.h" #define MAX_CAIF_DEVICES 7
@@ -68,7 +69,8 @@ struct conn_info {unsigned int cid;unsigned int device;unsigned int channel_id; -char interface[10 ]; +char ifname[16 ]; +int ifindex; };struct eppsd_response {
@@ -171,17 +173,40 @@ static struct conn_info *conn_info_create(unsigned int device,/* * Creates a new IP interface for CAIF. */ -static gboolean caif_if_create (const char *interface,unsigned int connid) +static gboolean caif_if_create (struct conn_info *conn) { -return FALSE; + +strcpy (conn->ifname,"caif%d" ); +if (rtnl_create_caif_interface (IFLA_CAIF_IPV4_CONNID , + conn->channel_id, + conn->ifname, + &conn->ifindex) <0 ) { +DBG ("Failed to create IP interface for CAIF" ); +return FALSE; + } + +DBG ("created CAIF interface ch:%d ifname:%s ifindex:%d\n" , + conn->channel_id, conn->ifname, conn->ifindex); + +return TRUE; }/* * Removes IP interface for CAIF. */ -static gboolean caif_if_remove (const char *interface,unsigned int connid) +static gboolean caif_if_remove (struct conn_info *conn) { -return FALSE; + +if (rtnl_delete_caif_interface (conn->ifindex) <0 ) { +ofono_error ("Failed to delete caif interface %s" , + conn->ifname); +return FALSE; + } + +DBG ("removed CAIF interface ch:%d ifname:%s ifindex:%d\n" , + conn->channel_id, conn->ifname, conn->ifindex); + +return TRUE; } static void ste_eppsd_down_cb(gboolean ok, GAtResult *result,
@@ -211,9 +236,9 @@ static void ste_eppsd_down_cb(gboolean ok, GAtResult *result, conn = l->data; -if (!caif_if_remove (conn->interface, conn->channel_id)) { +if (!caif_if_remove (conn)) {DBG ("Failed to remove caif interface %s." , - conn->interface); + conn->ifname); } conn->cid =0 ;
@@ -283,16 +308,16 @@ static void ste_eppsd_up_cb(gboolean ok, GAtResult *result, gpointer user_data) dns[1 ] = rsp.dns_server2; dns[2 ] =NULL ; -sprintf (conn->interface,"caif%u" , conn->device); +sprintf (conn->ifname,"caif%u" , conn->device); -if (!caif_if_create (conn->interface, conn->channel_id)) { +if (!caif_if_create (conn)) {ofono_error ("Failed to create caif interface %s." , - conn->interface); + conn->ifname);CALLBACK_WITH_SUCCESS (cb,NULL , FALSE, rsp.ip_address, rsp.subnet_mask, rsp.default_gateway, dns, cbd->data); }else { -CALLBACK_WITH_SUCCESS (cb, conn->interface, +CALLBACK_WITH_SUCCESS (cb, conn->ifname, FALSE, rsp.ip_address, rsp.subnet_mask, rsp.default_gateway, dns, cbd->data); }
@@ -544,7 +569,7 @@ static void ste_gprs_context_remove(struct ofono_gprs_context *gc)static struct ofono_gprs_context_driver driver = { .name ="stemodem" , .probe = ste_gprs_context_probe, - .remove = ste_gprs_context_remove, + .remove = ste_gprs_context_remove, .activate_primary = ste_gprs_activate_primary, .deactivate_primary = ste_gprs_deactivate_primary, };
drivers/stemodem/rtnl.c new file +318 -0
318 lines not on this page · raw message
drivers/stemodem/rtnl.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* +* oFono - Open Source Telephony +* +* Copyright (C) 2010 ST-Ericsson AB. +* +* 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 +* +*/ + +extern int rtnl_create_caif_interface (int type,int conn_id,char ifname[16 ], +int *ifindex); +extern int rtnl_delete_caif_interface (int ifid);
Signature · 1 line
1.6.3.3
PATCH v3 7/7 plugins/ste: Use SOCK_STREAM for CAIF and enable interface specification.
From: Sjur Brændeland <[email protected]>
--- plugins/modem.conf | 5 +++++ plugins/modemconf.c | 1 + plugins/ste.c | 20 +++++++++++++++++++- 3 files changed, 25 insertions(+), 1 deletions(-)
plugins/modem.conf +5 -0
@@ -44,3 +44,8 @@ #[n900] #Driver=n900modem #Interface=phonet0 + +# Sample STE modem +#[ste] +#Interface=cfttyS0 +#Driver=ste
plugins/modemconf.c +1 -0
@@ -138,6 +138,7 @@ static struct { { "g1", set_device }, { "wavecom", set_device }, { "ste", set_device }, + { "ste", set_interface }, { "calypso", set_device }, { "palmpre", set_device }, { "isimodem", set_interface },
plugins/ste.c +19 -1
@@ -30,6 +30,7 @@#include <stdlib.h> #include <string.h> #include <unistd.h> +#include <net/if.h> #include <glib.h> #include <gatchat.h>
@@ -171,14 +172,31 @@ static int ste_enable(struct ofono_modem *modem)if (!device) {struct sockaddr_caif addr;int err; +const char *interface;/* Create a CAIF socket for AT Service */ - fd =socket (AF_CAIF ,SOCK_SEQPACKET ,CAIFPROTO_AT ); + fd =socket (AF_CAIF ,SOCK_STREAM ,CAIFPROTO_AT );if (fd <0 ) {ofono_error ("Failed to create CAIF socket for AT" );return -EIO ; } +/* Bind CAIF socket to specified interface */ + interface =ofono_modem_get_string (modem,"Interface" ); +if (interface) { +struct ifreq ifreq; +memset (&ifreq,0 ,sizeof (ifreq)); +strcpy (ifreq.ifr_name, interface); + err =setsockopt (fd,SOL_SOCKET , +SO_BINDTODEVICE , &ifreq,sizeof (ifreq)); +if (err <0 ) { +ofono_error ("Failed to bind caif socket " +"to interface" ); +close (fd); +return err; + } + } +memset (&addr,0 ,sizeof (addr)); addr.family =AF_CAIF ; addr.u.at.type =CAIF_ATTYPE_PLAIN ;
Signature · 1 line
1.6.3.3
Re: [PATCH v3 2/7] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks.
In reply to Sjur BrændelandHi Sjur,
Quoted 15 lines
Quoted 3 lines
do we really wanna create another vendor quirk here. If both modems behave identical then just pass
OFONO_VENDOR_MBMin the SIM atom registration and be done with it.Re-use the MBM quirk rather than adding STE quirks in
atmodem/sim.c--- plugins/ste.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)plugins/ste.c +0
-0
plugins/ste.c static void ste_pre_sim(struct ofono_modem *modem) · line 217
Quoted 5 lines
plugins/ste.c +1
-1@@ -214,7 +214,7 @@ static void ste_pre_sim(struct ofono_modem *modem)ofono_devinfo_create (modem,0 ,"atmodem" , data->chat); sim =ofono_sim_create (modem,0 ,"atmodem" , data->chat); -ofono_voicecall_create (modem,0 ,"stemodem" , data->chat); +ofono_voicecall_create (modem,OFONO_VENDOR_MBM ,"stemodem" , data->chat);
this looks wrong. You are using a STE specific modem driver already. Why do you need to pass a quirk here as well.
Did I confuse you with one of my other replies or did I confuse myself here in the review?
Regards
Marcel
Re: [PATCH v3 1/7] plugins/ste: Include STK support from MBM driver.
In reply to Sjur BrændelandHi Sjur,
Quoted 22 lines
Quoted 3 lines
... The build system builds the plugins
properly and you can cross reference modem drivers from your modem plugin without any problems.Simply refering to MBM driver from
ste.cplugins/ste.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)plugins/ste.c +1
-0@@ -54,6 +54,7 @@#include <ofono/voicecall.h> #include <ofono/gprs.h> #include <ofono/gprs-context.h> +#include <ofono/stk.h> #include <drivers/atmodem/vendor.h> #include <drivers/stemodem/caif_socket.h>
plugins/ste.c static void ste_post_sim(struct ofono_modem *modem) · line 248
Quoted 7 lines
plugins/ste.c +1
-0@@ -241,6 +242,7 @@ static void ste_post_sim(struct ofono_modem *modem) gprs =ofono_gprs_create (modem,OFONO_VENDOR_STE ,"atmodem" , data->chat); +ofono_stk_create (modem,0 ,"mbmmodem" , data->chat); gc =ofono_gprs_context_create (modem,0 ,"stemodem" , data->chat);if (gprs && gc)
one minor nitpick here. Can you please not squeeze this in between GPRS and GPRS Context atoms. Put it at the same location the MBM plugin does.
Regards
Marcel
PATCH v4 1/7 plugins/ste: Include STK support from MBM driver.
In reply to Sjur BrændelandFrom: Sjur Brændeland <[email protected]>
---
Quoted 8 lines · Marcel Holtmann
Quoted 6 lines
Quoted 3 lines
... The build system builds the plugins
properly and you can cross reference modem drivers from your modem plugin without any problems.Simply refering to MBM driver from
ste.cone minor nitpick here. Can you please not squeeze this in between GPRS and GPRS Context atoms. Put it at the same location the MBM plugin does.
Fixed.
--- plugins/ste.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
plugins/ste.c +2 -0
@@ -54,6 +54,7 @@#include <ofono/voicecall.h> #include <ofono/gprs.h> #include <ofono/gprs-context.h> +#include <ofono/stk.h> #include <drivers/atmodem/vendor.h> #include <drivers/stemodem/caif_socket.h>
@@ -228,6 +229,7 @@ static void ste_post_sim(struct ofono_modem *modem)DBG ("%p" , modem); +ofono_stk_create (modem,0 ,"mbmmodem" , data->chat);ofono_ussd_create (modem,0 ,"atmodem" , data->chat);ofono_call_forwarding_create (modem,0 ,"atmodem" , data->chat);ofono_call_settings_create (modem,0 ,"atmodem" , data->chat);
Signature · 1 line
1.6.3.3
PATCH v4 2/7 plugins/ste: SIM - STE registers as MBM to utilize mbm quirks.
From: Sjur Brændeland <[email protected]>
---
Marcel Holtmann wrote:
...
Quoted 3 lines
do we really wanna create another vendor quirk here. If both modems behave identical then just pass
OFONO_VENDOR_MBMin the SIM atom registration and be done with it.
Re-use the MBM quirk rather than adding STE quirks in atmodem/sim.c
--- plugins/ste.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
plugins/ste.c +1 -1
@@ -214,7 +214,7 @@ static void ste_pre_sim(struct ofono_modem *modem)ofono_devinfo_create (modem,0 ,"atmodem" , data->chat); sim =ofono_sim_create (modem,0 ,"atmodem" , data->chat); -ofono_voicecall_create (modem,0 ,"stemodem" , data->chat); +ofono_voicecall_create (modem,OFONO_VENDOR_MBM ,"stemodem" , data->chat);if (sim)ofono_sim_inserted_notify (sim, TRUE);
Signature · 1 line
1.6.3.3
PATCH v4 3/7 stemodem: Add polling for SIM ready.
From: Sjur Brændeland <[email protected]>
Interim solution until support for SIM 'ready' notification is supported.
---
Changes:
o Fixed style issues (tabs and newlines)
plugins/ste.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 52 insertions(+), 3 deletions(-)
plugins/ste.c +52 -3
@@ -60,8 +60,13 @@#include <drivers/stemodem/caif_socket.h> #include <drivers/stemodem/if_caif.h> +static const char *cpin_prefix[] = {"+CPIN:" ,NULL }; +struct ste_data {GAtChat *chat; +guint cpin_poll_source; +guint cpin_poll_count; +gboolean have_sim; };static int ste_probe (struct ofono_modem *modem)
@@ -88,6 +93,10 @@ static void ste_remove(struct ofono_modem *modem)ofono_modem_set_data (modem,NULL );g_at_chat_unref (data->chat); + +if (data->cpin_poll_source >0 ) +g_source_remove (data->cpin_poll_source); +g_free (data); }
@@ -96,16 +105,55 @@ static void ste_debug(const char *str, void *user_data)ofono_info ("%s" , str); } +static gboolean init_simpin_check (gpointer user_data); + +static void simpin_check (gboolean ok,GAtResult *result,gpointer user_data) +{ +struct ofono_modem *modem = user_data; +struct ste_data *data =ofono_modem_get_data (modem); + +/* Modem returns +CME ERROR: 10 if SIM is not ready. */ +if (!ok && result->final_or_pdu && + !strcmp (result->final_or_pdu,"+CME ERROR: 10" ) && + data->cpin_poll_count++ <5 ) { + data->cpin_poll_source = +g_timeout_add_seconds (1 , init_simpin_check, modem); +return ; + } + + data->cpin_poll_count =0 ; + +/* Modem returns ERROR if there is no SIM in slot. */ + data->have_sim = ok; + +ofono_modem_set_powered (modem, TRUE); +} + +static gboolean init_simpin_check (gpointer user_data) +{ +struct ofono_modem *modem = user_data; +struct ste_data *data =ofono_modem_get_data (modem); + + data->cpin_poll_source =0 ; + +g_at_chat_send (data->chat,"AT+CPIN?" , cpin_prefix, + simpin_check, modem,NULL ); + +return FALSE; +} +static void cfun_enable (gboolean ok,GAtResult *result,gpointer user_data) {struct ofono_modem *modem = user_data;DBG ("" ); -if (!ok) +if (!ok) {ofono_modem_set_powered (modem, FALSE); +return ; + } -ofono_modem_set_powered (modem, TRUE); +init_simpin_check (modem); }static int ste_enable (struct ofono_modem *modem)
@@ -168,7 +216,8 @@ static int ste_enable(struct ofono_modem *modem)if (getenv ("OFONO_AT_DEBUG" ))g_at_chat_set_debug (data->chat, ste_debug,NULL ); -g_at_chat_send (data->chat,"ATE0 +CMEE=1" ,NULL ,NULL ,NULL ,NULL ); +g_at_chat_send (data->chat,"AT&F E0 V1 X4 &C1 +CMEE=1" , +NULL ,NULL ,NULL ,NULL );g_at_chat_send (data->chat,"AT+CFUN=1" ,NULL , cfun_enable, modem,NULL );return -EINPROGRESS ;
Signature · 1 line
1.6.3.3
PATCH v4 4/7 stemodem: Add Radio Settings to STE Modem
From: Sjur Brændeland <[email protected]>
--- Makefile.am | 3 +- drivers/stemodem/radio-settings.c | 225 +++++++++++++++++++++++++++++++++++++ drivers/stemodem/stemodem.c | 2 + drivers/stemodem/stemodem.h | 2 + 4 files changed, 231 insertions(+), 1 deletions(-) create mode 100644 drivers/stemodem/radio-settings.c
Makefile.am +2 -1
@@ -204,7 +204,8 @@ builtin_sources += drivers/atmodem/atutil.h \ drivers/stemodem/voicecall.c \ drivers/stemodem/gprs-context.c \ drivers/stemodem/caif_socket.h \ - drivers/stemodem/if_caif.h + drivers/stemodem/if_caif.h \ + drivers/stemodem/radio-settings.c builtin_modules += phonesim builtin_sources += plugins/phonesim.c
drivers/stemodem/radio-settings.c new file +225 -0
225 lines not on this page · raw message
drivers/stemodem/stemodem.c +2 -0
@@ -38,6 +38,7 @@ static int stemodem_init(void) {ste_voicecall_init ();ste_gprs_context_init (); +ste_radio_settings_init ();return 0 ; }
@@ -46,6 +47,7 @@ static void stemodem_exit(void) {ste_voicecall_exit ();ste_gprs_context_exit (); +ste_radio_settings_exit (); } OFONO_PLUGIN_DEFINE(stemodem, "STE modem driver", VERSION,
drivers/stemodem/stemodem.h +2 -0
@@ -28,3 +28,5 @@ extern void ste_gprs_context_exit();extern void ste_voicecall_init ();extern void ste_voicecall_exit (); +extern void ste_radio_settings_init (); +extern void ste_radio_settings_exit ();
Signature · 1 line
1.6.3.3
PATCH v4 5/7 plugins/ste: Add Radio-Settings
From: Sjur Brændeland <[email protected]>
--- plugins/ste.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
plugins/ste.c +2 -0
@@ -54,6 +54,7 @@#include <ofono/voicecall.h> #include <ofono/gprs.h> #include <ofono/gprs-context.h> +#include <ofono/radio-settings.h> #include <ofono/stk.h> #include <drivers/atmodem/vendor.h>
@@ -279,6 +280,7 @@ static void ste_post_sim(struct ofono_modem *modem)DBG ("%p" , modem);ofono_stk_create (modem,0 ,"mbmmodem" , data->chat); +ofono_radio_settings_create (modem,0 ,"stemodem" , data->chat);ofono_ussd_create (modem,0 ,"atmodem" , data->chat);ofono_call_forwarding_create (modem,0 ,"atmodem" , data->chat);ofono_call_settings_create (modem,0 ,"atmodem" , data->chat);
Signature · 1 line
1.6.3.3
PATCH v4 6/7 stemodem: Use RTNL for creating CAIF interface
From: Sjur Brændeland <[email protected]>
CAIF in Linux kernel 2.6.35 must use RTNL for configuring CAIF interfaces.
--- drivers/stemodem/gprs-context.c | 51 +++++-- drivers/stemodem/rtnl.c | 318 +++++++++++++++++++++++++++++++++++++++ drivers/stemodem/rtnl.h | 24 +++ 3 files changed, 380 insertions(+), 13 deletions(-) create mode 100644 drivers/stemodem/rtnl.c create mode 100644 drivers/stemodem/rtnl.h
drivers/stemodem/gprs-context.c +38 -13
@@ -43,8 +43,9 @@#include "gatchat.h" #include "gatresult.h" + +#include "rtnl.h" #include "stemodem.h" -#include "caif_socket.h" #include "if_caif.h" #define MAX_CAIF_DEVICES 7
@@ -68,7 +69,8 @@ struct conn_info {unsigned int cid;unsigned int device;unsigned int channel_id; -char interface[10 ]; +char ifname[16 ]; +int ifindex; };struct eppsd_response {
@@ -171,17 +173,40 @@ static struct conn_info *conn_info_create(unsigned int device,/* * Creates a new IP interface for CAIF. */ -static gboolean caif_if_create (const char *interface,unsigned int connid) +static gboolean caif_if_create (struct conn_info *conn) { -return FALSE; + +strcpy (conn->ifname,"caif%d" ); +if (rtnl_create_caif_interface (IFLA_CAIF_IPV4_CONNID , + conn->channel_id, + conn->ifname, + &conn->ifindex) <0 ) { +DBG ("Failed to create IP interface for CAIF" ); +return FALSE; + } + +DBG ("created CAIF interface ch:%d ifname:%s ifindex:%d\n" , + conn->channel_id, conn->ifname, conn->ifindex); + +return TRUE; }/* * Removes IP interface for CAIF. */ -static gboolean caif_if_remove (const char *interface,unsigned int connid) +static gboolean caif_if_remove (struct conn_info *conn) { -return FALSE; + +if (rtnl_delete_caif_interface (conn->ifindex) <0 ) { +ofono_error ("Failed to delete caif interface %s" , + conn->ifname); +return FALSE; + } + +DBG ("removed CAIF interface ch:%d ifname:%s ifindex:%d\n" , + conn->channel_id, conn->ifname, conn->ifindex); + +return TRUE; } static void ste_eppsd_down_cb(gboolean ok, GAtResult *result,
@@ -211,9 +236,9 @@ static void ste_eppsd_down_cb(gboolean ok, GAtResult *result, conn = l->data; -if (!caif_if_remove (conn->interface, conn->channel_id)) { +if (!caif_if_remove (conn)) {DBG ("Failed to remove caif interface %s." , - conn->interface); + conn->ifname); } conn->cid =0 ;
@@ -283,16 +308,16 @@ static void ste_eppsd_up_cb(gboolean ok, GAtResult *result, gpointer user_data) dns[1 ] = rsp.dns_server2; dns[2 ] =NULL ; -sprintf (conn->interface,"caif%u" , conn->device); +sprintf (conn->ifname,"caif%u" , conn->device); -if (!caif_if_create (conn->interface, conn->channel_id)) { +if (!caif_if_create (conn)) {ofono_error ("Failed to create caif interface %s." , - conn->interface); + conn->ifname);CALLBACK_WITH_SUCCESS (cb,NULL , FALSE, rsp.ip_address, rsp.subnet_mask, rsp.default_gateway, dns, cbd->data); }else { -CALLBACK_WITH_SUCCESS (cb, conn->interface, +CALLBACK_WITH_SUCCESS (cb, conn->ifname, FALSE, rsp.ip_address, rsp.subnet_mask, rsp.default_gateway, dns, cbd->data); }
@@ -544,7 +569,7 @@ static void ste_gprs_context_remove(struct ofono_gprs_context *gc)static struct ofono_gprs_context_driver driver = { .name ="stemodem" , .probe = ste_gprs_context_probe, - .remove = ste_gprs_context_remove, + .remove = ste_gprs_context_remove, .activate_primary = ste_gprs_activate_primary, .deactivate_primary = ste_gprs_deactivate_primary, };
drivers/stemodem/rtnl.c new file +318 -0
318 lines not on this page · raw message
drivers/stemodem/rtnl.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* +* oFono - Open Source Telephony +* +* Copyright (C) 2010 ST-Ericsson AB. +* +* 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 +* +*/ + +extern int rtnl_create_caif_interface (int type,int conn_id,char ifname[16 ], +int *ifindex); +extern int rtnl_delete_caif_interface (int ifid);
Signature · 1 line
1.6.3.3
PATCH v4 7/7 plugins/ste: Use SOCK_STREAM for CAIF and enable interface specification.
From: Sjur Brændeland <[email protected]>
--- plugins/modem.conf | 5 +++++ plugins/modemconf.c | 1 + plugins/ste.c | 20 +++++++++++++++++++- 3 files changed, 25 insertions(+), 1 deletions(-)
plugins/modem.conf +5 -0
@@ -44,3 +44,8 @@ #[n900] #Driver=n900modem #Interface=phonet0 + +# Sample STE modem +#[ste] +#Interface=cfttyS0 +#Driver=ste
plugins/modemconf.c +1 -0
@@ -138,6 +138,7 @@ static struct { { "g1", set_device }, { "wavecom", set_device }, { "ste", set_device }, + { "ste", set_interface }, { "calypso", set_device }, { "palmpre", set_device }, { "isimodem", set_interface },
plugins/ste.c +19 -1
@@ -30,6 +30,7 @@#include <stdlib.h> #include <string.h> #include <unistd.h> +#include <net/if.h> #include <glib.h> #include <gatchat.h>
@@ -171,14 +172,31 @@ static int ste_enable(struct ofono_modem *modem)if (!device) {struct sockaddr_caif addr;int err; +const char *interface;/* Create a CAIF socket for AT Service */ - fd =socket (AF_CAIF ,SOCK_SEQPACKET ,CAIFPROTO_AT ); + fd =socket (AF_CAIF ,SOCK_STREAM ,CAIFPROTO_AT );if (fd <0 ) {ofono_error ("Failed to create CAIF socket for AT" );return -EIO ; } +/* Bind CAIF socket to specified interface */ + interface =ofono_modem_get_string (modem,"Interface" ); +if (interface) { +struct ifreq ifreq; +memset (&ifreq,0 ,sizeof (ifreq)); +strcpy (ifreq.ifr_name, interface); + err =setsockopt (fd,SOL_SOCKET , +SO_BINDTODEVICE , &ifreq,sizeof (ifreq)); +if (err <0 ) { +ofono_error ("Failed to bind caif socket " +"to interface" ); +close (fd); +return err; + } + } +memset (&addr,0 ,sizeof (addr)); addr.family =AF_CAIF ; addr.u.at.type =CAIF_ATTYPE_PLAIN ;
Signature · 1 line
1.6.3.3
Re: [PATCH v4 7/7] plugins/ste: Use SOCK_STREAM for CAIF and enable interface specification.
Hi Sjur,
Quoted 4 lines
plugins/modem.conf | 5 +++++ plugins/modemconf.c | 1 + plugins/ste.c | 20 +++++++++++++++++++- 3 files changed, 25 insertions(+), 1 deletions(-)
please don't intermix modemconf and STE plugin changes. I need two separate patches for this.
Regards
Marcel
Re: [PATCH v4 6/7] stemodem: Use RTNL for creating CAIF interface
In reply to Sjur BrændelandHi Sjur,
Quoted 9 lines
CAIF in Linux kernel 2.6.35 must use RTNL for configuring CAIF interfaces.
--- drivers/stemodem/gprs-context.c | 51 +++++-- drivers/stemodem/rtnl.c | 318 +++++++++++++++++++++++++++++++++++++++ drivers/stemodem/rtnl.h | 24 +++ 3 files changed, 380 insertions(+), 13 deletions(-) create mode 100644 drivers/stemodem/rtnl.c create mode 100644 drivers/stemodem/rtnl.h
I can't really let you do make blocking reads to the netlink socket. That would be pretty much a bad idea.
We need a better solution for this. Maybe one that also helps the ISI modem drivers.
Regards
Marcel
Re: [PATCH v4 4/7] stemodem: Add Radio Settings to STE Modem
In reply to Sjur BrændelandHi Sjur,
Quoted 12 lines
Makefile.am | 3 +- drivers/stemodem/radio-settings.c | 225 +++++++++++++++++++++++++++++++++++++ drivers/stemodem/stemodem.c | 2 + drivers/stemodem/stemodem.h | 2 + 4 files changed, 231 insertions(+), 1 deletions(-) create mode 100644 drivers/stemodem/radio-settings.cMakefile.am +0
-0
Makefile.am builtin_sources += drivers/atmodem/atutil.h \ · line 208
Quoted 6 lines
Makefile.am +2
-1@@ -204,7 +204,8 @@ builtin_sources += drivers/atmodem/atutil.h \ drivers/stemodem/voicecall.c \ drivers/stemodem/gprs-context.c \ drivers/stemodem/caif_socket.h \ - drivers/stemodem/if_caif.h + drivers/stemodem/if_caif.h \ + drivers/stemodem/radio-settings.c
please put it after or before the gprs-context.c. I wanna keep the atom drivers together and not intermix with the CAIF includes.
Quoted 8 lines
Makefile.am +0
-0builtin_modules += phonesim builtin_sources += plugins/phonesim.cdrivers/stemodem/radio-settings.c new file +0
-0
drivers/stemodem/radio-settings.c line 10
Quoted 10 lines
drivers/stemodem/radio-settings.c new file +10
-0@@ -0,0 +1,225 @@ +/* +* +* oFono - Open Source Telephony +* +* Copyright (C) 2008-2010 Intel Corporation. All rights reserved. +* Copyright (C) 2010 ST-Ericsson AB. +* 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. +
You need to put an empty line after your copyright. Please keep the style we have for the copyright header.
Quoted 37 lines
*
+ * 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+ *
+ */drivers/stemodem/radio-settings.c new file +26
-0+ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#define _GNU_SOURCE +#include <string.h> +#include <stdlib.h> +#include <stdio.h> +#include <errno.h> + +#include <glib.h> + +#include <ofono/log.h> +#include <ofono/modem.h> +#include <ofono/radio-settings.h> + +#include "gatchat.h" +#include "gatresult.h" + +#include "stemodem.h" + +static const char *none_prefix[] = {NULL }; +static const char *cfun_prefix[] = {"+CFUN:" ,NULL }; + +struct radio_settings_data {
drivers/stemodem/radio-settings.c line 56
Quoted 10 lines
drivers/stemodem/radio-settings.c new file +10
-0+GAtChat *chat; +}; + +enum ste_radio_mode { +STE_RADIO_OFF =0 , +STE_RADIO_ON =1 , +STE_RADIO_FLIGHT_MODE =4 , +STE_RADIO_GSM_ONLY =5 , +STE_RADIO_WCDMA_ONLY =6 +};
Can you please insert tabs between the constant and the = <value>. We prefer having the enums nicely tabbed.
Quoted 7 lines
drivers/stemodem/radio-settings.c new file +7
-0+static gboolean ste_mode_to_ofono_mode (enum ste_radio_mode stemode, +enum ofono_radio_access_mode *mode) +{ +switch (stemode) { +case STE_RADIO_ON : + *mode =OFONO_RADIO_ACCESS_MODE_ANY ; +return TRUE;
drivers/stemodem/radio-settings.c line 74
Quoted 10 lines
drivers/stemodem/radio-settings.c new file +10
-0+case STE_RADIO_GSM_ONLY : + *mode =OFONO_RADIO_ACCESS_MODE_GSM ; +return TRUE; +case STE_RADIO_WCDMA_ONLY : + *mode =OFONO_RADIO_ACCESS_MODE_UMTS ; +return TRUE; +default : +return FALSE; + } +}
I prefer that you leave out the default statement and just add a return FALSE at the end of the function. Deal with missing enum entries and the compiler complaining by just adding a break.
This has the advantage if you accidentally add a constant the compiler will warn you instead of just using default statement.
Quoted 8 lines
drivers/stemodem/radio-settings.c new file +8
-0+static gboolean ofono_mode_to_ste_mode (enum ofono_radio_access_mode mode, +enum ste_radio_mode *stemode) +{ +switch (mode) { +case OFONO_RADIO_ACCESS_MODE_ANY : + *stemode =STE_RADIO_ON ; +return TRUE; +case OFONO_RADIO_ACCESS_MODE_GSM :
drivers/stemodem/radio-settings.c line 93
Quoted 10 lines
drivers/stemodem/radio-settings.c new file +10
-0+ *stemode =STE_RADIO_GSM_ONLY ; +return TRUE; + +case OFONO_RADIO_ACCESS_MODE_UMTS : + *stemode =STE_RADIO_WCDMA_ONLY ; +return TRUE; +default : +return FALSE; + } +}
Same here. And in addition please remove the empty line in between that is there for no real reason.
drivers/stemodem/radio-settings.c
Quoted 2 lines
drivers/stemodem/radio-settings.c new file +2
-0+static void sterat_query_cb (gboolean ok,GAtResult *result,gpointer user_data) +{
I prefer if you call this just rat_query_cb and don't bother prefixing it with ste.
Quoted 39 lines
drivers/stemodem/radio-settings.c new file +39
-0+struct cb_data *cbd = user_data; +ofono_radio_settings_rat_mode_query_cb_t cb = cbd->cb; +enum ofono_radio_access_mode mode; +struct ofono_error error; +GAtResultIter iter; +int value; + +decode_at_error (&error,g_at_result_final_response (result)); + +if (!ok) { +cb (&error,-1 , cbd->data); +return ; + } + +g_at_result_iter_init (&iter, result); + +if (!g_at_result_iter_next (&iter,"+CFUN:" )) + goto err; + +if (!g_at_result_iter_next_number (&iter, &value)) + goto err; + +if (!ste_mode_to_ofono_mode (value, &mode)) + goto err; + +CALLBACK_WITH_SUCCESS (cb, mode, cbd->data); + +return ; + +err: +CALLBACK_WITH_FAILURE (cb,-1 , cbd->data); +} + +static void ste_query_rat_mode (struct ofono_radio_settings *rs, +ofono_radio_settings_rat_mode_query_cb_t cb, +void *data) +{ +struct radio_settings_data *rsd =ofono_radio_settings_get_data (rs); +struct cb_data *cbd =cb_data_new (cb, data);
drivers/stemodem/radio-settings.c line 145
Quoted 10 lines
drivers/stemodem/radio-settings.c new file +10
-0+ +if (g_at_chat_send (rsd->chat,"AT+CFUN?" , cfun_prefix, + sterat_query_cb, cbd, g_free) ==0 ) { +CALLBACK_WITH_FAILURE (cb,-1 , data); +g_free (cbd); + } +} + +static void sterat_modify_cb (gboolean ok,GAtResult *result,gpointer user_data) +{
Same here. Please call it rat_modify_cb.
Quoted 105 lines
drivers/stemodem/radio-settings.c new file +80
-0+struct cb_data *cbd = user_data; +ofono_radio_settings_rat_mode_set_cb_t cb = cbd->cb; +struct ofono_error error; + +decode_at_error (&error,g_at_result_final_response (result)); + +if (!ok) { +cb (&error, cbd->data); +return ; + } + +CALLBACK_WITH_SUCCESS (cb, cbd->data); +} + +static void ste_set_rat_mode (struct ofono_radio_settings *rs, +enum ofono_radio_access_mode mode, +ofono_radio_settings_rat_mode_set_cb_t cb, +void *data) +{ +struct radio_settings_data *rsd =ofono_radio_settings_get_data (rs); +struct cb_data *cbd =cb_data_new (cb, data); +char buf[20 ]; +enum ste_radio_mode value; + +if (!ofono_mode_to_ste_mode (mode, &value)) { +CALLBACK_WITH_FAILURE (cb, data); +g_free (cbd); +return ; + } + +snprintf (buf,sizeof (buf),"AT+CFUN=%u" , value); + +if (g_at_chat_send (rsd->chat, buf, none_prefix, + sterat_modify_cb, cbd, g_free) ==0 ) { +CALLBACK_WITH_FAILURE (cb, data); +g_free (cbd); + } +} + +static int ste_radio_settings_probe (struct ofono_radio_settings *rs, +unsigned int vendor,void *data) +{ +GAtChat *chat = data; +struct radio_settings_data *rsd; + rsd = g_try_new0(struct radio_settings_data, 1); +if (!rsd) +return -ENOMEM ; + + rsd->chat = chat; + +ofono_radio_settings_set_data (rs, rsd); +ofono_radio_settings_register (rs); + +return 0 ; +} + +static void ste_radio_settings_remove (struct ofono_radio_settings *rs) +{ +struct radio_settings_data *rsd =ofono_radio_settings_get_data (rs); +ofono_radio_settings_set_data (rs,NULL ); +g_free (rsd); +} + +static struct ofono_radio_settings_driver driver = { + .name ="stemodem" , + .probe = ste_radio_settings_probe, + .remove = ste_radio_settings_remove, + .query_rat_mode = ste_query_rat_mode, + .set_rat_mode = ste_set_rat_mode +}; + +void ste_radio_settings_init () +{ +ofono_radio_settings_driver_register (&driver); +} + +void ste_radio_settings_exit () +{ +ofono_radio_settings_driver_unregister (&driver); +}drivers/stemodem/stemodem.c +2
-0@@ -38,6 +38,7 @@ static int stemodem_init(void) {ste_voicecall_init ();ste_gprs_context_init (); +ste_radio_settings_init ();return 0 ; }@@ -46,6 +47,7 @@ static void stemodem_exit(void) {ste_voicecall_exit ();ste_gprs_context_exit (); +ste_radio_settings_exit (); } OFONO_PLUGIN_DEFINE(stemodem, "STE modem driver", VERSION,drivers/stemodem/stemodem.h +0
-0
drivers/stemodem/stemodem.h extern void ste_gprs_context_exit(); · line 32
Quoted 5 lines
drivers/stemodem/stemodem.h +2
-0@@ -28,3 +28,5 @@ extern void ste_gprs_context_exit();extern void ste_voicecall_init ();extern void ste_voicecall_exit (); +extern void ste_radio_settings_init (); +extern void ste_radio_settings_exit ();
Rest looks just fine to me.
Regards
Marcel
Re: [PATCH v4 3/7] stemodem: Add polling for SIM ready.
In reply to Sjur BrændelandHi Sjur,
Quoted 83 lines
Interim solution until support for SIM 'ready' notification is supported.
---
Changes:
o Fixed style issues (tabs and newlines)plugins/ste.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 52 insertions(+), 3 deletions(-)plugins/ste.c +46
-0@@ -60,8 +60,13 @@#include <drivers/stemodem/caif_socket.h> #include <drivers/stemodem/if_caif.h> +static const char *cpin_prefix[] = {"+CPIN:" ,NULL }; +struct ste_data {GAtChat *chat; +guint cpin_poll_source; +guint cpin_poll_count; +gboolean have_sim; };static int ste_probe (struct ofono_modem *modem)@@ -88,6 +93,10 @@ static void ste_remove(struct ofono_modem *modem)ofono_modem_set_data (modem,NULL );g_at_chat_unref (data->chat); + +if (data->cpin_poll_source >0 ) +g_source_remove (data->cpin_poll_source); +g_free (data); }@@ -96,16 +105,55 @@ static void ste_debug(const char *str, void *user_data)ofono_info ("%s" , str); } +static gboolean init_simpin_check (gpointer user_data); + +static void simpin_check (gboolean ok,GAtResult *result,gpointer user_data) +{ +struct ofono_modem *modem = user_data; +struct ste_data *data =ofono_modem_get_data (modem); + +/* Modem returns +CME ERROR: 10 if SIM is not ready. */ +if (!ok && result->final_or_pdu && + !strcmp (result->final_or_pdu,"+CME ERROR: 10" ) && + data->cpin_poll_count++ <5 ) { + data->cpin_poll_source = +g_timeout_add_seconds (1 , init_simpin_check, modem); +return ; + } + + data->cpin_poll_count =0 ; + +/* Modem returns ERROR if there is no SIM in slot. */ + data->have_sim = ok; + +ofono_modem_set_powered (modem, TRUE); +} + +static gboolean init_simpin_check (gpointer user_data) +{ +struct ofono_modem *modem = user_data; +struct ste_data *data =ofono_modem_get_data (modem); + + data->cpin_poll_source =0 ; + +g_at_chat_send (data->chat,"AT+CPIN?" , cpin_prefix, + simpin_check, modem,NULL ); + +return FALSE; +} +static void cfun_enable (gboolean ok,GAtResult *result,gpointer user_data) {struct ofono_modem *modem = user_data;DBG ("" );
plugins/ste.c static void ste_debug(const char *str, void *user_data) · line 157
Quoted 10 lines
plugins/ste.c +4
-2-if (!ok) +if (!ok) {ofono_modem_set_powered (modem, FALSE); +return ; + } -ofono_modem_set_powered (modem, TRUE); +init_simpin_check (modem); }
I am fine with this if Denis is as well.
plugins/ste.c static int ste_enable(struct ofono_modem *modem) · line 221
Quoted 9 lines
plugins/ste.c +2
-1static int ste_enable (struct ofono_modem *modem)@@ -168,7 +216,8 @@ static int ste_enable(struct ofono_modem *modem)if (getenv ("OFONO_AT_DEBUG" ))g_at_chat_set_debug (data->chat, ste_debug,NULL ); -g_at_chat_send (data->chat,"ATE0 +CMEE=1" ,NULL ,NULL ,NULL ,NULL ); +g_at_chat_send (data->chat,"AT&F E0 V1 X4 &C1 +CMEE=1" , +NULL ,NULL ,NULL ,NULL );g_at_chat_send (data->chat,"AT+CFUN=1" ,NULL , cfun_enable, modem,NULL );
Why this change? If so, it does not belong in this commit. Or you need to add a comment why it does indeed.
Regards
Marcel
Re: [PATCH v4 2/7] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks.
In reply to Sjur BrændelandHi Sjur,
Quoted 16 lines
...
Quoted 3 lines
do we really wanna create another vendor quirk here. If both modems behave identical then just pass
OFONO_VENDOR_MBMin the SIM atom registration and be done with it.Re-use the MBM quirk rather than adding STE quirks in
atmodem/sim.c--- plugins/ste.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)plugins/ste.c +0
-0
plugins/ste.c static void ste_pre_sim(struct ofono_modem *modem) · line 217
Quoted 5 lines
plugins/ste.c +1
-1@@ -214,7 +214,7 @@ static void ste_pre_sim(struct ofono_modem *modem)ofono_devinfo_create (modem,0 ,"atmodem" , data->chat); sim =ofono_sim_create (modem,0 ,"atmodem" , data->chat); -ofono_voicecall_create (modem,0 ,"stemodem" , data->chat); +ofono_voicecall_create (modem,OFONO_VENDOR_MBM ,"stemodem" , data->chat);
I still don't get it. The stemodem/voicecall.c doesn't use any quirks and it should never do so. It is STE specific already.
Regards
Marcel
Re: [PATCH v4 1/7] plugins/ste: Include STK support from MBM driver.
In reply to Sjur BrændelandHi Sjur,
Quoted 10 lines
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
... The build system builds the plugins
properly and you can cross reference modem drivers from your modem plugin without any problems.Simply refering to MBM driver from
ste.cone minor nitpick here. Can you please not squeeze this in between GPRS and GPRS Context atoms. Put it at the same location the MBM plugin does.
Fixed.
patch has been applied. Thanks.
Regards
Marcel
v5 cover Resubmitting STE Driver Patches.
In reply to Sjur BrændelandResubmitting same changes as last patch set, but some of the patches are split up in smaller parts. The RTNL patch is removed and replaced by a separate RFC.
Sjur Brændeland (8):
plugins/ste: SIM - STE registers as MBM to utilize mbm quirks.
stemodem: Add polling for SIM ready.
plugins/ste: Add AT Channel configurations (new)
stemodem: Add Radio Settings to STE Modem
plugins/ste: Add Radio-Settings
plugins/modemconf.c add support for Interface for STE plugin. (new) plugins/ste: Use SOCK_STREAM for CAIF and enable interface
specification.
plugins: Add STE sample to modem.conf (new)
Makefile.am | 2 + drivers/stemodem/radio-settings.c | 225 +++++++++++++++++++++++++++++++++++++ drivers/stemodem/stemodem.c | 2 + drivers/stemodem/stemodem.h | 2 + plugins/modem.conf | 5 + plugins/modemconf.c | 1 + plugins/ste.c | 79 ++++++++++++- 7 files changed, 311 insertions(+), 5 deletions(-) create mode 100644 drivers/stemodem/radio-settings.c
PATCH v5 1/8 plugins/ste: SIM - STE registers as MBM to utilize mbm quirks.
---
Change: This time the right line is hopefully being edited.
plugins/ste.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
plugins/ste.c +1 -1
@@ -213,7 +213,7 @@ static void ste_pre_sim(struct ofono_modem *modem)DBG ("%p" , modem);ofono_devinfo_create (modem,0 ,"atmodem" , data->chat); - sim =ofono_sim_create (modem,0 ,"atmodem" , data->chat); + sim =ofono_sim_create (modem,OFONO_VENDOR_MBM ,"atmodem" , data->chat);ofono_voicecall_create (modem,0 ,"stemodem" , data->chat);if (sim)
Signature · 1 line
1.6.3.3
Re: [PATCH v5 1/8] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks.
Hi Sjur,
Quoted 5 lines
---
Change: This time the right line is hopefully being edited.plugins/ste.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
patch has been applied. Thanks.
Regards
Marcel
PATCH v5 2/8 stemodem: Add polling for SIM ready.
In reply to Sjur BrændelandInterim solution until support for SIM 'ready' notification is supported.
---
Change: AT-channel configuration is moved to separate patch.
plugins/ste.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 50 insertions(+), 2 deletions(-)
plugins/ste.c +50 -2
@@ -60,8 +60,13 @@#include <drivers/stemodem/caif_socket.h> #include <drivers/stemodem/if_caif.h> +static const char *cpin_prefix[] = {"+CPIN:" ,NULL }; +struct ste_data {GAtChat *chat; +guint cpin_poll_source; +guint cpin_poll_count; +gboolean have_sim; };static int ste_probe (struct ofono_modem *modem)
@@ -88,6 +93,10 @@ static void ste_remove(struct ofono_modem *modem)ofono_modem_set_data (modem,NULL );g_at_chat_unref (data->chat); + +if (data->cpin_poll_source >0 ) +g_source_remove (data->cpin_poll_source); +g_free (data); }
@@ -96,16 +105,55 @@ static void ste_debug(const char *str, void *user_data)ofono_info ("%s" , str); } +static gboolean init_simpin_check (gpointer user_data); + +static void simpin_check (gboolean ok,GAtResult *result,gpointer user_data) +{ +struct ofono_modem *modem = user_data; +struct ste_data *data =ofono_modem_get_data (modem); + +/* Modem returns +CME ERROR: 10 if SIM is not ready. */ +if (!ok && result->final_or_pdu && + !strcmp (result->final_or_pdu,"+CME ERROR: 10" ) && + data->cpin_poll_count++ <5 ) { + data->cpin_poll_source = +g_timeout_add_seconds (1 , init_simpin_check, modem); +return ; + } + + data->cpin_poll_count =0 ; + +/* Modem returns ERROR if there is no SIM in slot. */ + data->have_sim = ok; + +ofono_modem_set_powered (modem, TRUE); +} + +static gboolean init_simpin_check (gpointer user_data) +{ +struct ofono_modem *modem = user_data; +struct ste_data *data =ofono_modem_get_data (modem); + + data->cpin_poll_source =0 ; + +g_at_chat_send (data->chat,"AT+CPIN?" , cpin_prefix, + simpin_check, modem,NULL ); + +return FALSE; +} +static void cfun_enable (gboolean ok,GAtResult *result,gpointer user_data) {struct ofono_modem *modem = user_data;DBG ("" ); -if (!ok) +if (!ok) {ofono_modem_set_powered (modem, FALSE); +return ; + } -ofono_modem_set_powered (modem, TRUE); +init_simpin_check (modem); }static int ste_enable (struct ofono_modem *modem)
Signature · 1 line
1.6.3.3
Re: [PATCH v5 2/8] stemodem: Add polling for SIM ready.
Hi Sjur,
Quoted 6 lines
Interim solution until support for SIM 'ready' notification is supported.
---
Change: AT-channel configuration is moved to separate patch.plugins/ste.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 50 insertions(+), 2 deletions(-)
patch has been applied.
Denis, if you don't like it then feel free to revert it. For me it looked fine until we have better solution for this.
Regards
Marcel
PATCH v5 3/8 plugins/ste: Add AT Channel configurations
In reply to Sjur Brændeland--- plugins/ste.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
plugins/ste.c +2 -1
@@ -216,7 +216,8 @@ static int ste_enable(struct ofono_modem *modem)if (getenv ("OFONO_AT_DEBUG" ))g_at_chat_set_debug (data->chat, ste_debug,NULL ); -g_at_chat_send (data->chat,"ATE0 +CMEE=1" ,NULL ,NULL ,NULL ,NULL ); +g_at_chat_send (data->chat,"AT&F E0 V1 X4 &C1 +CMEE=1" , +NULL ,NULL ,NULL ,NULL );g_at_chat_send (data->chat,"AT+CFUN=1" ,NULL , cfun_enable, modem,NULL );return -EINPROGRESS ;
Signature · 1 line
1.6.3.3
Re: [PATCH v5 3/8] plugins/ste: Add AT Channel configurations
Hi Sjur,
Quoted 3 lines
--- plugins/ste.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
patch has been applied. Thanks.
Regards
Marcel
PATCH v5 4/7 stemodem: Add Radio Settings to STE Modem
In reply to Sjur Brændeland---
Changes:
o Changed order of files in Makefile
o Fixed missing empty line in copyright
o Formatted enum better
o Removed default is switches
o Removed ste in function names
Makefile.am | 2 + drivers/stemodem/radio-settings.c | 230 +++++++++++++++++++++++++++++++++++++ drivers/stemodem/stemodem.c | 2 + drivers/stemodem/stemodem.h | 2 + 4 files changed, 236 insertions(+), 0 deletions(-) create mode 100644 drivers/stemodem/radio-settings.c
Makefile.am +2 -0
@@ -202,10 +202,12 @@ builtin_sources += drivers/atmodem/atutil.h \ drivers/stemodem/stemodem.h \ drivers/stemodem/stemodem.c \ drivers/stemodem/voicecall.c \ + drivers/stemodem/radio-settings.c \ drivers/stemodem/gprs-context.c \ drivers/stemodem/caif_socket.h \ drivers/stemodem/if_caif.h + builtin_modules += phonesim builtin_sources += plugins/phonesim.c
drivers/stemodem/radio-settings.c new file +230 -0
230 lines not on this page · raw message
drivers/stemodem/stemodem.c +2 -0
@@ -38,6 +38,7 @@ static int stemodem_init(void) {ste_voicecall_init ();ste_gprs_context_init (); +ste_radio_settings_init ();return 0 ; }
@@ -46,6 +47,7 @@ static void stemodem_exit(void) {ste_voicecall_exit ();ste_gprs_context_exit (); +ste_radio_settings_exit (); } OFONO_PLUGIN_DEFINE(stemodem, "STE modem driver", VERSION,
drivers/stemodem/stemodem.h +2 -0
@@ -28,3 +28,5 @@ extern void ste_gprs_context_exit();extern void ste_voicecall_init ();extern void ste_voicecall_exit (); +extern void ste_radio_settings_init (); +extern void ste_radio_settings_exit ();
Signature · 1 line
1.6.3.3
Re: [PATCH v5 4/7] stemodem: Add Radio Settings to STE Modem
Hi Sjur,
Quoted 8 lines
---
Changes:
o Changed order of files inMakefile
o Fixed missing empty line in copyright
o Formatted enum better
o Removed default is switches
o Removed ste in function names
Quoted 6 lines
Makefile.am | 2 + drivers/stemodem/radio-settings.c | 230 +++++++++++++++++++++++++++++++++++++ drivers/stemodem/stemodem.c | 2 + drivers/stemodem/stemodem.h | 2 + 4 files changed, 236 insertions(+), 0 deletions(-) create mode 100644 drivers/stemodem/radio-settings.c
patch has been applied.
Quoted 4 lines
Makefile.am +0
-0@@ -202,10 +202,12 @@ builtin_sources += drivers/atmodem/atutil.h \ drivers/stemodem/stemodem.h \
Makefile.am builtin_sources += drivers/atmodem/atutil.h \ · line 212
Quoted 10 lines
Makefile.am +2
-0drivers/stemodem/stemodem.c \ drivers/stemodem/voicecall.c \ + drivers/stemodem/radio-settings.c \ drivers/stemodem/gprs-context.c \ drivers/stemodem/caif_socket.h \ drivers/stemodem/if_caif.h + builtin_modules += phonesim builtin_sources += plugins/phonesim.c
I fixed this for you, but in the future, please don't add extra unneeded empty lines.
Regards
Marcel
PATCH v5 5/8 plugins/ste: Add Radio-Settings
In reply to Sjur Brændeland--- drivers/stemodem/radio-settings.c | 5 +++++ plugins/ste.c | 2 ++ 2 files changed, 7 insertions(+), 0 deletions(-)
plugins/ste.c +2 -0
@@ -54,6 +54,7 @@#include <ofono/voicecall.h> #include <ofono/gprs.h> #include <ofono/gprs-context.h> +#include <ofono/radio-settings.h> #include <ofono/stk.h> #include <drivers/atmodem/vendor.h>
@@ -279,6 +280,7 @@ static void ste_post_sim(struct ofono_modem *modem)DBG ("%p" , modem);ofono_stk_create (modem,0 ,"mbmmodem" , data->chat); +ofono_radio_settings_create (modem,0 ,"stemodem" , data->chat);ofono_ussd_create (modem,0 ,"atmodem" , data->chat);ofono_call_forwarding_create (modem,0 ,"atmodem" , data->chat);ofono_call_settings_create (modem,0 ,"atmodem" , data->chat);
Signature · 1 line
1.6.3.3
Re: [PATCH v5 5/8] plugins/ste: Add Radio-Settings
Hi Sjur,
Quoted 4 lines
--- drivers/stemodem/radio-settings.c | 5 +++++ plugins/ste.c | 2 ++ 2 files changed, 7 insertions(+), 0 deletions(-)
your diffstat is wrong here. Please check the tools you use to create them.
Patch has been applied.
Regards
Marcel
PATCH v5 6/8 plugins/modemconf.c add support for Interface for STE plugin.
In reply to Sjur Brændeland--- plugins/modemconf.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
plugins/modemconf.c +1 -0
@@ -138,6 +138,7 @@ static struct { { "g1", set_device }, { "wavecom", set_device }, { "ste", set_device }, + { "ste", set_interface }, { "calypso", set_device }, { "palmpre", set_device }, { "isimodem", set_interface },
Signature · 1 line
1.6.3.3
Re: [PATCH v5 6/8] plugins/modemconf.c add support for Interface for STE plugin.
Hi Sjur,
Quoted 8 lines
plugins/modemconf.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)plugins/modemconf.c +0
-0
plugins/modemconf.c static struct { · line 144
Quoted 7 lines
plugins/modemconf.c +1
-0@@ -138,6 +138,7 @@ static struct { { "g1", set_device }, { "wavecom", set_device }, { "ste", set_device }, + { "ste", set_interface }, { "calypso", set_device }, { "palmpre", set_device }, { "isimodem", set_interface },
I applied this patch, but keep in mind that modemconf will go away pretty soon.
Regards
Marcel
PATCH v5 7/8 plugins/ste: Use SOCK_STREAM for CAIF and enable interface specification.
In reply to Sjur Brændeland--- plugins/ste.c | 20 +++++++++++++++++++- 1 files changed, 19 insertions(+), 1 deletions(-)
plugins/ste.c +19 -1
@@ -30,6 +30,7 @@#include <stdlib.h> #include <string.h> #include <unistd.h> +#include <net/if.h> #include <glib.h> #include <gatchat.h>
@@ -171,14 +172,31 @@ static int ste_enable(struct ofono_modem *modem)if (!device) {struct sockaddr_caif addr;int err; +const char *interface;/* Create a CAIF socket for AT Service */ - fd =socket (AF_CAIF ,SOCK_SEQPACKET ,CAIFPROTO_AT ); + fd =socket (AF_CAIF ,SOCK_STREAM ,CAIFPROTO_AT );if (fd <0 ) {ofono_error ("Failed to create CAIF socket for AT" );return -EIO ; } +/* Bind CAIF socket to specified interface */ + interface =ofono_modem_get_string (modem,"Interface" ); +if (interface) { +struct ifreq ifreq; +memset (&ifreq,0 ,sizeof (ifreq)); +strcpy (ifreq.ifr_name, interface); + err =setsockopt (fd,SOL_SOCKET , +SO_BINDTODEVICE , &ifreq,sizeof (ifreq)); +if (err <0 ) { +ofono_error ("Failed to bind caif socket " +"to interface" ); +close (fd); +return err; + } + } +memset (&addr,0 ,sizeof (addr)); addr.family =AF_CAIF ; addr.u.at.type =CAIF_ATTYPE_PLAIN ;
Signature · 1 line
1.6.3.3
Re: [PATCH v5 7/8] plugins/ste: Use SOCK_STREAM for CAIF and enable interface specification.
Hi Sjur,
Quoted 3 lines
--- plugins/ste.c | 20 +++++++++++++++++++- 1 files changed, 19 insertions(+), 1 deletions(-)
patch has been applied. Thanks.
Regards
Marcel
PATCH v5 8/8 plugins: Add STE sample to modem.conf
In reply to Sjur Brændeland--- plugins/modem.conf | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
plugins/modem.conf +5 -0
@@ -44,3 +44,8 @@ #[n900] #Driver=n900modem #Interface=phonet0 + +# Sample STE modem +#[ste] +#Interface=cfttyS0 +#Driver=ste
Signature · 1 line
1.6.3.3
Re: [PATCH v5 8/8] plugins: Add STE sample to modem.conf
Hi Sjur,
Quoted 2 lines
plugins/modem.conf | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
patch has been applied. Thanks.
Regards
Marcel