dji_mqtt_connect 0.1.24.1 → 0.1.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/config/locales/flighttask_status.en.yml +136 -0
  4. data/config/locales/result_codes.en.yml +2 -0
  5. data/config/locales/sys_product_status.en.yml +4 -0
  6. data/config/locales/thing_product_events.en.yml +64 -0
  7. data/config/locales/thing_product_events_reply.en.yml +4 -0
  8. data/config/locales/thing_product_osd.en.yml +7 -0
  9. data/config/locales/thing_product_requests.en.yml +12 -0
  10. data/config/locales/thing_product_requests_reply.en.yml +14 -0
  11. data/config/locales/thing_product_services.en.yml +27 -0
  12. data/config/locales/thing_product_services_reply.en.yml +4 -0
  13. data/config/locales/thing_product_state.en.yml +4 -0
  14. data/config/locales/thing_product_state_reply.en.yml +3 -0
  15. data/config/locales/video_qualities.en.yml +8 -0
  16. data/config/locales/video_types.en.yml +7 -0
  17. data/lib/dji_mqtt_connect/factories/events_messages.rb +73 -14
  18. data/lib/dji_mqtt_connect/factories/services_messages.rb +190 -0
  19. data/lib/dji_mqtt_connect/factories/state_messages.rb +19 -19
  20. data/lib/dji_mqtt_connect/factories.rb +14 -176
  21. data/lib/dji_mqtt_connect/marshals/sys/product/status_reply_marshal.rb +2 -16
  22. data/lib/dji_mqtt_connect/marshals/thing/product/events_marshal.rb +11 -4
  23. data/lib/dji_mqtt_connect/marshals/thing/product/events_reply_marshal.rb +2 -16
  24. data/lib/dji_mqtt_connect/marshals/thing/product/osd_marshal.rb +4 -4
  25. data/lib/dji_mqtt_connect/marshals/thing/product/requests_marshal.rb +4 -4
  26. data/lib/dji_mqtt_connect/marshals/thing/product/requests_reply_marshal.rb +2 -16
  27. data/lib/dji_mqtt_connect/marshals/thing/product/services_marshal.rb +2 -16
  28. data/lib/dji_mqtt_connect/marshals/thing/product/services_reply_marshal.rb +4 -4
  29. data/lib/dji_mqtt_connect/marshals/thing/product/state_marshal.rb +4 -4
  30. data/lib/dji_mqtt_connect/marshals/thing/product/state_reply_marshal.rb +2 -16
  31. data/lib/dji_mqtt_connect/messages/sys/product/status/update_topo.rb +1 -1
  32. data/lib/dji_mqtt_connect/messages/sys/product/status_message.rb +10 -0
  33. data/lib/dji_mqtt_connect/messages/sys/product/status_reply/update_topo.rb +1 -10
  34. data/lib/dji_mqtt_connect/messages/sys/product/status_reply_message.rb +22 -0
  35. data/lib/dji_mqtt_connect/messages/thing/product/events/airsense_warning.rb +16 -15
  36. data/lib/dji_mqtt_connect/messages/thing/product/events/cover_close.rb +9 -0
  37. data/lib/dji_mqtt_connect/messages/thing/product/events/cover_open.rb +9 -0
  38. data/lib/dji_mqtt_connect/messages/thing/product/events/device_exit_homing_notify.rb +13 -0
  39. data/lib/dji_mqtt_connect/messages/thing/product/events/device_reboot.rb +9 -0
  40. data/lib/dji_mqtt_connect/messages/thing/product/events/file_upload_callback.rb +13 -1
  41. data/lib/dji_mqtt_connect/messages/thing/product/events/fileupload_progress.rb +28 -1
  42. data/lib/dji_mqtt_connect/messages/thing/product/events/flight_areas_sync_progress.rb +8 -0
  43. data/lib/dji_mqtt_connect/messages/thing/product/events/flighttask_progress.rb +50 -2
  44. data/lib/dji_mqtt_connect/messages/thing/product/events/flighttask_ready.rb +6 -1
  45. data/lib/dji_mqtt_connect/messages/thing/product/events/highest_priority_upload_flighttask_media.rb +6 -1
  46. data/lib/dji_mqtt_connect/messages/thing/product/events/return_home_info.rb +24 -1
  47. data/lib/dji_mqtt_connect/messages/thing/product/events/takeoff_to_point_progress.rb +7 -1
  48. data/lib/dji_mqtt_connect/messages/thing/product/events_message.rb +19 -1
  49. data/lib/dji_mqtt_connect/messages/thing/product/events_reply_message.rb +12 -1
  50. data/lib/dji_mqtt_connect/messages/thing/product/osd/dock.rb +5 -1
  51. data/lib/dji_mqtt_connect/messages/thing/product/osd/drone.rb +5 -1
  52. data/lib/dji_mqtt_connect/messages/thing/product/osd/remote.rb +4 -0
  53. data/lib/dji_mqtt_connect/messages/thing/product/osd_message.rb +14 -4
  54. data/lib/dji_mqtt_connect/messages/thing/product/requests/airport_bind_status.rb +8 -1
  55. data/lib/dji_mqtt_connect/messages/thing/product/requests/airport_organization_bind.rb +15 -1
  56. data/lib/dji_mqtt_connect/messages/thing/product/requests/config.rb +0 -1
  57. data/lib/dji_mqtt_connect/messages/thing/product/requests/flight_areas_get.rb +0 -2
  58. data/lib/dji_mqtt_connect/messages/thing/product/requests/flighttask_resource_get.rb +6 -1
  59. data/lib/dji_mqtt_connect/messages/thing/product/requests/offline_map_get.rb +0 -2
  60. data/lib/dji_mqtt_connect/messages/thing/product/requests_message.rb +18 -1
  61. data/lib/dji_mqtt_connect/messages/thing/product/requests_reply/airport_bind_status.rb +16 -6
  62. data/lib/dji_mqtt_connect/messages/thing/product/requests_reply/airport_organization_bind.rb +2 -6
  63. data/lib/dji_mqtt_connect/messages/thing/product/requests_reply/airport_organization_get.rb +7 -5
  64. data/lib/dji_mqtt_connect/messages/thing/product/requests_reply/config.rb +9 -5
  65. data/lib/dji_mqtt_connect/messages/thing/product/requests_reply/flight_areas_get.rb +21 -5
  66. data/lib/dji_mqtt_connect/messages/thing/product/requests_reply/flighttask_resource_get.rb +1 -5
  67. data/lib/dji_mqtt_connect/messages/thing/product/requests_reply/offline_map_get.rb +3 -14
  68. data/lib/dji_mqtt_connect/messages/thing/product/requests_reply/storage_config_get.rb +7 -5
  69. data/lib/dji_mqtt_connect/messages/thing/product/requests_reply_message.rb +26 -0
  70. data/lib/dji_mqtt_connect/messages/thing/product/services/alarm_state_switch.rb +10 -0
  71. data/lib/dji_mqtt_connect/messages/thing/product/services/cover_close.rb +0 -2
  72. data/lib/dji_mqtt_connect/messages/thing/product/services/cover_open.rb +0 -2
  73. data/lib/dji_mqtt_connect/messages/thing/product/services/debug_mode_close.rb +0 -2
  74. data/lib/dji_mqtt_connect/messages/thing/product/services/debug_mode_open.rb +0 -2
  75. data/lib/dji_mqtt_connect/messages/thing/product/services/flighttask_execute.rb +81 -1
  76. data/lib/dji_mqtt_connect/messages/thing/product/services/flighttask_pause.rb +0 -2
  77. data/lib/dji_mqtt_connect/messages/thing/product/services/flighttask_prepare.rb +19 -5
  78. data/lib/dji_mqtt_connect/messages/thing/product/services/flighttask_progress_get.rb +25 -0
  79. data/lib/dji_mqtt_connect/messages/thing/product/services/flighttask_recovery.rb +0 -2
  80. data/lib/dji_mqtt_connect/messages/thing/product/services/flighttask_stop.rb +37 -0
  81. data/lib/dji_mqtt_connect/messages/thing/product/services/flighttask_undo.rb +12 -1
  82. data/lib/dji_mqtt_connect/messages/thing/product/services/live_lens_change.rb +10 -16
  83. data/lib/dji_mqtt_connect/messages/thing/product/services/live_set_quality.rb +10 -18
  84. data/lib/dji_mqtt_connect/messages/thing/product/services/live_start_push.rb +5 -19
  85. data/lib/dji_mqtt_connect/messages/thing/product/services/live_stop_push.rb +2 -1
  86. data/lib/dji_mqtt_connect/messages/thing/product/services/return_home.rb +1 -6
  87. data/lib/dji_mqtt_connect/messages/thing/product/services/return_home_cancel.rb +1 -6
  88. data/lib/dji_mqtt_connect/messages/thing/product/services/return_specific_home.rb +27 -0
  89. data/lib/dji_mqtt_connect/messages/thing/product/services_message.rb +18 -1
  90. data/lib/dji_mqtt_connect/messages/thing/product/services_reply/flighttask_progress_get.rb +48 -0
  91. data/lib/dji_mqtt_connect/messages/thing/product/services_reply/flighttask_stop.rb +9 -0
  92. data/lib/dji_mqtt_connect/messages/thing/product/services_reply/return_specific_home.rb +22 -0
  93. data/lib/dji_mqtt_connect/messages/thing/product/services_reply_message.rb +8 -0
  94. data/lib/dji_mqtt_connect/messages/thing/product/state_message.rb +71 -9
  95. data/lib/dji_mqtt_connect/messages/thing/product/state_reply_message.rb +12 -1
  96. data/lib/dji_mqtt_connect/mixins/video_quality.rb +43 -0
  97. data/lib/dji_mqtt_connect/mixins/video_type.rb +37 -0
  98. data/lib/dji_mqtt_connect/translations.rb +144 -0
  99. data/lib/dji_mqtt_connect/types.rb +24 -1
  100. data/lib/dji_mqtt_connect/utils/message_dumping.rb +49 -0
  101. data/lib/dji_mqtt_connect/version.rb +1 -1
  102. data/lib/dji_mqtt_connect.rb +12 -0
  103. metadata +26 -2
