dji_mqtt_connect 0.1.20.1 → 0.1.21

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20c0a46731aaabdaedbb0c44ccf73c73a568440762a2a5b09f9ec23a241bef04
4
- data.tar.gz: b7e616d46c8e4701fd28b5a68089e7610fde5a770cf8c01d17144d331d0be3b8
3
+ metadata.gz: 7c7dcc1c840ccf9aaee09ac40525e54250b00543951b3adf3fc2535fead82529
4
+ data.tar.gz: 768cbfdd365db52896838434a319742e55dbd82ad021d0a3aa6c76f07d94f8ac
5
5
  SHA512:
6
- metadata.gz: 40f586f623c7c269b3de4b54265b4efb1a2145f64462b974c3f4b01d9f775f5772c715a7cfff1970a63e8124179619245ce88cf1d282134f7b329857e874a6cc
7
- data.tar.gz: 9716ab8742e0e598863e7272ab2c612c00ccf895e8e7d62ecb0aff45f31c1cfef5061c053140120e7fd310406f7a0e691a6024dd58e76a36739331905959b259
6
+ metadata.gz: 530a33ad82c122710f9a8421553768cd7eff877099722d2ce34918d434703c7fa429fdad587030db3fca04953c5c26411d3665d9bd61e468d4e6ddfc4feafee5
7
+ data.tar.gz: 01df1da7273ba9b2492cd799c6eb08d8d20bb022c90f3860acd528abc32af4e2d759f6d8ec4a0ed922035db58bd0e7ef9cf68e2f668d68aaa97d00d4532282a7
data/.rubocop.yml CHANGED
@@ -17,4 +17,4 @@ inherit_from:
17
17
  AllCops:
18
18
  NewCops: disable
19
19
  SuggestExtensions: true
20
- TargetRubyVersion: 3.1
20
+ TargetRubyVersion: 2.7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dji_mqtt_connect (0.1.20.1)
4
+ dji_mqtt_connect (0.1.21)
5
5
  activesupport (>= 6.0, <= 8)
6
6
  dry-struct (~> 1.6)
7
7
  dry-transformer (~> 1.0)
@@ -11,19 +11,27 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- activejob (7.0.8)
15
- activesupport (= 7.0.8)
14
+ activejob (7.1.3.2)
15
+ activesupport (= 7.1.3.2)
16
16
  globalid (>= 0.3.6)
17
- activesupport (7.0.8)
17
+ activesupport (7.1.3.2)
18
+ base64
19
+ bigdecimal
18
20
  concurrent-ruby (~> 1.0, >= 1.0.2)
21
+ connection_pool (>= 2.2.5)
22
+ drb
19
23
  i18n (>= 1.6, < 2)
20
24
  minitest (>= 5.1)
25
+ mutex_m
21
26
  tzinfo (~> 2.0)
22
27
  ast (2.4.2)
23
- base64 (0.1.1)
24
- concurrent-ruby (1.2.2)
25
- diff-lcs (1.5.0)
28
+ base64 (0.2.0)
29
+ bigdecimal (3.1.7)
30
+ concurrent-ruby (1.2.3)
31
+ connection_pool (2.4.1)
32
+ diff-lcs (1.5.1)
26
33
  docile (1.4.0)
34
+ drb (2.2.1)
27
35
  dry-core (1.0.1)
28
36
  concurrent-ruby (~> 1.0)
29
37
  zeitwerk (~> 2.6)
@@ -39,7 +47,8 @@ GEM
39
47
  zeitwerk (~> 2.6)
40
48
  dry-transformer (1.0.1)
41
49
  zeitwerk (~> 2.6)
42
- dry-types (1.7.1)
50
+ dry-types (1.7.2)
51
+ bigdecimal (~> 3.0)
43
52
  concurrent-ruby (~> 1.0)
44
53
  dry-core (~> 1.0)
45
54
  dry-inflector (~> 1.0)
@@ -47,63 +56,66 @@ GEM
47
56
  zeitwerk (~> 2.6)
48
57
  globalid (1.2.1)
49
58
  activesupport (>= 6.1)
50
- i18n (1.14.1)
59
+ i18n (1.14.4)
51
60
  concurrent-ruby (~> 1.0)
52
61
  ice_nine (0.11.2)
53
- json (2.6.3)
62
+ json (2.7.2)
54
63
  language_server-protocol (3.17.0.3)
55
64
  lint_roller (1.1.0)
56
- minitest (5.20.0)
65
+ minitest (5.22.3)
57
66
  mqtt (0.6.0)
58
- parallel (1.23.0)
59
- parser (3.2.2.3)
67
+ mutex_m (0.2.0)
68
+ parallel (1.24.0)
69
+ parser (3.3.0.5)
60
70
  ast (~> 2.4.1)
61
71
  racc
62
- racc (1.7.1)
72
+ racc (1.7.3)
63
73
  rainbow (3.1.1)
64
- rake (13.0.6)
65
- regexp_parser (2.8.1)
74
+ rake (13.2.1)
75
+ regexp_parser (2.9.0)
66
76
  rexml (3.2.6)
