mirror of git://git.sysmocom.de/ofono
ublox: query USBCONF for applicable devices
The TOBY L2 series of modems presents a number of different configurations with different throughtput characteristics. These configurations are packaged up as USB profiles; moreover, changing the profile actually changes the USB model ID so this is even more like selecting a different "device" altogether. Nonetheless, all we need to know is which profile is selected in order to set things up correctly and this can be queried directly. This patch adds a call to UUSBCONF for applicable modems in order to query the USB configuration to find out which profile is active.
This commit is contained in:
parent
cfab42825d
commit
2dc053b28e
|
@ -46,6 +46,7 @@
|
|||
|
||||
#include <drivers/ubloxmodem/ubloxmodem.h>
|
||||
|
||||
static const char *uusbconf_prefix[] = { "+UUSBCONF:", NULL };
|
||||
static const char *none_prefix[] = { NULL };
|
||||
|
||||
enum supported_models {
|
||||
|
@ -155,6 +156,58 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
|
|||
ofono_modem_set_powered(modem, TRUE);
|
||||
}
|
||||
|
||||
static void query_usbconf_cb(gboolean ok,
|
||||
GAtResult *result, gpointer user_data)
|
||||
{
|
||||
struct ofono_modem *modem = user_data;
|
||||
struct ublox_data *data = ofono_modem_get_data(modem);
|
||||
GAtResultIter iter;
|
||||
int profile;
|
||||
|
||||
if (!ok) {
|
||||
ofono_error("Unable to query USB configuration");
|
||||
goto error;
|
||||
}
|
||||
|
||||
g_at_result_iter_init(&iter, result);
|
||||
|
||||
retry:
|
||||
if (!g_at_result_iter_next(&iter, "+UUSBCONF")) {
|
||||
ofono_error("Unable to query USB configuration");
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!g_at_result_iter_next_number(&iter, &profile))
|
||||
goto retry;
|
||||
|
||||
switch (profile) {
|
||||
case 0: /* Fairly back compatible */
|
||||
case 1: /* Fairly back compatible plus audio */
|
||||
data->model_id = TOBYL2_COMPATIBLE_MODE;
|
||||
break;
|
||||
case 2: /* Low/medium throughput */
|
||||
data->model_id = TOBYL2_MEDIUM_THROUGHPUT_MODE;
|
||||
break;
|
||||
case 3: /* High throughput mode */
|
||||
data->model_id = TOBYL2_HIGH_THROUGHPUT_MODE;
|
||||
break;
|
||||
default:
|
||||
ofono_error("Unexpected USB profile: %d", profile);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (g_at_chat_send(data->aux, "AT+CFUN=4", none_prefix,
|
||||
cfun_enable, modem, NULL))
|
||||
return;
|
||||
|
||||
error:
|
||||
g_at_chat_unref(data->aux);
|
||||
data->aux = NULL;
|
||||
g_at_chat_unref(data->modem);
|
||||
data->modem = NULL;
|
||||
ofono_modem_set_powered(modem, FALSE);
|
||||
}
|
||||
|
||||
static void query_model_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
||||
{
|
||||
struct ofono_modem *modem = user_data;
|
||||
|
@ -162,7 +215,6 @@ static void query_model_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
|||
struct ofono_error error;
|
||||
const char *model;
|
||||
const struct ublox_model *m;
|
||||
const char *model_str;
|
||||
|
||||
decode_at_error(&error, g_at_result_final_response(result));
|
||||
|
||||
|
@ -184,28 +236,13 @@ static void query_model_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
|||
|
||||
DBG("Model: %s", data->model->name);
|
||||
|
||||
if (data->model->flags & UBLOX_F_TOBY_L2) {
|
||||
model_str = ofono_modem_get_string(modem, "Model");
|
||||
if (!model_str)
|
||||
goto fail;
|
||||
if (data->model->flags & UBLOX_F_HAVE_USBCONF) {
|
||||
if (g_at_chat_send(data->aux, "AT+UUSBCONF?", uusbconf_prefix,
|
||||
query_usbconf_cb, modem, NULL))
|
||||
return;
|
||||
|
||||
/*
|
||||
* Toby L2 devices are more complex and special than previously
|
||||
* supported U-Blox devices. So they need a vendor of their own.
|
||||
*/
|
||||
data->model_id = strtoul(model_str, NULL, 10);
|
||||
|
||||
switch (data->model_id) {
|
||||
case TOBYL2_COMPATIBLE_MODE:
|
||||
case TOBYL2_HIGH_THROUGHPUT_MODE:
|
||||
break;
|
||||
case TOBYL2_MEDIUM_THROUGHPUT_MODE:
|
||||
DBG("low/medium throughtput profile unsupported");
|
||||
break;
|
||||
default:
|
||||
DBG("unknown ublox model id %d", data->model_id);
|
||||
goto fail;
|
||||
}
|
||||
ofono_error("Unable to query USB configuration");
|
||||
goto fail;
|
||||
} else {
|
||||
data->vendor_family = OFONO_VENDOR_UBLOX;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue