dji_mqtt_connect 0.1.24.1 → 0.1.25
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 +4 -4
- data/Gemfile.lock +1 -1
- data/config/locales/flighttask_status.en.yml +136 -0
- data/config/locales/result_codes.en.yml +2 -0
- data/config/locales/sys_product_status.en.yml +4 -0
- data/config/locales/thing_product_events.en.yml +64 -0
- data/config/locales/thing_product_events_reply.en.yml +4 -0
- data/config/locales/thing_product_osd.en.yml +7 -0
- data/config/locales/thing_product_requests.en.yml +12 -0
- data/config/locales/thing_product_requests_reply.en.yml +14 -0
- data/config/locales/thing_product_services.en.yml +27 -0
- data/config/locales/thing_product_services_reply.en.yml +4 -0
- data/config/locales/thing_product_state.en.yml +4 -0
- data/config/locales/thing_product_state_reply.en.yml +3 -0
- data/config/locales/video_qualities.en.yml +8 -0
- data/config/locales/video_types.en.yml +7 -0
- data/lib/dji_mqtt_connect/factories/events_messages.rb +73 -14
- data/lib/dji_mqtt_connect/factories/services_messages.rb +190 -0
- data/lib/dji_mqtt_connect/factories/state_messages.rb +19 -19
- data/lib/dji_mqtt_connect/factories.rb +14 -176
- data/lib/dji_mqtt_connect/marshals/sys/product/status_reply_marshal.rb +2 -16
- data/lib/dji_mqtt_connect/marshals/thing/product/events_marshal.rb +11 -4
- data/lib/dji_mqtt_connect/marshals/thing/product/events_reply_marshal.rb +2 -16
- data/lib/dji_mqtt_connect/marshals/thing/product/osd_marshal.rb +4 -4
- data/lib/dji_mqtt_connect/marshals/thing/product/requests_marshal.rb +4 -4
- data/lib/dji_mqtt_connect/marshals/thing/product/requests_reply_marshal.rb +2 -16
- data/lib/dji_mqtt_connect/marshals/thing/product/services_marshal.rb +2 -16
- data/lib/dji_mqtt_connect/marshals/thing/product/services_reply_marshal.rb +4 -4
- data/lib/dji_mqtt_connect/marshals/thing/product/state_marshal.rb +4 -4
- data/lib/dji_mqtt_connect/marshals/thing/product/state_reply_marshal.rb +2 -16
- data/lib/dji_mqtt_connect/messages/sys/product/status/update_topo.rb +1 -1
- data/lib/dji_mqtt_connect/messages/sys/product/status_message.rb +10 -0
- data/lib/dji_mqtt_connect/messages/sys/product/status_reply/update_topo.rb +1 -10
- data/lib/dji_mqtt_connect/messages/sys/product/status_reply_message.rb +22 -0
- data/lib/dji_mqtt_connect/messages/thing/product/events/airsense_warning.rb +16 -15
- data/lib/dji_mqtt_connect/messages/thing/product/events/cover_close.rb +9 -0
- data/lib/dji_mqtt_connect/messages/thing/product/events/cover_open.rb +9 -0
- data/lib/dji_mqtt_connect/messages/thing/product/events/device_exit_homing_notify.rb +13 -0
- data/lib/dji_mqtt_connect/messages/thing/product/events/device_reboot.rb +9 -0
- data/lib/dji_mqtt_connect/messages/thing/product/events/file_upload_callback.rb +13 -1
- data/lib/dji_mqtt_connect/messages/thing/product/events/fileupload_progress.rb +28 -1
- data/lib/dji_mqtt_connect/messages/thing/product/events/flight_areas_sync_progress.rb +8 -0
- data/lib/dji_mqtt_connect/messages/thing/product/events/flighttask_progress.rb +50 -2
- data/lib/dji_mqtt_connect/messages/thing/product/events/flighttask_ready.rb +6 -1
- data/lib/dji_mqtt_connect/messages/thing/product/events/highest_priority_upload_flighttask_media.rb +6 -1
- data/lib/dji_mqtt_connect/messages/thing/product/events/return_home_info.rb +24 -1
- data/lib/dji_mqtt_connect/messages/thing/product/events/takeoff_to_point_progress.rb +7 -1
- data/lib/dji_mqtt_connect/messages/thing/product/events_message.rb +19 -1
- data/lib/dji_mqtt_connect/messages/thing/product/events_reply_message.rb +12 -1
- data/lib/dji_mqtt_connect/messages/thing/product/osd/dock.rb +5 -1
- data/lib/dji_mqtt_connect/messages/thing/product/osd/drone.rb +5 -1
- data/lib/dji_mqtt_connect/messages/thing/product/osd/remote.rb +4 -0
- data/lib/dji_mqtt_connect/messages/thing/product/osd_message.rb +14 -4
- data/lib/dji_mqtt_connect/messages/thing/product/requests/airport_bind_status.rb +8 -1
- data/lib/dji_mqtt_connect/messages/thing/product/requests/airport_organization_bind.rb +15 -1
- data/lib/dji_mqtt_connect/messages/thing/product/requests/config.rb +0 -1
- data/lib/dji_mqtt_connect/messages/thing/product/requests/flight_areas_get.rb +0 -2
- data/lib/dji_mqtt_connect/messages/thing/product/requests/flighttask_resource_get.rb +6 -1
- data/lib/dji_mqtt_connect/messages/thing/product/requests/offline_map_get.rb +0 -2
- data/lib/dji_mqtt_connect/messages/thing/product/requests_message.rb +18 -1
- data/lib/dji_mqtt_connect/messages/thing/product/requests_reply/airport_bind_status.rb +16 -6
- data/lib/dji_mqtt_connect/messages/thing/product/requests_reply/airport_organization_bind.rb +2 -6
- data/lib/dji_mqtt_connect/messages/thing/product/requests_reply/airport_organization_get.rb +7 -5
- data/lib/dji_mqtt_connect/messages/thing/product/requests_reply/config.rb +9 -5
- data/lib/dji_mqtt_connect/messages/thing/product/requests_reply/flight_areas_get.rb +21 -5
- data/lib/dji_mqtt_connect/messages/thing/product/requests_reply/flighttask_resource_get.rb +1 -5
- data/lib/dji_mqtt_connect/messages/thing/product/requests_reply/offline_map_get.rb +3 -14
- data/lib/dji_mqtt_connect/messages/thing/product/requests_reply/storage_config_get.rb +7 -5
- data/lib/dji_mqtt_connect/messages/thing/product/requests_reply_message.rb +26 -0
- data/lib/dji_mqtt_connect/messages/thing/product/services/alarm_state_switch.rb +10 -0
- data/lib/dji_mqtt_connect/messages/thing/product/services/cover_close.rb +0 -2
- data/lib/dji_mqtt_connect/messages/thing/product/services/cover_open.rb +0 -2
- data/lib/dji_mqtt_connect/messages/thing/product/services/debug_mode_close.rb +0 -2
- data/lib/dji_mqtt_connect/messages/thing/product/services/debug_mode_open.rb +0 -2
- data/lib/dji_mqtt_connect/messages/thing/product/services/flighttask_execute.rb +81 -1
- data/lib/dji_mqtt_connect/messages/thing/product/services/flighttask_pause.rb +0 -2
- data/lib/dji_mqtt_connect/messages/thing/product/services/flighttask_prepare.rb +19 -5
- data/lib/dji_mqtt_connect/messages/thing/product/services/flighttask_progress_get.rb +25 -0
- data/lib/dji_mqtt_connect/messages/thing/product/services/flighttask_recovery.rb +0 -2
- data/lib/dji_mqtt_connect/messages/thing/product/services/flighttask_stop.rb +37 -0
- data/lib/dji_mqtt_connect/messages/thing/product/services/flighttask_undo.rb +12 -1
- data/lib/dji_mqtt_connect/messages/thing/product/services/live_lens_change.rb +10 -16
- data/lib/dji_mqtt_connect/messages/thing/product/services/live_set_quality.rb +10 -18
- data/lib/dji_mqtt_connect/messages/thing/product/services/live_start_push.rb +5 -19
- data/lib/dji_mqtt_connect/messages/thing/product/services/live_stop_push.rb +2 -1
- data/lib/dji_mqtt_connect/messages/thing/product/services/return_home.rb +1 -6
- data/lib/dji_mqtt_connect/messages/thing/product/services/return_home_cancel.rb +1 -6
- data/lib/dji_mqtt_connect/messages/thing/product/services/return_specific_home.rb +27 -0
- data/lib/dji_mqtt_connect/messages/thing/product/services_message.rb +18 -1
- data/lib/dji_mqtt_connect/messages/thing/product/services_reply/flighttask_progress_get.rb +48 -0
- data/lib/dji_mqtt_connect/messages/thing/product/services_reply/flighttask_stop.rb +9 -0
- data/lib/dji_mqtt_connect/messages/thing/product/services_reply/return_specific_home.rb +22 -0
- data/lib/dji_mqtt_connect/messages/thing/product/services_reply_message.rb +8 -0
- data/lib/dji_mqtt_connect/messages/thing/product/state_message.rb +71 -9
- data/lib/dji_mqtt_connect/messages/thing/product/state_reply_message.rb +12 -1
- data/lib/dji_mqtt_connect/mixins/video_quality.rb +43 -0
- data/lib/dji_mqtt_connect/mixins/video_type.rb +37 -0
- data/lib/dji_mqtt_connect/translations.rb +144 -0
- data/lib/dji_mqtt_connect/types.rb +24 -1
- data/lib/dji_mqtt_connect/utils/message_dumping.rb +49 -0
- data/lib/dji_mqtt_connect/version.rb +1 -1
- data/lib/dji_mqtt_connect.rb +12 -0
- metadata +26 -2
@@ -0,0 +1,190 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DjiMqttConnect
|
4
|
+
module Factories::ServicesMessages
|
5
|
+
def build_thing_product_alarm_state_switch_services_message
|
6
|
+
Thing::Product::AlarmStateSwitchServicesMessage.build(action: Thing::Product::AlarmStateSwitchServicesMessage::ACTION_OPEN)
|
7
|
+
end
|
8
|
+
|
9
|
+
def build_thing_product_cover_close_services_message
|
10
|
+
Thing::Product::CoverCloseServicesMessage.build
|
11
|
+
end
|
12
|
+
|
13
|
+
def build_thing_product_cover_open_services_message
|
14
|
+
Thing::Product::CoverOpenServicesMessage.build
|
15
|
+
end
|
16
|
+
|
17
|
+
def build_thing_product_debug_mode_close_services_message
|
18
|
+
Thing::Product::DebugModeCloseServicesMessage.build
|
19
|
+
end
|
20
|
+
|
21
|
+
def build_thing_product_debug_mode_open_services_message
|
22
|
+
Thing::Product::DebugModeOpenServicesMessage.build
|
23
|
+
end
|
24
|
+
|
25
|
+
def build_thing_product_fileupload_list_services_message
|
26
|
+
Thing::Product::FileuploadListServicesMessage.build(
|
27
|
+
module_list: [0, 3]
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
def build_thing_product_fileupload_start_services_message
|
32
|
+
timestamp = Message.current_timestamp
|
33
|
+
Thing::Product::FileuploadStartServicesMessage.build(
|
34
|
+
data: {
|
35
|
+
bucket: "stg-dji-service-hz-ksd7",
|
36
|
+
region: "hz",
|
37
|
+
credentials: {
|
38
|
+
access_key_id: "STS.access_key_id",
|
39
|
+
access_key_secret: "access_key_secret",
|
40
|
+
expire: 3600,
|
41
|
+
security_token: "security_token"
|
42
|
+
},
|
43
|
+
endpoint: "https://oss-cn-hangzhou.aliyuncs.com",
|
44
|
+
params: {
|
45
|
+
files: [
|
46
|
+
{
|
47
|
+
list: [
|
48
|
+
{
|
49
|
+
boot_index: 1111,
|
50
|
+
end_time: timestamp - 3000,
|
51
|
+
size: 33789,
|
52
|
+
start_time: timestamp - 4000
|
53
|
+
},
|
54
|
+
{
|
55
|
+
boot_index: 22222,
|
56
|
+
end_time: timestamp - 1000,
|
57
|
+
size: 33789,
|
58
|
+
start_time: timestamp - 2000
|
59
|
+
}
|
60
|
+
],
|
61
|
+
module: "3",
|
62
|
+
object_key: "object_key"
|
63
|
+
}
|
64
|
+
]
|
65
|
+
},
|
66
|
+
provider: "ali"
|
67
|
+
}
|
68
|
+
)
|
69
|
+
end
|
70
|
+
|
71
|
+
def build_thing_product_flighttask_execute_services_message
|
72
|
+
Thing::Product::FlighttaskExecuteServicesMessage.build(flight_id: SecureRandom.uuid)
|
73
|
+
end
|
74
|
+
|
75
|
+
def build_thing_product_flighttask_pause_services_message
|
76
|
+
Thing::Product::FlighttaskPauseServicesMessage.build
|
77
|
+
end
|
78
|
+
|
79
|
+
def build_thing_product_flighttask_prepare_services_message
|
80
|
+
Thing::Product::FlighttaskPrepareServicesMessage.build(
|
81
|
+
data: {
|
82
|
+
execute_time: 1234567890123,
|
83
|
+
flight_id: "xxxxxxx",
|
84
|
+
task_type: 2,
|
85
|
+
file: {
|
86
|
+
url: "https://xxx.com/xxxx",
|
87
|
+
fingerprint: "xxxx"
|
88
|
+
},
|
89
|
+
ready_conditions: {
|
90
|
+
battery_capacity: 90,
|
91
|
+
begin_time: 1234567890123,
|
92
|
+
end_time: 1234567890123
|
93
|
+
},
|
94
|
+
executable_conditions: {
|
95
|
+
storage_capacity: 1000
|
96
|
+
},
|
97
|
+
break_point: {
|
98
|
+
index: 1,
|
99
|
+
state: 0,
|
100
|
+
progress: 0.34,
|
101
|
+
wayline_id: 0
|
102
|
+
},
|
103
|
+
rth_altitude: 100,
|
104
|
+
rth_mode: 1,
|
105
|
+
out_of_control_action: 0,
|
106
|
+
exit_wayline_when_rc_lost: 0,
|
107
|
+
wayline_precision_type: 0
|
108
|
+
}
|
109
|
+
)
|
110
|
+
end
|
111
|
+
|
112
|
+
def build_thing_product_flighttask_recovery_services_message
|
113
|
+
Thing::Product::FlighttaskRecoveryServicesMessage.build
|
114
|
+
end
|
115
|
+
|
116
|
+
def build_thing_product_flighttask_progress_get_services_message
|
117
|
+
Thing::Product::FlighttaskProgressGetServicesMessage.build(
|
118
|
+
data: {
|
119
|
+
sn: "SN1234567890"
|
120
|
+
}
|
121
|
+
)
|
122
|
+
end
|
123
|
+
|
124
|
+
def build_thing_product_flighttask_stop_services_message
|
125
|
+
Thing::Product::FlighttaskStopServicesMessage.build(
|
126
|
+
data: {
|
127
|
+
flight_id: SecureRandom.uuid,
|
128
|
+
reason: 0
|
129
|
+
}
|
130
|
+
)
|
131
|
+
end
|
132
|
+
|
133
|
+
def build_thing_product_flighttask_undo_services_message
|
134
|
+
Thing::Product::FlighttaskUndoServicesMessage.build(
|
135
|
+
flight_ids: [SecureRandom.uuid, SecureRandom.uuid]
|
136
|
+
)
|
137
|
+
end
|
138
|
+
|
139
|
+
### Live Stream (Services Messages) ###
|
140
|
+
|
141
|
+
def build_thing_product_live_lens_change_services_message
|
142
|
+
Thing::Product::LiveLensChangeServicesMessage.build(
|
143
|
+
data: {
|
144
|
+
video_id: "1ZNDH1D0010098/39-0-7/normal-0",
|
145
|
+
video_type: "wide"
|
146
|
+
}
|
147
|
+
)
|
148
|
+
end
|
149
|
+
|
150
|
+
def build_thing_product_live_set_quality_services_message
|
151
|
+
Thing::Product::LiveSetQualityServicesMessage.build(
|
152
|
+
data: {
|
153
|
+
video_id: "1ZNDH1D0010098/39-0-7/normal-0",
|
154
|
+
video_quality: 0
|
155
|
+
}
|
156
|
+
)
|
157
|
+
end
|
158
|
+
|
159
|
+
def build_thing_product_live_start_push_services_message
|
160
|
+
Thing::Product::LiveStartPushServicesMessage.build(
|
161
|
+
data: {
|
162
|
+
url: "channel=1ZNDH1D0010098_39-0-7&sn=1ZNDH1D0010098&token=006dca67721582a48768ec4d817b7b25a86IADk%2Fcm%2Fdv%2BHY6qT%2FAKM6y7TcUe4lXNvZpycH7vUMAlM6pFALUKF2zyCIgA82pQE8cCoYAQAAQDxwKhgAgDxwKhgAwDxwKhgBADxwKhg&uid=50000",
|
163
|
+
url_type: 0,
|
164
|
+
video_id: "1ZNDH1D0010098/39-0-7/normal-0",
|
165
|
+
video_quality: 0
|
166
|
+
}
|
167
|
+
)
|
168
|
+
end
|
169
|
+
|
170
|
+
def build_thing_product_live_stop_push_services_message
|
171
|
+
Thing::Product::LiveStopPushServicesMessage.build(
|
172
|
+
data: {
|
173
|
+
video_id: "1ZNDH1D0010098/39-0-7/normal-0"
|
174
|
+
}
|
175
|
+
)
|
176
|
+
end
|
177
|
+
|
178
|
+
def build_thing_product_return_home_services_message
|
179
|
+
Thing::Product::ReturnHomeServicesMessage.build
|
180
|
+
end
|
181
|
+
|
182
|
+
def build_thing_product_return_home_cancel_services_message
|
183
|
+
Thing::Product::ReturnHomeCancelServicesMessage.build
|
184
|
+
end
|
185
|
+
|
186
|
+
def build_thing_product_return_specific_home_services_message(home_dock_sn: "SN1234567890")
|
187
|
+
Thing::Product::ReturnSpecificHomeServicesMessage.build(home_dock_sn: home_dock_sn)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
@@ -4,7 +4,7 @@ module DjiMqttConnect
|
|
4
4
|
module Factories::StateMessages
|
5
5
|
### Gateway Messages ###
|
6
6
|
|
7
|
-
def
|
7
|
+
def build_thing_product_state_message_with_firmware_version
|
8
8
|
message_data = {
|
9
9
|
firmware_version: "10.01.1607",
|
10
10
|
compatible_status: 0,
|
@@ -21,7 +21,7 @@ module DjiMqttConnect
|
|
21
21
|
)
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
24
|
+
def build_thing_product_state_message_with_live_capacity
|
25
25
|
message_data = {
|
26
26
|
live_capacity: {
|
27
27
|
available_video_number: 3,
|
@@ -99,7 +99,7 @@ module DjiMqttConnect
|
|
99
99
|
)
|
100
100
|
end
|
101
101
|
|
102
|
-
def
|
102
|
+
def build_thing_product_state_message_with_live_status
|
103
103
|
message_data = {
|
104
104
|
|
105
105
|
live_status: [
|
@@ -130,7 +130,7 @@ module DjiMqttConnect
|
|
130
130
|
)
|
131
131
|
end
|
132
132
|
|
133
|
-
def
|
133
|
+
def build_thing_product_state_message_with_rtcm_info
|
134
134
|
message_data = {
|
135
135
|
rtcm_info: {
|
136
136
|
host: "192.168.0.1",
|
@@ -153,7 +153,7 @@ module DjiMqttConnect
|
|
153
153
|
|
154
154
|
### Payload Messages ###
|
155
155
|
|
156
|
-
def
|
156
|
+
def build_thing_product_state_message_with_ar_info_switch
|
157
157
|
message_data = {
|
158
158
|
ar_info_switch: 1
|
159
159
|
}
|
@@ -168,7 +168,7 @@ module DjiMqttConnect
|
|
168
168
|
)
|
169
169
|
end
|
170
170
|
|
171
|
-
def
|
171
|
+
def build_thing_product_state_message_with_commander_flight_height
|
172
172
|
message_data = {
|
173
173
|
commander_flight_height: 50
|
174
174
|
}
|
@@ -183,7 +183,7 @@ module DjiMqttConnect
|
|
183
183
|
)
|
184
184
|
end
|
185
185
|
|
186
|
-
def
|
186
|
+
def build_thing_product_state_message_with_commander_flight_mode
|
187
187
|
message_data = {
|
188
188
|
commander_flight_mode: 0
|
189
189
|
}
|
@@ -198,7 +198,7 @@ module DjiMqttConnect
|
|
198
198
|
)
|
199
199
|
end
|
200
200
|
|
201
|
-
def
|
201
|
+
def build_thing_product_state_message_with_commander_mode_lost_action
|
202
202
|
message_data = {
|
203
203
|
commander_mode_lost_action: 1
|
204
204
|
}
|
@@ -213,7 +213,7 @@ module DjiMqttConnect
|
|
213
213
|
)
|
214
214
|
end
|
215
215
|
|
216
|
-
def
|
216
|
+
def build_thing_product_state_message_with_current_commander_flight_mode
|
217
217
|
message_data = {
|
218
218
|
current_commander_flight_mode: 0
|
219
219
|
}
|
@@ -228,7 +228,7 @@ module DjiMqttConnect
|
|
228
228
|
)
|
229
229
|
end
|
230
230
|
|
231
|
-
def
|
231
|
+
def build_thing_product_state_message_with_current_rth_mode
|
232
232
|
message_data = {
|
233
233
|
current_rth_mode: 1
|
234
234
|
}
|
@@ -243,7 +243,7 @@ module DjiMqttConnect
|
|
243
243
|
)
|
244
244
|
end
|
245
245
|
|
246
|
-
def
|
246
|
+
def build_thing_product_state_message_with_flysafe_database_version
|
247
247
|
message_data = {
|
248
248
|
flysafe_database_version: "01.00.01.35"
|
249
249
|
}
|
@@ -258,7 +258,7 @@ module DjiMqttConnect
|
|
258
258
|
)
|
259
259
|
end
|
260
260
|
|
261
|
-
def
|
261
|
+
def build_thing_product_state_message_with_geo_caging_status
|
262
262
|
message_data = {
|
263
263
|
geo_caging_status: {
|
264
264
|
state: 0
|
@@ -275,7 +275,7 @@ module DjiMqttConnect
|
|
275
275
|
)
|
276
276
|
end
|
277
277
|
|
278
|
-
def
|
278
|
+
def build_thing_product_state_message_with_mode_code_reason
|
279
279
|
message_data = {
|
280
280
|
mode_code_reason: 0
|
281
281
|
}
|
@@ -290,7 +290,7 @@ module DjiMqttConnect
|
|
290
290
|
)
|
291
291
|
end
|
292
292
|
|
293
|
-
def
|
293
|
+
def build_thing_product_state_message_with_offline_map_enable
|
294
294
|
message_data = {
|
295
295
|
offline_map_enable: true
|
296
296
|
}
|
@@ -305,7 +305,7 @@ module DjiMqttConnect
|
|
305
305
|
)
|
306
306
|
end
|
307
307
|
|
308
|
-
def
|
308
|
+
def build_thing_product_state_message_with_payloads
|
309
309
|
message_data = {
|
310
310
|
payloads: [
|
311
311
|
{
|
@@ -325,7 +325,7 @@ module DjiMqttConnect
|
|
325
325
|
)
|
326
326
|
end
|
327
327
|
|
328
|
-
def
|
328
|
+
def build_thing_proudct_state_message_with_rth_mode
|
329
329
|
message_data = {
|
330
330
|
rth_mode: 1
|
331
331
|
}
|
@@ -340,7 +340,7 @@ module DjiMqttConnect
|
|
340
340
|
)
|
341
341
|
end
|
342
342
|
|
343
|
-
def
|
343
|
+
def build_thing_product_state_message_with_uom_real_name_state
|
344
344
|
message_data = {
|
345
345
|
uom_real_name_state: 11
|
346
346
|
}
|
@@ -355,7 +355,7 @@ module DjiMqttConnect
|
|
355
355
|
)
|
356
356
|
end
|
357
357
|
|
358
|
-
def
|
358
|
+
def build_thing_product_state_message_with_wireless_link_topo
|
359
359
|
message_data = {
|
360
360
|
wireless_link_topo: {
|
361
361
|
center_node: {
|
@@ -389,7 +389,7 @@ module DjiMqttConnect
|
|
389
389
|
)
|
390
390
|
end
|
391
391
|
|
392
|
-
def
|
392
|
+
def build_thing_product_state_message_with_wpmz_version
|
393
393
|
message_data = {
|
394
394
|
wpmz_version: "1.0.6"
|
395
395
|
}
|
@@ -5,9 +5,11 @@ module DjiMqttConnect
|
|
5
5
|
# Do not include this in your production code
|
6
6
|
module Factories
|
7
7
|
autoload :EventsMessages, "dji_mqtt_connect/factories/events_messages"
|
8
|
+
autoload :ServicesMessages, "dji_mqtt_connect/factories/services_messages"
|
8
9
|
autoload :StateMessages, "dji_mqtt_connect/factories/state_messages"
|
9
10
|
|
10
11
|
include EventsMessages
|
12
|
+
include ServicesMessages
|
11
13
|
include StateMessages
|
12
14
|
|
13
15
|
# OSD
|
@@ -74,7 +76,7 @@ module DjiMqttConnect
|
|
74
76
|
tid: Message.generate_tid,
|
75
77
|
bid: Message.generate_bid,
|
76
78
|
timestamp: Message.current_timestamp,
|
77
|
-
gateway: "
|
79
|
+
gateway: "GATEWAYSN",
|
78
80
|
data: message_data,
|
79
81
|
_data: message_data
|
80
82
|
)
|
@@ -125,7 +127,7 @@ module DjiMqttConnect
|
|
125
127
|
tid: Message.generate_tid,
|
126
128
|
bid: Message.generate_bid,
|
127
129
|
timestamp: Message.current_timestamp,
|
128
|
-
gateway: "
|
130
|
+
gateway: "GATEWAYSN",
|
129
131
|
data: message_data,
|
130
132
|
_data: message_data
|
131
133
|
)
|
@@ -162,7 +164,7 @@ module DjiMqttConnect
|
|
162
164
|
tid: Message.generate_tid,
|
163
165
|
bid: Message.generate_bid,
|
164
166
|
timestamp: Message.current_timestamp,
|
165
|
-
gateway: "
|
167
|
+
gateway: "GATEWAYSN",
|
166
168
|
data: message_data,
|
167
169
|
_data: message_data
|
168
170
|
)
|
@@ -170,7 +172,7 @@ module DjiMqttConnect
|
|
170
172
|
|
171
173
|
# Status
|
172
174
|
|
173
|
-
def
|
175
|
+
def build_thing_product_update_topo_message_with_online_device
|
174
176
|
message_data = {
|
175
177
|
type: 98,
|
176
178
|
sub_type: 0,
|
@@ -179,7 +181,7 @@ module DjiMqttConnect
|
|
179
181
|
version: 1,
|
180
182
|
sub_devices: [
|
181
183
|
{
|
182
|
-
sn: "
|
184
|
+
sn: "SUBDEVICESN",
|
183
185
|
type: 116,
|
184
186
|
sub_type: 0,
|
185
187
|
index: "A",
|
@@ -200,7 +202,7 @@ module DjiMqttConnect
|
|
200
202
|
)
|
201
203
|
end
|
202
204
|
|
203
|
-
def
|
205
|
+
def build_thing_product_update_topo_status_reply_message
|
204
206
|
Sys::Product::UpdateTopoStatusReplyMessage.new(
|
205
207
|
_method: "update_topo",
|
206
208
|
tid: Message.generate_tid,
|
@@ -225,7 +227,7 @@ module DjiMqttConnect
|
|
225
227
|
tid: Message.generate_tid,
|
226
228
|
bid: Message.generate_bid,
|
227
229
|
timestamp: Message.current_timestamp,
|
228
|
-
gateway: "
|
230
|
+
gateway: "GATEWAYSN",
|
229
231
|
data: message_data,
|
230
232
|
_data: message_data.deep_stringify_keys
|
231
233
|
)
|
@@ -247,10 +249,10 @@ module DjiMqttConnect
|
|
247
249
|
message_data = {
|
248
250
|
devices: [
|
249
251
|
{
|
250
|
-
sn: "
|
252
|
+
sn: "DRONESN"
|
251
253
|
},
|
252
254
|
{
|
253
|
-
sn: "
|
255
|
+
sn: "DOCKSN"
|
254
256
|
}
|
255
257
|
]
|
256
258
|
}
|
@@ -404,7 +406,7 @@ module DjiMqttConnect
|
|
404
406
|
tid: Message.generate_tid,
|
405
407
|
bid: Message.generate_bid,
|
406
408
|
timestamp: Message.current_timestamp,
|
407
|
-
gateway: "
|
409
|
+
gateway: "GATEWAYSN",
|
408
410
|
data: message_data,
|
409
411
|
_data: message_data.deep_stringify_keys
|
410
412
|
)
|
@@ -451,7 +453,7 @@ module DjiMqttConnect
|
|
451
453
|
tid: Message.generate_tid,
|
452
454
|
bid: Message.generate_bid,
|
453
455
|
timestamp: Message.current_timestamp,
|
454
|
-
gateway: "
|
456
|
+
gateway: "GATEWAYSN",
|
455
457
|
data: message_data
|
456
458
|
)
|
457
459
|
end
|
@@ -502,171 +504,7 @@ module DjiMqttConnect
|
|
502
504
|
)
|
503
505
|
end
|
504
506
|
|
505
|
-
# Services
|
506
|
-
|
507
|
-
def build_thing_product_alarm_state_switch_services_message
|
508
|
-
Thing::Product::AlarmStateSwitchServicesMessage.build(action: Thing::Product::AlarmStateSwitchServicesMessage::ACTION_OPEN)
|
509
|
-
end
|
510
|
-
|
511
|
-
def build_thing_product_cover_close_services_message
|
512
|
-
Thing::Product::CoverCloseServicesMessage.build
|
513
|
-
end
|
514
|
-
|
515
|
-
def build_thing_product_cover_open_services_message
|
516
|
-
Thing::Product::CoverOpenServicesMessage.build
|
517
|
-
end
|
518
|
-
|
519
|
-
def build_thing_product_debug_mode_close_services_message
|
520
|
-
Thing::Product::DebugModeCloseServicesMessage.build
|
521
|
-
end
|
522
|
-
|
523
|
-
def build_thing_product_debug_mode_open_services_message
|
524
|
-
Thing::Product::DebugModeOpenServicesMessage.build
|
525
|
-
end
|
526
|
-
|
527
|
-
def build_thing_product_fileupload_list_services_message
|
528
|
-
Thing::Product::FileuploadListServicesMessage.build(
|
529
|
-
module_list: [0, 3]
|
530
|
-
)
|
531
|
-
end
|
532
|
-
|
533
|
-
def build_thing_product_fileupload_start_services_message
|
534
|
-
timestamp = Message.current_timestamp
|
535
|
-
Thing::Product::FileuploadStartServicesMessage.build(
|
536
|
-
data: {
|
537
|
-
bucket: "stg-dji-service-hz-ksd7",
|
538
|
-
region: "hz",
|
539
|
-
credentials: {
|
540
|
-
access_key_id: "STS.access_key_id",
|
541
|
-
access_key_secret: "access_key_secret",
|
542
|
-
expire: 3600,
|
543
|
-
security_token: "security_token"
|
544
|
-
},
|
545
|
-
endpoint: "https://oss-cn-hangzhou.aliyuncs.com",
|
546
|
-
params: {
|
547
|
-
files: [
|
548
|
-
{
|
549
|
-
list: [
|
550
|
-
{
|
551
|
-
boot_index: 1111,
|
552
|
-
end_time: timestamp - 3000,
|
553
|
-
size: 33789,
|
554
|
-
start_time: timestamp - 4000
|
555
|
-
},
|
556
|
-
{
|
557
|
-
boot_index: 22222,
|
558
|
-
end_time: timestamp - 1000,
|
559
|
-
size: 33789,
|
560
|
-
start_time: timestamp - 2000
|
561
|
-
}
|
562
|
-
],
|
563
|
-
module: "3",
|
564
|
-
object_key: "object_key"
|
565
|
-
}
|
566
|
-
]
|
567
|
-
},
|
568
|
-
provider: "ali"
|
569
|
-
}
|
570
|
-
)
|
571
|
-
end
|
572
|
-
|
573
|
-
def build_thing_product_flighttask_execute_services_message
|
574
|
-
Thing::Product::FlighttaskExecuteServicesMessage.build(flight_id: SecureRandom.uuid)
|
575
|
-
end
|
576
|
-
|
577
|
-
def build_thing_product_flighttask_pause_services_message
|
578
|
-
Thing::Product::FlighttaskPauseServicesMessage.build
|
579
|
-
end
|
580
|
-
|
581
|
-
def build_thing_product_flighttask_prepare_services_message
|
582
|
-
Thing::Product::FlighttaskPrepareServicesMessage.build(
|
583
|
-
data: {
|
584
|
-
execute_time: 1234567890123,
|
585
|
-
flight_id: "xxxxxxx",
|
586
|
-
task_type: 2,
|
587
|
-
wayline_type: 0,
|
588
|
-
file: {
|
589
|
-
url: "https://xxx.com/xxxx",
|
590
|
-
fingerprint: "xxxx"
|
591
|
-
},
|
592
|
-
ready_conditions: {
|
593
|
-
battery_capacity: 90,
|
594
|
-
begin_time: 1234567890123,
|
595
|
-
end_time: 1234567890123
|
596
|
-
},
|
597
|
-
executable_conditions: {
|
598
|
-
storage_capacity: 1000
|
599
|
-
},
|
600
|
-
break_point: {
|
601
|
-
index: 1,
|
602
|
-
state: 0,
|
603
|
-
progress: 0.34,
|
604
|
-
wayline_id: 0
|
605
|
-
},
|
606
|
-
rth_altitude: 100,
|
607
|
-
rth_mode: 1,
|
608
|
-
out_of_control_action: 0,
|
609
|
-
exit_wayline_when_rc_lost: 0
|
610
|
-
}
|
611
|
-
)
|
612
|
-
end
|
613
|
-
|
614
|
-
def build_thing_product_flighttask_recovery_services_message
|
615
|
-
Thing::Product::FlighttaskRecoveryServicesMessage.build
|
616
|
-
end
|
617
|
-
|
618
|
-
def build_thing_product_flighttask_undo_services_message
|
619
|
-
Thing::Product::FlighttaskUndoServicesMessage.build(
|
620
|
-
flight_ids: [SecureRandom.uuid, SecureRandom.uuid]
|
621
|
-
)
|
622
|
-
end
|
623
|
-
|
624
|
-
### Live Stream (Services Messages) ###
|
625
|
-
|
626
|
-
def build_thing_product_live_lens_change_services_message
|
627
|
-
Thing::Product::LiveLensChangeServicesMessage.build(
|
628
|
-
data: {
|
629
|
-
video_id: "1ZNDH1D0010098/39-0-7/normal-0",
|
630
|
-
video_type: "wide"
|
631
|
-
}
|
632
|
-
)
|
633
|
-
end
|
634
|
-
|
635
|
-
def build_thing_product_live_set_quality_services_message
|
636
|
-
Thing::Product::LiveSetQualityServicesMessage.build(
|
637
|
-
data: {
|
638
|
-
video_id: "1ZNDH1D0010098/39-0-7/normal-0",
|
639
|
-
video_quality: 0
|
640
|
-
}
|
641
|
-
)
|
642
|
-
end
|
643
|
-
|
644
|
-
def build_thing_product_live_start_push_services_message
|
645
|
-
Thing::Product::LiveStartPushServicesMessage.build(
|
646
|
-
data: {
|
647
|
-
url: "channel=1ZNDH1D0010098_39-0-7&sn=1ZNDH1D0010098&token=006dca67721582a48768ec4d817b7b25a86IADk%2Fcm%2Fdv%2BHY6qT%2FAKM6y7TcUe4lXNvZpycH7vUMAlM6pFALUKF2zyCIgA82pQE8cCoYAQAAQDxwKhgAgDxwKhgAwDxwKhgBADxwKhg&uid=50000",
|
648
|
-
url_type: 0,
|
649
|
-
video_id: "1ZNDH1D0010098/39-0-7/normal-0",
|
650
|
-
video_quality: 0
|
651
|
-
}
|
652
|
-
)
|
653
|
-
end
|
654
|
-
|
655
|
-
def build_thing_product_live_stop_push_services_message
|
656
|
-
Thing::Product::LiveStopPushServicesMessage.build(
|
657
|
-
data: {
|
658
|
-
video_id: "1ZNDH1D0010098/39-0-7/normal-0"
|
659
|
-
}
|
660
|
-
)
|
661
|
-
end
|
662
|
-
|
663
|
-
def build_thing_product_return_home_services_message
|
664
|
-
Thing::Product::ReturnHomeServicesMessage.build
|
665
|
-
end
|
666
|
-
|
667
|
-
def build_thing_product_return_home_cancel_services_message
|
668
|
-
Thing::Product::ReturnHomeCancelServicesMessage.build
|
669
|
-
end
|
507
|
+
# Services Replies
|
670
508
|
|
671
509
|
def build_thing_product_alarm_state_switch_services_reply_message
|
672
510
|
message_data = {
|
@@ -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 Sys::Product
|
8
7
|
class StatusReplyMarshal < MessageMarshal
|
9
|
-
|
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 =
|
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,12 +10,19 @@ 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
|
13
|
+
class EventsTransformer < Dry::Transformer::Pipe
|
14
14
|
import Dry::Transformer::Conditional
|
15
15
|
import Dry::Transformer::ArrayTransformations
|
16
16
|
import Dry::Transformer::HashTransformations
|
17
17
|
|
18
18
|
define! do
|
19
|
+
# Fix the airsense_warning message
|
20
|
+
guard ->(message) { message["data"].is_a?(Array) } do
|
21
|
+
# data is an array of hashes, we need to wrap it in a list key
|
22
|
+
rename_keys "data" => "list"
|
23
|
+
nest "data", ["list"]
|
24
|
+
end
|
25
|
+
|
19
26
|
# Keep a copy of the original data hash
|
20
27
|
copy_keys "data" => "_data"
|
21
28
|
|
@@ -65,7 +72,7 @@ module DjiMqttConnect
|
|
65
72
|
parsed_message = parse_json(raw_message)
|
66
73
|
|
67
74
|
# Transform the message
|
68
|
-
transformed_message =
|
75
|
+
transformed_message = events_transformer.call(parsed_message)
|
69
76
|
message_method = transformed_message["_method"]
|
70
77
|
|
71
78
|
# Build an instance of the class, or a generic message from the current class
|
@@ -75,8 +82,8 @@ module DjiMqttConnect
|
|
75
82
|
|
76
83
|
private
|
77
84
|
|
78
|
-
def
|
79
|
-
@
|
85
|
+
def events_transformer
|
86
|
+
@events_transformer ||= EventsTransformer.new
|
80
87
|
end
|
81
88
|
end
|
82
89
|
end
|