Also consider the vendor when looking for quirks

This commit is contained in:
Pierre Pronchery 2014-09-11 21:26:51 +02:00
parent fbf66280e0
commit 3d6af30b93
3 changed files with 38 additions and 23 deletions

View File

@ -2130,6 +2130,8 @@ static HayesCommandStatus _on_reset_settle_callback(HayesCommand * command,
HAYES_REQUEST_LOCAL_ECHO_DISABLE); HAYES_REQUEST_LOCAL_ECHO_DISABLE);
_hayes_request_type(hayes, channel, _hayes_request_type(hayes, channel,
HAYES_REQUEST_VERBOSE_ENABLE); HAYES_REQUEST_VERBOSE_ENABLE);
_hayes_request_type(hayes, channel,
HAYES_REQUEST_VENDOR);
_hayes_request_type(hayes, channel, _hayes_request_type(hayes, channel,
HAYES_REQUEST_MODEL); HAYES_REQUEST_MODEL);
_hayes_request_type(hayes, channel, _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]; ModemEvent * event = &channel->events[MODEM_EVENT_TYPE_MODEL];
char * p; char * p;
size_t i;
if(answer[0] == '\0' || strcmp(answer, "OK") == 0 if(answer[0] == '\0' || strcmp(answer, "OK") == 0
|| (p = strdup(answer)) == NULL) /* XXX report error? */ || (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); free(channel->model_name);
channel->model_name = p; channel->model_name = p;
event->model.name = p; event->model.name = p;
/* determine known quirks */ channel->quirks = hayes_quirks(event->model.vendor, p);
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;
}
} }

View File

@ -15,28 +15,51 @@
#include <stddef.h> #include <sys/types.h>
#include <string.h>
#include "quirks.h" #include "quirks.h"
/* HayesQuirks */ /* HayesQuirks */
/* public */ /* private */
/* constants */ /* 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_WANT_SMSC_IN_PDU
| HAYES_QUIRK_CONNECTED_LINE_DISABLED | HAYES_QUIRK_CONNECTED_LINE_DISABLED
| HAYES_QUIRK_REPEAT_ON_UNKNOWN_ERROR }, | 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_WANT_SMSC_IN_PDU
| HAYES_QUIRK_CONNECTED_LINE_DISABLED | HAYES_QUIRK_CONNECTED_LINE_DISABLED
| HAYES_QUIRK_REPEAT_ON_UNKNOWN_ERROR }, | 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_WANT_SMSC_IN_PDU
| HAYES_QUIRK_CONNECTED_LINE_DISABLED | HAYES_QUIRK_CONNECTED_LINE_DISABLED
| HAYES_QUIRK_REPEAT_ON_UNKNOWN_ERROR }, | HAYES_QUIRK_REPEAT_ON_UNKNOWN_ERROR },
{ "Nokia N900", { "Nokia", "Nokia N900",
HAYES_QUIRK_BATTERY_70 }, HAYES_QUIRK_BATTERY_70 }
{ NULL, 0 }
}; };
/* 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;
}

View File

@ -33,12 +33,13 @@ typedef enum _HayesQuirk
typedef const struct _HayesQuirks typedef const struct _HayesQuirks
{ {
char const * vendor;
char const * model; char const * model;
unsigned int quirks; unsigned int quirks;
} HayesQuirks; } HayesQuirks;
/* constants */ /* functions */
extern HayesQuirks hayes_quirks[]; unsigned int hayes_quirks(char const * vendor, char const * model);
#endif /* PHONE_MODEM_HAYES_QUIRKS_H */ #endif /* PHONE_MODEM_HAYES_QUIRKS_H */