dji_mqtt_connect 0.1.13.1 → 0.1.14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c144a661c638e1cab414b4798f2fad92e0f39f9fe4f8e433b0140073f92b0735
4
- data.tar.gz: 21df706b1a4f9dafbd3c8286113dea89cd476d292811cb1d2ba4f59a920d7d83
3
+ metadata.gz: cbf7e03c9debc9957d9d8fadc1fa6126377a14574f5f0cdc24009afac5b77bc5
4
+ data.tar.gz: e86ae21b238e3c0063cd42c584544350ba30b8e60eb8241c43b4d8cedb69aedf
5
5
  SHA512:
6
- metadata.gz: '07308e461f220bb9b2e41210a673a00cbcaac25856c00ba019999db97e978d6c8cc37b0125a4f49784edae8956e6c3759a11c5abbdd07e3cd74381969c9b243e'
7
- data.tar.gz: 651bfdc62aaacac40908c807d59903bf09a866fccd4a80aa91e2c8d5cd0db0e24e39b5710329591e99263cf834ecfa2b1787fd55ff608727daec0c2c06856f9e
6
+ metadata.gz: 5930cd00dbb6d2779af90659fdde1b70e2cf31247a1f31dcc3f6a4301f7663117bf06d061dfc1c1d101100c43ce040003fff5152435ad5b4bf1536cea74035a9
7
+ data.tar.gz: 4df8067dff28fb839f2e849b426760fa44ce2f7b9bb5f676c85daae15e54f9395030a3f6f047016f6aaa6ee9d328d75176ccc97d072615be1fb0ea6fd3d42b10
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dji_mqtt_connect (0.1.13.1)
4
+ dji_mqtt_connect (0.1.14)
5
5
  activesupport (>= 6.0, <= 8)
6
6
  dry-struct (~> 1.6)
7
7
  dry-transformer (~> 1.0)
@@ -750,7 +750,7 @@
750
750
  fpv_tip_0x16100006_in_the_sky: Invalid IMU serial number. Return to home or
751
751
  land
752
752
  fpv_tip_0x16100008: Compass calibrating. Unable to take off. Wait for calibration
753
- to complete before taking off(%{alarmid})
753
+ to complete before taking off (%{alarmid})
754
754
  fpv_tip_0x16100008_in_the_sky: Compass calibrating. Wait for calibration to
755
755
  complete before taking off
756
756
  fpv_tip_0x16100009: Sensor system initializing. Unable to take off. Wait for
@@ -0,0 +1,13 @@
1
+ ---
2
+ :en:
3
+ :dji_mqtt_connect:
4
+ :cover_step_key:
5
+ check_drone_sdr_connect_state: "Check Drone SDR Connect State"
6
+ check_scram_state: "Check SCRAM State"
7
+ core_mcu_reboot: "Core MCU Reboot"
8
+ land_mcu_reboot: "Land MCU Reboot"
9
+ rain_mcu_reboot: "Rain MCU Reboot"
10
+ sdr_reboot: "SDR Reboot"
11
+ :services_output_status:
12
+ ok: "Success"
13
+ canceled: "Canceled or Stopped"
@@ -9,17 +9,10 @@ module DjiMqttConnect
9
9
  attribute :result, Types::Integer
10
10
 
11
11
  attribute :output do
12
+ include Mixins::ServicesOutputStatusChecks
13
+
12
14
  # {"sent":"sent","in_progress":"in progress","ok":"success","paused":"paused","rejected":"rejected","failed":"failed","canceled":"canceled or stopped","timeout":"timeout"}
13
- attribute :status, Types::String.enum(
14
- "sent",
15
- "in_progress",
16
- "ok",
17
- "paused",
18
- "rejected",
19
- "failed",
20
- "canceled",
21
- "timeout"
22
- )
15
+ attribute :status, Types::ServicesOutputStatus
23
16
 
24
17
  attribute :progress do
25
18
  # {"min":"0","max":"100","step":"1"}
@@ -56,6 +49,12 @@ module DjiMqttConnect
56
49
  "stop_charge"
57
50
  )
58
51
 
52
+ def humanized_step_key
53
+ return unless step_key
54
+
55
+ I18n.t(step_key, scope: "dji_mqtt_connect.cover_step_key", default: step_key.titleize)
56
+ end
57
+
59
58
  attribute? :step_result, Types::Integer
60
59
  end
61
60
  end
@@ -9,17 +9,10 @@ module DjiMqttConnect
9
9
  attribute :result, Types::Integer
