0

Part of the open source project that connects to a drone for flight planning and taking images connects to a drone using the mosquitto library using js. They tested their app using a DJI Phantom 4 Pro as indicated in the code snippet below. My question is how do I find the specific topic to include in the client.subscribe as a parameter in this case it was 'camera/dji.phantom.4.pro.hawk.1'. I tried searching the dji sdk online but I cant seem to find any information. My end goal is to make the functions connect to an arbitrary drone that is SDK ready

// Drone Position 
 var drone_general_longtitute = 0;
 var drone_general_latitude = 0;
 var points_two = [];
 client.on('connect', function() {
 console.log('MQTT SERVER SUCCESSFULLY CONNECTED');
 jQuery('#communication_server').removeClass('offline');
 jQuery('#communication_server').addClass('online');
 client.subscribe('telemetry/dji.phantom.4.pro.hawk.1', function(err) {
 if (!err) {
 client.publish('presence', 'Hello mqtt')
 } else {
 console.log(err);
 }
 })
 client.subscribe('camera/dji.phantom.4.pro.hawk.1', function(err) {
 if (!err) {
 client.publish('presence', 'Hello mqtt')
 }
 })
 client.subscribe('missionStatus/dji.phantom.4.pro.hawk.1', function(err) {
 if (!err) {
 client.publish('presence', 'Hello mqtt')
 }
 })
 client.subscribe('missionStart/dji.phantom.4.pro.hawk.1', function(err) {
 if (!err) {
 client.publish('presence', 'Hello mqtt')
 }
 })
asked Jan 11, 2024 at 9:38
1
  • Mosquitto do not have a javascript library, I see you've tagged mqtt.js which is not by mosquitto. Commented Jan 11, 2024 at 11:16

1 Answer 1

1

You talk to the author and ask them to document what topics they are using.

You can use wildcard topic patterns to subscribe to all messages, e.g telemetry/# will get you all the topics that start with telemtry/ but you will still probably need the code author to document the payload of the messages so you can make use of them.

answered Jan 11, 2024 at 11:15
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.