Open Source Telephony
 help / color / mirror / Atom feed
* [PATCH v2 1/3] radio-settings: add frequency band selection methods
@ 2010-12-02  1:55 Lucas De Marchi
  2010-12-02  1:55 ` [PATCH v2 2/3] radio-settings: add frequency band selection properties Lucas De Marchi
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Lucas De Marchi @ 2010-12-02  1:55 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 2283 bytes --]

---
 include/radio-settings.h |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/include/radio-settings.h b/include/radio-settings.h
index 45e88e7..6c99278 100644
--- a/include/radio-settings.h
+++ b/include/radio-settings.h
@@ -35,6 +35,24 @@ enum ofono_radio_access_mode {
 	OFONO_RADIO_ACCESS_MODE_LTE	= 3,
 };
 
+enum ofono_radio_band_gsm {
+	OFONO_RADIO_BAND_GSM_ANY,
+	OFONO_RADIO_BAND_GSM_850,
+	OFONO_RADIO_BAND_GSM_900P,
+	OFONO_RADIO_BAND_GSM_900E,
+	OFONO_RADIO_BAND_GSM_1800,
+	OFONO_RADIO_BAND_GSM_1900,
+};
+
+enum ofono_radio_band_umts {
+	OFONO_RADIO_BAND_UMTS_ANY,
+	OFONO_RADIO_BAND_UMTS_850,
+	OFONO_RADIO_BAND_UMTS_900,
+	OFONO_RADIO_BAND_UMTS_1700AWS,
+	OFONO_RADIO_BAND_UMTS_1900,
+	OFONO_RADIO_BAND_UMTS_2100,
+};
+
 struct ofono_radio_settings;
 
 typedef void (*ofono_radio_settings_rat_mode_set_cb_t)(const struct ofono_error *error,
@@ -43,6 +61,13 @@ typedef void (*ofono_radio_settings_rat_mode_query_cb_t)(const struct ofono_erro
 						enum ofono_radio_access_mode mode,
 						void *data);
 
+typedef void (*ofono_radio_settings_band_set_cb_t)(const struct ofono_error *error,
+							void *data);
+typedef void (*ofono_radio_settings_band_query_cb_t)(const struct ofono_error *error,
+						enum ofono_radio_band_gsm band_gsm,
+						enum ofono_radio_band_umts band_umts,
+						void *data);
+
 typedef void (*ofono_radio_settings_fast_dormancy_set_cb_t)(const struct ofono_error *error,
 							void *data);
 typedef void (*ofono_radio_settings_fast_dormancy_query_cb_t)(const struct ofono_error *error,
@@ -61,6 +86,14 @@ struct ofono_radio_settings_driver {
 				enum ofono_radio_access_mode mode,
 				ofono_radio_settings_rat_mode_set_cb_t cb,
 				void *data);
+	void (*query_band)(struct ofono_radio_settings *rs,
+				ofono_radio_settings_band_query_cb_t cb,
+				void *data);
+	void (*set_band)(struct ofono_radio_settings *rs,
+				enum ofono_radio_band_gsm band_gsm,
+				enum ofono_radio_band_umts band_umts,
+				ofono_radio_settings_band_set_cb_t cb,
+				void *data);
 	void (*query_fast_dormancy)(struct ofono_radio_settings *rs,
 			ofono_radio_settings_fast_dormancy_query_cb_t cb,
 			void *data);
-- 
1.7.3.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/3] radio-settings: add frequency band selection properties
  2010-12-02  1:55 [PATCH v2 1/3] radio-settings: add frequency band selection methods Lucas De Marchi
@ 2010-12-02  1:55 ` Lucas De Marchi
  2010-12-08 17:40   ` Denis Kenzior
  2010-12-02  1:55 ` [PATCH v2 3/3] doc: document frequency band selection Lucas De Marchi
  2010-12-08 17:40 ` [PATCH v2 1/3] radio-settings: add frequency band selection methods Denis Kenzior
  2 siblings, 1 reply; 6+ messages in thread
From: Lucas De Marchi @ 2010-12-02  1:55 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 8907 bytes --]

---
 src/radio-settings.c |  250 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 248 insertions(+), 2 deletions(-)

diff --git a/src/radio-settings.c b/src/radio-settings.c
index ff6934b..51158ef 100644
--- a/src/radio-settings.c
+++ b/src/radio-settings.c
@@ -41,8 +41,12 @@ struct ofono_radio_settings {
 	DBusMessage *pending;
 	int flags;
 	enum ofono_radio_access_mode mode;
-	enum ofono_radio_access_mode pending_mode;
+	enum ofono_radio_band_gsm band_gsm;
+	enum ofono_radio_band_umts band_umts;
 	ofono_bool_t fast_dormancy;
+	enum ofono_radio_access_mode pending_mode;
+	enum ofono_radio_band_gsm pending_band_gsm;
+	enum ofono_radio_band_umts pending_band_umts;
 	ofono_bool_t fast_dormancy_pending;
 	const struct ofono_radio_settings_driver *driver;
 	void *driver_data;
@@ -86,6 +90,100 @@ static gboolean radio_access_mode_from_string(const char *str,
 	return FALSE;
 }
 
+static const char *radio_band_gsm_to_string(enum ofono_radio_band_gsm band)
+{
+	switch (band) {
+	case OFONO_RADIO_BAND_GSM_ANY:
+		return "any";
+	case OFONO_RADIO_BAND_GSM_850:
+		return "850";
+	case OFONO_RADIO_BAND_GSM_900P:
+		return "900P";
+	case OFONO_RADIO_BAND_GSM_900E:
+		return "900E";
+	case OFONO_RADIO_BAND_GSM_1800:
+		return "1800";
+	case OFONO_RADIO_BAND_GSM_1900:
+		return "1900";
+	}
+
+	return "";
+}
+
+static gboolean radio_band_gsm_from_string(const char *str,
+						enum ofono_radio_band_gsm *band)
+
+{
+	if (g_str_equal(str, "any")) {
+		*band = OFONO_RADIO_BAND_GSM_ANY;
+		return TRUE;
+	} else if (g_str_equal(str, "850")) {
+		*band = OFONO_RADIO_BAND_GSM_850;
+		return TRUE;
+	} else if (g_str_equal(str, "900P")) {
+		*band = OFONO_RADIO_BAND_GSM_900P;
+		return TRUE;
+	} else if (g_str_equal(str, "900E")) {
+		*band = OFONO_RADIO_BAND_GSM_900E;
+		return TRUE;
+	} else if (g_str_equal(str, "1800")) {
+		*band = OFONO_RADIO_BAND_GSM_1800;
+		return TRUE;
+	} else if (g_str_equal(str, "1900")) {
+		*band = OFONO_RADIO_BAND_GSM_1900;
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
+static const char *radio_band_umts_to_string(enum ofono_radio_band_umts band)
+{
+	switch (band) {
+	case OFONO_RADIO_BAND_UMTS_ANY:
+		return "any";
+	case OFONO_RADIO_BAND_UMTS_850:
+		return "850";
+	case OFONO_RADIO_BAND_UMTS_900:
+		return "900";
+	case OFONO_RADIO_BAND_UMTS_1700AWS:
+		return "1700AWS";
+	case OFONO_RADIO_BAND_UMTS_1900:
+		return "1900";
+	case OFONO_RADIO_BAND_UMTS_2100:
+		return "2100";
+	}
+
+	return "";
+}
+
+static gboolean radio_band_umts_from_string(const char *str,
+						enum ofono_radio_band_umts *band)
+
+{
+	if (g_str_equal(str, "any")) {
+		*band = OFONO_RADIO_BAND_GSM_ANY;
+		return TRUE;
+	} else if (g_str_equal(str, "850")) {
+		*band = OFONO_RADIO_BAND_UMTS_850;
+		return TRUE;
+	} else if (g_str_equal(str, "900")) {
+		*band = OFONO_RADIO_BAND_UMTS_900;
+		return TRUE;
+	} else if (g_str_equal(str, "1700AWS")) {
+		*band = OFONO_RADIO_BAND_UMTS_1700AWS;
+		return TRUE;
+	} else if (g_str_equal(str, "1900")) {
+		*band = OFONO_RADIO_BAND_UMTS_1900;
+		return TRUE;
+	} else if (g_str_equal(str, "2100")) {
+		*band = OFONO_RADIO_BAND_UMTS_2100;
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
 static DBusMessage *radio_get_properties_reply(DBusMessage *msg,
 						struct ofono_radio_settings *rs)
 {
@@ -108,6 +206,18 @@ static DBusMessage *radio_get_properties_reply(DBusMessage *msg,
 	ofono_dbus_dict_append(&dict, "TechnologyPreference",
 					DBUS_TYPE_STRING, &mode);
 
+	if (rs->driver->query_band) {
+		const char *band = radio_band_gsm_to_string(rs->band_gsm);
+
+		ofono_dbus_dict_append(&dict, "GsmBand",
+					DBUS_TYPE_STRING, &band);
+
+		band = radio_band_umts_to_string(rs->band_umts);
+
+		ofono_dbus_dict_append(&dict, "UmtsBand",
+					DBUS_TYPE_STRING, &band);
+	}
+
 	if (rs->driver->query_fast_dormancy) {
 		dbus_bool_t value = rs->fast_dormancy;
 		ofono_dbus_dict_append(&dict, "FastDormancy",
@@ -159,6 +269,60 @@ static void radio_fast_dormancy_set_callback(const struct ofono_error *error,
 	radio_set_fast_dormancy(rs, rs->fast_dormancy_pending);
 }
 
+static void radio_set_band(struct ofono_radio_settings *rs)
+{
+	DBusConnection *conn = ofono_dbus_get_connection();
+	const char *path;
+	const char *str_band;
+
+	path = __ofono_atom_get_path(rs->atom);
+
+	if (rs->band_gsm != rs->pending_band_gsm) {
+		rs->band_gsm = rs->pending_band_gsm;
+		str_band = radio_band_gsm_to_string(rs->band_gsm);
+
+		ofono_dbus_signal_property_changed(conn, path,
+						OFONO_RADIO_SETTINGS_INTERFACE,
+						"GsmBand", DBUS_TYPE_STRING,
+						&str_band);
+	}
+
+	if (rs->band_umts != rs->pending_band_umts) {
+		rs->band_umts = rs->pending_band_umts;
+		str_band = radio_band_umts_to_string(rs->band_umts);
+
+		ofono_dbus_signal_property_changed(conn, path,
+						OFONO_RADIO_SETTINGS_INTERFACE,
+						"UmtsBand", DBUS_TYPE_STRING,
+						&str_band);
+	}
+
+}
+
+static void radio_band_set_callback(const struct ofono_error *error,
+					void *data)
+{
+	struct ofono_radio_settings *rs = data;
+	DBusMessage *reply;
+
+	if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+		DBG("Error setting radio frequency band");
+
+		rs->pending_band_gsm = rs->band_gsm;
+		rs->pending_band_umts = rs->band_umts;
+
+		reply = __ofono_error_failed(rs->pending);
+		__ofono_dbus_pending_reply(&rs->pending, reply);
+
+		return;
+	}
+
+	reply = dbus_message_new_method_return(rs->pending);
+	__ofono_dbus_pending_reply(&rs->pending, reply);
+
+	radio_set_band(rs);
+}
+
 static void radio_set_rat_mode(struct ofono_radio_settings *rs,
 				enum ofono_radio_access_mode mode)
 {
@@ -242,6 +406,40 @@ static void radio_query_fast_dormancy(struct ofono_radio_settings *rs)
 					rs);
 }
 
+static void radio_band_query_callback(const struct ofono_error *error,
+					enum ofono_radio_band_gsm band_gsm,
+					enum ofono_radio_band_umts band_umts,
+					void *data)
+{
+	struct ofono_radio_settings *rs = data;
+	DBusMessage *reply;
+
+	if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+		DBG("Error during radio frequency band query");
+
+		reply = __ofono_error_failed(rs->pending);
+		__ofono_dbus_pending_reply(&rs->pending, reply);
+
+		return;
+	}
+
+	rs->pending_band_gsm = band_gsm;
+	rs->pending_band_umts = band_umts;
+
+	radio_set_band(rs);
+	radio_query_fast_dormancy(rs);
+}
+
+static void radio_query_band(struct ofono_radio_settings *rs)
+{
+	if (!rs->driver->query_band) {
+		radio_query_fast_dormancy(rs);
+		return;
+	}
+
+	rs->driver->query_band(rs, radio_band_query_callback, rs);
+}
+
 static void radio_rat_mode_query_callback(const struct ofono_error *error,
 					enum ofono_radio_access_mode mode,
 					void *data)
@@ -259,7 +457,7 @@ static void radio_rat_mode_query_callback(const struct ofono_error *error,
 	}
 
 	radio_set_rat_mode(rs, mode);
-	radio_query_fast_dormancy(rs);
+	radio_query_band(rs);
 }
 
 static DBusMessage *radio_get_properties(DBusConnection *conn,
@@ -330,6 +528,54 @@ static DBusMessage *radio_set_property(DBusConnection *conn, DBusMessage *msg,
 		rs->driver->set_rat_mode(rs, mode, radio_mode_set_callback, rs);
 
 		return NULL;
+	} else if (g_strcmp0(property, "GsmBand") == 0) {
+		const char *value;
+		enum ofono_radio_band_gsm band;
+
+		if (!rs->driver->set_band)
+			return __ofono_error_not_implemented(msg);
+
+		if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_STRING)
+			return __ofono_error_invalid_args(msg);
+
+		dbus_message_iter_get_basic(&var, &value);
+		if (radio_band_gsm_from_string(value, &band) == FALSE)
+			return __ofono_error_invalid_args(msg);
+
+		if (rs->band_gsm == band)
+			return dbus_message_new_method_return(msg);
+
+		rs->pending = dbus_message_ref(msg);
+		rs->pending_band_gsm = band;
+
+		rs->driver->set_band(rs, band, rs->band_umts,
+					radio_band_set_callback, rs);
+
+		return NULL;
+	} else if (g_strcmp0(property, "UmtsBand") == 0) {
+		const char *value;
+		enum ofono_radio_band_umts band;
+
+		if (!rs->driver->set_band)
+			return __ofono_error_not_implemented(msg);
+
+		if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_STRING)
+			return __ofono_error_invalid_args(msg);
+
+		dbus_message_iter_get_basic(&var, &value);
+		if (radio_band_umts_from_string(value, &band) == FALSE)
+			return __ofono_error_invalid_args(msg);
+
+		if (rs->band_umts == band)
+			return dbus_message_new_method_return(msg);
+
+		rs->pending = dbus_message_ref(msg);
+		rs->pending_band_umts = band;
+
+		rs->driver->set_band(rs, rs->band_gsm, band,
+					radio_band_set_callback, rs);
+
+		return NULL;
 	} else if (g_strcmp0(property, "FastDormancy") == 0) {
 		dbus_bool_t value;
 		int target;
-- 
1.7.3.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 3/3] doc: document frequency band selection
  2010-12-02  1:55 [PATCH v2 1/3] radio-settings: add frequency band selection methods Lucas De Marchi
  2010-12-02  1:55 ` [PATCH v2 2/3] radio-settings: add frequency band selection properties Lucas De Marchi
