dji_mqtt_connect 0.1.10 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (23) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +6 -6
  3. data/lib/dji_mqtt_connect/client.rb +5 -0
  4. data/lib/dji_mqtt_connect/factories.rb +137 -27
  5. data/lib/dji_mqtt_connect/marshals/thing/product/services_marshal.rb +34 -0
  6. data/lib/dji_mqtt_connect/message.rb +13 -0
  7. data/lib/dji_mqtt_connect/messages/sys/product/update_topo_status_reply_message.rb +4 -4
  8. data/lib/dji_mqtt_connect/messages/thing/product/airport_bind_status_requests_reply_message.rb +1 -1
  9. data/lib/dji_mqtt_connect/messages/thing/product/airport_organization_bind_requests_reply_message.rb +1 -1
  10. data/lib/dji_mqtt_connect/messages/thing/product/airport_organization_get_requests_reply_message.rb +1 -1
  11. data/lib/dji_mqtt_connect/messages/thing/product/config_requests_reply_message.rb +1 -1
  12. data/lib/dji_mqtt_connect/messages/thing/product/cover_close_services_message.rb +23 -0
  13. data/lib/dji_mqtt_connect/messages/thing/product/cover_open_services_message.rb +23 -0
  14. data/lib/dji_mqtt_connect/messages/thing/product/events_reply_message.rb +2 -1
  15. data/lib/dji_mqtt_connect/messages/thing/product/fileupload_list_services_message.rb +28 -0
  16. data/lib/dji_mqtt_connect/messages/thing/product/fileupload_progress_events_message.rb +44 -0
  17. data/lib/dji_mqtt_connect/messages/thing/product/fileupload_start_services_message.rb +48 -0
  18. data/lib/dji_mqtt_connect/messages/thing/product/storage_config_get_requests_reply_message.rb +1 -1
  19. data/lib/dji_mqtt_connect/topics/thing/product/services.rb +16 -0
  20. data/lib/dji_mqtt_connect/utils/message_sanitizer.rb +11 -1
  21. data/lib/dji_mqtt_connect/version.rb +1 -1
  22. data/lib/dji_mqtt_connect.rb +9 -0
  23. metadata +9 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: acdbcd3a64661ee53c4a9cc75d4e059eed52a3ab3eb6f19e9b7dc9beca46d18f
4
- data.tar.gz: de8b3c76bf634c59efceaf9a57a1fb6db4b7559b9a10ec8e045f69f6c986d529
3
+ metadata.gz: 23d05154788cc817a44ef2f2a275aaafe5f74b5b4ddaee53e428cc8a337bc949
4
+ data.tar.gz: 883c60b3a65b16b203d75eebdf68e7883a2e720aaba767be12f95b00a8b32b1a
5
5
  SHA512:
6
- metadata.gz: 7fb2327163be78ae6f9ca5ac162f390a89a14368063651857a49b3534147b730d2b1136eb5b490848487a75c65b9cbccae65223967d2dbe7dac79c15e2c50946
7
- data.tar.gz: 28648d5e4c19f0d6016cfd73e1af08dd9d7cc54f25fd4c1ac09aab860969d22cc0a64dc94f6acb90bf5e48ab41fc05d0ff253a32706b01db4aeb10f94047e467
6
+ metadata.gz: 95344951cae7502cd594263fe73bfffa600cdf695525a65d82e88380843d5997b9b6d08d069893a25519a39d0da33739cd84bce1ee399e2ecb00b9b056dbc8a8
7
+ data.tar.gz: e25271e968797ca94f94a07366e86c14c21de6ad6df480fc4a500d8027c2aeab7b6540ec6a28ab864234c29c71f1dea3ae823cdb05786fccf7c0612b1da7058e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dji_mqtt_connect (0.1.10)
4
+ dji_mqtt_connect (0.1.12)
5
5
  activesupport (>= 6.0, <= 8)
6
6
  dry-struct (~> 1.6)
7
7
  dry-transformer (~> 1.0)
