ublox: add device flags

Some aspects of a device are detectable at runtime, like the USB profile
detection that was added in a patch preceding this one.  This patch
switches the driver over from creating a new "vendor id" for each
profile to just setting a flag.  This is more easily extensible as we
detect other features of the modem.
This commit is contained in:
Jonas Bonn 2019-03-13 22:35:56 +01:00 committed by Denis Kenzior
parent c2f9faef1a
commit 8a62ee79a9
1 changed files with 9 additions and 13 deletions

View File

@ -49,20 +49,17 @@
static const char *uusbconf_prefix[] = { "+UUSBCONF:", NULL }; static const char *uusbconf_prefix[] = { "+UUSBCONF:", NULL };
static const char *none_prefix[] = { NULL }; static const char *none_prefix[] = { NULL };
enum supported_models { enum ublox_device_flags {
SARA_G270 = 1102, UBLOX_DEVICE_F_HIGH_THROUGHPUT_MODE = (1 << 0),
TOBYL2_COMPATIBLE_MODE = 1141,
TOBYL2_MEDIUM_THROUGHPUT_MODE = 1143,
TOBYL2_HIGH_THROUGHPUT_MODE = 1146,
}; };
struct ublox_data { struct ublox_data {
GAtChat *modem; GAtChat *modem;
GAtChat *aux; GAtChat *aux;
int model_id;
enum ofono_vendor vendor_family; enum ofono_vendor vendor_family;
const struct ublox_model *model; const struct ublox_model *model;
int flags;
}; };
static void ublox_debug(const char *str, void *user_data) static void ublox_debug(const char *str, void *user_data)
@ -148,7 +145,7 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
return; return;
} }
if (data->model_id == TOBYL2_HIGH_THROUGHPUT_MODE) if (data->flags & UBLOX_DEVICE_F_HIGH_THROUGHPUT_MODE)
/* use bridged mode until routed mode support is added */ /* use bridged mode until routed mode support is added */
g_at_chat_send(data->aux, "AT+UBMCONF=2", none_prefix, g_at_chat_send(data->aux, "AT+UBMCONF=2", none_prefix,
NULL, NULL, NULL); NULL, NULL, NULL);
@ -183,13 +180,12 @@ retry:
switch (profile) { switch (profile) {
case 0: /* Fairly back compatible */ case 0: /* Fairly back compatible */
case 1: /* Fairly back compatible plus audio */ case 1: /* Fairly back compatible plus audio */
data->model_id = TOBYL2_COMPATIBLE_MODE;
break; break;
case 2: /* Low/medium throughput */ case 2: /* Low/medium throughput */
data->model_id = TOBYL2_MEDIUM_THROUGHPUT_MODE; ofono_error("Medium throughput mode not supported");
break; goto error;
case 3: /* High throughput mode */ case 3: /* High throughput mode */
data->model_id = TOBYL2_HIGH_THROUGHPUT_MODE; data->flags |= UBLOX_DEVICE_F_HIGH_THROUGHPUT_MODE;
break; break;
default: default:
ofono_error("Unexpected USB profile: %d", profile); ofono_error("Unexpected USB profile: %d", profile);
@ -390,10 +386,10 @@ static void ublox_post_sim(struct ofono_modem *modem)
struct ofono_gprs *gprs; struct ofono_gprs *gprs;
struct ofono_gprs_context *gc; struct ofono_gprs_context *gc;
GAtChat *chat = data->modem ? data->modem : data->aux; GAtChat *chat = data->modem ? data->modem : data->aux;
const char *driver = data->model_id == TOBYL2_HIGH_THROUGHPUT_MODE ? const char *driver = data->flags & UBLOX_DEVICE_F_HIGH_THROUGHPUT_MODE ?
"ubloxmodem" : "atmodem"; "ubloxmodem" : "atmodem";
/* Toby L2: Create same number of contexts as supported PDP contexts. */ /* Toby L2: Create same number of contexts as supported PDP contexts. */
int ncontexts = data->model_id == TOBYL2_HIGH_THROUGHPUT_MODE ? 8 : 1; int ncontexts = data->flags & UBLOX_DEVICE_F_HIGH_THROUGHPUT_MODE ? 8 : 1;
DBG("%p", modem); DBG("%p", modem);