@ 2010-12-02  1:55 ` Lucas De Marchi
  2010-12-08 17:40   ` Denis Kenzior
  2010-12-08 17:40 ` [PATCH v2 1/3] radio-settings: add frequency band selection methods Denis Kenzior
  2 siblings, 1 reply; 6+ messages in thread
From: Lucas De Marchi @ 2010-12-02  1:55 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 2114 bytes --]

---
 doc/radio-settings-api.txt |   43 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/doc/radio-settings-api.txt b/doc/radio-settings-api.txt
index e073d1d..216f534 100644
--- a/doc/radio-settings-api.txt
+++ b/doc/radio-settings-api.txt
@@ -46,6 +46,49 @@ Properties	string TechnologyPreference [readwrite]
 				"umts"	Only UMTS used for radio access.
 				"lte"	Only LTE used for radio acccess.
 
+		string GsmBand [readwrite, optional]
+
+			Frequency band in which the modem is allowed to
+			operate when using "gsm" mode. Setting this property
+			has an imediate effect on modem only if
+			TechnologyPreference is set to "gsm".  Otherwise the
+			value is kept and applied whenever modem uses
+			this mode.
+
+			The possible values are:
+				"any"	Frequency band is selected
+					automatically by modem.
+				"850"	Operate only on 850 MHz.
+				"900P"	Operate only on 900 MHz, known as
+					Primary GSM-900 Band
+				"900E"	Operate only on 900 MHz, known as
+					Extended GSM-900 Band.
+				"1800"	Operate only on 1800 MHz, known as DCS.
+				"1900"	Operate only on 1900 MHz, known as PCS.
+
+		string UmtsBand [readwrite, optional]
+
+			Frequency band in which the modem is allowed to
+			operate when using "umts" mode. Setting this property
+			has an imediate effect on modem only if
+			TechnologyPreference is set to "umts".  Otherwise the
+			value is kept and applied whenever modem uses
+			this mode.
+
+			The possible values are:
+				"any"		Frequency band is selected
+						automatically by modem.
+				"850"		Operate only on 850 MHz, known
+						as CLR (class V).
+				"900"		Operate only on 900 MHz, known
+						as GSM (class VII).
+				"1700AWS"	Operate only on 1700 MHz, known
+						as AWS (class IV).
+				"1900"		Operate only on 1900 MHz, known
+						as PCS (class II).
+				"2100"		Operate only on 2100 MHz, known
+						as IMT (class I).
+
 		boolean	FastDormancy [readwrite, optional]
 
 			This property will enable or disable the fast
-- 
1.7.3.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/3] radio-settings: add frequency band selection methods
  2010-12-02  1:55 [PATCH v2 1/3] radio-settings: add frequency band selection methods Lucas De Marchi
  2010-12-02  1:55 ` [PATCH v2 2/3] radio-settings: add frequency band selection properties Lucas De Marchi
  2010-12-02  1:55 ` [PATCH v2 3/3] doc: document frequency band selection Lucas De Marchi
@ 2010-12-08 17:40 ` Denis Kenzior
  2 siblings, 0 replies; 6+ messages in thread
