Class: XBee::Frame::ModemStatus

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

Instance Attribute Summary collapse

Attributes inherited from Base

#api_identifier, #cmd_data, #frame_id

Instance Method Summary collapse

Methods inherited from Base

#_dump, #data, #length

Constructor Details

#initialize(data = nil) ⇒ ModemStatus

Returns a new instance of ModemStatus.



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

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

Instance Attribute Details

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

Instance Method Details

#cmd_data=(data_string) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/apimode/frame/modem_status.rb', line 18

def cmd_data=(data_string)
  status_byte = data_string.unpack("c")[0]
  # update status ivar for later use
  self.status = case status_byte
  when 0..2
    modem_statuses.assoc(status_byte)
  else
    raise "ModemStatus frame appears to include an invalid status value: #{data_string}"
  end
  #actually assign and move along
  @cmd_data = data_string
end

#modem_statusesObject



10
11
12
13
14
15
16
# File 'lib/apimode/frame/modem_status.rb', line 10

def modem_statuses
  [
    [0, :Hardware_Reset],
    [1, :Watchdog_Timer_Reset],
    [2, :Associated],
  ]
end