10
10
 
11
11
  attribute :output do
12
+ include Mixins::ServicesOutputStatusChecks
13
+
12
14
  # {"sent":"sent","in_progress":"in progress","ok":"success","paused":"paused","rejected":"rejected","failed":"failed","canceled":"canceled or stopped","timeout":"timeout"}
13
- attribute :status, Types::String.enum(
14
- "sent",
15
- "in_progress",
16
- "ok",
17
- "paused",
18
- "rejected",
19
- "failed",
20
- "canceled",
21
- "timeout"
22
- )
15
+ attribute :status, Types::ServicesOutputStatus
23
16
 
24
17
  attribute :progress do
25
18
  # {"min":"0","max":"100","step":"1"}
@@ -56,6 +49,12 @@ module DjiMqttConnect
56
49
  "stop_charge"
57
50
  )
58
51
 
52
+ def humanized_step_key
53
+ return unless step_key
54
+
55
+ I18n.t(step_key, scope: "dji_mqtt_connect.cover_step_key", default: step_key.titleize)
56
+ end
57
+
59
58
  attribute? :step_result, Types::Integer
60
59
  end
61
60
  end
@@ -53,7 +53,20 @@ module DjiMqttConnect
53
53
 
54
54
  attribute? :drone_charge_state do
55
55
  # {"0":"not charging","1":"charging"}
56
- attribute :state, Types::Integer.enum(0, 1)
56
+ attribute :state, Types::Integer.enum(
57
+ STATE_NOT_CHARGING = 0,
58
+ STATE_CHARGING = 1
59
+ )
60
+
61
+ def humanized_state
62
+ state_key = case state
63
+ when STATE_NOT_CHARGING
64
+ "Not Charging"
65
+ when STATE_CHARGING
66
+ "Charging"
67
+ end
68
+ I18n.t(state_key.parameterize.underscore, scope: "dji_mqtt_connect.dock_drone_charge_state.state", default: state_key)
69
+ end
57
70
 
58
71
  # {"min":"0","max":"100"}
59
72
  attribute :capacity_percent, Types::Integer.constrained(gteq: 0, lteq: 100)
@@ -88,9 +101,38 @@ module DjiMqttConnect
88
101
  end
89
102
 
90
103
  attribute? :network_state do
91
- attribute :type, Types::Integer
92
- attribute :quality, Types::Integer
104
+ attribute :type, Types::Integer.enum(
105
+ NETWORK_TYPE_4G = 1,
106
+ NETWORK_TYPE_ETHERNET = 2
107
+ )
108
+ attribute :quality, Types::Integer.enum(
109
+ QUALITY_BAD = 0,
110
+ QUALITY_MODERATE = 1,
111
+ QUALITY_GOOD = 2
112
+ )
93
113
  attribute :rate, Types::JSON::Decimal
114
+
115
+ def humanized_type
116
+ type_key = case type
117
+ when NETWORK_TYPE_4G
118
+ "4G"
119
+ when NETWORK_TYPE_ETHERNET
120
+ "Ethernet"
121
+ end
122
+ I18n.t(type_key.downcase, scope: "dji_mqtt_connect.dock_network_state.type", default: type_key)
123
+ end
124
+
125
+ def humanized_quality
126
+ quality_key = case quality
127
+ when QUALITY_BAD
128
+ "Bad"
129
+ when QUALITY_MODERATE
130
+ "Moderate"
131
+ when QUALITY_GOOD
132
+ "Good"
133
+ end
134
+ I18n.t(quality_key.downcase, scope: "dji_mqtt_connect.dock_network_state.quality", default: quality_key)
135
+ end
94
136
  end
95
137
 
96
138
  attribute? :sdr do
@@ -164,22 +206,114 @@ module DjiMqttConnect
164
206
  end
165
207
 
166
208
  # {"0":"Closed","1":"Opened"}
167
- attribute? :alarm_state, Types::Integer.enum(0, 1)
209
+ attribute? :alarm_state, Types::Integer.enum(
210
+ ALARM_STATE_CLOSED = 0,
211
+ ALARM_STATE_OPEN = 1
212
+ )
213
+
214
+ def humanized_alarm_state
215
+ return unless alarm_state
216
+
217
+ state_key = case alarm_state
218
+ when ALARM_STATE_CLOSED
219
+ "Closed"
220
+ when ALARM_STATE_OPEN
221
+ "Open"
222
+ end
223
+
224
+ I18n.t(state_key.downcase, scope: "dji_mqtt_connect.dock_alarm_state", default: state_key)
225
+ end
168
226
 