67
- rspec (3.12.0)
68
- rspec-core (~> 3.12.0)
69
- rspec-expectations (~> 3.12.0)
70
- rspec-mocks (~> 3.12.0)
71
- rspec-core (3.12.2)
72
- rspec-support (~> 3.12.0)
73
- rspec-expectations (3.12.3)
77
+ rspec (3.13.0)
78
+ rspec-core (~> 3.13.0)
79
+ rspec-expectations (~> 3.13.0)
80
+ rspec-mocks (~> 3.13.0)
81
+ rspec-core (3.13.0)
82
+ rspec-support (~> 3.13.0)
83
+ rspec-expectations (3.13.0)
74
84
  diff-lcs (>= 1.2.0, < 2.0)
75
- rspec-support (~> 3.12.0)
76
- rspec-mocks (3.12.6)
85
+ rspec-support (~> 3.13.0)
86
+ rspec-mocks (3.13.0)
77
87
  diff-lcs (>= 1.2.0, < 2.0)
78
- rspec-support (~> 3.12.0)
79
- rspec-support (3.12.1)
80
- rubocop (1.56.4)
81
- base64 (~> 0.1.1)
88
+ rspec-support (~> 3.13.0)
89
+ rspec-support (3.13.1)
90
+ rubocop (1.62.1)
82
91
  json (~> 2.3)
83
92
  language_server-protocol (>= 3.17.0)
84
93
  parallel (~> 1.10)
85
- parser (>= 3.2.2.3)
94
+ parser (>= 3.3.0.2)
86
95
  rainbow (>= 2.2.2, < 4.0)
87
96
  regexp_parser (>= 1.8, < 3.0)
88
97
  rexml (>= 3.2.5, < 4.0)
89
- rubocop-ast (>= 1.28.1, < 2.0)
98
+ rubocop-ast (>= 1.31.1, < 2.0)
90
99
  ruby-progressbar (~> 1.7)
91
100
  unicode-display_width (>= 2.4.0, < 3.0)
92
- rubocop-ast (1.29.0)
93
- parser (>= 3.2.1.0)
94
- rubocop-capybara (2.19.0)
101
+ rubocop-ast (1.31.2)
102
+ parser (>= 3.3.0.4)
103
+ rubocop-capybara (2.20.0)
95
104
  rubocop (~> 1.41)
96
- rubocop-factory_bot (2.24.0)
97
- rubocop (~> 1.33)
98
- rubocop-performance (1.19.1)
99
- rubocop (>= 1.7.0, < 2.0)
100
- rubocop-ast (>= 0.4.0)
105
+ rubocop-factory_bot (2.25.1)
106
+ rubocop (~> 1.41)
107
+ rubocop-performance (1.20.2)
108
+ rubocop (>= 1.48.1, < 2.0)
109
+ rubocop-ast (>= 1.30.0, < 2.0)
101
110
  rubocop-rake (0.6.0)
102
111
  rubocop (~> 1.0)
103
- rubocop-rspec (2.24.1)
104
- rubocop (~> 1.33)
112
+ rubocop-rspec (2.29.1)
113
+ rubocop (~> 1.40)
105
114
  rubocop-capybara (~> 2.17)
106
115
  rubocop-factory_bot (~> 2.22)
116
+ rubocop-rspec_rails (~> 2.28)
117
+ rubocop-rspec_rails (2.28.2)
118
+ rubocop (~> 1.40)
107
119
  ruby-progressbar (1.13.0)
108
120
  simplecov (0.22.0)
109
121
  docile (~> 1.1)
@@ -111,24 +123,24 @@ GEM
111
123
  simplecov_json_formatter (~> 0.1)
112
124
  simplecov-html (0.12.3)
113
125
  simplecov_json_formatter (0.1.4)
114
- standard (1.31.1)
126
+ standard (1.35.1)
115
127
  language_server-protocol (~> 3.17.0.2)
116
128
  lint_roller (~> 1.0)
117
- rubocop (~> 1.56.2)
129
+ rubocop (~> 1.62.0)
118
130
  standard-custom (~> 1.0.0)
119
- standard-performance (~> 1.2)
131
+ standard-performance (~> 1.3)
120
132
  standard-custom (1.0.2)
121
133
  lint_roller (~> 1.0)
122
134
  rubocop (~> 1.50)
123
- standard-performance (1.2.0)
135
+ standard-performance (1.3.1)
124
136
  lint_roller (~> 1.1)
125
- rubocop-performance (~> 1.19.0)
137
+ rubocop-performance (~> 1.20.2)
126
138
  tzinfo (2.0.6)
127
139
  concurrent-ruby (~> 1.0)
128
140
  unicode-display_width (2.5.0)
129
141
  wisper (2.0.1)
130
142
  wisper-rspec (1.1.0)
131
- zeitwerk (2.6.12)
143
+ zeitwerk (2.6.13)
132
144
 
133
145
  PLATFORMS
134
146
  arm64-darwin-22
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.summary = "Manages MQTT Connections with DJI Drones"
12
12
  # spec.description = "TODO: Write a longer description or delete this line."
