Module: DjiMqttConnect::Factories::ServicesMessages

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

Instance Method Summary collapse

Instance Method Details

#build_thing_product_alarm_state_switch_services_messageObject



5
6
7
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 5

def build_thing_product_alarm_state_switch_services_message
  Thing::Product::AlarmStateSwitchServicesMessage.build(action: Thing::Product::AlarmStateSwitchServicesMessage::ACTION_OPEN)
end

#build_thing_product_cover_close_services_messageObject



9
10
11
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 9

def build_thing_product_cover_close_services_message
  Thing::Product::CoverCloseServicesMessage.build
end

#build_thing_product_cover_open_services_messageObject



13
14
15
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 13

def build_thing_product_cover_open_services_message
  Thing::Product::CoverOpenServicesMessage.build
end

#build_thing_product_debug_mode_close_services_messageObject



17
18
19
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 17

def build_thing_product_debug_mode_close_services_message
  Thing::Product::DebugModeCloseServicesMessage.build
end

#build_thing_product_debug_mode_open_services_messageObject



21
22
23
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 21

def build_thing_product_debug_mode_open_services_message
  Thing::Product::DebugModeOpenServicesMessage.build
end

#build_thing_product_drone_close_services_messageObject



25
26
27
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 25

def build_thing_product_drone_close_services_message
  Thing::Product::DroneCloseServicesMessage.build
end

#build_thing_product_drone_open_services_messageObject



29
30
31
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 29

def build_thing_product_drone_open_services_message
  Thing::Product::DroneOpenServicesMessage.build
end

#build_thing_product_fileupload_list_services_messageObject



33
34
35
36
37
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 33

def build_thing_product_fileupload_list_services_message
  Thing::Product::FileuploadListServicesMessage.build(
    module_list: [0, 3]
  )
end

#build_thing_product_fileupload_start_services_messageObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 39

def build_thing_product_fileupload_start_services_message
  timestamp = Message.current_timestamp
  Thing::Product::FileuploadStartServicesMessage.build(
    data: {
      bucket: "stg-dji-service-hz-ksd7",
      region: "hz",
      credentials: {
        access_key_id: "STS.access_key_id",
        access_key_secret: "access_key_secret",
        expire: 3600,
        security_token: "security_token"
      },
      endpoint: "https://oss-cn-hangzhou.aliyuncs.com",
      params: {
        files: [
          {
            list: [
              {
                boot_index: 1111,
                end_time: timestamp - 3000,
                size: 33789,
                start_time: timestamp - 4000
              },
              {
                boot_index: 22222,
                end_time: timestamp - 1000,
                size: 33789,
                start_time: timestamp - 2000
              }
            ],
            module: "3",
            object_key: "object_key"
          }
        ]
      },
      provider: "ali"
    }
  )
end

#build_thing_product_flight_authority_grab_services_messageObject

Flight Authority Grab ###



81
82
83
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 81

def build_thing_product_flight_authority_grab_services_message
  Thing::Product::FlightAuthorityGrabServicesMessage.build
end

#build_thing_product_flight_authority_grab_services_reply_message(result: 0) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 85

def build_thing_product_flight_authority_grab_services_reply_message(result: 0)
  message_data = {
    result: result
  }

  Thing::Product::FlightAuthorityGrabServicesReplyMessage.new(
    bid: SecureRandom.uuid,
    tid: SecureRandom.uuid,
    timestamp: Message.current_timestamp,
    _method: "flight_authority_grab",
    _data: message_data,
    data: message_data
  )
end

#build_thing_product_flighttask_execute_services_messageObject

Flighttask Execute ###



102
103
104
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 102

def build_thing_product_flighttask_execute_services_message
  Thing::Product::FlighttaskExecuteServicesMessage.build(flight_id: SecureRandom.uuid)
end

#build_thing_product_flighttask_pause_services_messageObject



106
107
108
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 106

def build_thing_product_flighttask_pause_services_message
  Thing::Product::FlighttaskPauseServicesMessage.build
end

#build_thing_product_flighttask_prepare_services_messageObject



110
111
112
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
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 110

def build_thing_product_flighttask_prepare_services_message
  Thing::Product::FlighttaskPrepareServicesMessage.build(
    data: {
      execute_time: 1234567890123,
      flight_id: "xxxxxxx",
      task_type: 2,
      file: {
        url: "https://xxx.com/xxxx",
        fingerprint: "xxxx"
      },
      ready_conditions: {
        battery_capacity: 90,
        begin_time: 1234567890123,
        end_time: 1234567890123
      },
      executable_conditions: {
        storage_capacity: 1000
      },
      break_point: {
        index: 1,
        state: 0,
        progress: 0.34,
        wayline_id: 0
      },
      rth_altitude: 100,
      rth_mode: 1,
      out_of_control_action: 0,
      exit_wayline_when_rc_lost: 0,
      wayline_precision_type: 0
    }
  )
end

#build_thing_product_flighttask_progress_get_services_messageObject



147
148
149
150
151
152
153
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 147

def build_thing_product_flighttask_progress_get_services_message
  Thing::Product::FlighttaskProgressGetServicesMessage.build(
    data: {
      sn: "SN1234567890"
    }
  )
end

#build_thing_product_flighttask_recovery_services_messageObject



143
144
145
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 143

