utel 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -8,7 +8,6 @@ Utel::Balance
8
8
 
9
9
  Для корректной работы, в порт USB должен быть вставлен модем ОГО!Мобильный. Скрипт обращается к /dev/ttyUSB2, так что я думаю, что будет поддерживаться не только модемы Huawei, но и остальные
10
10
 
11
-
12
11
  Проверка баланса
13
12
  ----------------
14
13
 
@@ -3,7 +3,11 @@ require "utel/balance"
3
3
  require "utel/operator"
4
4
  require "utel/pdu"
5
5
  require "utel/sms"
6
+ require "utel/device"
6
7
 
7
8
  module Utel
9
+ # usb modem by default
8
10
  DEVICE = "/dev/ttyUSB2"
11
+ # default pin code
12
+ PIN_CODE = "0000"
9
13
  end
@@ -0,0 +1,24 @@
1
+ module Utel
2
+ class Device
3
+ def self.send_at
4
+ new.send_at
5
+ end
6
+
7
+ def self.pin(*args)
8
+ new.pin(*args)
9
+ end
10
+
11
+ def pin(code=PIN_CODE)
12
+ puts code
13
+ end
14
+
15
+ def send_at
16
+ File.open(Utel::DEVICE, 'w+') do |f|
17
+ f.write("AT\r\n")
18
+ while (s = f.gets) do
19
+ break if s.slice(0,2) == "OK"
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -30,5 +30,14 @@ module Utel
30
30
  end
31
31
  out
32
32
  end
33
+
34
+ def self.decimal_semi_octets number
35
+ reversed = ''
36
+ number.to_s.split('').each_slice(2) do |pair|
37
+ a,b = pair
38
+ reversed << (b.nil? ? "F" : b) << a
39
+ end
40
+ reversed
41
+ end
33
42
  end
34
43
  end
@@ -1,3 +1,3 @@
1
1
  module Utel
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.3"
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: 21
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 3
10
+ version: 0.2.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Eugene Russkikh
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-04 00:00:00 +03:00
18
+ date: 2011-08-05 00:00:00 +03:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -36,6 +36,7 @@ files:
36
36
  - balance.rb
37
37
  - lib/utel.rb
38
38
  - lib/utel/balance.rb
39
+ - lib/utel/device.rb
39
40
  - lib/utel/operator.rb
40
41
  - lib/utel/pdu.rb
41
42
  - lib/utel/sms.rb