1414#endif
1515#define MODEM "/dev/ttyUSB1"
1616#define SPEED 236800
17- // #define APN "gprs.base.be"
17+ /* #define APN "gprs.base.be" */
1818#define APN "web.be"
1919#define PASSWD "web"
20- // #define DEBUG_FLOW
20+ /* #define DEBUG_FLOW */
2121static int fd = -1 ;
2222static int idx ;
2323static int ping_on = 0 ;
2424static struct pico_device * ppp = NULL ;
2525
2626static void sigusr1_hdl (int signo )
2727{
28- fprintf (stderr , "SIGUSR1: Connecting!\n" );
29- if (ppp )
30- pico_ppp_connect (ppp );
28+ fprintf (stderr , "SIGUSR1: Connecting!\n" );
29+ if (ppp )
30+ pico_ppp_connect (ppp );
3131}
3232
3333static void sigusr2_hdl (int signo )
3434{
35- fprintf (stderr , "SIGUSR2/SIGINT: Disconnecting!\n" );
36- if (ppp )
37- pico_ppp_disconnect (ppp );
38- if (signo == SIGINT )
39- exit (0 );
35+ fprintf (stderr , "SIGUSR2/SIGINT: Disconnecting!\n" );
36+ if (ppp )
37+ pico_ppp_disconnect (ppp );
38+
39+ if (signo == SIGINT )
40+ exit (0 );
4041}
4142
4243#ifdef PICO_SUPPORT_POLARSSL
@@ -68,6 +69,7 @@ int modem_read(struct pico_device *dev, void *data, int len)
6869 }
6970 printf ("\n" );
7071 }
72+
7173#endif
7274
7375 return r ;
@@ -92,10 +94,13 @@ int modem_set_speed(struct pico_device *dev, uint32_t speed)
9294 struct termios term ;
9395 if (tcgetattr (fd , & term ) != 0 )
9496 return 6 ;
97+
9598 if (cfsetspeed (& term , B115200 ) != 0 )
9699 return 7 ;
100+
97101 if (tcsetattr (fd , TCSANOW , & term ) != 0 )
98102 return 8 ;
103+
99104 printf ("Speed set to 115200.\n" );
100105 return 0 ;
101106}
@@ -116,7 +121,7 @@ static void cb_sock(uint16_t ev, struct pico_socket *s)
116121
117122}
118123
119- static void ping (void )
124+ static void ping (void )
120125{
121126 struct pico_socket * s ;
122127 struct pico_ip4 dst ;
@@ -136,8 +141,10 @@ int main(int argc, const char *argv[])
136141
137142 if (argc > 1 )
138143 path = argv [1 ];
144+
139145 if (argc > 2 )
140146 apn = argv [2 ];
147+
141148 if (argc > 3 )
142149 passwd = argv [3 ];
143150
@@ -157,7 +164,7 @@ int main(int argc, const char *argv[])
157164
158165 ppp = pico_ppp_create ();
159166 if (!ppp )
160- return 2 ;
167+ return 2 ;
161168
162169 pico_ppp_set_serial_read (ppp , modem_read );
163170 pico_ppp_set_serial_write (ppp , modem_write );
@@ -176,5 +183,4 @@ int main(int argc, const char *argv[])
176183 ping ();
177184 }
178185 }
179-
180186}
0 commit comments