]> git.pld-linux.org Git - packages/asterisk-chan_dongle.git/blob - chan_dongle-pin.patch
- up to 20161221 snap
[packages/asterisk-chan_dongle.git] / chan_dongle-pin.patch
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
7 @@ -148,6 +148,7 @@
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 */
10  
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 */
15 @@ -173,6 +174,7 @@
16         unsigned in, out;
17         int begin = -1;
18         int err;
19 +       char * ptmp0 = NULL;
20         char * ptmp1 = NULL;
21         char * ptmp2 = NULL;
22         pvt_t * pvt = cpvt->pvt;
23 @@ -193,10 +195,18 @@
24                         continue;
25                 if(st_cmds[in].cmd == CMD_AT_U2DIAG && CONF_SHARED(pvt, u2diag) == -1)
26                         continue;
27 +               if(st_cmds[in].cmd == CMD_AT_CPIN_NUMBER && (!CONF_UNIQ(pvt, pin) || !strlen(CONF_UNIQ(pvt, pin))))
28 +                       continue;
29  
30                 memcpy(&cmds[out], &st_cmds[in], sizeof(st_cmds[in]));
31  
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));
35 +                       if (err)
36 +                               goto failure;
37 +                       ptmp0 = cmds[out].data;
38 +               }
39 +               else if(cmds[out].cmd == CMD_AT_U2DIAG)
40                 {
41                         err = at_fill_generic_cmd(&cmds[out], "AT^U2DIAG=%d\r", CONF_SHARED(pvt, u2diag));
42                         if(err)
43 @@ -219,6 +229,8 @@
44                 return at_queue_insert(cpvt, cmds, out, 0);
45         return 0;
46  failure:
47 +       if(ptmp0)
48 +               ast_free(ptmp0);
49         if(ptmp1)
50                 ast_free(ptmp1);
51         if(ptmp2)
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
55 @@ -43,6 +43,7 @@
56  
57         CMD_AT_COPS,
58         CMD_AT_COPS_INIT,
59 +       CMD_AT_CPIN_NUMBER,
60         CMD_AT_CPIN,
61         CMD_AT_CPMS,
62  
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
66 @@ -135,6 +135,7 @@
67                         case CMD_AT_CGSN:
68                         case CMD_AT_CIMI:
69                         case CMD_AT_CPIN:
70 +                       case CMD_AT_CPIN_NUMBER:
71                         case CMD_AT_CCWA_SET:
72                         case CMD_AT_CCWA_STATUS:
73                         case CMD_AT_CHLD_2:
74 @@ -364,6 +365,11 @@
75                                 ast_log (LOG_ERROR, "[%s] Getting IMSI number failed\n", PVT_ID(pvt));
76                                 goto e_return;
77  
78 +                       case CMD_AT_CPIN_NUMBER:
79 +                               ast_log (LOG_ERROR, "[%s] Error sending PIN - ignored\n", PVT_ID(pvt));
80 +                               break;
81 +                               //goto e_return;
82 +
83                         case CMD_AT_CPIN:
84                                 ast_log (LOG_ERROR, "[%s] Error checking PIN state\n", PVT_ID(pvt));
85                                 goto e_return;
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
89 @@ -32,11 +32,13 @@
90         const char * data_tty;
91         const char * imei;
92         const char * imsi;
93 +       const char * pin;
94  
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");
100  
101         if(imei && strlen(imei) != IMEI_SIZE) {
102                 ast_log (LOG_WARNING, "[%s] Ignore invalid IMEI value '%s'\n", cat, imei);
103 @@ -46,6 +48,10 @@
104                 ast_log (LOG_WARNING, "[%s] Ignore invalid IMSI value '%s'\n", cat, imsi);
105                 imsi = NULL;
106                 }
107 +       if(pin && strlen(pin) == 0) {
108 +               ast_log (LOG_WARNING, "[%s] Ignore invalid PIN value '%s'\n", cat, pin);
109 +               pin = NULL;
110 +               }
111  
112         if(!audio_tty && !imei && !imsi)
113         {
114 @@ -70,6 +76,7 @@
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));
119  
120         return 0;
121  }
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
125 @@ -109,6 +109,7 @@
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?
130  } dc_uconfig_t;
131  
132  /* all Config settings join in one place */
133
This page took 0.176399 seconds and 3 git commands to generate.