summaryrefslogtreecommitdiffabout
path: root/gammu/emb/common/device
authorzautrix <zautrix>2004-10-05 11:13:51 (UTC)
committer zautrix <zautrix>2004-10-05 11:13:51 (UTC)
commit50ab40e1e02ad7c65c17a78d08116a808b1257aa (patch) (unidiff)
tree0d1939e2297fa7bbd8e1f2030f154463854164c6 /gammu/emb/common/device
parentcf8616f64f20e5448d4ff644f7cc15750cf3f85f (diff)
downloadkdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.zip
kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.tar.gz
kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.tar.bz2
updated to latest gammu version
Diffstat (limited to 'gammu/emb/common/device') (more/less context) (show whitespace changes)
-rw-r--r--gammu/emb/common/device/bluetoth/bluez.c29
-rw-r--r--gammu/emb/common/device/devfunc.c12
-rw-r--r--gammu/emb/common/device/irda/irda.c8
-rw-r--r--gammu/emb/common/device/irda/irda_unx.h2
-rw-r--r--gammu/emb/common/device/serial/ser_djg.c10
-rw-r--r--gammu/emb/common/device/serial/ser_unx.c36
-rw-r--r--gammu/emb/common/device/serial/ser_w32.c6
7 files changed, 78 insertions, 25 deletions
diff --git a/gammu/emb/common/device/bluetoth/bluez.c b/gammu/emb/common/device/bluetoth/bluez.c
index 8a4807e..e7e8adf 100644
--- a/gammu/emb/common/device/bluetoth/bluez.c
+++ b/gammu/emb/common/device/bluetoth/bluez.c
@@ -1,7 +1,16 @@
1/* Based on work by Marcel Holtmann and other authors of Bluez */ 1/* Based on some work from Bluez (www.bluez.org)
2 * (C) 2000-2001 Qualcomm Incorporated
3 * (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
4 * (C) 2002-2004 Marcel Holtmann <marcel@holtmann.org>
5 * GNU GPL version 2
6 */
7/* based on some Marcel Holtmann work from Gnokii (www.gnokii.org)
8 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
9 * GNU GPL version 2 or later
10 */
2 11
3#include "../../gsmstate.h" 12#include "../../gsmstate.h"
4 13
5#ifdef GSM_ENABLE_BLUETOOTHDEVICE 14#ifdef GSM_ENABLE_BLUETOOTHDEVICE
6#ifdef GSM_ENABLE_BLUEZ 15#ifdef GSM_ENABLE_BLUEZ
7 16
@@ -78,13 +87,13 @@ static void print_service_desc(void *value, void *user)
78 87
79 for (; p; p = p->next, i++) { 88 for (; p; p = p->next, i++) {
80 switch (p->dtd) { 89 switch (p->dtd) {
81 case SDP_UUID16: 90 case SDP_UUID16:
82 case SDP_UUID32: 91 case SDP_UUID32:
83 case SDP_UUID128: 92 case SDP_UUID128:
84 proto = 1;//sdp_uuid_to_proto(&p->val.uuid); 93 proto = sdp_uuid_to_proto(&p->val.uuid);
85 break; 94 break;
86 case SDP_UINT8: 95 case SDP_UINT8:
87 if (proto == RFCOMM_UUID) { 96 if (proto == RFCOMM_UUID) {
88 (*channel) = p->val.uint8; 97 (*channel) = p->val.uint8;
89 return; 98 return;
90 } 99 }
@@ -101,19 +110,19 @@ void print_access_protos(value, user)
101 sdp_list_foreach(protDescSeq,print_service_desc,channel); 110 sdp_list_foreach(protDescSeq,print_service_desc,channel);
102} 111}
103 112
104static GSM_Error bluetooth_checkdevice(GSM_StateMachine *s, bdaddr_t *bdaddr, struct search_context *context) 113static GSM_Error bluetooth_checkdevice(GSM_StateMachine *s, bdaddr_t *bdaddr, struct search_context *context)
105{ 114{
106 sdp_session_t *sess; 115 sdp_session_t *sess;
107 sdp_list_t *attrid, *search, *seq, *next, *proto = 0;
108 uint32_t range = 0x0000ffff;
109 char str[20];
110 sdp_record_t *rec; 116 sdp_record_t *rec;
117 sdp_list_t *attrid, *search, *seq, *next, *proto = 0;
111 sdp_data_t *d; 118 sdp_data_t *d;
112 bdaddr_t interface; 119 bdaddr_t interface;
120 uint32_t range = 0x0000ffff;
113 struct search_context subcontext; 121 struct search_context subcontext;
122 char str[20];
114 int channel,channel2; 123 int channel,channel2;
115 124
116 bacpy(&interface,BDADDR_ANY); 125 bacpy(&interface,BDADDR_ANY);
117 126
118 ba2str(bdaddr, str); 127 ba2str(bdaddr, str);
119 smprintf(s,"%s\n", str); 128 smprintf(s,"%s\n", str);
@@ -139,16 +148,16 @@ static GSM_Error bluetooth_checkdevice(GSM_StateMachine *s, bdaddr_t *bdaddr, st
139 rec = (sdp_record_t *) seq->data; 148 rec = (sdp_record_t *) seq->data;
140 149
141 if (channel2 == -1) { 150 if (channel2 == -1) {
142 if (!context->tree) { 151 if (!context->tree) {
143 d = sdp_data_get(rec,SDP_ATTR_SVCNAME_PRIMARY); 152 d = sdp_data_get(rec,SDP_ATTR_SVCNAME_PRIMARY);
144 153
145 if (false) { 154 if (sdp_get_access_protos(rec,&proto) == 0) {
146 channel = -1; 155 channel = -1;
147 sdp_list_foreach(proto,print_access_protos,&channel); 156 sdp_list_foreach(proto,print_access_protos,&channel);
148 //sdp_list_free(proto,(sdp_free_func_t)sdp_data_free); 157 sdp_list_free(proto,(sdp_free_func_t)sdp_data_free);
149 } 158 }
150 smprintf(s,"Channel %i",channel); 159 smprintf(s,"Channel %i",channel);
151 if (d) smprintf(s," - \"%s\"",d->val.str); 160 if (d) smprintf(s," - \"%s\"",d->val.str);
152 smprintf(s,"\n"); 161 smprintf(s,"\n");
153 if (channel2 == -1 && bluetooth_checkservicename(s, d->val.str) == ERR_NONE) { 162 if (channel2 == -1 && bluetooth_checkservicename(s, d->val.str) == ERR_NONE) {
154 channel2 = channel; 163 channel2 = channel;
@@ -159,31 +168,31 @@ static GSM_Error bluetooth_checkdevice(GSM_StateMachine *s, bdaddr_t *bdaddr, st
159 if (subcontext.group.value.uuid16 != context->group.value.uuid16) bluetooth_checkdevice(s,bdaddr,&subcontext); 168 if (subcontext.group.value.uuid16 != context->group.value.uuid16) bluetooth_checkdevice(s,bdaddr,&subcontext);
160 } 169 }
161 } 170 }
162 171
163 next = seq->next; 172 next = seq->next;
164 free(seq); 173 free(seq);
165 //sdp_record_free(rec); 174 sdp_record_free(rec);
166 } 175 }
167 sdp_close(sess); 176 sdp_close(sess);
168 177
169 if (channel2 != -1) return bluetooth_connect(s, channel2, str); 178 if (channel2 != -1) return bluetooth_connect(s, channel2, str);
170 179
171 return ERR_UNKNOWN; 180 return ERR_NOTSUPPORTED;
172} 181}
173 182
174GSM_Error bluetooth_findchannel(GSM_StateMachine *s) 183GSM_Error bluetooth_findchannel(GSM_StateMachine *s)
175{ 184{
176 inquiry_info ii[20]; 185 inquiry_info ii[20];
177 uint8_t count = 0; 186 uint8_t count = 0;
178 int i; 187 int i;
179 struct search_context context; 188 struct search_context context;
180 GSM_Error error = ERR_NOTSUPPORTED; 189 GSM_Error error = ERR_NOTSUPPORTED;
181 190
182 memset(&context, '\0', sizeof(struct search_context)); 191 memset(&context, '\0', sizeof(struct search_context));
183 //sdp_uuid16_create(&(context.group),PUBLIC_BROWSE_GROUP); 192 sdp_uuid16_create(&(context.group),PUBLIC_BROWSE_GROUP);
184 193
185 if (!strcmp(s->CurrentConfig->Device,"/dev/ttyS1")) { 194 if (!strcmp(s->CurrentConfig->Device,"/dev/ttyS1")) {
186 dbgprintf("Searching for devices\n"); 195 dbgprintf("Searching for devices\n");
187 if (sdp_general_inquiry(ii, 20, 8, &count) < 0) { 196 if (sdp_general_inquiry(ii, 20, 8, &count) < 0) {
188 return ERR_UNKNOWN; 197 return ERR_UNKNOWN;
189 } 198 }
diff --git a/gammu/emb/common/device/devfunc.c b/gammu/emb/common/device/devfunc.c
index d31ebbf..c58a01f 100644
--- a/gammu/emb/common/device/devfunc.c
+++ b/gammu/emb/common/device/devfunc.c
@@ -1,6 +1,14 @@
1/* Some source from Gnokii (www.gnokii.org)
2 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
3 * GNU GPL version 2 or later
4 */
5/* Some source from Minicom (http://alioth.debian.org/projects/minicom)
6 * (C) 1991,1992,1993,1994,1995,1996 by Miquel van Smoorenburg
7 * GNU GPL version 2
8 */
1 9
2#include <string.h> 10#include <string.h>
3#ifdef WIN32 11#ifdef WIN32
4# include <io.h> 12# include <io.h>
5#else 13#else
6# include <errno.h> 14# include <errno.h>
@@ -102,13 +110,13 @@ bool unlock_device(char **lock_file)
102 110
103/* Lock the device. Allocated string with a lock name is returned 111/* Lock the device. Allocated string with a lock name is returned
104 * in lock_device 112 * in lock_device
105 */ 113 */
106GSM_Error lock_device(const char* port, char **lock_device) 114GSM_Error lock_device(const char* port, char **lock_device)
107{ 115{
108#ifndef WIN32 116#if !defined(WIN32) && !defined(DJGPP)
109 char *lock_file = NULL; 117 char *lock_file = NULL;
110 char buffer[max_buf_len]; 118 char buffer[max_buf_len];
111 const char *aux; 119 const char *aux;
112 int fd, len; 120 int fd, len;
113 GSM_Errorerror = ERR_NONE; 121 GSM_Errorerror = ERR_NONE;
114 122
@@ -215,13 +223,13 @@ failed:
215#endif 223#endif
216} 224}
217 225
218/* Removes lock and frees memory */ 226/* Removes lock and frees memory */
219bool unlock_device(char **lock_file) 227bool unlock_device(char **lock_file)
220{ 228{
221#ifndef WIN32 229#if !defined(WIN32) && !defined(DJGPP)
222 int err; 230 int err;
223 231
224 if (!lock_file) { 232 if (!lock_file) {
225 dbgprintf("Cannot unlock device\n"); 233 dbgprintf("Cannot unlock device\n");
226 return false; 234 return false;
227 } 235 }
diff --git a/gammu/emb/common/device/irda/irda.c b/gammu/emb/common/device/irda/irda.c
index fef50ac..e680377 100644
--- a/gammu/emb/common/device/irda/irda.c
+++ b/gammu/emb/common/device/irda/irda.c
@@ -1,9 +1,13 @@
1/* (c) 2001-2004 by Marcin Wiacek */ 1/* (c) 2001-2004 by Marcin Wiacek */
2/* based on some work from Ralf Thelen and MyGnokii */ 2/* based on some work from Ralf Thelen and MyGnokii (www.mwiacek.com) */
3/* based on some work from Gnokii and MSDN */ 3/* based on some work from MSDN */
4/* based on some work from Gnokii (www.gnokii.org)
5 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
6 * GNU GPL version 2 or later
7 */
4 8
5/* You have to include wsock32.lib library to MS VC project to compile it */ 9/* You have to include wsock32.lib library to MS VC project to compile it */
6 10
7#include "../../gsmstate.h" 11#include "../../gsmstate.h"
8 12
9#ifdef GSM_ENABLE_IRDADEVICE 13#ifdef GSM_ENABLE_IRDADEVICE
diff --git a/gammu/emb/common/device/irda/irda_unx.h b/gammu/emb/common/device/irda/irda_unx.h
index 8dbcb97..7a55273 100644
--- a/gammu/emb/common/device/irda/irda_unx.h
+++ b/gammu/emb/common/device/irda/irda_unx.h
@@ -1,7 +1,7 @@
1/* part of irda.h available in Linux kernel source */ 1/* part of irda.h available in Linux kernel source (www.kernel.org) */
2 2
3/********************************************************************* 3/*********************************************************************
4 * 4 *
5 * Filename: irda.h 5 * Filename: irda.h
6 * Version: 6 * Version:
7 * Description: 7 * Description:
diff --git a/gammu/emb/common/device/serial/ser_djg.c b/gammu/emb/common/device/serial/ser_djg.c
index ac9d7c8..2524187 100644
--- a/gammu/emb/common/device/serial/ser_djg.c
+++ b/gammu/emb/common/device/serial/ser_djg.c
@@ -8,41 +8,41 @@
8#include "ser_djg.h" 8#include "ser_djg.h"
9 9
10static GSM_Error serial_close(GSM_StateMachine *s) 10static GSM_Error serial_close(GSM_StateMachine *s)
11{ 11{
12 GSM_Device_SerialData *d = &s->Device.Data.Serial; 12 GSM_Device_SerialData *d = &s->Device.Data.Serial;
13 13
14 return ERR_NONE; 14 return ERR_NOTIMPLEMENTED;
15} 15}
16 16
17static GSM_Error serial_open (GSM_StateMachine *s) 17static GSM_Error serial_open (GSM_StateMachine *s)
18{ 18{
19 GSM_Device_SerialData *d = &s->Device.Data.Serial; 19 GSM_Device_SerialData *d = &s->Device.Data.Serial;
20 20
21 return ERR_NONE; 21 return ERR_NOTIMPLEMENTED;
22} 22}
23 23
24static GSM_Error serial_setparity(GSM_StateMachine *s, bool parity) 24static GSM_Error serial_setparity(GSM_StateMachine *s, bool parity)
25{ 25{
26 GSM_Device_SerialData *d = &s->Device.Data.Serial; 26 GSM_Device_SerialData *d = &s->Device.Data.Serial;
27 27
28 return ERR_NONE; 28 return ERR_NOTIMPLEMENTED;
29} 29}
30 30
31static GSM_Error serial_setdtrrts(GSM_StateMachine *s, bool dtr, bool rts) 31static GSM_Error serial_setdtrrts(GSM_StateMachine *s, bool dtr, bool rts)
32{ 32{
33 GSM_Device_SerialData *d = &s->Device.Data.Serial; 33 GSM_Device_SerialData *d = &s->Device.Data.Serial;
34 34
35 return ERR_NONE; 35 return ERR_NOTIMPLEMENTED;
36} 36}
37 37
38static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed) 38static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed)
39{ 39{
40 GSM_Device_SerialData *d = &s->Device.Data.Serial; 40 GSM_Device_SerialData *d = &s->Device.Data.Serial;
41 41
42 return ERR_NONE; 42 return ERR_NOTIMPLEMENTED;
43} 43}
44 44
45static int serial_read(GSM_StateMachine *s, void *buf, size_t nbytes) 45static int serial_read(GSM_StateMachine *s, void *buf, size_t nbytes)
46{ 46{
47 GSM_Device_SerialData *d = &s->Device.Data.Serial; 47 GSM_Device_SerialData *d = &s->Device.Data.Serial;
48 48
diff --git a/gammu/emb/common/device/serial/ser_unx.c b/gammu/emb/common/device/serial/ser_unx.c
index 2a87b11..69c7515 100644
--- a/gammu/emb/common/device/serial/ser_unx.c
+++ b/gammu/emb/common/device/serial/ser_unx.c
@@ -1,8 +1,12 @@
1/* (c) 2002-2004 by Marcin Wiacek */ 1/* (c) 2002-2004 by Marcin Wiacek */
2/* locking device and settings all speeds by Michal Cihar */ 2/* locking device and settings all speeds by Michal Cihar */
3/* based on some work from Gnokii (www.gnokii.org)
4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
5 * GNU GPL version 2 or later
6 */
3 7
4#include "../../gsmstate.h" 8#include "../../gsmstate.h"
5 9
6#ifdef GSM_ENABLE_SERIALDEVICE 10#ifdef GSM_ENABLE_SERIALDEVICE
7#ifndef WIN32 11#ifndef WIN32
8#ifndef DJGPP 12#ifndef DJGPP
@@ -13,12 +17,36 @@
13#include <termios.h> 17#include <termios.h>
14#include <errno.h> 18#include <errno.h>
15 19
16#include "../../gsmcomon.h" 20#include "../../gsmcomon.h"
17#include "ser_unx.h" 21#include "ser_unx.h"
18 22
23#ifndef O_NONBLOCK
24# define O_NONBLOCK 0
25#endif
26
27#ifdef __NetBSD__
28# define FNONBLOCK O_NONBLOCK
29
30# define B57600 0010001
31# define B115200 0010002
32# define B230400 0010003
33# define B460800 0010004
34# define B500000 0010005
35# define B576000 0010006
36# define B921600 0010007
37# define B1000000 0010010
38# define B1152000 0010011
39# define B1500000 0010012
40# define B2000000 0010013
41# define B2500000 0010014
42# define B3000000 0010015
43# define B3500000 0010016
44# define B4000000 0010017
45#endif
46
19static GSM_Error serial_close(GSM_StateMachine *s) 47static GSM_Error serial_close(GSM_StateMachine *s)
20{ 48{
21 GSM_Device_SerialData *d = &s->Device.Data.Serial; 49 GSM_Device_SerialData *d = &s->Device.Data.Serial;
22 50
23 /* Restores old settings */ 51 /* Restores old settings */
24 tcsetattr(d->hPhone, TCSANOW, &d->old_settings); 52 tcsetattr(d->hPhone, TCSANOW, &d->old_settings);
@@ -26,16 +54,12 @@ static GSM_Error serial_close(GSM_StateMachine *s)
26 /* Closes device */ 54 /* Closes device */
27 close(d->hPhone); 55 close(d->hPhone);
28 56
29 return ERR_NONE; 57 return ERR_NONE;
30} 58}
31 59
32#ifndef O_NONBLOCK
33# define O_NONBLOCK 0
34#endif
35
36static GSM_Error serial_open (GSM_StateMachine *s) 60static GSM_Error serial_open (GSM_StateMachine *s)
37{ 61{
38 GSM_Device_SerialData *d = &s->Device.Data.Serial; 62 GSM_Device_SerialData *d = &s->Device.Data.Serial;
39 struct termios t; 63 struct termios t;
40 int i; 64 int i;
41 65
@@ -199,27 +223,31 @@ static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed)
199 case 1800: speed2 = B1800; break; 223 case 1800: speed2 = B1800; break;
200 case 2400: speed2 = B2400; break; 224 case 2400: speed2 = B2400; break;
201 case 4800: speed2 = B4800; break; 225 case 4800: speed2 = B4800; break;
202 case 9600: speed2 = B9600; break; 226 case 9600: speed2 = B9600; break;
203 case 19200: speed2 = B19200;break; 227 case 19200: speed2 = B19200;break;
204 case 38400: speed2 = B38400;break; 228 case 38400: speed2 = B38400;break;
229#ifdef B57600
205 case 57600: speed2 = B57600;break; 230 case 57600: speed2 = B57600;break;
206 case 115200: speed2 = B115200;break; 231 case 115200: speed2 = B115200;break;
207 case 230400: speed2 = B230400;break; 232 case 230400: speed2 = B230400;break;
208 case 460800: speed2 = B460800;break; 233 case 460800: speed2 = B460800;break;
234#ifdef B500000
209 case 500000: speed2 = B500000;break; 235 case 500000: speed2 = B500000;break;
210 case 576000: speed2 = B576000;break; 236 case 576000: speed2 = B576000;break;
211 case 921600: speed2 = B921600;break; 237 case 921600: speed2 = B921600;break;
212 case 1000000: speed2 = B1000000;break; 238 case 1000000: speed2 = B1000000;break;
213 case 1152000: speed2 = B1152000;break; 239 case 1152000: speed2 = B1152000;break;
214 case 1500000: speed2 = B1500000;break; 240 case 1500000: speed2 = B1500000;break;
215 case 2000000: speed2 = B2000000;break; 241 case 2000000: speed2 = B2000000;break;
216 case 2500000: speed2 = B2500000;break; 242 case 2500000: speed2 = B2500000;break;
217 case 3000000: speed2 = B3000000;break; 243 case 3000000: speed2 = B3000000;break;
218 case 3500000: speed2 = B3500000;break; 244 case 3500000: speed2 = B3500000;break;
219 case 4000000: speed2 = B4000000; break; 245 case 4000000: speed2 = B4000000; break;
246#endif
247#endif
220 } 248 }
221 249
222 /* This should work on all systems because it is done according to POSIX */ 250 /* This should work on all systems because it is done according to POSIX */
223 cfsetispeed(&t, speed2); 251 cfsetispeed(&t, speed2);
224 cfsetospeed(&t, speed2); 252 cfsetospeed(&t, speed2);
225 253
diff --git a/gammu/emb/common/device/serial/ser_w32.c b/gammu/emb/common/device/serial/ser_w32.c
index 9fa0135..7d88fc7 100644
--- a/gammu/emb/common/device/serial/ser_w32.c
+++ b/gammu/emb/common/device/serial/ser_w32.c
@@ -1,8 +1,12 @@
1/* (c) 2002-2004 by Marcin Wiacek */ 1/* (c) 2002-2004 by Marcin Wiacek */
2/* based on some work from Gnokii, MSDN and others */ 2/* based on some work from MSDN and others */
3/* based on some work from Gnokii (www.gnokii.org)
4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
5 * GNU GPL version 2 or later
6 */
3 7
4#include "../../gsmstate.h" 8#include "../../gsmstate.h"
5 9
6#ifdef GSM_ENABLE_SERIALDEVICE 10#ifdef GSM_ENABLE_SERIALDEVICE
7#ifdef WIN32 11#ifdef WIN32
8 12