@@ -1,34 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry-transformer"
4
3
  require "json"
5
4
 
6
5
  module DjiMqttConnect
7
6
  module Thing::Product
8
7
  class EventsReplyMarshal < MessageMarshal
9
- # Renames the method attribute
10
- class HashTransformer < Dry::Transformer::Pipe
11
- import Dry::Transformer::HashTransformations
12
-
13
- define! do
14
- rename_keys _method: :method
15
- end
16
- end
8
+ include Utils::MessageDumping
17
9
 
18
10
  # Converts a message for transmission via MQTT
19
11
  def dump(message)
20
12
  # Fix up the hash representation
21
- transformed_message = hash_transformer.call(message)
13
+ transformed_message = convert_message_to_hash(message)
22
14
 
23
15
  # Convert the transformed message into JSON
24
16
  JSON.generate(transformed_message)
25
17
  end
26
-
27
- private
28
-
29
- def hash_transformer
30
- @hash_transformer ||= HashTransformer.new
31
- end
32
18
  end
33
19
  end
34
20
  end
@@ -9,7 +9,7 @@ module DjiMqttConnect
9
9
  include Utils::MessageParsing
10
10
 
11
11
  # Make a copy of the raw data
12
- class AttributeTransformer < Dry::Transformer::Pipe
12
+ class OsdTransformer < Dry::Transformer::Pipe
13
13
  import Dry::Transformer::Conditional
