Class: Sms::Method::GSM

Inherits:
Object
  • Object
show all
Defined in:
lib/sms/method/gsm.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ GSM

Returns a new instance of GSM.

Raises:

  • (ArgumentError)


8
9
10
11
12
13
14
15
16
17
# File 'lib/sms/method/gsm.rb', line 8

def initialize(options = {})
  raise ArgumentError.new('No :smsc was provided') unless options[:smsc]
  @port = SerialPort.new(options[:port] || 3, options[:baud] || 38400, options[:bits] || 8, options[:stop] || 1, SerialPort::NONE)
  @debug = options[:debug]
  cmd("AT")
  # Set to text mode
  cmd("AT+CMGF=1")
  # Set SMSC number
  cmd(%Q{AT+CSCA="#{options[:smsc]}"})
end

Instance Method Details

#closeObject



19
20
21
# File 'lib/sms/method/gsm.rb', line 19

def close
  @port.close
end