Direct-BT
2.3.1
Direct-BT - Direct Bluetooth Programming.
|
Go to the documentation of this file.
26 package org.direct_bt;
28 import java.util.ArrayList;
29 import java.util.Arrays;
30 import java.util.Collection;
31 import java.util.Collections;
32 import java.util.HashSet;
33 import java.util.Iterator;
34 import java.util.List;
81 private static List<DeviceQuery> waitForDevices =
new ArrayList<DeviceQuery>();
103 public final boolean equals(
final Object obj) {
107 if (obj ==
null || !(obj instanceof
DeviceID)) {
130 private static Collection<DeviceID> devicesInProcessing = Collections.synchronizedCollection(
new HashSet<DeviceID>());
131 private static Collection<DeviceID> devicesProcessed = Collections.synchronizedCollection(
new HashSet<DeviceID>());
135 final StringBuilder errmsg =
new StringBuilder();
140 waitForDevices.add(
new DeviceQuery( addrOrNameSub ) );
144 return waitForDevices.size()>0;
147 return waitForDevices.size();
150 return Arrays.toString(waitForDevices.toArray());
156 return waitForDevices;
162 waitForDevices.clear();
166 devicesProcessed.add(
new DeviceID(a, n) );
169 return devicesProcessed.contains(
new DeviceID(a,
null) );
172 return devicesProcessed.size();
175 return Arrays.toString(devicesProcessed.toArray());
181 return new ArrayList<DeviceID>(devicesProcessed);
187 devicesProcessed.clear();
221 for(
final Iterator<DeviceQuery> it=waitForDevices.iterator(); it.hasNext(); ) {
223 if( m.
match(address, name, q) ) {
259 for(
final Iterator<DeviceQuery> it1=waitForDevices.iterator(); it1.hasNext(); ) {
261 final Iterator<DeviceID> it2=devicesProcessed.iterator();
262 while( it2.hasNext() ) {
264 if( m.
match(
id.addressAndType.address,
id.name, q) ) {
268 if( !it2.hasNext() ) {
295 devicesInProcessing.add(
new DeviceID(a, n) );
298 return devicesInProcessing.remove(
new DeviceID(a,
null) );
301 return devicesInProcessing.contains(
new DeviceID(a,
null) );
304 return devicesInProcessing.size();
310 return new ArrayList<DeviceID>(devicesInProcessing);
316 devicesInProcessing.clear();
static void clearProcessingDevices()
Clears internal list.
final boolean equals(final Object obj)
boolean contains(final EUI48Sub needle)
Returns true, if given EUI48Sub is contained in here.
static int getProcessingDeviceCount()
static boolean isWaitingForAnyDevice()
Application toolkit providing BT device registration of processed and awaited devices.
static String getWaitForDevicesString()
boolean match(final EUI48 address, final String name, final DeviceQuery q)
Return.
static void clearWaitForDevices()
Clears internal list.
A 48 bit EUI-48 sub-identifier, see EUI48.
A packed 48 bit EUI-48 identifier, formerly known as MAC-48 or simply network device MAC address (Med...
static final EUI48Sub ANY_DEVICE
EUI48Sub MAC address matching any device, i.e.
final boolean isEUI48Sub()
static boolean areAllDevicesProcessed()
Returns.
static boolean removeFromProcessingDevices(final BDAddressAndType a)
Specifies devices queries to act upon.
DeviceQuery(final EUI48Sub as)
NAME
DeviceQuery type, using a sensor device String name.
static boolean isWaitingForDevice(final EUI48 address, final String name)
Returns.
static List< DeviceID > getProcessingDevices()
Returns a copy of the current collection of processing DeviceID.
void clear()
Method clears the underlying byte array b and sets length to zero.
Interface for user defined DeviceQuery matching criteria and algorithm.
static boolean isDeviceProcessing(final BDAddressAndType a)
static List< DeviceQuery > getWaitForDevices()
Returns the reference of the current list of DeviceQuery, not a copy.
static void addToWaitForDevices(final String addrOrNameSub)
final EUI48Sub addressSub
final BDAddressAndType addressAndType
DeviceQuery(final String ns)
Unique Bluetooth EUI48 address and BDAddressType tuple.
Specifies unique device identities, using BDAddressAndType as key.
static boolean areAllDevicesProcessed(final DeviceQueryMatch m)
Returns.
static void addToProcessedDevices(final BDAddressAndType a, final String n)
final boolean equals(final Object obj)
static String getProcessedDevicesString()
static void clearProcessedDevices()
Clears internal list.
static int getWaitForDevicesCount()
static boolean scanEUI48Sub(final String str, final EUI48Sub dest, final StringBuilder errmsg)
Fills given EUI48Sub instance via given string representation.
static boolean isDeviceProcessed(final BDAddressAndType a)
static void addToProcessingDevices(final BDAddressAndType a, final String n)
static int getProcessedDeviceCount()
static boolean isWaitingForDevice(final EUI48 address, final String name, final DeviceQueryMatch m)
Returns.
EUI48SUB
DeviceQuery type, using a sensor device EUI48Sub.
DeviceID(final BDAddressAndType a, final String n)
static List< DeviceID > getProcessedDevices()
Returns a copy of the current collection of processed DeviceID.