169
227
  # {"1":"Planned storage strategy of battery","2":"Emergency storage strategy of battery"}
170
228
  attribute? :battery_store_mode, Types::Integer.enum(1, 2)
171
229
 
172
230
  # {"0":"Closed","1":"Opened","2":"Half-open","3":"Cover state is abnormal"}
173
- attribute? :cover_state, Types::Integer.enum(0, 1, 2, 3)
231
+ attribute? :cover_state, Types::Integer.enum(
232
+ COVER_STATE_CLOSED = 0,
233
+ COVER_STATE_OPEN = 1,
234
+ COVER_STATE_HALF_OPEN = 2,
235
+ COVER_STATE_ABNORMAL = 3
236
+ )
237
+
238
+ def humanized_cover_state
239
+ return unless cover_state
240
+
241
+ state_key = case cover_state
242
+ when COVER_STATE_CLOSED
243
+ "Closed"
244
+ when COVER_STATE_OPEN
245
+ "Open"
246
+ when COVER_STATE_HALF_OPEN
247
+ "Half-open"
248
+ when COVER_STATE_ABNORMAL
249
+ "Abnormal"
250
+ end
251
+
252
+ I18n.t(state_key.parameterize.underscore, scope: "dji_mqtt_connect.dock_cover_state", default: state_key)
253
+ end
174
254
 
175
255
  # {"0":"Closed","1":"Opened"}
176
- attribute? :emergency_stop_state, Types::Integer.enum(0, 1)
256
+ attribute? :emergency_stop_state, Types::Integer.enum(
257
+ EMERGENCY_STOP_STATE_CLOSED = 0,
258
+ EMERGENCY_STOP_STATE_OPEN = 1
259
+ )
260
+
261
+ def humanized_emergency_stop_state
262
+ return unless emergency_stop_state
263
+
264
+ state_key = case emergency_stop_state
265
+ when EMERGENCY_STOP_STATE_CLOSED
266
+ "Closed"
267
+ when EMERGENCY_STOP_STATE_OPEN
268
+ "Open"
269
+ end
270
+
271
+ I18n.t(state_key.downcase, scope: "dji_mqtt_connect.dock_emergency_stop_state", default: state_key)
272
+ end
177
273
 
178
274
  # {"0":"Closed","1":"Opened","2":"Half-open","3":"Putter state is abnormal"}
179
- attribute? :putter_state, Types::Integer.enum(0, 1, 2, 3)
275
+ attribute? :putter_state, Types::Integer.enum(
276
+ PUTTER_STATE_CLOSED = 0,
277
+ PUTTER_STATE_OPEN = 1,
278
+ PUTTER_STATE_HALF_OPEN = 2,
279
+ PUTTER_STATE_ABNORMAL = 3
280
+ )
281
+
282
+ def humanized_putter_state
283
+ return unless putter_state
284
+
285
+ state_key = case putter_state
286
+ when PUTTER_STATE_CLOSED
287
+ "Closed"
288
+ when PUTTER_STATE_OPEN
289
+ "Open"
290
+ when PUTTER_STATE_HALF_OPEN
291
+ "Half-open"
292
+ when PUTTER_STATE_ABNORMAL
293
+ "Abnormal"
294
+ end
295
+
296
+ I18n.t(state_key.parameterize.underscore, scope: "dji_mqtt_connect.dock_putter_state", default: state_key)
297
+ end
180
298
 
181
299
  # {"0":"Closed","1":"Opened"}
182
- attribute? :supplement_light_state, Types::Integer.enum(0, 1)
300
+ attribute? :supplement_light_state, Types::Integer.enum(
301
+ SUPPLEMENT_LIGHT_STATE_CLOSED = 0,
302
+ SUPPLEMENT_LIGHT_STATE_OPEN = 1
303
+ )
304
+
305
+ def humanized_supplement_light_state
306
+ return unless supplement_light_state
307
+
308
+ state_key = case supplement_light_state
309
+ when SUPPLEMENT_LIGHT_STATE_CLOSED
310
+ "Closed"
311
+ when SUPPLEMENT_LIGHT_STATE_OPEN
312
+ "Open"
313
+ end
314
+
315
+ I18n.t(state_key.downcase, scope: "dji_mqtt_connect.dock_supplement_light_state", default: state_key)
316
+ end
183
317
 
184
318
  attribute? :sub_device do
185
319
  attribute? :device_sn, Types::String