13
13
  spec.homepage = "https://github.com/sphere-drones/dji_mqtt_connect"
14
- spec.required_ruby_version = ">= 3.1.0"
14
+ spec.required_ruby_version = ">= 2.7.0"
15
15
 
16
16
  # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
17
17
 
@@ -76,6 +76,11 @@ module DjiMqttConnect
76
76
  Thing::Product::ServicesReplyTopicRepository.new(self)
77
77
  end
78
78
 
79
+ # Handles topic thing/product/#{pid}/state
80
+ def thing_product_state_topic
81
+ Thing::Product::StateTopicRepository.new(self)
82
+ end
83
+
79
84
  attr_reader :mqtt_client
80
85
  end
81
86
  end
@@ -799,6 +799,45 @@ module DjiMqttConnect
799
799
  )
800
800
  end
801
801
 
802
+ ### Live Stream (Services Messages) ###
803
+
804
+ def build_thing_product_live_lens_change_services_message
805
+ Thing::Product::LiveLensChangeServicesMessage.build(
806
+ data: {
807
+ video_id: "1ZNDH1D0010098/39-0-7/normal-0",
808
+ video_type: "wide"
809
+ }
810
+ )
811
+ end
812
+
813
+ def build_thing_product_live_set_quality_services_message
814
+ Thing::Product::LiveSetQualityServicesMessage.build(
815
+ data: {
816
+ video_id: "1ZNDH1D0010098/39-0-7/normal-0",
817
+ video_quality: 0
818
+ }
819
+ )
820
+ end
821
+
822
+ def build_thing_product_live_start_push_services_message
823
+ Thing::Product::LiveStartPushServicesMessage.build(
824
+ data: {
825
+ url: "channel=1ZNDH1D0010098_39-0-7&sn=1ZNDH1D0010098&token=006dca67721582a48768ec4d817b7b25a86IADk%2Fcm%2Fdv%2BHY6qT%2FAKM6y7TcUe4lXNvZpycH7vUMAlM6pFALUKF2zyCIgA82pQE8cCoYAQAAQDxwKhgAgDxwKhgAwDxwKhgBADxwKhg&uid=50000",
826
+ url_type: 0,
827
+ video_id: "1ZNDH1D0010098/39-0-7/normal-0",
828
+ video_quality: 0
829
+ }
830
+ )
831
+ end
832
+
833
+ def build_thing_product_live_stop_push_services_message
834
+ Thing::Product::LiveStopPushServicesMessage.build(
835
+ data: {
836
+ video_id: "1ZNDH1D0010098/39-0-7/normal-0"
837
+ }
838
+ )
839
+ end
840
+
802
841
  def build_thing_product_return_home_services_message
803
842
  Thing::Product::ReturnHomeServicesMessage.build
804
843
  end
@@ -1004,6 +1043,60 @@ module DjiMqttConnect
1004
1043
  )
1005
1044
  end
1006
1045
 
1046
+ ### Live Stream (Services Reply Messages) ###
1047
+
1048
+ def build_thing_product_live_lens_change_services_reply_message
1049
+ message_data = {result: 0}
1050
+
1051
+ Thing::Product::LiveLensChangeServicesReplyMessage.new(
1052
+ bid: Message.generate_bid,
1053
+ tid: Message.generate_tid,
1054
+ timestamp: Message.current_timestamp,
1055
+ _method: "live_lens_change",
1056
+ _data: message_data,
1057
+ data: message_data
1058
+ )
1059
+ end
1060
+
1061
+ def build_thing_product_live_set_quality_services_reply_message
1062
+ message_data = {result: 0}
1063
+
1064
+ Thing::Product::LiveSetQualityServicesReplyMessage.new(
1065
+ bid: Message.generate_bid,
1066
+ tid: Message.generate_tid,
1067
+ timestamp: Message.current_timestamp,
1068
+ _method: "live_set_quality",
1069
+ _data: message_data,
1070
+ data: message_data
1071
+ )
1072
+ end
1073
+
1074
+ def build_thing_product_live_start_push_services_reply_message
1075
+ message_data = {result: 0}
1076
+
1077
+ Thing::Product::LiveStartPushServicesReplyMessage.new(
1078
+ bid: Message.generate_bid,
1079
+ tid: Message.generate_tid,
1080
+ timestamp: Message.current_timestamp,
1081
+ _method: "live_start_push",
1082
+ _data: message_data,
1083
+ data: message_data
1084
+ )
1085
+ end
1086
+
1087
+ def build_thing_product_live_stop_push_services_reply_message
1088
+ message_data = {result: 0}
1089
+
1090
+ Thing::Product::LiveStopPushServicesReplyMessage.new(
1091
+ bid: Message.generate_bid,
1092
+ tid: Message.generate_tid,
1093
+ timestamp: Message.current_timestamp,
1094
+ _method: "live_stop_push",
1095
+ _data: message_data,
1096
+ data: message_data
1097
+ )
1098
+ end
1099
+
1007
1100
  def build_thing_product_return_home_services_reply_message
