View Javadoc

1   /**
2    *  BlueCove - Java library for Bluetooth
3    *  Copyright (C) 2007-2008 Vlad Skarzhevskyy
4    *
5    *  This library is free software; you can redistribute it and/or
6    *  modify it under the terms of the GNU Lesser General Public
7    *  License as published by the Free Software Foundation; either
8    *  version 2.1 of the License, or (at your option) any later version.
9    *
10   *  This library is distributed in the hope that it will be useful,
11   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   *  Lesser General Public License for more details.
14   *
15   *  You should have received a copy of the GNU Lesser General Public
16   *  License along with this library; if not, write to the Free Software
17   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   *
19   *  @version $Id: BluetoothStackToshiba.java 2136 2008-04-30 16:37:53Z skarzhevskyy $
20   */
21  package com.intel.bluetooth;
22  
23  import java.io.IOException;
24  
25  import javax.bluetooth.BluetoothStateException;
26  import javax.bluetooth.DeviceClass;
27  import javax.bluetooth.DiscoveryListener;
28  import javax.bluetooth.RemoteDevice;
29  import javax.bluetooth.ServiceRegistrationException;
30  import javax.bluetooth.UUID;
31  
32  class BluetoothStackToshiba implements BluetoothStack, DeviceInquiryRunnable, SearchServicesRunnable {
33  
34  	private boolean initialized = false;
35  
36  	BluetoothStackToshiba() {
37  
38  	}
39  
40  	// ---------------------- Library initialization
41  
42  	public String getStackID() {
43  		return BlueCoveImpl.STACK_TOSHIBA;
44  	}
45  
46  	public String toString() {
47  		return getStackID();
48  	}
49  
50  	/*
51  	 * (non-Javadoc)
52  	 * 
53  	 * @see com.intel.bluetooth.BluetoothStack#getFeatureSet()
54  	 */
55  	public int getFeatureSet() {
56  		return 0;
57  	}
58  
59  	/*
60  	 * (non-Javadoc)
61  	 * 
62  	 * @see com.intel.bluetooth.BluetoothStack#isNativeCodeLoaded()
63  	 */
64  	public native boolean isNativeCodeLoaded();
65  
66  	/*
67  	 * (non-Javadoc)
68  	 * 
69  	 * @see com.intel.bluetooth.BluetoothStack#requireNativeLibraries()
70  	 */
71  	public LibraryInformation[] requireNativeLibraries() {
72  		return LibraryInformation.library(BlueCoveImpl.NATIVE_LIB_TOSHIBA);
73  	}
74  
75  	public native int getLibraryVersion();
76  
77  	public native int detectBluetoothStack();
78  
79  	public native void enableNativeDebug(Class nativeDebugCallback, boolean on);
80  
81  	private native boolean initializeImpl() throws BluetoothStateException;
82  
83  	private native void destroyImpl();
84  
85  	public void initialize() throws BluetoothStateException {
86  		if (!initializeImpl()) {
87  			throw new BluetoothStateException("TOSHIBA BluetoothStack not found");
88  		}
89  		initialized = true;
90  	}
91  
92  	public void destroy() {
93  		if (initialized) {
94  			destroyImpl();
95  			initialized = false;
96  			DebugLog.debug("TOSHIBA destroyed");
97  		}
98  	}
99  
100 	/*
101 	 * (non-Javadoc)
102 	 * 
103 	 * @see com.intel.bluetooth.BluetoothStack#isCurrentThreadInterruptedCallback()
104 	 */
105 	public boolean isCurrentThreadInterruptedCallback() {
106 		return UtilsJavaSE.isCurrentThreadInterrupted();
107 	}
108 
109 	// ---------------------- LocalDevice
110 
111 	public native String getLocalDeviceBluetoothAddress() throws BluetoothStateException;
112 
113 	public DeviceClass getLocalDeviceClass() {
114 		// TODO Auto-generated method stub
115 		return null;
116 	}
117 
118 	/*
119 	 * (non-Javadoc)
120 	 * 
121 	 * @see com.intel.bluetooth.BluetoothStack#setLocalDeviceServiceClasses(int)
122 	 */
123 	public void setLocalDeviceServiceClasses(int classOfDevice) {
124 		// TODO Auto-generated method stub
125 	}
126 
127 	public String getLocalDeviceName() {
128 		// TODO Auto-generated method stub
129 		return null;
130 	}
131 
132 	public boolean isLocalDevicePowerOn() {
133 		// TODO Auto-generated method stub
134 		return false;
135 	}
136 
137 	public String getLocalDeviceProperty(String property) {
138 		// TODO Auto-generated method stub
139 		return null;
140 	}
141 
142 	public int getLocalDeviceDiscoverable() {
143 		// TODO Auto-generated method stub
144 		return 0;
145 	}
146 
147 	public boolean setLocalDeviceDiscoverable(int mode) throws BluetoothStateException {
148 		// TODO Auto-generated method stub
149 		return false;
150 	}
151 
152 	public String getRemoteDeviceFriendlyName(long address) throws IOException {
153 		// TODO Auto-generated method stub
154 		return null;
155 	}
156 
157 	// ---------------------- Remote Device authentication
158 
159 	public boolean authenticateRemoteDevice(long address) throws IOException {
160 		return false;
161 	}
162 
163 	/*
164 	 * (non-Javadoc)
165 	 * 
166 	 * @see com.intel.bluetooth.BluetoothStack#authenticateRemoteDevice(long,
167 	 *      java.lang.String)
168 	 */
169 	public boolean authenticateRemoteDevice(long address, String passkey) throws IOException {
170 		return false;
171 	}
172 
173 	// ---------------------- Device Inquiry
174 
175 	public boolean startInquiry(int accessCode, DiscoveryListener listener) throws BluetoothStateException {
176 		return DeviceInquiryThread.startInquiry(this, this, accessCode, listener);
177 	}
178 
179 	public int runDeviceInquiry(DeviceInquiryThread startedNotify, int accessCode, DiscoveryListener listener)
180 			throws BluetoothStateException {
181 		// TODO Auto-generated method stub
182 		return 0;
183 	}
184 
185 	public void deviceDiscoveredCallback(DiscoveryListener listener, long deviceAddr, int deviceClass,
186 			String deviceName, boolean paired) {
187 		// TODO Auto-generated method stub
188 	}
189 
190 	public boolean cancelInquiry(DiscoveryListener listener) {
191 		// TODO Auto-generated method stub
192 		return false;
193 	}
194 
195 	// ---------------------- Service search
196 
197 	public int runSearchServices(SearchServicesThread startedNotify, int[] attrSet, UUID[] uuidSet,
198 			RemoteDevice device, DiscoveryListener listener) throws BluetoothStateException {
199 		return SearchServicesThread.startSearchServices(this, this, attrSet, uuidSet, device, listener);
200 	}
201 
202 	public int searchServices(int[] attrSet, UUID[] uuidSet, RemoteDevice device, DiscoveryListener listener)
203 			throws BluetoothStateException {
204 		// TODO Auto-generated method stub
205 		return 0;
206 	}
207 
208 	public boolean cancelServiceSearch(int transID) {
209 		// TODO Auto-generated method stub
210 		return false;
211 	}
212 
213 	public boolean populateServicesRecordAttributeValues(ServiceRecordImpl serviceRecord, int[] attrIDs)
214 			throws IOException {
215 		// TODO Auto-generated method stub
216 		return false;
217 	}
218 
219 	// ---------------------- Client RFCOMM connections
220 
221 	public long connectionRfOpenClientConnection(BluetoothConnectionParams params) throws IOException {
222 		// TODO Auto-generated method stub
223 		return 0;
224 	}
225 
226 	public void connectionRfCloseClientConnection(long handle) throws IOException {
227 		// TODO Auto-generated method stub
228 
229 	}
230 
231 	public int rfGetSecurityOpt(long handle, int expected) throws IOException {
232 		return expected;
233 	}
234 
235 	/*
236 	 * (non-Javadoc)
237 	 * 
238 	 * @see com.intel.bluetooth.BluetoothStack#l2Encrypt(long,long,boolean)
239 	 */
240 	public boolean rfEncrypt(long address, long handle, boolean on) throws IOException {
241 		return false;
242 	}
243 
244 	// ---------------------- Server RFCOMM connections
245 
246 	public long rfServerOpen(BluetoothConnectionNotifierParams params, ServiceRecordImpl serviceRecord)
247 			throws IOException {
248 		// TODO Auto-generated method stub
249 		return 0;
250 	}
251 
252 	public void rfServerClose(long handle, ServiceRecordImpl serviceRecord) throws IOException {
253 		// TODO Auto-generated method stub
254 
255 	}
256 
257 	public void rfServerUpdateServiceRecord(long handle, ServiceRecordImpl serviceRecord, boolean acceptAndOpen)
258 			throws ServiceRegistrationException {
259 		// TODO Auto-generated method stub
260 
261 	}
262 
263 	public long rfServerAcceptAndOpenRfServerConnection(long handle) throws IOException {
264 		// TODO Auto-generated method stub
265 		return 0;
266 	}
267 
268 	public void connectionRfCloseServerConnection(long handle) throws IOException {
269 		// TODO Auto-generated method stub
270 	}
271 
272 	// ---------------------- Shared Client and Server RFCOMM connections
273 
274 	public void connectionRfFlush(long handle) throws IOException {
275 		// TODO Auto-generated method stub
276 
277 	}
278 
279 	public int connectionRfRead(long handle) throws IOException {
280 		// TODO Auto-generated method stub
281 		return 0;
282 	}
283 
284 	public int connectionRfRead(long handle, byte[] b, int off, int len) throws IOException {
285 		// TODO Auto-generated method stub
286 		return 0;
287 	}
288 
289 	public int connectionRfReadAvailable(long handle) throws IOException {
290 		// TODO Auto-generated method stub
291 		return 0;
292 	}
293 
294 	public void connectionRfWrite(long handle, int b) throws IOException {
295 		// TODO Auto-generated method stub
296 
297 	}
298 
299 	public void connectionRfWrite(long handle, byte[] b, int off, int len) throws IOException {
300 		// TODO Auto-generated method stub
301 
302 	}
303 
304 	public long getConnectionRfRemoteAddress(long handle) throws IOException {
305 		// TODO Auto-generated method stub
306 		return 0;
307 	}
308 
309 	// ---------------------- Client and Server L2CAP connections
310 
311 	/*
312 	 * (non-Javadoc)
313 	 * 
314 	 * @see com.intel.bluetooth.BluetoothStack#l2OpenClientConnection(com.intel.bluetooth.BluetoothConnectionParams,
315 	 *      int, int)
316 	 */
317 	public long l2OpenClientConnection(BluetoothConnectionParams params, int receiveMTU, int transmitMTU)
318 			throws IOException {
319 		// TODO Auto-generated method stub
320 		return 0;
321 	}
322 
323 	/*
324 	 * (non-Javadoc)
325 	 * 
326 	 * @see com.intel.bluetooth.BluetoothStack#l2CloseClientConnection(long)
327 	 */
328 	public void l2CloseClientConnection(long handle) throws IOException {
329 		// TODO Auto-generated method stub
330 	}
331 
332 	/*
333 	 * (non-Javadoc)
334 	 * 
335 	 * @see com.intel.bluetooth.BluetoothStack#l2ServerOpen(com.intel.bluetooth.BluetoothConnectionNotifierParams,
336 	 *      int, int, com.intel.bluetooth.ServiceRecordImpl)
337 	 */
338 	public long l2ServerOpen(BluetoothConnectionNotifierParams params, int receiveMTU, int transmitMTU,
339 			ServiceRecordImpl serviceRecord) throws IOException {
340 		// TODO Auto-generated method stub
341 		return 0;
342 	}
343 
344 	/*
345 	 * (non-Javadoc)
346 	 * 
347 	 * @see com.intel.bluetooth.BluetoothStack#l2ServerUpdateServiceRecord(long,
348 	 *      com.intel.bluetooth.ServiceRecordImpl, boolean)
349 	 */
350 	public void l2ServerUpdateServiceRecord(long handle, ServiceRecordImpl serviceRecord, boolean acceptAndOpen)
351 			throws ServiceRegistrationException {
352 		// TODO Auto-generated method stub
353 	}
354 
355 	/*
356 	 * (non-Javadoc)
357 	 * 
358 	 * @see com.intel.bluetooth.BluetoothStack#l2ServerAcceptAndOpenServerConnection(long)
359 	 */
360 	public long l2ServerAcceptAndOpenServerConnection(long handle) throws IOException {
361 		// TODO Auto-generated method stub
362 		return 0;
363 	}
364 
365 	/*
366 	 * (non-Javadoc)
367 	 * 
368 	 * @see com.intel.bluetooth.BluetoothStack#l2CloseServerConnection(long)
369 	 */
370 	public void l2CloseServerConnection(long handle) throws IOException {
371 		// TODO Auto-generated method stub
372 
373 	}
374 
375 	/*
376 	 * (non-Javadoc)
377 	 * 
378 	 * @see com.intel.bluetooth.BluetoothStack#l2ServerClose(long,
379 	 *      com.intel.bluetooth.ServiceRecordImpl)
380 	 */
381 	public void l2ServerClose(long handle, ServiceRecordImpl serviceRecord) throws IOException {
382 		// TODO Auto-generated method stub
383 
384 	}
385 
386 	public int l2GetSecurityOpt(long handle, int expected) throws IOException {
387 		return expected;
388 	}
389 
390 	/*
391 	 * (non-Javadoc)
392 	 * 
393 	 * @see com.intel.bluetooth.BluetoothStack#l2Ready(long)
394 	 */
395 	public boolean l2Ready(long handle) throws IOException {
396 		// TODO Auto-generated method stub
397 		return false;
398 	}
399 
400 	/*
401 	 * (non-Javadoc)
402 	 * 
403 	 * @see com.intel.bluetooth.BluetoothStack#l2receive(long, byte[])
404 	 */
405 	public int l2Receive(long handle, byte[] inBuf) throws IOException {
406 		// TODO Auto-generated method stub
407 		return 0;
408 	}
409 
410 	/*
411 	 * (non-Javadoc)
412 	 * 
413 	 * @see com.intel.bluetooth.BluetoothStack#l2send(long, byte[])
414 	 */
415 	public void l2Send(long handle, byte[] data) throws IOException {
416 		// TODO Auto-generated method stub
417 	}
418 
419 	/*
420 	 * (non-Javadoc)
421 	 * 
422 	 * @see com.intel.bluetooth.BluetoothStack#l2GetReceiveMTU(long)
423 	 */
424 	public int l2GetReceiveMTU(long handle) throws IOException {
425 		// TODO Auto-generated method stub
426 		return 0;
427 	}
428 
429 	/*
430 	 * (non-Javadoc)
431 	 * 
432 	 * @see com.intel.bluetooth.BluetoothStack#l2GetTransmitMTU(long)
433 	 */
434 	public int l2GetTransmitMTU(long handle) throws IOException {
435 		// TODO Auto-generated method stub
436 		return 0;
437 	}
438 
439 	/*
440 	 * (non-Javadoc)
441 	 * 
442 	 * @see com.intel.bluetooth.BluetoothStack#l2RemoteAddress(long)
443 	 */
444 	public long l2RemoteAddress(long handle) throws IOException {
445 		// TODO Auto-generated method stub
446 		return 0;
447 	}
448 
449 	/*
450 	 * (non-Javadoc)
451 	 * 
452 	 * @see com.intel.bluetooth.BluetoothStack#l2Encrypt(long,long,boolean)
453 	 */
454 	public boolean l2Encrypt(long address, long handle, boolean on) throws IOException {
455 		// TODO Auto-generated method stub
456 		return false;
457 	}
458 }