digi.xbee.io module

class digi.xbee.io.IOLine(description, index, at_command, pwm_command=None)[source]

Bases: enum.Enum

Enumerates the different IO lines that can be found in the XBee devices.

Depending on the hardware and firmware of the device, the number of lines that can be used as well as their functionality may vary. Refer to the product manual to learn more about the IO lines of your XBee device.

Values:
IOLine.DIO0_AD0 = (‘DIO0/AD0’, 0, ‘D0’)
IOLine.DIO1_AD1 = (‘DIO1/AD1’, 1, ‘D1’)
IOLine.DIO2_AD2 = (‘DIO2/AD2’, 2, ‘D2’)
IOLine.DIO3_AD3 = (‘DIO3/AD3’, 3, ‘D3’)
IOLine.DIO4_AD4 = (‘DIO4/AD4’, 4, ‘D4’)
IOLine.DIO5_AD5 = (‘DIO5/AD5’, 5, ‘D5’)
IOLine.DIO6 = (‘DIO6’, 6, ‘D6’)
IOLine.DIO7 = (‘DIO7’, 7, ‘D7’)
IOLine.DIO8 = (‘DIO8’, 8, ‘D8’)
IOLine.DIO9 = (‘DIO9’, 9, ‘D9’)
IOLine.DIO10_PWM0 = (‘DIO10/PWM0’, 10, ‘P0’, ‘M0’)
IOLine.DIO11_PWM1 = (‘DIO11/PWM1’, 11, ‘P1’, ‘M1’)
IOLine.DIO12 = (‘DIO12’, 12, ‘P2’)
IOLine.DIO13 = (‘DIO13’, 13, ‘P3’)
IOLine.DIO14 = (‘DIO14’, 14, ‘P4’)
IOLine.DIO15 = (‘DIO15’, 15, ‘P5’)
IOLine.DIO16 = (‘DIO16’, 16, ‘P6’)
IOLine.DIO17 = (‘DIO17’, 17, ‘P7’)
IOLine.DIO18 = (‘DIO18’, 18, ‘P8’)
IOLine.DIO19 = (‘DIO19’, 19, ‘P9’)

has_pwm_capability()[source]

Returns whether the IO line has PWM capability or not.

Returns:True if the IO line has PWM capability, False otherwise.
Return type:Boolean
description

String. The IO line description.

index

Integer. The IO line index.

at_command

String. The IO line AT command.

pwm_at_command

String. The IO line PWM AT command.

class digi.xbee.io.IOValue(code)[source]

Bases: enum.Enum

Enumerates the possible values of a IOLine configured as digital I/O.
Values:
IOValue.LOW = 4
IOValue.HIGH = 5

code

Integer. The IO value code.

class digi.xbee.io.IOSample(io_sample_payload)[source]

Bases: object

This class represents an IO Data Sample. The sample is built using the the constructor. The sample contains an analog and digital mask indicating which IO lines are configured with that functionality.

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 contained (digital and analog masks are contained in 2 bytes).

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 =  DIO01
bit 1 =  DIO10
bit 2 =  DIO20
bit 3 =  DIO31
bit 4 =  DIO40
bit 5 =  DIO51
bit 6 =  DIO60
bit 7 =  DIO70
bit 8 =  DIO80
bit 9 =  AD00
bit 10 = AD11
bit 11 = AD21
bit 12 = AD30
bit 13 = AD40
bit 14 = AD50
bit 15 = NA0

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

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 =  DIO0AD0
bit 1 =  DIO1AD1
bit 2 =  DIO2AD2
bit 3 =  DIO3AD3
bit 4 =  DIO4AD4
bit 5 =  DIO5AD5ASSOC
bit 6 =  DIO6RTS
bit 7 =  DIO7CTS
bit 8 =  DIO8DTRSLEEP_RQ
bit 9 =  DIO9ON_SLEEP
bit 10 = DIO10PWM0RSSI
bit 11 = DIO11PWM1
bit 12 = DIO12CD
bit 13 = DIO13
bit 14 = DIO14
bit 15 = NA

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 = AD0DIO0
bit 1 = AD1DIO1
bit 2 = AD2DIO2
bit 3 = AD3DIO3
bit 4 = AD4DIO4
bit 5 = AD5DIO5ASSOC
bit 6 = NA
bit 7 = Supply Voltage Value

Example: mask of 0x83 means AD0, and AD1 enabled.
0 0 0 0 0 0 1 1

Class constructor. Instantiates a new IOSample object with the provided parameters.

Parameters:io_sample_payload (Bytearray) – The payload corresponding to an IO sample.
Raises:ValueError – if io_sample_payload length is less than 5.
static min_io_sample_payload()[source]

Returns the minimum IO sample payload length.

Returns:the minimum IO sample payload length.
Return type:Integer
has_digital_values()[source]

Checks whether the IOSample has digital values or not.

Returns:True if the sample has digital values, False otherwise.
Return type:Boolean
has_digital_value(io_line)[source]

Returns whether th IO sample contains a digital value for the provided IO line or not.

Parameters:io_line (IOLine) – The IO line to check if it has a digital value.
Returns:True if the given IO line has a digital value, False otherwise.
Return type:Boolean
has_analog_value(io_line)[source]

Returns whether the given IOLine has an analog value or not.

Returns:True if the given IOLine has an analog value, False otherwise.
Return type:Boolean
has_analog_values()[source]

Returns whether the {@code IOSample} has analog values or not.

Returns:Boolean. True if there are analog values, False otherwise.
has_power_supply_value()[source]

Returns whether the IOSample has power supply value or not.

Returns:Boolean. True if the given IOLine has a power supply value, False otherwise.
get_digital_value(io_line)[source]

Returns the digital value of the provided IO line.

To verify if this sample contains a digital value for the given IOLine, use the method IOSample.has_digital_value().

Parameters:io_line (IOLine) – The IO line to get its digital value.
Returns:
The IOValue of the given IO line or None if the
IO sample does not contain a digital value for the given IO line.
Return type:IOValue

See also

get_analog_value(io_line)[source]

Returns the analog value of the provided IO line.

To verify if this sample contains an analog value for the given IOLine, use the method IOSample.has_analog_value().

Parameters:io_line (IOLine) – The IO line to get its analog value.
Returns:
The analog value of the given IO line or None if the IO sample does not
contain an analog value for the given IO line.
Return type:Integer

See also

digital_hsb_mask

Integer. High Significant Byte (HSB) of the digital mask.

digital_lsb_mask

Integer. Low Significant Byte (LSB) of the digital mask.

digital_mask

Integer. Digital mask of the IO sample.

analog_mask

Integer. Analog mask of the IO sample.

digital_values

Dictionary. Digital values map.

analog_values

Dictionary. Analog values map.

power_supply_value

Integer. Power supply value, None if the sample does not contain power supply value.

class digi.xbee.io.IOMode[source]

Bases: enum.Enum

Enumerates the different Input/Output modes that an IO line can be configured with.

DISABLED = 0

Disabled

SPECIAL_FUNCTIONALITY = 1

Firmware special functionality

PWM = 2

PWM output

ADC = 2

Analog to Digital Converter

DIGITAL_IN = 3

Digital input

DIGITAL_OUT_LOW = 4

Digital output, Low

DIGITAL_OUT_HIGH = 5

Digital output, High

I2C_FUNCTIONALITY = 6

I2C functionality