1008
1101
  message_data = {
1009
1102
  result: 0,
@@ -1032,5 +1125,85 @@ module DjiMqttConnect
1032
1125
  data: message_data
1033
1126
  )
1034
1127
  end
1128
+
1129
+ ### State Messages ###
1130
+
1131
+ def build_thing_product_live_capacity_state_message
1132
+ message_data = {
1133
+ live_capacity: {
1134
+ available_video_number: 3,
1135
+ coexist_video_number_max: 2,
1136
+ device_list: [
1137
+ {
1138
+ sn: "DOCK01",
1139
+ available_video_number: 1,
1140
+ coexist_video_number_max: 1,
1141
+ camera_list: [
1142
+ {
1143
+ camera_index: "165-0-7",
1144
+ available_video_number: 1,
1145
+ coexist_video_number_max: 1,
1146
+ video_list: [
1147
+ {
1148
+ video_index: "normal-0",
1149
+ video_type: "normal",
1150
+ switchable_video_types: [
1151
+ "normal"
1152
+ ]
1153
+ }
1154
+ ]
1155
+ }
1156
+ ]
1157
+ },
1158
+ {
1159
+ sn: "DRONE01",
1160
+ available_video_number: 2,
1161
+ coexist_video_number_max: 2,
1162
+ camera_list: [
1163
+ {
1164
+ camera_index: "39-0-7",
1165
+ available_video_number: 1,
1166
+ coexist_video_number_max: 1,
1167
+ video_list: [
1168
+ {
1169
+ video_index: "normal-0",
1170
+ video_type: "normal",
1171
+ switchable_video_types: [
1172
+ "normal"
1173
+ ]
1174
+ }
1175
+ ]
1176
+ },
1177
+ {
1178
+ camera_index: "52-0-0",
1179
+ available_video_number: 1,
1180
+ coexist_video_number_max: 1,
1181
+ video_list: [
1182
+ {
1183
+ video_index: "normal-0",
1184
+ video_type: "wide",
1185
+ switchable_video_types: [
1186
+ "wide",
1187
+ "zoom",
1188
+ "ir"
1189
+ ]
1190
+ }
1191
+ ]
1192
+ }
1193
+ ]
1194
+ }
1195
+ ]
1196
+ }
1197
+ }
1198
+
1199
+ Thing::Product::StateMessage.new(
1200
+ bid: Message.generate_bid,
1201
+ tid: Message.generate_tid,
1202
+ timestamp: Message.current_timestamp,
1203
+ gateway: "GATEWAY01",
1204
+ _data: message_data,
1205
+ data: message_data
1206
+ )
1207
+ end
1035
1208
  end
1036
1209
  end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dry-struct"
