dji_mqtt_connect 0.1.39 → 0.1.40

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: 46ee9a9805803efb395c42306ad2b8b7a60f78b45731e0ba7ab6788f45b3142b
4
- data.tar.gz: 80d648fcc793256d4a8a5e2d0cb4a8a38baa1467df6c951bcb33297166486638
3
+ metadata.gz: 209eb2ba74757a25e02dbbf23c1b69f934afb836d30edf8afdc9a4b19f5943d7
4
+ data.tar.gz: dff2d0f26cdfff2d30834193330519181e38e207ac5a866068fc320b966466c9
5
5
  SHA512:
6
- metadata.gz: bc7c47e9496cd68e0bbe8478417f52a78cd60067748bc0091d39fa0f2068c5fda1a2840e3410e0b086ad581647b365c76e2c4f8d1a48c03c080210b27b179343
7
- data.tar.gz: 145aee434ab1618320a1f31cdd39485966f1c91d24830689a786667dccef17e7ebb9a18293a74a54686d1148672fe8b58e919bfcd85c3803e1dd9215dd22eeb8
6
+ metadata.gz: 3c3d50fa6ef757e7c4d4e48ef49f46cf0e2e23ee2b6e633694a7e0fc72db7694e4097204c76aacf3f9082c359991eb41d30abbb9bf6561e28763f20ecdd73117
7
+ data.tar.gz: f4e7dedef4d6eb1669e1b21af8d221ae51abefaf0a7e5eb7a3d41dff924ec482265ba9df7b7e38127cba354cbcc88b26507aced63e13fa07430de97735965b98
@@ -110,9 +110,11 @@ module DjiMqttConnect
110
110
  include Mixins::DockModeCode
111
111
 
112
112
  attribute? :network_state do
113
- attribute :type, Types::NetworkStateType
113
+ # {"1":"4G","2":"Ethernet"}
114
+ attribute :type, Types::NetworkStateType | Types::Integer
114
115
  include Mixins::NetworkStateType
115
116
 
117
+ # {"0":"No signal","1":"Bad","2":"Poor","3":"Fair","4":"Good","5":"Excellent"}
116
118
  attribute :quality, Types::NetworkStateQuality | Types::Integer
117
119
  include Mixins::NetworkStateQuality
118
120
 
@@ -127,15 +129,52 @@ module DjiMqttConnect
127
129
 
128
130
  attribute? :wireless_link do
129
131
  attribute? :_4g_freq_band, Types::JSON::Decimal
130
- attribute? :_4g_gnd_quality, Types::Integer
131
- attribute? :_4g_link_state, Types::Integer
132
- attribute? :_4g_quality, Types::Integer
133
- attribute? :_4g_uav_quality, Types::Integer
132
+
133
+ attribute? :_4g_gnd_quality, Types::WirelessLinkQuality | Types::Integer
134
+
135
+ def _4g_gnd_quality?
136
+ Types::WirelessLinkQuality.valid?(_4g_gnd_quality)
137
+ end
138
+
139
+ # {"0":"Disconnected","1":"Connected"}
140
+ attribute? :_4g_link_state, Types::WirelessLinkState | Types::Integer
141
+
142
+ def _4g_link_connected?
143
+ _4g_link_state == Types::WIRELESS_LINK_CONNECTED
144
+ end
145
+
146
+ attribute? :_4g_quality, Types::WirelessLinkQuality | Types::Integer
147
+
148
+ def _4g_quality?
149
+ Types::WirelessLinkQuality.valid?(_4g_quality)
150
+ end
151
+
152
+ attribute? :_4g_uav_quality, Types::WirelessLinkQuality | Types::Integer
153
+
154
+ def _4g_uav_quality?
155
+ Types::WirelessLinkQuality.valid?(_4g_uav_quality)
156
+ end
157
+
134
158
  attribute? :dongle_number, Types::Integer
135
- attribute? :link_workmode, Types::Integer
159
+
160
+ # {"0":"SDR mode","1":"4G fusion mode"}
161
+ attribute? :link_workmode, Types::WirelessLinkWorkmode | Types::Integer
162
+
136
163
  attribute? :sdr_freq_band, Types::JSON::Decimal
137
- attribute? :sdr_link_state, Types::Integer
138
- attribute? :sdr_quality, Types::Integer
164
+
165
+ # {"0":"Disconnected","1":"Connected"}
166
+ attribute? :sdr_link_state, Types::WirelessLinkState | Types::Integer
167
+
168
+ def sdr_link_connected?
169
+ sdr_link_state == Types::WIRELESS_LINK_CONNECTED
170
+ end
171
+
172
+ attribute? :sdr_quality, Types::WirelessLinkQuality | Types::Integer
173
+
174
+ def sdr_quality?
175
+ Types::WirelessLinkQuality.valid?(sdr_quality)
176
+ end
177
+
139
178
  attribute? :sdr_relay_gnd_link_state, Types::Integer
140
179
  attribute? :sdr_relay_gnd_quality, Types::Integer
141
180
  attribute? :sdr_relay_uav_link_state, Types::Integer
