Class: DjiMqttConnect::Client
- Inherits:
-
Object
- Object
- DjiMqttConnect::Client
- Defined in:
- lib/dji_mqtt_connect/client.rb
Overview
Client for communicating with DJI Cloud API MQTT Messages see: developer.dji.com/doc/cloud-api-tutorial/en/server-api-reference/mqtt/topic-definition.html
Instance Attribute Summary collapse
-
#mqtt_client ⇒ Object
readonly
Returns the value of attribute mqtt_client.
Class Method Summary collapse
- .build(mqtt_address, username:, password:, client_name: DjiMqttConnect.client_name, &block) ⇒ Object
Instance Method Summary collapse
-
#initialize(mqtt_client) ⇒ Client
constructor
A new instance of Client.
-
#sys_product_status_reply_topic ⇒ Object
Handles topic sys/product/#pid/status_reply.
-
#sys_product_status_topic ⇒ Object
Handles topic sys/product/#pid/status.
-
#thing_product_events_reply_topic ⇒ Object
Handles topic thing/product/#pid/events_reply.
-
#thing_product_events_topic ⇒ Object
Handles topic thing/product/#pid/events.
-
#thing_product_osd_topic ⇒ Object
Handles topic thing/product/#pid/osd.
-
#thing_product_requests_reply_topic ⇒ Object
Handles topic thing/product/#pid/requests_reply.
-
#thing_product_requests_topic ⇒ Object
Handles topic thing/product/#pid/requests.
-
#thing_product_services_reply_topic ⇒ Object
Handles topic thing/product/#pid/services_reply.
-
#thing_product_services_topic ⇒ Object
Handles topic thing/product/#pid/services.
-
#thing_product_state_reply_topic ⇒ Object
Handles topic thing/product/#pid/state_reply.
-
#thing_product_state_topic ⇒ Object
Handles topic thing/product/#pid/state.
Constructor Details
#initialize(mqtt_client) ⇒ Client
Returns a new instance of Client.
30 31 32 |
# File 'lib/dji_mqtt_connect/client.rb', line 30 def initialize(mqtt_client) @mqtt_client = mqtt_client end |
Instance Attribute Details
#mqtt_client ⇒ Object (readonly)
Returns the value of attribute mqtt_client.
89 90 91 |
# File 'lib/dji_mqtt_connect/client.rb', line 89 def mqtt_client @mqtt_client end |
Class Method Details
.build(mqtt_address, username:, password:, client_name: DjiMqttConnect.client_name, &block) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/dji_mqtt_connect/client.rb', line 9 def self.build(mqtt_address, username:, password:, client_name: DjiMqttConnect.client_name, &block) mqtt_url = URI.parse(mqtt_address) mqtt_host = mqtt_url.host mqtt_port = mqtt_url.port.to_i mqtt_scheme = mqtt_url.scheme DjiMqttConnect.logger.tagged(name) do DjiMqttConnect.logger.info("Connecting to #{mqtt_scheme}://#{mqtt_host}:#{mqtt_port}...") mqtt_client = MQTT::Client.connect( host: mqtt_host, port: mqtt_port, client_id: MQTT::Client.generate_client_id(client_name), username: username, password: password, ssl: !%w[tcp mqtt ws].include?(mqtt_scheme) ) new(mqtt_client) end end |
Instance Method Details
#sys_product_status_reply_topic ⇒ Object
Handles topic sys/product/#pid/status_reply
40 41 42 |
# File 'lib/dji_mqtt_connect/client.rb', line 40 def sys_product_status_reply_topic Sys::Product::StatusReplyTopicRepository.new(self) end |
#sys_product_status_topic ⇒ Object
Handles topic sys/product/#pid/status
35 36 37 |
# File 'lib/dji_mqtt_connect/client.rb', line 35 def sys_product_status_topic Sys::Product::StatusTopicRepository.new(self) end |
#thing_product_events_reply_topic ⇒ Object
Handles topic thing/product/#pid/events_reply
50 51 52 |
# File 'lib/dji_mqtt_connect/client.rb', line 50 def thing_product_events_reply_topic Thing::Product::EventsReplyTopicRepository.new(self) end |
#thing_product_events_topic ⇒ Object
Handles topic thing/product/#pid/events
45 46 47 |
# File 'lib/dji_mqtt_connect/client.rb', line 45 def thing_product_events_topic Thing::Product::EventsTopicRepository.new(self) end |
#thing_product_osd_topic ⇒ Object
Handles topic thing/product/#pid/osd
55 56 57 |
# File 'lib/dji_mqtt_connect/client.rb', line 55 def thing_product_osd_topic Thing::Product::OsdTopicRepository.new(self) end |
#thing_product_requests_reply_topic ⇒ Object
Handles topic thing/product/#pid/requests_reply
65 66 67 |
# File 'lib/dji_mqtt_connect/client.rb', line 65 def thing_product_requests_reply_topic Thing::Product::RequestsReplyTopicRepository.new(self) end |
#thing_product_requests_topic ⇒ Object
Handles topic thing/product/#pid/requests
60 61 62 |
# File 'lib/dji_mqtt_connect/client.rb', line 60 def thing_product_requests_topic Thing::Product::RequestsTopicRepository.new(self) end |
#thing_product_services_reply_topic ⇒ Object
Handles topic thing/product/#pid/services_reply
75 76 77 |
# File 'lib/dji_mqtt_connect/client.rb', line 75 def thing_product_services_reply_topic Thing::Product::ServicesReplyTopicRepository.new(self) end |
#thing_product_services_topic ⇒ Object
Handles topic thing/product/#pid/services
70 71 72 |
# File 'lib/dji_mqtt_connect/client.rb', line 70 def thing_product_services_topic Thing::Product::ServicesTopicRepository.new(self) end |
#thing_product_state_reply_topic ⇒ Object
Handles topic thing/product/#pid/state_reply
85 86 87 |
# File 'lib/dji_mqtt_connect/client.rb', line 85 def thing_product_state_reply_topic Thing::Product::StateReplyTopicRepository.new(self) end |
#thing_product_state_topic ⇒ Object
Handles topic thing/product/#pid/state
80 81 82 |
# File 'lib/dji_mqtt_connect/client.rb', line 80 def thing_product_state_topic Thing::Product::StateTopicRepository.new(self) end |