14
14
  import Dry::Transformer::HashTransformations
15
15
 
@@ -53,15 +53,15 @@ module DjiMqttConnect
53
53
  OsdMessage
54
54
  end
55
55
 
56
- transformed_message = attribute_transformer.call(parsed_message)
56
+ transformed_message = osd_transformer.call(parsed_message)
57
57
 
58
58
  build_message(message_class, transformed_message)
59
59
  end
60
60
 
61
61
  private
62
62
 
63
- def attribute_transformer
64
- @attribute_transformer ||= AttributeTransformer.new
63
+ def osd_transformer
64
+ @osd_transformer ||= OsdTransformer.new
65
65
  end
66
66
 
67
67
  def dock_osd_data_attributes
@@ -10,7 +10,7 @@ module DjiMqttConnect
10
10
  include Utils::MessageParsing
11
11
 
12
12
  # Rename pesky `method` argument to `_method` and makes a copy of the raw data
13
- class AttributeTransformer < Dry::Transformer::Pipe
13
+ class RequestsTransformer < Dry::Transformer::Pipe
14
14
  import Dry::Transformer::HashTransformations
15
15
 
16
16
  define! do
@@ -25,7 +25,7 @@ module DjiMqttConnect
25
25
  parsed_message = parse_json(raw_message)
