if(verbose&¤t_state==PX_WPP_IDLE)printf("Got MAVLINK_MSG_ID_WAYPOINT_REQUEST_LIST from %u changing state to PX_WPP_SENDLIST\n",msg->sysid);
if(verbose&¤t_state==PX_WPP_SENDLIST)printf("Got MAVLINK_MSG_ID_WAYPOINT_REQUEST_LIST again from %u staying in state PX_WPP_SENDLIST\n",msg->sysid);
if(verbose&¤t_state==PX_WPP_IDLE)qDebug("Got MAVLINK_MSG_ID_WAYPOINT_REQUEST_LIST from %u changing state to PX_WPP_SENDLIST\n",msg->sysid);
if(verbose&¤t_state==PX_WPP_SENDLIST)qDebug("Got MAVLINK_MSG_ID_WAYPOINT_REQUEST_LIST again from %u staying in state PX_WPP_SENDLIST\n",msg->sysid);
//ensure that we are in the correct state and that the first request has id 0 and the following requests have either the last id (re-send last waypoint) or last_id+1 (next waypoint)
if(verbose&¤t_state==PX_WPP_SENDLIST)printf("Got MAVLINK_MSG_ID_WAYPOINT_REQUEST of waypoint %u from %u changing state to PX_WPP_SENDLIST_SENDWPS\n",wpr.seq,msg->sysid);
if(verbose&¤t_state==PX_WPP_SENDLIST_SENDWPS&&wpr.seq==protocol_current_wp_id+1)printf("Got MAVLINK_MSG_ID_WAYPOINT_REQUEST of waypoint %u from %u staying in state PX_WPP_SENDLIST_SENDWPS\n",wpr.seq,msg->sysid);
if(verbose&¤t_state==PX_WPP_SENDLIST_SENDWPS&&wpr.seq==protocol_current_wp_id)printf("Got MAVLINK_MSG_ID_WAYPOINT_REQUEST of waypoint %u (again) from %u staying in state PX_WPP_SENDLIST_SENDWPS\n",wpr.seq,msg->sysid);
if(verbose&¤t_state==PX_WPP_SENDLIST)qDebug("Got MAVLINK_MSG_ID_WAYPOINT_REQUEST of waypoint %u from %u changing state to PX_WPP_SENDLIST_SENDWPS\n",wpr.seq,msg->sysid);
if(verbose&¤t_state==PX_WPP_SENDLIST_SENDWPS&&wpr.seq==protocol_current_wp_id+1)qDebug("Got MAVLINK_MSG_ID_WAYPOINT_REQUEST of waypoint %u from %u staying in state PX_WPP_SENDLIST_SENDWPS\n",wpr.seq,msg->sysid);
if(verbose&¤t_state==PX_WPP_SENDLIST_SENDWPS&&wpr.seq==protocol_current_wp_id)qDebug("Got MAVLINK_MSG_ID_WAYPOINT_REQUEST of waypoint %u (again) from %u staying in state PX_WPP_SENDLIST_SENDWPS\n",wpr.seq,msg->sysid);
if(!(current_state==PX_WPP_SENDLIST||current_state==PX_WPP_SENDLIST_SENDWPS)){printf("Ignored MAVLINK_MSG_ID_WAYPOINT_REQUEST because i'm doing something else already (state=%i).\n",current_state);break;}
if(!(current_state==PX_WPP_SENDLIST||current_state==PX_WPP_SENDLIST_SENDWPS)){qDebug("Ignored MAVLINK_MSG_ID_WAYPOINT_REQUEST because i'm doing something else already (state=%i).\n",current_state);break;}
elseif(current_state==PX_WPP_SENDLIST)
{
if(wpr.seq!=0)printf("Ignored MAVLINK_MSG_ID_WAYPOINT_REQUEST because the first requested waypoint ID (%u) was not 0.\n",wpr.seq);
if(wpr.seq!=0)qDebug("Ignored MAVLINK_MSG_ID_WAYPOINT_REQUEST because the first requested waypoint ID (%u) was not 0.\n",wpr.seq);
}
elseif(current_state==PX_WPP_SENDLIST_SENDWPS)
{
if(wpr.seq!=protocol_current_wp_id&&wpr.seq!=protocol_current_wp_id+1)printf("Ignored MAVLINK_MSG_ID_WAYPOINT_REQUEST because the requested waypoint ID (%u) was not the expected (%u or %u).\n",wpr.seq,protocol_current_wp_id,protocol_current_wp_id+1);
elseif(wpr.seq>=waypoints->size())printf("Ignored MAVLINK_MSG_ID_WAYPOINT_REQUEST because the requested waypoint ID (%u) was out of bounds.\n",wpr.seq);
if(wpr.seq!=protocol_current_wp_id&&wpr.seq!=protocol_current_wp_id+1)qDebug("Ignored MAVLINK_MSG_ID_WAYPOINT_REQUEST because the requested waypoint ID (%u) was not the expected (%u or %u).\n",wpr.seq,protocol_current_wp_id,protocol_current_wp_id+1);
elseif(wpr.seq>=waypoints->size())qDebug("Ignored MAVLINK_MSG_ID_WAYPOINT_REQUEST because the requested waypoint ID (%u) was out of bounds.\n",wpr.seq);
if(verbose)printf("Ignored MAVLINK_MSG_ID_WAYPOINT_REQUEST from ID %u because i'm already talking to ID %u.\n",msg->sysid,protocol_current_partner_systemid);
if(verbose)qDebug("Ignored MAVLINK_MSG_ID_WAYPOINT_REQUEST from ID %u because i'm already talking to ID %u.\n",msg->sysid,protocol_current_partner_systemid);
if(verbose&¤t_state==PX_WPP_IDLE)printf("Got MAVLINK_MSG_ID_WAYPOINT_COUNT (%u) from %u changing state to PX_WPP_GETLIST\n",wpc.count,msg->sysid);
if(verbose&¤t_state==PX_WPP_GETLIST)printf("Got MAVLINK_MSG_ID_WAYPOINT_COUNT (%u) again from %u\n",wpc.count,msg->sysid);
if(verbose&¤t_state==PX_WPP_IDLE)qDebug("Got MAVLINK_MSG_ID_WAYPOINT_COUNT (%u) from %u changing state to PX_WPP_GETLIST\n",wpc.count,msg->sysid);
if(verbose&¤t_state==PX_WPP_GETLIST)qDebug("Got MAVLINK_MSG_ID_WAYPOINT_COUNT (%u) again from %u\n",wpc.count,msg->sysid);
if(verbose&¤t_state==PX_WPP_GETLIST)printf("Got MAVLINK_MSG_ID_WAYPOINT %u from %u changing state to PX_WPP_GETLIST_GETWPS\n",wp.seq,msg->sysid);
if(verbose&¤t_state==PX_WPP_GETLIST_GETWPS&&wp.seq==protocol_current_wp_id)printf("Got MAVLINK_MSG_ID_WAYPOINT %u from %u\n",wp.seq,msg->sysid);
if(verbose&¤t_state==PX_WPP_GETLIST_GETWPS&&wp.seq-1==protocol_current_wp_id)printf("Got MAVLINK_MSG_ID_WAYPOINT %u (again) from %u\n",wp.seq,msg->sysid);
if(verbose&¤t_state==PX_WPP_GETLIST)qDebug("Got MAVLINK_MSG_ID_WAYPOINT %u from %u changing state to PX_WPP_GETLIST_GETWPS\n",wp.seq,msg->sysid);
if(verbose&¤t_state==PX_WPP_GETLIST_GETWPS&&wp.seq==protocol_current_wp_id)qDebug("Got MAVLINK_MSG_ID_WAYPOINT %u from %u\n",wp.seq,msg->sysid);
if(verbose&¤t_state==PX_WPP_GETLIST_GETWPS&&wp.seq-1==protocol_current_wp_id)qDebug("Got MAVLINK_MSG_ID_WAYPOINT %u (again) from %u\n",wp.seq,msg->sysid);
if(!(wp.seq==protocol_current_wp_id))printf("Ignored MAVLINK_MSG_ID_WAYPOINT because the waypoint ID (%u) was not the expected %u.\n",wp.seq,protocol_current_wp_id);
elseif(!(wp.seq<protocol_current_count))printf("Ignored MAVLINK_MSG_ID_WAYPOINT because the waypoint ID (%u) was out of bounds.\n",wp.seq);
if(!(wp.seq==protocol_current_wp_id))qDebug("Ignored MAVLINK_MSG_ID_WAYPOINT because the waypoint ID (%u) was not the expected %u.\n",wp.seq,protocol_current_wp_id);
elseif(!(wp.seq<protocol_current_count))qDebug("Ignored MAVLINK_MSG_ID_WAYPOINT because the waypoint ID (%u) was out of bounds.\n",wp.seq);
if(verbose)printf("Ignored MAVLINK_MSG_ID_WAYPOINT %u from ID %u because i'm already talking to ID %u.\n",wp.seq,msg->sysid,protocol_current_partner_systemid);
if(verbose)qDebug("Ignored MAVLINK_MSG_ID_WAYPOINT %u from ID %u because i'm already talking to ID %u.\n",wp.seq,msg->sysid,protocol_current_partner_systemid);