Module: DjiMqttConnect::Factories::EventsMessages

Included in:
DjiMqttConnect::Factories
Defined in:
lib/dji_mqtt_connect/factories/events_messages.rb

Instance Method Summary collapse

Instance Method Details

#build_thing_product_airsense_warning_events_messageObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dji_mqtt_connect/factories/events_messages.rb', line 5

def build_thing_product_airsense_warning_events_message
  message_data = {
    list: [
      {
        icao: "icao",
        warning_level: 1,
        latitude: 22.1,
        longitude: 113.9,
        altitude: 100,
        altitude_type: 0,
        distance: 100,
        heading: 90.0,
        relative_altitude: 100,
        vert_trend: 1
      }
    ]
  }

  Thing::Product::AirsenseWarningEventsMessage.new(
    _method: "airsense_warning",
    bid: Message.generate_bid,
    tid: Message.generate_tid,
    need_reply: 1,
    gateway: "GATEWAYSN",
    timestamp: Message.current_timestamp,
    data: message_data,
    _data: message_data
  )
end

#build_thing_product_device_exit_homing_notify_events_messageObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/dji_mqtt_connect/factories/events_messages.rb', line 35

def build_thing_product_device_exit_homing_notify_events_message
  message_data = {
    action: 1,
    sn: "DOCK01",
    reason: "0"
  }
  Thing::Product::DeviceExitHomingNotifyEventsMessage.new(
    _method: "device_exit_homing_notify",
    bid: Message.generate_bid,
    tid: Message.generate_tid,
    need_reply: 1,
    gateway: "GATEWAYSN",
    timestamp: Message.current_timestamp,
    data: message_data,
    _data: message_data
  )
end

#build_thing_product_device_reboot_events_messageObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/dji_mqtt_connect/factories/events_messages.rb', line 53

def build_thing_product_device_reboot_events_message
  message_data = {
    result: 0,
    output: {
      status: "ok",
      progress: {
        percent: 100
      }
    }
  }

  Thing::Product::DeviceRebootEventsMessage.new(
    bid: Message.generate_bid,
    tid: Message.generate_tid,
    timestamp: Message.current_timestamp,
    _method: "device_reboot",
    need_reply: 1,
    data: message_data,
    _data: message_data
  )
end

#build_thing_product_file_upload_callback_events_messageObject



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/dji_mqtt_connect/factories/events_messages.rb', line 75

def build_thing_product_file_upload_callback_events_message
  message_data = {
    file: {
      object_key: "object_key",
      path: "xxx",
      name: "dog.jpeg",
      ext: {
        flight_id: "xxx",
        drone_model_key: "0-67-0",
        payload_model_key: "0-67-0",
        is_original: true
      },
      metadata: {
        shoot_position: {
          lat: 22.1,
          lng: 122.5
        },
        gimbal_yaw_degree: -91.4,
        absolute_altitude: 56.311,
        relative_altitude: 41.124,
        created_time: "2021-05-10 16:04:20"
      }
    },
    result: 0
  }

  Thing::Product::FileUploadCallbackEventsMessage.new(
    _method: "file_upload_callback",
    bid: Message.generate_bid,
    tid: Message.generate_tid,
    need_reply: 1,
    gateway: "GATEWAYSN",
    timestamp: Message.current_timestamp,
    data: message_data,
    _data: message_data
  )
end

#build_thing_product_fileupload_progress_events_messageObject



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/dji_mqtt_connect/factories/events_messages.rb', line 113

def build_thing_product_fileupload_progress_events_message
  message_data = {
    output: {
      ext: {
        files: [
          {
            module: "0",
            size: 155232,
            device_sn: "DRONESN",
            key: "4bf0039f-6434-44a8-b891-8d7b6b7ff138/DRONESN/video_20220621_110830.log",
            fingerprint: "4f65b891f3bc09bdb6d4c36a996b532d",
            progress: {
              current_step: 19,
              progress: 100,
              finish_time: 1655781395926,
              upload_rate: 0,
              result: 0,
              status: "ok"
            }
          },
          {
            module: "3",
            size: 155232,
            device_sn: "DOCKSN",
            key: "4bf0039f-6434-44a8-b891-8d7b6b7ff138/DOCKSN/video_20220621_110830.log",
            fingerprint: "4f65b891f3bc09bdb6d4c36a996b532d",
            progress: {
              current_step: 19,
              total_step: 30,
              progress: 100,
              finish_time: 1655781395926,
              upload_rate: 0,
              result: 0,
              status: "ok"
            }
          }
        ]
      },
      status: "ok"
    }
  }

  Thing::Product::FileuploadProgressEventsMessage.new(
    _method: "fileupload_progress",
    need_reply: 0,
    bid: Message.generate_bid,
    tid: Message.generate_tid,
    timestamp: Message.current_timestamp,
    gateway: "GATEWAYSN",
    _data: message_data,
    data: message_data
  )
