da_funk 3.30.0 → 3.34.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +10 -1
- data/Gemfile.lock +12 -2
- data/README.md +0 -0
- data/README_GUIDE.md +0 -0
- data/RELEASE_NOTES.md +27 -0
- data/Rakefile +14 -0
- data/guides/sample_input_output.rb +0 -0
- data/guides/sample_message_iso8583.rb +0 -0
- data/guides/sample_network_gprs.rb +0 -0
- data/guides/sample_read_magnect_card.rb +0 -0
- data/guides/sample_socket.rb +0 -0
- data/guides/sample_transaction.rb +0 -0
- data/guides/sample_transaction_download_application.rb +0 -0
- data/guides/sample_transaction_download_file.rb +0 -0
- data/guides/sample_transaction_download_parameter_file.rb +0 -0
- data/lib/da_funk/connection_management.rb +25 -10
- data/lib/da_funk/event_handler.rb +1 -1
- data/lib/da_funk/helper.rb +55 -16
- data/lib/da_funk/helper/status_bar.rb +158 -105
- data/lib/da_funk/params_dat.rb +65 -25
- data/lib/da_funk/rake_task.rb +13 -6
- data/lib/da_funk/transaction/download.rb +0 -0
- data/lib/da_funk/transaction/iso.rb +0 -0
- data/lib/da_funk/version.rb +1 -1
- data/lib/device.rb +0 -0
- data/lib/device/crypto.rb +0 -0
- data/lib/device/display.rb +2 -1
- data/lib/device/io.rb +53 -0
- data/lib/device/network.rb +19 -33
- data/lib/device/printer.rb +0 -0
- data/lib/device/setting.rb +0 -0
- data/lib/device/system.rb +9 -0
- data/lib/device/version.rb +0 -0
- data/lib/device/virtual_keyboard.rb +81 -34
- data/lib/file_db.rb +0 -0
- data/lib/iso8583/bitmap.rb +94 -54
- data/lib/iso8583/codec.rb +3 -3
- data/lib/iso8583/field.rb +38 -3
- data/lib/iso8583/fields.rb +3 -1
- data/lib/iso8583/message.rb +25 -12
- data/lib/iso8583/util.rb +1 -1
- data/test/iso8583/bitmap_test.rb +277 -0
- data/test/iso8583/message_test.rb +111 -0
- data/test/iso8583/minitest_helper.rb +11 -0
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3a687d541cc683675f05e5ebcf8d28504a929c97a57606e9af3d5f238f04def
|
4
|
+
data.tar.gz: f3a1c52920ca5d00f3b43a3d9e513dad9ae883b7167c4b8c37509089bc489af6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c7d8b462ac97d930628a593a27bc5a7388d3543683f9950db9449d34d22159c68250dc6a8cd2aa24abbed62c5b0ddd09711d0ca0b040924e9337d4f85e1b1e0
|
7
|
+
data.tar.gz: 40d72d5925bfaf49d65bc54ccbfb2c231d8d2f548fd13f784a8bc1bf1b4c863418251e4a1b773ef44836a01dc3fe53321f5f736e33ae9666fd7783546676eac2
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
da_funk (3.
|
4
|
+
da_funk (3.34.0)
|
5
5
|
archive-zip (~> 0.5)
|
6
6
|
bundler
|
7
7
|
cloudwalk_handshake
|
@@ -15,17 +15,20 @@ GEM
|
|
15
15
|
archive-zip (0.12.0)
|
16
16
|
io-like (~> 0.3.0)
|
17
17
|
ast (2.4.1)
|
18
|
+
byebug (11.1.3)
|
18
19
|
cloudwalk (1.15.0)
|
19
20
|
bundler
|
20
21
|
rake
|
21
22
|
cloudwalk_handshake (1.21.3)
|
22
23
|
funky-simplehttp (~> 0.6)
|
24
|
+
docile (1.3.5)
|
23
25
|
funky-emv (1.4.1)
|
24
26
|
funky-tlv (~> 0.2)
|
25
27
|
funky-mock (0.1.0)
|
26
28
|
funky-simplehttp (0.6.0)
|
27
29
|
funky-tlv (0.2.3)
|
28
30
|
io-like (0.3.1)
|
31
|
+
minitest (5.14.4)
|
29
32
|
parallel (1.19.2)
|
30
33
|
parser (2.7.2.0)
|
31
34
|
ast (~> 2.4.1)
|
@@ -47,6 +50,10 @@ GEM
|
|
47
50
|
rubocop-ast (1.1.0)
|
48
51
|
parser (>= 2.7.1.5)
|
49
52
|
ruby-progressbar (1.10.1)
|
53
|
+
simplecov (0.18.5)
|
54
|
+
docile (~> 1.1)
|
55
|
+
simplecov-html (~> 0.11)
|
56
|
+
simplecov-html (0.12.3)
|
50
57
|
unicode-display_width (1.7.0)
|
51
58
|
yard (0.9.25)
|
52
59
|
|
@@ -56,12 +63,15 @@ PLATFORMS
|
|
56
63
|
x86-mingw32
|
57
64
|
|
58
65
|
DEPENDENCIES
|
66
|
+
byebug
|
59
67
|
cloudwalk
|
60
68
|
da_funk!
|
61
69
|
funky-mock
|
62
70
|
funky-simplehttp
|
71
|
+
minitest
|
63
72
|
rubocop
|
73
|
+
simplecov
|
64
74
|
yard
|
65
75
|
|
66
76
|
BUNDLED WITH
|
67
|
-
2.
|
77
|
+
2.2.7
|
data/README.md
CHANGED
File without changes
|
data/README_GUIDE.md
CHANGED
File without changes
|
data/RELEASE_NOTES.md
CHANGED
@@ -1,5 +1,32 @@
|
|
1
1
|
# DaFunk
|
2
2
|
|
3
|
+
### 3.33.1 - 2021-02-19
|
4
|
+
|
5
|
+
- Fixed argument being passed to hours2seconds method which was nil;
|
6
|
+
|
7
|
+
### 3.33.0 - 2021-02-08
|
8
|
+
|
9
|
+
- Added method Device::IO#get_format_or_touchscreen_action;
|
10
|
+
- Added support to images on ParamsDat#download, ParamsDat#update_app and ParamsDat#update_file;
|
11
|
+
- Return result of ParamsDat#update_apps call to the caller.
|
12
|
+
|
13
|
+
### 3.32.0 - 2021-01-04
|
14
|
+
|
15
|
+
- Remapped virtual keyboard to add support to new layout;
|
16
|
+
- Make timeout of virtual keyboard parametrized;
|
17
|
+
- Limit size of string to 20 on virtual keyboard;
|
18
|
+
- Refactoring status bar:
|
19
|
+
- Check if thread is paused which means communication it's being configured. In this case 'sem sinal' message should be displayed;
|
20
|
+
- Do not show media type an media icon if thread is paused;
|
21
|
+
- Removed thread pause from attach and scan calls, let the application that is doing the configuration take care of that;
|
22
|
+
- Move reload of metadata to communication thread;
|
23
|
+
- Added support to check network conn status from time to time, default is each 5 minutes.
|
24
|
+
|
25
|
+
### 3.31.0 - 2020-11-27
|
26
|
+
|
27
|
+
- Added support to new battery view (Exact percentage);
|
28
|
+
- Added support to new main screen when there's a pending sale.
|
29
|
+
|
3
30
|
### 3.30.0 - 2020-11-16
|
4
31
|
|
5
32
|
- Replace GPRS icon to 3G;
|
data/Rakefile
CHANGED
@@ -90,3 +90,17 @@ end
|
|
90
90
|
task "test:all" => :build
|
91
91
|
task "test:unit" => :build
|
92
92
|
task "test:integration" => :build
|
93
|
+
|
94
|
+
Rake::TestTask.new('test:iso8583') do |t|
|
95
|
+
Bundler.require(:default, :test)
|
96
|
+
t.libs << File.join("lib", "da_funk", "helper")
|
97
|
+
t.libs << File.join("lib","iso8583")
|
98
|
+
t.libs << File.join("test", "iso8583")
|
99
|
+
t.test_files = FileList['test/iso8583/**/*_test.rb']
|
100
|
+
end
|
101
|
+
|
102
|
+
task "test:iso8583:cov" do
|
103
|
+
ENV.store('COV', '1')
|
104
|
+
Bundler.require(:default, :test)
|
105
|
+
Rake::Task["test:iso8583"].execute
|
106
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/guides/sample_socket.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,21 +1,23 @@
|
|
1
1
|
module DaFunk
|
2
2
|
class ConnectionManagement
|
3
3
|
class << self
|
4
|
-
attr_accessor :drops, :primary_timeout
|
4
|
+
attr_accessor :drops, :primary_timeout, :last_time_check
|
5
5
|
end
|
6
6
|
self.drops = 0
|
7
7
|
DEFAULT_DROP_LIMIT = 2
|
8
8
|
|
9
9
|
def self.check
|
10
|
-
if
|
11
|
-
if
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
if fallback?
|
16
|
-
:fallback_communication
|
10
|
+
if must_check?
|
11
|
+
if Device::Network.connected?
|
12
|
+
if primary_try?
|
13
|
+
:primary_communication
|
14
|
+
end
|
17
15
|
else
|
18
|
-
|
16
|
+
if fallback?
|
17
|
+
:fallback_communication
|
18
|
+
else
|
19
|
+
:attach_registration_fail
|
20
|
+
end
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
@@ -125,6 +127,19 @@ module DaFunk
|
|
125
127
|
def self.schedule_primary_timeout
|
126
128
|
self.primary_timeout = (Time.now + self.conn_fallback_timer)
|
127
129
|
end
|
130
|
+
|
131
|
+
def self.must_check?
|
132
|
+
if self.last_time_check
|
133
|
+
if self.last_time_check < Time.now
|
134
|
+
self.last_time_check = Time.now + @value
|
135
|
+
true
|
136
|
+
end
|
137
|
+
else
|
138
|
+
@value = DaFunk::ParamsDat.file['conn_check_timer']
|
139
|
+
@value = @value.nil? ? 300 : @value * 60
|
140
|
+
self.last_time_check = Time.now + @value
|
141
|
+
true
|
142
|
+
end
|
143
|
+
end
|
128
144
|
end
|
129
145
|
end
|
130
|
-
|
@@ -52,7 +52,7 @@ module DaFunk
|
|
52
52
|
end
|
53
53
|
|
54
54
|
unless config["timestamp"]
|
55
|
-
config["timestamp"] = hours2seconds(option[
|
55
|
+
config["timestamp"] = hours2seconds(option[:hours])
|
56
56
|
else
|
57
57
|
if config["interval"]["hours"].to_s != option[:hours].to_s
|
58
58
|
config["timestamp"] = hours2seconds(option[:hours])
|
data/lib/da_funk/helper.rb
CHANGED
@@ -61,38 +61,77 @@ module DaFunk
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
def check_download_error(
|
65
|
-
value =
|
64
|
+
def check_download_error(download_ret, enable_txt_ui = true)
|
65
|
+
value = false
|
66
|
+
|
67
|
+
if download_ret == DaFunk::Transaction::Download::FILE_NOT_CHANGE
|
68
|
+
if enable_txt_ui
|
69
|
+
I18n.pt(:download_file_is_the_same, :args => [download_ret])
|
70
|
+
getc(1000)
|
71
|
+
end
|
72
|
+
value = true
|
73
|
+
elsif download_ret == DaFunk::Transaction::Download::SUCCESS
|
74
|
+
if enable_txt_ui
|
75
|
+
I18n.pt(:download_success, :args => [download_ret])
|
76
|
+
getc(1000)
|
77
|
+
end
|
78
|
+
value = true
|
79
|
+
end
|
80
|
+
value
|
81
|
+
end
|
82
|
+
|
83
|
+
def show_download_error(download_ret, enable_txt_ui = true)
|
66
84
|
ui = {}
|
67
85
|
|
68
|
-
case
|
86
|
+
case download_ret
|
69
87
|
when DaFunk::Transaction::Download::SERIAL_NUMBER_NOT_FOUND
|
88
|
+
unless enable_txt_ui
|
89
|
+
Device::Display.print_bitmap('./shared/config_fail.bmp')
|
90
|
+
getc(5000)
|
91
|
+
end
|
70
92
|
ui[:i18n] = :download_serial_number_not_found
|
71
|
-
|
93
|
+
ContextLog.info "[I] Download error, serial number not registered"
|
72
94
|
when DaFunk::Transaction::Download::FILE_NOT_FOUND
|
95
|
+
unless enable_txt_ui
|
96
|
+
Device::Display.print_bitmap('./shared/config_fail.bmp')
|
97
|
+
getc(5000)
|
98
|
+
end
|
73
99
|
ui[:i18n] = :download_file_not_found
|
74
|
-
|
75
|
-
when DaFunk::Transaction::Download::FILE_NOT_CHANGE
|
76
|
-
ui[:i18n] = :download_file_is_the_same
|
77
|
-
when DaFunk::Transaction::Download::SUCCESS
|
78
|
-
ui[:i18n] = :download_success
|
100
|
+
ContextLog.info "[I] Download error, file not found"
|
79
101
|
when DaFunk::Transaction::Download::COMMUNICATION_ERROR
|
102
|
+
unless enable_txt_ui
|
103
|
+
Device::Display.print_bitmap('./shared/network_system_error.bmp')
|
104
|
+
getc(5000)
|
105
|
+
end
|
80
106
|
ui[:i18n] = :download_communication_failure
|
81
|
-
|
107
|
+
ContextLog.info "[I] Download error, connection problem"
|
82
108
|
when DaFunk::Transaction::Download::MAPREDUCE_RESPONSE_ERROR
|
109
|
+
unless enable_txt_ui
|
110
|
+
Device::Display.print_bitmap('./shared/config_fail.bmp')
|
111
|
+
getc(5000)
|
112
|
+
end
|
83
113
|
ui[:i18n] = :download_encoding_error
|
84
|
-
|
114
|
+
ContextLog.info "[I] Download error, encoding problem"
|
85
115
|
when DaFunk::Transaction::Download::IO_ERROR
|
116
|
+
unless enable_txt_ui
|
117
|
+
Device::Display.print_bitmap('./shared/config_fail.bmp')
|
118
|
+
getc(5000)
|
119
|
+
end
|
86
120
|
ui[:i18n] = :download_io_error
|
87
|
-
|
121
|
+
ContextLog.info "[I] Download error, IO error"
|
88
122
|
else
|
123
|
+
unless enable_txt_ui
|
124
|
+
Device::Display.print_bitmap('./shared/network_system_error.bmp')
|
125
|
+
getc(5000)
|
126
|
+
end
|
89
127
|
ui[:i18n] = :download_communication_failure
|
90
|
-
|
128
|
+
ContextLog.info "[I] Download error, connection problem"
|
91
129
|
end
|
92
130
|
|
93
|
-
|
94
|
-
|
95
|
-
|
131
|
+
if enable_txt_ui
|
132
|
+
I18n.pt(ui[:i18n], :args => [download_ret])
|
133
|
+
getc(5000)
|
134
|
+
end
|
96
135
|
end
|
97
136
|
|
98
137
|
def try(tries, &block)
|
@@ -1,31 +1,75 @@
|
|
1
|
+
#
|
2
|
+
# @file status_bar.rb
|
3
|
+
# @brief DaFunk status bar helper script.
|
4
|
+
# @platform N/A
|
5
|
+
#
|
6
|
+
# @copyright Copyright (c) 2016 CloudWalk, Inc.
|
7
|
+
#
|
8
|
+
|
1
9
|
module DaFunk
|
2
10
|
module Helper
|
11
|
+
# Status bar class definition.
|
3
12
|
class StatusBar
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
13
|
+
# Class macros and constants
|
14
|
+
STATUS_TIMEOUT = 60
|
15
|
+
SLOT_MEDIA = 0
|
16
|
+
SLOT_SIGNAL_LEVEL = 1
|
17
|
+
SLOT_UPDATE = 2
|
8
18
|
SLOT_BATTERY_PERCENTUAL = 6
|
9
|
-
SLOT_BATTERY_LEVEL
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
SLOT_BATTERY_LEVEL = 7
|
20
|
+
|
21
|
+
# TODO: review the 'print_status_bar' API to reduce the number of files
|
22
|
+
# to eleven?
|
23
|
+
BATTERY_PERCENTAGE_IMAGES = [
|
24
|
+
'./shared/1%.png', './shared/1%.png', './shared/2%.png',
|
25
|
+
'./shared/3%.png', './shared/4%.png', './shared/5%.png',
|
26
|
+
'./shared/6%.png', './shared/7%.png', './shared/8%.png',
|
27
|
+
'./shared/9%.png', './shared/10%.png', './shared/11%.png',
|
28
|
+
'./shared/12%.png', './shared/13%.png', './shared/14%.png',
|
29
|
+
'./shared/15%.png', './shared/16%.png', './shared/17%.png',
|
30
|
+
'./shared/18%.png', './shared/19%.png', './shared/20%.png',
|
31
|
+
'./shared/21%.png', './shared/22%.png', './shared/23%.png',
|
32
|
+
'./shared/24%.png', './shared/25%.png', './shared/26%.png',
|
33
|
+
'./shared/27%.png', './shared/28%.png', './shared/29%.png',
|
34
|
+
'./shared/30%.png', './shared/31%.png', './shared/32%.png',
|
35
|
+
'./shared/33%.png', './shared/34%.png', './shared/35%.png',
|
36
|
+
'./shared/36%.png', './shared/37%.png', './shared/38%.png',
|
37
|
+
'./shared/39%.png', './shared/40%.png', './shared/41%.png',
|
38
|
+
'./shared/42%.png', './shared/43%.png', './shared/44%.png',
|
39
|
+
'./shared/45%.png', './shared/46%.png', './shared/47%.png',
|
40
|
+
'./shared/48%.png', './shared/49%.png', './shared/50%.png',
|
41
|
+
'./shared/51%.png', './shared/52%.png', './shared/53%.png',
|
42
|
+
'./shared/54%.png', './shared/55%.png', './shared/56%.png',
|
43
|
+
'./shared/57%.png', './shared/58%.png', './shared/59%.png',
|
44
|
+
'./shared/60%.png', './shared/61%.png', './shared/62%.png',
|
45
|
+
'./shared/63%.png', './shared/64%.png', './shared/65%.png',
|
46
|
+
'./shared/66%.png', './shared/67%.png', './shared/68%.png',
|
47
|
+
'./shared/69%.png', './shared/70%.png', './shared/71%.png',
|
48
|
+
'./shared/72%.png', './shared/73%.png', './shared/74%.png',
|
49
|
+
'./shared/75%.png', './shared/76%.png', './shared/77%.png',
|
50
|
+
'./shared/78%.png', './shared/79%.png', './shared/80%.png',
|
51
|
+
'./shared/81%.png', './shared/82%.png', './shared/83%.png',
|
52
|
+
'./shared/84%.png', './shared/85%.png', './shared/86%.png',
|
53
|
+
'./shared/87%.png', './shared/88%.png', './shared/89%.png',
|
54
|
+
'./shared/90%.png', './shared/91%.png', './shared/92%.png',
|
55
|
+
'./shared/93%.png', './shared/94%.png', './shared/95%.png',
|
56
|
+
'./shared/96%.png', './shared/97%.png', './shared/98%.png',
|
57
|
+
'./shared/99%.png', './shared/100%.png'
|
58
|
+
].freeze
|
59
|
+
|
60
|
+
MEDIA_PATH = {
|
61
|
+
:gprs => './shared/3G.png',
|
62
|
+
:wifi => './shared/WIFI.png'
|
23
63
|
}
|
24
64
|
|
65
|
+
BATTERY_CHARGING = [
|
66
|
+
"./shared/battery_charging.png",
|
67
|
+
"./shared/battery_charged.png"
|
68
|
+
].freeze
|
69
|
+
|
25
70
|
BATTERY_IMAGES = {
|
26
71
|
0..4 => "./shared/battery0.png",
|
27
|
-
5..
|
28
|
-
10..19 => "./shared/battery10.png",
|
72
|
+
5..19 => "./shared/battery10.png",
|
29
73
|
20..29 => "./shared/battery20.png",
|
30
74
|
30..39 => "./shared/battery30.png",
|
31
75
|
40..49 => "./shared/battery40.png",
|
@@ -34,48 +78,29 @@ module DaFunk
|
|
34
78
|
70..79 => "./shared/battery70.png",
|
35
79
|
80..89 => "./shared/battery80.png",
|
36
80
|
90..99 => "./shared/battery90.png",
|
37
|
-
100..100 => "./shared/battery100.png"
|
38
|
-
}
|
39
|
-
|
40
|
-
BATTERY_CHARGE_IMAGES = {
|
41
|
-
50 => "./shared/battery0c.png",
|
42
|
-
100 => "./shared/battery100c.png"
|
43
|
-
}
|
44
|
-
|
45
|
-
BATTERY_PERCENTAGE_IMAGES = {
|
46
|
-
0..4 => "./shared/battery1_percent.png",
|
47
|
-
5..9 => "./shared/battery5_percent.png",
|
48
|
-
10..19 => "./shared/battery10_percent.png",
|
49
|
-
20..29 => "./shared/battery20_percent.png",
|
50
|
-
30..39 => "./shared/battery30_percent.png",
|
51
|
-
40..49 => "./shared/battery40_percent.png",
|
52
|
-
50..59 => "./shared/battery50_percent.png",
|
53
|
-
60..69 => "./shared/battery60_percent.png",
|
54
|
-
70..79 => "./shared/battery70_percent.png",
|
55
|
-
80..89 => "./shared/battery80_percent.png",
|
56
|
-
90..99 => "./shared/battery90_percent.png",
|
57
|
-
100..100 => "./shared/battery100_percent.png",
|
81
|
+
100..100 => "./shared/battery100.png"
|
58
82
|
}
|
59
83
|
|
60
84
|
WIFI_IMAGES = {
|
61
|
-
0..0
|
62
|
-
1..25
|
63
|
-
26..50
|
64
|
-
59..75
|
65
|
-
76..200
|
85
|
+
0..0 => "./shared/wifi0.png",
|
86
|
+
1..25 => "./shared/wifi25.png",
|
87
|
+
26..50 => "./shared/wifi50.png",
|
88
|
+
59..75 => "./shared/wifi75.png",
|
89
|
+
76..200 => "./shared/wifi100.png"
|
66
90
|
}
|
67
91
|
|
68
92
|
MOBILE_IMAGES = {
|
69
|
-
0..0
|
70
|
-
1..20
|
71
|
-
21..40
|
72
|
-
41..60
|
73
|
-
61..80
|
74
|
-
81..200
|
93
|
+
0..0 => "./shared/mobile0.png",
|
94
|
+
1..20 => "./shared/mobile20.png",
|
95
|
+
21..40 => "./shared/mobile40.png",
|
96
|
+
41..60 => "./shared/mobile60.png",
|
97
|
+
61..80 => "./shared/mobile80.png",
|
98
|
+
81..200 => "./shared/mobile100.png"
|
75
99
|
}
|
76
100
|
|
77
101
|
class << self
|
78
|
-
attr_accessor :
|
102
|
+
attr_accessor :current_signal, :current_message, :battery, :power, :managment
|
103
|
+
attr_accessor :current_media
|
79
104
|
end
|
80
105
|
|
81
106
|
def self.check
|
@@ -90,98 +115,127 @@ module DaFunk
|
|
90
115
|
if File.exists?('./shared/system_update')
|
91
116
|
PAX::Display.print_status_bar(SLOT_UPDATE, "./shared/system_update_download.png")
|
92
117
|
PAX::Display.print_status_bar(3, nil)
|
93
|
-
self.connected = false
|
94
118
|
else
|
95
|
-
change_message
|
119
|
+
self.change_message
|
96
120
|
end
|
97
121
|
end
|
98
122
|
|
99
123
|
def self.change_message
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
124
|
+
if ThreadScheduler.pause?(ThreadScheduler::THREAD_EXTERNAL_COMMUNICATION, 200)
|
125
|
+
if self.current_message != :pause
|
126
|
+
self.current_message = :pause
|
127
|
+
Device::Display.print_status_bar(2, './shared/semsinal_01.png')
|
128
|
+
Device::Display.print_status_bar(3, './shared/semsinal_02.png')
|
129
|
+
end
|
130
|
+
elsif Device::Network.connected?
|
131
|
+
if self.current_message != :connected
|
132
|
+
self.current_message = :connected
|
133
|
+
Device::Display.print_status_bar(2, './shared/conectado_01.png')
|
134
|
+
Device::Display.print_status_bar(3, './shared/conectado_02.png')
|
135
|
+
end
|
136
|
+
else
|
137
|
+
if self.current_message != :searching
|
138
|
+
self.current_message = :searching
|
139
|
+
Device::Display.print_status_bar(2, './shared/buscando_01.png')
|
140
|
+
Device::Display.print_status_bar(3, './shared/buscando_02.png')
|
114
141
|
end
|
115
142
|
end
|
116
143
|
end
|
117
144
|
|
118
145
|
def self.change_connection
|
119
|
-
if
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
146
|
+
if ThreadScheduler.pause?(ThreadScheduler::THREAD_EXTERNAL_COMMUNICATION, 200)
|
147
|
+
Device::Display.print_status_bar(SLOT_MEDIA, nil)
|
148
|
+
Device::Display.print_status_bar(SLOT_SIGNAL_LEVEL, nil)
|
149
|
+
self.current_media = nil
|
150
|
+
self.current_signal = nil
|
151
|
+
elsif Device::Network.connected?
|
152
|
+
media = Device::Network.gprs? ? :gprs : :wifi
|
153
|
+
signal = Device::Network.signal
|
154
|
+
if media != self.current_media
|
155
|
+
self.current_media = media
|
156
|
+
Device::Display.print_status_bar(SLOT_MEDIA, MEDIA_PATH[self.current_media])
|
157
|
+
end
|
158
|
+
if signal != self.current_signal
|
159
|
+
self.current_signal = signal
|
160
|
+
Device::Display.print_status_bar(SLOT_SIGNAL_LEVEL,
|
161
|
+
self.get_image_path(self.current_media, self.current_signal))
|
134
162
|
end
|
135
163
|
else
|
136
164
|
Device::Display.print_status_bar(SLOT_MEDIA, nil)
|
137
165
|
Device::Display.print_status_bar(SLOT_SIGNAL_LEVEL, "./shared/searching.png")
|
166
|
+
self.current_media = nil
|
167
|
+
self.current_signal = nil
|
138
168
|
end
|
139
169
|
end
|
140
170
|
|
171
|
+
# Updates the battery slot whenever a capacity or power supply change is
|
172
|
+
# detected.
|
141
173
|
def self.change_battery
|
142
|
-
|
143
|
-
|
174
|
+
capacity_type = Device::System.battery_capacity_type
|
175
|
+
|
176
|
+
capacity = Device::System.battery
|
177
|
+
charging = Device::System.power_supply
|
144
178
|
|
145
|
-
if self.battery !=
|
146
|
-
self.battery = bat
|
147
|
-
self.power = dock
|
179
|
+
if self.battery != capacity || self.power != charging
|
148
180
|
|
149
|
-
if self.
|
150
|
-
|
181
|
+
if self.battery.nil? # basic integrity check
|
182
|
+
self.battery = capacity
|
183
|
+
elsif charging
|
184
|
+
capacity >= self.battery && self.battery = capacity
|
151
185
|
else
|
152
|
-
|
153
|
-
|
186
|
+
capacity <= self.battery && self.battery = capacity
|
187
|
+
end
|
188
|
+
|
189
|
+
if self.power == charging && capacity != self.battery
|
190
|
+
return nil
|
154
191
|
end
|
155
192
|
|
156
|
-
|
157
|
-
|
158
|
-
|
193
|
+
self.power = charging
|
194
|
+
|
195
|
+
rsc = self.get_image_path(self.power ? :battery_charge : :battery, self.battery)
|
196
|
+
|
197
|
+
Device::Display.print_status_bar(SLOT_BATTERY_LEVEL, rsc)
|
198
|
+
|
199
|
+
if capacity_type == 'percentage' || !self.power
|
200
|
+
rsc = self.get_image_path(:battery_percentual, self.battery)
|
159
201
|
else
|
160
|
-
|
161
|
-
get_image_path(:battery, self.battery))
|
202
|
+
rsc = nil
|
162
203
|
end
|
204
|
+
|
205
|
+
Device::Display.print_status_bar(SLOT_BATTERY_PERCENTUAL, rsc)
|
163
206
|
end
|
164
207
|
end
|
165
208
|
|
209
|
+
# Searches for the correspondent image to 'type' and 'signal strength'.
|
166
210
|
def self.get_image_path(type, sig)
|
167
211
|
return if sig.nil?
|
168
212
|
case type
|
169
213
|
when :gprs
|
170
|
-
MOBILE_IMAGES.each
|
214
|
+
MOBILE_IMAGES.each do |k, v|
|
215
|
+
return v if k.include? sig
|
216
|
+
end
|
171
217
|
when :wifi
|
172
|
-
WIFI_IMAGES.each
|
218
|
+
WIFI_IMAGES.each do |k, v|
|
219
|
+
return v if k.include? sig
|
220
|
+
end
|
173
221
|
when :battery
|
174
|
-
BATTERY_IMAGES.each
|
222
|
+
BATTERY_IMAGES.each do |k, v|
|
223
|
+
return v if k.include? sig
|
224
|
+
end
|
175
225
|
when :battery_charge
|
176
|
-
|
226
|
+
if sig < 100
|
227
|
+
BATTERY_CHARGING[0]
|
228
|
+
else
|
229
|
+
BATTERY_CHARGING[1]
|
230
|
+
end
|
177
231
|
when :battery_percentual
|
178
|
-
BATTERY_PERCENTAGE_IMAGES
|
232
|
+
BATTERY_PERCENTAGE_IMAGES[sig]
|
179
233
|
else
|
180
234
|
nil
|
181
235
|
end
|
182
236
|
end
|
183
237
|
|
184
|
-
self.managment
|
238
|
+
self.managment ||= true
|
185
239
|
def self.valid?
|
186
240
|
if self.managment
|
187
241
|
true
|
@@ -190,4 +244,3 @@ module DaFunk
|
|
190
244
|
end
|
191
245
|
end
|
192
246
|
end
|
193
|
-
|