option/hso: implement solicited access technology request
This commit is contained in:
@@ -682,6 +682,14 @@ set_allowed_mode (MMGenericGsm *gsm,
|
|||||||
option_set_allowed_mode (gsm, mode, callback, user_data);
|
option_set_allowed_mode (gsm, mode, callback, user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
get_access_technology (MMGenericGsm *gsm,
|
||||||
|
MMModemUIntFn callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
option_get_access_technology (gsm, callback, user_data);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -808,5 +816,6 @@ mm_modem_hso_class_init (MMModemHsoClass *klass)
|
|||||||
gsm_class->do_enable_power_up_done = real_do_enable_power_up_done;
|
gsm_class->do_enable_power_up_done = real_do_enable_power_up_done;
|
||||||
gsm_class->set_allowed_mode = set_allowed_mode;
|
gsm_class->set_allowed_mode = set_allowed_mode;
|
||||||
gsm_class->get_allowed_mode = get_allowed_mode;
|
gsm_class->get_allowed_mode = get_allowed_mode;
|
||||||
|
gsm_class->get_access_technology = get_access_technology;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -179,41 +179,58 @@ owcti_to_mm (char owcti, MMModemGsmAccessTech *out_act)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
octi_request_done (MMAtSerialPort *port,
|
parse_octi_response (GString *response, MMModemGsmAccessTech *act)
|
||||||
GString *response,
|
|
||||||
GError *error,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
{
|
||||||
|
MMModemGsmAccessTech cur_act = MM_MODEM_GSM_ACCESS_TECH_UNKNOWN;
|
||||||
const char *p;
|
const char *p;
|
||||||
MMModemGsmAccessTech act = MM_MODEM_GSM_ACCESS_TECH_UNKNOWN;
|
|
||||||
GRegex *r;
|
GRegex *r;
|
||||||
GMatchInfo *match_info;
|
GMatchInfo *match_info;
|
||||||
char *str;
|
char *str;
|
||||||
|
gboolean success = FALSE;
|
||||||
|
|
||||||
|
g_return_val_if_fail (act != NULL, FALSE);
|
||||||
|
g_return_val_if_fail (response != NULL, FALSE);
|
||||||
|
|
||||||
|
p = mm_strip_tag (response->str, "_OCTI:");
|
||||||
|
|
||||||
|
r = g_regex_new ("(\\d),(\\d)", G_REGEX_UNGREEDY, 0, NULL);
|
||||||
|
g_return_val_if_fail (r != NULL, FALSE);
|
||||||
|
|
||||||
|
g_regex_match (r, p, 0, &match_info);
|
||||||
|
if (g_match_info_matches (match_info)) {
|
||||||
|
str = g_match_info_fetch (match_info, 2);
|
||||||
|
if (str && octi_to_mm (str[0], &cur_act)) {
|
||||||
|
*act = cur_act;
|
||||||
|
success = TRUE;
|
||||||
|
}
|
||||||
|
g_free (str);
|
||||||
|
}
|
||||||
|
g_match_info_free (match_info);
|
||||||
|
g_regex_unref (r);
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ossys_octi_request_done (MMAtSerialPort *port,
|
||||||
|
GString *response,
|
||||||
|
GError *error,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
MMModemGsmAccessTech act = MM_MODEM_GSM_ACCESS_TECH_UNKNOWN;
|
||||||
|
|
||||||
if (!error) {
|
if (!error) {
|
||||||
p = mm_strip_tag (response->str, "_OCTI:");
|
if (parse_octi_response (response, &act))
|
||||||
|
mm_generic_gsm_update_access_technology (MM_GENERIC_GSM (user_data), act);
|
||||||
r = g_regex_new ("(\\d),(\\d)", G_REGEX_UNGREEDY, 0, NULL);
|
|
||||||
g_return_if_fail (r != NULL);
|
|
||||||
|
|
||||||
g_regex_match (r, p, 0, &match_info);
|
|
||||||
if (g_match_info_matches (match_info)) {
|
|
||||||
str = g_match_info_fetch (match_info, 2);
|
|
||||||
if (str && octi_to_mm (str[0], &act))
|
|
||||||
mm_generic_gsm_update_access_technology (MM_GENERIC_GSM (user_data), act);
|
|
||||||
g_free (str);
|
|
||||||
}
|
|
||||||
g_match_info_free (match_info);
|
|
||||||
g_regex_unref (r);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
owcti_request_done (MMAtSerialPort *port,
|
ossys_owcti_request_done (MMAtSerialPort *port,
|
||||||
GString *response,
|
GString *response,
|
||||||
GError *error,
|
GError *error,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
const char *p;
|
const char *p;
|
||||||
MMModemGsmAccessTech act = MM_MODEM_GSM_ACCESS_TECH_UNKNOWN;
|
MMModemGsmAccessTech act = MM_MODEM_GSM_ACCESS_TECH_UNKNOWN;
|
||||||
@@ -254,9 +271,9 @@ option_ossys_tech_changed (MMAtSerialPort *port,
|
|||||||
* access technology requests.
|
* access technology requests.
|
||||||
*/
|
*/
|
||||||
if (act == MM_MODEM_GSM_ACCESS_TECH_GPRS)
|
if (act == MM_MODEM_GSM_ACCESS_TECH_GPRS)
|
||||||
mm_at_serial_port_queue_command (port, "AT_OCTI?", 3, octi_request_done, user_data);
|
mm_at_serial_port_queue_command (port, "_OCTI?", 3, ossys_octi_request_done, user_data);
|
||||||
else if (act == MM_MODEM_GSM_ACCESS_TECH_UMTS)
|
else if (act == MM_MODEM_GSM_ACCESS_TECH_UMTS)
|
||||||
mm_at_serial_port_queue_command (port, "AT_OWCTI?", 3, owcti_request_done, user_data);
|
mm_at_serial_port_queue_command (port, "_OWCTI?", 3, ossys_owcti_request_done, user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -367,3 +384,68 @@ option_change_unsolicited_messages (MMGenericGsm *modem,
|
|||||||
mm_at_serial_port_queue_command (primary, enabled ? "_OSQI=1" : "_OSQI=0", 3, unsolicited_msg_done, info);
|
mm_at_serial_port_queue_command (primary, enabled ? "_OSQI=1" : "_OSQI=0", 3, unsolicited_msg_done, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
get_act_octi_request_done (MMAtSerialPort *port,
|
||||||
|
GString *response,
|
||||||
|
GError *error,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
MMCallbackInfo *info = user_data;
|
||||||
|
MMModemGsmAccessTech octi = MM_MODEM_GSM_ACCESS_TECH_UNKNOWN;
|
||||||
|
MMModemGsmAccessTech owcti;
|
||||||
|
|
||||||
|
if (!error) {
|
||||||
|
if (parse_octi_response (response, &octi)) {
|
||||||
|
/* If no 3G tech yet or current tech isn't 3G, then 2G tech is the best */
|
||||||
|
owcti = GPOINTER_TO_UINT (mm_callback_info_get_data (info, "owcti"));
|
||||||
|
if (octi && !owcti)
|
||||||
|
mm_callback_info_set_result (info, GUINT_TO_POINTER (octi), NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mm_callback_info_chain_complete_one (info);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
get_act_owcti_request_done (MMAtSerialPort *port,
|
||||||
|
GString *response,
|
||||||
|
GError *error,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
MMCallbackInfo *info = user_data;
|
||||||
|
MMModemGsmAccessTech owcti = MM_MODEM_GSM_ACCESS_TECH_UNKNOWN;
|
||||||
|
const char *p;
|
||||||
|
|
||||||
|
if (!error) {
|
||||||
|
p = mm_strip_tag (response->str, "_OWCTI:");
|
||||||
|
if (owcti_to_mm (*p, &owcti)) {
|
||||||
|
/* 3G tech always takes precedence over 2G tech */
|
||||||
|
if (owcti)
|
||||||
|
mm_callback_info_set_result (info, GUINT_TO_POINTER (owcti), NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mm_callback_info_chain_complete_one (info);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
option_get_access_technology (MMGenericGsm *modem,
|
||||||
|
MMModemUIntFn callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
MMAtSerialPort *port;
|
||||||
|
MMCallbackInfo *info;
|
||||||
|
|
||||||
|
info = mm_callback_info_uint_new (MM_MODEM (modem), callback, user_data);
|
||||||
|
mm_callback_info_chain_start (info, 2);
|
||||||
|
|
||||||
|
port = mm_generic_gsm_get_best_at_port (modem, &info->error);
|
||||||
|
if (!port) {
|
||||||
|
mm_callback_info_schedule (info);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mm_at_serial_port_queue_command (port, "_OCTI?", 3, get_act_octi_request_done, info);
|
||||||
|
mm_at_serial_port_queue_command (port, "_OWCTI?", 3, get_act_owcti_request_done, info);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -113,6 +113,14 @@ set_allowed_mode (MMGenericGsm *gsm,
|
|||||||
option_set_allowed_mode (gsm, mode, callback, user_data);
|
option_set_allowed_mode (gsm, mode, callback, user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
get_access_technology (MMGenericGsm *gsm,
|
||||||
|
MMModemUIntFn callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
option_get_access_technology (gsm, callback, user_data);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -221,5 +229,6 @@ mm_modem_option_class_init (MMModemOptionClass *klass)
|
|||||||
gsm_class->do_enable_power_up_done = real_do_enable_power_up_done;
|
gsm_class->do_enable_power_up_done = real_do_enable_power_up_done;
|
||||||
gsm_class->set_allowed_mode = set_allowed_mode;
|
gsm_class->set_allowed_mode = set_allowed_mode;
|
||||||
gsm_class->get_allowed_mode = get_allowed_mode;
|
gsm_class->get_allowed_mode = get_allowed_mode;
|
||||||
|
gsm_class->get_access_technology = get_access_technology;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user