diff --git a/src/modems/hayes.c b/src/modems/hayes.c index 1907db5..67dc0a8 100644 --- a/src/modems/hayes.c +++ b/src/modems/hayes.c @@ -2130,6 +2130,8 @@ static HayesCommandStatus _on_reset_settle_callback(HayesCommand * command, HAYES_REQUEST_LOCAL_ECHO_DISABLE); _hayes_request_type(hayes, channel, HAYES_REQUEST_VERBOSE_ENABLE); + _hayes_request_type(hayes, channel, + HAYES_REQUEST_VENDOR); _hayes_request_type(hayes, channel, HAYES_REQUEST_MODEL); _hayes_request_type(hayes, channel, @@ -2948,7 +2950,6 @@ static void _on_code_cgmm(HayesChannel * channel, char const * answer) { ModemEvent * event = &channel->events[MODEM_EVENT_TYPE_MODEL]; char * p; - size_t i; if(answer[0] == '\0' || strcmp(answer, "OK") == 0 || (p = strdup(answer)) == NULL) /* XXX report error? */ @@ -2956,17 +2957,7 @@ static void _on_code_cgmm(HayesChannel * channel, char const * answer) free(channel->model_name); channel->model_name = p; event->model.name = p; - /* determine known quirks */ - for(i = 0; hayes_quirks[i].model != NULL; i++) - if(strcmp(hayes_quirks[i].model, p) == 0) - { - channel->quirks = hayes_quirks[i].quirks; -#ifdef DEBUG - fprintf(stderr, "DEBUG: %s() quirks=%u\n", __func__, - channel->quirks); -#endif - break; - } + channel->quirks = hayes_quirks(event->model.vendor, p); } diff --git a/src/modems/hayes/quirks.c b/src/modems/hayes/quirks.c index e5c5176..1dcdf33 100644 --- a/src/modems/hayes/quirks.c +++ b/src/modems/hayes/quirks.c @@ -15,28 +15,51 @@ -#include +#include +#include #include "quirks.h" /* HayesQuirks */ -/* public */ +/* private */ /* constants */ -HayesQuirks hayes_quirks[] = +static HayesQuirks _hayes_quirks[] = { - { "\"Neo1973 Embedded GSM Modem\"", + { "Openmomo", "\"Neo1973 Embedded GSM Modem\"", HAYES_QUIRK_WANT_SMSC_IN_PDU | HAYES_QUIRK_CONNECTED_LINE_DISABLED | HAYES_QUIRK_REPEAT_ON_UNKNOWN_ERROR }, - { "\"Neo1973 GTA01/GTA02 Embedded GSM Modem\"", + { "Openmoko", "\"Neo1973 GTA01/GTA02 Embedded GSM Modem\"", HAYES_QUIRK_WANT_SMSC_IN_PDU | HAYES_QUIRK_CONNECTED_LINE_DISABLED | HAYES_QUIRK_REPEAT_ON_UNKNOWN_ERROR }, - { "\"Neo1973 GTA02 Embedded GSM Modem\"", + { "Openmoko", "\"Neo1973 GTA02 Embedded GSM Modem\"", HAYES_QUIRK_WANT_SMSC_IN_PDU | HAYES_QUIRK_CONNECTED_LINE_DISABLED | HAYES_QUIRK_REPEAT_ON_UNKNOWN_ERROR }, - { "Nokia N900", - HAYES_QUIRK_BATTERY_70 }, - { NULL, 0 } + { "Nokia", "Nokia N900", + HAYES_QUIRK_BATTERY_70 } }; + + +/* public */ +/* functions */ +/* hayes_quirks */ +unsigned int hayes_quirks(char const * vendor, char const * model) +{ + size_t i; + + if(vendor == NULL || model == NULL) + return 0; + for(i = 0; i < sizeof(_hayes_quirks) / sizeof(*_hayes_quirks); i++) + if(strcmp(_hayes_quirks[i].vendor, vendor) == 0 + && strcmp(_hayes_quirks[i].model, model) == 0) + { +#ifdef DEBUG + fprintf(stderr, "DEBUG: %s() quirks=%u\n", __func__, + _hayes_quirks[i].quirks); +#endif + return _hayes_quirks[i].quirks; + } + return 0; +} diff --git a/src/modems/hayes/quirks.h b/src/modems/hayes/quirks.h index 07e6597..71db162 100644 --- a/src/modems/hayes/quirks.h +++ b/src/modems/hayes/quirks.h @@ -33,12 +33,13 @@ typedef enum _HayesQuirk typedef const struct _HayesQuirks { + char const * vendor; char const * model; unsigned int quirks; } HayesQuirks; -/* constants */ -extern HayesQuirks hayes_quirks[]; +/* functions */ +unsigned int hayes_quirks(char const * vendor, char const * model); #endif /* PHONE_MODEM_HAYES_QUIRKS_H */