Class: XBee::Frames::ReceivePacket

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

Overview

When a device configured with a standard API Rx Indicator (AO = 0) receives an RF data 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',
	0x40 => 'End device',
}.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) ⇒ ReceivePacket

Returns a new instance of ReceivePacket.



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/xbee/frames/receive_packet.rb', line 26

def initialize(packet: nil)
	super

	if @parse_bytes
		@address64 = Address64.new *@parse_bytes.shift(8)
		@address16 = Address16.new *@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/receive_packet.rb', line 21

def address16
  @address16
end

#address64Object

Returns the value of attribute address64.



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

def address64
  @address64
end

#dataObject

Returns the value of attribute data.



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

def data
  @data
end

#optionsObject

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

#bytesObject



39
40
41
# File 'lib/xbee/frames/receive_packet.rb', line 39

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