smartware 0.1.14 → 0.1.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,6 +31,10 @@ module Smartware
31
31
  "#{rand(90)*100+rand(9)} " + %w(руб. dollars тэньге).sample
32
32
  end
33
33
 
34
+ def balance
35
+ ussd
36
+ end
37
+
34
38
  end
35
39
 
36
40
  end
@@ -52,8 +52,14 @@ module Smartware
52
52
  #
53
53
  # Valid ussd answer sample: ["", "+CUSD: 2,\"003100310035002C003000300440002E00320031002E00330031002004310430043B002E0020\",72", "OK"]
54
54
  #
55
+ def balance
56
+ loop do
57
+ break if @balance = ussd('*100#')
58
+ sleep 0.5
59
+ end
60
+ end
61
+
55
62
  def ussd(code="*100#")
56
- self.send "AT"
57
63
  res = self.send "AT+CUSD=1,\"#{code}\",15"
58
64
  unless res[1][0..4] == "+CUSD"
59
65
  @error = ERRORS["11"]
@@ -52,7 +52,7 @@ module Smartware
52
52
  @status[:signal_level] = @device.signal_level
53
53
  @status[:model] = @device.model
54
54
  @status[:error] = @device.error
55
- @status[:balance] = @device.ussd('*100#')
55
+ @status[:balance] = @device.balance
56
56
  sleep 30
57
57
  end
58
58
  end
@@ -1,3 +1,3 @@
1
1
  module Smartware
2
- VERSION = "0.1.14"
2
+ VERSION = "0.1.15"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smartware
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.1.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: