Send GPS data via Mavlink to ardupilot

Hi everyone. I’m using ArduCopter 4.2.2 and trying to send GPS data via Mavlink.
I use “dronekit” library to send GPS messages via Mavlink to Ardupilot with a USB cable.
my function is here:

def send_gps_raw(lat,lon,alt):
msg = vehicle.message_factory.gps_input_encode(
0, # Timestamp (micros since boot or Unix epoch)
0, # ID of the GPS for multiple GPS inputs
# Flags indicating which fields to ignore (see GPS_INPUT_IGNORE_FLAGS enum).
# All other fields must be provided.
0, # GPS time (milliseconds from start of GPS week)
0, # GPS week number
3, # 0-1: no fix, 2: 2D fix, 3: 3D fix. 4: 3D with DGPS. 5: 3D with RTK
int(lat1e7), # Latitude (WGS84), in degrees * 1E7
1e7), # Longitude (WGS84), in degrees * 1E7
alt, # Altitude (AMSL, not WGS84), in m (positive for up)
0.4, # GPS HDOP horizontal dilution of position in m
1.4, # GPS VDOP vertical dilution of position in m
0, # GPS velocity in m/s in NORTH direction in earth-fixed NED frame
0, # GPS velocity in m/s in EAST direction in earth-fixed NED frame
0, # GPS velocity in m/s in DOWN direction in earth-fixed NED frame
0, # GPS speed accuracy in m/s
0, # GPS horizontal accuracy in m
0, # GPS vertical accuracy in m
24 # Number of satellites visible.

all data has been ignored except lat, long, and HDOP. for generating lat, long, and HDOP I used UBLOX GPS connected to my PC.
I extracted GPS data via the pynmea2 library in python.
I set GPS_TYPE =14(MAV) in the parameters.
after this configuration when I ran the code GPS status was shown in MP(Its image is attached below).
When I want to ARM the vehicle in “PosHold” mode this error is displayed on MP: GPS1 is unhealthy.
What should I do?
Can anyone help me, please?

Can you please help me?


It is a guess but I wonder if maybe the mavlink messages aren’t being sent quickly enough? they need to be sent at 5hz (or higher)…