Class: XBee::Frame::RemoteCommandRequest

Inherits:
ATCommand show all
Defined in:
lib/ruxbee/frame/remote_command_request.rb

Instance Attribute Summary collapse

Attributes inherited from ATCommand

#at_command, #parameter_pack_string, #parameter_value

Attributes inherited from Base

#frame_id

Instance Method Summary collapse

Methods inherited from Base

#_dump, #data, #length

Constructor Details

#initialize(at_command, destination_address = 0x000000000000ffff, destination_network = 0x0000fffe, frame_id = nil, parameter_value = nil, parameter_pack_string = "a*") {|_self| ... } ⇒ RemoteCommandRequest

Returns a new instance of RemoteCommandRequest.

Yields:

  • (_self)

Yield Parameters:



10
11
12
13
14
15
# File 'lib/ruxbee/frame/remote_command_request.rb', line 10

def initialize(at_command, destination_address = 0x000000000000ffff, destination_network = 0x0000fffe, frame_id = nil, parameter_value = nil, parameter_pack_string = "a*")
  self.destination_address = destination_address
  self.destination_network = destination_network
  super(at_command, frame_id, parameter_value, parameter_pack_string)
  yield self if block_given?
end

Instance Attribute Details

#destination_addressObject

Returns the value of attribute destination_address.



8
9
10
# File 'lib/ruxbee/frame/remote_command_request.rb', line 8

def destination_address
  @destination_address
end

#destination_networkObject

Returns the value of attribute destination_network.



8
9
10
# File 'lib/ruxbee/frame/remote_command_request.rb', line 8

def destination_network
  @destination_network
end

Instance Method Details

#api_identifierObject



6
# File 'lib/ruxbee/frame/remote_command_request.rb', line 6

def api_identifier ; 0x17 ; end

#cmd_dataObject



23
24
25
26
27
28
29
30
31
# File 'lib/ruxbee/frame/remote_command_request.rb', line 23

def cmd_data
  dest_high = (self.destination_address >> 32) & 0xFFFFFFFF
  dest_low = self.destination_address & 0xFFFFFFFF
  if parameter_value.nil?
    [self.frame_id, dest_high, dest_low, self.destination_network, 0x00, self.at_command].pack("CNNnCa2")
  else
    [self.frame_id, dest_high, dest_low, self.destination_network, 0x02, self.at_command, self.parameter_value].pack("CNNnCa2#{parameter_pack_string}")
  end
end

#cmd_data=(data_string) ⇒ Object



17
18
19
20
21
# File 'lib/ruxbee/frame/remote_command_request.rb', line 17

def cmd_data=(data_string)
  dest_high = dest_low = 0
  self.frame_id, dest_high, dest_low, self.destination_network, self.at_command, self.parameter_value = data_string.unpack("CNNnxa2#{parameter_pack_string}")
  self.destination_address = dest_high << 32 | dest_low
end