@@ -9,14 +9,22 @@ module DjiMqttConnect
9
9
 
10
10
  def humanized_quality
11
11
  quality_key = case quality
12
+ when Types::NETWORK_STATE_QUALITY_NO_SIGNAL
13
+ "No signal"
12
14
  when Types::NETWORK_STATE_QUALITY_BAD
13
15
  "Bad"
14
- when Types::NETWORK_STATE_QUALITY_MODERATE
15
- "Moderate"
16
+ when Types::NETWORK_STATE_QUALITY_POOR
17
+ "Poor"
18
+ when Types::NETWORK_STATE_QUALITY_FAIR
19
+ "Fair"
16
20
  when Types::NETWORK_STATE_QUALITY_GOOD
17
21
  "Good"
22
+ when Types::NETWORK_STATE_QUALITY_EXCELLENT
23
+ "Excellent"
18
24
  end
19
- I18n.t(quality_key.downcase, scope: "dji_mqtt_connect.dock_network_state.quality", default: quality_key)
25
+ return if quality_key.nil?
26
+
27
+ I18n.t(quality_key.parameterize.underscore, scope: "dji_mqtt_connect.dock_network_state.quality", default: quality_key)
20
28
  end
21
29
  end
22
30
  end
@@ -3,6 +3,10 @@
3
3
  module DjiMqttConnect
4
4
  module Mixins
5
5
  module NetworkStateType
6
+ def type?
7
+ Types::NetworkStateType.valid?(type)
8
+ end
9
+
6
10
  def humanized_type
7
11
  type_key = case type
8
12
  when Types::NETWORK_STATE_TYPE_4G
@@ -10,6 +14,8 @@ module DjiMqttConnect
10
14
  when Types::NETWORK_STATE_TYPE_ETHERNET
11
15
  "Ethernet"
12
16
  end
17
+ return if type_key.nil?
18
+
13
19
  I18n.t(type_key.downcase, scope: "dji_mqtt_connect.dock_network_state.type", default: type_key)
14
20
  end
15
21
  end
@@ -124,6 +124,23 @@ module DjiMqttConnect
124
124
  AREA_LIMIT_REACHED = 1
125
125
  )
126
126
 
127
+ # {"0":"Disconnected","1":"Connected"}
128
+ WirelessLinkState = Types::Integer.enum(
129
+ WIRELESS_LINK_DISCONNECTED = 0,
130
+ WIRELESS_LINK_CONNECTED = 1
131
+ )
132
+
133
+ # {"min":"0","max":"5"}
134
+ WIRELESS_LINK_QUALITY_MIN = 0
135
+ WIRELESS_LINK_QUALITY_MAX = 5
136
+ WirelessLinkQuality = Types::Integer.constrained(gteq: WIRELESS_LINK_QUALITY_MIN, lteq: WIRELESS_LINK_QUALITY_MAX)
137
+
138
+ # {"0":"SDR mode","1":"4G fusion mode"}
139
+ WirelessLinkWorkmode = Types::Integer.enum(
140
+ WIRELESS_LINK_WORKMODE_SDR = 0,
141
+ WIRELESS_LINK_WORKMODE_4G_FUSION = 1
142
+ )
143
+
127
144
  # {"max":"1500","min":"20","unit_name":"Meters / m"}
128
145
  HEIGHT_LIMIT_MIN = 20
129
146
  HEIGHT_LIMIT_MAX = 1500
@@ -456,15 +473,20 @@ module DjiMqttConnect
456
473
  "upgrading_prevent_reboot"
457
474
  )
458
475
 
476
+ # {"1":"4G","2":"Ethernet"}
459
477
  NetworkStateType = Integer.enum(
460
478
  NETWORK_STATE_TYPE_4G = 1,
461
479
  NETWORK_STATE_TYPE_ETHERNET = 2
462
480
  )
463
481
 
482
+ # {"0":"No signal","1":"Bad","2":"Poor","3":"Fair","4":"Good","5":"Excellent"}
464
483
  NetworkStateQuality = Integer.enum(
465
- NETWORK_STATE_QUALITY_BAD = 0,
466
- NETWORK_STATE_QUALITY_MODERATE = 1,
467
- NETWORK_STATE_QUALITY_GOOD = 2
484
+ NETWORK_STATE_QUALITY_NO_SIGNAL = 0,
485
+ NETWORK_STATE_QUALITY_BAD = 1,
486
+ NETWORK_STATE_QUALITY_POOR = 2,
487
+ NETWORK_STATE_QUALITY_FAIR = 3,
488
+ NETWORK_STATE_QUALITY_GOOD = 4,
489
+ NETWORK_STATE_QUALITY_EXCELLENT = 5
468
490
  )
469
491
 
470
492
  # Enumeration of camera payload and mounted location. Non-standard device_mode_key, formatted as {type-subtype-gimbalindex}.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DjiMqttConnect
4
- VERSION = "0.1.39"
4
+ VERSION = "0.1.40"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dji_mqtt_connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.39
4
+ version: 0.1.40
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sphere Drones