public abstract class NADevice extends Object
The representation of a device detected by the ProxPlatform.
This class also provides convenience methods for working with devices the platform knows about.
An instance of NADevice is actively backed by the device in the system, so any calls into the device return the current state of the device as known to the system at the time of the call. The state of the device may be updated at any time.
If your application needs to know when a device is updated you can register an observer. This observer will be called when a device in the system changes state, however which device is not specified via this interface.
Modifier and Type | Field and Description |
---|---|
static Comparator<NADevice> |
COMPARATOR_MAJOR_MINOR
Comparator for sorting by Major/Minor.
|
static Comparator<NADevice> |
COMPARATOR_SIGNAL_STRENGTH
Comparator for sorting by signal strength.
|
Modifier | Constructor and Description |
---|---|
protected |
NADevice()
Only subclass construction.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(NADevice other)
This is the default way to compare NADevices when sorting
them in a list.
|
int |
compareTo(com.newaer.sdk.proximity.NAObject another) |
abstract NAMessage |
createMessageToSend(byte[] message)
Gets a message to be sent to this device.
|
boolean |
equals(Object another) |
static List<NADevice> |
getAllByType(Context context,
NADeviceType type)
This is a convenience for
NAPlatform.get(context).getAllUntaggedDevicesByType(type) |
static List<NADevice> |
getAllDevices(Context context)
This is a convenience for
NAPlatform.get(context).getAllDevices() |
abstract String |
getAppId()
This returns the application ID of the app which has this device, or null if this
device is not of type NEWAER_DEVICE.
|
abstract String |
getBeaconUUID() |
static NADevice |
getDevice(Context context,
String id)
This is a convenience for
NAPlatform.get(context).getDevice(id) |
abstract String |
getId()
Returns the identifier for this object within the platform.
|
abstract byte[] |
getInfo()
This returns extra information set via
NAPlatform.setInfo(byte[]) . |
abstract long |
getLastSeenTimestamp() |
abstract int |
getMajor() |
abstract int |
getMinor() |
abstract String |
getName()
Returns a human friendly name for this device.
|
abstract int |
getPowerbars()
Returns the number of power bars to display for this device, from
zero to five.
|
abstract int |
getSignalStrength() |
abstract NADeviceStatus |
getStatus() |
abstract int |
getTxPower() |
abstract NADeviceType |
getType() |
int |
hashCode() |
abstract boolean |
isRemote() |
static void |
registerObserver(Context context,
DataSetObserver observer)
This is a convenience for
NAPlatform.get(context).registerDeviceObserver(observer) |
static void |
registerStatusListener(Context context,
NADeviceStatusListener listener)
This is a convenience for
NAPlatform.get(context).registerDeviceStatusListener(NADeviceStatusListener) |
abstract void |
setName(Context context,
String name)
Change the name for this object.
|
static void |
unregisterObserver(Context context,
DataSetObserver observer)
This is a convenience for
NAPlatform.get(context).unregisterDeviceObserver(observer) |
static void |
unregisterStatusListener(Context context,
NADeviceStatusListener listener)
This is a convenience for
NAPlatform.get(context).unregisterDeviceStatusListener(NADeviceStatusListener) |
public static final Comparator<NADevice> COMPARATOR_SIGNAL_STRENGTH
public static final Comparator<NADevice> COMPARATOR_MAJOR_MINOR
public static List<NADevice> getAllByType(Context context, NADeviceType type)
This is a convenience for
NAPlatform.get(context).getAllUntaggedDevicesByType(type)
context
- the context to work intype
- the type of devices to getpublic static List<NADevice> getAllDevices(Context context)
This is a convenience for
NAPlatform.get(context).getAllDevices()
context
- the context to work inpublic static void registerObserver(Context context, DataSetObserver observer)
This is a convenience for
NAPlatform.get(context).registerDeviceObserver(observer)
context
- the context to work in.observer
- the observer to register.public static void unregisterObserver(Context context, DataSetObserver observer)
This is a convenience for
NAPlatform.get(context).unregisterDeviceObserver(observer)
context
- the context to work inobserver
- the observer to register.public static NADevice getDevice(Context context, String id)
This is a convenience for
NAPlatform.get(context).getDevice(id)
context
- the context to work inid
- the id of the device to retrieve.public static void registerStatusListener(Context context, NADeviceStatusListener listener)
This is a convenience for
NAPlatform.get(context).registerDeviceStatusListener(NADeviceStatusListener)
context
- the context to work inlistener
- the listener to registerpublic static void unregisterStatusListener(Context context, NADeviceStatusListener listener)
This is a convenience for
NAPlatform.get(context).unregisterDeviceStatusListener(NADeviceStatusListener)
context
- the context to work inlistener
- the listener to unregisterpublic abstract NADeviceType getType()
public abstract int getSignalStrength()
public abstract NADeviceStatus getStatus()
public abstract String getName()
public abstract int getPowerbars()
public int compareTo(NADevice other)
public abstract long getLastSeenTimestamp()
public abstract byte[] getInfo()
NAPlatform.setInfo(byte[])
.
If no information has been set, or this device is not of type NADeviceType.NEWAER
then this returns null.NAPlatform.setInfo(byte[])
or nullpublic abstract String getAppId()
public abstract NAMessage createMessageToSend(byte[] message)
public abstract int getMajor()
public abstract int getMinor()
public abstract String getBeaconUUID()
public abstract int getTxPower()
public abstract boolean isRemote()
public abstract String getId()
Returns the identifier for this object within the platform.
This identifier is unique on a per object type basis.
public abstract void setName(Context context, String name)
context
- the context to work inname
- the new name for this object.public int compareTo(com.newaer.sdk.proximity.NAObject another)
compareTo
in interface Comparable<T extends com.newaer.sdk.proximity.NAObject>