4
+ require "dry-transformer"
5
+ require "json"
6
+
7
+ module DjiMqttConnect
8
+ module Thing::Product
9
+ class StateMarshal < MessageMarshal
10
+ include Utils::MessageParsing
11
+
12
+ # Rename pesky `method` argument to `_method` and makes a copy of the raw data
13
+ class AttributeTransformer < Dry::Transformer::Pipe
14
+ import Dry::Transformer::HashTransformations
15
+
16
+ define! do
17
+ copy_keys "data" => "_data"
18
+ end
19
+ end
20
+
21
+ # Attempts to look a the method attribute, and builds a specific Message class for the message
22
+ def load(raw_message)
23
+ # Parse the message from JSON
24
+ parsed_message = JSON.parse(raw_message)
25
+
26
+ # Transform the message
27
+ transformed_message = attribute_transformer.call(parsed_message)
28
+
29
+ # Build an instance of the class, or a generic message from the current class
30
+ StateMessage.new transformed_message
31
+ rescue JSON::ParserError => e
32
+ raise ParseError.new(e, "Unable to parse message as JSON")
33
+ rescue Dry::Struct::Error => e
34
+ raise ParseError.new(e, "Unexpected #{StateMessage} payload")
35
+ end
36
+
37
+ private
38
+
39
+ def attribute_transformer
40
+ @attribute_transformer ||= AttributeTransformer.new
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DjiMqttConnect
4
+ module Thing::Product
5
+ # Live Set Lens
6
+ # https://developer.dji.com/doc/cloud-api-tutorial/en/api-reference/dock-to-cloud/mqtt/dock/dock1/live.html
7
+ class LiveLensChangeServicesMessage < Message
8
+ def self.build(data:, bid: generate_bid, tid: generate_tid, timestamp: current_timestamp)
9
+ new(
10
+ bid: bid,
11
+ tid: tid,
12
+ data: data,
13
+ timestamp: timestamp,
14
+ _method: "live_lens_change"
15
+ )
16
+ end
17
+
18
+ # {"ir":"Infrared","normal":"Default","wide":"Wide-angle","zoom":"Zoom"}
19
+ VIDEO_TYPE_INFRARED = "ir"
20
+ VIDEO_TYPE_DEFAULT = "normal"
21
+ VIDEO_TYPE_WIDE_ANGLE = "wide"
22
+ VIDEO_TYPE_ZOOM = "zoom"
23
+
24
+ attribute :tid, Types::UUID
25
+ attribute :bid, Types::UUID
26
+ attribute :timestamp, Types::Timestamp
27
+
28
+ attribute :_method, Types::String.enum("live_lens_change")
29
+ attribute :data do
30
+ attribute :video_id, Types::String
31
+
32
+ attribute :video_type, Types::String.enum(
33
+ VIDEO_TYPE_INFRARED,
34
+ VIDEO_TYPE_DEFAULT,
35
+ VIDEO_TYPE_WIDE_ANGLE,
36
+ VIDEO_TYPE_ZOOM
37
+ )
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DjiMqttConnect
4
+ module Thing::Product
5
+ # Live Set Quality
6
+ # https://developer.dji.com/doc/cloud-api-tutorial/en/api-reference/dock-to-cloud/mqtt/dock/dock1/live.html
7
+ class LiveSetQualityServicesMessage < Message
8
+ def self.build(data:, bid: generate_bid, tid: generate_tid, timestamp: current_timestamp)
9
+ new(
10
+ bid: bid,
11
+ tid: tid,
12
+ data: data,
13
+ timestamp: timestamp,
14
+ _method: "live_set_quality"
15
+ )
16
+ end
17
+
18
+ # {"0":"Adaptive","1":"Smooth","2":"Standard definition","3":"High definition","4":"Ultra-high definition"}
19
+ VIDEO_QUALITY_ADAPTIVE = 0
20
+ VIDEO_QUALITY_SMOOTH = 1
21
+ VIDEO_QUALITY_STANDARD_DEFINITION = 2
22
+ VIDEO_QUALITY_HIGH_DEFINITION = 3
23
+ VIDEO_QUALITY_ULTRA_HIGH_DEFINITION = 4
24
+
25
+ attribute :tid, Types::UUID
26
+ attribute :bid, Types::UUID
27
+ attribute :timestamp, Types::Timestamp
28
+
29
+ attribute :_method, Types::String.enum("live_set_quality")
30
+ attribute :data do
31
+ attribute :video_id, Types::String
32
+
33
+ attribute :video_quality, Types::Integer.enum(
34
+ VIDEO_QUALITY_ADAPTIVE,
35
+ VIDEO_QUALITY_SMOOTH,
36
+ VIDEO_QUALITY_STANDARD_DEFINITION,
37
+ VIDEO_QUALITY_HIGH_DEFINITION,
38
+ VIDEO_QUALITY_ULTRA_HIGH_DEFINITION
39
+ )
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DjiMqttConnect
4
+ module Thing::Product
5
+ # Live Start Push
6
+ # https://developer.dji.com/doc/cloud-api-tutorial/en/api-reference/dock-to-cloud/mqtt/dock/dock1/live.html
7
+ class LiveStartPushServicesMessage < Message
8
+ def self.build(data:, bid: generate_bid, tid: generate_tid, timestamp: current_timestamp)
9
+ new(
10
+ bid: bid,
11
+ tid: tid,
12
+ data: data,
13
+ timestamp: timestamp,
14
+ _method: "live_start_push"
15
+ )
16
+ end
17
+
18
+ # {"0":"Agora","1":"RTMP","3":"GB28181","4":"WebRTC"}
19
+ URL_TYPE_AGORA = 0
20
+ URL_TYPE_RTMP = 1
21
+ URL_TYPE_GB28181 = 3
22
+ URL_TYPE_WEBRTC = 4
23
+
24
+ # {"0":"Adaptive","1":"Smooth","2":"Standard definition","3":"High definition","4":"Ultra-high definition"}
25
+ VIDEO_QUALITY_ADAPTIVE = 0
26
+ VIDEO_QUALITY_SMOOTH = 1
27
+ VIDEO_QUALITY_STANDARD_DEFINITION = 2
28
+ VIDEO_QUALITY_HIGH_DEFINITION = 3
29
+ VIDEO_QUALITY_ULTRA_HIGH_DEFINITION = 4
30
+
31
+ attribute :tid, Types::UUID
32
+ attribute :bid, Types::UUID
33
+ attribute :timestamp, Types::Timestamp
34
+
35
+ attribute :_method, Types::String.enum("live_start_push")
36
+ attribute :data do
37
+ attribute :url, Types::String
38
+
39
+ attribute :url_type, Types::Integer.enum(
40
+ URL_TYPE_AGORA,
41
+ URL_TYPE_RTMP,
42
+ URL_TYPE_GB28181,
43
+ URL_TYPE_WEBRTC
44
+ )
45
+
46
+ attribute :video_id, Types::String
47
+
48
+ attribute :video_quality, Types::Integer.enum(
49
+ VIDEO_QUALITY_ADAPTIVE,
50
+ VIDEO_QUALITY_SMOOTH,
51
+ VIDEO_QUALITY_STANDARD_DEFINITION,
52
+ VIDEO_QUALITY_HIGH_DEFINITION,
53
+ VIDEO_QUALITY_ULTRA_HIGH_DEFINITION
54
+ )
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DjiMqttConnect
4
+ module Thing::Product
5
+ # Live Stop Push
6
+ # https://developer.dji.com/doc/cloud-api-tutorial/en/api-reference/dock-to-cloud/mqtt/dock/dock1/live.html
7
+ class LiveStopPushServicesMessage < Message
8
+ def self.build(data:, bid: generate_bid, tid: generate_tid, timestamp: current_timestamp)
9
+ new(
10
+ bid: bid,
11
+ tid: tid,
12
+ data: data,
13
+ timestamp: timestamp,
14
+ _method: "live_stop_push"
15
+ )
16
+ end
17
+
18
+ attribute :tid, Types::UUID
19
+ attribute :bid, Types::UUID
20
+ attribute :timestamp, Types::Timestamp
21
+
22
+ attribute :_method, Types::String.enum("live_stop_push")
23
+ attribute :data do
24
+ attribute :video_id, Types::String
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DjiMqttConnect
4
+ module Thing::Product
5
+ class LiveLensChangeServicesReplyMessage < ServicesReplyMessage
6
+ attribute :_method, Types::String.enum("live_lens_change")
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DjiMqttConnect
4
+ module Thing::Product
5
+ class LiveSetQualityServicesReplyMessage < ServicesReplyMessage
6
+ attribute :_method, Types::String.enum("live_set_quality")
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DjiMqttConnect
4
+ module Thing::Product
5
+ class LiveStartPushServicesReplyMessage < ServicesReplyMessage
6
+ attribute :_method, Types::String.enum("live_start_push")
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DjiMqttConnect
4
+ module Thing::Product
5
+ class LiveStopPushServicesReplyMessage < ServicesReplyMessage
6
+ attribute :_method, Types::String.enum("live_stop_push")
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,109 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DjiMqttConnect
4
+ module Thing::Product
5
+ # {
6
+ # "bid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
7
+ # "tid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
8
+ # "data": {
9
+ # "live_capacity": {
10
+ # "available_video_number": 3,
11
+ # "coexist_video_number_max": 2,
12
+ # "device_list": [
13
+ # {
14
+ # "sn": "4BKBJ4R1010TGD",
15
+ # "available_video_number": 1,
16
+ # "coexist_video_number_max": 1,
17
+ # "camera_list": [
18
+ # {
19
+ # "camera_index": "165-0-7",
20
+ # "available_video_number": 1,
21
+ # "coexist_video_number_max": 1,
22
+ # "video_list": [
23
+ # {
24
+ # "video_index": "normal-0",
25
+ # "video_type": "normal",
26
+ # "switchable_video_types": [
27
+ # "normal"
28
+ # ]
29
+ # }
30
+ # ]
31
+ # }
32
+ # ]
33
+ # },
34
+ # {
35
+ # "sn": "1581F4BND22180040075",
36
+ # "available_video_number": 2,
37
+ # "coexist_video_number_max": 2,
38
+ # "camera_list": [
39
+ # {
40
+ # "camera_index": "39-0-7",
41
+ # "available_video_number": 1,
42
+ # "coexist_video_number_max": 1,
43
+ # "video_list": [
44
+ # {
45
+ # "video_index": "normal-0",
46
+ # "video_type": "normal",
47
+ # "switchable_video_types": [
48
+ # "normal"
49
+ # ]
50
+ # }
51
+ # ]
52
+ # },
53
+ # {
54
+ # "camera_index": "52-0-0",
55
+ # "available_video_number": 1,
56
+ # "coexist_video_number_max": 1,
57
+ # "video_list": [
58
+ # {
59
+ # "video_index": "normal-0",
60
+ # "video_type": "wide",
61
+ # "switchable_video_types": [
62
+ # "wide",
63
+ # "zoom",
64
+ # "ir"
65
+ # ]
66
+ # }
67
+ # ]
68
+ # }
69
+ # ]
70
+ # }
71
+ # ]
72
+ # }
73
+ # },
74
+ # "timestamp:": 1654070968655,
75
+ # "gateway": "4BKBJ4R1010TGD"
76
+ # }
77
+ class StateMessage < DjiMqttConnect::Message
78
+ attribute :tid, Types::UUID
79
+ attribute :bid, Types::UUID
80
+ attribute :timestamp, Types::Timestamp
81
+ attribute :gateway, Types::String
82
+
83
+ attribute :_data, Types::Hash
84
+
85
+ attribute :data do
86
+ # Not all messages will have a live_capacity attribute
87
+ attribute? :live_capacity do
88
+ attribute :available_video_number, Types::Integer
89
+ attribute :coexist_video_number_max, Types::Integer
90
+ attribute :device_list, Types::Array do
91
+ attribute :sn, Types::String
92
+ attribute :available_video_number, Types::Integer
93
+ attribute :coexist_video_number_max, Types::Integer
94
+ attribute :camera_list, Types::Array do
95
+ attribute :camera_index, Types::String
96
+ attribute :available_video_number, Types::Integer
97
+ attribute :coexist_video_number_max, Types::Integer
98
+ attribute :video_list, Types::Array do
99
+ attribute :video_index, Types::String
100
+ attribute :video_type, Types::String
101
+ attribute :switchable_video_types, Types::Array.of(Types::String)
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DjiMqttConnect
4
+ module Thing::Product
5
+ class StateTopicRepository < TopicRepository
6
+ STATE_TOPIC_REGEX = /\Athing\/product\/(?<gateway_sn>.+)\/state\z/
7
+
8
+ def listen!
9
+ listen_to_topic("thing/product/+/state") do |topic, raw_message|
10
+ logger.debug(raw_message)
11
+
12
+ matched_topic = STATE_TOPIC_REGEX.match(topic)
13
+ raise Error, "Unknown topic: #{topic}" unless matched_topic
14
+
15
+ gateway_sn = matched_topic[:gateway_sn]
16
+ message = state_marshal.load(raw_message)
17
+
18
+ logger.info("Received #{message} from #{gateway_sn}")
19
+
20
+ # Broadcast the state update
21
+ broadcast(:state_update, gateway_sn, message)
22
+ rescue ParseError => error
23
+ broadcast(:parse_error, error, topic, raw_message)
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def state_marshal
30
+ @state_marshal ||= StateMarshal.new
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DjiMqttConnect
4
- VERSION = "0.1.20.1"
4
+ VERSION = "0.1.21"
5
5
  end
