1 ; hacky way to get PIN capability. Proper version should check AT+CPIN?
2 ; first and then decide if PIN is needed at all.
3 ; arekm@maven.pl, 20120409
4 diff -ur ../../test/chan_dongle/at_command.c chan_dongle/at_command.c
5 --- ../../test/chan_dongle/at_command.c 2012-04-26 11:11:01.000000000 +0200
6 +++ chan_dongle/at_command.c 2012-05-09 14:43:39.994983010 +0200
8 ATQ_CMD_DECLARE_ST(CMD_AT_CGMR, cmd8), /* Get software version */
9 ATQ_CMD_DECLARE_ST(CMD_AT_CMEE, cmd9), /* set MS Error Report to 'ERROR' only TODO: change to 1 or 2 and add support in response handlers */
11 + ATQ_CMD_DECLARE_DYNI(CMD_AT_CPIN_NUMBER),
12 ATQ_CMD_DECLARE_ST(CMD_AT_CGSN, cmd10), /* IMEI Read */
13 ATQ_CMD_DECLARE_ST(CMD_AT_CIMI, cmd11), /* IMSI Read */
14 ATQ_CMD_DECLARE_ST(CMD_AT_CPIN, cmd12), /* check is password authentication requirement and the remainder validation times */
19 + char * ptmp0 = NULL;
22 pvt_t * pvt = cpvt->pvt;
25 if(st_cmds[in].cmd == CMD_AT_U2DIAG && CONF_SHARED(pvt, u2diag) == -1)
27 + if(st_cmds[in].cmd == CMD_AT_CPIN_NUMBER && (!CONF_UNIQ(pvt, pin) || !strlen(CONF_UNIQ(pvt, pin))))
30 memcpy(&cmds[out], &st_cmds[in], sizeof(st_cmds[in]));
32 - if(cmds[out].cmd == CMD_AT_U2DIAG)
33 + if(st_cmds[in].cmd == CMD_AT_CPIN_NUMBER) {
34 + err = at_fill_generic_cmd(&cmds[out], "AT+CPIN=\"%s\"\r", CONF_UNIQ(pvt, pin));
37 + ptmp0 = cmds[out].data;
39 + else if(cmds[out].cmd == CMD_AT_U2DIAG)
41 err = at_fill_generic_cmd(&cmds[out], "AT^U2DIAG=%d\r", CONF_SHARED(pvt, u2diag));
44 return at_queue_insert(cpvt, cmds, out, 0);
52 diff -ur ../../test/chan_dongle/at_command.h chan_dongle/at_command.h
53 --- ../../test/chan_dongle/at_command.h 2012-04-26 11:11:01.000000000 +0200
54 +++ chan_dongle/at_command.h 2012-05-08 12:20:28.218759636 +0200
63 diff -ur ../../test/chan_dongle/at_response.c chan_dongle/at_response.c
64 --- ../../test/chan_dongle/at_response.c 2012-04-26 11:11:01.000000000 +0200
65 +++ chan_dongle/at_response.c 2012-05-09 14:39:54.298193606 +0200
70 + case CMD_AT_CPIN_NUMBER:
72 case CMD_AT_CCWA_STATUS:
75 ast_log (LOG_ERROR, "[%s] Getting IMSI number failed\n", PVT_ID(pvt));
78 + case CMD_AT_CPIN_NUMBER:
79 + ast_log (LOG_ERROR, "[%s] Error sending PIN - ignored\n", PVT_ID(pvt));
84 ast_log (LOG_ERROR, "[%s] Error checking PIN state\n", PVT_ID(pvt));
86 diff -ur ../../test/chan_dongle/dc_config.c chan_dongle/dc_config.c
87 --- ../../test/chan_dongle/dc_config.c 2012-04-26 11:11:01.000000000 +0200
88 +++ chan_dongle/dc_config.c 2012-05-09 14:43:14.849045773 +0200
90 const char * data_tty;
95 audio_tty = ast_variable_retrieve (cfg, cat, "audio");
96 data_tty = ast_variable_retrieve (cfg, cat, "data");
97 imei = ast_variable_retrieve (cfg, cat, "imei");
98 imsi = ast_variable_retrieve (cfg, cat, "imsi");
99 + pin = ast_variable_retrieve (cfg, cat, "pin");
101 if(imei && strlen(imei) != IMEI_SIZE) {
102 ast_log (LOG_WARNING, "[%s] Ignore invalid IMEI value '%s'\n", cat, imei);
104 ast_log (LOG_WARNING, "[%s] Ignore invalid IMSI value '%s'\n", cat, imsi);
107 + if(pin && strlen(pin) == 0) {
108 + ast_log (LOG_WARNING, "[%s] Ignore invalid PIN value '%s'\n", cat, pin);
112 if(!audio_tty && !imei && !imsi)
115 ast_copy_string (config->audio_tty, S_OR(audio_tty, ""), sizeof (config->audio_tty));
116 ast_copy_string (config->imei, S_OR(imei, ""), sizeof (config->imei));
117 ast_copy_string (config->imsi, S_OR(imsi, ""), sizeof (config->imsi));
118 + ast_copy_string (config->pin, S_OR(pin, ""), sizeof (config->pin));
122 diff -ur ../../test/chan_dongle/dc_config.h chan_dongle/dc_config.h
123 --- ../../test/chan_dongle/dc_config.h 2012-04-26 11:11:01.000000000 +0200
124 +++ chan_dongle/dc_config.h 2012-05-09 14:41:42.945044440 +0200
126 char data_tty[DEVPATHLEN]; /*!< tty for AT commands */
127 char imei[IMEI_SIZE+1]; /*!< search device by imei */
128 char imsi[IMSI_SIZE+1]; /*!< search device by imsi */
129 + char pin[128]; // how long it can be really?
132 /* all Config settings join in one place */