end

#build_thing_product_flighttask_progress_events_messageObject



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/dji_mqtt_connect/factories/events_messages.rb', line 167

def build_thing_product_flighttask_progress_events_message
  message_data = {
    output: {
      ext: {
        current_waypoint_index: 3,
        media_count: 6,
        track_id: "track_id",
        flight_id: "flight_id",
        break_point: {
          index: 1,
          state: 0,
          progress: 0.34,
          wayline_id: 0,
          break_reason: 1,
          latitude: 23.4,
          longitude: 113.99,
          height: 100.23,
          attitude_head: 30
        }
      },
      progress: {
        current_step: 19,
        percent: 100
      },
      status: "ok"
    },
    result: 0
  }

  Thing::Product::FlighttaskProgressEventsMessage.new(
    bid: Message.generate_bid,
    tid: Message.generate_tid,
    data: message_data,
    _data: message_data,
    _method: "flighttask_progress",
    timestamp: Message.current_timestamp
  )
end

#build_thing_product_flighttask_ready_events_messageObject



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/dji_mqtt_connect/factories/events_messages.rb', line 206

def build_thing_product_flighttask_ready_events_message
  message_data = {
    flight_ids: [
      SecureRandom.uuid,
      SecureRandom.uuid
    ]
  }

  Thing::Product::FlighttaskReadyEventsMessage.new(
    bid: Message.generate_bid,
    tid: Message.generate_tid,
    data: message_data,
    _data: message_data,
    _method: "flighttask_ready",
    timestamp: Message.current_timestamp
  )
end

#build_thing_product_highest_priority_upload_flighttask_media_events_messageObject



224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/dji_mqtt_connect/factories/events_messages.rb', line 224

def build_thing_product_highest_priority_upload_flighttask_media_events_message
  message_data = {
    flight_id: SecureRandom.uuid
  }

  Thing::Product::HighestPriorityUploadFlighttaskMediaEventsMessage.new(
    bid: Message.generate_bid,
    _data: message_data,
    data: message_data,
    _method: "highest_priority_upload_flighttask_media",
    need_reply: 1,
    tid: Message.generate_tid,
    timestamp: Message.current_timestamp,
    gateway: "DOCK01"
  )
end

#build_thing_product_offline_map_sync_progress_events_messageObject



241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/dji_mqtt_connect/factories/events_messages.rb', line 241

def build_thing_product_offline_map_sync_progress_events_message
  message_data = {
    status: "failed",
    reason: 0,
    file: "geofence_xxx.json"
  }

  Thing::Product::OfflineMapSyncProgressEventsMessage.new(
    bid: Message.generate_bid,
    tid: Message.generate_tid,
    timestamp: Message.current_timestamp,
    _method: "offline_map_sync_progress",
    need_reply: 1,
    data: message_data,
    _data: message_data
  )
end

#build_thing_product_return_home_info_events_messageObject



259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
# File 'lib/dji_mqtt_connect/factories/events_messages.rb', line 259

def build_thing_product_return_home_info_events_message
  message_data = {
    flight_id: "5c746ff3-3b3e-4787-8e06-23c491a99a13",
    last_point_type: 0,
    planned_path_points: [
      {
        height: 99.654359985142946,
        latitude: -33.9614494331181,
        longitude: 150.72803176939487
      },
      {
        height: 99.654359985142946,
        latitude: -33.961449558846653,
        longitude: 150.72803218849
      }
    ]
  }

  Thing::Product::ReturnHomeInfoEventsMessage.new(
    bid: Message.generate_bid,
    tid: Message.generate_tid,
    timestamp: Message.current_timestamp,
    _method: "return_home_info",
    need_reply: 1,
    data: message_data,
    _data: message_data
  )
end

#build_thing_product_takeoff_to_point_progress_events_messageObject



288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# File 'lib/dji_mqtt_connect/factories/events_messages.rb', line 288

def build_thing_product_takeoff_to_point_progress_events_message
  message_data = {
    flight_id: SecureRandom.uuid,
    remaining_distance: 100,
    remaining_time: 10,
    result: 0,
    status: "ok",
    track_id: SecureRandom.uuid,
    way_point_index: 3
  }

  Thing::Product::TakeoffToPointProgressEventsMessage.new(
    bid: Message.generate_bid,
    tid: Message.generate_tid,
    timestamp: Message.current_timestamp,
    _method: "takeoff_to_point_progress",
    need_reply: 1,
    data: message_data,
    _data: message_data
  )
end