dji_mqtt_connect 0.1.6 → 0.1.8
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 +2 -2
- data/lib/dji_mqtt_connect/factories.rb +44 -0
- data/lib/dji_mqtt_connect/messages/thing/product/airport_organization_bind_requests_message.rb +22 -0
- data/lib/dji_mqtt_connect/messages/thing/product/airport_organization_bind_requests_reply_message.rb +37 -0
- data/lib/dji_mqtt_connect/messages/thing/product/file_upload_callback_events_message.rb +56 -0
- data/lib/dji_mqtt_connect/version.rb +1 -1
- data/lib/dji_mqtt_connect.rb +4 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a011ad0cc1d0fa6ac5a2a46ca0b2189d019021689b4b28aba9487a7dfd5b0b04
|
4
|
+
data.tar.gz: 4e963910473c5cba3ef2052c6cfc1b1d0c1f4e4a5053a10981f67ee52b925068
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92607be71eb3fa9ae96075a1f1a95ec0badea279ca788be9f9b6ad3a032837026a75cae52e9a80174f117e4cccd06d4dddaaf9a11a1a643d7062ad9426c25cf4
|
7
|
+
data.tar.gz: 1ddc4e521211e8e226fcf1987dad023dcb425e00337f4c4c181eb9cd216215ba370a210667d5256f1943e5f0b7cf27af05c9932222dd1715999429527055341d
|
data/Gemfile.lock
CHANGED
@@ -6,7 +6,7 @@ module DjiMqttConnect
|
|
6
6
|
# Client for communicating with DJI Cloud API MQTT Messages
|
7
7
|
# see: https://developer.dji.com/doc/cloud-api-tutorial/en/server-api-reference/mqtt/topic-definition.html
|
8
8
|
class Client
|
9
|
-
def self.build(mqtt_address, username:, password:, &block)
|
9
|
+
def self.build(mqtt_address, username:, password:, client_name: DjiMqttConnect.client_name, &block)
|
10
10
|
mqtt_url = URI.parse(mqtt_address)
|
11
11
|
mqtt_host = mqtt_url.host
|
12
12
|
mqtt_port = mqtt_url.port.to_i
|
@@ -18,7 +18,7 @@ module DjiMqttConnect
|
|
18
18
|
mqtt_client = MQTT::Client.connect(
|
19
19
|
host: mqtt_host,
|
20
20
|
port: mqtt_port,
|
21
|
-
client_id:
|
21
|
+
client_id: MQTT::Client.generate_client_id(client_name),
|
22
22
|
username: username,
|
23
23
|
password: password,
|
24
24
|
ssl: !%w[tcp mqtt ws].include?(mqtt_scheme)
|
@@ -115,6 +115,50 @@ module DjiMqttConnect
|
|
115
115
|
)
|
116
116
|
end
|
117
117
|
|
118
|
+
def build_thing_product_airport_organization_bind_requests_message
|
119
|
+
message_data = {
|
120
|
+
bind_devices: [
|
121
|
+
{
|
122
|
+
device_binding_code: "",
|
123
|
+
organization_id: "curo",
|
124
|
+
device_callsign: "",
|
125
|
+
sn: "DOCK01",
|
126
|
+
device_secret: "DEVICE_SECRET",
|
127
|
+
device_nonce: "DEVICE_NONCE",
|
128
|
+
device_model_key: "3-1-0"
|
129
|
+
},
|
130
|
+
{
|
131
|
+
device_binding_code: "",
|
132
|
+
organization_id: "curo",
|
133
|
+
device_callsign: "",
|
134
|
+
sn: "M30DRONE01",
|
135
|
+
device_secret: "DEVICE_SECRET",
|
136
|
+
device_nonce: "DEVICE_NONCE",
|
137
|
+
device_model_key: "0-67-0"
|
138
|
+
}
|
139
|
+
]
|
140
|
+
}
|
141
|
+
|
142
|
+
Thing::Product::AirportOrganizationBindRequestsMessage.new(
|
143
|
+
_method: "airport_organization_bind",
|
144
|
+
_data: message_data,
|
145
|
+
tid: "3093aad5-bb98-5026-685a-cea540eb9267",
|
146
|
+
bid: "479533e0-cb01-933c-3758-22f2a82abeb8",
|
147
|
+
timestamp: 1679380233000,
|
148
|
+
data: message_data,
|
149
|
+
gateway: "DOCK01"
|
150
|
+
)
|
151
|
+
end
|
152
|
+
|
153
|
+
def build_thing_product_airport_organization_bind_requests_reply_message
|
154
|
+
airport_organization_bind_request = build_thing_product_airport_organization_bind_requests_message
|
155
|
+
|
156
|
+
Thing::Product::AirportOrganizationBindRequestsReplyMessage.build_for(
|
157
|
+
airport_organization_bind_request,
|
158
|
+
result: 0
|
159
|
+
)
|
160
|
+
end
|
161
|
+
|
118
162
|
def build_thing_product_airport_organization_get_requests_message
|
119
163
|
message_data = {
|
120
164
|
device_binding_code: "device_binding_code",
|
data/lib/dji_mqtt_connect/messages/thing/product/airport_organization_bind_requests_message.rb
ADDED
@@ -0,0 +1,22 @@
|
|
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/thing-model/gateway/dock/organization.html#device-bind-to-organization
|
6
|
+
class AirportOrganizationBindRequestsMessage < RequestsMessage
|
7
|
+
attribute :_method, Types::String.enum("airport_organization_bind")
|
8
|
+
|
9
|
+
attribute :data do
|
10
|
+
attribute :bind_devices, Types::Array do
|
11
|
+
attribute :device_binding_code, Types::String
|
12
|
+
attribute :organization_id, Types::String
|
13
|
+
attribute :device_callsign, Types::String
|
14
|
+
attribute :sn, Types::String
|
15
|
+
attribute :device_model_key, Types::String
|
16
|
+
attribute :device_nonce, Types::String
|
17
|
+
attribute :device_secret, Types::String
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/dji_mqtt_connect/messages/thing/product/airport_organization_bind_requests_reply_message.rb
ADDED
@@ -0,0 +1,37 @@
|
|
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/thing-model/gateway/dock/organization.html#device-bind-to-organization
|
6
|
+
class AirportOrganizationBindRequestsReplyMessage < Message
|
7
|
+
def self.build_for(airport_organization_bind_message, err_infos: [], result: 0)
|
8
|
+
new(
|
9
|
+
_method: airport_organization_bind_message._method,
|
10
|
+
tid: airport_organization_bind_message.tid,
|
11
|
+
bid: airport_organization_bind_message.bid,
|
12
|
+
timestamp: Time.now.strftime("%s%L").to_i,
|
13
|
+
data: {
|
14
|
+
result: result,
|
15
|
+
err_infos: err_infos
|
16
|
+
}
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
attribute :tid, Types::UUID
|
21
|
+
attribute :bid, Types::UUID
|
22
|
+
attribute :timestamp, Types::Timestamp
|
23
|
+
|
24
|
+
attribute :_method, Types::String.enum("airport_organization_bind")
|
25
|
+
|
26
|
+
attribute :data do
|
27
|
+
attribute :result, Types::Integer
|
28
|
+
attribute :err_infos, Types::Array do
|
29
|
+
attribute :sn, Types::String
|
30
|
+
|
31
|
+
# Custom field. Non-zero indicates that the bind was unsuccessful.
|
32
|
+
attribute :err_code, Types::Integer
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DjiMqttConnect
|
4
|
+
module Thing::Product
|
5
|
+
class FileUploadCallbackEventsMessage < EventsMessage
|
6
|
+
attribute :_method, Types::String.enum("file_upload_callback")
|
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 :file do
|
13
|
+
attribute :object_key, Types::String
|
14
|
+
|
15
|
+
attribute :path, Types::String
|
16
|
+
|
17
|
+
attribute :name, Types::String
|
18
|
+
|
19
|
+
attribute :ext do
|
20
|
+
attribute :flight_id, Types::String
|
21
|
+
|
22
|
+
attribute :drone_model_key, Types::String
|
23
|
+
|
24
|
+
attribute :payload_model_key, Types::String
|
25
|
+
|
26
|
+
# {"0":"No","1":"Yes"}
|
27
|
+
attribute :is_original, Types::Bool
|
28
|
+
end
|
29
|
+
|
30
|
+
attribute :metadata do
|
31
|
+
attribute :gimbal_yaw_degree, Types::JSON::Decimal
|
32
|
+
|
33
|
+
attribute :absolute_altitude, Types::JSON::Decimal
|
34
|
+
|
35
|
+
attribute :relative_altitude, Types::JSON::Decimal
|
36
|
+
|
37
|
+
attribute :created_time, Types::JSON::DateTime
|
38
|
+
|
39
|
+
attribute :shoot_position do
|
40
|
+
include Mixins::LatitudeConditional
|
41
|
+
include Mixins::LongitudeConditional
|
42
|
+
|
43
|
+
attribute :lat, Types::Latitude
|
44
|
+
attribute :lng, Types::Longitude
|
45
|
+
|
46
|
+
alias_method :latitude, :lat
|
47
|
+
alias_method :longitude, :lng
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
attribute :result, Types::Integer
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/dji_mqtt_connect.rb
CHANGED
@@ -33,6 +33,7 @@ module DjiMqttConnect
|
|
33
33
|
module Thing
|
34
34
|
module Product
|
35
35
|
# Messages
|
36
|
+
autoload :FileUploadCallbackEventsMessage, "dji_mqtt_connect/messages/thing/product/file_upload_callback_events_message"
|
36
37
|
autoload :HmsEventsMessage, "dji_mqtt_connect/messages/thing/product/hms_events_message"
|
37
38
|
autoload :StatusCodeEventsMessage, "dji_mqtt_connect/messages/thing/product/status_code_events_message"
|
38
39
|
autoload :EventsMessage, "dji_mqtt_connect/messages/thing/product/events_message"
|
@@ -43,12 +44,14 @@ module DjiMqttConnect
|
|
43
44
|
autoload :RemoteOsdMessage, "dji_mqtt_connect/messages/thing/product/remote_osd_message"
|
44
45
|
|
45
46
|
autoload :AirportBindStatusRequestsMessage, "dji_mqtt_connect/messages/thing/product/airport_bind_status_requests_message"
|
47
|
+
autoload :AirportOrganizationBindRequestsMessage, "dji_mqtt_connect/messages/thing/product/airport_organization_bind_requests_message"
|
46
48
|
autoload :AirportOrganizationGetRequestsMessage, "dji_mqtt_connect/messages/thing/product/airport_organization_get_requests_message"
|
47
49
|
autoload :ConfigRequestsMessage, "dji_mqtt_connect/messages/thing/product/config_requests_message"
|
48
50
|
autoload :StorageConfigGetRequestsMessage, "dji_mqtt_connect/messages/thing/product/storage_config_get_requests_message"
|
49
51
|
autoload :RequestsMessage, "dji_mqtt_connect/messages/thing/product/requests_message"
|
50
52
|
|
51
53
|
autoload :AirportBindStatusRequestsReplyMessage, "dji_mqtt_connect/messages/thing/product/airport_bind_status_requests_reply_message"
|
54
|
+
autoload :AirportOrganizationBindRequestsReplyMessage, "dji_mqtt_connect/messages/thing/product/airport_organization_bind_requests_reply_message"
|
52
55
|
autoload :AirportOrganizationGetRequestsReplyMessage, "dji_mqtt_connect/messages/thing/product/airport_organization_get_requests_reply_message"
|
53
56
|
autoload :ConfigRequestsReplyMessage, "dji_mqtt_connect/messages/thing/product/config_requests_reply_message"
|
54
57
|
autoload :StorageConfigGetRequestsReplyMessage, "dji_mqtt_connect/messages/thing/product/storage_config_get_requests_reply_message"
|
@@ -89,7 +92,7 @@ module DjiMqttConnect
|
|
89
92
|
autoload :MessageSerializer, "dji_mqtt_connect/railties/message_serializer"
|
90
93
|
end
|
91
94
|
|
92
|
-
cattr_accessor :
|
95
|
+
cattr_accessor :client_name, default: name
|
93
96
|
cattr_accessor :logger, default: ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new($stdout)).tap { |logger| logger.level = Logger::INFO }
|
94
97
|
end
|
95
98
|
|
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.8
|
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-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -121,6 +121,8 @@ files:
|
|
121
121
|
- lib/dji_mqtt_connect/messages/sys/product/update_topo_status_reply_message.rb
|
122
122
|
- lib/dji_mqtt_connect/messages/thing/product/airport_bind_status_requests_message.rb
|
123
123
|
- lib/dji_mqtt_connect/messages/thing/product/airport_bind_status_requests_reply_message.rb
|
124
|
+
- lib/dji_mqtt_connect/messages/thing/product/airport_organization_bind_requests_message.rb
|
125
|
+
- lib/dji_mqtt_connect/messages/thing/product/airport_organization_bind_requests_reply_message.rb
|
124
126
|
- lib/dji_mqtt_connect/messages/thing/product/airport_organization_get_requests_message.rb
|
125
127
|
- lib/dji_mqtt_connect/messages/thing/product/airport_organization_get_requests_reply_message.rb
|
126
128
|
- lib/dji_mqtt_connect/messages/thing/product/config_requests_message.rb
|
@@ -128,6 +130,7 @@ files:
|
|
128
130
|
- lib/dji_mqtt_connect/messages/thing/product/dock_osd_message.rb
|
129
131
|
- lib/dji_mqtt_connect/messages/thing/product/drone_osd_message.rb
|
130
132
|
- lib/dji_mqtt_connect/messages/thing/product/events_message.rb
|
133
|
+
- lib/dji_mqtt_connect/messages/thing/product/file_upload_callback_events_message.rb
|
131
134
|
- lib/dji_mqtt_connect/messages/thing/product/hms_events_message.rb
|
132
135
|
- lib/dji_mqtt_connect/messages/thing/product/osd_message.rb
|
133
136
|
- lib/dji_mqtt_connect/messages/thing/product/remote_osd_message.rb
|