26
26
 
27
27
  # Transform the message
28
- transformed_message = attribute_transformer.call(parsed_message)
28
+ transformed_message = requests_transformer.call(parsed_message)
29
29
  message_method = transformed_message["_method"]
30
30
 
31
31
  # Build an instance of the class, or a generic message from the current class
@@ -35,8 +35,8 @@ module DjiMqttConnect
35
35
 
36
36
  private
37
37
 
38
- def attribute_transformer
39
- @attribute_transformer ||= AttributeTransformer.new
38
+ def requests_transformer
39
+ @requests_transformer ||= RequestsTransformer.new
40
40
  end
41
41
  end
42
42
  end
@@ -1,34 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry-transformer"
4
3
  require "json"
5
4
 
6
5
  module DjiMqttConnect
7
6
  module Thing::Product
8
7
  class RequestsReplyMarshal < MessageMarshal
9
- # Renames the method attribute
10
- class HashTransformer < Dry::Transformer::Pipe
11
- import Dry::Transformer::HashTransformations
12
-
13
- define! do
14
- rename_keys _method: :method
15
- end
16
- end
8
+ include Utils::MessageDumping
17
9
 
18
10
  # Converts a message for transmission via MQTT
19
11
  def dump(message)
20
12
  # Fix up the hash representation
21
- transformed_message = hash_transformer.call(message)
13
+ transformed_message = convert_message_to_hash(message)
22
14
 
23
15
  # Convert the transformed message into JSON
24
16
  JSON.generate(transformed_message)
25
17
  end
26
-
27
- private
28
-
29
- def hash_transformer
30
- @hash_transformer ||= HashTransformer.new
31
- end
32
18
  end
33
19
  end
34
20
  end
@@ -1,34 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry-transformer"
4
3
  require "json"
5
4
 
6
5
  module DjiMqttConnect
7
6
  module Thing::Product
8
7
  class ServicesMarshal < MessageMarshal
9
- # Renames the method attribute
10
- class HashTransformer < Dry::Transformer::Pipe
11
- import Dry::Transformer::HashTransformations
12
-
13
- define! do
14
- rename_keys _method: :method
15
- end
16
- end
8
+ include Utils::MessageDumping
17
9
 
18
10
  # Converts a message for transmission via MQTT
19
11
  def dump(message)
20
12
  # Fix up the hash representation
21
- transformed_message = hash_transformer.call(message)
13
+ transformed_message = convert_message_to_hash(message)
22
14
 
23
15
  # Convert the transformed message into JSON
24
16
  JSON.generate(transformed_message)
25
17
  end
26
-
27
- private
28
-
29
- def hash_transformer
30
- @hash_transformer ||= HashTransformer.new
31
- end
32
18
  end
33
19
  end
34
20
  end
@@ -10,7 +10,7 @@ module DjiMqttConnect
10
10
  include Utils::MessageParsing
11
11
 
