da_funk 3.28.2 → 3.32.0
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +10 -10
- data/RELEASE_NOTES.md +33 -0
- data/Rakefile +2 -0
- data/lib/da_funk/connection_management.rb +25 -10
- data/lib/da_funk/helper/status_bar.rb +163 -105
- data/lib/da_funk/rake_task.rb +13 -6
- data/lib/da_funk/secure_random.rb +17 -0
- data/lib/da_funk/transaction/reversal.rb +13 -0
- data/lib/da_funk/version.rb +1 -1
- data/lib/device/display.rb +13 -3
- data/lib/device/network.rb +19 -33
- data/lib/device/system.rb +9 -0
- data/lib/device/virtual_keyboard.rb +81 -34
- data/test/unit/da_funk/secure_random.rb +18 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b33827fb8e6019dae3a230de689a73d62065b71fe5d87cde66a5d034e10c8958
|
4
|
+
data.tar.gz: b88cd578be7d53abc94f00ffe3ff35fe21ecc028b75296c5d7b46391a35a6520
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f06599b79a0a3a2f098b2d544ef440231289d554737acf02cb7c1fae1a54509f503f6e66c7e90c2936eac9de0cab6aa3d9cdce8e9ebff2960adaf468c973dcb
|
7
|
+
data.tar.gz: 0d22fb804323266724e6efdf3eb79f075a69674cda33ee6321e3117a91983b9bed246bc2ae3c9408649c2ad20755c7e672b55a7c62502fdf77ff6d9562c9df20
|
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.32.0)
|
5
5
|
archive-zip (~> 0.5)
|
6
6
|
bundler
|
7
7
|
cloudwalk_handshake
|
@@ -18,7 +18,7 @@ GEM
|
|
18
18
|
cloudwalk (1.15.0)
|
19
19
|
bundler
|
20
20
|
rake
|
21
|
-
cloudwalk_handshake (1.
|
21
|
+
cloudwalk_handshake (1.21.3)
|
22
22
|
funky-simplehttp (~> 0.6)
|
23
23
|
funky-emv (1.4.1)
|
24
24
|
funky-tlv (~> 0.2)
|
@@ -27,25 +27,25 @@ GEM
|
|
27
27
|
funky-tlv (0.2.3)
|
28
28
|
io-like (0.3.1)
|
29
29
|
parallel (1.19.2)
|
30
|
-
parser (2.7.
|
30
|
+
parser (2.7.2.0)
|
31
31
|
ast (~> 2.4.1)
|
32
32
|
posxml_parser (2.26.0)
|
33
33
|
funky-emv (~> 1)
|
34
34
|
rainbow (3.0.0)
|
35
35
|
rake (13.0.1)
|
36
|
-
regexp_parser (1.
|
36
|
+
regexp_parser (1.8.2)
|
37
37
|
rexml (3.2.4)
|
38
|
-
rubocop (
|
38
|
+
rubocop (1.1.0)
|
39
39
|
parallel (~> 1.10)
|
40
|
-
parser (>= 2.7.1.
|
40
|
+
parser (>= 2.7.1.5)
|
41
41
|
rainbow (>= 2.2.2, < 4.0)
|
42
|
-
regexp_parser (>= 1.
|
42
|
+
regexp_parser (>= 1.8)
|
43
43
|
rexml
|
44
|
-
rubocop-ast (>= 0.
|
44
|
+
rubocop-ast (>= 1.0.1)
|
45
45
|
ruby-progressbar (~> 1.7)
|
46
46
|
unicode-display_width (>= 1.4.0, < 2.0)
|
47
|
-
rubocop-ast (
|
48
|
-
parser (>= 2.7.1.
|
47
|
+
rubocop-ast (1.1.0)
|
48
|
+
parser (>= 2.7.1.5)
|
49
49
|
ruby-progressbar (1.10.1)
|
50
50
|
unicode-display_width (1.7.0)
|
51
51
|
yard (0.9.25)
|
data/RELEASE_NOTES.md
CHANGED
@@ -1,5 +1,38 @@
|
|
1
1
|
# DaFunk
|
2
2
|
|
3
|
+
### 3.32.0 - 2021-01-04
|
4
|
+
|
5
|
+
- Remapped virtual keyboard to add support to new layout;
|
6
|
+
- Make timeout of virtual keyboard parametrized;
|
7
|
+
- Limit size of string to 20 on virtual keyboard;
|
8
|
+
- Refactoring status bar:
|
9
|
+
- Check if thread is paused which means communication it's being configured. In this case 'sem sinal' message should be displayed;
|
10
|
+
- Do not show media type an media icon if thread is paused;
|
11
|
+
- Removed thread pause from attach and scan calls, let the application that is doing the configuration take care of that;
|
12
|
+
- Move reload of metadata to communication thread;
|
13
|
+
- Added support to check network conn status from time to time, default is each 5 minutes.
|
14
|
+
|
15
|
+
### 3.31.0 - 2020-11-27
|
16
|
+
|
17
|
+
- Added support to new battery view (Exact percentage);
|
18
|
+
- Added support to new main screen when there's a pending sale.
|
19
|
+
|
20
|
+
### 3.30.0 - 2020-11-16
|
21
|
+
|
22
|
+
- Replace GPRS icon to 3G;
|
23
|
+
- Added new method main_image_format on Device::Display;
|
24
|
+
- Use main_image_format method to get the image name instead adapter;
|
25
|
+
- Added new class DaFunk::Transaction::Reversal.
|
26
|
+
|
27
|
+
### 3.29.1 - 2020-11-04
|
28
|
+
|
29
|
+
- Fix battery charging status. When power supply is connected the SDK always returns 50% of battery, in this case it won't show the percentage until the SDK returns 100%.
|
30
|
+
|
31
|
+
### 3.29.0 - 2020-11-03
|
32
|
+
|
33
|
+
- Added support to Ruby SecureRandom;
|
34
|
+
- Update cloudwalk_handshake (1.21.3).
|
35
|
+
|
3
36
|
### 3.28.2 - 2020-10-07
|
4
37
|
|
5
38
|
- Added support of params.dat file restore if it was corrupted;
|
data/Rakefile
CHANGED
@@ -53,9 +53,11 @@ FILES = FileList[
|
|
53
53
|
"lib/da_funk/application.rb",
|
54
54
|
"lib/da_funk/transaction/iso.rb",
|
55
55
|
"lib/da_funk/transaction/download.rb",
|
56
|
+
"lib/da_funk/transaction/reversal.rb",
|
56
57
|
"lib/da_funk/notification_event.rb",
|
57
58
|
"lib/da_funk/notification_callback.rb",
|
58
59
|
"lib/da_funk/notification.rb",
|
60
|
+
"lib/da_funk/secure_random.rb",
|
59
61
|
|
60
62
|
"lib/device.rb",
|
61
63
|
"lib/device/audio.rb",
|
@@ -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
|
-
|
@@ -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,93 +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
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
174
|
+
capacity_type = Device::System.battery_capacity_type
|
175
|
+
|
176
|
+
capacity = Device::System.battery
|
177
|
+
charging = Device::System.power_supply
|
178
|
+
|
179
|
+
if self.battery != capacity || self.power != charging
|
180
|
+
|
181
|
+
if self.battery.nil? # basic integrity check
|
182
|
+
self.battery = capacity
|
183
|
+
elsif charging
|
184
|
+
capacity >= self.battery && self.battery = capacity
|
185
|
+
else
|
186
|
+
capacity <= self.battery && self.battery = capacity
|
187
|
+
end
|
188
|
+
|
189
|
+
if self.power == charging && capacity != self.battery
|
190
|
+
return nil
|
191
|
+
end
|
192
|
+
|
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)
|
154
201
|
else
|
155
|
-
|
156
|
-
get_image_path(:battery, self.battery))
|
202
|
+
rsc = nil
|
157
203
|
end
|
204
|
+
|
205
|
+
Device::Display.print_status_bar(SLOT_BATTERY_PERCENTUAL, rsc)
|
158
206
|
end
|
159
207
|
end
|
160
208
|
|
209
|
+
# Searches for the correspondent image to 'type' and 'signal strength'.
|
161
210
|
def self.get_image_path(type, sig)
|
162
211
|
return if sig.nil?
|
163
212
|
case type
|
164
213
|
when :gprs
|
165
|
-
MOBILE_IMAGES.each
|
214
|
+
MOBILE_IMAGES.each do |k, v|
|
215
|
+
return v if k.include? sig
|
216
|
+
end
|
166
217
|
when :wifi
|
167
|
-
WIFI_IMAGES.each
|
218
|
+
WIFI_IMAGES.each do |k, v|
|
219
|
+
return v if k.include? sig
|
220
|
+
end
|
168
221
|
when :battery
|
169
|
-
BATTERY_IMAGES.each
|
222
|
+
BATTERY_IMAGES.each do |k, v|
|
223
|
+
return v if k.include? sig
|
224
|
+
end
|
170
225
|
when :battery_charge
|
171
|
-
|
226
|
+
if sig < 100
|
227
|
+
BATTERY_CHARGING[0]
|
228
|
+
else
|
229
|
+
BATTERY_CHARGING[1]
|
230
|
+
end
|
172
231
|
when :battery_percentual
|
173
|
-
BATTERY_PERCENTAGE_IMAGES
|
232
|
+
BATTERY_PERCENTAGE_IMAGES[sig]
|
174
233
|
else
|
175
234
|
nil
|
176
235
|
end
|
177
236
|
end
|
178
237
|
|
179
|
-
self.managment
|
238
|
+
self.managment ||= true
|
180
239
|
def self.valid?
|
181
240
|
if self.managment
|
182
241
|
true
|
@@ -185,4 +244,3 @@ module DaFunk
|
|
185
244
|
end
|
186
245
|
end
|
187
246
|
end
|
188
|
-
|
data/lib/da_funk/rake_task.rb
CHANGED
@@ -31,7 +31,7 @@ module DaFunk
|
|
31
31
|
@resources_out ||= @resources.pathmap("%{resources,#{File.join(root_path, "out")}}p")
|
32
32
|
@tests_res_out ||= @tests_resources.pathmap("%{test/resources,out}p")
|
33
33
|
@mruby ||= "cloudwalk run -b"
|
34
|
-
@mrbc
|
34
|
+
@mrbc = get_mrbc_bin(@mrbc)
|
35
35
|
|
36
36
|
define
|
37
37
|
end
|
@@ -44,14 +44,21 @@ module DaFunk
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
+
# Searches for a mrbc binary.
|
47
48
|
def get_mrbc_bin(from_user)
|
48
|
-
|
49
|
+
device = "/dev/null"
|
50
|
+
|
51
|
+
if %w[i386-mingw32 x64-mingw32].include?(RUBY_PLATFORM) && !ENV['SHELL']
|
52
|
+
device = "NUL" # Windows Command Prompt
|
53
|
+
end
|
54
|
+
|
55
|
+
if !system("type mrbc > #{device} 2>&1") && from_user
|
49
56
|
from_user
|
50
|
-
elsif system("type mrbc >
|
57
|
+
elsif system("type mrbc > #{device} 2>&1")
|
51
58
|
"env mrbc"
|
52
59
|
elsif ENV["MRBC"]
|
53
60
|
ENV["MRBC"]
|
54
|
-
elsif system("type cloudwalk >
|
61
|
+
elsif system("type cloudwalk > #{device} 2>&1")
|
55
62
|
"env cloudwalk compile"
|
56
63
|
else
|
57
64
|
puts "$MRBC isn't set or mrbc/cloudwalk isn't on $PATH"
|
@@ -64,7 +71,7 @@ module DaFunk
|
|
64
71
|
command_line = File.join(File.dirname(__FILE__), "..", "..", "utils", "command_line_platform.rb")
|
65
72
|
command_line_obj = File.join(root_path, "out", "main", "command_line_platform.mrb")
|
66
73
|
all_files = FileList["test/test_helper.rb"] + libs + files + [command_line] + [File.join(File.dirname(__FILE__), "..", "..", "utils", "test_run.rb")]
|
67
|
-
if platform_call("#{mrbc} -g -o #{command_line_obj} #{command_line}") && platform_call("#{mrbc} -g -o #{test_out} #{all_files.uniq}")
|
74
|
+
if platform_call("#{@mrbc} -g -o #{command_line_obj} #{command_line}") && platform_call("#{@mrbc} -g -o #{test_out} #{all_files.uniq}")
|
68
75
|
puts "cd #{File.dirname(out_path)}"
|
69
76
|
FileUtils.cd File.dirname(out_path)
|
70
77
|
platform_call("#{mruby} #{File.join(name, "test.mrb")}")
|
@@ -108,7 +115,7 @@ module DaFunk
|
|
108
115
|
|
109
116
|
desc "Compile app to mrb and process resources"
|
110
117
|
task :build => :resources do
|
111
|
-
platform_call "#{mrbc} #{debug_flag} -o #{main_out} #{libs} "
|
118
|
+
platform_call "#{@mrbc} #{debug_flag} -o #{main_out} #{libs} "
|
112
119
|
end
|
113
120
|
|
114
121
|
desc "Compile, build and pack app and resources"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module DaFunk
|
2
|
+
class SecureRandom
|
3
|
+
CHARS = [('a'..'z'), ('A'..'Z')].map(&:to_a).flatten
|
4
|
+
|
5
|
+
def self.random_bytes(n = nil)
|
6
|
+
n = n ? n.to_int : 16
|
7
|
+
(0...n).map { CHARS[rand(CHARS.length)] }.join
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.uuid
|
11
|
+
bytes = random_bytes.unpack('NnnnnN')
|
12
|
+
bytes[2] = (bytes[2] & 0x0fff) | 0x4000
|
13
|
+
bytes[3] = (bytes[3] & 0x3fff) | 0x8000
|
14
|
+
"%08x-%04x-%04x-%04x-%04x%08x" % bytes
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/da_funk/version.rb
CHANGED
data/lib/device/display.rb
CHANGED
@@ -71,13 +71,23 @@ class Device
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def self.main_image
|
74
|
-
|
75
|
-
|
76
|
-
|
74
|
+
file = main_image_format
|
75
|
+
if File.exists?("./shared/#{file}")
|
76
|
+
file
|
77
77
|
else
|
78
78
|
MAIN_BMP
|
79
79
|
end
|
80
80
|
end
|
81
|
+
|
82
|
+
private
|
83
|
+
def self.main_image_format
|
84
|
+
major, min, patch = Device.version.to_s.split('.').map { |v| v.to_i }
|
85
|
+
if DaFunk::Transaction::Reversal.exists? && major >= 8
|
86
|
+
"main_#{Device::System.model}_reversal.bmp"
|
87
|
+
else
|
88
|
+
"main_#{Device::System.model}.bmp"
|
89
|
+
end
|
90
|
+
end
|
81
91
|
end
|
82
92
|
end
|
83
93
|
|
data/lib/device/network.rb
CHANGED
@@ -159,9 +159,7 @@ class Device
|
|
159
159
|
# Device::Setting.mode = selected[:mode]
|
160
160
|
def self.scan
|
161
161
|
if wifi?
|
162
|
-
|
163
|
-
adapter.scan if Device::Network.init(*self.config)
|
164
|
-
end
|
162
|
+
adapter.scan if Device::Network.init(*self.config)
|
165
163
|
end
|
166
164
|
end
|
167
165
|
|
@@ -192,39 +190,28 @@ class Device
|
|
192
190
|
def self.attach(options = nil)
|
193
191
|
Device::Network.connected?
|
194
192
|
if self.code != SUCCESS
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
process[:ret] == PROCESSING || process[:ret] == 2 || process[:ret] == -3307 # if true keep trying
|
206
|
-
end
|
207
|
-
self.code = hash[:ret]
|
208
|
-
|
209
|
-
if self.code == SUCCESS
|
210
|
-
self.load_metadata
|
211
|
-
self.code = Device::Network.dhcp_client(20000) if (wifi? || ethernet?)
|
212
|
-
else
|
213
|
-
self.code = ERR_USER_CANCEL if hash[:key] == Device::IO::CANCEL
|
214
|
-
Device::Network.shutdown
|
215
|
-
end
|
193
|
+
self.code = Device::Network.init(*self.config)
|
194
|
+
self.code = Device::Network.connect
|
195
|
+
Device::Network.connected? if self.code != SUCCESS
|
196
|
+
|
197
|
+
hash = try_user(self.attach_timeout, options) do |process|
|
198
|
+
Device::Network.connected?
|
199
|
+
process[:ret] = self.code
|
200
|
+
# TODO develop an interface to keep waiting communication module dial
|
201
|
+
# based on platform returns
|
202
|
+
process[:ret] == PROCESSING || process[:ret] == 2 || process[:ret] == -3307 # if true keep trying
|
216
203
|
end
|
217
|
-
|
218
|
-
Context::ThreadPubSub.publish('communication_update')
|
219
|
-
self.code
|
220
|
-
end
|
204
|
+
self.code = hash[:ret]
|
221
205
|
|
222
|
-
|
223
|
-
|
224
|
-
|
206
|
+
if self.code == SUCCESS
|
207
|
+
self.code = Device::Network.dhcp_client(20000) if (wifi? || ethernet?)
|
208
|
+
else
|
209
|
+
self.code = ERR_USER_CANCEL if hash[:key] == Device::IO::CANCEL
|
210
|
+
Device::Network.shutdown
|
211
|
+
end
|
225
212
|
end
|
213
|
+
self.code
|
226
214
|
end
|
227
|
-
|
228
215
|
def self.shutdown
|
229
216
|
if self.adapter.started?
|
230
217
|
Device::Network.disconnect
|
@@ -276,4 +263,3 @@ class Device
|
|
276
263
|
end
|
277
264
|
end
|
278
265
|
end
|
279
|
-
|
data/lib/device/system.rb
CHANGED
@@ -45,6 +45,15 @@ class Device
|
|
45
45
|
adapter.battery
|
46
46
|
end
|
47
47
|
|
48
|
+
# Checks the type of the battery capacity return (percentage or scale).
|
49
|
+
def self.battery_capacity_type
|
50
|
+
begin
|
51
|
+
adapter.battery_capacity_type
|
52
|
+
rescue StandardError => exception
|
53
|
+
'scale'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
48
57
|
def self.beep
|
49
58
|
adapter.beep
|
50
59
|
end
|
@@ -82,34 +82,76 @@ class Device
|
|
82
82
|
],
|
83
83
|
|
84
84
|
keyboard_symbol_number: [
|
85
|
-
{ x: 0..
|
86
|
-
{ x: 0..
|
87
|
-
{ x: 0..
|
88
|
-
{ x: 0..
|
89
|
-
{ x: 0..
|
90
|
-
{ x: 0..
|
91
|
-
{ x: 0..
|
92
|
-
{ x: 0..
|
93
|
-
{ x: 0..
|
94
|
-
{ x: 0..
|
95
|
-
{ x: 0..
|
96
|
-
{ x: 0..
|
97
|
-
{ x: 0..
|
98
|
-
{ x: 0..
|
99
|
-
{ x: 0..
|
100
|
-
{ x: 0..
|
101
|
-
{ x: 0..
|
102
|
-
{ x: 0..
|
103
|
-
{ x: 0..
|
104
|
-
{ x: 0..
|
105
|
-
{ x: 0..
|
106
|
-
{ x: 0..
|
107
|
-
{ x: 0..
|
108
|
-
{ x: 0..
|
109
|
-
{ x: 0..
|
110
|
-
{ x: 0..
|
111
|
-
{ x: 0..
|
112
|
-
{ x: 0..
|
85
|
+
{ x: 0..34, y: 191..209, char: '1' },
|
86
|
+
{ x: 0..46, y: 191..209, char: '2' },
|
87
|
+
{ x: 0..65, y: 191..209, char: '3' },
|
88
|
+
{ x: 0..96, y: 191..209, char: '4' },
|
89
|
+
{ x: 0..115, y: 191..209, char: '5' },
|
90
|
+
{ x: 0..145, y: 191..209, char: '6' },
|
91
|
+
{ x: 0..161, y: 191..209, char: '7' },
|
92
|
+
{ x: 0..191, y: 191..209, char: '8' },
|
93
|
+
{ x: 0..216, y: 191..209, char: '9' },
|
94
|
+
{ x: 0..255, y: 191..209, char: '0' },
|
95
|
+
{ x: 0..31, y: 223..241, char: '%' },
|
96
|
+
{ x: 0..52, y: 223..241, char: '#' },
|
97
|
+
{ x: 0..77, y: 223..241, char: '$' },
|
98
|
+
{ x: 0..97, y: 223..241, char: '_' },
|
99
|
+
{ x: 0..121, y: 223..241, char: '&' },
|
100
|
+
{ x: 0..143, y: 223..241, char: '-' },
|
101
|
+
{ x: 0..168, y: 223..241, char: '+' },
|
102
|
+
{ x: 0..186, y: 223..241, char: '(' },
|
103
|
+
{ x: 0..215, y: 223..241, char: ')' },
|
104
|
+
{ x: 0..236, y: 223..241, char: '/' },
|
105
|
+
{ x: 0..42, y: 223..274, char: :keyboard_symbol_number_2 },
|
106
|
+
{ x: 0..60, y: 223..274, char: '*' },
|
107
|
+
{ x: 0..84, y: 223..274, char: '"' },
|
108
|
+
{ x: 0..107, y: 223..274, char: "'" },
|
109
|
+
{ x: 0..130, y: 223..274, char: ':' },
|
110
|
+
{ x: 0..152, y: 223..274, char: ';' },
|
111
|
+
{ x: 0..171, y: 223..274, char: '!' },
|
112
|
+
{ x: 0..197, y: 223..274, char: '?' },
|
113
|
+
{ x: 0..255, y: 223..274, char: :erase },
|
114
|
+
{ x: 0..36, y: 223..315, char: :keyboard_capital },
|
115
|
+
{ x: 0..63, y: 223..315, char: '@' },
|
116
|
+
{ x: 0..88, y: 223..315, char: ',' },
|
117
|
+
{ x: 0..152, y: 223..315, char: :space },
|
118
|
+
{ x: 0..168, y: 223..315, char: '.' },
|
119
|
+
{ x: 0..255, y: 223..315, char: :enter }
|
120
|
+
],
|
121
|
+
|
122
|
+
keyboard_symbol_number_2: [
|
123
|
+
{ x: 0..34, y: 191..209, char: '1' },
|
124
|
+
{ x: 0..46, y: 191..209, char: '2' },
|
125
|
+
{ x: 0..69, y: 191..209, char: '3' },
|
126
|
+
{ x: 0..96, y: 191..209, char: '4' },
|
127
|
+
{ x: 0..115, y: 191..209, char: '5' },
|
128
|
+
{ x: 0..145, y: 191..209, char: '6' },
|
129
|
+
{ x: 0..161, y: 191..209, char: '7' },
|
130
|
+
{ x: 0..191, y: 191..209, char: '8' },
|
131
|
+
{ x: 0..216, y: 191..209, char: '9' },
|
132
|
+
{ x: 0..255, y: 191..209, char: '0' },
|
133
|
+
{ x: 0..35, y: 223..241, char: '^' },
|
134
|
+
{ x: 0..63, y: 223..241, char: '[' },
|
135
|
+
{ x: 0..97, y: 223..241, char: ']' },
|
136
|
+
{ x: 0..128, y: 223..241, char: '{' },
|
137
|
+
{ x: 0..158, y: 223..241, char: '}' },
|
138
|
+
{ x: 0..193, y: 223..241, char: '<' },
|
139
|
+
{ x: 0..255, y: 223..241, char: '>' },
|
140
|
+
{ x: 0..39, y: 223..274, char: :keyboard_symbol_number },
|
141
|
+
{ x: 0..63, y: 223..274, char: '\\' },
|
142
|
+
{ x: 0..86, y: 223..274, char: '-' },
|
143
|
+
{ x: 0..106, y: 223..274, char: '+' },
|
144
|
+
{ x: 0..130, y: 223..274, char: '=' },
|
145
|
+
{ x: 0..149, y: 223..274, char: '_' },
|
146
|
+
{ x: 0..175, y: 223..274, char: '˜' },
|
147
|
+
{ x: 0..195, y: 223..274, char: '|' },
|
148
|
+
{ x: 0..255, y: 223..274, char: :erase },
|
149
|
+
{ x: 0..34, y: 223..310, char: :keyboard_capital },
|
150
|
+
{ x: 0..61, y: 223..310, char: '@' },
|
151
|
+
{ x: 0..87, y: 223..310, char: ',' },
|
152
|
+
{ x: 0..146, y: 223..313, char: :space },
|
153
|
+
{ x: 0..168, y: 223..311, char: '.' },
|
154
|
+
{ x: 0..194, y: 223..319, char: :enter }
|
113
155
|
]
|
114
156
|
}
|
115
157
|
|
@@ -117,9 +159,11 @@ class Device
|
|
117
159
|
phisical_keys = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', "\017"]
|
118
160
|
change_keyboard
|
119
161
|
Device::Display.print_line("#{self.text}", params[:line], params[:column])
|
120
|
-
|
121
|
-
|
162
|
+
if params[:timeout_enabled]
|
163
|
+
time = Time.now + (params[:timeout] || Device::IO.timeout) / 1000
|
164
|
+
end
|
122
165
|
|
166
|
+
key = nil
|
123
167
|
while text_not_ready?(key)
|
124
168
|
line_x, line_y = getxy_stream(100)
|
125
169
|
|
@@ -127,8 +171,9 @@ class Device
|
|
127
171
|
touch_clear
|
128
172
|
key = parse(line_x, line_y, params)
|
129
173
|
else
|
130
|
-
|
131
|
-
|
174
|
+
if params[:timeout_enabled]
|
175
|
+
break(Device::IO::KEY_TIMEOUT) if Time.now > time
|
176
|
+
end
|
132
177
|
key = getc(100)
|
133
178
|
if phisical_keys.include?(key)
|
134
179
|
if key == Device::IO::BACK
|
@@ -161,7 +206,7 @@ class Device
|
|
161
206
|
|
162
207
|
def self.show_text(key, params)
|
163
208
|
case key[:char]
|
164
|
-
when :keyboard_uppercase, :keyboard_symbol_number, :keyboard_capital
|
209
|
+
when :keyboard_uppercase, :keyboard_symbol_number, :keyboard_symbol_number_2, :keyboard_capital
|
165
210
|
self.type = key[:char]
|
166
211
|
change_keyboard
|
167
212
|
when :erase
|
@@ -170,7 +215,9 @@ class Device
|
|
170
215
|
when :space
|
171
216
|
self.text += ' '
|
172
217
|
else
|
173
|
-
self.text
|
218
|
+
if self.text && self.text.size < 20
|
219
|
+
self.text << key[:char] unless key[:char] == :enter
|
220
|
+
end
|
174
221
|
end
|
175
222
|
Device::Display.print_line("#{self.text}", params[:line], params[:column])
|
176
223
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class SecureRandomTest < DaFunk::Test.case
|
2
|
+
def setup
|
3
|
+
@uuid = DaFunk::SecureRandom.uuid
|
4
|
+
@random_bytes = DaFunk::SecureRandom.random_bytes
|
5
|
+
end
|
6
|
+
|
7
|
+
def test_uuid
|
8
|
+
assert_equal(36, @uuid.size)
|
9
|
+
|
10
|
+
# Check time_hi_and_version and clock_seq_hi_res bits (RFC 4122 4.4)
|
11
|
+
assert_equal('4', @uuid[14])
|
12
|
+
assert_include(%w'8 9 a b', @uuid[19])
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_random_bytes
|
16
|
+
assert_equal(16, @random_bytes.size)
|
17
|
+
end
|
18
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: da_funk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.32.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thiago Scalone
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -174,10 +174,12 @@ files:
|
|
174
174
|
- lib/da_funk/rake_task.rb
|
175
175
|
- lib/da_funk/screen.rb
|
176
176
|
- lib/da_funk/screen_flow.rb
|
177
|
+
- lib/da_funk/secure_random.rb
|
177
178
|
- lib/da_funk/struct.rb
|
178
179
|
- lib/da_funk/test.rb
|
179
180
|
- lib/da_funk/transaction/download.rb
|
180
181
|
- lib/da_funk/transaction/iso.rb
|
182
|
+
- lib/da_funk/transaction/reversal.rb
|
181
183
|
- lib/da_funk/version.rb
|
182
184
|
- lib/device.rb
|
183
185
|
- lib/device/audio.rb
|
@@ -220,6 +222,7 @@ files:
|
|
220
222
|
- test/resources/shared/bitmap_gp.dat
|
221
223
|
- test/test_helper.rb
|
222
224
|
- test/unit/da_funk/event_listener_test.rb
|
225
|
+
- test/unit/da_funk/secure_random.rb
|
223
226
|
- test/unit/da_funk/struct_test.rb
|
224
227
|
- test/unit/da_funk/support_test.rb
|
225
228
|
- test/unit/device/application_test.rb
|
@@ -256,7 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
256
259
|
- !ruby/object:Gem::Version
|
257
260
|
version: '0'
|
258
261
|
requirements: []
|
259
|
-
rubygems_version: 3.
|
262
|
+
rubygems_version: 3.1.2
|
260
263
|
signing_key:
|
261
264
|
specification_version: 4
|
262
265
|
summary: MRuby Embedded System Framework
|
@@ -269,6 +272,7 @@ test_files:
|
|
269
272
|
- test/resources/shared/bitmap_gp.dat
|
270
273
|
- test/test_helper.rb
|
271
274
|
- test/unit/da_funk/event_listener_test.rb
|
275
|
+
- test/unit/da_funk/secure_random.rb
|
272
276
|
- test/unit/da_funk/struct_test.rb
|
273
277
|
- test/unit/da_funk/support_test.rb
|
274
278
|
- test/unit/device/application_test.rb
|