timex_datalink_client 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/timex_datalink_client/helpers/char_encoders.rb +1 -1
- data/lib/timex_datalink_client/protocol_1/eeprom.rb +27 -6
- data/lib/timex_datalink_client/protocol_3/eeprom.rb +27 -6
- data/lib/timex_datalink_client/protocol_4/eeprom.rb +27 -6
- data/lib/timex_datalink_client/protocol_7/eeprom/speech.rb +4 -1
- data/lib/timex_datalink_client/protocol_7/eeprom.rb +0 -3
- data/lib/timex_datalink_client/version.rb +1 -1
- data/lib/timex_datalink_client.rb +5 -5
- metadata +45 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10adb86fd981a90fa2e764e3dd63bbaf0b1ffa1c37b5210d510ea6aa29b76edb
|
4
|
+
data.tar.gz: 2d2b67b5b10a8a6bd7bbefd4423e9e7b661a4824649e241df0e4e3ca45e17290
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a2fca239d0220cc056a7577ec7b17d1e4e9cf9f2c706af832b38ec0d0eb5522ae4df970369fa7be882eea686fa0da0bb0f063d86f8ce3736ba24c9c0f1acca2
|
7
|
+
data.tar.gz: 4c8296686c59d03b8da2970cda23c8c525f2376a1d8bca2094c3b44955c37d59625d9cf8e9a8c9545a600421514e584a32e53d52fa537f40af0a035041f140b6
|
@@ -20,7 +20,7 @@ class TimexDatalinkClient
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def eeprom_chars_for(string_chars, length: 31)
|
23
|
-
chars = chars_for(string_chars, char_map: EEPROM_CHARS, length:
|
23
|
+
chars = chars_for(string_chars, char_map: EEPROM_CHARS, length:).append(EEPROM_TERMINATOR)
|
24
24
|
|
25
25
|
packed_int = chars.each_with_index.sum do |char, index|
|
26
26
|
char << (6 * index)
|
@@ -1,11 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "active_model"
|
4
|
+
|
3
5
|
require "timex_datalink_client/helpers/cpacket_paginator"
|
4
6
|
require "timex_datalink_client/helpers/crc_packets_wrapper"
|
5
7
|
|
6
8
|
class TimexDatalinkClient
|
7
9
|
class Protocol1
|
8
10
|
class Eeprom
|
11
|
+
include ActiveModel::Validations
|
9
12
|
include Helpers::CpacketPaginator
|
10
13
|
prepend Helpers::CrcPacketsWrapper
|
11
14
|
|
@@ -16,8 +19,16 @@ class TimexDatalinkClient
|
|
16
19
|
CPACKET_DATA_LENGTH = 27
|
17
20
|
START_INDEX = 14
|
18
21
|
APPOINTMENT_NO_NOTIFICATION = 0xff
|
22
|
+
APPOINTMENT_NOTIFICATION_VALID_MINUTES = (0..30).step(5)
|
23
|
+
|
24
|
+
attr_accessor :appointments, :anniversaries, :phone_numbers, :lists, :appointment_notification_minutes
|
19
25
|
|
20
|
-
|
26
|
+
validates :appointment_notification_minutes, inclusion: {
|
27
|
+
in: APPOINTMENT_NOTIFICATION_VALID_MINUTES,
|
28
|
+
allow_nil: true,
|
29
|
+
message: "value %{value} is invalid! Valid appointment notification minutes values are" \
|
30
|
+
" #{APPOINTMENT_NOTIFICATION_VALID_MINUTES.to_a} or nil."
|
31
|
+
}
|
21
32
|
|
22
33
|
# Create an Eeprom instance.
|
23
34
|
#
|
@@ -25,21 +36,25 @@ class TimexDatalinkClient
|
|
25
36
|
# @param anniversaries [Array<Anniversary>] Anniversaries to be added to EEPROM data.
|
26
37
|
# @param phone_numbers [Array<PhoneNumber>] Phone numbers to be added to EEPROM data.
|
27
38
|
# @param lists [Array<List>] Lists to be added to EEPROM data.
|
28
|
-
# @param
|
29
|
-
# notification)
|
39
|
+
# @param appointment_notification_minutes [Integer, nil] Appointment notification in minutes.
|
30
40
|
# @return [Eeprom] Eeprom instance.
|
31
|
-
def initialize(
|
41
|
+
def initialize(
|
42
|
+
appointments: [], anniversaries: [], phone_numbers: [], lists: [], appointment_notification_minutes: nil
|
43
|
+
)
|
32
44
|
@appointments = appointments
|
33
45
|
@anniversaries = anniversaries
|
34
46
|
@phone_numbers = phone_numbers
|
35
47
|
@lists = lists
|
36
|
-
@
|
48
|
+
@appointment_notification_minutes = appointment_notification_minutes
|
37
49
|
end
|
38
50
|
|
39
51
|
# Compile packets for EEPROM data.
|
40
52
|
#
|
53
|
+
# @raise [ActiveModel::ValidationError] One or more model values are invalid.
|
41
54
|
# @return [Array<Array<Integer>>] Two-dimensional array of integers that represent bytes.
|
42
55
|
def packets
|
56
|
+
validate!
|
57
|
+
|
43
58
|
[header] + payloads + [CPACKET_END]
|
44
59
|
end
|
45
60
|
|
@@ -57,7 +72,7 @@ class TimexDatalinkClient
|
|
57
72
|
items_indexes,
|
58
73
|
items_lengths,
|
59
74
|
earliest_appointment_year,
|
60
|
-
|
75
|
+
appointment_notification_minutes_value,
|
61
76
|
all_packets
|
62
77
|
].flatten
|
63
78
|
end
|
@@ -95,6 +110,12 @@ class TimexDatalinkClient
|
|
95
110
|
|
96
111
|
earliest_appointment.time.year % 100
|
97
112
|
end
|
113
|
+
|
114
|
+
def appointment_notification_minutes_value
|
115
|
+
return APPOINTMENT_NO_NOTIFICATION unless appointment_notification_minutes
|
116
|
+
|
117
|
+
appointment_notification_minutes / 5
|
118
|
+
end
|
98
119
|
end
|
99
120
|
end
|
100
121
|
end
|
@@ -1,11 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "active_model"
|
4
|
+
|
3
5
|
require "timex_datalink_client/helpers/cpacket_paginator"
|
4
6
|
require "timex_datalink_client/helpers/crc_packets_wrapper"
|
5
7
|
|
6
8
|
class TimexDatalinkClient
|
7
9
|
class Protocol3
|
8
10
|
class Eeprom
|
11
|
+
include ActiveModel::Validations
|
9
12
|
include Helpers::CpacketPaginator
|
10
13
|
prepend Helpers::CrcPacketsWrapper
|
11
14
|
|
@@ -17,8 +20,16 @@ class TimexDatalinkClient
|
|
17
20
|
CPACKET_DATA_LENGTH = 32
|
18
21
|
START_ADDRESS = 0x0236
|
19
22
|
APPOINTMENT_NO_NOTIFICATION = 0xff
|
23
|
+
APPOINTMENT_NOTIFICATION_VALID_MINUTES = (0..30).step(5)
|
24
|
+
|
25
|
+
attr_accessor :appointments, :anniversaries, :phone_numbers, :lists, :appointment_notification_minutes
|
20
26
|
|
21
|
-
|
27
|
+
validates :appointment_notification_minutes, inclusion: {
|
28
|
+
in: APPOINTMENT_NOTIFICATION_VALID_MINUTES,
|
29
|
+
allow_nil: true,
|
30
|
+
message: "value %{value} is invalid! Valid appointment notification minutes values are" \
|
31
|
+
" #{APPOINTMENT_NOTIFICATION_VALID_MINUTES.to_a} or nil."
|
32
|
+
}
|
22
33
|
|
23
34
|
# Create an Eeprom instance.
|
24
35
|
#
|
@@ -26,21 +37,25 @@ class TimexDatalinkClient
|
|
26
37
|
# @param anniversaries [Array<Anniversary>] Anniversaries to be added to EEPROM data.
|
27
38
|
# @param phone_numbers [Array<PhoneNumber>] Phone numbers to be added to EEPROM data.
|
28
39
|
# @param lists [Array<List>] Lists to be added to EEPROM data.
|
29
|
-
# @param
|
30
|
-
# notification)
|
40
|
+
# @param appointment_notification_minutes [Integer, nil] Appointment notification in minutes.
|
31
41
|
# @return [Eeprom] Eeprom instance.
|
32
|
-
def initialize(
|
42
|
+
def initialize(
|
43
|
+
appointments: [], anniversaries: [], phone_numbers: [], lists: [], appointment_notification_minutes: nil
|
44
|
+
)
|
33
45
|
@appointments = appointments
|
34
46
|
@anniversaries = anniversaries
|
35
47
|
@phone_numbers = phone_numbers
|
36
48
|
@lists = lists
|
37
|
-
@
|
49
|
+
@appointment_notification_minutes = appointment_notification_minutes
|
38
50
|
end
|
39
51
|
|
40
52
|
# Compile packets for EEPROM data.
|
41
53
|
#
|
54
|
+
# @raise [ActiveModel::ValidationError] One or more model values are invalid.
|
42
55
|
# @return [Array<Array<Integer>>] Two-dimensional array of integers that represent bytes.
|
43
56
|
def packets
|
57
|
+
validate!
|
58
|
+
|
44
59
|
[CPACKET_CLEAR, header] + payloads + [CPACKET_END]
|
45
60
|
end
|
46
61
|
|
@@ -53,7 +68,7 @@ class TimexDatalinkClient
|
|
53
68
|
items_addresses,
|
54
69
|
items_lengths,
|
55
70
|
earliest_appointment_year,
|
56
|
-
|
71
|
+
appointment_notification_minutes_value
|
57
72
|
].flatten
|
58
73
|
end
|
59
74
|
|
@@ -90,6 +105,12 @@ class TimexDatalinkClient
|
|
90
105
|
|
91
106
|
earliest_appointment.time.year % 100
|
92
107
|
end
|
108
|
+
|
109
|
+
def appointment_notification_minutes_value
|
110
|
+
return APPOINTMENT_NO_NOTIFICATION unless appointment_notification_minutes
|
111
|
+
|
112
|
+
appointment_notification_minutes / 5
|
113
|
+
end
|
93
114
|
end
|
94
115
|
end
|
95
116
|
end
|
@@ -1,11 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "active_model"
|
4
|
+
|
3
5
|
require "timex_datalink_client/helpers/cpacket_paginator"
|
4
6
|
require "timex_datalink_client/helpers/crc_packets_wrapper"
|
5
7
|
|
6
8
|
class TimexDatalinkClient
|
7
9
|
class Protocol4
|
8
10
|
class Eeprom
|
11
|
+
include ActiveModel::Validations
|
9
12
|
include Helpers::CpacketPaginator
|
10
13
|
prepend Helpers::CrcPacketsWrapper
|
11
14
|
|
@@ -17,8 +20,16 @@ class TimexDatalinkClient
|
|
17
20
|
CPACKET_DATA_LENGTH = 32
|
18
21
|
START_ADDRESS = 0x0236
|
19
22
|
APPOINTMENT_NO_NOTIFICATION = 0xff
|
23
|
+
APPOINTMENT_NOTIFICATION_VALID_MINUTES = (0..30).step(5)
|
24
|
+
|
25
|
+
attr_accessor :appointments, :anniversaries, :phone_numbers, :lists, :appointment_notification_minutes
|
20
26
|
|
21
|
-
|
27
|
+
validates :appointment_notification_minutes, inclusion: {
|
28
|
+
in: APPOINTMENT_NOTIFICATION_VALID_MINUTES,
|
29
|
+
allow_nil: true,
|
30
|
+
message: "value %{value} is invalid! Valid appointment notification minutes values are" \
|
31
|
+
" #{APPOINTMENT_NOTIFICATION_VALID_MINUTES.to_a} or nil."
|
32
|
+
}
|
22
33
|
|
23
34
|
# Create an Eeprom instance.
|
24
35
|
#
|
@@ -26,21 +37,25 @@ class TimexDatalinkClient
|
|
26
37
|
# @param anniversaries [Array<Anniversary>] Anniversaries to be added to EEPROM data.
|
27
38
|
# @param phone_numbers [Array<PhoneNumber>] Phone numbers to be added to EEPROM data.
|
28
39
|
# @param lists [Array<List>] Lists to be added to EEPROM data.
|
29
|
-
# @param
|
30
|
-
# notification)
|
40
|
+
# @param appointment_notification_minutes [Integer, nil] Appointment notification in minutes.
|
31
41
|
# @return [Eeprom] Eeprom instance.
|
32
|
-
def initialize(
|
42
|
+
def initialize(
|
43
|
+
appointments: [], anniversaries: [], phone_numbers: [], lists: [], appointment_notification_minutes: nil
|
44
|
+
)
|
33
45
|
@appointments = appointments
|
34
46
|
@anniversaries = anniversaries
|
35
47
|
@phone_numbers = phone_numbers
|
36
48
|
@lists = lists
|
37
|
-
@
|
49
|
+
@appointment_notification_minutes = appointment_notification_minutes
|
38
50
|
end
|
39
51
|
|
40
52
|
# Compile packets for EEPROM data.
|
41
53
|
#
|
54
|
+
# @raise [ActiveModel::ValidationError] One or more model values are invalid.
|
42
55
|
# @return [Array<Array<Integer>>] Two-dimensional array of integers that represent bytes.
|
43
56
|
def packets
|
57
|
+
validate!
|
58
|
+
|
44
59
|
[CPACKET_CLEAR, header] + payloads + [CPACKET_END]
|
45
60
|
end
|
46
61
|
|
@@ -53,7 +68,7 @@ class TimexDatalinkClient
|
|
53
68
|
items_addresses,
|
54
69
|
items_lengths,
|
55
70
|
earliest_appointment_year,
|
56
|
-
|
71
|
+
appointment_notification_minutes_value
|
57
72
|
].flatten
|
58
73
|
end
|
59
74
|
|
@@ -90,6 +105,12 @@ class TimexDatalinkClient
|
|
90
105
|
|
91
106
|
earliest_appointment.time.year % 100
|
92
107
|
end
|
108
|
+
|
109
|
+
def appointment_notification_minutes_value
|
110
|
+
return APPOINTMENT_NO_NOTIFICATION unless appointment_notification_minutes
|
111
|
+
|
112
|
+
appointment_notification_minutes / 5
|
113
|
+
end
|
93
114
|
end
|
94
115
|
end
|
95
116
|
end
|
@@ -155,7 +155,10 @@ class TimexDatalinkClient
|
|
155
155
|
value_4_length = device_nickname.any? ? NICKNAME_LENGTH_WITH_DEVICE : NICKNAME_LENGTH_WITHOUT_DEVICE
|
156
156
|
|
157
157
|
value_4_length.times.flat_map do |value_4_index|
|
158
|
-
device_value = HEADER_VALUE_4_DEVICE_INDEXES[value_4_index].sum
|
158
|
+
device_value = HEADER_VALUE_4_DEVICE_INDEXES[value_4_index].sum do |device_index|
|
159
|
+
packet_lengths[device_index]
|
160
|
+
end
|
161
|
+
|
159
162
|
device_value *= HEADER_VALUE_4_DEVICE_MULTIPLIERS[value_4_index]
|
160
163
|
|
161
164
|
user_value = HEADER_VALUE_4_USER_INDEXES[value_4_index].sum { |device_index| packet_lengths[device_index] }
|
@@ -9,9 +9,6 @@ class TimexDatalinkClient
|
|
9
9
|
include Helpers::CpacketPaginator
|
10
10
|
prepend Helpers::CrcPacketsWrapper
|
11
11
|
|
12
|
-
# FIXME use arrays for array models
|
13
|
-
# FIXME: check Array<Integer> yardoc around places
|
14
|
-
|
15
12
|
CPACKET_SECT = [0x90, 0x05]
|
16
13
|
CPACKET_DATA = [0x91, 0x05]
|
17
14
|
CPACKET_END = [0x92, 0x05]
|
@@ -104,17 +104,17 @@ class TimexDatalinkClient
|
|
104
104
|
#
|
105
105
|
# @return [Array<Array<Integer>>] Two-dimensional array of integers that represent bytes.
|
106
106
|
def packets
|
107
|
-
models.
|
107
|
+
models.flat_map(&:packets)
|
108
108
|
end
|
109
109
|
|
110
110
|
private
|
111
111
|
|
112
112
|
def notebook_adapter
|
113
113
|
@notebook_adapter ||= NotebookAdapter.new(
|
114
|
-
serial_device
|
115
|
-
byte_sleep
|
116
|
-
packet_sleep
|
117
|
-
verbose:
|
114
|
+
serial_device:,
|
115
|
+
byte_sleep:,
|
116
|
+
packet_sleep:,
|
117
|
+
verbose:
|
118
118
|
)
|
119
119
|
end
|
120
120
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timex_datalink_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maxwell Pray
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.6.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: mdl
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.12.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.12.0
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rspec
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +94,34 @@ dependencies:
|
|
80
94
|
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: 3.11.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.41.1
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.41.1
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop-github
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.20.0
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.20.0
|
83
125
|
- !ruby/object:Gem::Dependency
|
84
126
|
name: tzinfo
|
85
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -182,7 +224,7 @@ files:
|
|
182
224
|
- lib/timex_datalink_client/protocol_9/time_name.rb
|
183
225
|
- lib/timex_datalink_client/protocol_9/timer.rb
|
184
226
|
- lib/timex_datalink_client/version.rb
|
185
|
-
homepage: https://github.com/synthead/timex_datalink_client/tree/v0.
|
227
|
+
homepage: https://github.com/synthead/timex_datalink_client/tree/v0.11.0
|
186
228
|
licenses:
|
187
229
|
- MIT
|
188
230
|
metadata: {}
|