12
12
  # Rename pesky `method` argument to `_method` and makes a copy of the raw data
13
- class AttributeTransformer < Dry::Transformer::Pipe
13
+ class ServicesReplyTransformer < Dry::Transformer::Pipe
14
14
  import Dry::Transformer::HashTransformations
15
15
 
16
16
  define! do
@@ -25,7 +25,7 @@ module DjiMqttConnect
25
25
  parsed_message = parse_json(raw_message)
26
26
 
27
27
  # Transform the message
28
- transformed_message = attribute_transformer.call(parsed_message)
28
+ transformed_message = services_reply_transformer.call(parsed_message)
29
29
  message_method = transformed_message["_method"]
30
30
 
31
31
  # Build an instance of the class, or a generic message from the current class
@@ -35,8 +35,8 @@ module DjiMqttConnect
35
35
 
36
36
  private
37
37
 
38
- def attribute_transformer
39
- @attribute_transformer ||= AttributeTransformer.new
38
+ def services_reply_transformer
39
+ @services_reply_transformer ||= ServicesReplyTransformer.new
40
40
  end
41
41
  end
42
42
  end
@@ -10,7 +10,7 @@ module DjiMqttConnect
10
10
  include Utils::MessageParsing
11
11
 
12
12
  # Rename pesky `method` argument to `_method` and makes a copy of the raw data
13
- class AttributeTransformer < Dry::Transformer::Pipe
13
+ class StateTransformer < Dry::Transformer::Pipe
14
14
  import Dry::Transformer::HashTransformations
15
15
 
16
16
  define! do
@@ -24,7 +24,7 @@ module DjiMqttConnect
24
24
  parsed_message = parse_json(raw_message)
25
25
 
26
26
  # Transform the message
27
- transformed_message = attribute_transformer.call(parsed_message)
27
+ transformed_message = state_transformer.call(parsed_message)
28
28
 
29
29
  # Build an instance of the class, or a generic message from the current class
30
30
  build_message(StateMessage, transformed_message)
@@ -32,8 +32,8 @@ module DjiMqttConnect
32
32
 
33
33
  private
34
34
 
35
- def attribute_transformer
36
- @attribute_transformer ||= AttributeTransformer.new
35
+ def state_transformer
36
+ @state_transformer ||= StateTransformer.new
37
37
  end
38
38
  end
39
39
  end
@@ -1,34 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry-transformer"
4
3
  require "json"
5
4
 
6
5
  module DjiMqttConnect
7
6
  module Thing::Product
8
7
  class StateReplyMarshal < MessageMarshal
9
- # Renames the method attribute
10
- class HashTransformer < Dry::Transformer::Pipe
11
- import Dry::Transformer::HashTransformations
12
-
13
- define! do
14
- rename_keys _method: :method
15
- end
16
- end
8
+ include Utils::MessageDumping
17
9
 
18
10
  # Converts a message for transmission via MQTT
19
11
  def dump(message)
20
12
  # Fix up the hash representation
21
- transformed_message = hash_transformer.call(message)
13
+ transformed_message = convert_message_to_hash(message)
22
14
 
23
15
  # Convert the transformed message into JSON
24
16
  JSON.generate(transformed_message)
25
17
  end
26
-
27
- private
28
-
29
- def hash_transformer
30
- @hash_transformer ||= HashTransformer.new
31
- end
32
18
  end
33
19
  end
34
20
  end
@@ -14,7 +14,7 @@ module DjiMqttConnect
14
14
  attribute? :thing_version, Types::String # dock contains thing_version instead of version
15
15
 
16
16
  attribute :sub_devices, Types::Array do
17
- attribute :sn, Types::String
17
+ attribute :sn, Types::SerialNumber
18
18
  attribute? :domain, Types::DeviceDomain
19
19
  attribute :type, Types::DeviceType
20
20
  attribute :sub_type, Types::DeviceSubType
@@ -11,6 +11,16 @@ module DjiMqttConnect
11
11
  attribute :_data, Types::Hash
12
12
  attribute :_method, Types::String
