utel 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -18,12 +18,25 @@ Utel::Balance
18
18
  Utel::Balance.vas
19
19
  => "Internet:3G 1572602.0Kb,Universalnyi 144140.0Kb,Nat.rouming 0.0Kb;0.0SMS po Ukraini;0v mezhah Ukrainy;0na inshi mobilni Ukrainy"
20
20
 
21
- Или же кастомным скриптом
21
+ Текущий оператор
22
+ ----------------
23
+
24
+ Utel::Operator.name
25
+ => "UTEL3G�"
26
+
27
+ Отправить SMS
28
+ -------------
29
+
30
+ Utel::SMS.send('0917776655', 'Hello, world!')
31
+
32
+
33
+ Узнать баланс и текущего оператора кастомным скриптом
22
34
  ---------------------------
23
35
 
24
36
  $ ruby balance.rb
25
37
  Vash balans:zagal'nyi 46,06; paketnyi 0,00; dodatkovyi 0,00 hrn.Perevirka dodatkovykh poslug *121#
26
38
  Internet:3G 1572602.0Kb,Universalnyi 144140.0Kb,Nat.rouming 0.0Kb;0.0SMS po Ukraini;0v mezhah Ukrainy;0na inshi mobilni Ukrainy
39
+ UTEL3G�
27
40
 
28
41
  TODO
29
42
  ----
data/balance.rb CHANGED
@@ -1,8 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'utel'
3
3
 
4
- Utel::DEVICE = "/dev/ttyUSB3"
5
-
6
4
  puts Utel::Balance.summary
7
5
  puts Utel::Balance.vas
8
6
  puts Utel::Operator.name
@@ -2,6 +2,7 @@ require "utel/version"
2
2
  require "utel/balance"
3
3
  require "utel/operator"
4
4
  require "utel/pdu"
5
+ require "utel/sms"
5
6
 
6
7
  module Utel
7
8
  DEVICE = "/dev/ttyUSB2"
@@ -15,6 +15,7 @@ module Utel
15
15
  end
16
16
  end
17
17
  out
18
+ "Utel 3G" if out =~ /25507/
18
19
  end
19
20
  end
20
21
  end
@@ -0,0 +1,34 @@
1
+ module Utel
2
+ class SMS
3
+ def self.send *args
4
+ new.send(*args)
5
+ end
6
+
7
+ def send number, message
8
+ out = ''
9
+ File.open(Utel::DEVICE, "w+") do |f|
10
+ f.write "AT+CMGF=1\r\n"
11
+ f.write "AT+CMGS=\"#{number}\"\r\n"
12
+ f.write "#{message}\x1A"
13
+
14
+ while(s = f.gets) do
15
+ if s.slice(0, 2) == "OK"
16
+ out << s
17
+ break if out.scan(/OK/).count == 2
18
+ else
19
+ if (s.slice(0, 10) == "+CMS ERROR")
20
+ out << s
21
+ break
22
+ end
23
+ end
24
+ end
25
+ end
26
+ parse_response(out)
27
+ end
28
+
29
+ private
30
+ def parse_response output
31
+ output =~ /ERROR/ ? false : true
32
+ end
33
+ end
34
+ end
@@ -1,3 +1,3 @@
1
1
  module Utel
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: utel
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Eugene Russkikh
@@ -38,6 +38,7 @@ files:
38
38
  - lib/utel/balance.rb
39
39
  - lib/utel/operator.rb
40
40
  - lib/utel/pdu.rb
41
+ - lib/utel/sms.rb
41
42
  - lib/utel/version.rb
42
43
  - utel.gemspec
43
44
  has_rdoc: true