public class IOSample extends Object
Depending on the protocol the XBee device is executing, the digital and analog masks are retrieved in separated bytes (2 bytes for the digital mask and 1 for the analog mask) or merged (digital and analog masks are contained in the same 2 bytes).
802.15.4 Protocol
Digital and analog channels masks
------------------------------------------------------------------
Indicates which digital and ADC IO lines are configured in the module. Each bit corresponds to one digital or ADC IO line on the module:
bit 0 = DIO0
1bit 1 = DIO1
0bit 2 = DIO2
0bit 3 = DIO3
1bit 4 = DIO4
0bit 5 = DIO5
1bit 6 = DIO6
0bit 7 = DIO7
0bit 8 = DIO8
0bit 9 = AD0
0bit 10 = AD1
1bit 11 = AD2
1bit 12 = AD3
0bit 13 = AD4
0bit 14 = AD5
0bit 15 = N/A
0
Example: mask of
0x0C29
means DIO0, DIO3, DIO5, AD1 and AD2 enabled.0 0 0 0 1 1 0 0 0 0 1 0 1 0 0 1
Other Protocols
Digital Channel Mask
------------------------------------------------------------------
Indicates which digital IO lines are configured in the module. Each bit corresponds to one digital IO line on the module:
bit 0 = DIO0/AD0
bit 1 = DIO1/AD1
bit 2 = DIO2/AD2
bit 3 = DIO3/AD3
bit 4 = DIO4/AD4
bit 5 = DIO5/AD5/ASSOC
bit 6 = DIO6/RTS
bit 7 = DIO7/CTS
bit 8 = DIO8/DTR/SLEEP_RQ
bit 9 = DIO9/ON_SLEEP
bit 10 = DIO10/PWM0/RSSI
bit 11 = DIO11/PWM1
bit 12 = DIO12/CD
bit 13 = DIO13
bit 14 = DIO14
bit 15 = N/A
Example: mask of
0x040B
means DIO0, DIO1, DIO2, DIO3 and DIO10 enabled.0 0 0 0 0 1 0 0 0 0 0 0 1 0 1 1
Analog Channel Mask
-----------------------------------------------------------------------
Indicates which lines are configured as ADC. Each bit in the analog channel mask corresponds to one ADC line on the module.
bit 0 = AD0/DIO0
bit 1 = AD1/DIO1
bit 2 = AD2/DIO2
bit 3 = AD3/DIO3
bit 4 = AD4/DIO4
bit 5 = AD5/DIO5/ASSOC
bit 6 = N/A
bit 7 = Supply Voltage Value
Example: mask of
0x03
means AD0, and AD1 enabled.0 0 0 0 0 0 1 1
Constructor and Description |
---|
IOSample(byte[] ioSamplePayload)
Class constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
getAnalogMask()
Returns the analog mask.
|
Integer |
getAnalogValue(IOLine ioLine)
Returns the analog value of the provided IO line.
|
HashMap<IOLine,Integer> |
getAnalogValues()
Returns the analog values map.
|
int |
getDigitalHSBMask()
Returns the HSB of the digital mask.
|
int |
getDigitalLSBMask()
Returns the LSB of the digital mask.
|
int |
getDigitalMask()
Returns the combined (HSB + LSB) digital mask.
|
IOValue |
getDigitalValue(IOLine ioLine)
Returns the digital value of the provided IO line.
|
HashMap<IOLine,IOValue> |
getDigitalValues()
Returns the digital values map.
|
int |
getPowerSupplyValue()
Returns the value of the power supply voltage.
|
boolean |
hasAnalogValue(IOLine ioLine)
Returns whether or not the given IO line has an analog value.
|
boolean |
hasAnalogValues()
Returns whether or not the
IOSample has analog values. |
boolean |
hasDigitalValue(IOLine ioLine)
Returns whether or not this IO sample contains a digital value for
the given IO line.
|
boolean |
hasDigitalValues()
Checks whether or not the
IOSample has digital values. |
boolean |
hasPowerSupplyValue()
Returns whether or not the IOSample has power supply value.
|
String |
toString() |
public IOSample(byte[] ioSamplePayload)
IOSample
with the given IO sample payload.ioSamplePayload
- The payload corresponding to an IO sample.IllegalArgumentException
- if ioSamplePayload.length < 5
.NullPointerException
- if ioSamplePayload == null
.public int getAnalogMask()
public Integer getAnalogValue(IOLine ioLine)
To verify if this sample contains an analog value for the given
IOLine
, use the method hasAnalogValue(IOLine)
.
if (ioSample.hasAnalogValue(IOLine.DIO0_AD0)) {
Integer value = ioSample.getAnalogValue(IOLine.DIO0_AD0);
...
} else {
...
}
ioLine
- The IO line to get its analog value.null
if the
IO sample does not contain an analog value for the given IO line.getAnalogValues()
,
hasAnalogValue(IOLine)
,
hasAnalogValues()
,
IOLine
public HashMap<IOLine,Integer> getAnalogValues()
To verify if this sample contains a valid analog values, use the
method hasAnalogValues()
.
if (ioSample.hasAnalogValues()) {
HashMap<IOLine, Integer> values = ioSample.getAnalogValues();
...
} else {
...
}
HashMap
with the analog value of each configured IO
line.getAnalogValue(IOLine)
,
hasAnalogValue(IOLine)
,
hasAnalogValues()
,
IOLine
public int getDigitalHSBMask()
getDigitalLSBMask()
,
getDigitalMask()
public int getDigitalLSBMask()
getDigitalHSBMask()
,
getDigitalMask()
public int getDigitalMask()
getDigitalLSBMask()
,
getDigitalHSBMask()
public IOValue getDigitalValue(IOLine ioLine)
To verify if this sample contains a digital value for the given
IOLine
, use the method hasDigitalValue(IOLine)
.
if (ioSample.hasDigitalValue(IOLine.DIO0_AD0)) {
IOValue value = ioSample.getDigitalValue(IOLine.DIO0_AD0);
...
} else {
...
}
ioLine
- The IO line to get its digital value.IOValue
of the given IO line or null
if the
IO sample does not contain a digital value for the given IO line.getDigitalValues()
,
hasDigitalValues()
,
IOLine
,
IOValue
public HashMap<IOLine,IOValue> getDigitalValues()
To verify if this sample contains a valid digital values, use the
method hasDigitalValues()
.
if (ioSample.hasDigitalValues()) {
HashMap<IOLine, IOValue> values = ioSample.getDigitalValues();
...
} else {
...
}
HashMap
with the digital value of each configured IO
line.getDigitalValue(IOLine)
,
hasDigitalValues()
,
IOLine
,
IOValue
public int getPowerSupplyValue() throws OperationNotSupportedException
To verify if this sample contains the power supply voltage, use the
method hasPowerSupplyValue()
.
if (ioSample.hasPowerSupplyValue()) {
int value = ioSample.getPowerSupplyValue();
...
} else {
...
}
OperationNotSupportedException
- if the IOSample does not have
power supply value.hasPowerSupplyValue()
public boolean hasAnalogValue(IOLine ioLine)
ioLine
- The IO line to check if has an analog value.true
if the given IO line has an analog value,
false
otherwise.getAnalogValue(IOLine)
,
getAnalogValues()
,
hasAnalogValues()
,
IOLine
public boolean hasAnalogValues()
IOSample
has analog values.true
if there are analog values, false
otherwise.getAnalogValue(IOLine)
,
getAnalogValues()
,
hasAnalogValue(IOLine)
,
IOLine
public boolean hasDigitalValue(IOLine ioLine)
ioLine
- The IO line to check if has a digital value.true
if the given IO line has a digital value,
false
otherwise.hasDigitalValues()
,
IOLine
public boolean hasDigitalValues()
IOSample
has digital values.true
if there are digital values, false
otherwise.public boolean hasPowerSupplyValue()
true
if the IOSample has power supply value,
false
otherwise.getPowerSupplyValue()
© Copyright 2014–2014 Digi International Inc. All rights reserved.