13
13
 
14
+ attribute :data, Types::Hash.default({}.freeze)
15
+
16
+ def humanized_summary
17
+ Translations.sys_product_status_summary(_method, **humanized_summary_interpolation)
18
+ end
19
+
20
+ def humanized_summary_interpolation
21
+ data.to_h.merge(method: _method)
22
+ end
23
+
14
24
  def to_s
15
25
  # Include data method for Generic messages
16
26
  instance_of?(StatusMessage) ? "#{super}[#{_method}]" : super
@@ -2,7 +2,7 @@
2
2
 
3
3
  module DjiMqttConnect
4
4
  module Sys::Product
5
- class UpdateTopoStatusReplyMessage < Message
5
+ class UpdateTopoStatusReplyMessage < StatusReplyMessage
6
6
  # Builds a reply for an update_topo status message
7
7
  # a result of 0 means we approve of this action
8
8
  def self.build_for(update_topo_status_message, result: 0)
@@ -18,15 +18,6 @@ module DjiMqttConnect
18
18
  end
19
19
 
20
20
  attribute :_method, Types::String.enum("update_topo")
21
-
22
- attribute :tid, Types::UUID
23
- attribute :bid, Types::UUID
24
- attribute :timestamp, Types::Timestamp
25
- attribute :data do
26
- include Mixins::ResultMessage
27
-
28
- attribute :result, Types::ResultCode
29
- end
30
21
  end
31
22
  end
32
23
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DjiMqttConnect
4
+ module Sys::Product
5
+ class StatusReplyMessage < DjiMqttConnect::Message
6
+ # Ensure all values are accepted
7
+ schema schema.strict
8
+
9
+ attribute :tid, Types::UUID
10
+ attribute :bid, Types::UUID
11
+ attribute :timestamp, Types::Timestamp
12
+
13
+ attribute :_method, Types::String
14
+
15
+ attribute :data do
16
+ include Mixins::ResultMessage
17
+
18
+ attribute :result, Types::ResultCode
19
+ end
20
+ end
21
+ end
22
+ end
@@ -4,31 +4,32 @@ module DjiMqttConnect
4
4
  module Thing::Product
5
5
  class AirsenseWarningEventsMessage < EventsMessage
6
6
  attribute :_method, Types::String.enum("airsense_warning")
7
- attribute :_data, Types::Array
8
7
 
9
- attribute :data, Types::Array do
10
- attribute :icao, Types::String
8
+ attribute :data do
9
+ attribute :list, Types::Array do
10
+ attribute :icao, Types::String
11
11
 
12
- # {"0":"No danger","1":"Level one","2":"Level two","3":"Level three","4":"Level four"}
13
- attribute :warning_level, Types::Integer.enum(0, 1, 2, 3, 4)
12
+ # {"0":"No danger","1":"Level one","2":"Level two","3":"Level three","4":"Level four"}
13
+ attribute :warning_level, Types::Integer.enum(0, 1, 2, 3, 4)
14
14
 
15
- attribute :latitude, Types::Latitude
15
+ attribute :latitude, Types::Latitude
16
16
 
17
- attribute :longitude, Types::Longitude
17
+ attribute :longitude, Types::Longitude
18
18
 
19
- attribute :altitude, Types::Integer
19
+ attribute :altitude, Types::Integer
20
20
 
21
- # {"0":"Ellipsoid height","1":"altitude"}
22
- attribute :altitude_type, Types::Integer.enum(0, 1)
21
+ # {"0":"Ellipsoid height","1":"altitude"}
22
+ attribute :altitude_type, Types::Integer.enum(0, 1)
23
23
 
24
- attribute :distance, Types::Integer
24
+ attribute :distance, Types::Integer
25
25
 
26
- attribute :heading, Types::JSON::Decimal
26
+ attribute :heading, Types::JSON::Decimal
27
27
 
28
- attribute :relative_altitude, Types::Integer
28
+ attribute :relative_altitude, Types::Integer
29
29
 
