Switching to Offboard mode in microcomputer via mavlink


I run into confusing problems when using a single chip microcomputer (msp430) as a companion computer to control px4. I have searched for possible solutions for several days but most solutions are about MAVROS, few touch on using microcomputers, so finally, I have to ask for help and I apologize for my noob questions in advance. Here are my problems:

  1. I can only receive messages of heartbeat, imu, attitude, sys_status, but the message of LOCAL_POSITION_NED, GLOBAL_POSITION_INT, OPTICAL_FLOW, and others.
  2. Cannot set the px4 as Offboard mode.

For problem 1, I have tried several methods but none of them work: I have tried sending the message of REQUEST_DATA_STREAM and the command of MAV_CMD_SET_MESSAGE_INTERVAL but I still cannot receive the message that I want from px4. At first, I thought it was because of the lack of GPS module but later even though I connected it with the pixhawk, message of LOCAL_POSITION_NED is still unavailable in QGC and my msp430.

For problem2, I kept sending a stream of target setpoints and armed the vehicle before trying to enter the offboard mode, and then I send the command of MAV_CMD_DO_SET_MODE with the base mode of MAV_MODE_FLAG_CUSTOM_MODE_ENABLED and custom mode of PX4_CUSTOM_MAIN_MODE_OFFBOARD, but it still refuses to switch to the offboard mode. I am very confused.

The code running in my microcomputer is based on the example from Mavlink Guide. Since my microcomputer can not handle multi-thread at the same time, I modified the example code from C++ to C.

I am wondering if there are some configurations I missed or something I did wrong.

Thanks for your help in advance.

the example code I referred to is here