GPRS context setup and teardown (doc/dataconnectionmanager-api.txt)
RFC 1/1 GPRS context setup and teardown (doc/dataconnectionmanager-api.txt)
Hi,
here's a one-big-patch that adds the DataConnectionManager interface according to doc/dataconnectionmanager-api.txt without any glue for the multiplexer or PPP setup. Only AT backend is implemented.
One issue with the AT implementation of the api is that "Powered" (a read-write property) can be set independently of "Attached" (read-only property) and remain set when "Attached" is clear. The semantics would be that the network doesn't have resources to let the modem attach, but the modem waits for the resources to become available and then attaches. On AT the modem is in this state only when executing +CGATT, so currently the code will rerun +CGATT as soon as the previous one returns with error, probably starving other commands. A possible workaround would be for "Powered" to flip back to False after the modem fails to attach once, or give up on having separate properties. Alternatively we could re-try to attach periodically but on one modem I've tried +CGATT fails after about 1 minute (that's the Calypso) and on another only about 0.5s (Nokia phones with AT emulation).
When "Powered" is set and "RoamingAllowed" is clear and we manage to attach and find that we're roaming, ofono resets "Powered".
We may want to catch the user trying to dial *99***1# which is the backwards compatibility quirk for old modems (same way ofono parses USSD strings).
--- Makefile.am | 12 +- doc/dataconnectionmanager-api.txt | 2 +- drivers/atmodem/atmodem.c | 2 + drivers/atmodem/atmodem.h | 3 + drivers/atmodem/data-connection.c | 649 ++++++++++++++++++++++ include/data-connection.h | 89 +++ include/types.h | 10 + plugins/phonesim.c | 3 + src/data-connection.c | 1074 +++++++++++++++++++++++++++++++++++++ src/ofono.h | 2 + 10 files changed, 1841 insertions(+), 5 deletions(-) create mode 100644 drivers/atmodem/data-connection.c create mode 100644 include/data-connection.h create mode 100644 src/data-connection.c
Makefile.am +8 -4
@@ -10,7 +10,8 @@ include_HEADERS = include/log.h include/plugin.h include/history.h \ include/phonebook.h include/ssn.h include/ussd.h \ include/sms.h include/sim.h include/message-waiting.h \ include/netreg.h include/voicecall.h include/devinfo.h \ - include/cbs.h include/call-volume.h + include/cbs.h include/call-volume.h \ + include/data-connection.h nodist_include_HEADERS = include/version.h
@@ -108,7 +109,8 @@ builtin_sources += $(gatchat_sources) \ drivers/atmodem/call-volume.c \ drivers/atmodem/vendor.h \ drivers/atmodem/atutil.h \ - drivers/atmodem/atutil.c + drivers/atmodem/atutil.c \ + drivers/atmodem/data-connection.c builtin_modules += calypsomodem builtin_sources += drivers/atmodem/atutil.h \
@@ -165,7 +167,8 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) \ src/ssn.c src/call-barring.c src/sim.c \ src/phonebook.c src/history.c src/message-waiting.c \ src/simutil.h src/simutil.c src/storage.h \ - src/storage.c src/cbs.c src/watch.c src/call-volume.c + src/storage.c src/cbs.c src/watch.c src/call-volume.c \ + src/data-connection.c src_ofonod_LDADD = $(builtin_libadd) \ @GLIB_LIBS@ @GTHREAD_LIBS@ @DBUS_LIBS@ -ldl
@@ -197,7 +200,8 @@ doc_files = doc/overview.txt doc/ofono-paper.txt \ doc/manager-api.txt doc/modem-api.txt doc/network-api.txt \ doc/voicecallmanager-api.txt doc/voicecall-api.txt \ doc/call-forwarding-api.txt doc/call-settings-api.txt \ - doc/call-meter-api.txt + doc/call-meter-api.txt \ + doc/dataconnectionmanager-api.txt test_files = test/test-manager test/test-modem test/test-voicecall \ test/test-network-registration test/test-phonebook \
doc/dataconnectionmanager-api.txt +1 -1
@@ -42,7 +42,7 @@ Signals PropertyChanged(string property, variant value) Properties array{object} PrimaryContexts [readonly] - List of all primary contexts objects. + List of all primary context objects. boolean Attached [readonly]
drivers/atmodem/atmodem.c +2 -0
@@ -48,6 +48,7 @@ static int atmodem_init(void)at_netreg_init ();at_cbs_init ();at_call_volume_init (); +at_data_connection_init ();return 0 ; }
@@ -68,6 +69,7 @@ static void atmodem_exit(void)at_voicecall_exit ();at_cbs_exit ();at_call_volume_exit (); +at_data_connection_exit (); } OFONO_PLUGIN_DEFINE(atmodem, "AT modem driver", VERSION,
drivers/atmodem/atmodem.h +3 -0
@@ -62,3 +62,6 @@ extern void at_cbs_exit();extern void at_call_volume_init ();extern void at_call_volume_exit (); + +extern void at_data_connection_init (); +extern void at_data_connection_exit ();
drivers/atmodem/data-connection.c new file +649 -0
649 lines not on this page · raw message
include/data-connection.h new file +89 -0
89 lines not on this page · raw message
include/types.h +10 -0
@@ -91,6 +91,16 @@ struct ofono_call {int clip_validity; }; +struct ofono_data_context { +unsigned id; +int type; +int direction; +int active; +char *apn; +char *username; +char *password; +}; + #ifdef __cplusplus }#endif
plugins/phonesim.c +3 -0
@@ -54,6 +54,7 @@#include <ofono/ssn.h> #include <ofono/ussd.h> #include <ofono/voicecall.h> +#include <ofono/data-connection.h> #include <drivers/atmodem/vendor.h>
@@ -285,6 +286,8 @@ static void phonesim_post_sim(struct ofono_modem *modem)ofono_cbs_create (modem,0 ,"atmodem" , data->chat); } +ofono_data_connection_create (modem,0 ,"atmodem" , data->chat); + mw =ofono_message_waiting_create (modem);if (mw)ofono_message_waiting_register (mw);
src/data-connection.c new file +1074 -0
1,074 lines not on this page · raw message
src/ofono.h +2 -0
@@ -106,6 +106,7 @@ enum ofono_atom_type {OFONO_ATOM_TYPE_MESSAGE_WAITING =13 ,OFONO_ATOM_TYPE_CBS =14 ,OFONO_ATOM_TYPES_CALL_VOLUME =15 , + OFONO_ATOM_TYPE_DATA_CONNECTION = 16, }; enum ofono_atom_watch_condition {
@@ -160,6 +161,7 @@ void __ofono_atom_free(struct ofono_atom *atom);#include <ofono/sms.h> #include <ofono/sim.h> #include <ofono/voicecall.h> +#include <ofono/data-connection.h> #include <ofono/ssn.h>
Signature · 1 line
1.6.1
2009/10/12 Andrzej Zaborowski <[email protected]>:
Quoted 3 lines
here's a one-big-patch that adds the DataConnectionManager interface according to
doc/dataconnectionmanager-api.txtwithout any glue for the multiplexer or PPP setup. Only AT backend is implemented.
This patch depends on 0001 attached, other patches are small independent changes that I had in queue.
Regards
From 6bdfef650f64766f13abaa4b6538d7facdebd6f3 Mon Sep 17 00:00:00 2001
From: Andrzej Zaborowski <[email protected]>
Date: Mon, 12 Oct 2009 22:37:14 +0200
Subject: [PATCH 1/5] Move network registration status to string functions to common.c
so that they can be used in data connection related network registration code.
--- src/common.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/common.h | 3 +++ src/network.c | 44 -------------------------------------------- 3 files changed, 47 insertions(+), 44 deletions(-)
src/common.c +44 -0
@@ -597,3 +597,47 @@ gboolean is_valid_pin(const char *pin)return TRUE; } + +const char *registration_status_to_string (int status) +{ +switch (status) { +case NETWORK_REGISTRATION_STATUS_NOT_REGISTERED : +return "unregistered" ; +case NETWORK_REGISTRATION_STATUS_REGISTERED : +return "registered" ; +case NETWORK_REGISTRATION_STATUS_SEARCHING : +return "searching" ; +case NETWORK_REGISTRATION_STATUS_DENIED : +return "denied" ; +case NETWORK_REGISTRATION_STATUS_UNKNOWN : +return "unknown" ; +case NETWORK_REGISTRATION_STATUS_ROAMING : +return "roaming" ; + } + +return "" ; +} + +const char *registration_tech_to_string (int tech) +{ +switch (tech) { +case ACCESS_TECHNOLOGY_GSM : +return "GSM" ; +case ACCESS_TECHNOLOGY_GSM_COMPACT : +return "GSMCompact" ; +case ACCESS_TECHNOLOGY_UTRAN : +return "UTRAN" ; +case ACCESS_TECHNOLOGY_GSM_EGPRS : +return "GSM+EGPRS" ; +case ACCESS_TECHNOLOGY_UTRAN_HSDPA : +return "UTRAN+HSDPA" ; +case ACCESS_TECHNOLOGY_UTRAN_HSUPA : +return "UTRAN+HSUPA" ; +case ACCESS_TECHNOLOGY_UTRAN_HSDPA_HSUPA : +return "UTRAN+HSDPA+HSUPA" ; +case ACCESS_TECHNOLOGY_EUTRAN : +return "EUTRAN" ; +default : +return "" ; + } +}
src/common.h +3 -0
@@ -135,3 +135,6 @@ const char *ss_control_type_to_string(enum ss_control_type type);const char *bearer_class_to_string (enum bearer_class cls);gboolean is_valid_pin (const char *pin); + +const char *registration_status_to_string (int status); +const char *registration_tech_to_string (int tech);
src/network.c +0 -44
50 lines not on this page · raw message
Signature · 1 line
1.6.1
From 73938e4e1005672b99f92995c26a5ff41a01d656 Mon Sep 17 00:00:00 2001
From: Andrzej Zaborowski <[email protected]>
Date: Mon, 12 Oct 2009 22:39:47 +0200
Subject: [PATCH 2/5] Always return a string from telephony_error_to_str.
So that it can be used as a printf argument directly.
--- src/common.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
src/common.c +2 -2
@@ -280,14 +280,14 @@ const char *telephony_error_to_str(const struct ofono_error *error) maxentries =sizeof (ceer_errors) /sizeof (struct error_entry );break ;default : -return 0 ; +return "Unknown error type" ; }for (i =0 ; i < maxentries; i++)if (e[i].error == error->error)return e[i].str; -return 0 ; +return "Unknown error" ; }int mmi_service_code_to_bearer_class (int code)
Signature · 1 line
1.6.1
From 3f771555079fa77045596fa1bc2b516970a43290 Mon Sep 17 00:00:00 2001
From: Andrzej Zaborowski <[email protected]>
Date: Mon, 12 Oct 2009 22:41:35 +0200
Subject: [PATCH 3/5] Emit debug message instead of an error when SMS storage is empty on init.
--- drivers/atmodem/sms.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/atmodem/sms.c +1 -1
@@ -548,7 +548,7 @@ static void at_cmgl_cb(gboolean ok, GAtResult *result, gpointer user_data)struct ofono_sms *sms = user_data;if (!ok) -ofono_error ("Initial listing SMS storage failed!" ); +ofono_debug ("Initial listing SMS storage failed!" );at_cmgl_done (sms); }
Signature · 1 line
1.6.1
From fc0cb192de7cb0f622aa9e6d6879865de2fe169b Mon Sep 17 00:00:00 2001
From: Andrzej Zaborowski <[email protected]>
Date: Mon, 12 Oct 2009 22:43:04 +0200
Subject: [PATCH 4/5] Don't crash on sms messages containing only UDH.
--- src/smsutil.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
src/smsutil.c +3 -0
@@ -2133,6 +2133,9 @@ char *sms_decode_text(GSList *sms_list) udl_in_bytes =sms_udl_in_bytes (udl, dcs); +if (udl_in_bytes == taken) +continue ; +if (charset ==SMS_CHARSET_7BIT ) {unsigned char buf[160 ];long written;
Signature · 1 line
1.6.1
Hi Andrew,
Quoted 7 lines
2009/10/12 Andrzej Zaborowski <[email protected]>:
Quoted 3 lines
here's a one-big-patch that adds the DataConnectionManager interface according to
doc/dataconnectionmanager-api.txtwithout any glue for the multiplexer or PPP setup. Only AT backend is implemented.This patch depends on 0001 attached, other patches are small independent changes that I had in queue.
I applied all four small patches. Still reviewing the big patch :)
Regards,
-Denis
Hi Andrew,
Quoted 4 lines
Hi,
here's a one-big-patch that adds the DataConnectionManager interface according todoc/dataconnectionmanager-api.txtwithout any glue for the multiplexer or PPP setup. Only AT backend is implemented.
Ok, so I took the patch and hacked on it for a while. I disagreed with how you split up responsibilities, so much of the logic got moved into the core and the driver was simplified. Some parts might have been lost along the way.
I also decided to split up GPRS into two atoms to ease integration of hardware that supports dedicated network interfaces. This way the attach / GPRS network registration parameters can be reused from the generic 'atmodem' driver, while specific context handling can be customized.
I'm happy to report that this actually sort of works with my MBM card. I can even define a GPRS context and activate it. Of course the card crashes as soon as I do :)
Quoted 14 lines
One issue with the AT implementation of the api is that "Powered" (a read-write property) can be set independently of "Attached" (read-only property) and remain set when "Attached" is clear. The semantics would be that the network doesn't have resources to let the modem attach, but the modem waits for the resources to become available and then attaches. On AT the modem is in this state only when executing +CGATT, so currently the code will rerun +CGATT as soon as the previous one returns with error, probably starving other commands. A possible workaround would be for "Powered" to flip back to False after the modem fails to attach once, or give up on having separate properties. Alternatively we could re-try to attach periodically but on one modem I've tried +CGATT fails after about 1 minute (that's the Calypso) and on another only about 0.5s (Nokia phones with AT emulation).
We should probably do both with some intelligence. Right now we lose GPRS registration when we run an operator scan (the modem turns off GPRS automagically), so running CGATT afterwards is OK. But then we should do it in increasing timeouts. E.g. 5 seconds, 10 seconds, etc and turn off entirely once we have given up.
I don't think this is necessary, all voice dial strings are suffixed by ';', so dialing *99***1#; should result in an error.
Some parts I still don't understand:
in set_registration_status:
attached = (status != NETWORK_REGISTRATION_STATUS_REGISTERED &&
status != NETWORK_REGISTRATION_STATUS_ROAMING);
if (gprs->attached != (int) attached &&
!(gprs->flags & GPRS_FLAG_ATTACHING)) {
gprs->attached = (int) attached;
ofono_dbus_signal_property_changed(conn, path,
DATA_CONNECTION_MANAGER_INTERFACE,
"Attached", DBUS_TYPE_BOOLEAN,
&attached);
gprs_netreg_update(gprs);
}I do not understand this logic at all. Can't we always call gprs_netreg_update here? In my opinion Attached should only be emitted once it really has changed (e.g. in the callback)
gprs_netreg_update:
/* Prevent further attempts to attach */
if (!attach && gprs->powered) {
gprs->powered = 0;
path = __ofono_atom_get_path(gprs->atom);
ofono_dbus_signal_property_changed(conn, path,
DATA_CONNECTION_MANAGER_INTERFACE,
"Powered", DBUS_TYPE_BOOLEAN, &value);
}This is just too evil. Can't we set another flag that attached conditions have changed while we were attaching/detaching and that we should recheck those conditions when we return from attach/detach?
In gprs_set_property:
You should really ignore set property requests that set the value to the already set value. Simply return success and don't do anything else.
Regards,
-Denis
Hi,
2009/10/24 Denis Kenzior <[email protected]>:
Quoted 3 lines
Ok, so I took the patch and hacked on it for a while. I disagreed with how you split up responsibilities, so much of the logic got moved into the core and the driver was simplified.
Yes, there were a couple of possible choices, I chose to align with how the list of voice calls was managed in voicecall.c .
Quoted 5 lines
I also decided to split up GPRS into two atoms to ease integration of hardware that supports dedicated network interfaces. This way the attach / GPRS network registration parameters can be reused from the generic 'atmodem' driver, while specific context handling can be customized.
That's a good idea.
Quoted 4 lines
I'm happy to report that this actually sort of works with my MBM card. I can even define a GPRS context and activate it. Of course the card crashes as soon as I do :)
I'm happy to report it still works on my Nokia phone, too, except for one test: when you have active contexts and either tell ofono to power gprs down or are detached by the network for whatever reason, ".active" is never reset and no event emitted, meaning that you can't remove the context, can't re-activate it or deactivate it.
Quoted 15 lines
Some parts I still don't understand:
in
set_registration_status:
attached = (status !=NETWORK_REGISTRATION_STATUS_REGISTERED&& status !=NETWORK_REGISTRATION_STATUS_ROAMING); if (gprs->attached!= (int) attached && !(gprs->flags &GPRS_FLAG_ATTACHING)) {gprs->attached= (int) attached;ofono_dbus_signal_property_changed(conn, path,
DATA_CONNECTION_MANAGER_INTERFACE, "Attached",DBUS_TYPE_BOOLEAN, &attached);
Quoted 5 lines
gprs_netreg_update(gprs);
}I do not understand this logic at all. Can't we always call
gprs_netreg_updatehere?
Sure, but it won't do anything, if either "attached" state hasn't changed at all or it's already busy executing +CGATT.
Quoted 2 lines
In my opinion Attached should only be emitted once it really has changed (e.g. in the callback)
Often there's no other notification telling us that we were detached, so we must take any sign of it into account (it might be broken modems but I've seen such situations on both modems that I've tested it with)
Quoted 12 lines
gprs_netreg_update:
/* Prevent further attempts to attach */ if (!attach &&gprs->powered) {gprs->powered= 0;path =
__ofono_atom_get_path(gprs->atom);ofono_dbus_signal_property_changed(conn, path, DATA_CONNECTION_MANAGER_INTERFACE, "Powered", DBUS_TYPE_BOOLEAN, &value); }
Quoted 3 lines
This is just too evil. Can't we set another flag that attached conditions have changed while we were attaching/detaching and that we should recheck those conditions when we return from attach/detach?
Is it evil because we change a property that is writable?
This is only for the case of RoamingAllowed = 0. In my understanding "Powered" being set means that we're attached or attempting to attach, which is not the case after we detached because of roaming, so the D-Bus client would be misled.
Quoted 5 lines
In
gprs_set_property:You should really ignore set property requests that set the value to the already set value. Simply return success and don't do anything else.
Good point, the attached patch checks for those cases.
Best regards
From 6d4439fc701ca49ad88149833ac2f4b6d68ba4f3 Mon Sep 17 00:00:00 2001
From: Andrzej Zaborowski <[email protected]>
Date: Sat, 24 Oct 2009 11:27:23 +0200
Subject: [PATCH 1/2] Just return success when value already set in SetProperty.
--- src/gprs.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
src/gprs.c +6 -0
@@ -661,6 +661,9 @@ static DBusMessage *gprs_set_property(DBusConnection *conn,dbus_message_iter_get_basic (&var, &value); +if (gprs->roaming_allowed == (ofono_bool_t ) value) +return dbus_message_new_method_return (msg); + gprs->roaming_allowed = value;gprs_netreg_update (gprs); }else if (!strcmp (property,"Powered" )) {
@@ -672,6 +675,9 @@ static DBusMessage *gprs_set_property(DBusConnection *conn,dbus_message_iter_get_basic (&var, &value); +if (gprs->powered == (ofono_bool_t ) value) +return dbus_message_new_method_return (msg); + gprs->powered = value;gprs_netreg_update (gprs); }else
Signature · 1 line
1.6.1
From e9498d070f3593c1ef5c27b91f59ca8e2be971ad Mon Sep 17 00:00:00 2001
From: Andrzej Zaborowski <[email protected]>
Date: Sat, 24 Oct 2009 11:28:07 +0200
Subject: [PATCH 2/2] Register gprs-context on calypso modem/phonesim.
--- plugins/phonesim.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-)
plugins/phonesim.c +8 -1
@@ -55,6 +55,7 @@#include <ofono/ussd.h> #include <ofono/voicecall.h> #include <ofono/gprs.h> +#include <ofono/gprs-context.h> #include <drivers/atmodem/vendor.h>
@@ -289,6 +290,8 @@ static void phonesim_post_sim(struct ofono_modem *modem) {struct phonesim_data *data =ofono_modem_get_data (modem);struct ofono_message_waiting *mw; +struct ofono_gprs *gprs; +struct ofono_gprs_context *gc;DBG ("%p" , modem);
@@ -313,7 +316,11 @@ static void phonesim_post_sim(struct ofono_modem *modem)ofono_cbs_create (modem,0 ,"atmodem" , data->chat); } -ofono_gprs_create (modem,0 ,"atmodem" , data->chat); + gprs =ofono_gprs_create (modem,0 ,"atmodem" , data->chat); + gc =ofono_gprs_context_create (modem,0 ,"atmodem" , data->chat); + +if (gprs && gc) +ofono_gprs_add_context (gprs, gc); mw =ofono_message_waiting_create (modem);if (mw)
Signature · 1 line
1.6.1
2009/10/24 andrzej zaborowski <[email protected]>:
Quoted 4 lines
2009/10/24 Denis Kenzior <[email protected]>:
Quoted 3 lines
Ok, so I took the patch and hacked on it for a while. I disagreed with how you split up responsibilities, so much of the logic got moved into the core and the driver was simplified.
By the way I notice that in most atoms' _create functions, when we loop over the drivers
and call drv->probe() until we succeed, we still return success even if none of the drivers succeeded, should we return a NULL?
Regards
Hi Andrew,
Quoted 10 lines
2009/10/24 andrzej zaborowski <[email protected]>:
Quoted 4 lines
2009/10/24 Denis Kenzior <[email protected]>:
Quoted 3 lines
Ok, so I took the patch and hacked on it for a while. I disagreed with how you split up responsibilities, so much of the logic got moved into the core and the driver was simplified.
By the way I notice that in most atoms'
_createfunctions, when we loop over the drivers
and calldrv->probe()until we succeed, we still return success even if none of the drivers succeeded, should we return a NULL?
I think my intention was to eventually have foo_driver_register functions also go through the probe process. Without the driver the atoms are never registered, so the way it is now is OK for now.
Regards,
-Denis
Hi Andrew,
Quoted 12 lines
Quoted 12 lines
in
set_registration_status:attached = (status != NETWORK_REGISTRATION_STATUS_REGISTERED && status != NETWORK_REGISTRATION_STATUS_ROAMING); if (gprs->attached != (int) attached && !(gprs->flags & GPRS_FLAG_ATTACHING)) { gprs->attached = (int) attached; ofono_dbus_signal_property_changed(conn, path, DATA_CONNECTION_MANAGER_INTERFACE, "Attached", DBUS_TYPE_BOOLEAN, &attached);
Quoted 8 lines
Quoted 5 lines
gprs_netreg_update(gprs); }I do not understand this logic at all. Can't we always call
gprs_netreg_updatehere?Sure, but it won't do anything, if either "attached" state hasn't changed at all or it's already busy executing +CGATT.
So the issue here is that I can actually understand what gprs_netreg_update does. This function I'm having trouble with.
Lets suppose status=registered arrives and we're already attached. Here attached will be set to FALSE, Attached property will be set to false and emitted. gprs_netreg_update will presumably reset Attached back to True. Why do this for a potentially spurious indication? Remember your status might be indicated when just the network access technology has changed.
Another case. We're detached (Powered=True, RoamingAllowed=False) and are currently Roaming. Then status=searching arrives. We report Attached as True.
Am I properly outlining the logic or am I missing something? Again, explain the intention here. Either way, the current logic is way too complicated and needs to be simplified.
Quoted 7 lines
Quoted 3 lines
In my opinion Attached should only be emitted once it really has changed (e.g. in the callback)
Often there's no other notification telling us that we were detached, so we must take any sign of it into account (it might be broken modems but I've seen such situations on both modems that I've tested it with)
For situations where we are forcefully detached and/or go into a non- registered state, the core should take care of this. If it is a modem not reporting this properly, then I'd argue this is something the driver needs to take care of. If the core starts trying to guess / outwit every single broken hardware out there it will be unmaintainable. Lets at least try to keep the core clean and only responsible for the things mandated by the relevant standards.
Quoted 12 lines
Quoted 12 lines
gprs_netreg_update:/* Prevent further attempts to attach */ if (!attach && gprs->powered) { gprs->powered = 0; path = __ofono_atom_get_path(gprs->atom); ofono_dbus_signal_property_changed(conn, path, DATA_CONNECTION_MANAGER_INTERFACE, "Powered", DBUS_TYPE_BOOLEAN,&value); }
Quoted 5 lines
Quoted 3 lines
This is just too evil. Can't we set another flag that attached conditions have changed while we were attaching/detaching and that we should recheck those conditions when we return from attach/detach?
Is it evil because we change a property that is writable?
Yes, and also because this is a hack :)
Quoted 3 lines
This is only for the case of RoamingAllowed = 0. In my understanding "Powered" being set means that we're attached or attempting to attach,
No, Powered means GPRS is on assuming all conditions are fulfilled (e.g. registration, roaming, network resources) This is a user setting that will be persisted (in IMSI based storage.) It should not be spuriously changed by the daemon.
Quoted 2 lines
which is not the case after we detached because of roaming, so the D-Bus client would be misled.
No, 'Attached' is what is used for this purpose.
Both patches have been applied. Thanks!
Regards,
-Denis
Hi,
2009/10/24 Denis Kenzior <[email protected]>:
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
in
set_registration_status:
attached = (status !=NETWORK_REGISTRATION_STATUS_REGISTERED&& status !=NETWORK_REGISTRATION_STATUS_ROAMING); if (gprs->attached!= (int) attached && !(gprs->flags &GPRS_FLAG_ATTACHING)) {gprs->attached= (int) attached;Quoted 7 lines
Quoted 7 lines
ofono_dbus_signal_property_changed(conn, path,
DATA_CONNECTION_MANAGER_INTERFACE, "Attached",DBUS_TYPE_BOOLEAN, &attached);gprs_netreg_update(gprs);
}
Quoted 6 lines
So the issue here is that I can actually understand what
gprs_netreg_updatedoes. This function I'm having trouble with.Lets suppose status=registered arrives and we're already attached. Here attached will be set to FALSE, Attached property will be set to false and emitted. gprs_netreg_update will presumably reset Attached back to True.
Now I see it and you're absolutely right to be alerted, I set "attached" to the reverse of what it should be set to. We're attached when we're either in REGISTERED or ROAMING state. If I had done it right then the logic would look simple (I suppose):
If either we already knew that we were in that state then there's nothing to do. Otherwise we set the D-Bus property to reflect current state and call gprs_netreg_update to figure out if this is the state we really wanted to be in.
If the notification indicates we were detached we will also need to reset all current contexts to inactive here, originally I did this in the driver.
Quoted 21 lines
Quoted 12 lines
Quoted 12 lines
gprs_netreg_update:
/* Prevent further attempts to attach */ if (!attach &&gprs->powered) {gprs->powered= 0;path =
__ofono_atom_get_path(gprs->atom);ofono_dbus_signal_property_changed(conn, path, DATA_CONNECTION_MANAGER_INTERFACE, "Powered", DBUS_TYPE_BOOLEAN, &value); }Quoted 5 lines
Quoted 3 lines
This is just too evil. Can't we set another flag that attached conditions have changed while we were attaching/detaching and that we should recheck those conditions when we return from attach/detach?
Is it evil because we change a property that is writable?
Yes, and also because this is a hack :)
Quoted 1 line
Quoted 7 lines
Quoted 2 lines
This is only for the case of RoamingAllowed = 0. In my understanding "Powered" being set means that we're attached or attempting to attach,
No, Powered means GPRS is on assuming all conditions are fulfilled (e.g. registration, roaming, network resources) This is a user setting that will be persisted (in IMSI based storage.) It should not be spuriously changed by the daemon.
This is a policy question, what do we do when the user disallowed roaming but the modem wants to roam? If we decide that we will not retry to attach until the user pokes us again then "Powered" really should be reset to false because even if the conditions you listed are met we still won't attach. Maybe instead we should do the retries with increasing timeouts like you mentioned in another message, and then "Powered" should stay set.
An unrelated thing: you keep the allowed cid range in the core and only remember the min and max cid. However I think (but don't know where to check for it) that +CGDCONT=? is free to return (1,2) instead of (1-2), or even (1-2,5-6,13). Other AT commands do return ranges with this syntax.
Regards
Hi,
Quoted 8 lines
Quoted 3 lines
Lets suppose status=registered arrives and we're already attached. Here attached will be set to FALSE, Attached property will be set to false and emitted.
gprs_netreg_updatewill presumably reset Attached back to True.Now I see it and you're absolutely right to be alerted, I set "attached" to the reverse of what it should be set to. We're attached when we're either in REGISTERED or ROAMING state. If I had done it right then the logic would look simple (I suppose):
I still don't believe that it works. Suppose we're attached and registered. Now we get an indication that we're in 'searching' state. set attach to true, compare with stored value (true). Ah, don't do anything -> not good.
You also emit a signal that outright lies as to the current state. Suppose we're registered and just the cellid / lac / technology changes. This function still gets triggered and does a funky dance of emitting signals and calling into the driver to attach / detach.
Quoted 5 lines
If either we already knew that we were in that state then there's nothing to do. Otherwise we set the D-Bus property to reflect current state and call
gprs_netreg_updateto figure out if this is the state we really wanted to be in.
This part is fine, but lets make it easy to understand, e.g. do all of this inside gprs_netreg_update.
Quoted 4 lines
If the notification indicates we were detached we will also need to reset all current contexts to inactive here, originally I did this in the driver.
Yes, this is one of the parts I forgot to port over :(
Quoted 7 lines
This is a policy question, what do we do when the user disallowed roaming but the modem wants to roam? If we decide that we will not retry to attach until the user pokes us again then "Powered" really should be reset to false because even if the conditions you listed are met we still won't attach. Maybe instead we should do the retries with increasing timeouts like you mentioned in another message, and then "Powered" should stay set.
Resetting Powered in the core leads to strange situations where after coming from an overseas trip you'd need to reset Powered back to on. I would find that annoying.
The nice thing is I don't think we need to play the attach/detach dance. We can take advantage of the netreg atom's information. If we're roaming there, we will be roaming on GPRS as well. If we're registered there, then we should try to attach.
Quoted 6 lines
An unrelated thing: you keep the allowed cid range in the core and only remember the min and max cid. However I think (but don't know where to check for it) that +CGDCONT=? is free to return (1,2) instead of (1-2), or even (1-2,5-6,13). Other AT commands do return ranges with this syntax.
You're absolutely correct that the syntax allows this. My decision here was mostly a matter of prudence. I doubt any device actually uses a non- contiguous cid range. If/once we do find one that does, we can add a new set_sparse_range function (or something) in the core to take care of it.
Regards,
-Denis
2009/10/25 Denis Kenzior <[email protected]>:
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Lets suppose status=registered arrives and we're already attached. Here attached will be set to FALSE, Attached property will be set to false and emitted. gprs_netreg_update will presumably reset Attached back to True.
Quoted 8 lines
Quoted 4 lines
Now I see it and you're absolutely right to be alerted, I set "attached" to the reverse of what it should be set to. We're attached when we're either in REGISTERED or ROAMING state. If I had done it right then the logic would look simple (I suppose):
I still don't believe that it works. Suppose we're attached and registered. Now we get an indication that we're in 'searching' state. set attach to true, compare with stored value (true). Ah, don't do anything -> not good.
I tried to say that I agree that current code is wrong, but assuming the variable "attached" was set correctly, this would not happen (see attached patch).
Now that I think of it if the current status is 'searching' then possibly there's no point calling driver->set_attached (see second patch).
Quoted 8 lines
Resetting Powered in the core leads to strange situations where after coming from an overseas trip you'd need to reset Powered back to on. I would find that annoying.
The nice thing is I don't think we need to play the attach/detach dance. We can take advantage of the netreg atom's information. If we're roaming there, we will be roaming on GPRS as well. If we're registered there, then we should try to attach.
That's a great idea, I will send a patch separately.
Regards
From 03f9b38d6ae5d98bcfb46c3f636b791e018b6515 Mon Sep 17 00:00:00 2001
From: Andrzej Zaborowski <[email protected]>
Date: Sun, 25 Oct 2009 09:14:54 +0100
Subject: [PATCH 1/2] Fix interpretation of new GPRS registration status signal.
--- src/gprs.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
src/gprs.c +2 -2
@@ -882,8 +882,8 @@ static void set_registration_status(struct ofono_gprs *gprs, int status)"Status" ,DBUS_TYPE_STRING , &str_status); - attached = (status !=NETWORK_REGISTRATION_STATUS_REGISTERED && - status !=NETWORK_REGISTRATION_STATUS_ROAMING ); + attached = (status ==NETWORK_REGISTRATION_STATUS_REGISTERED || + status ==NETWORK_REGISTRATION_STATUS_ROAMING );if (gprs->attached != (int ) attached && !(gprs->flags &GPRS_FLAG_ATTACHING )) { gprs->attached = (int ) attached;
Signature · 1 line
1.6.1
From d0f0331ea8d3f8c4df75069cfca082bb99ce0dfa Mon Sep 17 00:00:00 2001
From: Andrzej Zaborowski <[email protected]>
Date: Sun, 25 Oct 2009 09:35:26 +0100
Subject: [PATCH 2/2] Don't ask driver to attach GPRS if modem is already searching for operator.
--- src/gprs.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
src/gprs.c +5 -3
@@ -543,7 +543,9 @@ static void gprs_netreg_update(struct ofono_gprs *gprs) attach = gprs->powered && operator_ok;if (gprs->attached != attach && - !(gprs->flags &GPRS_FLAG_ATTACHING )) { + !(gprs->flags &GPRS_FLAG_ATTACHING ) && + !(attach && gprs->status != +NETWORK_REGISTRATION_STATUS_SEARCHING )) { gprs->flags |=GPRS_FLAG_ATTACHING ; gprs->driver->set_attached(gprs, attach, gprs_attach_callback,
@@ -892,9 +894,9 @@ static void set_registration_status(struct ofono_gprs *gprs, int status)DATA_CONNECTION_MANAGER_INTERFACE ,"Attached" ,DBUS_TYPE_BOOLEAN , &attached); - -gprs_netreg_update (gprs); } + +gprs_netreg_update (gprs); } static void set_registration_location(struct ofono_gprs *gprs,
Signature · 1 line
1.6.1
2009/10/25 andrzej zaborowski <[email protected]>:
Quoted 3 lines
Now that I think of it if the current status is 'searching' then possibly there's no point calling
driver->set_attached(see second patch).
I repeated the same typo in this patch, attached is a corrected version, sorry.
Regards
From d0f0331ea8d3f8c4df75069cfca082bb99ce0dfa Mon Sep 17 00:00:00 2001
From: Andrzej Zaborowski <[email protected]>
Date: Sun, 25 Oct 2009 09:35:26 +0100
Subject: [PATCH 2/2] Don't ask driver to attach GPRS if modem is already searching for operator.
--- src/gprs.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
src/gprs.c +5 -3
@@ -543,7 +543,9 @@ static void gprs_netreg_update(struct ofono_gprs *gprs) attach = gprs->powered && operator_ok;if (gprs->attached != attach && - !(gprs->flags &GPRS_FLAG_ATTACHING )) { + !(gprs->flags &GPRS_FLAG_ATTACHING ) && + !(attach && gprs->status == +NETWORK_REGISTRATION_STATUS_SEARCHING )) { gprs->flags |=GPRS_FLAG_ATTACHING ; gprs->driver->set_attached(gprs, attach, gprs_attach_callback,
@@ -892,9 +894,9 @@ static void set_registration_status(struct ofono_gprs *gprs, int status)DATA_CONNECTION_MANAGER_INTERFACE ,"Attached" ,DBUS_TYPE_BOOLEAN , &attached); - -gprs_netreg_update (gprs); } + +gprs_netreg_update (gprs); } static void set_registration_location(struct ofono_gprs *gprs,
Signature · 1 line
1.6.1