30
- # {"0":"Relative height unchanged","1":"Relative height increase","2":"Relative height decrease"}
31
- attribute :vert_trend, Types::Integer.enum(0, 1, 2)
30
+ # {"0":"Relative height unchanged","1":"Relative height increase","2":"Relative height decrease"}
31
+ attribute :vert_trend, Types::Integer.enum(0, 1, 2)
32
+ end
32
33
  end
33
34
  end
34
35
  end
@@ -33,6 +33,15 @@ module DjiMqttConnect
33
33
  end
34
34
  end
35
35
  end
36
+
37
+ def humanized_summary_interpolation
38
+ super.merge(
39
+ status: data.output.humanized_status,
40
+ percent: data.output.progress.percent,
41
+ current_step: data.output.progress.current_step || "-",
42
+ total_steps: data.output.progress.total_steps || "-"
43
+ )
44
+ end
36
45
  end
37
46
  end
38
47
  end
@@ -33,6 +33,15 @@ module DjiMqttConnect
33
33
  end
34
34
  end
35
35
  end
36
+
37
+ def humanized_summary_interpolation
38
+ super.merge(
39
+ status: data.output.humanized_status,
40
+ percent: data.output.progress.percent,
41
+ current_step: data.output.progress.current_step || "-",
42
+ total_steps: data.output.progress.total_steps || "-"
43
+ )
44
+ end
36
45
  end
37
46
  end
38
47
  end
@@ -4,6 +4,7 @@ module DjiMqttConnect
4
4
  module Thing::Product
5
5
  # Notification of device exits the Return to Home (RTH) state
6
6
  # https://developer.dji.com/doc/cloud-api-tutorial/en/server-api-reference/mqtt/thing-model/gateway/dock/wayline.html#notification-of-device-exits-the-return-to-home-rth-state
7
+ # https://developer.dji.com/doc/cloud-api-tutorial/en/api-reference/dock-to-cloud/mqtt/dock/dock2/wayline.html#device-notification-of-return-to-home-exit-state
7
8
  class DeviceExitHomingNotifyEventsMessage < EventsMessage
8
9
  ENTERING_EXIT_RTH_STATE_ACTION = 1
9
10
  EXIT_EXITING_RTH_STATE_ACTION = 0
@@ -14,6 +15,10 @@ module DjiMqttConnect
14
15
  # {"1":"Enter exiting RTH state"},{"0":"Exit exiting RTH state"}
15
16
  attribute :action, Types::Coercible::Integer.enum(EXIT_EXITING_RTH_STATE_ACTION, ENTERING_EXIT_RTH_STATE_ACTION)
16
17
 
18
+ def humanized_action
19
+ I18n.t(action, scope: "dji_mqtt_connect.thing_product_device_exit_homing_notify_events_message.humanized_action")
20
+ end
21
+
17
22
  attribute :sn, Types::SerialNumber
18
23
 
19
24
  # {"0":"Add joystick throttle","1":"Add joystick pitch","2":"The initialization of behavior tree is failed","3":"Surrounded by obstacles","4":"Flight restriction is triggered","5":"Obstacle is too closed","6":"No GPS signal","7":"The output flag of GPS and VIO location is false","8":"The error of GPS and VIO fusion position is too large","9":"Backtrack in a short distance","10":"Trigger the RTH in a short distance"}
@@ -30,6 +35,14 @@ module DjiMqttConnect
30
35
  BACKTRACK_IN_A_SHORT_DISTANCE_REASON = 9,
31
36
  TRIGGER_THE_RTH_IN_A_SHORT_DISTANCE_REASON = 10
32
37
  )
38
+
39
+ def humanized_reason
40
+ I18n.t(reason, scope: "dji_mqtt_connect.thing_product_device_exit_homing_notify_events_message.humanized_reason", default: "-")
41
+ end
42
+ end
43
+
44
+ def humanized_summary_interpolation
45
+ super.merge(action: data.humanized_action, reason: data.humanized_reason)
33
46
  end
34
47
  end
35
48
  end