@@ -11,10 +11,10 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- activejob (7.0.4.3)
15
- activesupport (= 7.0.4.3)
14
+ activejob (7.0.5)
15
+ activesupport (= 7.0.5)
16
16
  globalid (>= 0.3.6)
17
- activesupport (7.0.4.3)
17
+ activesupport (7.0.5)
18
18
  concurrent-ruby (~> 1.0, >= 1.0.2)
19
19
  i18n (>= 1.6, < 2)
20
20
  minitest (>= 5.1)
@@ -88,7 +88,7 @@ GEM
88
88
  parser (>= 3.2.1.0)
89
89
  rubocop-capybara (2.18.0)
90
90
  rubocop (~> 1.41)
91
- rubocop-factory_bot (2.22.0)
91
+ rubocop-factory_bot (2.23.1)
92
92
  rubocop (~> 1.33)
93
93
  rubocop-performance (1.16.0)
94
94
  rubocop (>= 1.7.0, < 2.0)
@@ -106,7 +106,7 @@ GEM
106
106
  simplecov_json_formatter (~> 0.1)
107
107
  simplecov-html (0.12.3)
108
108
  simplecov_json_formatter (0.1.4)
109
- standard (1.28.2)
109
+ standard (1.28.4)
110
110
  language_server-protocol (~> 3.17.0.2)
111
111
  lint_roller (~> 1.0)
112
112
  rubocop (~> 1.50.2)
@@ -66,6 +66,11 @@ module DjiMqttConnect
66
66
  Thing::Product::RequestsReplyTopicRepository.new(self)
67
67
  end
68
68
 
69
+ # Handles topic thing/product/#{pid}/services
70
+ def thing_product_services_topic
71
+ Thing::Product::ServicesTopicRepository.new(self)
72
+ end
73
+
69
74
  attr_reader :mqtt_client
70
75
  end
71
76
  end
@@ -34,29 +34,83 @@ module DjiMqttConnect
34
34
 
35
35
  Thing::Product::FileUploadCallbackEventsMessage.new(
36
36
  _method: "file_upload_callback",
37
- bid: "12345678-1234-1234-1234-12345678901B",
38
- tid: "12345678-1234-1234-1234-12345678901A",
37
+ bid: Message.generate_bid,
38
+ tid: Message.generate_tid,
39
39
  need_reply: 1,
40
40
  gateway: "xxx",
41
- timestamp: 1654070968655,
41
+ timestamp: Message.current_timestamp,
42
42
  data: message_data,
43
43
  _data: message_data
44
44
  )
45
45
  end
46
46
 
47
+ def build_fileupload_progress_events_message
48
+ message_data = {
49
+ output: {
50
+ ext: {
51
+ files: [
52
+ {
53
+ module: "0",
54
+ size: 155232,
55
+ device_sn: "drone_sn",
56
+ key: "4bf0039f-6434-44a8-b891-8d7b6b7ff138/drone_sn/video_20220621_110830.log",
57
+ fingerprint: "4f65b891f3bc09bdb6d4c36a996b532d",
58
+ progress: {
59
+ current_step: 19,
60
+ prgress: 100,
61
+ finish_time: 1655781395926,
62
+ upload_rate: 0,
63
+ result: 0,
64
+ status: "ok"
65
+ }
66
+ },
67
+ {
68
+ module: "3",
69
+ size: 155232,
70
+ device_sn: "dock_sn",
71
+ key: "4bf0039f-6434-44a8-b891-8d7b6b7ff138/dock_sn/video_20220621_110830.log",
72
+ fingerprint: "4f65b891f3bc09bdb6d4c36a996b532d",
73
+ progress: {
74
+ current_step: 19,
75
+ total_step: 30,
76
+ prgress: 100,
77
+ finish_time: 1655781395926,
78
+ upload_rate: 0,
79
+ result: 0,
80
+ status: "ok"
81
+ }
82
+ }
83
+ ]
84
+ },
85
+ status: "ok"
86
+ }
87
+ }
88
+
89
+ Thing::Product::FileuploadProgressEventsMessage.new(
90
+ _method: "fileupload_progress",
91
+ need_reply: 0,
92
+ bid: Message.generate_bid,
93
+ tid: Message.generate_tid,
94
+ timestamp: Message.current_timestamp,
95
+ gateway: "dock_sn",
96
+ _data: message_data,
97
+ data: message_data
98
+ )
99
+ end
100
+
47
101
  def build_highest_priority_upload_flighttask_media_events_message