@@ -9,17 +9,10 @@ module DjiMqttConnect
9
9
  attribute :result, Types::Integer
10
10
 
11
11
  attribute :output do
12
+ include Mixins::ServicesOutputStatusChecks
13
+
12
14
  # {"sent":"sent","in_progress":"in progress","ok":"success","paused":"paused","rejected":"rejected","failed":"failed","canceled":"canceled or stopped","timeout":"timeout"}
13
- attribute :status, Types::String.enum(
14
- "sent",
15
- "in_progress",
16
- "ok",
17
- "paused",
18
- "rejected",
19
- "failed",
20
- "canceled",
21
- "timeout"
22
- )
15
+ attribute :status, Types::ServicesOutputStatus
23
16
  end
24
17
  end
25
18
  end
@@ -9,17 +9,10 @@ module DjiMqttConnect
9
9
  attribute :result, Types::Integer
10
10
 
11
11
  attribute :output do
12
+ include Mixins::ServicesOutputStatusChecks
13
+
12
14
  # {"sent":"sent","in_progress":"in progress","ok":"success","paused":"paused","rejected":"rejected","failed":"failed","canceled":"canceled or stopped","timeout":"timeout"}
13
- attribute :status, Types::String.enum(
14
- "sent",
15
- "in_progress",
16
- "ok",
17
- "paused",
18
- "rejected",
19
- "failed",
20
- "canceled",
21
- "timeout"
22
- )
15
+ attribute :status, Types::ServicesOutputStatus
23
16
  end
24
17
  end
25
18
  end
@@ -9,17 +9,10 @@ module DjiMqttConnect
9
9
  attribute :result, Types::Integer
10
10
 
11
11
  attribute :output do
12
+ include Mixins::ServicesOutputStatusChecks
13
+
12
14
  # {"sent":"sent","in_progress":"in progress","ok":"success","paused":"paused","rejected":"rejected","failed":"failed","canceled":"canceled or stopped","timeout":"timeout"}
13
- attribute :status, Types::String.enum(
14
- "sent",
15
- "in_progress",
16
- "ok",
17
- "paused",
18
- "rejected",
19
- "failed",
20
- "canceled",
21
- "timeout"
22
- )
15
+ attribute :status, Types::ServicesOutputStatus
23
16
  end
24
17
  end
25
18
  end
@@ -9,17 +9,10 @@ module DjiMqttConnect
9
9
  attribute :result, Types::Integer
10
10
 
11
11
  attribute :output do
12
+ include Mixins::ServicesOutputStatusChecks
13
+
12
14
  # {"sent":"sent","in_progress":"in progress","ok":"success","paused":"paused","rejected":"rejected","failed":"failed","canceled":"canceled or stopped","timeout":"timeout"}
13
- attribute :status, Types::String.enum(
14
- "sent",
15
- "in_progress",
16
- "ok",
17
- "paused",
18
- "rejected",
19
- "failed",
20
- "canceled",
21
- "timeout"
22
- )
15
+ attribute :status, Types::ServicesOutputStatus
23
16
  end
24
17
  end
25
18
  end
@@ -9,17 +9,10 @@ module DjiMqttConnect
9
9
  attribute :result, Types::Integer
10
10
 
11
11
  attribute :output do
12
+ include Mixins::ServicesOutputStatusChecks
13
+
12
14
  # {"sent":"sent","in_progress":"in progress","ok":"success","paused":"paused","rejected":"rejected","failed":"failed","canceled":"canceled or stopped","timeout":"timeout"}
13
- attribute :status, Types::String.enum(
14
- "sent",
15
- "in_progress",
16
- "ok",
17
- "paused",
18
- "rejected",
19
- "failed",
20
- "canceled",
21
- "timeout"
22
- )
15
+ attribute :status, Types::ServicesOutputStatus
23
16
  end
24
17
  end
25
18
  end
@@ -9,17 +9,10 @@ module DjiMqttConnect
9
9
  attribute :result, Types::Integer
10
10
 
11
11
  attribute :output do
12
+ include Mixins::ServicesOutputStatusChecks
13
+
12
14
  # {"sent":"sent","in_progress":"in progress","ok":"succeeded","paused":"paused","rejected":"rejected","failed":"failed","canceled":"canceled or terminated","timeout":"timeout"}
13
- attribute :status, Types::String.enum(
14
- "sent",
15
- "in_progress",
16
- "ok",
17
- "paused",
18
- "rejected",
19
- "failed",
20
- "canceled",
21
- "timeout"
22
- )
15
+ attribute :status, Types::ServicesOutputStatus
23
16
  end
