dji_mqtt_connect 0.1.14.1 → 0.1.15.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47395f1b58ac06502a0920de3175c3410f11872f25c6248245b206bd4f4a5522
4
- data.tar.gz: 72ff4759ad36e7f157b374a1d230d5f493e384a767b26a3d59d20e8a8f32c5c2
3
+ metadata.gz: 47088befabe8de8f2476d0cae32c0a7d6514bb4bb535a4fa9f9ca77d8487b012
4
+ data.tar.gz: 794eaa0083251281365af9ac3eabdaa1d519c97ca306387384af51b8461211d9
5
5
  SHA512:
6
- metadata.gz: acf0c009ffd5fbe14ad9b0ef6708dcb437e3d4ffdd1082e4aa567dbd7734b98f93b756155be1fbb820d291c86d4b11eb6ff14f4cca657e9abf67cb4cfbeb6ce2
7
- data.tar.gz: fc2b1c92cc39e9d8581df7056c6531e3cc6979d66b2a8fba89e7818097e5723b7deda2bdb5c3f708cf5619eaab6d42fde52de05f7b93a06033cc1cdee60cc22c
6
+ metadata.gz: 54ecb1cfb6c7e1155a52c8cd1543c7b251e9ed573c34a9dcb6b563b15bc0374d685812735e867811ccbc7ab5f81004973ab2917d6f63e6954d10295720a9f9ce
7
+ data.tar.gz: 8ebd5fd2616808530e7c7ea23cfbf52ef705314462baf408c886fd91c93afb17f051ae413492db65279ddd934988f90384bdb171aa3a1d4ac17217a257557bdc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dji_mqtt_connect (0.1.14.1)
4
+ dji_mqtt_connect (0.1.15.1)
5
5
  activesupport (>= 6.0, <= 8)
6
6
  dry-struct (~> 1.6)
7
7
  dry-transformer (~> 1.0)
@@ -39,9 +39,11 @@ module DjiMqttConnect
39
39
  parsed_message = JSON.parse(raw_message)
40
40
 
41
41
  message_data = parsed_message.fetch("data", {})
42
+
42
43
  message_class = if drone_osd_data_attributes.all? { |attribute| message_data.key?(attribute.to_s) }
43
44
  DroneOsdMessage
44
- elsif remote_osd_data_attributes.all? { |attribute| message_data.key?(attribute.to_s) }
45
+ elsif required_remote_osd_data_attributes.all? { |attribute| message_data.key?(attribute.to_s) } &&
46
+ optional_remote_osd_data_attributes.any? { |attribute| message_data.key?(attribute.to_s) }
45
47
  RemoteOsdMessage
46
48
  elsif dock_osd_data_attributes.any? { |attribute| message_data.key?(attribute.to_s) }
47
49
  DockOsdMessage
@@ -72,12 +74,19 @@ module DjiMqttConnect
72
74
  @drone_osd_data_attributes ||= DroneOsdMessage::STABLE_DATA_ATTRIBUTES.map(&:to_s)
73
75
  end
74
76
 
75
- def remote_osd_data_attributes
76
- @remote_osd_data_attributes ||= begin
77
+ def required_remote_osd_data_attributes
78
+ @required_remote_osd_data_attributes ||= begin
77
79
  data_keys = DjiMqttConnect::Thing::Product::RemoteOsdMessage::Data.schema.keys
78
80
  data_keys.select(&:required?).map(&:name)
79
81
  end
80
82
  end
83
+
84
+ def optional_remote_osd_data_attributes
85
+ @optional_remote_osd_data_attributes ||= begin
86
+ data_keys = DjiMqttConnect::Thing::Product::RemoteOsdMessage::Data.schema.keys
87
+ data_keys.reject(&:required?).map(&:name)
88
+ end
89
+ end
81
90
  end
82
91
  end
83
92
  end
@@ -161,11 +161,36 @@ module DjiMqttConnect
161
161
 
162
162
  attribute? :height, Types::JSON::Decimal
163
163
  attribute? :humidity, Types::Integer
164
- attribute? :rainfall, Types::JSON::Decimal
164
+
165
165
  attribute? :temperature, Types::Temperature
166
166
  attribute? :wind_speed, Types::JSON::Decimal
167
167
  attribute? :environment_temperature, Types::Temperature
168
168
 
169
+ # {"0":"No rain","1":"Light rain","2":"Moderate rain","3":"Heavy rain"}
170
+ attribute? :rainfall, Types::Integer.enum(
171
+ RAINFALL_NONE = 0,
172
+ RAINFALL_LIGHT = 1,
173
+ RAINFALL_MODERATE = 2,
174
+ RAINFALL_HEAVY = 3
175
+ )
176
+
177
+ def humanized_rainfall
178
+ return unless rainfall
179
+
180
+ rainfall_key = case rainfall
181
+ when RAINFALL_NONE
182
+ "None"
183
+ when RAINFALL_LIGHT
184
+ "Light"
185
+ when RAINFALL_MODERATE
186
+ "Moderate"
187
+ when RAINFALL_HEAVY
188
+ "Heavy"
189
+ end
190
+
191
+ I18n.t(rainfall_key.downcase, scope: "dji_mqtt_connect.rainfall", default: rainfall_key)
192
+ end
193
+
169
194
  attribute? :alternate_land_point do