48
102
  message_data = {
49
103
  flight_id: SecureRandom.uuid
50
104
  }
51
105
 
52
106
  Thing::Product::HighestPriorityUploadFlighttaskMediaEventsMessage.new(
53
- bid: "fe0e2218-038f-46fe-b27d-74cd257c386a",
107
+ bid: Message.generate_bid,
54
108
  _data: message_data,
55
109
  data: message_data,
56
110
  _method: "highest_priority_upload_flighttask_media",
57
111
  need_reply: 1,
58
- tid: "c6aa22c0-e9dd-4895-a25c-6c12411513df",
59
- timestamp: 1684986146586,
112
+ tid: Message.generate_tid,
113
+ timestamp: Message.current_timestamp,
60
114
  gateway: "DOCK01"
61
115
  )
62
116
  end
@@ -85,9 +139,9 @@ module DjiMqttConnect
85
139
 
86
140
  Sys::Product::UpdateTopoStatusMessage.new(
87
141
  _method: "update_topo",
88
- tid: "12345678-1234-1234-1234-A00000000001",
89
- bid: "12345678-1234-1234-1234-B00000000001",
90
- timestamp: 1234567890123,
142
+ tid: Message.generate_tid,
143
+ bid: Message.generate_bid,
144
+ timestamp: Message.current_timestamp,
91
145
  data: message_data,
92
146
  _data: message_data.deep_stringify_keys
93
147
  )
@@ -96,9 +150,9 @@ module DjiMqttConnect
96
150
  def build_update_topo_status_reply_message
97
151
  Sys::Product::UpdateTopoStatusReplyMessage.new(
98
152
  _method: "update_topo",
99
- tid: "3093aad5-bb98-5026-685a-cea540eb9267",
100
- bid: "479533e0-cb01-933c-3758-22f2a82abeb8",
101
- timestamp: 1679380233000,
153
+ tid: Message.generate_tid,
154
+ bid: Message.generate_bid,
155
+ timestamp: Message.current_timestamp,
102
156
  data: {
103
157
  result: 0
104
158
  }
@@ -115,9 +169,9 @@ module DjiMqttConnect
115
169
 
116
170
  Thing::Product::ConfigRequestsMessage.new(
117
171
  _method: "config",
118
- tid: "3093aad5-bb98-5026-685a-cea540eb9267",
119
- bid: "479533e0-cb01-933c-3758-22f2a82abeb8",
120
- timestamp: 1679380233000,
172
+ tid: Message.generate_tid,
173
+ bid: Message.generate_bid,
174
+ timestamp: Message.current_timestamp,
121
175
  gateway: "gatewaysn",
122
176
  data: message_data,
123
177
  _data: message_data.deep_stringify_keys
@@ -151,9 +205,9 @@ module DjiMqttConnect
151
205
  Thing::Product::AirportBindStatusRequestsMessage.new(
152
206
  _method: "airport_bind_status",
153
207
  _data: message_data,
154
- tid: "3093aad5-bb98-5026-685a-cea540eb9267",
155
- bid: "479533e0-cb01-933c-3758-22f2a82abeb8",
156
- timestamp: 1679380233000,
208
+ tid: Message.generate_tid,
209
+ bid: Message.generate_bid,
210
+ timestamp: Message.current_timestamp,
157
211
  data: message_data
158
212
  )
159
213
  end
@@ -203,9 +257,9 @@ module DjiMqttConnect
203
257
  Thing::Product::AirportOrganizationBindRequestsMessage.new(
204
258
  _method: "airport_organization_bind",
205
259
  _data: message_data,
206
- tid: "3093aad5-bb98-5026-685a-cea540eb9267",
207
- bid: "479533e0-cb01-933c-3758-22f2a82abeb8",
208
- timestamp: 1679380233000,
260
+ tid: Message.generate_tid,
261
+ bid: Message.generate_bid,
262
+ timestamp: Message.current_timestamp,
209
263
  data: message_data,
210
264
  gateway: "DOCK01"
211
265
  )
@@ -229,9 +283,9 @@ module DjiMqttConnect
229
283
  Thing::Product::AirportOrganizationGetRequestsMessage.new(
230
284
  _method: "airport_organization_get",
231
285
  _data: message_data,
232
- tid: "3093aad5-bb98-5026-685a-cea540eb9267",
233
- bid: "479533e0-cb01-933c-3758-22f2a82abeb8",
234
- timestamp: 1679380233000,
286
+ tid: Message.generate_tid,
287
+ bid: Message.generate_bid,
288
+ timestamp: Message.current_timestamp,
235
289
  data: message_data
236
290
  )
237
291
  end
@@ -256,9 +310,9 @@ module DjiMqttConnect
256
310
  Thing::Product::StorageConfigGetRequestsMessage.new(
257
311
  _method: "storage_config_get",
258
312
  _data: message_data,
259
- tid: "3093aad5-bb98-5026-685a-cea540eb9267",
260
- bid: "479533e0-cb01-933c-3758-22f2a82abeb8",
261
- timestamp: 1679380233000,
313
+ tid: Message.generate_tid,
314
+ bid: Message.generate_bid,
315
+ timestamp: Message.current_timestamp,
262
316
  data: message_data
263
317
  )
264
318
  end
@@ -284,5 +338,61 @@ module DjiMqttConnect
284
338
  }
285
339
  )
