Fixed error checking and PIN code handling
This commit is contained in:
parent
20b0bc4f16
commit
06fd109abd
@ -14,7 +14,6 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
/* FIXME:
|
/* FIXME:
|
||||||
* - implement new contacts
|
* - implement new contacts
|
||||||
* - verify that the error when the SIM PIN code is wrong is handled properly
|
|
||||||
* - allow a trace log to be stored */
|
* - allow a trace log to be stored */
|
||||||
|
|
||||||
|
|
||||||
@ -2431,24 +2430,30 @@ static HayesCommandStatus _on_request_authenticate(HayesCommand * command,
|
|||||||
memset(&request, 0, sizeof(request));
|
memset(&request, 0, sizeof(request));
|
||||||
switch((status = _on_request_generic(command, status, priv)))
|
switch((status = _on_request_generic(command, status, priv)))
|
||||||
{
|
{
|
||||||
|
case HCS_SUCCESS:
|
||||||
|
break;
|
||||||
case HCS_ERROR:
|
case HCS_ERROR:
|
||||||
event->authentication.status
|
event->authentication.status
|
||||||
= MODEM_AUTHENTICATION_STATUS_ERROR;
|
= MODEM_AUTHENTICATION_STATUS_ERROR;
|
||||||
break;
|
modem->helper->event(modem->helper->modem, event);
|
||||||
case HCS_SUCCESS:
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
/* XXX it should be bound to the request instead */
|
/* XXX it should be bound to the request instead */
|
||||||
if(event->authentication.name != NULL)
|
if(event->authentication.name != NULL && (strcmp("SIM PIN",
|
||||||
modem->helper->event(modem->helper->modem, event);
|
event->authentication.name) == 0
|
||||||
if(status == HCS_SUCCESS)
|
|| strcmp("SIM PUK",
|
||||||
|
event->authentication.name) == 0))
|
||||||
{
|
{
|
||||||
/* verify that it really worked */
|
/* verify that it really worked */
|
||||||
request.type = HAYES_REQUEST_SIM_PIN_VALID;
|
request.type = HAYES_REQUEST_SIM_PIN_VALID;
|
||||||
_hayes_request(modem, &request);
|
_hayes_request(modem, &request);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
event->authentication.status = MODEM_AUTHENTICATION_STATUS_OK;
|
||||||
|
modem->helper->event(modem->helper->modem, event);
|
||||||
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2758,7 +2763,14 @@ static HayesCommandStatus _on_request_sim_pin_valid(HayesCommand * command,
|
|||||||
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_AUTHENTICATION];
|
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_AUTHENTICATION];
|
||||||
ModemRequest request;
|
ModemRequest request;
|
||||||
|
|
||||||
if((status = _on_request_generic(command, status, priv)) != HCS_SUCCESS)
|
if((status = _on_request_generic(command, status, priv)) == HCS_ERROR)
|
||||||
|
{
|
||||||
|
event->authentication.status
|
||||||
|
= MODEM_AUTHENTICATION_STATUS_ERROR;
|
||||||
|
modem->helper->event(modem->helper->modem, event);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
else if(status != HCS_SUCCESS)
|
||||||
return status;
|
return status;
|
||||||
modem->helper->event(modem->helper->modem, event);
|
modem->helper->event(modem->helper->modem, event);
|
||||||
/* return if not successful */
|
/* return if not successful */
|
||||||
@ -2814,7 +2826,10 @@ static void _on_trigger_call_error(ModemPlugin * modem, char const * answer)
|
|||||||
: NULL;
|
: NULL;
|
||||||
|
|
||||||
if(command != NULL)
|
if(command != NULL)
|
||||||
|
{
|
||||||
_hayes_command_set_status(command, HCS_ERROR);
|
_hayes_command_set_status(command, HCS_ERROR);
|
||||||
|
_hayes_command_callback(command);
|
||||||
|
}
|
||||||
_hayes_trigger(modem, MODEM_EVENT_TYPE_CALL);
|
_hayes_trigger(modem, MODEM_EVENT_TYPE_CALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3011,7 +3026,10 @@ static void _on_trigger_cme_error(ModemPlugin * modem, char const * answer)
|
|||||||
ModemRequest request;
|
ModemRequest request;
|
||||||
|
|
||||||
if(command != NULL)
|
if(command != NULL)
|
||||||
|
{
|
||||||
_hayes_command_set_status(command, HCS_ERROR);
|
_hayes_command_set_status(command, HCS_ERROR);
|
||||||
|
_hayes_command_callback(command);
|
||||||
|
}
|
||||||
if(sscanf(answer, "%u", &u) != 1)
|
if(sscanf(answer, "%u", &u) != 1)
|
||||||
return;
|
return;
|
||||||
switch(u)
|
switch(u)
|
||||||
@ -3053,8 +3071,9 @@ static void _on_trigger_cme_error(ModemPlugin * modem, char const * answer)
|
|||||||
_hayes_request(modem, &request);
|
_hayes_request(modem, &request);
|
||||||
break;
|
break;
|
||||||
default: /* FIXME implement the rest */
|
default: /* FIXME implement the rest */
|
||||||
|
case 3: /* operation not allowed */
|
||||||
case 4: /* operation not supported */
|
case 4: /* operation not supported */
|
||||||
case 16: /* Incorrect SIM PUK */
|
case 16: /* Incorrect SIM PIN/PUK */
|
||||||
case 20: /* Memory full */
|
case 20: /* Memory full */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -3434,7 +3453,10 @@ static void _on_trigger_cms_error(ModemPlugin * modem, char const * answer)
|
|||||||
HayesCommand * p;
|
HayesCommand * p;
|
||||||
|
|
||||||
if(command != NULL)
|
if(command != NULL)
|
||||||
|
{
|
||||||
_hayes_command_set_status(command, HCS_ERROR);
|
_hayes_command_set_status(command, HCS_ERROR);
|
||||||
|
_hayes_command_callback(command);
|
||||||
|
}
|
||||||
if(sscanf(answer, "%u", &u) != 1)
|
if(sscanf(answer, "%u", &u) != 1)
|
||||||
return;
|
return;
|
||||||
switch(u)
|
switch(u)
|
||||||
@ -3832,9 +3854,10 @@ static void _on_trigger_csq(ModemPlugin * modem, char const * answer)
|
|||||||
return;
|
return;
|
||||||
if(u > 31)
|
if(u > 31)
|
||||||
event->registration.signal = 0.0 / 0.0;
|
event->registration.signal = 0.0 / 0.0;
|
||||||
|
else if(u <= 12)
|
||||||
|
event->registration.signal = 1.0;
|
||||||
else
|
else
|
||||||
/* FIXME check this */
|
event->registration.signal = (32.0 - u) / 20.0;
|
||||||
event->registration.signal = (32.0 - u) / 32.0;
|
|
||||||
/* this is usually worth an event */
|
/* this is usually worth an event */
|
||||||
modem->helper->event(modem->helper->modem, event);
|
modem->helper->event(modem->helper->modem, event);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user