diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2018-12-24 16:09:06 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2019-01-30 12:10:03 +0100 |
commit | c3f4fe063f59a706bec35fab3839f9f873420c75 (patch) | |
tree | 59942d1001d472a1a785db5fae79df5fd726a23d /plugins/ublox/mm-modem-helpers-ublox.c | |
parent | f2e3798bb328aac2d27896274d4737c314caf257 (diff) |
ublox: rework support config loading
Make mm_ublox_get_support_config() return FALSE only when GError is
set. And also, prepare a preload_support_config() method to be run
before using any information from the support configuration (i.e.
don't do it in load_supported_bands(), do it in load_current_bands()
or in set_current_bands().
Diffstat (limited to 'plugins/ublox/mm-modem-helpers-ublox.c')
-rw-r--r-- | plugins/ublox/mm-modem-helpers-ublox.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/plugins/ublox/mm-modem-helpers-ublox.c b/plugins/ublox/mm-modem-helpers-ublox.c index 1fc598bf..702992b3 100644 --- a/plugins/ublox/mm-modem-helpers-ublox.c +++ b/plugins/ublox/mm-modem-helpers-ublox.c @@ -926,30 +926,32 @@ static const BandConfiguration band_configuration[] = { }, }; -/* Returns AT command support configuration */ - -gboolean mm_ublox_get_support_config (const gchar *model, - UbloxSupportConfig *config, - GError **error) +gboolean +mm_ublox_get_support_config (const gchar *model, + UbloxSupportConfig *config, + GError **error) { guint i; - if (model) { - for (i = 0; i < G_N_ELEMENTS (band_configuration); i++) - if (g_str_has_prefix (model, band_configuration[i].model)) { - config->method = band_configuration[i].method; - config->uact = band_configuration[i].uact; - config->ubandsel = band_configuration[i].ubandsel; - return TRUE; - } - } - - if (i == G_N_ELEMENTS (band_configuration) || !(model)) { + if (!model) { g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, - "Unknown support found for modem: %s", model); + "Support configuration unknown for unknown model"); return FALSE; } - + + for (i = 0; i < G_N_ELEMENTS (band_configuration); i++) { + /* NOTE: matching by prefix! */ + if (g_str_has_prefix (model, band_configuration[i].model)) { + config->loaded = TRUE; + config->method = band_configuration[i].method; + config->uact = band_configuration[i].uact; + config->ubandsel = band_configuration[i].ubandsel; + return TRUE; + } + } + + g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, + "No support configuration found for modem: %s", model); return FALSE; } |