# frozen_string_literal: true module DjiMqttConnect module Factories::EventsMessages 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 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 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 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 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 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 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 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 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 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 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 end end