7 A Linux/Unix toolset and driver for Nokia mobile phones.
9 Copyright (C) 1999, 2000 Hugh Blemings & Pavel JanÃk ml.
11 Released under the terms of the GNU GPL, see file COPYING for more details.
14 Revision 1.1.1.2 2002/04/03 01:44:15 short
15 Implemented connection type "tcp" (GCT_TCP), use <hostname>:<port> as "port"
17 Revision 1.1.1.1 2001/11/25 21:58:58 short
18 :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
20 Revision 1.11 2001/09/14 12:15:28 pkot
21 Cleanups from 0.3.3 (part1)
23 Revision 1.10 2001/08/20 23:27:37 pkot
24 Add hardware shakehand to the link layer (Manfred Jonsson)
26 Revision 1.9 2001/06/28 00:28:45 pkot
27 Small docs updates (Pawel Kot)
29 Revision 1.8 2001/02/21 19:56:55 chris
30 More fiddling with the directory layout
32 Revision 1.7 2001/02/09 18:12:53 chris
33 Marcel's tekram support
35 Revision 1.6 2001/02/03 23:56:12 chris
36 Start of work on irda support (now we just need fbus-irda.c!)
37 Proper unicode support in 7110 code (from pkot)
44 #include "devices/unixserial.h"
45 #include "devices/unixirda.h"
46 #include "devices/tekram.h"
47 #include "devices/tcp.h"
51 * Structure to store the filedescriptor we use.
55 int device_portfd = -1;
57 /* The device type to use */
59 GSM_ConnectionType devicetype;
61 int device_getfd(void) {
66 int device_open(__const char *__file, int __with_odd_parity, int __with_async, int __with_hw_handshake, GSM_ConnectionType device_type)
68 devicetype = device_type;
73 device_portfd = serial_opendevice(__file, __with_odd_parity, __with_async, __with_hw_handshake);
76 device_portfd = tekram_open(__file);
79 device_portfd = irda_open();
82 device_portfd = tcp_opendevice(__file, __with_async);
87 return (device_portfd >= 0);
90 void device_close(void)
95 serial_close(device_portfd);
98 tekram_close(device_portfd);
101 irda_close(device_portfd);
104 tcp_close(device_portfd);
111 void device_reset(void)
115 void device_setdtrrts(int __dtr, int __rts)
117 switch (devicetype) {
120 serial_setdtrrts(device_portfd, __dtr, __rts);
133 void device_changespeed(int __speed)
135 switch (devicetype) {
138 serial_changespeed(device_portfd, __speed);
141 tekram_changespeed(device_portfd, __speed);
152 size_t device_read(__ptr_t __buf, size_t __nbytes)
154 switch (devicetype) {
157 return (serial_read(device_portfd, __buf, __nbytes));
160 return (tekram_read(device_portfd, __buf, __nbytes));
163 return irda_read(device_portfd, __buf, __nbytes);
166 return tcp_read(device_portfd, __buf, __nbytes);
174 size_t device_write(__const __ptr_t __buf, size_t __n)
176 switch (devicetype) {
179 return (serial_write(device_portfd, __buf, __n));
182 return (tekram_write(device_portfd, __buf, __n));
185 return irda_write(device_portfd, __buf, __n);
188 return tcp_write(device_portfd, __buf, __n);
196 int device_select(struct timeval *timeout)
198 switch (devicetype) {
201 return serial_select(device_portfd, timeout);
204 return tekram_select(device_portfd, timeout);
207 return irda_select(device_portfd, timeout);
210 return tcp_select(device_portfd, timeout);