Response

Responses

class hachi.response.XBeeResponse(frame)

Base class for all XBee responses

The XBeeResponse is a wrapper around the underlying raw API frame.

Parameters:frame (bytearray) – unescaped raw API frame
api_id = None

API ID

Subclasses must implement this and return the corresponding API ID

frame = None

Unescaped raw API frame

length

Length, on 2 bytes starting right after the FRAME_DELIMITER of the frame

id_data

API ID-specific raw data, bytes between the api_id and the checksum

Subclasses may provide properties to access API ID-specific data

checksum

Checksum, last byte of the frame

verify()

Check if the response has a valid checksum

Returns:True if the response has a valid checksum, False otherwise
Return type:bool
class hachi.response.Rx64Response(frame)

Response to a Tx64Request

Frame example: 7E 00 10 80 00 13 A2 00 40 52 2B AA 16 03 F1 2E AA BD C9 FB

source_address

Source address, first 8 bytes of the id_data

rssi

RSSI, immediatly following the source_address

options

Options, immediatly following the rssi

data

Data, all bytes following the options until the end of the id_data

class hachi.response.Rx16Response(frame)

Response to a Tx16Request

Frame example: 7E 00 0A 81 52 1A 23 01 12 33 85 A1 F2 91’

source_address

Source address, first 2 bytes of the id_data

rssi

RSSI, immediatly following the source_address

options

Options, immediatly following the rssi

data

Data, all bytes following the options until the end of the id_data

class hachi.response.Rx64IoSampleResponse(frame)

IO sample response using 64-bits addressing

Frame example: 7E 00 14 82 00 13 A2 00 40 52 2B AA 23 01 02 14 88 00 80 00 8F 03 ED 00 08 02 4C 00 0C 3E

source_address

Source address, first 8 bytes of the id_data

rssi

RSSI, immediatly following the source_address

options

Options, immediatly following the rssi

sample_count

Sample count, immediatly following the options

analog_mask

Analog mask, immediatly following the sample_count

It is the whole byte of which first and last bit are set to 0 because useless in this context. Second bit (right to left) tells if analog channel 0 (A0) is enabled (bit to 1) or disabled (bit to 0), third bit is for A1 and so on until seventh bit which is for A5

digital_mask

Digital mask, on 2 bytes including the analog_mask byte

It is the whole first byte (right to left) and the second one of which all bits except the first one are set to 0 because useless in this context. First bit (right to left) tells if digital channel 0 (D0) is enabled (bit to 1) or disabled (bit to 0), second bit is for D1 and so on until ninth bit which is for D8

contains_analog

True if at least one analog channel is enabled, False otherwise

contains_digital

True if at least one digital channel is enabled, False otherwise

is_analog_enabled(pin)

Tells if a given analog pin is enabled or not

Parameters:pin (int) – analog pin number
Returns:True if the given analog pin is enabled, False otherwise
Return type:boolean
is_digital_enabled(pin)

Tells if a given digital pin is enabled or not

Parameters:pin (int) – digital pin number
Returns:True if the given digital pin is enabled, False otherwise
Return type:boolean
is_digital_on(index, pin)

Tells if a given digital pin is on or not in a sample

Parameters:
  • index (int) – index of the sample
  • pin (int) – digital pin number
Returns:

True if the given digital pin is on in the sample, False otherwise

Return type:

boolean

get_analog(index, pin)

Gives the analog value of a pin in a sample

Parameters:
  • index (int) – index of the sample
  • pin (int) – analog pin number
Returns:

analog pin value

Return type:

int

class hachi.response.Rx16IoSampleResponse(frame)

IO sample response using 16-bits addressing

Frame example: 7E 00 14 83 7D 84 23 01 02 14 88 00 80 00 8F 03 ED 00 08 02 4C 00 0C 58

source_address

Source address, first 2 bytes of the id_data

rssi

RSSI, immediatly following the source_address

options

Options, immediatly following the rssi

sample_count

Sample count, immediatly following the options

analog_mask

Analog mask, immediatly following the sample_count

It is the whole byte of which first and last bit are set to 0 because useless in this context. Second bit (right to left) tells if analog channel 0 (A0) is enabled (bit to 1) or disabled (bit to 0), third bit is for A1 and so on until seventh bit which is for A5

digital_mask

Digital mask, on 2 bytes including the analog_mask byte

It is the whole first byte (right to left) and the second one of which all bits except the first one are set to 0 because useless in this context. First bit (right to left) tells if digital channel 0 (D0) is enabled (bit to 1) or disabled (bit to 0), second bit is for D1 and so on until ninth bit which is for D8

contains_analog

True if at least one analog channel is enabled, False otherwise

contains_digital

True if at least one digital channel is enabled, False otherwise

is_analog_enabled(pin)

Tells if a given analog pin is enabled or not

Parameters:pin (int) – analog pin number
Returns:True if the given analog pin is enabled, False otherwise
Return type:boolean
is_digital_enabled(pin)

Tells if a given digital pin is enabled or not

Parameters:pin (int) – digital pin number
Returns:True if the given digital pin is enabled, False otherwise
Return type:boolean
is_digital_on(index, pin)

Tells if a given digital pin is on or not in a sample

Parameters:
  • index (int) – index of the sample
  • pin (int) – digital pin number
Returns:

True if the given digital pin is on in the sample, False otherwise