24
17
  end
25
18
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DjiMqttConnect
4
+ end
5
+ # frozen_string_literal: true
6
+
7
+ module DjiMqttConnect
8
+ module Mixins
9
+ # Provides checks for the output object that contains a Types::ServicesOutputStatus status value
10
+ module ServicesOutputStatusChecks
11
+ def status_finalized?
12
+ [
13
+ Types::SERVICE_OUTPUT_STATUS_OK,
14
+ Types::SERVICE_OUTPUT_STATUS_REJECTED,
15
+ Types::SERVICE_OUTPUT_STATUS_FAILED,
16
+ Types::SERVICE_OUTPUT_STATUS_CANCELED,
17
+ Types::SERVICE_OUTPUT_STATUS_TIMEOUT
18
+ ].include?(status)
19
+ end
20
+ alias_method :status_finalised?, :status_finalized?
21
+
22
+ def humanized_status
23
+ I18n.t(status, scope: "dji_mqtt_connect.services_output_status", default: status.titleize)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -34,5 +34,17 @@ module DjiMqttConnect
34
34
 
35
35
  InvalidTemperature = Types::Integer.constrained(gteq: 1300) # maximum temp of k-type thermocouple, errors are usually 30K+
36
36
  Temperature = InvalidTemperature | Types::JSON::Decimal
37
+
38
+ # {"sent":"sent","in_progress":"in progress","ok":"success","paused":"paused","rejected":"rejected","failed":"failed","canceled":"canceled or stopped","timeout":"timeout"}
39
+ ServicesOutputStatus = Types::String.enum(
40
+ SERVICE_OUTPUT_STATUS_SENT = "sent",
41
+ SERVICE_OUTPUT_STATUS_IN_PROGRESS = "in_progress",
42
+ SERVICE_OUTPUT_STATUS_OK = "ok",
43
+ SERVICE_OUTPUT_STATUS_PAUSED = "paused",
44
+ SERVICE_OUTPUT_STATUS_REJECTED = "rejected",
45
+ SERVICE_OUTPUT_STATUS_FAILED = "failed",
46
+ SERVICE_OUTPUT_STATUS_CANCELED = "canceled",
47
+ SERVICE_OUTPUT_STATUS_TIMEOUT = "timeout"
48
+ )
37
49
  end
38
50
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DjiMqttConnect
4
- VERSION = "0.1.13.1"
4
+ VERSION = "0.1.14"
5
5
  end
@@ -126,6 +126,7 @@ module DjiMqttConnect
126
126
  module Mixins
127
127
  autoload :LatitudeConditional, "dji_mqtt_connect/mixins/latitude_conditional"
128
128
  autoload :LongitudeConditional, "dji_mqtt_connect/mixins/longitude_conditional"
129
+ autoload :ServicesOutputStatusChecks, "dji_mqtt_connect/mixins/services_output_status_checks"
129
130
  autoload :TemperatureConditional, "dji_mqtt_connect/mixins/temperature_conditional"
130
131
  end
131
132
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dji_mqtt_connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13.1
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sphere Drones
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-08 00:00:00.000000000 Z
11
+ date: 2023-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -103,8 +103,9 @@ files:
103
103
  - Gemfile.lock
104
104
  - README.md
105
105
  - Rakefile
106
- - config/locales/dji_mqtt_connect.en.yml
107
- - config/locales/dji_mqtt_connect.zh.yml
106
+ - config/locales/hms_event_codes.en.yml
107
+ - config/locales/hms_event_codes.zh.yml
108
+ - config/locales/services_output_status.en.yml
108
109
  - dji_mqtt_connect.gemspec
109
110
  - lib/dji_mqtt_connect.rb
110
111
  - lib/dji_mqtt_connect/client.rb
@@ -184,6 +185,7 @@ files:
184
185
  - lib/dji_mqtt_connect/messages/thing/product/services_reply_message.rb
185
186
  - lib/dji_mqtt_connect/mixins/latitude_conditional.rb
186
187
  - lib/dji_mqtt_connect/mixins/longitude_conditional.rb
188
+ - lib/dji_mqtt_connect/mixins/services_output_status_checks.rb
187
189
  - lib/dji_mqtt_connect/mixins/temperature_conditional.rb
188
190
  - lib/dji_mqtt_connect/railtie.rb
189
191
  - lib/dji_mqtt_connect/railties/message_serializer.rb