286
340
  end
341
+
342
+ # Services
343
+
344
+ def build_thing_product_cover_close_services_message
345
+ Thing::Product::CoverCloseServicesMessage.build
346
+ end
347
+
348
+ def build_thing_product_cover_open_services_message
349
+ Thing::Product::CoverOpenServicesMessage.build
350
+ end
351
+
352
+ def build_thing_product_fileupload_list_services_message
353
+ Thing::Product::FileuploadListServicesMessage.build(
354
+ module_list: [0, 3]
355
+ )
356
+ end
357
+
358
+ def build_thing_product_fileupload_start_services_message
359
+ timestamp = Message.current_timestamp
360
+ Thing::Product::FileuploadStartServicesMessage.build(
361
+ data: {
362
+ bucket: "stg-dji-service-hz-ksd7",
363
+ region: "hz",
364
+ credentials: {
365
+ access_key_id: "STS.access_key_id",
366
+ access_key_secret: "access_key_secret",
367
+ expire: 3600,
368
+ security_token: "security_token"
369
+ },
370
+ endpoint: "https://oss-cn-hangzhou.aliyuncs.com",
371
+ params: {
372
+ files: [
373
+ {
374
+ list: [
375
+ {
376
+ boot_index: 1111,
377
+ end_time: timestamp - 3000,
378
+ size: 33789,
379
+ start_time: timestamp - 4000
380
+ },
381
+ {
382
+ boot_index: 22222,
383
+ end_time: timestamp - 1000,
384
+ size: 33789,
385
+ start_time: timestamp - 2000
386
+ }
387
+ ],
388
+ module: "3",
389
+ object_key: "object_key"
390
+ }
391
+ ]
392
+ },
393
+ provider: "ali"
394
+ }
395
+ )
396
+ end
287
397
  end
288
398
  end
@@ -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 ServicesMarshal < 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
@@ -1,11 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "dry-struct"
4
+ require "securerandom"
4
5
 
5
6
  module DjiMqttConnect
6
7
  class Message < Dry::Struct
7
8
  transform_keys(&:to_sym)
8
9
 
10
+ def self.current_timestamp
11
+ Integer(Time.now.strftime("%s%L"))
12
+ end
13
+
14
+ def self.generate_bid
15
+ SecureRandom.uuid
16
+ end
17
+
18
+ def self.generate_tid
19
+ SecureRandom.uuid
20
+ end
21
+
9
22
  def to_s
