lib/ruby_xbee.rb in ruby-xbee-1.1.0 vs lib/ruby_xbee.rb in ruby-xbee-1.2.0

- old
+ new

@@ -64,16 +64,16 @@ ## # This is it, the base class where it all starts. Command mode or API mode, version 1 or version 2, all XBees descend # from this class. class RFModule - + VERSION = "2.1" - + include XBee include Config - attr_accessor :xbee_serialport, :xbee_uart_config, :guard_time, :command_mode_timeout, :command_character, :node_discover_timeout, :node_identifier, :operation_mode, :transmission_mode + attr_accessor :xbee_serialport, :xbee_uart_config, :guard_time, :command_mode_timeout, :command_character, :node_discover_timeout, :node_identifier, :operation_mode, :api_mode, :transmission_mode attr_reader :serial_number, :hardware_rev, :firmware_rev def version VERSION end @@ -84,24 +84,25 @@ def initialize(xbee_usbdev_str = "/dev/tty.usbserial-A7004nmf", uart_config = XBeeUARTConfig.new, operation_mode = :AT, transmission_mode = :SYNC) unless uart_config.kind_of?(XBeeUARTConfig) raise "uart_config must be an instance of XBeeUARTConfig for this to work" end unless operation_mode == :AT || operation_mode == :API - raise "XBee operation_mode must be either AT or API" + raise "XBee operation_mode must be either :AT or :API" end unless transmission_mode == :SYNC || transmission_mode == :ASYNC - raise "XBee transmission_mode must be either SYNC (Synchronous) or ASYNC (Asynchronous)" + raise "XBee transmission_mode must be either :SYNC (Synchronous) or :ASYNC (Asynchronous)" end self.xbee_uart_config = uart_config @xbee_serialport = SerialPort.new( xbee_usbdev_str, uart_config.baud, uart_config.data_bits, uart_config.stop_bits, uart_config.parity ) @xbee_serialport.read_timeout = self.read_timeout(:short) @guard_time = GuardTime.new @command_mode_timeout= CommandModeTimeout.new @command_character = CommandCharacter.new @node_discover_timeout = NodeDiscoverTimeout.new @node_identifier = NodeIdentifier.new @operation_mode = operation_mode + @api_mode = ApiEnableMode.new @transmission_mode = transmission_mode end def in_command_mode sleep self.guard_time.in_seconds @@ -121,10 +122,10 @@ # work fine for most cases. The unit of time for a timeout constant is ms def read_timeout(type = :short) case type when :short 1200 - when :long + when :long 3000 else 3000 end end end