class XBee::Frame::Base

Attributes

api_identifier[RW]
cmd_data[RW]
frame_id[RW]

Public Instance Methods

_dump(api_mode = :API1) click to toggle source
# File lib/ruxbee/frame/base_frame.rb, line 17
def _dump(api_mode = :API1)
  unless api_mode == :API1 or api_mode == :API2
    raise "XBee api_mode must be either :API1 (non-escaped) or :API2 (escaped, default)"
  end
  raise "Too much data (#{self.length} bytes) to fit into one frame!" if (self.length > 0xFFFF)

  if (api_mode == :API1)
    "~" + [length].pack("n") + data + [Frame.checksum(data)].pack("C")
  elsif (api_mode == :API2)
    "~" + [length].pack("n").xb_escape + data.xb_escape + [Frame.checksum(data)].pack("C")
  end
end
data() click to toggle source
# File lib/ruxbee/frame/base_frame.rb, line 13
def data
  Array(api_identifier).pack("C") + cmd_data
end
length() click to toggle source
# File lib/ruxbee/frame/base_frame.rb, line 11
def length ; data.length ; end