Class: XBee::Frames::XBeeSensorReadIndicator

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

Overview

When the device receives a sensor sample (from a Digi 1-wire sensor adapter), it is sent out the serial port using this message type (when AO=0).

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) ⇒ XBeeSensorReadIndicator

Returns a new instance of XBeeSensorReadIndicator.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/xbee/frames/xbee_sensor_read_indicator.rb', line 20

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
		@one_wire_sensors = @parse_bytes.shift
		@analog_values = [
			Bytes.unsigned_int_from_array(@parse_bytes.shift(2)),
			Bytes.unsigned_int_from_array(@parse_bytes.shift(2)),
			Bytes.unsigned_int_from_array(@parse_bytes.shift(2)),
			Bytes.unsigned_int_from_array(@parse_bytes.shift(2)),
		]
		@temperature = Bytes.unsigned_int_from_array(@parse_bytes.shift(2))
	end
end

Instance Attribute Details

#address16Object

Returns the value of attribute address16.



13
14
15
# File 'lib/xbee/frames/xbee_sensor_read_indicator.rb', line 13

def address16
  @address16
end

#address64Object

Returns the value of attribute address64.



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

def address64
  @address64
end

#analog_valuesObject

Array of 4 integers



16
17
18
# File 'lib/xbee/frames/xbee_sensor_read_indicator.rb', line 16

def analog_values
  @analog_values
end

#one_wire_sensorsObject

Returns the value of attribute one_wire_sensors.



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

def one_wire_sensors
  @one_wire_sensors
end

#optionsObject

Returns the value of attribute options.



14
15
16
# File 'lib/xbee/frames/xbee_sensor_read_indicator.rb', line 14

def options
  @options
end

#temperatureObject

Returns the value of attribute temperature.



17
18
19
# File 'lib/xbee/frames/xbee_sensor_read_indicator.rb', line 17

def temperature
  @temperature
end

Instance Method Details

#bytesObject



39
40
41
42
43
44
45
46
47
# File 'lib/xbee/frames/xbee_sensor_read_indicator.rb', line 39

def bytes
	super +
		(address64 || Address64::COORDINATOR).to_a +
		(address16 || Address16::COORDINATOR).to_a +
		[options || 0x00] +
		[one_wire_sensors || 0x00] +
		((analog_values || [0xffff] * 4).map { |v| Bytes.array_from_unsigned_int(v, 2) }.reduce(:+))+
		Bytes.array_from_unsigned_int(temperature || 0x0, 2)
end