smartware 0.1.20 → 0.1.21
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.
@@ -10,8 +10,6 @@ module Smartware
|
|
10
10
|
ERRORS = {
|
11
11
|
"-1" => -1, # invalid device answer
|
12
12
|
"10" => 10, # invalid ussd answer
|
13
|
-
"11" => 11, # invalid ussd answer size
|
14
|
-
"12" => 12, # invalid ussd body answer size
|
15
13
|
"20" => 20, # invalid modem model
|
16
14
|
"21" => 21, # invalid modem signal level
|
17
15
|
}
|
@@ -54,7 +52,6 @@ module Smartware
|
|
54
52
|
# Valid ussd answer sample: ["", "+CUSD: 2,\"003100310035002C003000300440002E00320031002E00330031002004310430043B002E0020\",72", "OK"]
|
55
53
|
#
|
56
54
|
def ussd(code="*100#")
|
57
|
-
sleep 3
|
58
55
|
res = self.send("AT+CUSD=1,\"*100#\",15").reject{|i| i[0..4] != '+CUSD'}[0]
|
59
56
|
if res
|
60
57
|
ussd_body = res.split(",")[1].gsub('"','') # Parse USSD message body
|
@@ -66,6 +63,7 @@ module Smartware
|
|
66
63
|
end
|
67
64
|
|
68
65
|
def send(cmd)
|
66
|
+
@error = false
|
69
67
|
@sp.write "#{ cmd }\r\n"
|
70
68
|
read_port(@sp)
|
71
69
|
end
|
@@ -30,7 +30,7 @@ module Smartware
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def self.error
|
33
|
-
@status[:error]
|
33
|
+
@status[:error]
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.model
|
@@ -51,12 +51,14 @@ module Smartware
|
|
51
51
|
loop do
|
52
52
|
@status = {}
|
53
53
|
@status[:signal_level] = @device.signal_level
|
54
|
+
sleep 1
|
54
55
|
@status[:model] = @device.model
|
55
|
-
|
56
|
-
|
56
|
+
sleep 1
|
57
|
+
@status[:error] = @device.error || ''
|
58
|
+
sleep 3
|
57
59
|
balance = @device.ussd("*100#")
|
58
60
|
@status[:balance] = balance if balance
|
59
|
-
sleep
|
61
|
+
sleep 1
|
60
62
|
end
|
61
63
|
end
|
62
64
|
end
|
data/lib/smartware/version.rb
CHANGED