Pixhawk rejects offboard mode

I am trying to control the pixhawk using setpoints in offboard mode without using ROS. This is in an indoor environment and now I have a pxflow for local position. I can see the local position estimate but the pixhawk won’t seem to accept set point position target msgs nor offboard mode.

I tried Lorenz Meier c uart example: https://github.com/mavlink/c_uart_interface_example. I’ve had it go into offboard mode (as verified by QGC) a handful of times and most times it says set mode command temporarily rejected. This is extremely frustrating as I do not know what the error is referring to nor why it sometimes works even though absolutely nothing else has changed, not even the physical position of the quad.

Secondly, if offboard mode cannot be enabled before optical flow is established, and optical flow does not seem to work that well when the quad has landed, how do you get it to take off?

You have to send 100 setpoints before putting the multicopter in OFFBOARD mode. Can you check you are ?