utel 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -0
- data/Gemfile +0 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/balance.rb +0 -0
- data/lib/utel.rb +0 -0
- data/lib/utel/balance.rb +5 -9
- data/lib/utel/device.rb +7 -8
- data/lib/utel/operator.rb +0 -0
- data/lib/utel/pdu.rb +34 -32
- data/lib/utel/sms.rb +0 -0
- data/lib/utel/version.rb +1 -1
- data/utel.gemspec +1 -1
- metadata +6 -8
data/.gitignore
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/README.md
CHANGED
File without changes
|
data/Rakefile
CHANGED
File without changes
|
data/balance.rb
CHANGED
File without changes
|
data/lib/utel.rb
CHANGED
File without changes
|
data/lib/utel/balance.rb
CHANGED
@@ -1,24 +1,20 @@
|
|
1
1
|
module Utel
|
2
2
|
class Balance
|
3
|
-
|
4
|
-
new.
|
5
|
-
end
|
6
|
-
|
7
|
-
def self.vas
|
8
|
-
new.vas
|
3
|
+
class << self
|
4
|
+
[:summary, :vas].each{|method| define_method(method) { new.send(method) }}
|
9
5
|
end
|
10
6
|
|
11
7
|
def summary
|
12
|
-
|
8
|
+
call_ussd "*100#"
|
13
9
|
end
|
14
10
|
|
15
11
|
def vas
|
16
|
-
|
12
|
+
call_ussd "*121#"
|
17
13
|
end
|
18
14
|
|
19
15
|
private
|
20
16
|
# @param [String] number USSD number service
|
21
|
-
def
|
17
|
+
def call_ussd number
|
22
18
|
File.open(Utel::DEVICE, "w+") do |f|
|
23
19
|
f.write "AT+CUSD=1,#{Utel::Pdu.encode(number)},15\r\n"
|
24
20
|
parse_result f
|
data/lib/utel/device.rb
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
module Utel
|
2
2
|
class Device
|
3
|
-
|
4
|
-
new.send_at
|
5
|
-
end
|
6
|
-
|
7
|
-
def self.pin(*args)
|
8
|
-
new.pin(*args)
|
9
|
-
end
|
3
|
+
[:send_at, :pin].each{|method| define_method(method) {|*args| new.send(method, *args) }}
|
10
4
|
|
11
5
|
def pin(code=PIN_CODE)
|
12
|
-
|
6
|
+
File.open(Utel::DEVICE, 'w+') do |f|
|
7
|
+
f.write "AT+CPIN=\"code\"\r\n"
|
8
|
+
while (s = f.gets) do
|
9
|
+
break if s.slice(0,2) == "OK"
|
10
|
+
end
|
11
|
+
end
|
13
12
|
end
|
14
13
|
|
15
14
|
def send_at
|
data/lib/utel/operator.rb
CHANGED
File without changes
|
data/lib/utel/pdu.rb
CHANGED
@@ -1,43 +1,45 @@
|
|
1
1
|
module Utel
|
2
2
|
class Pdu
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
3
|
+
class << self
|
4
|
+
# Encode and decode pdu strings
|
5
|
+
def encode string
|
6
|
+
out = ''
|
7
|
+
for i in (0..string.length - 1) do
|
8
|
+
t = i%8+1
|
9
|
+
next if t == 8
|
10
|
+
c = string[i] >> i%8
|
11
|
+
b = (string[i+1] || 0) & ((1 << t)-1)
|
12
|
+
c = (b << (8-t)) | c
|
13
|
+
out << c.to_s(16).rjust(2, '0').upcase
|
14
|
+
end
|
15
|
+
out
|
13
16
|
end
|
14
|
-
out
|
15
|
-
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
18
|
+
def decode string
|
19
|
+
out = ''
|
20
|
+
b = 0; d = 0
|
21
|
+
string.scan(/.{2}/).each do |part|
|
22
|
+
byte = part.to_i(16)
|
23
|
+
c = ((byte & ((1 << 7-d)-1)) << d) | b;
|
24
|
+
b = byte >> (7-d);
|
25
|
+
out << c.chr
|
26
|
+
d += 1
|
27
|
+
if d == 7
|
28
|
+
out << b.chr
|
29
|
+
d = 0; b = 0
|
30
|
+
end
|
29
31
|
end
|
32
|
+
out
|
30
33
|
end
|
31
|
-
out
|
32
|
-
end
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
def decimal_semi_octets number
|
36
|
+
reversed = ''
|
37
|
+
number.to_s.split('').each_slice(2) do |pair|
|
38
|
+
a,b = pair
|
39
|
+
reversed << (b.nil? ? "F" : b) << a
|
40
|
+
end
|
41
|
+
reversed
|
39
42
|
end
|
40
|
-
reversed
|
41
43
|
end
|
42
44
|
end
|
43
45
|
end
|
data/lib/utel/sms.rb
CHANGED
File without changes
|
data/lib/utel/version.rb
CHANGED
data/utel.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.version = Utel::VERSION
|
9
9
|
s.authors = ["Eugene Russkikh"]
|
10
10
|
s.email = ["eugene@russkikh.org.ua"]
|
11
|
-
s.homepage = "
|
11
|
+
s.homepage = "https://github.com/komba/utel"
|
12
12
|
s.summary = %q{Utel USSD}
|
13
13
|
s.description = %q{Utel USSD services balance checker}
|
14
14
|
|
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:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 4
|
10
|
+
version: 0.2.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Eugene Russkikh
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
19
|
-
default_executable:
|
18
|
+
date: 2012-07-19 00:00:00 Z
|
20
19
|
dependencies: []
|
21
20
|
|
22
21
|
description: Utel USSD services balance checker
|
@@ -42,8 +41,7 @@ files:
|
|
42
41
|
- lib/utel/sms.rb
|
43
42
|
- lib/utel/version.rb
|
44
43
|
- utel.gemspec
|
45
|
-
|
46
|
-
homepage: http://komba.org.ua
|
44
|
+
homepage: https://github.com/komba/utel
|
47
45
|
licenses: []
|
48
46
|
|
49
47
|
post_install_message:
|
@@ -72,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
70
|
requirements: []
|
73
71
|
|
74
72
|
rubyforge_project:
|
75
|
-
rubygems_version: 1.
|
73
|
+
rubygems_version: 1.8.10
|
76
74
|
signing_key:
|
77
75
|
specification_version: 3
|
78
76
|
summary: Utel USSD
|