Class: XBee::Frame::ATCommandResponse

Inherits:
ReceivedFrame show all
Defined in:
lib/apimode/frame/at_command_response.rb

Direct Known Subclasses

RemoteCommandResponse

Instance Attribute Summary collapse

Attributes inherited from Base

#api_identifier, #cmd_data

Instance Method Summary collapse

Methods inherited from Base

#_dump, #data, #length

Constructor Details

#initialize(data = nil) ⇒ ATCommandResponse

Returns a new instance of ATCommandResponse.



6
7
8
# File 'lib/apimode/frame/at_command_response.rb', line 6

def initialize(data = nil)
  super(data) && (yield self if block_given?)
end

Instance Attribute Details

#at_commandObject

Returns the value of attribute at_command.



4
5
6
# File 'lib/apimode/frame/at_command_response.rb', line 4

def at_command
  @at_command
end

#frame_idObject

Returns the value of attribute frame_id.



4
5
6
# File 'lib/apimode/frame/at_command_response.rb', line 4

def frame_id
  @frame_id
end

#retrieved_valueObject

Returns the value of attribute retrieved_value.



4
5
6
# File 'lib/apimode/frame/at_command_response.rb', line 4

def retrieved_value
  @retrieved_value
end

#statusObject

Returns the value of attribute status.



4
5
6
# File 'lib/apimode/frame/at_command_response.rb', line 4

def status
  @status
end

Instance Method Details

#cmd_data=(data_string) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/apimode/frame/at_command_response.rb', line 14

def cmd_data=(data_string)
  self.frame_id, self.at_command, status_byte, self.retrieved_value = data_string.unpack("Ca2Ca*")
  self.status = case status_byte
  when 0..3 
    command_statuses[status_byte]
  else
    raise "AT Command Response frame appears to include an invalid status: 0x%x" % status_byte
  end
  #actually assign and move along
  @cmd_data = data_string
  #### DEBUG ####
  if $DEBUG then
    print "Retrieved Value: #{self.retrieved_value.unpack('C*').join(', ')} | "
    print "Retrieved Value: #{self.retrieved_value.unpack('a*')} | "
  end
  #### DEBUG ####
end

#command_statusesObject



10
11
12
# File 'lib/apimode/frame/at_command_response.rb', line 10

def command_statuses
  [:OK, :ERROR, :Invalid_Command, :Invalid_Parameter]
end