MAVLink Messages between APM 2.5 and Arduino ADK

'm developing a system where I have an Android mobile connected to ADK board. This ADK is connected via UART to the APM telemetry port. (IN-TX, OUT-RX)
For testing purpouses i’m trying to get parameters of APM through the arduino and seeing them on Mission Planner as if we were only connecting APM to a desktop by USB.
When I connect the APM to the desktop I am able to see all the parameters and variables changing. But when I connect the APM to the Arduino and the Arduino to the PC it receives the heartbeat message but then retrives communication failed because the packages were empty.
I’m new to this MAVLink communication and I’m having a hard time to get through it. I hope somebody could help me!

So this is the code I have at the moment:

// Arduino MAVLink test code.
#include <FastSerial.h>
#include “…/mavlink/include/mavlink.h” // Mavlink interface

void setup() {

void loop() {
/* The default UART header for your MCU */
int sysid = 20; ///< ID 20 for this airplane
int compid = MAV_COMP_ID_IMU; ///< The component sending the message is the IMU, it could be also a Linux process
int type = MAV_TYPE_QUADROTOR; ///< This system is an airplane / fixed wing

// Define the system type, in this case an airplane
uint8_t system_type = MAV_TYPE_FIXED_WING;
uint8_t autopilot_type = MAV_AUTOPILOT_GENERIC;

uint8_t system_mode = MAV_MODE_PREFLIGHT; ///< Booting up
uint32_t custom_mode = 0; ///< Custom mode, can be defined by user/adopter
uint8_t system_state = MAV_STATE_STANDBY; ///< System ready for flight
// Initialize the required buffers
mavlink_message_t msg;

// Pack the message
mavlink_msg_heartbeat_pack(sysid,compid, &msg, type, autopilot_type, system_mode, custom_mode, system_state);

// Copy the message to the send buffer
uint16_t len = mavlink_msg_to_send_buffer(buf, &msg);

// Send the message with the standard UART send function
// uart0_send might be named differently depending on
// the individual microcontroller / library in use.
Serial.write(buf, len);
void comm_receive() {

   mavlink_message_t msg;
    mavlink_status_t status;

    while(Serial.available() > 0 )
            uint8_t c =;
            // Try to get a new message
            if(mavlink_parse_char(MAVLINK_COMM_0, c, &msg, &status)) {
                    // Handle message

                     case MAVLINK_MSG_ID_HEARTBEAT:
                             // E.g. read GCS heartbeat and go into
                              // comm lost mode if timer times out
                    case MAVLINK_MSG_ID_COMMAND_LONG:
                            // EXECUTE ACTION
                            //Do nothing

            // And get the next one


if you don’t manage to get a response here you might raise it again on where more of the developers talk about things.
it could be a number of things… maybe the target id of your request isn’t set to the vehicle’s id so it’s ignoring your request.