2013-02-22 14:06:49 +01:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
#encoding: utf-8
|
|
|
|
|
|
|
|
$: << 'lib'
|
|
|
|
|
|
|
|
require 'biju'
|
|
|
|
require 'pp'
|
|
|
|
|
2013-02-28 22:55:59 +01:00
|
|
|
#str = 'www.ruby-lang.org and bonjour www.rubygarden.org coucou'
|
2013-02-22 14:06:49 +01:00
|
|
|
#re = /
|
|
|
|
# ( # capture the hostname in $1
|
|
|
|
# (?: # these parens for grouping only
|
|
|
|
# (?! [-_] ) # lookahead for neither underscore nor dash
|
|
|
|
# [\w-] + # hostname component
|
|
|
|
# \. # and the domain dot
|
|
|
|
# ) + # now repeat that whole thing a bunch of times
|
|
|
|
# [A-Za-z] # next must be a letter
|
|
|
|
# [\w-] + # now trailing domain part
|
|
|
|
# ) # end of $1 capture
|
|
|
|
# /x # /x for nice formatting
|
2013-02-28 22:55:59 +01:00
|
|
|
#str = '((www.ruby-lang.org), (www.rubygarden.org), (www.co.com) ucou)'
|
|
|
|
strs = []
|
|
|
|
strs << '((www.ruby-lang.org), (www.rubygarden.org), (www.co.com) (u)cou)'
|
|
|
|
strs << '(www.ruby-lang.org), (www.rubygarden.org), (www.co.com) (u)'
|
2013-02-22 14:06:49 +01:00
|
|
|
|
2013-02-28 22:55:59 +01:00
|
|
|
re = /
|
|
|
|
\( # parenthese
|
|
|
|
(
|
|
|
|
#[^\(\)]*?
|
|
|
|
[\(\)]*?
|
|
|
|
.*?
|
|
|
|
)
|
|
|
|
\) # parenthese
|
|
|
|
/x
|
|
|
|
|
|
|
|
strs.each do |str|
|
|
|
|
pp "STR : #{str}"
|
|
|
|
str.gsub! re do # pass a block to execute replacement
|
|
|
|
pp $1
|
|
|
|
end
|
2013-02-22 14:06:49 +01:00
|
|
|
end
|
|
|
|
|
2013-02-28 22:55:59 +01:00
|
|
|
exit
|
2013-02-22 14:06:49 +01:00
|
|
|
|
|
|
|
puts "here"
|
|
|
|
hayes = Biju::HayesSms.new
|
|
|
|
pp hayes.attention
|
|
|
|
pp hayes.answer = 'OK'
|
|
|
|
pp hayes.ok?
|
|
|
|
pp hayes.init_modem
|
|
|
|
pp hayes.answer = 'OK'
|
|
|
|
pp hayes.ok?
|
|
|
|
pp hayes.text_mode
|
|
|
|
pp (hayes.answer = 'OK')
|
|
|
|
pp hayes.ok?
|
|
|
|
pp hayes.prefered_storage?
|
|
|
|
pp hayes.answer = '+CPMS: ("ME","MT","SM","SR"),("ME","MT","SM","SR"),("ME","MT","SM","SR")'
|
|
|
|
# ((),(),())
|
|
|
|
# (),(),()
|
|
|
|
# 1,2
|
|
|
|
|
|
|
|
pp hayes.ok?
|
|
|
|
|
|
|
|
exit
|
|
|
|
|
|
|
|
@modem = Biju::Modem.new(:port => "/dev/ttyUSB0", :pin => '2382')
|
|
|
|
|
|
|
|
# method to list all messages
|
|
|
|
@modem.messages.each do |sms|
|
|
|
|
puts sms
|
|
|
|
end
|
|
|
|
|
|
|
|
# method to send sms
|
|
|
|
sms = Biju::Sms.new(:phone_number => "0668486469", :message => 'hello world3')
|
|
|
|
puts @modem.send(sms)
|
|
|
|
|
|
|
|
@modem.close
|
|
|
|
|
|
|
|
|