dji_mqtt_connect 0.1.9 → 0.1.10
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.rb +61 -0
- data/lib/dji_mqtt_connect/marshals/thing/product/events_reply_marshal.rb +34 -0
- data/lib/dji_mqtt_connect/messages/sys/product/update_topo_status_message.rb +3 -0
- data/lib/dji_mqtt_connect/messages/thing/product/dock_osd_message.rb +8 -2
- data/lib/dji_mqtt_connect/messages/thing/product/events_reply_message.rb +34 -0
- data/lib/dji_mqtt_connect/messages/thing/product/file_upload_callback_events_message.rb +4 -0
- data/lib/dji_mqtt_connect/messages/thing/product/highest_priority_upload_flighttask_media_events_message.rb +20 -0
- data/lib/dji_mqtt_connect/topics/thing/product/events_reply.rb +16 -0
- data/lib/dji_mqtt_connect/version.rb +1 -1
- data/lib/dji_mqtt_connect.rb +5 -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: acdbcd3a64661ee53c4a9cc75d4e059eed52a3ab3eb6f19e9b7dc9beca46d18f
|
4
|
+
data.tar.gz: de8b3c76bf634c59efceaf9a57a1fb6db4b7559b9a10ec8e045f69f6c986d529
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fb2327163be78ae6f9ca5ac162f390a89a14368063651857a49b3534147b730d2b1136eb5b490848487a75c65b9cbccae65223967d2dbe7dac79c15e2c50946
|
7
|
+
data.tar.gz: 28648d5e4c19f0d6016cfd73e1af08dd9d7cc54f25fd4c1ac09aab860969d22cc0a64dc94f6acb90bf5e48ab41fc05d0ff253a32706b01db4aeb10f94047e467
|
data/Gemfile.lock
CHANGED
@@ -46,6 +46,11 @@ module DjiMqttConnect
|
|
46
46
|
Thing::Product::EventsTopicRepository.new(self)
|
47
47
|
end
|
48
48
|
|
49
|
+
# Handles topic thing/product/#{pid}/events_reply
|
50
|
+
def thing_product_events_reply_topic
|
51
|
+
Thing::Product::EventsReplyTopicRepository.new(self)
|
52
|
+
end
|
53
|
+
|
49
54
|
# Handles topic thing/product/#{pid}/osd
|
50
55
|
def thing_product_osd_topic
|
51
56
|
Thing::Product::OsdTopicRepository.new(self)
|
@@ -4,6 +4,65 @@ module DjiMqttConnect
|
|
4
4
|
# Factories for building example messages
|
5
5
|
# Do not include this in your production code
|
6
6
|
module Factories
|
7
|
+
# Events
|
8
|
+
|
9
|
+
def build_file_upload_callback_events_message
|
10
|
+
message_data = {
|
11
|
+
file: {
|
12
|
+
object_key: "object_key",
|
13
|
+
path: "xxx",
|
14
|
+
name: "dog.jpeg",
|
15
|
+
ext: {
|
16
|
+
flight_id: "xxx",
|
17
|
+
drone_model_key: "0-67-0",
|
18
|
+
payload_model_key: "0-67-0",
|
19
|
+
is_original: true
|
20
|
+
},
|
21
|
+
metadata: {
|
22
|
+
shoot_position: {
|
23
|
+
lat: 22.1,
|
24
|
+
lng: 122.5
|
25
|
+
},
|
26
|
+
gimbal_yaw_degree: -91.4,
|
27
|
+
absolute_altitude: 56.311,
|
28
|
+
relative_altitude: 41.124,
|
29
|
+
created_time: "2021-05-10 16:04:20"
|
30
|
+
}
|
31
|
+
},
|
32
|
+
result: 0
|
33
|
+
}
|
34
|
+
|
35
|
+
Thing::Product::FileUploadCallbackEventsMessage.new(
|
36
|
+
_method: "file_upload_callback",
|
37
|
+
bid: "12345678-1234-1234-1234-12345678901B",
|
38
|
+
tid: "12345678-1234-1234-1234-12345678901A",
|
39
|
+
need_reply: 1,
|
40
|
+
gateway: "xxx",
|
41
|
+
timestamp: 1654070968655,
|
42
|
+
data: message_data,
|
43
|
+
_data: message_data
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
def build_highest_priority_upload_flighttask_media_events_message
|
48
|
+
message_data = {
|
49
|
+
flight_id: SecureRandom.uuid
|
50
|
+
}
|
51
|
+
|
52
|
+
Thing::Product::HighestPriorityUploadFlighttaskMediaEventsMessage.new(
|
53
|
+
bid: "fe0e2218-038f-46fe-b27d-74cd257c386a",
|
54
|
+
_data: message_data,
|
55
|
+
data: message_data,
|
56
|
+
_method: "highest_priority_upload_flighttask_media",
|
57
|
+
need_reply: 1,
|
58
|
+
tid: "c6aa22c0-e9dd-4895-a25c-6c12411513df",
|
59
|
+
timestamp: 1684986146586,
|
60
|
+
gateway: "DOCK01"
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
# Status
|
65
|
+
|
7
66
|
def build_device_online_update_topo_message
|
8
67
|
message_data = {
|
9
68
|
type: 98,
|
@@ -46,6 +105,8 @@ module DjiMqttConnect
|
|
46
105
|
)
|
47
106
|
end
|
48
107
|
|
108
|
+
# Requests
|
109
|
+
|
49
110
|
def build_thing_product_config_requests_message
|
50
111
|
message_data = {
|
51
112
|
config_type: "json",
|
@@ -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 EventsReplyMarshal < 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
|
@@ -15,12 +15,15 @@ module DjiMqttConnect
|
|
15
15
|
|
16
16
|
attribute :sub_devices, Types::Array do
|
17
17
|
attribute :sn, Types::String
|
18
|
+
attribute? :domain, Types::DeviceDomain
|
18
19
|
attribute :type, Types::DeviceType
|
19
20
|
attribute :sub_type, Types::DeviceSubType
|
20
21
|
attribute :index, Types::String
|
21
22
|
attribute :device_secret, Types::String
|
22
23
|
attribute :nonce, Types::String
|
23
24
|
attribute? :version, Types::Integer
|
25
|
+
|
26
|
+
alias_method :serial_number, :sn
|
24
27
|
end
|
25
28
|
end
|
26
29
|
end
|
@@ -11,6 +11,9 @@ module DjiMqttConnect
|
|
11
11
|
job_number
|
12
12
|
]
|
13
13
|
|
14
|
+
# {"0":"Idle mode (No cooling, heating, and dehumidification)","1":"Cooling mode","2":"Heating mode","3":"Dehumidification mode","4":"Cooling exit mode","5":"Heating exit mode","6":"Dehumidification exit mode","7":"Cooling preparation mode","8":"Heating preparation mode","9":"Dehumidification preparation mode"}
|
15
|
+
AirConditionerState = Types::Integer.enum(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
|
16
|
+
|
14
17
|
attribute :data do
|
15
18
|
include Mixins::LatitudeConditional
|
16
19
|
include Mixins::LongitudeConditional
|
@@ -152,9 +155,12 @@ module DjiMqttConnect
|
|
152
155
|
attribute? :mode_code, Types::Integer.enum(0, 1, 2, 3, 4)
|
153
156
|
|
154
157
|
attribute? :air_conditioner do
|
155
|
-
|
156
|
-
attribute :air_conditioner_state, Types::Integer.enum(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
|
158
|
+
attribute :air_conditioner_state, AirConditionerState | Types::Integer
|
157
159
|
attribute :switch_time, Types::Integer
|
160
|
+
|
161
|
+
def air_conditioner_state?
|
162
|
+
AirConditionerState.valid?(air_conditioner_state)
|
163
|
+
end
|
158
164
|
end
|
159
165
|
|
160
166
|
# {"0":"Closed","1":"Opened"}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DjiMqttConnect
|
4
|
+
module Thing::Product
|
5
|
+
# https://developer.dji.com/doc/cloud-api-tutorial/en/server-api-reference/mqtt/topic-definition.html#events-reply-struct-example
|
6
|
+
class EventsReplyMessage < Message
|
7
|
+
# a result of 0 means we approve of this action
|
8
|
+
def self.build_for(events_message, result: 0)
|
9
|
+
new(
|
10
|
+
_method: events_message._method,
|
11
|
+
tid: events_message.tid,
|
12
|
+
bid: events_message.bid,
|
13
|
+
timestamp: Time.now.strftime("%s%L").to_i,
|
14
|
+
data: {
|
15
|
+
result: result
|
16
|
+
}
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
attribute :bid, Types::UUID
|
21
|
+
attribute :tid, Types::UUID
|
22
|
+
attribute :timestamp, Types::Timestamp
|
23
|
+
|
24
|
+
attribute :_method, Types::String.enum(
|
25
|
+
"file_upload_callback",
|
26
|
+
"highest_priority_upload_flighttask_media"
|
27
|
+
)
|
28
|
+
|
29
|
+
attribute :data do
|
30
|
+
attribute :result, Types::Integer
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DjiMqttConnect
|
4
|
+
module Thing::Product
|
5
|
+
class HighestPriorityUploadFlighttaskMediaEventsMessage < EventsMessage
|
6
|
+
attribute :_method, Types::String.enum("highest_priority_upload_flighttask_media")
|
7
|
+
|
8
|
+
# NOTE: Not documented, but appears in examples
|
9
|
+
attribute? :need_reply, Types::Integer.enum(0, 1)
|
10
|
+
|
11
|
+
attribute :data do
|
12
|
+
attribute :flight_id, Types::String
|
13
|
+
end
|
14
|
+
|
15
|
+
def need_reply?
|
16
|
+
need_reply == 1
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DjiMqttConnect
|
4
|
+
module Thing::Product
|
5
|
+
class EventsReplyTopicRepository < TopicRepository
|
6
|
+
# Publishes a message to gateway_sn on the "thing/product/+/events_reply" topic.
|
7
|
+
def publish_to_device(gateway_sn, events_reply_message)
|
8
|
+
publish_to_topic(
|
9
|
+
"thing/product/#{gateway_sn}/events_reply",
|
10
|
+
events_reply_message,
|
11
|
+
marshal: EventsReplyMarshal
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/dji_mqtt_connect.rb
CHANGED
@@ -35,10 +35,13 @@ module DjiMqttConnect
|
|
35
35
|
module Product
|
36
36
|
# Messages
|
37
37
|
autoload :FileUploadCallbackEventsMessage, "dji_mqtt_connect/messages/thing/product/file_upload_callback_events_message"
|
38
|
+
autoload :HighestPriorityUploadFlighttaskMediaEventsMessage, "dji_mqtt_connect/messages/thing/product/highest_priority_upload_flighttask_media_events_message"
|
38
39
|
autoload :HmsEventsMessage, "dji_mqtt_connect/messages/thing/product/hms_events_message"
|
39
40
|
autoload :StatusCodeEventsMessage, "dji_mqtt_connect/messages/thing/product/status_code_events_message"
|
40
41
|
autoload :EventsMessage, "dji_mqtt_connect/messages/thing/product/events_message"
|
41
42
|
|
43
|
+
autoload :EventsReplyMessage, "dji_mqtt_connect/messages/thing/product/events_reply_message"
|
44
|
+
|
42
45
|
autoload :OsdMessage, "dji_mqtt_connect/messages/thing/product/osd_message"
|
43
46
|
autoload :DockOsdMessage, "dji_mqtt_connect/messages/thing/product/dock_osd_message"
|
44
47
|
autoload :DroneOsdMessage, "dji_mqtt_connect/messages/thing/product/drone_osd_message"
|
@@ -59,12 +62,14 @@ module DjiMqttConnect
|
|
59
62
|
|
60
63
|
# Topics
|
61
64
|
autoload :EventsTopicRepository, "dji_mqtt_connect/topics/thing/product/events"
|
65
|
+
autoload :EventsReplyTopicRepository, "dji_mqtt_connect/topics/thing/product/events_reply"
|
62
66
|
autoload :OsdTopicRepository, "dji_mqtt_connect/topics/thing/product/osd"
|
63
67
|
autoload :RequestsTopicRepository, "dji_mqtt_connect/topics/thing/product/requests"
|
64
68
|
autoload :RequestsReplyTopicRepository, "dji_mqtt_connect/topics/thing/product/requests_reply"
|
65
69
|
|
66
70
|
# Marshals
|
67
71
|
autoload :EventsMarshal, "dji_mqtt_connect/marshals/thing/product/events_marshal"
|
72
|
+
autoload :EventsReplyMarshal, "dji_mqtt_connect/marshals/thing/product/events_reply_marshal"
|
68
73
|
|
69
74
|
autoload :OsdMarshal, "dji_mqtt_connect/marshals/thing/product/osd_marshal"
|
70
75
|
|
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.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sphere Drones
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-25 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/marshals/sys/product/status_marshal.rb
|
114
114
|
- lib/dji_mqtt_connect/marshals/sys/product/status_reply_marshal.rb
|
115
115
|
- lib/dji_mqtt_connect/marshals/thing/product/events_marshal.rb
|
116
|
+
- lib/dji_mqtt_connect/marshals/thing/product/events_reply_marshal.rb
|
116
117
|
- lib/dji_mqtt_connect/marshals/thing/product/osd_marshal.rb
|
117
118
|
- lib/dji_mqtt_connect/marshals/thing/product/requests_marshal.rb
|
118
119
|
- lib/dji_mqtt_connect/marshals/thing/product/requests_reply_marshal.rb
|
@@ -132,7 +133,9 @@ files:
|
|
132
133
|
- lib/dji_mqtt_connect/messages/thing/product/dock_osd_message.rb
|
133
134
|
- lib/dji_mqtt_connect/messages/thing/product/drone_osd_message.rb
|
134
135
|
- lib/dji_mqtt_connect/messages/thing/product/events_message.rb
|
136
|
+
- lib/dji_mqtt_connect/messages/thing/product/events_reply_message.rb
|
135
137
|
- lib/dji_mqtt_connect/messages/thing/product/file_upload_callback_events_message.rb
|
138
|
+
- lib/dji_mqtt_connect/messages/thing/product/highest_priority_upload_flighttask_media_events_message.rb
|
136
139
|
- lib/dji_mqtt_connect/messages/thing/product/hms_events_message.rb
|
137
140
|
- lib/dji_mqtt_connect/messages/thing/product/osd_message.rb
|
138
141
|
- lib/dji_mqtt_connect/messages/thing/product/remote_osd_message.rb
|
@@ -149,6 +152,7 @@ files:
|
|
149
152
|
- lib/dji_mqtt_connect/topics/sys/product/status.rb
|
150
153
|
- lib/dji_mqtt_connect/topics/sys/product/status_reply.rb
|
151
154
|
- lib/dji_mqtt_connect/topics/thing/product/events.rb
|
155
|
+
- lib/dji_mqtt_connect/topics/thing/product/events_reply.rb
|
152
156
|
- lib/dji_mqtt_connect/topics/thing/product/osd.rb
|
153
157
|
- lib/dji_mqtt_connect/topics/thing/product/requests.rb
|
154
158
|
- lib/dji_mqtt_connect/topics/thing/product/requests_reply.rb
|