Class: XBee::Frames::DataSampleRXIndicator

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

Constant Summary collapse

OPTION_BITS =
{
  0x01 => :acknowledged,
  0x02 => :broadcast,
}.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) ⇒ DataSampleRXIndicator

Returns a new instance of DataSampleRXIndicator.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/xbee/frames/data_sample_rx_indicator.rb', line 24

def initialize(packet: nil)
  @samples = []

  super

  if @parse_bytes
    @address64 = Address64.new *@parse_bytes.shift(8)
    @address16 = Address16.new *@parse_bytes.shift(2)
    @options = @parse_bytes.shift
    @number_of_samples = @parse_bytes.shift
    @number_of_samples.times do
      @samples << Data::Sample.new(parse_bytes: @parse_bytes)
    end
  end
end

Instance Attribute Details

#address16Object (readonly)

Returns the value of attribute address16.



10
11
12
# File 'lib/xbee/frames/data_sample_rx_indicator.rb', line 10

def address16
  @address16
end

#address64Object (readonly)

Returns the value of attribute address64.



11
12
13
# File 'lib/xbee/frames/data_sample_rx_indicator.rb', line 11

def address64
  @address64
end

#optionsObject (readonly)

Returns the value of attribute options.



12
13
14
# File 'lib/xbee/frames/data_sample_rx_indicator.rb', line 12

def options
  @options
end

#samplesObject (readonly)

Array<Data::DataSample>

Array of sample objects



15
16
17
# File 'lib/xbee/frames/data_sample_rx_indicator.rb', line 15

def samples
  @samples
end

Instance Method Details

#bytesObject



41
42
43
44
45
46
47
48
# File 'lib/xbee/frames/data_sample_rx_indicator.rb', line 41

def bytes
  super +
    (address64 || Address64::COORDINATOR).to_a +
    (address16 || Address16::COORDINATOR).to_a +
    [options || 0x00] +
    [(samples || []).length] +
    samples.map(&:to_a).reduce(:+)
end