From cbffc8d64707828b045b679e8db0269ae362ffcf Mon Sep 17 00:00:00 2001 From: laforge Date: Mon, 23 Oct 2006 20:28:37 +0000 Subject: more gsmd/libgsm implementation git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@114 99fdad57-331a-0410-800a-d7fa5415bdb3 --- src/util/pin.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/util/pin.c (limited to 'src/util/pin.c') diff --git a/src/util/pin.c b/src/util/pin.c new file mode 100644 index 0000000..b855e53 --- /dev/null +++ b/src/util/pin.c @@ -0,0 +1,39 @@ +#include +#include + +#include +#include + +#define PIN_SIZE 32 + +static char *pin; +static char pinbuf[PIN_SIZE+1]; + +static int pin_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux) +{ + int rc; + + printf("EVENT: PIN request (type=%u) ", aux->u.pin.type); + + /* FIXME: read pin from STDIN and send it back via lgsm_pin */ + if (aux->u.pin.type == 1 && pin) { + printf("Auto-responding with pin `%s'\n", pin); + lgsm_pin(lh, pin); + } else { + do { + printf("Please enter PIN: "); + rc = fscanf(stdin, "%32s\n", &pinbuf); + } while (rc < 1); + + return lgsm_pin(lh, pinbuf); + } + + return 0; +} + +int pin_init(struct lgsm_handle *lh, const char *pin_preset) +{ + pin = pin_preset; + return lgsm_evt_handler_register(lh, GSMD_EVT_PIN, &pin_handler); +} + -- cgit v1.2.3