author | zautrix <zautrix> | 2004-08-07 17:24:40 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-07 17:24:40 (UTC) |
commit | 88b0d33b8b0b1f6ae320cfc863ca6a47fa8fec22 (patch) (unidiff) | |
tree | 6331418973714243beb674abc87692277b83869d /gammu/emb/common/device/bluetoth/bluetoth.c | |
parent | ef8a09ce74ad3f0a51484d03fdf009bd5b3677bf (diff) | |
download | kdepimpi-88b0d33b8b0b1f6ae320cfc863ca6a47fa8fec22.zip kdepimpi-88b0d33b8b0b1f6ae320cfc863ca6a47fa8fec22.tar.gz kdepimpi-88b0d33b8b0b1f6ae320cfc863ca6a47fa8fec22.tar.bz2 |
Initial revision
Diffstat (limited to 'gammu/emb/common/device/bluetoth/bluetoth.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | gammu/emb/common/device/bluetoth/bluetoth.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/gammu/emb/common/device/bluetoth/bluetoth.c b/gammu/emb/common/device/bluetoth/bluetoth.c new file mode 100644 index 0000000..c20e04b --- a/dev/null +++ b/gammu/emb/common/device/bluetoth/bluetoth.c | |||
@@ -0,0 +1,85 @@ | |||
1 | /* (c) 2003-2004 by Marcin Wiacek and Marcel Holtmann and others */ | ||
2 | |||
3 | #include "../../gsmstate.h" | ||
4 | |||
5 | #ifdef GSM_ENABLE_BLUETOOTHDEVICE | ||
6 | #ifndef DJGPP | ||
7 | |||
8 | #include <stdlib.h> | ||
9 | #include <stdio.h> | ||
10 | #include <fcntl.h> | ||
11 | #include <errno.h> | ||
12 | #include <string.h> | ||
13 | |||
14 | #include "../../misc/coding/coding.h" | ||
15 | #include "../../gsmcomon.h" | ||
16 | #include "../devfunc.h" | ||
17 | #include "bluetoth.h" | ||
18 | |||
19 | #ifdef GSM_ENABLE_BLUEZ | ||
20 | # include "bluez.h" | ||
21 | #endif | ||
22 | #ifdef GSM_ENABLE_AFFIX | ||
23 | # include "affix.h" | ||
24 | #endif | ||
25 | #ifdef WIN32 | ||
26 | # include "blue_w32.h" | ||
27 | #endif | ||
28 | |||
29 | GSM_Error bluetooth_findrfchannel(GSM_StateMachine *s) | ||
30 | { | ||
31 | GSM_Error error; | ||
32 | |||
33 | #ifdef BLUETOOTH_RF_SEARCHING | ||
34 | if (!mystrncasecmp(s->CurrentConfig->Connection, "bluerf", 6)) return bluetooth_findchannel(s); | ||
35 | #endif | ||
36 | |||
37 | switch (s->ConnectionType) { | ||
38 | case GCT_BLUEAT: | ||
39 | return bluetooth_connect(s,1,s->CurrentConfig->Device); | ||
40 | case GCT_BLUEOBEX: | ||
41 | return bluetooth_connect(s,9,s->CurrentConfig->Device); | ||
42 | case GCT_BLUEPHONET: | ||
43 | error = bluetooth_connect(s,14,s->CurrentConfig->Device); //older Series 40 - 8910, 6310 | ||
44 | if (error == ERR_NONE) return error; | ||
45 | return bluetooth_connect(s,15,s->CurrentConfig->Device); //new Series 40 - 6310i, 6230 | ||
46 | default: | ||
47 | return ERR_UNKNOWN; | ||
48 | } | ||
49 | } | ||
50 | |||
51 | static int bluetooth_read(GSM_StateMachine *s, void *buf, size_t nbytes) | ||
52 | { | ||
53 | return socket_read(s, buf, nbytes, s->Device.Data.BlueTooth.hPhone); | ||
54 | } | ||
55 | |||
56 | #ifdef WIN32 | ||
57 | static int bluetooth_write(GSM_StateMachine *s, unsigned char *buf, size_t nbytes) | ||
58 | #else | ||
59 | static int bluetooth_write(GSM_StateMachine *s, void *buf, size_t nbytes) | ||
60 | #endif | ||
61 | { | ||
62 | return socket_write(s, buf, nbytes, s->Device.Data.BlueTooth.hPhone); | ||
63 | } | ||
64 | |||
65 | static GSM_Error bluetooth_close(GSM_StateMachine *s) | ||
66 | { | ||
67 | return socket_close(s, s->Device.Data.BlueTooth.hPhone); | ||
68 | } | ||
69 | |||
70 | GSM_Device_Functions BlueToothDevice = { | ||
71 | bluetooth_findrfchannel, | ||
72 | bluetooth_close, | ||
73 | NONEFUNCTION, | ||
74 | NONEFUNCTION, | ||
75 | NONEFUNCTION, | ||
76 | bluetooth_read, | ||
77 | bluetooth_write | ||
78 | }; | ||
79 | |||
80 | #endif | ||
81 | #endif | ||
82 | |||
83 | /* How should editor hadle tabs in this file? Add editor commands here. | ||
84 | * vim: noexpandtab sw=8 ts=8 sts=8: | ||
85 | */ | ||