@@ -90,6 +90,10 @@ module DjiMqttConnect
90
90
  autoload :FlighttaskPrepareServicesMessage, "dji_mqtt_connect/messages/thing/product/services/flighttask_prepare"
91
91
  autoload :FlighttaskRecoveryServicesMessage, "dji_mqtt_connect/messages/thing/product/services/flighttask_recovery"
92
92
  autoload :FlighttaskUndoServicesMessage, "dji_mqtt_connect/messages/thing/product/services/flighttask_undo"
93
+ autoload :LiveLensChangeServicesMessage, "dji_mqtt_connect/messages/thing/product/services/live_lens_change"
94
+ autoload :LiveSetQualityServicesMessage, "dji_mqtt_connect/messages/thing/product/services/live_set_quality"
95
+ autoload :LiveStartPushServicesMessage, "dji_mqtt_connect/messages/thing/product/services/live_start_push"
96
+ autoload :LiveStopPushServicesMessage, "dji_mqtt_connect/messages/thing/product/services/live_stop_push"
93
97
  autoload :ReturnHomeServicesMessage, "dji_mqtt_connect/messages/thing/product/services/return_home"
94
98
  autoload :ReturnHomeCancelServicesMessage, "dji_mqtt_connect/messages/thing/product/services/return_home_cancel"