170
195
  attribute :latitude, Types::Latitude
171
196
  attribute :longitude, Types::Longitude
@@ -87,37 +87,37 @@ module DjiMqttConnect
87
87
  # M30 Fields
88
88
 
89
89
  attribute? :cameras, Types::Array do
90
+ attribute :payload_index, Types::String
91
+
90
92
  # {"0":"Photo taking","1":"Recording"}
91
- attribute :camera_mode, Types::Integer.enum(0, 1)
93
+ attribute? :camera_mode, Types::Integer.enum(0, 1)
92
94
 
93
95
  # {"min":2,"max":20}
94
- attribute :ir_zoom_factor, Types::JSON::Decimal
96
+ attribute? :ir_zoom_factor, Types::JSON::Decimal
95
97
 
96
- attribute :liveview_world_region do
98
+ attribute? :liveview_world_region do
97
99
  attribute :bottom, Types::JSON::Decimal.constrained(gteq: 0, lteq: 1)
98
100
  attribute :left, Types::JSON::Decimal.constrained(gteq: 0, lteq: 1)
99
101
  attribute :right, Types::JSON::Decimal.constrained(gteq: 0, lteq: 1)
100
102
  attribute :top, Types::JSON::Decimal.constrained(gteq: 0, lteq: 1)
101
103
  end
102
104
 
103
- attribute :payload_index, Types::String
104
-
105
105
  # {"0":"Idle","1":"Taking photo"}
106
- attribute :photo_state, Types::Integer.enum(0, 1)
106
+ attribute? :photo_state, Types::Integer.enum(0, 1)
107
107
 
108
108
  # {"0":"Idle","1":"Recording"}
109
- attribute :recording_state, Types::Integer.enum(0, 1)
109
+ attribute? :recording_state, Types::Integer.enum(0, 1)
110
110
 
111
111
  # {"unit":"s"}
112
- attribute :record_time, Types::Integer
112
+ attribute? :record_time, Types::Integer
113
113
 
114
- attribute :remain_photo_num, Types::Integer
114
+ attribute? :remain_photo_num, Types::Integer
115
115
 
116
116
  # {"unit":"s"}
117
- attribute :remain_record_duration, Types::Integer
117
+ attribute? :remain_record_duration, Types::Integer
118
118
 
119
119
  # {"min":2,"max":200}
120
- attribute :zoom_factor, Types::JSON::Decimal
120
+ attribute? :zoom_factor, Types::JSON::Decimal
121
121
  end
122
122
 
123
123
  # {"0":"Continue to execute the wayline task","1":"Exit the wayline task, and execute the remote controller out of control action."}
@@ -8,15 +8,17 @@ module DjiMqttConnect
8
8
  include Mixins::LongitudeConditional
9
9
 
10
10
  attribute :capacity_percent, Types::Integer
11
+
11
12
  attribute :latitude, Types::Latitude
12
- attribute :live_status do
13
+ attribute :longitude, Types::Longitude
14
+
15
+ attribute? :live_status do
13
16
  attribute :live_time, Types::Integer
14
17
  attribute :live_trendline, Types::Integer
15
18
  attribute :video_id, Types::String
16
19
  attribute :video_quality, Types::Integer
17
20
  end
18
- attribute :longitude, Types::Longitude
19
- attribute :transmission_signal_quality, Types::Integer
21
+ attribute? :transmission_signal_quality, Types::Integer
20
22
  attribute? :wireless_link do
21
23
  attribute :_4g_freq_band, Types::JSON::Decimal
22
24
  attribute :_4g_gnd_quality, Types::Integer
@@ -29,7 +31,7 @@ module DjiMqttConnect
29
31
  attribute :sdr_link_state, Types::Integer
30
32
  attribute :sdr_quality, Types::Integer
31
33
  end
32
- attribute :wireless_link_state do
34
+ attribute? :wireless_link_state do
33
35
  attribute :download_quality, Types::Integer
34
36
  attribute :frequency_band, Types::Integer
35
37
  attribute :upward_quality, Types::Integer
@@ -8,6 +8,11 @@ module DjiMqttConnect
8
8
  module Mixins
9
9
  # Provides checks for the output object that contains a Types::ServicesOutputStatus status value
10
10
  module ServicesOutputStatusChecks
11
+ # Provide accessors for each status value
12
+ DjiMqttConnect::Types::ServicesOutputStatus.values.each do |status_value|
13
+ define_method(:"status_#{status_value}?") { status == status_value }
14
+ end
15
+
11
16
  def status_finalized?
12
17
  [
13
18
  Types::SERVICE_OUTPUT_STATUS_OK,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DjiMqttConnect
4
- VERSION = "0.1.14.1"
4
+ VERSION = "0.1.15.1"
5
5
  end
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.14.1
4
+ version: 0.1.15.1
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-20 00:00:00.000000000 Z
11
+ date: 2023-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport