28import java.util.ArrayList;
29import java.util.Arrays;
30import java.util.Collection;
31import java.util.Collections;
32import java.util.HashSet;
33import java.util.Iterator;
36import org.jau.net.EUI48;
37import org.jau.net.EUI48Sub;
84 private static List<DeviceQuery> waitForDevices =
new ArrayList<DeviceQuery>();
106 public final boolean equals(
final Object obj) {
110 if (obj ==
null || !(obj instanceof
DeviceID)) {
133 private static Collection<DeviceID> devicesProcessed = Collections.synchronizedCollection(
new HashSet<DeviceID>());
136 final EUI48Sub addr1 =
new EUI48Sub();
137 final StringBuilder errmsg =
new StringBuilder();
138 if( EUI48Sub.scanEUI48Sub(addrOrNameSub, addr1, errmsg) ) {
142 waitForDevices.add(
new DeviceQuery( addrOrNameSub ) );
146 return waitForDevices.size()==0;
149 return waitForDevices.size();
152 return Arrays.toString(waitForDevices.toArray());
158 return waitForDevices;
164 waitForDevices.clear();
168 devicesProcessed.add(
new DeviceID(a, n) );
171 return devicesProcessed.contains(
new DeviceID(a,
null) );
174 return devicesProcessed.size();
177 return Arrays.toString(devicesProcessed.toArray());
183 return new ArrayList<DeviceID>(devicesProcessed);
189 devicesProcessed.clear();
223 for(
final Iterator<DeviceQuery> it=waitForDevices.iterator(); it.hasNext(); ) {
225 if( m.
match(address, name, q) ) {
247 (
final EUI48 a,
final String n,
final DeviceQuery q) -> {
261 for(
final Iterator<DeviceQuery> it1=waitForDevices.iterator(); it1.hasNext(); ) {
263 final Iterator<DeviceID> it2=devicesProcessed.iterator();
264 while( it2.hasNext() ) {
266 if( m.
match(
id.addressAndType.address,
id.name, q) ) {
270 if( !it2.hasNext() ) {
Unique Bluetooth EUI48 address and BDAddressType tuple.
final boolean equals(final Object obj)
If both types are of BDAddressAndType, it compares their EUI48 address and BDAddressType.
Specifies unique device identities, using BDAddressAndType as key.
final boolean equals(final Object obj)
final BDAddressAndType addressAndType
DeviceID(final BDAddressAndType a, final String n)
Specifies devices queries to act upon.
DeviceQuery(final EUI48Sub as)
final boolean isEUI48Sub()
final EUI48Sub addressSub
DeviceQuery(final String ns)
Application toolkit providing BT device registration of processed and awaited devices.
static int getWaitForDevicesCount()
static List< DeviceQuery > getWaitForDevices()
Returns the reference of the current list of DeviceQuery, not a copy.
static int getProcessedDeviceCount()
static List< DeviceID > getProcessedDevices()
Returns a copy of the current collection of processed DeviceID.
static void addToProcessedDevices(final BDAddressAndType a, final String n)
static String getWaitForDevicesString()
static boolean isDeviceProcessed(final BDAddressAndType a)
static boolean isWaitingForDevice(final EUI48 address, final String name, final DeviceQueryMatch m)
Returns true if the given address and/or name matches any of the awaited devices.
static boolean areAllDevicesProcessed()
Returns true if all awaited devices have been processed.
static void clearWaitForDevices()
Clears internal list.
static boolean isWaitingForDevice(final EUI48 address, final String name)
Returns true if the given address and/or name matches any of the awaited devices.
static boolean areAllDevicesProcessed(final DeviceQueryMatch m)
Returns true if all awaited devices have been processed.
static void clearProcessedDevices()
Clears internal list.
static boolean isWaitingForAnyDevice()
static void addToWaitForDevices(final String addrOrNameSub)
static String getProcessedDevicesString()
NAME
DeviceQuery type, using a sensor device String name.
EUI48SUB
DeviceQuery type, using a sensor device EUI48Sub.
Interface for user defined DeviceQuery matching criteria and algorithm.
boolean match(final EUI48 address, final String name, final DeviceQuery q)
Return true if the given address and/or name matches with the DeviceQuery's addressSub and/or nameSub...