Return type:

boolean

get_analog(index, pin)

Gives the analog value of a pin in a sample

Parameters:
  • index (int) – index of the sample
  • pin (int) – analog pin number
Returns:

analog pin value

Return type:

int

class hachi.response.AtResponse(frame)

Response to a AtRequest

Frame example: 7E 00 07 88 52 4D 59 00 00 00 7F

frame_id

Frame Id, first byte of the id_data

command

Command, on 2 bytes immediately following the frame_id

status

Status, immediately following the command

value

Value, all bytes following the status until the end of the id_data

class hachi.response.TxStatusResponse(frame)

Status response emitted by the module after a Tx64Request or a Tx16Request

Frame example: 7E 00 03 89 2A 74 D8

frame_id

Frame Id, first byte of the id_data

status

Status, immediately following the frame_id

class hachi.response.ModemStatusResponse(frame)

Modem status response

Frame example: 7E 00 02 8A 06 6F

status

Status, first byte of the id_data

class hachi.response.ZBTxStatusResponse(frame)

Status response emitted by the module after a ZBTxRequest or a ZBExplicitTxRequest

Frame example: 7E 00 07 8B 01 7D 84 00 00 01 71

frame_id

Frame Id, first byte of the id_data

destination_address

Destination address, on 2 bytes immediately following the frame_id

retry_count

Retry count, immediately following the destination_address

delivery_status

Delivery status, immediately following the retry_count

discovery_status

Discovery status, immediately following the delivery_status

class hachi.response.ZBRxResponse(frame)

Response to a ZBTxRequest

Frame example: 7E 00 12 90 00 13 A2 00 40 52 2B AA 7D 84 01 52 78 44 61 74 61 0D

source_address_64

64-bits source address, first 8 bytes of the id_data

source_address_16

16-bits source address, on 2 bytes immediately following the source_address_64

options

Options, immediately following the source_address_16

data

Data, all bytes following the options until the end of the id_data

class hachi.response.ZBExplicitRxResponse(frame)

Response to a ZBExplicitTxRequest

Frame example: 7E 00 18 91 00 13 A2 00 40 52 2B AA 7D 84 E0 E0 22 11 C1 05 02 52 78 44 61 74 61 52

source_address_64

64-bits source address, first 8 bytes of the id_data

source_address_16

16-bits source address, on 2 bytes immediately following the source_address_64

source_endpoint

Source endpoint, immediately following the source_address_16

destination_endpoint

Destination endpoint, immediately following the source_endpoint

cluster_id

Cluster id, on 2 bytes immediately following the destination_endpoint

profile_id

Profile id, on 2 bytes immediately following the cluster_id

options

Options, immediately following the profile_id

data

Data, all bytes following the options until the end of the id_data

class hachi.response.ZBIoSampleResponse(frame)

IO sample response

Frame example: 7E 00 14 92 00 13 A2 00 40 52 2B AA 7D 84 01 01 00 1C 02 00 14 02 25 F5

source_address_64

64-bits source address, first 8 bytes of the id_data

source_address_16

16-bits source address, on 2 bytes immediately following the source_address_64

options

Options, immediately following the source_address_16

sample_count

Sample count, immediately following the options

digital_mask

Digital mask, on 2 bytes, immediately following the sample_count

analog_mask

Analog mask, immediately following the digital_mask

contains_digital

True if at least one digital channel is enabled, False otherwise

contains_analog

True if at least one analog channel is enabled, False otherwise

is_digital_enabled(pin)

Tells if a given digital pin is enabled or not

Parameters:pin (int) – digital pin number
Returns:True if the given digital pin is enabled, False otherwise
Return type:boolean
is_analog_enabled(pin)

Tells if a given analog pin is enabled or not

Parameters:pin (int) – analog pin number
Returns:True if the given analog pin is enabled, False otherwise
Return type:boolean
is_digital_on(pin)

Tells if a given digital pin is on or not

Parameters:pin (int) – digital pin number
Returns:True if the given digital pin is on, False otherwise
Return type:boolean
get_analog(pin)

Gives the analog value of a pin

Parameters:pin (int) – analog pin number
Returns:analog pin value
Return type:int
class hachi.response.RemoteAtResponse(frame)

Response to a RemoteAtRequest

Frame example: 7E 00 13 97 55 00 13 A2 00 40 52 2B AA 7D 84 53 4C 00 40 52 2B AA F0

frame_id

Frame Id, first byte of the id_data

source_address_64

64-bits source address, on 8 bytes immediately following the frame_id

source_address_16

16-bits source address, on 2 bytes immediately following the source_address_64

command

Command, on two bytes immediately following the source_address_16

status

Status, immediately following the command

data

Data, all bytes following the status until the end of the id_data if any None otherwise

Map

hachi.response.RESPONSE_MAP

Mapping from Response API IDs to XBeeResponse

Utilities

hachi.response.bitcount(number)

Count the number of bits to 1 in a number

For example:

>>> bitcount(0b10110010)
4
>>> bitcount(0b0100)
1
Parameters:number (int) – number on which to count the positive bits
Returns:the number of positive bits
Return type:int

Hachi

Hachi is a Python library to interact with XBees.

PyPI downloads

Donate

If you like hachi, please consider making a donation

Table Of Contents

Related Topics

This Page

Fork me on GitHub