dji_mqtt_connect 0.1.22.2 → 0.1.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/dji_mqtt_connect/client.rb +5 -0
- data/lib/dji_mqtt_connect/factories/state_messages.rb +390 -0
- data/lib/dji_mqtt_connect/factories.rb +5 -81
- data/lib/dji_mqtt_connect/marshals/thing/product/state_reply_marshal.rb +34 -0
- data/lib/dji_mqtt_connect/messages/thing/product/state_message.rb +70 -0
- data/lib/dji_mqtt_connect/messages/thing/product/state_reply_message.rb +29 -0
- data/lib/dji_mqtt_connect/topics/thing/product/events.rb +3 -0
- data/lib/dji_mqtt_connect/topics/thing/product/osd.rb +7 -4
- data/lib/dji_mqtt_connect/topics/thing/product/requests.rb +3 -0
- data/lib/dji_mqtt_connect/topics/thing/product/services_reply.rb +3 -0
- data/lib/dji_mqtt_connect/topics/thing/product/state.rb +5 -5
- data/lib/dji_mqtt_connect/topics/thing/product/state_reply.rb +16 -0
- data/lib/dji_mqtt_connect/version.rb +1 -1
- data/lib/dji_mqtt_connect.rb +3 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d41d271b698a961d6df9e07d3685c002559ef4fd7584ccc34a27ed80f003fb7
|
4
|
+
data.tar.gz: 710151bc2df812d86e19c1b971be1f13e308f8cff214c19ce4411218abdc6e33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '040780116df09cd20a201ce19558ccf63c939d6762bf405645b05f56866f89e6b77fde96ae491d4f2a181cae5350117b5af6e1343638e8515f621191d8c04eea'
|
7
|
+
data.tar.gz: 3b8898e3ce6ed6285449421b8f8ad14bc157b8dd534d632ebd9cedafd2cd3c451c6dda29bc13b39e041af65b498801229ee31a52556bd7fb334daa8b430d794f
|
data/Gemfile.lock
CHANGED
@@ -81,6 +81,11 @@ module DjiMqttConnect
|
|
81
81
|
Thing::Product::StateTopicRepository.new(self)
|
82
82
|
end
|
83
83
|
|
84
|
+
# Handles topic thing/product/#{pid}/state_reply
|
85
|
+
def thing_product_state_reply_topic
|
86
|
+
Thing::Product::StateReplyTopicRepository.new(self)
|
87
|
+
end
|
88
|
+
|
84
89
|
attr_reader :mqtt_client
|
85
90
|
end
|
86
91
|
end
|
@@ -0,0 +1,390 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DjiMqttConnect
|
4
|
+
module Factories::StateMessages
|
5
|
+
### Gateway Messages ###
|
6
|
+
|
7
|
+
def build_thing_product_gateway_live_capacity_state_message
|
8
|
+
message_data = {
|
9
|
+
live_capacity: {
|
10
|
+
available_video_number: 3,
|
11
|
+
coexist_video_number_max: 2,
|
12
|
+
device_list: [
|
13
|
+
{
|
14
|
+
sn: "DOCK01",
|
15
|
+
available_video_number: 1,
|
16
|
+
coexist_video_number_max: 1,
|
17
|
+
camera_list: [
|
18
|
+
{
|
19
|
+
camera_index: "165-0-7",
|
20
|
+
available_video_number: 1,
|
21
|
+
coexist_video_number_max: 1,
|
22
|
+
video_list: [
|
23
|
+
{
|
24
|
+
video_index: "normal-0",
|
25
|
+
video_type: "normal",
|
26
|
+
switchable_video_types: [
|
27
|
+
"normal"
|
28
|
+
]
|
29
|
+
}
|
30
|
+
]
|
31
|
+
}
|
32
|
+
]
|
33
|
+
},
|
34
|
+
{
|
35
|
+
sn: "DRONE01",
|
36
|
+
available_video_number: 2,
|
37
|
+
coexist_video_number_max: 2,
|
38
|
+
camera_list: [
|
39
|
+
{
|
40
|
+
camera_index: "39-0-7",
|
41
|
+
available_video_number: 1,
|
42
|
+
coexist_video_number_max: 1,
|
43
|
+
video_list: [
|
44
|
+
{
|
45
|
+
video_index: "normal-0",
|
46
|
+
video_type: "normal",
|
47
|
+
switchable_video_types: [
|
48
|
+
"normal"
|
49
|
+
]
|
50
|
+
}
|
51
|
+
]
|
52
|
+
},
|
53
|
+
{
|
54
|
+
camera_index: "52-0-0",
|
55
|
+
available_video_number: 1,
|
56
|
+
coexist_video_number_max: 1,
|
57
|
+
video_list: [
|
58
|
+
{
|
59
|
+
video_index: "normal-0",
|
60
|
+
video_type: "wide",
|
61
|
+
switchable_video_types: [
|
62
|
+
"wide",
|
63
|
+
"zoom",
|
64
|
+
"ir"
|
65
|
+
]
|
66
|
+
}
|
67
|
+
]
|
68
|
+
}
|
69
|
+
]
|
70
|
+
}
|
71
|
+
]
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
Thing::Product::StateMessage.new(
|
76
|
+
bid: Message.generate_bid,
|
77
|
+
tid: Message.generate_tid,
|
78
|
+
timestamp: Message.current_timestamp,
|
79
|
+
gateway: "GATEWAYSN",
|
80
|
+
_data: message_data,
|
81
|
+
data: message_data
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
def build_thing_product_gateway_live_status_state_message
|
86
|
+
message_data = {
|
87
|
+
|
88
|
+
live_status: [
|
89
|
+
{
|
90
|
+
video_id: "1581F6QAD242M00BD78G/80-0-0/normal-0",
|
91
|
+
video_type: "wide",
|
92
|
+
video_quality: 0,
|
93
|
+
status: 1,
|
94
|
+
error_status: 0
|
95
|
+
},
|
96
|
+
{
|
97
|
+
video_id: "7CTDM2100BQ58L/165-0-7/normal-0",
|
98
|
+
video_type: "normal",
|
99
|
+
video_quality: 0,
|
100
|
+
status: 1,
|
101
|
+
error_status: 0
|
102
|
+
}
|
103
|
+
]
|
104
|
+
}
|
105
|
+
|
106
|
+
Thing::Product::StateMessage.new(
|
107
|
+
bid: Message.generate_bid,
|
108
|
+
tid: Message.generate_tid,
|
109
|
+
timestamp: Message.current_timestamp,
|
110
|
+
gateway: "GATEWAYSN",
|
111
|
+
_data: message_data,
|
112
|
+
data: message_data
|
113
|
+
)
|
114
|
+
end
|
115
|
+
|
116
|
+
def build_thing_product_gateway_rtcm_info_state_message
|
117
|
+
message_data = {
|
118
|
+
rtcm_info: {
|
119
|
+
host: "192.168.0.1",
|
120
|
+
mount_point: "RTCM3X",
|
121
|
+
port: "2101",
|
122
|
+
rtcm_device_type: 1,
|
123
|
+
source_type: 3
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
Thing::Product::StateMessage.new(
|
128
|
+
bid: Message.generate_bid,
|
129
|
+
tid: Message.generate_tid,
|
130
|
+
timestamp: Message.current_timestamp,
|
131
|
+
gateway: "GATEWAYSN",
|
132
|
+
_data: message_data,
|
133
|
+
data: message_data
|
134
|
+
)
|
135
|
+
end
|
136
|
+
|
137
|
+
### Payload Messages ###
|
138
|
+
|
139
|
+
def build_thing_product_payload_ar_info_switch_state_message
|
140
|
+
message_data = {
|
141
|
+
ar_info_switch: 1
|
142
|
+
}
|
143
|
+
|
144
|
+
Thing::Product::StateMessage.new(
|
145
|
+
bid: Message.generate_bid,
|
146
|
+
tid: Message.generate_tid,
|
147
|
+
timestamp: Message.current_timestamp,
|
148
|
+
gateway: "GATEWAYSN",
|
149
|
+
_data: message_data,
|
150
|
+
data: message_data
|
151
|
+
)
|
152
|
+
end
|
153
|
+
|
154
|
+
def build_thing_product_payload_commander_flight_height_state_message
|
155
|
+
message_data = {
|
156
|
+
commander_flight_height: 50
|
157
|
+
}
|
158
|
+
|
159
|
+
Thing::Product::StateMessage.new(
|
160
|
+
bid: Message.generate_bid,
|
161
|
+
tid: Message.generate_tid,
|
162
|
+
timestamp: Message.current_timestamp,
|
163
|
+
gateway: "GATEWAYSN",
|
164
|
+
_data: message_data,
|
165
|
+
data: message_data
|
166
|
+
)
|
167
|
+
end
|
168
|
+
|
169
|
+
def build_thing_product_payload_commander_flight_mode_state_message
|
170
|
+
message_data = {
|
171
|
+
commander_flight_mode: 0
|
172
|
+
}
|
173
|
+
|
174
|
+
Thing::Product::StateMessage.new(
|
175
|
+
bid: Message.generate_bid,
|
176
|
+
tid: Message.generate_tid,
|
177
|
+
timestamp: Message.current_timestamp,
|
178
|
+
gateway: "GATEWAYSN",
|
179
|
+
_data: message_data,
|
180
|
+
data: message_data
|
181
|
+
)
|
182
|
+
end
|
183
|
+
|
184
|
+
def build_thing_product_payload_commander_mode_lost_action_state_message
|
185
|
+
message_data = {
|
186
|
+
commander_mode_lost_action: 1
|
187
|
+
}
|
188
|
+
|
189
|
+
Thing::Product::StateMessage.new(
|
190
|
+
bid: Message.generate_bid,
|
191
|
+
tid: Message.generate_tid,
|
192
|
+
timestamp: Message.current_timestamp,
|
193
|
+
gateway: "GATEWAYSN",
|
194
|
+
_data: message_data,
|
195
|
+
data: message_data
|
196
|
+
)
|
197
|
+
end
|
198
|
+
|
199
|
+
def build_thing_product_payload_current_commander_flight_mode_state_message
|
200
|
+
message_data = {
|
201
|
+
current_commander_flight_mode: 0
|
202
|
+
}
|
203
|
+
|
204
|
+
Thing::Product::StateMessage.new(
|
205
|
+
bid: Message.generate_bid,
|
206
|
+
tid: Message.generate_tid,
|
207
|
+
timestamp: Message.current_timestamp,
|
208
|
+
gateway: "GATEWAYSN",
|
209
|
+
_data: message_data,
|
210
|
+
data: message_data
|
211
|
+
)
|
212
|
+
end
|
213
|
+
|
214
|
+
def build_thing_proudct_current_rth_mode_state_message
|
215
|
+
message_data = {
|
216
|
+
current_rth_mode: 1
|
217
|
+
}
|
218
|
+
|
219
|
+
Thing::Product::StateMessage.new(
|
220
|
+
bid: Message.generate_bid,
|
221
|
+
tid: Message.generate_tid,
|
222
|
+
timestamp: Message.current_timestamp,
|
223
|
+
gateway: "GATEWAYSN",
|
224
|
+
_data: message_data,
|
225
|
+
data: message_data
|
226
|
+
)
|
227
|
+
end
|
228
|
+
|
229
|
+
def build_thing_product_payload_flysafe_database_version_state_message
|
230
|
+
message_data = {
|
231
|
+
flysafe_database_version: "01.00.01.35"
|
232
|
+
}
|
233
|
+
|
234
|
+
Thing::Product::StateMessage.new(
|
235
|
+
bid: Message.generate_bid,
|
236
|
+
tid: Message.generate_tid,
|
237
|
+
timestamp: Message.current_timestamp,
|
238
|
+
gateway: "GATEWAYSN",
|
239
|
+
_data: message_data,
|
240
|
+
data: message_data
|
241
|
+
)
|
242
|
+
end
|
243
|
+
|
244
|
+
def build_thing_product_payload_geo_caging_status_state_message
|
245
|
+
message_data = {
|
246
|
+
geo_caging_status: {
|
247
|
+
state: 0
|
248
|
+
}
|
249
|
+
}
|
250
|
+
|
251
|
+
Thing::Product::StateMessage.new(
|
252
|
+
bid: Message.generate_bid,
|
253
|
+
tid: Message.generate_tid,
|
254
|
+
timestamp: Message.current_timestamp,
|
255
|
+
gateway: "GATEWAYSN",
|
256
|
+
_data: message_data,
|
257
|
+
data: message_data
|
258
|
+
)
|
259
|
+
end
|
260
|
+
|
261
|
+
def build_thing_product_payload_mode_code_reason_state_message
|
262
|
+
message_data = {
|
263
|
+
mode_code_reason: 0
|
264
|
+
}
|
265
|
+
|
266
|
+
Thing::Product::StateMessage.new(
|
267
|
+
bid: Message.generate_bid,
|
268
|
+
tid: Message.generate_tid,
|
269
|
+
timestamp: Message.current_timestamp,
|
270
|
+
gateway: "GATEWAYSN",
|
271
|
+
_data: message_data,
|
272
|
+
data: message_data
|
273
|
+
)
|
274
|
+
end
|
275
|
+
|
276
|
+
def build_thing_product_payload_offline_map_enable_state_message
|
277
|
+
message_data = {
|
278
|
+
offline_map_enable: true
|
279
|
+
}
|
280
|
+
|
281
|
+
Thing::Product::StateMessage.new(
|
282
|
+
bid: Message.generate_bid,
|
283
|
+
tid: Message.generate_tid,
|
284
|
+
timestamp: Message.current_timestamp,
|
285
|
+
gateway: "GATEWAYSN",
|
286
|
+
_data: message_data,
|
287
|
+
data: message_data
|
288
|
+
)
|
289
|
+
end
|
290
|
+
|
291
|
+
def build_thing_product_payload_payloads_state_message
|
292
|
+
message_data = {
|
293
|
+
payloads: [
|
294
|
+
{
|
295
|
+
control_source: "A",
|
296
|
+
payload_index: "80-0-0"
|
297
|
+
}
|
298
|
+
]
|
299
|
+
}
|
300
|
+
|
301
|
+
Thing::Product::StateMessage.new(
|
302
|
+
bid: Message.generate_bid,
|
303
|
+
tid: Message.generate_tid,
|
304
|
+
timestamp: Message.current_timestamp,
|
305
|
+
gateway: "GATEWAYSN",
|
306
|
+
_data: message_data,
|
307
|
+
data: message_data
|
308
|
+
)
|
309
|
+
end
|
310
|
+
|
311
|
+
def build_thing_proudct_rth_mode_state_message
|
312
|
+
message_data = {
|
313
|
+
rth_mode: 1
|
314
|
+
}
|
315
|
+
|
316
|
+
Thing::Product::StateMessage.new(
|
317
|
+
bid: Message.generate_bid,
|
318
|
+
tid: Message.generate_tid,
|
319
|
+
timestamp: Message.current_timestamp,
|
320
|
+
gateway: "GATEWAYSN",
|
321
|
+
_data: message_data,
|
322
|
+
data: message_data
|
323
|
+
)
|
324
|
+
end
|
325
|
+
|
326
|
+
def build_thing_product_payload_uom_real_name_state_state_message
|
327
|
+
message_data = {
|
328
|
+
uom_real_name_state: 11
|
329
|
+
}
|
330
|
+
|
331
|
+
Thing::Product::StateMessage.new(
|
332
|
+
bid: Message.generate_bid,
|
333
|
+
tid: Message.generate_tid,
|
334
|
+
timestamp: Message.current_timestamp,
|
335
|
+
gateway: "GATEWAYSN",
|
336
|
+
_data: message_data,
|
337
|
+
data: message_data
|
338
|
+
)
|
339
|
+
end
|
340
|
+
|
341
|
+
def build_thing_product_payload_wireless_link_topo_state_message
|
342
|
+
message_data = {
|
343
|
+
wireless_link_topo: {
|
344
|
+
center_node: {
|
345
|
+
sdr_id: 836770082,
|
346
|
+
sn: "WIRELESSLINK01"
|
347
|
+
},
|
348
|
+
leaf_nodes: [{
|
349
|
+
control_source_index: 1,
|
350
|
+
sdr_id: 961551644,
|
351
|
+
sn: "LEAFNODE01",
|
352
|
+
|
353
|
+
valid: true
|
354
|
+
}, {
|
355
|
+
control_source_index: 2,
|
356
|
+
sdr_id: 878711578,
|
357
|
+
sn: "LEAFNODE02",
|
358
|
+
valid: true
|
359
|
+
}],
|
360
|
+
secret_code: [0, 0, 0, 0, 1, 0, 0, 0, 126, 180, 137, 135, 192, 229, 237, 97, 34, 58, 71, 58, 139, 30, 218, 120, 160, 254, 117, 250]
|
361
|
+
}
|
362
|
+
}
|
363
|
+
|
364
|
+
Thing::Product::StateMessage.new(
|
365
|
+
bid: Message.generate_bid,
|
366
|
+
tid: Message.generate_tid,
|
367
|
+
timestamp: Message.current_timestamp,
|
368
|
+
gateway: "GATEWAYSN",
|
369
|
+
need_reply: 1,
|
370
|
+
_data: message_data,
|
371
|
+
data: message_data
|
372
|
+
)
|
373
|
+
end
|
374
|
+
|
375
|
+
def build_thing_product_payload_wpmz_version_state_message
|
376
|
+
message_data = {
|
377
|
+
wpmz_version: "1.0.6"
|
378
|
+
}
|
379
|
+
|
380
|
+
Thing::Product::StateMessage.new(
|
381
|
+
bid: Message.generate_bid,
|
382
|
+
tid: Message.generate_tid,
|
383
|
+
timestamp: Message.current_timestamp,
|
384
|
+
gateway: "GATEWAYSN",
|
385
|
+
_data: message_data,
|
386
|
+
data: message_data
|
387
|
+
)
|
388
|
+
end
|
389
|
+
end
|
390
|
+
end
|
@@ -4,6 +4,10 @@ module DjiMqttConnect
|
|
4
4
|
# Factories for building example messages
|
5
5
|
# Do not include this in your production code
|
6
6
|
module Factories
|
7
|
+
autoload :StateMessages, "dji_mqtt_connect/factories/state_messages"
|
8
|
+
|
9
|
+
include StateMessages
|
10
|
+
|
7
11
|
# Events
|
8
12
|
|
9
13
|
def build_device_exit_homing_notify_events_message
|
@@ -17,7 +21,7 @@ module DjiMqttConnect
|
|
17
21
|
bid: Message.generate_bid,
|
18
22
|
tid: Message.generate_tid,
|
19
23
|
need_reply: 1,
|
20
|
-
gateway: "
|
24
|
+
gateway: "GATEWAYSN",
|
21
25
|
timestamp: Message.current_timestamp,
|
22
26
|
data: message_data,
|
23
27
|
_data: message_data
|
@@ -1166,85 +1170,5 @@ module DjiMqttConnect
|
|
1166
1170
|
data: message_data
|
1167
1171
|
)
|
1168
1172
|
end
|
1169
|
-
|
1170
|
-
### State Messages ###
|
1171
|
-
|
1172
|
-
def build_thing_product_live_capacity_state_message
|
1173
|
-
message_data = {
|
1174
|
-
live_capacity: {
|
1175
|
-
available_video_number: 3,
|
1176
|
-
coexist_video_number_max: 2,
|
1177
|
-
device_list: [
|
1178
|
-
{
|
1179
|
-
sn: "DOCK01",
|
1180
|
-
available_video_number: 1,
|
1181
|
-
coexist_video_number_max: 1,
|
1182
|
-
camera_list: [
|
1183
|
-
{
|
1184
|
-
camera_index: "165-0-7",
|
1185
|
-
available_video_number: 1,
|
1186
|
-
coexist_video_number_max: 1,
|
1187
|
-
video_list: [
|
1188
|
-
{
|
1189
|
-
video_index: "normal-0",
|
1190
|
-
video_type: "normal",
|
1191
|
-
switchable_video_types: [
|
1192
|
-
"normal"
|
1193
|
-
]
|
1194
|
-
}
|
1195
|
-
]
|
1196
|
-
}
|
1197
|
-
]
|
1198
|
-
},
|
1199
|
-
{
|
1200
|
-
sn: "DRONE01",
|
1201
|
-
available_video_number: 2,
|
1202
|
-
coexist_video_number_max: 2,
|
1203
|
-
camera_list: [
|
1204
|
-
{
|
1205
|
-
camera_index: "39-0-7",
|
1206
|
-
available_video_number: 1,
|
1207
|
-
coexist_video_number_max: 1,
|
1208
|
-
video_list: [
|
1209
|
-
{
|
1210
|
-
video_index: "normal-0",
|
1211
|
-
video_type: "normal",
|
1212
|
-
switchable_video_types: [
|
1213
|
-
"normal"
|
1214
|
-
]
|
1215
|
-
}
|
1216
|
-
]
|
1217
|
-
},
|
1218
|
-
{
|
1219
|
-
camera_index: "52-0-0",
|
1220
|
-
available_video_number: 1,
|
1221
|
-
coexist_video_number_max: 1,
|
1222
|
-
video_list: [
|
1223
|
-
{
|
1224
|
-
video_index: "normal-0",
|
1225
|
-
video_type: "wide",
|
1226
|
-
switchable_video_types: [
|
1227
|
-
"wide",
|
1228
|
-
"zoom",
|
1229
|
-
"ir"
|
1230
|
-
]
|
1231
|
-
}
|
1232
|
-
]
|
1233
|
-
}
|
1234
|
-
]
|
1235
|
-
}
|
1236
|
-
]
|
1237
|
-
}
|
1238
|
-
}
|
1239
|
-
|
1240
|
-
Thing::Product::StateMessage.new(
|
1241
|
-
bid: Message.generate_bid,
|
1242
|
-
tid: Message.generate_tid,
|
1243
|
-
timestamp: Message.current_timestamp,
|
1244
|
-
gateway: "GATEWAY01",
|
1245
|
-
_data: message_data,
|
1246
|
-
data: message_data
|
1247
|
-
)
|
1248
|
-
end
|
1249
1173
|
end
|
1250
1174
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "dry-transformer"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module DjiMqttConnect
|
7
|
+
module Thing::Product
|
8
|
+
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
|
17
|
+
|
18
|
+
# Converts a message for transmission via MQTT
|
19
|
+
def dump(message)
|
20
|
+
# Fix up the hash representation
|
21
|
+
transformed_message = hash_transformer.call(message)
|
22
|
+
|
23
|
+
# Convert the transformed message into JSON
|
24
|
+
JSON.generate(transformed_message)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def hash_transformer
|
30
|
+
@hash_transformer ||= HashTransformer.new
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -82,7 +82,18 @@ module DjiMqttConnect
|
|
82
82
|
|
83
83
|
attribute :_data, Types::Hash
|
84
84
|
|
85
|
+
# NOTE: Included in some state messages, requires a reply on the state_reply topic if true
|
86
|
+
attribute? :need_reply, Types::Integer.enum(0, 1)
|
87
|
+
|
88
|
+
def need_reply?
|
89
|
+
need_reply == 1
|
90
|
+
end
|
91
|
+
|
85
92
|
attribute :data do
|
93
|
+
attribute? :geo_caging_status do
|
94
|
+
attribute :state, Types::Integer
|
95
|
+
end
|
96
|
+
|
86
97
|
# Not all messages will have a live_capacity attribute
|
87
98
|
attribute? :live_capacity do
|
88
99
|
attribute :available_video_number, Types::Integer
|
@@ -103,6 +114,65 @@ module DjiMqttConnect
|
|
103
114
|
end
|
104
115
|
end
|
105
116
|
end
|
117
|
+
|
118
|
+
attribute? :live_status, Types::Array do
|
119
|
+
attribute :video_id, Types::String
|
120
|
+
attribute :video_type, Types::String
|
121
|
+
attribute :video_quality, Types::Integer
|
122
|
+
attribute :status, Types::Integer
|
123
|
+
attribute :error_status, Types::Integer
|
124
|
+
end
|
125
|
+
|
126
|
+
attribute? :payloads, Types::Array do
|
127
|
+
attribute :control_source, Types::String
|
128
|
+
attribute? :firmware_version, Types::String
|
129
|
+
attribute :payload_index, Types::String
|
130
|
+
attribute? :sn, Types::String
|
131
|
+
end
|
132
|
+
|
133
|
+
attribute? :rtcm_info do
|
134
|
+
attribute :host, Types::String
|
135
|
+
attribute :mount_point, Types::String
|
136
|
+
attribute :port, Types::String
|
137
|
+
attribute :rtcm_device_type, Types::Integer
|
138
|
+
attribute :source_type, Types::Integer
|
139
|
+
end
|
140
|
+
|
141
|
+
attribute? :wireless_link_topo do
|
142
|
+
attribute :center_node do
|
143
|
+
attribute :sdr_id, Types::Integer
|
144
|
+
attribute :sn, Types::String
|
145
|
+
end
|
146
|
+
|
147
|
+
attribute :leaf_nodes, Types::Array do
|
148
|
+
attribute :control_source_index, Types::Integer
|
149
|
+
attribute :sdr_id, Types::Integer
|
150
|
+
attribute :sn, Types::String
|
151
|
+
attribute :valid, Types::Bool
|
152
|
+
end
|
153
|
+
|
154
|
+
attribute :secret_code, Types::Array.of(Types::Integer)
|
155
|
+
end
|
156
|
+
|
157
|
+
attribute? :ar_info_switch, Types::Integer
|
158
|
+
attribute? :commander_flight_height, Types::Integer
|
159
|
+
attribute? :commander_flight_mode, Types::Integer
|
160
|
+
attribute? :commander_mode_lost_action, Types::Integer
|
161
|
+
attribute? :control_source, Types::String
|
162
|
+
attribute? :current_commander_flight_mode, Types::Integer
|
163
|
+
attribute? :current_rth_mode, Types::Integer
|
164
|
+
attribute? :flysafe_database_version, Types::String
|
165
|
+
attribute? :home_latitude, Types::Latitude
|
166
|
+
attribute? :home_longitude, Types::Longitude
|
167
|
+
attribute? :locked, Types::Bool
|
168
|
+
attribute? :mode_code_reason, Types::Integer
|
169
|
+
attribute? :offline_map_enable, Types::Bool
|
170
|
+
attribute? :rth_mode, Types::Integer
|
171
|
+
attribute? :uom_real_name_state, Types::Integer
|
172
|
+
attribute? :wpmz_version, Types::String
|
173
|
+
|
174
|
+
attribute? :low_battery_warning_threshold, Types::Integer
|
175
|
+
attribute? :serious_low_battery_warning_threshold, Types::Integer
|
106
176
|
end
|
107
177
|
end
|
108
178
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DjiMqttConnect
|
4
|
+
module Thing::Product
|
5
|
+
class StateReplyMessage < Message
|
6
|
+
# a result of 0 means we approve of this action
|
7
|
+
def self.build_for(events_message, result: 0)
|
8
|
+
new(
|
9
|
+
tid: events_message.tid,
|
10
|
+
bid: events_message.bid,
|
11
|
+
timestamp: current_timestamp,
|
12
|
+
data: {
|
13
|
+
result: result
|
14
|
+
}
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
attribute :bid, Types::UUID
|
19
|
+
attribute :tid, Types::UUID
|
20
|
+
attribute :timestamp, Types::Timestamp
|
21
|
+
|
22
|
+
attribute :data do
|
23
|
+
include Mixins::ResultMessage
|
24
|
+
|
25
|
+
attribute :result, Types::ResultCode
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -25,6 +25,9 @@ module DjiMqttConnect
|
|
25
25
|
event_name = message.class.name.demodulize.sub(/sMessage\z/, "").underscore.to_sym
|
26
26
|
broadcast(event_name, device_sn, message)
|
27
27
|
end
|
28
|
+
|
29
|
+
# Broadcast a generic received events message event
|
30
|
+
broadcast(:received_events_message, device_sn, message)
|
28
31
|
rescue ParseError => error
|
29
32
|
broadcast(:parse_error, error, topic, raw_message)
|
30
33
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module DjiMqttConnect
|
4
4
|
module Thing::Product
|
5
5
|
class OsdTopicRepository < TopicRepository
|
6
|
-
OSD_TOPIC_REGEX = /\Athing\/product\/(?<
|
6
|
+
OSD_TOPIC_REGEX = /\Athing\/product\/(?<device_sn>.+)\/osd\z/
|
7
7
|
|
8
8
|
def listen!
|
9
9
|
listen_to_topic("thing/product/+/osd") do |topic, raw_message|
|
@@ -12,10 +12,10 @@ module DjiMqttConnect
|
|
12
12
|
matched_topic = OSD_TOPIC_REGEX.match(topic)
|
13
13
|
raise Error, "Unknown topic: #{topic}" unless matched_topic
|
14
14
|
|
15
|
-
|
15
|
+
device_sn = matched_topic[:device_sn]
|
16
16
|
message = OsdMarshal.load(raw_message)
|
17
17
|
|
18
|
-
logger.info("Received #{message} from #{
|
18
|
+
logger.info("Received #{message} from #{device_sn}")
|
19
19
|
|
20
20
|
if message.instance_of?(OsdMessage)
|
21
21
|
# Broadcast an unsupported message event
|
@@ -23,8 +23,11 @@ module DjiMqttConnect
|
|
23
23
|
else
|
24
24
|
# Build event name and broadcast (i.e. ::RemoteOsdMessage => remote_osd_update)
|
25
25
|
event_name = message.class.name.demodulize.sub(/Message\z/, "Update").underscore.to_sym
|
26
|
-
broadcast(event_name,
|
26
|
+
broadcast(event_name, device_sn, message)
|
27
27
|
end
|
28
|
+
|
29
|
+
# Broadcast a generic received osd message event
|
30
|
+
broadcast(:received_osd_message, device_sn, message)
|
28
31
|
rescue ParseError => error
|
29
32
|
broadcast(:parse_error, error, topic, raw_message)
|
30
33
|
end
|
@@ -24,6 +24,9 @@ module DjiMqttConnect
|
|
24
24
|
# Build event name and broadcast (i.e. ::ConfigRequestsMessage => config)
|
25
25
|
broadcast(message._method.to_sym, gateway_sn, message)
|
26
26
|
end
|
27
|
+
|
28
|
+
# Broadcast a generic received requests message event
|
29
|
+
broadcast(:received_requests_message, gateway_sn, message)
|
27
30
|
rescue ParseError => error
|
28
31
|
broadcast(:parse_error, error, topic, raw_message)
|
29
32
|
end
|
@@ -25,6 +25,9 @@ module DjiMqttConnect
|
|
25
25
|
event_name = "#{message._method.to_sym}_reply"
|
26
26
|
broadcast(event_name, gateway_sn, message)
|
27
27
|
end
|
28
|
+
|
29
|
+
# Broadcast a generic received services reply message event
|
30
|
+
broadcast(:received_services_reply_message, gateway_sn, message)
|
28
31
|
rescue ParseError => error
|
29
32
|
broadcast(:parse_error, error, topic, raw_message)
|
30
33
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module DjiMqttConnect
|
4
4
|
module Thing::Product
|
5
5
|
class StateTopicRepository < TopicRepository
|
6
|
-
STATE_TOPIC_REGEX = /\Athing\/product\/(?<
|
6
|
+
STATE_TOPIC_REGEX = /\Athing\/product\/(?<device_sn>.+)\/state\z/
|
7
7
|
|
8
8
|
def listen!
|
9
9
|
listen_to_topic("thing/product/+/state") do |topic, raw_message|
|
@@ -12,13 +12,13 @@ module DjiMqttConnect
|
|
12
12
|
matched_topic = STATE_TOPIC_REGEX.match(topic)
|
13
13
|
raise Error, "Unknown topic: #{topic}" unless matched_topic
|
14
14
|
|
15
|
-
|
15
|
+
device_sn = matched_topic[:device_sn]
|
16
16
|
message = state_marshal.load(raw_message)
|
17
17
|
|
18
|
-
logger.info("Received #{message} from #{
|
18
|
+
logger.info("Received #{message} from #{device_sn}")
|
19
19
|
|
20
|
-
# Broadcast
|
21
|
-
broadcast(:
|
20
|
+
# Broadcast a generic received state message event
|
21
|
+
broadcast(:received_state_message, device_sn, message)
|
22
22
|
rescue ParseError => error
|
23
23
|
broadcast(:parse_error, error, topic, raw_message)
|
24
24
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DjiMqttConnect
|
4
|
+
module Thing::Product
|
5
|
+
class StateReplyTopicRepository < TopicRepository
|
6
|
+
# Publishes a message to gateway_sn on the "thing/product/+/state_reply" topic.
|
7
|
+
def publish_to_device(gateway_sn, state_reply_message)
|
8
|
+
publish_to_topic(
|
9
|
+
"thing/product/#{gateway_sn}/state_reply",
|
10
|
+
state_reply_message,
|
11
|
+
marshal: StateReplyMarshal
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/dji_mqtt_connect.rb
CHANGED
@@ -119,6 +119,7 @@ module DjiMqttConnect
|
|
119
119
|
autoload :ReturnHomeCancelServicesReplyMessage, "dji_mqtt_connect/messages/thing/product/services_reply/return_home_cancel"
|
120
120
|
|
121
121
|
autoload :StateMessage, "dji_mqtt_connect/messages/thing/product/state_message"
|
122
|
+
autoload :StateReplyMessage, "dji_mqtt_connect/messages/thing/product/state_reply_message"
|
122
123
|
|
123
124
|
# Topics
|
124
125
|
autoload :EventsTopicRepository, "dji_mqtt_connect/topics/thing/product/events"
|
@@ -129,6 +130,7 @@ module DjiMqttConnect
|
|
129
130
|
autoload :ServicesTopicRepository, "dji_mqtt_connect/topics/thing/product/services"
|
130
131
|
autoload :ServicesReplyTopicRepository, "dji_mqtt_connect/topics/thing/product/services_reply"
|
131
132
|
autoload :StateTopicRepository, "dji_mqtt_connect/topics/thing/product/state"
|
133
|
+
autoload :StateReplyTopicRepository, "dji_mqtt_connect/topics/thing/product/state_reply"
|
132
134
|
|
133
135
|
# Marshals
|
134
136
|
autoload :EventsMarshal, "dji_mqtt_connect/marshals/thing/product/events_marshal"
|
@@ -143,6 +145,7 @@ module DjiMqttConnect
|
|
143
145
|
autoload :ServicesReplyMarshal, "dji_mqtt_connect/marshals/thing/product/services_reply_marshal"
|
144
146
|
|
145
147
|
autoload :StateMarshal, "dji_mqtt_connect/marshals/thing/product/state_marshal"
|
148
|
+
autoload :StateReplyMarshal, "dji_mqtt_connect/marshals/thing/product/state_reply_marshal"
|
146
149
|
end
|
147
150
|
end
|
148
151
|
|
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.
|
4
|
+
version: 0.1.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sphere Drones
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -113,6 +113,7 @@ files:
|
|
113
113
|
- lib/dji_mqtt_connect/client.rb
|
114
114
|
- lib/dji_mqtt_connect/error.rb
|
115
115
|
- lib/dji_mqtt_connect/factories.rb
|
116
|
+
- lib/dji_mqtt_connect/factories/state_messages.rb
|
116
117
|
- lib/dji_mqtt_connect/marshals/sys/product/status_marshal.rb
|
117
118
|
- lib/dji_mqtt_connect/marshals/sys/product/status_reply_marshal.rb
|
118
119
|
- lib/dji_mqtt_connect/marshals/thing/product/events_marshal.rb
|
@@ -123,6 +124,7 @@ files:
|
|
123
124
|
- lib/dji_mqtt_connect/marshals/thing/product/services_marshal.rb
|
124
125
|
- lib/dji_mqtt_connect/marshals/thing/product/services_reply_marshal.rb
|
125
126
|
- lib/dji_mqtt_connect/marshals/thing/product/state_marshal.rb
|
127
|
+
- lib/dji_mqtt_connect/marshals/thing/product/state_reply_marshal.rb
|
126
128
|
- lib/dji_mqtt_connect/message.rb
|
127
129
|
- lib/dji_mqtt_connect/message_marshal.rb
|
128
130
|
- lib/dji_mqtt_connect/messages/sys/product/status/update_topo.rb
|
@@ -206,6 +208,7 @@ files:
|
|
206
208
|
- lib/dji_mqtt_connect/messages/thing/product/services_reply/return_home_cancel.rb
|
207
209
|
- lib/dji_mqtt_connect/messages/thing/product/services_reply_message.rb
|
208
210
|
- lib/dji_mqtt_connect/messages/thing/product/state_message.rb
|
211
|
+
- lib/dji_mqtt_connect/messages/thing/product/state_reply_message.rb
|
209
212
|
- lib/dji_mqtt_connect/mixins/events_progress_checks.rb
|
210
213
|
- lib/dji_mqtt_connect/mixins/latitude_conditional.rb
|
211
214
|
- lib/dji_mqtt_connect/mixins/longitude_conditional.rb
|
@@ -225,6 +228,7 @@ files:
|
|
225
228
|
- lib/dji_mqtt_connect/topics/thing/product/services.rb
|
226
229
|
- lib/dji_mqtt_connect/topics/thing/product/services_reply.rb
|
227
230
|
- lib/dji_mqtt_connect/topics/thing/product/state.rb
|
231
|
+
- lib/dji_mqtt_connect/topics/thing/product/state_reply.rb
|
228
232
|
- lib/dji_mqtt_connect/translations.rb
|
229
233
|
- lib/dji_mqtt_connect/types.rb
|
230
234
|
- lib/dji_mqtt_connect/utils/message_parsing.rb
|