@@ -33,6 +33,15 @@ module DjiMqttConnect
33
33
  end
34
34
  end
35
35
  end
36
+
37
+ def humanized_summary_interpolation
38
+ super.merge(
39
+ status: data.output.humanized_status,
40
+ percent: data.output.progress.percent,
41
+ current_step: data.output.progress.current_step || "-",
42
+ total_steps: data.output.progress.total_steps || "-"
43
+ )
44
+ end
36
45
  end
37
46
  end
38
47
  end
@@ -18,7 +18,7 @@ module DjiMqttConnect
18
18
  attribute :name, Types::String
19
19
 
20
20
  attribute :ext do
21
- attribute :flight_id, Types::String
21
+ attribute :flight_id, Types::FlightID
22
22
 
23
23
  attribute :drone_model_key, Types::String
24
24
 
@@ -50,6 +50,18 @@ module DjiMqttConnect
50
50
  end
51
51
  end
52
52
  end
53
+
54
+ def humanized_summary_interpolation
55
+ super.merge(
56
+ file_name: data.file.name,
57
+ flight_id: data.file.ext.flight_id
58
+ )
59
+ end
60
+
61
+ # All the flight IDs in the message
62
+ def flight_ids
63
+ [data.file.ext.flight_id]
64
+ end
53
65
  end
54
66
  end
55
67
  end
@@ -13,8 +13,12 @@ module DjiMqttConnect
13
13
  # {"0":"Aircraft","3":"DJI Dock"}
14
14
  attribute :module, Types::Coercible::Integer.enum(0, 3)
15
15
 
16
+ def humanized_module
17
+ I18n.t(self.module, scope: "dji_mqtt_connect.thing_product_fileupload_progress_events_message.humanized_module")
18
+ end
19
+
16
20
  attribute :size, Types::Integer
17
- attribute :device_sn, Types::String
21
+ attribute :device_sn, Types::SerialNumber
18
22
  attribute :key, Types::String
19
23
  attribute? :fingerprint, Types::String
20
24
 
@@ -26,12 +30,35 @@ module DjiMqttConnect
26
30
  attribute :upload_rate, Types::Integer
27
31
  attribute? :result, Types::Integer
28
32
  attribute :status, Types::String
33
+
34
+ def humanized_status
35
+ # NOTE: status shares many values with flighttask_status, but not all
36
+ I18n.t(status, scope: "dji_mqtt_connect.flighttask_status", default: status.titleize)
37
+ end
38
+ end
39
+
40
+ def humanized_summary
41
+ I18n.t(
42
+ "humanized_summary",
43
+ scope: "dji_mqtt_connect.thing_product_fileupload_progress_events_message",
44
+ module: humanized_module,
45
+ key: key.split("/").last,
46
+ status: progress.humanized_status,
47
+ progress: progress.progress
48
+ )
29
49
  end
30
50
  end
31
51
  end
52
+
32
53
  attribute :status, Types::String
33
54
  end
34
55
  end
56
+
57
+ def humanized_summary_interpolation
58
+ super.merge(
59
+ progress: data.output.ext.files.map(&:humanized_summary).join(", ")
60
+ )
61
+ end
35
62
  end
36
63
  end
37
64
  end
@@ -21,6 +21,14 @@ module DjiMqttConnect
21
21
 
22
22
  # {"1":"Failed to parse file information returned from the cloud.","2":"Failed to retrieve file information from the aircraft's end.","3":"Failed to download the file from the cloud.","4":"Link flipping failed.","5":"File transmission failed."}
23
23
  attribute :reason, Types::Integer.enum(0, 1, 2, 3, 4, 5)
24
+
25
+ def humanized_reason
26
+ I18n.t(reason, scope: "dji_mqtt_connect.thing_product_flight_areas_sync_progress_events_message.humanized_reason")
27
+ end
28
+ end
29
+
30
+ def humanized_summary_interpolation
31
+ super.merge(reason: data.humanized_reason)
24
32
  end
25
33
  end
26
34
  end