From: Denis Kenzior @ 2010-12-08 17:40 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 251 bytes --]

Hi Lucas,

On 12/01/2010 07:55 PM, Lucas De Marchi wrote:
> ---
>  include/radio-settings.h |   33 +++++++++++++++++++++++++++++++++
>  1 files changed, 33 insertions(+), 0 deletions(-)
> 

Patch has been applied, thanks.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/3] radio-settings: add frequency band selection properties
  2010-12-02  1:55 ` [PATCH v2 2/3] radio-settings: add frequency band selection properties Lucas De Marchi
@ 2010-12-08 17:40   ` Denis Kenzior
  0 siblings, 0 replies; 6+ messages in thread
From: Denis Kenzior @ 2010-12-08 17:40 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 265 bytes --]

Hi Lucas,

On 12/01/2010 07:55 PM, Lucas De Marchi wrote:
> ---
>  src/radio-settings.c |  250 +++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 files changed, 248 insertions(+), 2 deletions(-)
> 

Patch has been applied, thanks.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 3/3] doc: document frequency band selection
  2010-12-02  1:55 ` [PATCH v2 3/3] doc: document frequency band selection Lucas De Marchi
@ 2010-12-08 17:40   ` Denis Kenzior
  0 siblings, 0 replies; 6+ messages in thread
From: Denis Kenzior @ 2010-12-08 17:40 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 263 bytes --]

Hi Lucas,

On 12/01/2010 07:55 PM, Lucas De Marchi wrote:
> ---
>  doc/radio-settings-api.txt |   43 +++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 43 insertions(+), 0 deletions(-)
> 

Patch has been applied, thanks.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-12-08 17:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-02  1:55 [PATCH v2 1/3] radio-settings: add frequency band selection methods Lucas De Marchi
2010-12-02  1:55 ` [PATCH v2 2/3] radio-settings: add frequency band selection properties Lucas De Marchi
2010-12-08 17:40   ` Denis Kenzior
2010-12-02  1:55 ` [PATCH v2 3/3] doc: document frequency band selection Lucas De Marchi
2010-12-08 17:40   ` Denis Kenzior
2010-12-08 17:40 ` [PATCH v2 1/3] radio-settings: add frequency band selection methods Denis Kenzior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox