Class: XBee::Frames::ExplicitRXIndicator

Inherits:
Frame
  • Object
show all
Defined in:
lib/xbee/frames/explicit_rx_indicator.rb

Overview

When a device configured with explicit API Rx Indicator (AO = 1) receives an RF packet, it sends it out the serial interface using this message type.

Constant Summary collapse

OPTION_BITS =
{
  0x01 => 'Acknowledged',
  0x02 => 'Broadcast packet',
  0x20 => 'Encrypted with APS encryption',
}.freeze

Instance Attribute Summary collapse

Attributes inherited from Frame

#packet

Instance Method Summary collapse

Methods inherited from Frame

api_id, from_packet, #to_packet

Constructor Details

#initialize(packet: nil) ⇒ ExplicitRXIndicator

Returns a new instance of ExplicitRXIndicator.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/xbee/frames/explicit_rx_indicator.rb', line 30

def initialize(packet: nil)
  super

  if @parse_bytes
    @address64 = Address64.new *@parse_bytes.shift(8)
    @address16 = Address16.new *@parse_bytes.shift(2)
    @source_endpoint = @parse_bytes.shift
    @destination_endpoint = @parse_bytes.shift
    @cluster_id = Bytes.unsigned_int_from_array @parse_bytes.shift(2)
    @profile_id = Bytes.unsigned_int_from_array @parse_bytes.shift(2)
    @options = @parse_bytes.shift
    @data = @parse_bytes
    @parse_bytes = []
  end
end

Instance Attribute Details

#address16Object

Returns the value of attribute address16.



21
22
23
# File 'lib/xbee/frames/explicit_rx_indicator.rb', line 21

def address16
  @address16
end

#address64Object

Returns the value of attribute address64.



20
21
22
# File 'lib/xbee/frames/explicit_rx_indicator.rb', line 20

def address64
  @address64
end

#cluster_idObject

16-bit scalar



24
25
26
# File 'lib/xbee/frames/explicit_rx_indicator.rb', line 24

def cluster_id
  @cluster_id
end

#dataObject

0-n bytes



27
28
29
# File 'lib/xbee/frames/explicit_rx_indicator.rb', line 27

def data
  @data
end

#destination_endpointObject

8-bit scalar



23
24
25
# File 'lib/xbee/frames/explicit_rx_indicator.rb', line 23

def destination_endpoint
  @destination_endpoint
end

#optionsObject

8-bit scalar



26
27
28
# File 'lib/xbee/frames/explicit_rx_indicator.rb', line 26

def options
  @options
end

#profile_idObject

16-bit scalar



25
26
27
# File 'lib/xbee/frames/explicit_rx_indicator.rb', line 25

def profile_id
  @profile_id
end

#source_endpointObject

8-bit scalar



22
23
24
# File 'lib/xbee/frames/explicit_rx_indicator.rb', line 22

def source_endpoint
  @source_endpoint
end

Instance Method Details

#bytesObject



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/xbee/frames/explicit_rx_indicator.rb', line 47

def bytes
  super +
    (address64 || Address64.from_array([0] * 8)).to_a +
    (address16 || Address16.new(0, 0)).to_a +
    [source_endpoint || 0x00] +
    [destination_endpoint || 0x00] +
    Bytes.array_from_unsigned_int(cluster_id || 0) +
    Bytes.array_from_unsigned_int(profile_id || 0) +
    [options || 0x00] +
    (data || [])
end