95
99
 
@@ -104,9 +108,15 @@ module DjiMqttConnect
104
108
  autoload :FlighttaskPrepareServicesReplyMessage, "dji_mqtt_connect/messages/thing/product/services_reply/flighttask_prepare"
105
109
  autoload :FlighttaskRecoveryServicesReplyMessage, "dji_mqtt_connect/messages/thing/product/services_reply/flighttask_recovery"
106
110
  autoload :FlighttaskUndoServicesReplyMessage, "dji_mqtt_connect/messages/thing/product/services_reply/flighttask_undo"
111
+ autoload :LiveLensChangeServicesReplyMessage, "dji_mqtt_connect/messages/thing/product/services_reply/live_lens_change"
112
+ autoload :LiveSetQualityServicesReplyMessage, "dji_mqtt_connect/messages/thing/product/services_reply/live_set_quality"
113
+ autoload :LiveStartPushServicesReplyMessage, "dji_mqtt_connect/messages/thing/product/services_reply/live_start_push"
114
+ autoload :LiveStopPushServicesReplyMessage, "dji_mqtt_connect/messages/thing/product/services_reply/live_stop_push"
107
115
  autoload :ReturnHomeServicesReplyMessage, "dji_mqtt_connect/messages/thing/product/services_reply/return_home"
108
116
  autoload :ReturnHomeCancelServicesReplyMessage, "dji_mqtt_connect/messages/thing/product/services_reply/return_home_cancel"
109
117
 
118
+ autoload :StateMessage, "dji_mqtt_connect/messages/thing/product/state_message"
119
+
110
120
  # Topics
111
121
  autoload :EventsTopicRepository, "dji_mqtt_connect/topics/thing/product/events"
112
122
  autoload :EventsReplyTopicRepository, "dji_mqtt_connect/topics/thing/product/events_reply"
@@ -115,6 +125,7 @@ module DjiMqttConnect
115
125
  autoload :RequestsReplyTopicRepository, "dji_mqtt_connect/topics/thing/product/requests_reply"
116
126
  autoload :ServicesTopicRepository, "dji_mqtt_connect/topics/thing/product/services"
117
127
  autoload :ServicesReplyTopicRepository, "dji_mqtt_connect/topics/thing/product/services_reply"
128
+ autoload :StateTopicRepository, "dji_mqtt_connect/topics/thing/product/state"
118
129
 
119
130
  # Marshals
120
131
  autoload :EventsMarshal, "dji_mqtt_connect/marshals/thing/product/events_marshal"
