Code cleanup
This commit is contained in:
parent
f304a02388
commit
9bdbb0abf2
@ -15,6 +15,8 @@
|
|||||||
/* FIXME:
|
/* FIXME:
|
||||||
* - implement priorities again
|
* - implement priorities again
|
||||||
* - parse messages from within +CMGL already
|
* - parse messages from within +CMGL already
|
||||||
|
* - test with a SIM card without a PIN code
|
||||||
|
* - add MCT callbacks/buttons to change the SIM code (via a helper in phone.c)
|
||||||
* - implement new contacts */
|
* - implement new contacts */
|
||||||
|
|
||||||
|
|
||||||
@ -161,11 +163,11 @@ typedef struct _HayesRequestHandler
|
|||||||
HayesCommandCallback callback;
|
HayesCommandCallback callback;
|
||||||
} HayesRequestHandler;
|
} HayesRequestHandler;
|
||||||
|
|
||||||
typedef struct _HayesTriggerHandler
|
typedef struct _HayesCodeHandler
|
||||||
{
|
{
|
||||||
char const * trigger;
|
char const * code;
|
||||||
void (*callback)(ModemPlugin * modem, char const * answer);
|
void (*callback)(ModemPlugin * modem, char const * answer);
|
||||||
} HayesTriggerHandler;
|
} HayesCodeHandler;
|
||||||
|
|
||||||
|
|
||||||
/* constants */
|
/* constants */
|
||||||
@ -311,8 +313,6 @@ static HayesCommandStatus _on_request_call_status(HayesCommand * command,
|
|||||||
HayesCommandStatus status, void * priv);
|
HayesCommandStatus status, void * priv);
|
||||||
static HayesCommandStatus _on_request_contact_delete(HayesCommand * command,
|
static HayesCommandStatus _on_request_contact_delete(HayesCommand * command,
|
||||||
HayesCommandStatus status, void * priv);
|
HayesCommandStatus status, void * priv);
|
||||||
static HayesCommandStatus _on_request_contact_list(HayesCommand * command,
|
|
||||||
HayesCommandStatus status, void * priv);
|
|
||||||
static HayesCommandStatus _on_request_functional(HayesCommand * command,
|
static HayesCommandStatus _on_request_functional(HayesCommand * command,
|
||||||
HayesCommandStatus status, void * priv);
|
HayesCommandStatus status, void * priv);
|
||||||
static HayesCommandStatus _on_request_functional_enable(HayesCommand * command,
|
static HayesCommandStatus _on_request_functional_enable(HayesCommand * command,
|
||||||
@ -327,8 +327,6 @@ static HayesCommandStatus _on_request_message_delete(HayesCommand * command,
|
|||||||
HayesCommandStatus status, void * priv);
|
HayesCommandStatus status, void * priv);
|
||||||
static HayesCommandStatus _on_request_message_list(HayesCommand * command,
|
static HayesCommandStatus _on_request_message_list(HayesCommand * command,
|
||||||
HayesCommandStatus status, void * priv);
|
HayesCommandStatus status, void * priv);
|
||||||
static HayesCommandStatus _on_request_message_send(HayesCommand * command,
|
|
||||||
HayesCommandStatus status, void * priv);
|
|
||||||
static HayesCommandStatus _on_request_model(HayesCommand * command,
|
static HayesCommandStatus _on_request_model(HayesCommand * command,
|
||||||
HayesCommandStatus status, void * priv);
|
HayesCommandStatus status, void * priv);
|
||||||
static HayesCommandStatus _on_request_registration(HayesCommand * command,
|
static HayesCommandStatus _on_request_registration(HayesCommand * command,
|
||||||
@ -342,31 +340,31 @@ static HayesCommandStatus _on_request_sim_pin_valid(HayesCommand * command,
|
|||||||
static HayesCommandStatus _on_request_unsupported(HayesCommand * command,
|
static HayesCommandStatus _on_request_unsupported(HayesCommand * command,
|
||||||
HayesCommandStatus status, void * priv);
|
HayesCommandStatus status, void * priv);
|
||||||
|
|
||||||
static void _on_trigger_call_error(ModemPlugin * modem, char const * answer);
|
static void _on_code_call_error(ModemPlugin * modem, char const * answer);
|
||||||
static void _on_trigger_cbc(ModemPlugin * modem, char const * answer);
|
static void _on_code_cbc(ModemPlugin * modem, char const * answer);
|
||||||
static void _on_trigger_cfun(ModemPlugin * modem, char const * answer);
|
static void _on_code_cfun(ModemPlugin * modem, char const * answer);
|
||||||
static void _on_trigger_cgatt(ModemPlugin * modem, char const * answer);
|
static void _on_code_cgatt(ModemPlugin * modem, char const * answer);
|
||||||
static void _on_trigger_cgmi(ModemPlugin * modem, char const * answer);
|
static void _on_code_cgmi(ModemPlugin * modem, char const * answer);
|
||||||
static void _on_trigger_cgmm(ModemPlugin * modem, char const * answer);
|
static void _on_code_cgmm(ModemPlugin * modem, char const * answer);
|
||||||
static void _on_trigger_cgmr(ModemPlugin * modem, char const * answer);
|
static void _on_code_cgmr(ModemPlugin * modem, char const * answer);
|
||||||
static void _on_trigger_clip(ModemPlugin * modem, char const * answer);
|
static void _on_code_clip(ModemPlugin * modem, char const * answer);
|
||||||
static void _on_trigger_cme_error(ModemPlugin * modem, char const * answer);
|
static void _on_code_cme_error(ModemPlugin * modem, char const * answer);
|
||||||
static void _on_trigger_cmgl(ModemPlugin * modem, char const * answer);
|
static void _on_code_cmgl(ModemPlugin * modem, char const * answer);
|
||||||
static void _on_trigger_cmgr(ModemPlugin * modem, char const * answer);
|
static void _on_code_cmgr(ModemPlugin * modem, char const * answer);
|
||||||
static void _on_trigger_cmgs(ModemPlugin * modem, char const * answer);
|
static void _on_code_cmgs(ModemPlugin * modem, char const * answer);
|
||||||
static void _on_trigger_cms_error(ModemPlugin * modem, char const * answer);
|
static void _on_code_cms_error(ModemPlugin * modem, char const * answer);
|
||||||
static void _on_trigger_cmti(ModemPlugin * modem, char const * answer);
|
static void _on_code_cmti(ModemPlugin * modem, char const * answer);
|
||||||
static void _on_trigger_connect(ModemPlugin * modem, char const * answer);
|
static void _on_code_connect(ModemPlugin * modem, char const * answer);
|
||||||
static void _on_trigger_colp(ModemPlugin * modem, char const * answer);
|
static void _on_code_colp(ModemPlugin * modem, char const * answer);
|
||||||
static void _on_trigger_cops(ModemPlugin * modem, char const * answer);
|
static void _on_code_cops(ModemPlugin * modem, char const * answer);
|
||||||
static void _on_trigger_cpas(ModemPlugin * modem, char const * answer);
|
static void _on_code_cpas(ModemPlugin * modem, char const * answer);
|
||||||
static void _on_trigger_cpbr(ModemPlugin * modem, char const * answer);
|
static void _on_code_cpbr(ModemPlugin * modem, char const * answer);
|
||||||
static void _on_trigger_cpin(ModemPlugin * modem, char const * answer);
|
static void _on_code_cpin(ModemPlugin * modem, char const * answer);
|
||||||
static void _on_trigger_creg(ModemPlugin * modem, char const * answer);
|
static void _on_code_creg(ModemPlugin * modem, char const * answer);
|
||||||
static void _on_trigger_cring(ModemPlugin * modem, char const * answer);
|
static void _on_code_cring(ModemPlugin * modem, char const * answer);
|
||||||
static void _on_trigger_csq(ModemPlugin * modem, char const * answer);
|
static void _on_code_csq(ModemPlugin * modem, char const * answer);
|
||||||
static void _on_trigger_cusd(ModemPlugin * modem, char const * answer);
|
static void _on_code_cusd(ModemPlugin * modem, char const * answer);
|
||||||
static void _on_trigger_ext_error(ModemPlugin * modem, char const * answer);
|
static void _on_code_ext_error(ModemPlugin * modem, char const * answer);
|
||||||
|
|
||||||
/* helpers */
|
/* helpers */
|
||||||
static int _is_figure(int c);
|
static int _is_figure(int c);
|
||||||
@ -566,7 +564,7 @@ static HayesRequestHandler _hayes_request_handlers[] =
|
|||||||
{ MODEM_REQUEST_CONTACT_DELETE, NULL,
|
{ MODEM_REQUEST_CONTACT_DELETE, NULL,
|
||||||
_on_request_contact_delete },
|
_on_request_contact_delete },
|
||||||
{ MODEM_REQUEST_CONTACT_LIST, "AT+CPBR=?",
|
{ MODEM_REQUEST_CONTACT_LIST, "AT+CPBR=?",
|
||||||
_on_request_contact_list },
|
_on_request_generic },
|
||||||
{ MODEM_REQUEST_MESSAGE, NULL,
|
{ MODEM_REQUEST_MESSAGE, NULL,
|
||||||
_on_request_message },
|
_on_request_message },
|
||||||
{ MODEM_REQUEST_MESSAGE_DELETE, NULL,
|
{ MODEM_REQUEST_MESSAGE_DELETE, NULL,
|
||||||
@ -574,7 +572,7 @@ static HayesRequestHandler _hayes_request_handlers[] =
|
|||||||
{ MODEM_REQUEST_MESSAGE_LIST, NULL,
|
{ MODEM_REQUEST_MESSAGE_LIST, NULL,
|
||||||
_on_request_message_list },
|
_on_request_message_list },
|
||||||
{ MODEM_REQUEST_MESSAGE_SEND, NULL,
|
{ MODEM_REQUEST_MESSAGE_SEND, NULL,
|
||||||
_on_request_message_send },
|
_on_request_generic },
|
||||||
{ MODEM_REQUEST_REGISTRATION, NULL,
|
{ MODEM_REQUEST_REGISTRATION, NULL,
|
||||||
_on_request_registration },
|
_on_request_registration },
|
||||||
{ MODEM_REQUEST_SIGNAL_LEVEL, "AT+CSQ",
|
{ MODEM_REQUEST_SIGNAL_LEVEL, "AT+CSQ",
|
||||||
@ -583,36 +581,36 @@ static HayesRequestHandler _hayes_request_handlers[] =
|
|||||||
_on_request_unsupported }
|
_on_request_unsupported }
|
||||||
};
|
};
|
||||||
|
|
||||||
static HayesTriggerHandler _hayes_trigger_handlers[] =
|
static HayesCodeHandler _hayes_code_handlers[] =
|
||||||
{
|
{
|
||||||
{ "+CBC", _on_trigger_cbc },
|
{ "+CBC", _on_code_cbc },
|
||||||
{ "+CFUN", _on_trigger_cfun },
|
{ "+CFUN", _on_code_cfun },
|
||||||
{ "+CGATT", _on_trigger_cgatt },
|
{ "+CGATT", _on_code_cgatt },
|
||||||
{ "+CGMI", _on_trigger_cgmi },
|
{ "+CGMI", _on_code_cgmi },
|
||||||
{ "+CGMM", _on_trigger_cgmm },
|
{ "+CGMM", _on_code_cgmm },
|
||||||
{ "+CGMR", _on_trigger_cgmr },
|
{ "+CGMR", _on_code_cgmr },
|
||||||
{ "+CLIP", _on_trigger_clip },
|
{ "+CLIP", _on_code_clip },
|
||||||
{ "+CME ERROR", _on_trigger_cme_error },
|
{ "+CME ERROR", _on_code_cme_error },
|
||||||
{ "+CMGL", _on_trigger_cmgl },
|
{ "+CMGL", _on_code_cmgl },
|
||||||
{ "+CMGR", _on_trigger_cmgr },
|
{ "+CMGR", _on_code_cmgr },
|
||||||
{ "+CMGS", _on_trigger_cmgs },
|
{ "+CMGS", _on_code_cmgs },
|
||||||
{ "+CMS ERROR", _on_trigger_cms_error },
|
{ "+CMS ERROR", _on_code_cms_error },
|
||||||
{ "+CMTI", _on_trigger_cmti },
|
{ "+CMTI", _on_code_cmti },
|
||||||
{ "+COLP", _on_trigger_colp },
|
{ "+COLP", _on_code_colp },
|
||||||
{ "+COPS", _on_trigger_cops },
|
{ "+COPS", _on_code_cops },
|
||||||
{ "+CPAS", _on_trigger_cpas },
|
{ "+CPAS", _on_code_cpas },
|
||||||
{ "+CPBR", _on_trigger_cpbr },
|
{ "+CPBR", _on_code_cpbr },
|
||||||
{ "+CPIN", _on_trigger_cpin },
|
{ "+CPIN", _on_code_cpin },
|
||||||
{ "+CREG", _on_trigger_creg },
|
{ "+CREG", _on_code_creg },
|
||||||
{ "+CRING", _on_trigger_cring },
|
{ "+CRING", _on_code_cring },
|
||||||
{ "+CSQ", _on_trigger_csq },
|
{ "+CSQ", _on_code_csq },
|
||||||
{ "+CUSD", _on_trigger_cusd },
|
{ "+CUSD", _on_code_cusd },
|
||||||
{ "+EXT ERROR", _on_trigger_ext_error },
|
{ "+EXT ERROR", _on_code_ext_error },
|
||||||
{ "BUSY", _on_trigger_call_error },
|
{ "BUSY", _on_code_call_error },
|
||||||
{ "CONNECT", _on_trigger_connect },
|
{ "CONNECT", _on_code_connect },
|
||||||
{ "NO CARRIER", _on_trigger_call_error },
|
{ "NO CARRIER", _on_code_call_error },
|
||||||
{ "NO DIALTONE",_on_trigger_call_error },
|
{ "NO DIALTONE",_on_code_call_error },
|
||||||
{ "RING", _on_trigger_cring }
|
{ "RING", _on_code_cring }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -1485,10 +1483,10 @@ static int _hayes_parse_trigger(ModemPlugin * modem, char const * answer,
|
|||||||
HayesCommand * command)
|
HayesCommand * command)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
size_t count = sizeof(_hayes_trigger_handlers)
|
size_t count = sizeof(_hayes_code_handlers)
|
||||||
/ sizeof(*_hayes_trigger_handlers);
|
/ sizeof(*_hayes_code_handlers);
|
||||||
size_t len;
|
size_t len;
|
||||||
HayesTriggerHandler * th;
|
HayesCodeHandler * hch;
|
||||||
char const * p;
|
char const * p;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
@ -1496,12 +1494,12 @@ static int _hayes_parse_trigger(ModemPlugin * modem, char const * answer,
|
|||||||
fprintf(stderr, "DEBUG: %s(modem, \"%s\", command)\n", __func__,
|
fprintf(stderr, "DEBUG: %s(modem, \"%s\", command)\n", __func__,
|
||||||
answer);
|
answer);
|
||||||
#endif
|
#endif
|
||||||
/* if the trigger is obvious return directly */
|
/* if the handler is obvious return directly */
|
||||||
for(i = 0; i < count; i++)
|
for(i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
th = &_hayes_trigger_handlers[i];
|
hch = &_hayes_code_handlers[i];
|
||||||
len = strlen(th->trigger);
|
len = strlen(hch->code);
|
||||||
if(strncmp(th->trigger, answer, len) != 0)
|
if(strncmp(hch->code, answer, len) != 0)
|
||||||
continue;
|
continue;
|
||||||
if(answer[len] == ':')
|
if(answer[len] == ':')
|
||||||
{
|
{
|
||||||
@ -1510,7 +1508,7 @@ static int _hayes_parse_trigger(ModemPlugin * modem, char const * answer,
|
|||||||
}
|
}
|
||||||
else if(answer[len] != '\0')
|
else if(answer[len] != '\0')
|
||||||
continue;
|
continue;
|
||||||
th->callback(modem, &answer[len]);
|
hch->callback(modem, &answer[len]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* if the answer has no prefix choose it from the command issued */
|
/* if the answer has no prefix choose it from the command issued */
|
||||||
@ -1520,12 +1518,12 @@ static int _hayes_parse_trigger(ModemPlugin * modem, char const * answer,
|
|||||||
return 0;
|
return 0;
|
||||||
for(i = 0; i < count; i++)
|
for(i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
th = &_hayes_trigger_handlers[i];
|
hch = &_hayes_code_handlers[i];
|
||||||
len = strlen(th->trigger);
|
len = strlen(hch->code);
|
||||||
if(strncmp(th->trigger, &p[2], len) != 0
|
if(strncmp(hch->code, &p[2], len) != 0
|
||||||
|| isalnum((j = p[2 + len])))
|
|| isalnum((j = p[2 + len])))
|
||||||
continue;
|
continue;
|
||||||
th->callback(modem, answer);
|
hch->callback(modem, answer);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -2199,7 +2197,6 @@ static HayesCommandStatus _on_reset_callback(HayesCommand * command,
|
|||||||
HayesCommandStatus status, void * priv)
|
HayesCommandStatus status, void * priv)
|
||||||
{
|
{
|
||||||
ModemPlugin * modem = priv;
|
ModemPlugin * modem = priv;
|
||||||
Hayes * hayes = modem->priv;
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "DEBUG: %s(%u)\n", __func__, status);
|
fprintf(stderr, "DEBUG: %s(%u)\n", __func__, status);
|
||||||
@ -2594,15 +2591,6 @@ static HayesCommandStatus _on_request_contact_delete(HayesCommand * command,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_request_contact_list */
|
|
||||||
static HayesCommandStatus _on_request_contact_list(HayesCommand * command,
|
|
||||||
HayesCommandStatus status, void * priv)
|
|
||||||
{
|
|
||||||
/* FIXME implement */
|
|
||||||
return _on_request_generic(command, status, priv);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* on_request_functional */
|
/* on_request_functional */
|
||||||
static HayesCommandStatus _on_request_functional(HayesCommand * command,
|
static HayesCommandStatus _on_request_functional(HayesCommand * command,
|
||||||
HayesCommandStatus status, void * priv)
|
HayesCommandStatus status, void * priv)
|
||||||
@ -2637,7 +2625,7 @@ static HayesCommandStatus _on_request_functional_enable(HayesCommand * command,
|
|||||||
HAYES_REQUEST_FUNCTIONAL_ENABLE_RESET);
|
HAYES_REQUEST_FUNCTIONAL_ENABLE_RESET);
|
||||||
break;
|
break;
|
||||||
case HCS_SUCCESS:
|
case HCS_SUCCESS:
|
||||||
_on_trigger_cfun(modem, "1"); /* XXX ugly workaround */
|
_on_code_cfun(modem, "1"); /* XXX ugly workaround */
|
||||||
break;
|
break;
|
||||||
case HCS_TIMEOUT:
|
case HCS_TIMEOUT:
|
||||||
/* repeat request */
|
/* repeat request */
|
||||||
@ -2660,7 +2648,7 @@ static HayesCommandStatus _on_request_functional_enable_reset(
|
|||||||
switch((status = _on_request_generic(command, status, priv)))
|
switch((status = _on_request_generic(command, status, priv)))
|
||||||
{
|
{
|
||||||
case HCS_SUCCESS:
|
case HCS_SUCCESS:
|
||||||
_on_trigger_cfun(modem, "1"); /* XXX ugly workaround */
|
_on_code_cfun(modem, "1"); /* XXX ugly workaround */
|
||||||
break;
|
break;
|
||||||
case HCS_TIMEOUT:
|
case HCS_TIMEOUT:
|
||||||
/* repeat request */
|
/* repeat request */
|
||||||
@ -2745,15 +2733,6 @@ static HayesCommandStatus _on_request_message_list(HayesCommand * command,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_request_message_send */
|
|
||||||
static HayesCommandStatus _on_request_message_send(HayesCommand * command,
|
|
||||||
HayesCommandStatus status, void * priv)
|
|
||||||
{
|
|
||||||
/* FIXME implement */
|
|
||||||
return _on_request_generic(command, status, priv);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* on_request_model */
|
/* on_request_model */
|
||||||
static HayesCommandStatus _on_request_model(HayesCommand * command,
|
static HayesCommandStatus _on_request_model(HayesCommand * command,
|
||||||
HayesCommandStatus status, void * priv)
|
HayesCommandStatus status, void * priv)
|
||||||
@ -2901,8 +2880,8 @@ static HayesCommandStatus _on_request_unsupported(HayesCommand * command,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_trigger_call_error */
|
/* on_code_call_error */
|
||||||
static void _on_trigger_call_error(ModemPlugin * modem, char const * answer)
|
static void _on_code_call_error(ModemPlugin * modem, char const * answer)
|
||||||
{
|
{
|
||||||
Hayes * hayes = modem->priv;
|
Hayes * hayes = modem->priv;
|
||||||
HayesCommand * command = (hayes->queue != NULL) ? hayes->queue->data
|
HayesCommand * command = (hayes->queue != NULL) ? hayes->queue->data
|
||||||
@ -2914,8 +2893,8 @@ static void _on_trigger_call_error(ModemPlugin * modem, char const * answer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_trigger_cbc */
|
/* on_code_cbc */
|
||||||
static void _on_trigger_cbc(ModemPlugin * modem, char const * answer)
|
static void _on_code_cbc(ModemPlugin * modem, char const * answer)
|
||||||
{
|
{
|
||||||
Hayes * hayes = modem->priv;
|
Hayes * hayes = modem->priv;
|
||||||
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_BATTERY_LEVEL];
|
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_BATTERY_LEVEL];
|
||||||
@ -2958,8 +2937,8 @@ static void _on_trigger_cbc(ModemPlugin * modem, char const * answer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_trigger_cfun */
|
/* on_code_cfun */
|
||||||
static void _on_trigger_cfun(ModemPlugin * modem, char const * answer)
|
static void _on_code_cfun(ModemPlugin * modem, char const * answer)
|
||||||
{
|
{
|
||||||
Hayes * hayes = modem->priv;
|
Hayes * hayes = modem->priv;
|
||||||
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_STATUS];
|
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_STATUS];
|
||||||
@ -2986,8 +2965,8 @@ static void _on_trigger_cfun(ModemPlugin * modem, char const * answer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_trigger_cgatt */
|
/* on_code_cgatt */
|
||||||
static void _on_trigger_cgatt(ModemPlugin * modem, char const * answer)
|
static void _on_code_cgatt(ModemPlugin * modem, char const * answer)
|
||||||
{
|
{
|
||||||
Hayes * hayes = modem->priv;
|
Hayes * hayes = modem->priv;
|
||||||
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_REGISTRATION];
|
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_REGISTRATION];
|
||||||
@ -3006,8 +2985,8 @@ static void _on_trigger_cgatt(ModemPlugin * modem, char const * answer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_trigger_cgmi */
|
/* on_code_cgmi */
|
||||||
static void _on_trigger_cgmi(ModemPlugin * modem, char const * answer)
|
static void _on_code_cgmi(ModemPlugin * modem, char const * answer)
|
||||||
{
|
{
|
||||||
Hayes * hayes = modem->priv;
|
Hayes * hayes = modem->priv;
|
||||||
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_MODEL];
|
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_MODEL];
|
||||||
@ -3021,8 +3000,8 @@ static void _on_trigger_cgmi(ModemPlugin * modem, char const * answer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_trigger_cgmm */
|
/* on_code_cgmm */
|
||||||
static void _on_trigger_cgmm(ModemPlugin * modem, char const * answer)
|
static void _on_code_cgmm(ModemPlugin * modem, char const * answer)
|
||||||
{
|
{
|
||||||
Hayes * hayes = modem->priv;
|
Hayes * hayes = modem->priv;
|
||||||
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_MODEL];
|
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_MODEL];
|
||||||
@ -3048,8 +3027,8 @@ static void _on_trigger_cgmm(ModemPlugin * modem, char const * answer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_trigger_cgmr */
|
/* on_code_cgmr */
|
||||||
static void _on_trigger_cgmr(ModemPlugin * modem, char const * answer)
|
static void _on_code_cgmr(ModemPlugin * modem, char const * answer)
|
||||||
/* FIXME the output may be multi-line */
|
/* FIXME the output may be multi-line */
|
||||||
{
|
{
|
||||||
Hayes * hayes = modem->priv;
|
Hayes * hayes = modem->priv;
|
||||||
@ -3064,8 +3043,8 @@ static void _on_trigger_cgmr(ModemPlugin * modem, char const * answer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_trigger_clip */
|
/* on_code_clip */
|
||||||
static void _on_trigger_clip(ModemPlugin * modem, char const * answer)
|
static void _on_code_clip(ModemPlugin * modem, char const * answer)
|
||||||
{
|
{
|
||||||
Hayes * hayes = modem->priv;
|
Hayes * hayes = modem->priv;
|
||||||
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_CALL];
|
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_CALL];
|
||||||
@ -3094,8 +3073,8 @@ static void _on_trigger_clip(ModemPlugin * modem, char const * answer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_trigger_cme_error */
|
/* on_code_cme_error */
|
||||||
static void _on_trigger_cme_error(ModemPlugin * modem, char const * answer)
|
static void _on_code_cme_error(ModemPlugin * modem, char const * answer)
|
||||||
{
|
{
|
||||||
ModemPluginHelper * helper = modem->helper;
|
ModemPluginHelper * helper = modem->helper;
|
||||||
Hayes * hayes = modem->priv;
|
Hayes * hayes = modem->priv;
|
||||||
@ -3113,11 +3092,11 @@ static void _on_trigger_cme_error(ModemPlugin * modem, char const * answer)
|
|||||||
switch(u)
|
switch(u)
|
||||||
{
|
{
|
||||||
case 11: /* SIM PIN required */
|
case 11: /* SIM PIN required */
|
||||||
_on_trigger_cpin(modem, "SIM PIN");
|
_on_code_cpin(modem, "SIM PIN");
|
||||||
_hayes_trigger(modem, MODEM_EVENT_TYPE_AUTHENTICATION);
|
_hayes_trigger(modem, MODEM_EVENT_TYPE_AUTHENTICATION);
|
||||||
break;
|
break;
|
||||||
case 12: /* SIM PUK required */
|
case 12: /* SIM PUK required */
|
||||||
_on_trigger_cpin(modem, "SIM PUK");
|
_on_code_cpin(modem, "SIM PUK");
|
||||||
_hayes_trigger(modem, MODEM_EVENT_TYPE_AUTHENTICATION);
|
_hayes_trigger(modem, MODEM_EVENT_TYPE_AUTHENTICATION);
|
||||||
break;
|
break;
|
||||||
case 14: /* SIM busy */
|
case 14: /* SIM busy */
|
||||||
@ -3162,8 +3141,8 @@ static void _on_trigger_cme_error(ModemPlugin * modem, char const * answer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_trigger_cmgl */
|
/* on_code_cmgl */
|
||||||
static void _on_trigger_cmgl(ModemPlugin * modem, char const * answer)
|
static void _on_code_cmgl(ModemPlugin * modem, char const * answer)
|
||||||
{
|
{
|
||||||
Hayes * hayes = modem->priv;
|
Hayes * hayes = modem->priv;
|
||||||
/* XXX ugly */
|
/* XXX ugly */
|
||||||
@ -3199,7 +3178,7 @@ static void _on_trigger_cmgl(ModemPlugin * modem, char const * answer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_trigger_cmgr */
|
/* on_code_cmgr */
|
||||||
static char * _cmgr_pdu_parse(char const * pdu, time_t * timestamp,
|
static char * _cmgr_pdu_parse(char const * pdu, time_t * timestamp,
|
||||||
char * number, ModemMessageEncoding * encoding,
|
char * number, ModemMessageEncoding * encoding,
|
||||||
size_t * length);
|
size_t * length);
|
||||||
@ -3213,7 +3192,7 @@ static void _cmgr_pdu_parse_number(unsigned int type, char const * number,
|
|||||||
size_t length, char * buf);
|
size_t length, char * buf);
|
||||||
static time_t _cmgr_pdu_parse_timestamp(char const * timestamp);
|
static time_t _cmgr_pdu_parse_timestamp(char const * timestamp);
|
||||||
|
|
||||||
static void _on_trigger_cmgr(ModemPlugin * modem, char const * answer)
|
static void _on_code_cmgr(ModemPlugin * modem, char const * answer)
|
||||||
{
|
{
|
||||||
Hayes * hayes = modem->priv;
|
Hayes * hayes = modem->priv;
|
||||||
/* XXX ugly */
|
/* XXX ugly */
|
||||||
@ -3511,8 +3490,8 @@ static time_t _cmgr_pdu_parse_timestamp(char const * timestamp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_trigger_cmgs */
|
/* on_code_cmgs */
|
||||||
static void _on_trigger_cmgs(ModemPlugin * modem, char const * answer)
|
static void _on_code_cmgs(ModemPlugin * modem, char const * answer)
|
||||||
{
|
{
|
||||||
Hayes * hayes = modem->priv;
|
Hayes * hayes = modem->priv;
|
||||||
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_MESSAGE_SENT];
|
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_MESSAGE_SENT];
|
||||||
@ -3525,8 +3504,8 @@ static void _on_trigger_cmgs(ModemPlugin * modem, char const * answer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_trigger_cms_error */
|
/* on_code_cms_error */
|
||||||
static void _on_trigger_cms_error(ModemPlugin * modem, char const * answer)
|
static void _on_code_cms_error(ModemPlugin * modem, char const * answer)
|
||||||
{
|
{
|
||||||
Hayes * hayes = modem->priv;
|
Hayes * hayes = modem->priv;
|
||||||
HayesCommand * command = (hayes->queue != NULL) ? hayes->queue->data
|
HayesCommand * command = (hayes->queue != NULL) ? hayes->queue->data
|
||||||
@ -3541,17 +3520,17 @@ static void _on_trigger_cms_error(ModemPlugin * modem, char const * answer)
|
|||||||
switch(u)
|
switch(u)
|
||||||
{
|
{
|
||||||
case 311: /* SIM PIN required */
|
case 311: /* SIM PIN required */
|
||||||
_on_trigger_cpin(modem, "SIM PIN");
|
_on_code_cpin(modem, "SIM PIN");
|
||||||
_hayes_trigger(modem, MODEM_EVENT_TYPE_AUTHENTICATION);
|
_hayes_trigger(modem, MODEM_EVENT_TYPE_AUTHENTICATION);
|
||||||
break;
|
break;
|
||||||
case 316: /* SIM PUK required */
|
case 316: /* SIM PUK required */
|
||||||
_on_trigger_cpin(modem, "SIM PUK");
|
_on_code_cpin(modem, "SIM PUK");
|
||||||
_hayes_trigger(modem, MODEM_EVENT_TYPE_AUTHENTICATION);
|
_hayes_trigger(modem, MODEM_EVENT_TYPE_AUTHENTICATION);
|
||||||
break;
|
break;
|
||||||
case 314: /* SIM busy */
|
case 314: /* SIM busy */
|
||||||
case 500: /* unknown error */
|
case 500: /* unknown error */
|
||||||
/* repeat the command */
|
/* repeat the command */
|
||||||
/* FIXME duplicated from _on_trigger_cme_error() */
|
/* FIXME duplicated from _on_code_cme_error() */
|
||||||
if(command == NULL)
|
if(command == NULL)
|
||||||
break;
|
break;
|
||||||
if((p = _hayes_command_new(command->attention)) == NULL)
|
if((p = _hayes_command_new(command->attention)) == NULL)
|
||||||
@ -3573,8 +3552,8 @@ static void _on_trigger_cms_error(ModemPlugin * modem, char const * answer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_trigger_cmti */
|
/* on_code_cmti */
|
||||||
static void _on_trigger_cmti(ModemPlugin * modem, char const * answer)
|
static void _on_code_cmti(ModemPlugin * modem, char const * answer)
|
||||||
{
|
{
|
||||||
char buf[32];
|
char buf[32];
|
||||||
unsigned int u;
|
unsigned int u;
|
||||||
@ -3591,8 +3570,8 @@ static void _on_trigger_cmti(ModemPlugin * modem, char const * answer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_trigger_connect */
|
/* on_code_connect */
|
||||||
static void _on_trigger_connect(ModemPlugin * modem, char const * answer)
|
static void _on_code_connect(ModemPlugin * modem, char const * answer)
|
||||||
{
|
{
|
||||||
Hayes * hayes = modem->priv;
|
Hayes * hayes = modem->priv;
|
||||||
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_CONNECTION];
|
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_CONNECTION];
|
||||||
@ -3636,8 +3615,8 @@ static void _on_trigger_connect(ModemPlugin * modem, char const * answer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_trigger_colp */
|
/* on_code_colp */
|
||||||
static void _on_trigger_colp(ModemPlugin * modem, char const * answer)
|
static void _on_code_colp(ModemPlugin * modem, char const * answer)
|
||||||
{
|
{
|
||||||
Hayes * hayes = modem->priv;
|
Hayes * hayes = modem->priv;
|
||||||
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_CALL];
|
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_CALL];
|
||||||
@ -3665,8 +3644,8 @@ static void _on_trigger_colp(ModemPlugin * modem, char const * answer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_trigger_cops */
|
/* on_code_cops */
|
||||||
static void _on_trigger_cops(ModemPlugin * modem, char const * answer)
|
static void _on_code_cops(ModemPlugin * modem, char const * answer)
|
||||||
{
|
{
|
||||||
Hayes * hayes = modem->priv;
|
Hayes * hayes = modem->priv;
|
||||||
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_REGISTRATION];
|
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_REGISTRATION];
|
||||||
@ -3714,8 +3693,8 @@ static void _on_trigger_cops(ModemPlugin * modem, char const * answer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_trigger_cpas */
|
/* on_code_cpas */
|
||||||
static void _on_trigger_cpas(ModemPlugin * modem, char const * answer)
|
static void _on_code_cpas(ModemPlugin * modem, char const * answer)
|
||||||
{
|
{
|
||||||
ModemPluginHelper * helper = modem->helper;
|
ModemPluginHelper * helper = modem->helper;
|
||||||
Hayes * hayes = modem->priv;
|
Hayes * hayes = modem->priv;
|
||||||
@ -3752,8 +3731,8 @@ static void _on_trigger_cpas(ModemPlugin * modem, char const * answer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_trigger_cpbr */
|
/* on_code_cpbr */
|
||||||
static void _on_trigger_cpbr(ModemPlugin * modem, char const * answer)
|
static void _on_code_cpbr(ModemPlugin * modem, char const * answer)
|
||||||
{
|
{
|
||||||
Hayes * hayes = modem->priv;
|
Hayes * hayes = modem->priv;
|
||||||
ModemRequest request;
|
ModemRequest request;
|
||||||
@ -3807,8 +3786,8 @@ static void _on_trigger_cpbr(ModemPlugin * modem, char const * answer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_trigger_cpin */
|
/* on_code_cpin */
|
||||||
static void _on_trigger_cpin(ModemPlugin * modem, char const * answer)
|
static void _on_code_cpin(ModemPlugin * modem, char const * answer)
|
||||||
{
|
{
|
||||||
Hayes * hayes = modem->priv;
|
Hayes * hayes = modem->priv;
|
||||||
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_AUTHENTICATION];
|
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_AUTHENTICATION];
|
||||||
@ -3834,8 +3813,8 @@ static void _on_trigger_cpin(ModemPlugin * modem, char const * answer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_trigger_creg */
|
/* on_code_creg */
|
||||||
static void _on_trigger_creg(ModemPlugin * modem, char const * answer)
|
static void _on_code_creg(ModemPlugin * modem, char const * answer)
|
||||||
{
|
{
|
||||||
Hayes * hayes = modem->priv;
|
Hayes * hayes = modem->priv;
|
||||||
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_REGISTRATION];
|
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_REGISTRATION];
|
||||||
@ -3912,8 +3891,8 @@ static void _on_trigger_creg(ModemPlugin * modem, char const * answer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_trigger_cring */
|
/* on_code_cring */
|
||||||
static void _on_trigger_cring(ModemPlugin * modem, char const * answer)
|
static void _on_code_cring(ModemPlugin * modem, char const * answer)
|
||||||
{
|
{
|
||||||
Hayes * hayes = modem->priv;
|
Hayes * hayes = modem->priv;
|
||||||
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_CALL];
|
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_CALL];
|
||||||
@ -3928,8 +3907,8 @@ static void _on_trigger_cring(ModemPlugin * modem, char const * answer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_trigger_csq */
|
/* on_code_csq */
|
||||||
static void _on_trigger_csq(ModemPlugin * modem, char const * answer)
|
static void _on_code_csq(ModemPlugin * modem, char const * answer)
|
||||||
{
|
{
|
||||||
Hayes * hayes = modem->priv;
|
Hayes * hayes = modem->priv;
|
||||||
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_REGISTRATION];
|
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_REGISTRATION];
|
||||||
@ -3949,8 +3928,8 @@ static void _on_trigger_csq(ModemPlugin * modem, char const * answer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_trigger_cusd */
|
/* on_code_cusd */
|
||||||
static void _on_trigger_cusd(ModemPlugin * modem, char const * answer)
|
static void _on_code_cusd(ModemPlugin * modem, char const * answer)
|
||||||
{
|
{
|
||||||
unsigned int u;
|
unsigned int u;
|
||||||
|
|
||||||
@ -3960,8 +3939,8 @@ static void _on_trigger_cusd(ModemPlugin * modem, char const * answer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_trigger_ext_error */
|
/* on_code_ext_error */
|
||||||
static void _on_trigger_ext_error(ModemPlugin * modem, char const * answer)
|
static void _on_code_ext_error(ModemPlugin * modem, char const * answer)
|
||||||
{
|
{
|
||||||
Hayes * hayes = modem->priv;
|
Hayes * hayes = modem->priv;
|
||||||
/* XXX ugly */
|
/* XXX ugly */
|
||||||
|
Loading…
Reference in New Issue
Block a user