def build_thing_product_flighttask_recovery_services_message
  Thing::Product::FlighttaskRecoveryServicesMessage.build
end

#build_thing_product_flighttask_stop_services_messageObject



155
156
157
158
159
160
161
162
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 155

def build_thing_product_flighttask_stop_services_message
  Thing::Product::FlighttaskStopServicesMessage.build(
    data: {
      flight_id: SecureRandom.uuid,
      reason: 0
    }
  )
end

#build_thing_product_flighttask_undo_services_messageObject



164
165
166
167
168
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 164

def build_thing_product_flighttask_undo_services_message
  Thing::Product::FlighttaskUndoServicesMessage.build(
    flight_ids: [SecureRandom.uuid, SecureRandom.uuid]
  )
end

#build_thing_product_fly_to_point_services_messageObject

Fly to Point (Services Messages) ###



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 172

def build_thing_product_fly_to_point_services_message
  message_data = {
    fly_to_id: SecureRandom.uuid,
    points: [
      {
        latitude: 37.7749,
        longitude: -122.4194,
        height: 100
      }
    ],
    max_speed: 5
  }

  Thing::Product::FlyToPointServicesMessage.build(
    data: message_data
  )
end

#build_thing_product_fly_to_point_stop_services_messageObject



190
191
192
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 190

def build_thing_product_fly_to_point_stop_services_message
  Thing::Product::FlyToPointStopServicesMessage.build
end

#build_thing_product_fly_to_point_update_services_messageObject



194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 194

def build_thing_product_fly_to_point_update_services_message
  message_data = {
    points: [
      {
        latitude: 37.7750,
        longitude: -122.4195,
        height: 120
      }
    ],
    max_speed: 6
  }

  Thing::Product::FlyToPointUpdateServicesMessage.build(
    data: message_data
  )
end

#build_thing_product_live_lens_change_services_messageObject

Live Stream (Services Messages) ###



213
214
215
216
217
218
219
220
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 213

def build_thing_product_live_lens_change_services_message
  Thing::Product::LiveLensChangeServicesMessage.build(
    data: {
      video_id: "1ZNDH1D0010098/39-0-7/normal-0",
      video_type: "wide"
    }
  )
end

#build_thing_product_live_set_quality_services_messageObject



222
223
224
225
226
227
228
229
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 222

def build_thing_product_live_set_quality_services_message
  Thing::Product::LiveSetQualityServicesMessage.build(
    data: {
      video_id: "1ZNDH1D0010098/39-0-7/normal-0",
      video_quality: 0
    }
  )
end

#build_thing_product_live_start_push_services_messageObject



231
232
233
234
235
236
237
238
239
240
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 231

def build_thing_product_live_start_push_services_message
  Thing::Product::LiveStartPushServicesMessage.build(
    data: {
      url: "channel=1ZNDH1D0010098_39-0-7&sn=1ZNDH1D0010098&token=006dca67721582a48768ec4d817b7b25a86IADk%2Fcm%2Fdv%2BHY6qT%2FAKM6y7TcUe4lXNvZpycH7vUMAlM6pFALUKF2zyCIgA82pQE8cCoYAQAAQDxwKhgAgDxwKhgAwDxwKhgBADxwKhg&uid=50000",
      url_type: 0,
      video_id: "1ZNDH1D0010098/39-0-7/normal-0",
      video_quality: 0
    }
  )
end

#build_thing_product_live_stop_push_services_messageObject



242
243
244
245
246
247
248
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 242

def build_thing_product_live_stop_push_services_message
  Thing::Product::LiveStopPushServicesMessage.build(
    data: {
      video_id: "1ZNDH1D0010098/39-0-7/normal-0"
    }
  )
end

#build_thing_product_return_home_cancel_services_messageObject



254
255
256
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 254

def build_thing_product_return_home_cancel_services_message
  Thing::Product::ReturnHomeCancelServicesMessage.build
end

#build_thing_product_return_home_services_messageObject



250
251
252
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 250

def build_thing_product_return_home_services_message
  Thing::Product::ReturnHomeServicesMessage.build
end

#build_thing_product_return_specific_home_services_message(home_dock_sn: "SN1234567890") ⇒ Object



258
259
260
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 258

def build_thing_product_return_specific_home_services_message(home_dock_sn: "SN1234567890")
  Thing::Product::ReturnSpecificHomeServicesMessage.build(home_dock_sn: home_dock_sn)
end

#build_thing_product_takeoff_to_point_services_messageObject

Takeoff to Point (Services Messages) ###



264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 264

def build_thing_product_takeoff_to_point_services_message
  message_data = {
    flight_id: SecureRandom.uuid,
    target_latitude: 37.7749,
    target_longitude: -122.4194,
    target_height: 100,
    max_speed: 5,
    rth_mode: 1,
    rth_altitude: 30,
    security_takeoff_height: 10,
    rc_lost_action: 1,
    commander_mode_lost_action: 0,
    commander_flight_mode: 1,
    commander_flight_height: 50,
    flight_safety_advance_check: 1
  }

  Thing::Product::TakeoffToPointServicesMessage.build(
    data: message_data
  )
end

#build_thing_product_takeoff_to_point_services_reply_messageObject



286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/dji_mqtt_connect/factories/services_messages.rb', line 286

def build_thing_product_takeoff_to_point_services_reply_message
  message_data = {
    result: 0
  }

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