summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTDriver.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/noncore/settings/networksettings2/opietooth2/OTDriver.cpp b/noncore/settings/networksettings2/opietooth2/OTDriver.cpp
index cfd0491..dbc9b97 100644
--- a/noncore/settings/networksettings2/opietooth2/OTDriver.cpp
+++ b/noncore/settings/networksettings2/opietooth2/OTDriver.cpp
@@ -1,208 +1,210 @@
1/*************************************************************************** 1/***************************************************************************
2 * Copyright (C) 2003 by Mattia Merzi * 2 * Copyright (C) 2003 by Mattia Merzi *
3 * ottobit@ferrara.linux.it * 3 * ottobit@ferrara.linux.it *
4 * * 4 * *
5 * This program is free software; you can redistribute it and/or modify * 5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by * 6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or * 7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. * 8 * (at your option) any later version. *
9 ***************************************************************************/ 9 ***************************************************************************/
10 10
11#include <opie2/odebug.h> 11#include <opie2/odebug.h>
12#include <qtimer.h> 12#include <qtimer.h>
13 13
14#include <sys/poll.h> 14#include <sys/poll.h>
15#include <bluezlib.h> 15#include <bluezlib.h>
16 16#ifndef GET_LINK_QUALITY_RP_SIZE
17#define GET_LINK_QUALITY_RP_SIZE READ_LINK_QUALITY_RP_SIZE
18#endif
17#include <OTGateway.h> 19#include <OTGateway.h>
18#include <OTDriver.h> 20#include <OTDriver.h>
19#include <OTHCISocket.h> 21#include <OTHCISocket.h>
20 22
21using namespace Opietooth2; 23using namespace Opietooth2;
22 24
23static struct { 25static struct {
24 const char *str; 26 const char *str;
25 unsigned short rev; 27 unsigned short rev;
26} csr_map[] = { 28} csr_map[] = {
27 { "HCI 11.2 (bc01b)", 114 }, 29 { "HCI 11.2 (bc01b)", 114 },
28 { "HCI 11.3 (bc01b)", 115 }, 30 { "HCI 11.3 (bc01b)", 115 },
29 { "HCI 12.1 (bc01b)", 119 }, 31 { "HCI 12.1 (bc01b)", 119 },
30 { "HCI 12.3 (bc01b)", 134 }, 32 { "HCI 12.3 (bc01b)", 134 },
31 { "HCI 12.7 (bc01b)", 188 }, 33 { "HCI 12.7 (bc01b)", 188 },
32 { "HCI 12.8 (bc01b)", 218 }, 34 { "HCI 12.8 (bc01b)", 218 },
33 { "HCI 12.9 (bc01b)", 283 }, 35 { "HCI 12.9 (bc01b)", 283 },
34 { "HCI 13.10 (bc01b)", 309 }, 36 { "HCI 13.10 (bc01b)", 309 },
35 { "HCI 13.11 (bc01b)", 351 }, 37 { "HCI 13.11 (bc01b)", 351 },
36 { "HCI 16.4 (bc01b)", 523 }, 38 { "HCI 16.4 (bc01b)", 523 },
37 { "HCI 14.3 (bc02x)", 272 }, 39 { "HCI 14.3 (bc02x)", 272 },
38 { "HCI 14.6 (bc02x)", 336 }, 40 { "HCI 14.6 (bc02x)", 336 },
39 { "HCI 14.7 (bc02x)", 373 }, 41 { "HCI 14.7 (bc02x)", 373 },
40 { "HCI 14.8 (bc02x)", 487 }, 42 { "HCI 14.8 (bc02x)", 487 },
41 { "HCI 15.3 (bc02x)", 443 }, 43 { "HCI 15.3 (bc02x)", 443 },
42 { "HCI 16.4 (bc02x)", 525 }, 44 { "HCI 16.4 (bc02x)", 525 },
43 { NULL, 0} 45 { NULL, 0}
44}; 46};
45 47
46static char *services[] = { "Positioning", 48static char *services[] = { "Positioning",
47 "Networking", 49 "Networking",
48 "Rendering", 50 "Rendering",
49 "Capturing", 51 "Capturing",
50 "Object Transfer", 52 "Object Transfer",
51 "Audio", 53 "Audio",
52 "Telephony", 54 "Telephony",
53 "Information" }; 55 "Information" };
54 56
55static char *major_devices[] = { "Miscellaneous", 57static char *major_devices[] = { "Miscellaneous",
56 "Computer", 58 "Computer",
57 "Phone", 59 "Phone",
58 "LAN Access", 60 "LAN Access",
59 "Audio/Video", 61 "Audio/Video",
60 "Peripheral", 62 "Peripheral",
61 "Imaging", 63 "Imaging",
62 "Uncategorized" }; 64 "Uncategorized" };
63 65
64 66
65typedef struct { 67typedef struct {
66 short Minor; 68 short Minor;
67 const char * Description; 69 const char * Description;
68} ClassMap_t; 70} ClassMap_t;
69 71
70static ClassMap_t MapMiscClass[] = { 72static ClassMap_t MapMiscClass[] = {
71 { -1, "" } 73 { -1, "" }
72}; 74};
73 75
74static ClassMap_t MapUnclassifiedClass[] = { 76static ClassMap_t MapUnclassifiedClass[] = {
75 { -1, "" } 77 { -1, "" }
76}; 78};
77 79
78static ClassMap_t MapComputerClass[] = { 80static ClassMap_t MapComputerClass[] = {
79 { 0, "Uncategorized" } , 81 { 0, "Uncategorized" } ,
80 { 1, "Desktop workstation" } , 82 { 1, "Desktop workstation" } ,
81 { 2, "Server" } , 83 { 2, "Server" } ,
82 { 3, "Laptop" } , 84 { 3, "Laptop" } ,
83 { 4, "Handheld" } , 85 { 4, "Handheld" } ,
84 { 5, "Palm" } , 86 { 5, "Palm" } ,
85 { 6, "Wearable" }, 87 { 6, "Wearable" },
86 { -1, 0 } 88 { -1, 0 }
87}; 89};
88 90
89static ClassMap_t MapPhoneClass[] = { 91static ClassMap_t MapPhoneClass[] = {
90 { 0, "Uncategorized" }, 92 { 0, "Uncategorized" },
91 { 1, "Cellular" }, 93 { 1, "Cellular" },
92 { 2, "Cordless" }, 94 { 2, "Cordless" },
93 { 3, "Smart phone" }, 95 { 3, "Smart phone" },
94 { 4, "Wired modem or voice gateway" }, 96 { 4, "Wired modem or voice gateway" },
95 { 5, "Common ISDN Access" }, 97 { 5, "Common ISDN Access" },
96 { 6, "Sim Card Reader" }, 98 { 6, "Sim Card Reader" },
97 { -1, 0 } 99 { -1, 0 }
98}; 100};
99 101
100static ClassMap_t MapAVClass[] = { 102static ClassMap_t MapAVClass[] = {
101 { 0, "Uncategorized" }, 103 { 0, "Uncategorized" },
102 { 1, "Device conforms to the Headset profile" }, 104 { 1, "Device conforms to the Headset profile" },
103 { 2, "Hands-free" }, 105 { 2, "Hands-free" },
104 { 3, 0 }, 106 { 3, 0 },
105 { 4, "Microphone" }, 107 { 4, "Microphone" },
106 { 5, "Loudspeaker" }, 108 { 5, "Loudspeaker" },
107 { 6, "Headphones" }, 109 { 6, "Headphones" },
108 { 7, "Portable Audio" }, 110 { 7, "Portable Audio" },
109 { 8, "Car Audio" }, 111 { 8, "Car Audio" },
110 { 9, "Set-top box" }, 112 { 9, "Set-top box" },
111 { 10, "HiFi Audio Device" }, 113 { 10, "HiFi Audio Device" },
112 { 11, "VCR" }, 114 { 11, "VCR" },
113 { 12, "Video Camera" }, 115 { 12, "Video Camera" },
114 { 13, "Camcorder" }, 116 { 13, "Camcorder" },
115 { 14, "Video Monitor" }, 117 { 14, "Video Monitor" },
116 { 15, "Video Display and Loudspeaker" }, 118 { 15, "Video Display and Loudspeaker" },
117 { 16, "Video Conferencing" }, 119 { 16, "Video Conferencing" },
118 { 17, 0 }, 120 { 17, 0 },
119 { 18, "Gaming/Toy" }, 121 { 18, "Gaming/Toy" },
120 { -1, 0 } 122 { -1, 0 }
121}; 123};
122 124
123static ClassMap_t MapPeripheralClass[] = { 125static ClassMap_t MapPeripheralClass[] = {
124 { 16, "Keyboard" }, 126 { 16, "Keyboard" },
125 { 32, "Pointing device" }, 127 { 32, "Pointing device" },
126 { 48, "Combo keyboard/pointing device" }, 128 { 48, "Combo keyboard/pointing device" },
127 { -1, 0 } 129 { -1, 0 }
128}; 130};
129 131
130typedef struct { 132typedef struct {
131 int Major; 133 int Major;
132 ClassMap_t * Map; 134 ClassMap_t * Map;
133} MainClassMap_t; 135} MainClassMap_t;
134 136
135static MainClassMap_t MainClasses[] = { 137static MainClassMap_t MainClasses[] = {
136 { 0, MapMiscClass }, 138 { 0, MapMiscClass },
137 { 1, MapComputerClass }, 139 { 1, MapComputerClass },
138 { 2, MapPhoneClass }, 140 { 2, MapPhoneClass },
139 { 3, 0 }, // special case 141 { 3, 0 }, // special case
140 { 4, MapAVClass }, 142 { 4, MapAVClass },
141 { 5, MapPeripheralClass }, 143 { 5, MapPeripheralClass },
142 { 6, 0 }, // special case 144 { 6, 0 }, // special case
143 { 63, MapUnclassifiedClass }, 145 { 63, MapUnclassifiedClass },
144 { -1, 0 } 146 { -1, 0 }
145}; 147};
146 148
147OTDriver::OTDriver( OTGateway * _OT, struct hci_dev_info* di) : QObject( _OT ), Address() { 149OTDriver::OTDriver( OTGateway * _OT, struct hci_dev_info* di) : QObject( _OT ), Address() {
148 OT = _OT; 150 OT = _OT;
149 IsUp = 0; 151 IsUp = 0;
150 Socket = 0; 152 Socket = 0;
151 153
152 init(di); 154 init(di);
153 odebug << "Driver " << devname() << oendl; 155 odebug << "Driver " << devname() << oendl;
154 156
155 AutoClose = new QTimer( this ); 157 AutoClose = new QTimer( this );
156 connect( AutoClose, 158 connect( AutoClose,
157 SIGNAL( timeout() ), 159 SIGNAL( timeout() ),
158 this, 160 this,
159 SLOT( SLOT_CloseFd() ) 161 SLOT( SLOT_CloseFd() )
160 ); 162 );
161} 163}
162 164
163OTDriver::~OTDriver() { 165OTDriver::~OTDriver() {
164 closeSocket(); 166 closeSocket();
165 SLOT_CloseFd(); 167 SLOT_CloseFd();
166} 168}
167 169
168void OTDriver::SLOT_CloseFd( void ){ 170void OTDriver::SLOT_CloseFd( void ){
169 if ( isOpen() ) { 171 if ( isOpen() ) {
170 AutoClose->stop(); 172 AutoClose->stop();
171 ::close( fd() ); 173 ::close( fd() );
172 setfd( -1 ); 174 setfd( -1 );
173 } 175 }
174} 176}
175 177
176void OTDriver::init(struct hci_dev_info* di) { 178void OTDriver::init(struct hci_dev_info* di) {
177 179
178 Dev = di->name; 180 Dev = di->name;
179 181
180 setDevId(di->dev_id); 182 setDevId(di->dev_id);
181 setType(di->type); 183 setType(di->type);
182 setFlags(di->flags); 184 setFlags(di->flags);
183 Address.setBDAddr( di->bdaddr ); 185 Address.setBDAddr( di->bdaddr );
184 setFeatures(di->features); 186 setFeatures(di->features);
185 setfd( -1 ); // not open 187 setfd( -1 ); // not open
186 188
187 Manufacturer = ""; 189 Manufacturer = "";
188} 190}
189 191
190// internal reinitialize 192// internal reinitialize
191void OTDriver::reinit() { 193void OTDriver::reinit() {
192 bool Old; 194 bool Old;
193 Old = IsUp; 195 Old = IsUp;
194 196
195 if( currentState() < 0 ) 197 if( currentState() < 0 )
196 return; 198 return;
197 199
198 if( Old != IsUp ) { 200 if( Old != IsUp ) {
199 // state changes 201 // state changes
200 emit stateChange( this, IsUp ); 202 emit stateChange( this, IsUp );
201 } 203 }
202} 204}
203 205
204// requested by application 206// requested by application
205int OTDriver::currentState() { 207int OTDriver::currentState() {
206 struct hci_dev_info di; 208 struct hci_dev_info di;
207 209
208 // uint16_t tmp_dev_id = device_info.dev_id; 210 // uint16_t tmp_dev_id = device_info.dev_id;