Acknowledge of Arm/Disarm command on STM32 MCU

Currently I’m working on receiving Mavlink Arm/Disarm command sent from qgc and receive on my STM32 board.

My current program flow is as follow:

  1. Sends Arm command from qgc to STM32
  2. STM32 checks and confirms the command is of “MAV_CMD_COMPONENT_ARM_DISARM”. Thus performs its Arm routines and changes heartbeat field system_mode (to MAV_MODE_FLAG_SAFETY_ARMED).
  3. On qgc, it switches to [Arm status]
  4. The screen shows error saying that: ”Aircraft did not respond to command: MAV_CMD_COMPONENT_ARM_DISARM” (Sorry I’m usingJapanese version of qgc)

I have done several research on Internet and try everything in my ability by changing to various parameter on heart message, but still don’t succeed on acknowledging it correctly from STM32.

I would be thankful if someone can give me guidance how to solve this.

Are you responding with a COMMAND_ACK?

1 Like

Hi JulianOnes,

Thanks for your hint, this seems like a correct way to go.
I am trying to acknowledge the command by using
mavlink_msg_command_ack_pack(), but the error still occurs. Below is my code:

I guess probably something isn’t right with the last two arguments for target system_id and component_id (qgroundcontrol’s id).
Do you have any idea regarding this?

You need to send the ack back to where the command came from. So the source of the command_long becomes the target of the ack.

Hi JulianOnes,
I got my mistake. As you said, I changed to the correct target system and component. But the error remains the same.

The code

Immediately sending back acknowledge message doesn’t work, as a temporary fix I have to put it into 10Hz loop to continuously send acknowledge commmd and the pop-up disappeared now.

That doesn’t sound right…

sysid of -1 and compid of -66 don’t look correct at all.

I don’t know what values are expected but that’s the sysid and compid from my qgroundcontrol instance (not yet converted to unsigned integer 8)

I am able to acknowledge Arm command successfully but not in a proper manner.
Does any have idea with how should I reply the command after receiving Arm command from Qgc (what timing…)? Replying immediately doesn’t work in my case.

Does this example help?

This is how it is done in the MAVSDK autopilot_server based on the action_server plugin.