@@ -127,6 +138,8 @@ module DjiMqttConnect
127
138
 
128
139
  autoload :ServicesMarshal, "dji_mqtt_connect/marshals/thing/product/services_marshal"
129
140
  autoload :ServicesReplyMarshal, "dji_mqtt_connect/marshals/thing/product/services_reply_marshal"
141
+
142
+ autoload :StateMarshal, "dji_mqtt_connect/marshals/thing/product/state_marshal"
130
143
  end
131
144
  end
132
145
 
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.20.1
4
+ version: 0.1.21
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-10-10 00:00:00.000000000 Z
11
+ date: 2024-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -122,6 +122,7 @@ files:
122
122
  - lib/dji_mqtt_connect/marshals/thing/product/requests_reply_marshal.rb
123
123
  - lib/dji_mqtt_connect/marshals/thing/product/services_marshal.rb
124
124
  - lib/dji_mqtt_connect/marshals/thing/product/services_reply_marshal.rb
125
+ - lib/dji_mqtt_connect/marshals/thing/product/state_marshal.rb
125
126
  - lib/dji_mqtt_connect/message.rb
126
127
  - lib/dji_mqtt_connect/message_marshal.rb
127
128
  - lib/dji_mqtt_connect/messages/sys/product/status/update_topo.rb
@@ -177,6 +178,10 @@ files:
177
178
  - lib/dji_mqtt_connect/messages/thing/product/services/flighttask_prepare.rb
178
179
  - lib/dji_mqtt_connect/messages/thing/product/services/flighttask_recovery.rb
179
180
  - lib/dji_mqtt_connect/messages/thing/product/services/flighttask_undo.rb
181
+ - lib/dji_mqtt_connect/messages/thing/product/services/live_lens_change.rb
182
+ - lib/dji_mqtt_connect/messages/thing/product/services/live_set_quality.rb
183
+ - lib/dji_mqtt_connect/messages/thing/product/services/live_start_push.rb
184
+ - lib/dji_mqtt_connect/messages/thing/product/services/live_stop_push.rb
180
185
  - lib/dji_mqtt_connect/messages/thing/product/services/return_home.rb
181
186
  - lib/dji_mqtt_connect/messages/thing/product/services/return_home_cancel.rb
182
187
  - lib/dji_mqtt_connect/messages/thing/product/services_message.rb
@@ -190,9 +195,14 @@ files:
190
195
  - lib/dji_mqtt_connect/messages/thing/product/services_reply/flighttask_prepare.rb
191
196
  - lib/dji_mqtt_connect/messages/thing/product/services_reply/flighttask_recovery.rb
192
197
  - lib/dji_mqtt_connect/messages/thing/product/services_reply/flighttask_undo.rb
198
+ - lib/dji_mqtt_connect/messages/thing/product/services_reply/live_lens_change.rb
199
+ - lib/dji_mqtt_connect/messages/thing/product/services_reply/live_set_quality.rb
200
+ - lib/dji_mqtt_connect/messages/thing/product/services_reply/live_start_push.rb
201
+ - lib/dji_mqtt_connect/messages/thing/product/services_reply/live_stop_push.rb
193
202
  - lib/dji_mqtt_connect/messages/thing/product/services_reply/return_home.rb
194
203
  - lib/dji_mqtt_connect/messages/thing/product/services_reply/return_home_cancel.rb
195
204
  - lib/dji_mqtt_connect/messages/thing/product/services_reply_message.rb
205
+ - lib/dji_mqtt_connect/messages/thing/product/state_message.rb
196
206
  - lib/dji_mqtt_connect/mixins/events_progress_checks.rb
197
207
  - lib/dji_mqtt_connect/mixins/latitude_conditional.rb
198
208
  - lib/dji_mqtt_connect/mixins/longitude_conditional.rb
@@ -211,6 +221,7 @@ files:
211
221
  - lib/dji_mqtt_connect/topics/thing/product/requests_reply.rb
212
222
  - lib/dji_mqtt_connect/topics/thing/product/services.rb
213
223
  - lib/dji_mqtt_connect/topics/thing/product/services_reply.rb
224
+ - lib/dji_mqtt_connect/topics/thing/product/state.rb
214
225
  - lib/dji_mqtt_connect/translations.rb
215
226
  - lib/dji_mqtt_connect/types.rb
216
227
  - lib/dji_mqtt_connect/utils/message_parsing.rb
@@ -233,14 +244,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
233
244
  requirements:
234
245
  - - ">="
235
246
  - !ruby/object:Gem::Version
236
- version: 3.1.0
247
+ version: 2.7.0
237
248
  required_rubygems_version: !ruby/object:Gem::Requirement
238
249
  requirements:
239
250
  - - ">="
240
251
  - !ruby/object:Gem::Version
241
252
  version: '0'
242
253
  requirements: []
243
- rubygems_version: 3.4.19
254
+ rubygems_version: 3.5.4
244
255
  signing_key:
245
256
  specification_version: 4
246
257
  summary: Manages MQTT Connections with DJI Drones