10
23
  self.class.name
11
24
  end
@@ -10,7 +10,7 @@ module DjiMqttConnect
10
10
  _method: update_topo_status_message._method,
11
11
  tid: update_topo_status_message.tid,
12
12
  bid: update_topo_status_message.bid,
13
- timestamp: Time.now.strftime("%s%L").to_i,
13
+ timestamp: current_timestamp,
14
14
  data: {
15
15
  result: result
16
16
  }
@@ -19,9 +19,9 @@ module DjiMqttConnect
19
19
 
20
20
  attribute :_method, Types::String.enum("update_topo")
21
21
 
22
- attribute :tid, Types::String
23
- attribute :bid, Types::String
24
- attribute :timestamp, Types::Integer
22
+ attribute :tid, Types::UUID
23
+ attribute :bid, Types::UUID
24
+ attribute :timestamp, Types::Timestamp
25
25
  attribute :data do
26
26
  attribute :result, Types::Integer
27
27
  end
@@ -8,7 +8,7 @@ module DjiMqttConnect
8
8
  _method: airport_bind_status_message._method,
9
9
  tid: airport_bind_status_message.tid,
10
10
  bid: airport_bind_status_message.bid,
11
- timestamp: Time.now.strftime("%s%L").to_i,
11
+ timestamp: current_timestamp,
12
12
  data: {
13
13
  result: result,
14
14
  output: {
@@ -9,7 +9,7 @@ module DjiMqttConnect
9
9
  _method: airport_organization_bind_message._method,
10
10
  tid: airport_organization_bind_message.tid,
11
11
  bid: airport_organization_bind_message.bid,
12
- timestamp: Time.now.strftime("%s%L").to_i,
12
+ timestamp: current_timestamp,
13
13
  data: {
14
14
  result: result,
15
15
  err_infos: err_infos
@@ -9,7 +9,7 @@ module DjiMqttConnect
9
9
  _method: airport_organization_get_message._method,
10
10
  tid: airport_organization_get_message.tid,
11
11
  bid: airport_organization_get_message.bid,
12
- timestamp: Time.now.strftime("%s%L").to_i,
12
+ timestamp: current_timestamp,
13
13
  data: {
14
14
  result: result,
15
15
  output: output
@@ -9,7 +9,7 @@ module DjiMqttConnect
9
9
  data: data,
10
10
  tid: config_request_message.tid,
11
11
  bid: config_request_message.bid,
12
- timestamp: Time.now.strftime("%s%L").to_i,
12
+ timestamp: current_timestamp,
13
13
  gateway: config_request_message.gateway
14
14
  )
15
15
  end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DjiMqttConnect
4
+ module Thing::Product
5
+ class CoverCloseServicesMessage < Message
6
+ def self.build(bid: generate_bid, tid: generate_tid, timestamp: current_timestamp)
7
+ new(
8
+ bid: bid,
9
+ tid: tid,
10
+ timestamp: timestamp,
11
+ _method: "cover_close"
12
+ )
13
+ end
14
+
15
+ attribute :tid, Types::UUID
16
+ attribute :bid, Types::UUID
17
+ attribute :timestamp, Types::Timestamp
18
+
19
+ attribute :_method, Types::String.enum("cover_close")
20
+ attribute :data, Types::Hash.default({}.freeze)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DjiMqttConnect
4
+ module Thing::Product
5
+ class CoverOpenServicesMessage < Message
6
+ def self.build(bid: generate_bid, tid: generate_tid, timestamp: current_timestamp)
7
+ new(
8
+ bid: bid,
9
+ tid: tid,
10
+ timestamp: timestamp,
11
+ _method: "cover_open"
12
+ )
13
+ end
14
+
15
+ attribute :tid, Types::UUID
16
+ attribute :bid, Types::UUID
17
+ attribute :timestamp, Types::Timestamp
18
+
19
+ attribute :_method, Types::String.enum("cover_open")
20
+ attribute :data, Types::Hash.default({}.freeze)
21
+ end
22
+ end
23
+ end
@@ -10,7 +10,7 @@ module DjiMqttConnect
10
10
  _method: events_message._method,
11
11
  tid: events_message.tid,
12
12
  bid: events_message.bid,
13
- timestamp: Time.now.strftime("%s%L").to_i,
13
+ timestamp: current_timestamp,
14
14
  data: {
15
15
  result: result
16
16
  }
@@ -23,6 +23,7 @@ module DjiMqttConnect
23
23
 
24
24
  attribute :_method, Types::String.enum(
25
25
  "file_upload_callback",
26
+ "fileupload_progress",
26
27
  "highest_priority_upload_flighttask_media"
27
28
  )
28
29
 
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DjiMqttConnect
4
+ module Thing::Product
5
+ class FileuploadListServicesMessage < Message
6
+ def self.build(module_list:, bid: generate_bid, tid: generate_tid, timestamp: current_timestamp)
7
+ new(
8
+ _method: "fileupload_list",
9
+ bid: bid,
10
+ tid: tid,
11
+ timestamp: timestamp,
12
+ data: {
13
+ module_list: module_list
14
+ }
15
+ )
16
+ end
17
+
18
+ attribute :_method, Types::String.enum("fileupload_list")
19
+
20
+ attribute :tid, Types::UUID
21
+ attribute :bid, Types::UUID
22
+ attribute :timestamp, Types::Timestamp
23
+ attribute :data do
24
+ attribute :module_list, Types::Array.of(Types::Coercible::String.enum("0", "3"))
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,44 @@
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/log.html#inform-of-file-uploading-progress
6
+ class FileuploadProgressEventsMessage < EventsMessage
7
+ attribute :_method, Types::String.enum("fileupload_progress")
8
+
9
+ # NOTE: Not documented, but appears in examples
10
+ attribute? :need_reply, Types::Integer.enum(0, 1)
11
+
12
+ attribute :data do
13
+ attribute :output do
14
+ attribute :ext do
15
+ attribute :files, Types::Array do
16
+ # {"0":"Aircraft","3":"DJI Dock"}
17
+ attribute :module, Types::Coercible::Integer.enum(0, 3)
18
+
19
+ attribute :size, Types::Integer
20
+ attribute :device_sn, Types::String
21
+ attribute :key, Types::String
22
+ attribute :fingerprint, Types::String
23
+
24
+ attribute :progress do
25
+ attribute :current_step, Types::Integer
26
+ attribute? :total_step, Types::Integer
27
+ attribute :prgress, Types::Integer
28
+ attribute :finish_time, Types::Timestamp
29
+ attribute :upload_rate, Types::Integer
30
+ attribute :result, Types::Integer
31
+ attribute :status, Types::String
32
+ end
33
+ end
34
+ end
35
+ attribute :status, Types::String
36
+ end
37
+ end
38
+
39
+ def need_reply?
40
+ need_reply == 1
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DjiMqttConnect
4
+ module Thing::Product
5
+ class FileuploadStartServicesMessage < Message
6
+ def self.build(data:, bid: generate_bid, tid: generate_tid, timestamp: current_timestamp)
7
+ new(
8
+ _method: "fileupload_start",
9
+ bid: bid,
10
+ tid: tid,
11
+ timestamp: timestamp,
12
+ data: data
13
+ )
14
+ end
15
+
16
+ attribute :_method, Types::String.enum("fileupload_start")
17
+
18
+ attribute :tid, Types::UUID
19
+ attribute :bid, Types::UUID
20
+ attribute :timestamp, Types::Timestamp
21
+
22
+ attribute :data do
23
+ attribute :endpoint, Types::String
24
+ attribute :bucket, Types::String
25
+ attribute :region, Types::String
26
+ attribute :credentials do
27
+ attribute :access_key_id, Types::String
28
+ attribute :access_key_secret, Types::String
29
+ attribute :expire, Types::Integer.constrained(gt: 0)
30
+ attribute :security_token, Types::String
31
+ end
32
+ attribute :params do
33
+ attribute :files, Types::Array do
34
+ attribute :list, Types::Array do
35
+ attribute :boot_index, Types::Integer
36
+ attribute :end_time, Types::Timestamp
37
+ attribute :size, Types::Integer
38
+ attribute :start_time, Types::Timestamp
39
+ end
40
+ attribute :module, Types::Coercible::String.enum("0", "3")
41
+ attribute :object_key, Types::String
42
+ end
43
+ end
44
+ attribute :provider, Types::String
45
+ end
46
+ end
47
+ end
48
+ end
@@ -9,7 +9,7 @@ module DjiMqttConnect
9
9
  _method: storage_config_get_message._method,
10
10
  tid: storage_config_get_message.tid,
11
11
  bid: storage_config_get_message.bid,
12
- timestamp: Time.now.strftime("%s%L").to_i,
12
+ timestamp: current_timestamp,
13
13
  data: {
14
14
  result: result,
15
15
  output: output
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DjiMqttConnect
4
+ module Thing::Product
5
+ class ServicesTopicRepository < TopicRepository
6
+ # Publishes a message to gateway_sn on the "thing/product/+/services" topic.
7
+ def publish_to_device(gateway_sn, services_message)
8
+ publish_to_topic(
9
+ "thing/product/#{gateway_sn}/services",
10
+ services_message,
11
+ marshal: ServicesMarshal
12
+ )
13
+ end
14
+ end
15
+ end
16
+ end
@@ -9,7 +9,17 @@ module DjiMqttConnect
9
9
  DEFAULT_LATITUDE = "-33.865143"
10
10
  DEFAULT_LONGITUDE = "151.209900"
11
11
 
12
- SECRET_KEYS = %w[app_id app_key app_license callsign device_secret nonce]
12
+ SECRET_KEYS = %w[
13
+ app_id
14
+ app_key
15
+ app_license
16
+ callsign
17
+ device_secret
18
+ nonce
19
+ access_key_id
20
+ access_key_secret
21
+ security_token
22
+ ]
13
23
 
14
24
  SERIAL_NUMBER_KEYS = %w[device_sn gateway sn]
15
25
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DjiMqttConnect
4
- VERSION = "0.1.10"
4
+ VERSION = "0.1.12"
5
5
  end
@@ -35,6 +35,7 @@ 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 :FileuploadProgressEventsMessage, "dji_mqtt_connect/messages/thing/product/fileupload_progress_events_message"
38
39
  autoload :HighestPriorityUploadFlighttaskMediaEventsMessage, "dji_mqtt_connect/messages/thing/product/highest_priority_upload_flighttask_media_events_message"
39
40
  autoload :HmsEventsMessage, "dji_mqtt_connect/messages/thing/product/hms_events_message"
40
41
  autoload :StatusCodeEventsMessage, "dji_mqtt_connect/messages/thing/product/status_code_events_message"
@@ -60,12 +61,18 @@ module DjiMqttConnect
60
61
  autoload :ConfigRequestsReplyMessage, "dji_mqtt_connect/messages/thing/product/config_requests_reply_message"
61
62
  autoload :StorageConfigGetRequestsReplyMessage, "dji_mqtt_connect/messages/thing/product/storage_config_get_requests_reply_message"
62
63
 
64
+ autoload :CoverCloseServicesMessage, "dji_mqtt_connect/messages/thing/product/cover_close_services_message"
65
+ autoload :CoverOpenServicesMessage, "dji_mqtt_connect/messages/thing/product/cover_open_services_message"
66
+ autoload :FileuploadListServicesMessage, "dji_mqtt_connect/messages/thing/product/fileupload_list_services_message"
67
+ autoload :FileuploadStartServicesMessage, "dji_mqtt_connect/messages/thing/product/fileupload_start_services_message"
68
+
63
69
  # Topics
64
70
  autoload :EventsTopicRepository, "dji_mqtt_connect/topics/thing/product/events"
65
71
  autoload :EventsReplyTopicRepository, "dji_mqtt_connect/topics/thing/product/events_reply"
66
72
  autoload :OsdTopicRepository, "dji_mqtt_connect/topics/thing/product/osd"
67
73
  autoload :RequestsTopicRepository, "dji_mqtt_connect/topics/thing/product/requests"
68
74
  autoload :RequestsReplyTopicRepository, "dji_mqtt_connect/topics/thing/product/requests_reply"
75
+ autoload :ServicesTopicRepository, "dji_mqtt_connect/topics/thing/product/services"
69
76
 
70
77
  # Marshals
71
78
  autoload :EventsMarshal, "dji_mqtt_connect/marshals/thing/product/events_marshal"
@@ -75,6 +82,8 @@ module DjiMqttConnect
75
82
 
76
83
  autoload :RequestsMarshal, "dji_mqtt_connect/marshals/thing/product/requests_marshal"
77
84
  autoload :RequestsReplyMarshal, "dji_mqtt_connect/marshals/thing/product/requests_reply_marshal"
85
+
86
+ autoload :ServicesMarshal, "dji_mqtt_connect/marshals/thing/product/services_marshal"
78
87
  end
79
88
  end
80
89
 
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.10
4
+ version: 0.1.12
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-25 00:00:00.000000000 Z
11
+ date: 2023-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -117,6 +117,7 @@ files:
117
117
  - lib/dji_mqtt_connect/marshals/thing/product/osd_marshal.rb
118
118
  - lib/dji_mqtt_connect/marshals/thing/product/requests_marshal.rb
119
119
  - lib/dji_mqtt_connect/marshals/thing/product/requests_reply_marshal.rb
120
+ - lib/dji_mqtt_connect/marshals/thing/product/services_marshal.rb
120
121
  - lib/dji_mqtt_connect/message.rb
121
122
  - lib/dji_mqtt_connect/message_marshal.rb
122
123
  - lib/dji_mqtt_connect/messages/sys/product/status_message.rb
@@ -130,11 +131,16 @@ files:
130
131
  - lib/dji_mqtt_connect/messages/thing/product/airport_organization_get_requests_reply_message.rb
131
132
  - lib/dji_mqtt_connect/messages/thing/product/config_requests_message.rb
132
133
  - lib/dji_mqtt_connect/messages/thing/product/config_requests_reply_message.rb
134
+ - lib/dji_mqtt_connect/messages/thing/product/cover_close_services_message.rb
135
+ - lib/dji_mqtt_connect/messages/thing/product/cover_open_services_message.rb
133
136
  - lib/dji_mqtt_connect/messages/thing/product/dock_osd_message.rb
134
137
  - lib/dji_mqtt_connect/messages/thing/product/drone_osd_message.rb
135
138
  - lib/dji_mqtt_connect/messages/thing/product/events_message.rb
136
139
  - lib/dji_mqtt_connect/messages/thing/product/events_reply_message.rb
137
140
  - lib/dji_mqtt_connect/messages/thing/product/file_upload_callback_events_message.rb
141
+ - lib/dji_mqtt_connect/messages/thing/product/fileupload_list_services_message.rb
142
+ - lib/dji_mqtt_connect/messages/thing/product/fileupload_progress_events_message.rb
143
+ - lib/dji_mqtt_connect/messages/thing/product/fileupload_start_services_message.rb
138
144
  - lib/dji_mqtt_connect/messages/thing/product/highest_priority_upload_flighttask_media_events_message.rb
139
145
  - lib/dji_mqtt_connect/messages/thing/product/hms_events_message.rb
140
146
  - lib/dji_mqtt_connect/messages/thing/product/osd_message.rb
@@ -156,6 +162,7 @@ files:
156
162
  - lib/dji_mqtt_connect/topics/thing/product/osd.rb
157
163
  - lib/dji_mqtt_connect/topics/thing/product/requests.rb
158
164
  - lib/dji_mqtt_connect/topics/thing/product/requests_reply.rb
165
+ - lib/dji_mqtt_connect/topics/thing/product/services.rb
159
166
  - lib/dji_mqtt_connect/translations.rb
160
167
  - lib/dji_mqtt_connect/types.rb
161
168
  - lib/dji_mqtt_connect/utils/message_parsing.rb