Class: XBee::Frame::ATCommand

Inherits:
Base
  • Object
show all
Defined in:
lib/apimode/frame/at_command.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#frame_id

Instance Method Summary collapse

Methods inherited from Base

#_dump, #data, #length

Constructor Details

#initialize(at_command, frame_id = nil, parameter_value = nil, parameter_pack_string = "a*") {|_self| ... } ⇒ ATCommand

Returns a new instance of ATCommand.

Yields:

  • (_self)

Yield Parameters:



8
9
10
11
12
13
14
# File 'lib/apimode/frame/at_command.rb', line 8

def initialize(at_command, frame_id = nil, parameter_value = nil, parameter_pack_string = "a*")
  self.frame_id = frame_id
  self.at_command = at_command # TODO: Check for valid AT command codes here
  self.parameter_value = parameter_value
  self.parameter_pack_string = parameter_pack_string
  yield self if block_given?
end

Instance Attribute Details

#at_commandObject

Returns the value of attribute at_command.



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

def at_command
  @at_command
end

#parameter_pack_stringObject

Returns the value of attribute parameter_pack_string.



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

def parameter_pack_string
  @parameter_pack_string
end

#parameter_valueObject

Returns the value of attribute parameter_value.



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

def parameter_value
  @parameter_value
end

Instance Method Details

#api_identifierObject



4
# File 'lib/apimode/frame/at_command.rb', line 4

def api_identifier ; 0x08 ; end

#cmd_dataObject



20
21
22
23
24
25
26
# File 'lib/apimode/frame/at_command.rb', line 20

def cmd_data
  if parameter_value.nil?
    [frame_id, at_command].pack("ca2")
  else
    [frame_id, at_command, parameter_value].pack("ca2#{parameter_pack_string}")
  end
end

#cmd_data=(data_string) ⇒ Object



16
17
18
# File 'lib/apimode/frame/at_command.rb', line 16

def cmd_data=(data_string)
  self.frame_id, self.at_command, self.parameter_value = data_string.unpack("ca2#{parameter_pack_string}")
end