author | zautrix <zautrix> | 2004-10-05 11:13:51 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-05 11:13:51 (UTC) |
commit | 50ab40e1e02ad7c65c17a78d08116a808b1257aa (patch) (unidiff) | |
tree | 0d1939e2297fa7bbd8e1f2030f154463854164c6 /gammu/emb/common/device/bluetoth/bluez.c | |
parent | cf8616f64f20e5448d4ff644f7cc15750cf3f85f (diff) | |
download | kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.zip kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.tar.gz kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.tar.bz2 |
updated to latest gammu version
Diffstat (limited to 'gammu/emb/common/device/bluetoth/bluez.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | gammu/emb/common/device/bluetoth/bluez.c | 29 |
1 files changed, 19 insertions, 10 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 | ||
104 | static GSM_Error bluetooth_checkdevice(GSM_StateMachine *s, bdaddr_t *bdaddr, struct search_context *context) | 113 | static 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 | ||
174 | GSM_Error bluetooth_findchannel(GSM_StateMachine *s) | 183 | GSM_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 | } |