In your decoding logic, you need to make sure you’re using the full-frame counter, as only the 16 least-significant bits of the FCnt are emitted. The 16 most-significant bits you have to derive yourself by observing the previous messages (https://lora-alliance.org/lorawan-for-developers).
Example:
When the uplink-frame counter is 65539 at the device (32 bit), the received LoRaWAN frame by the gateway will contain frame-counter 3 (as 65539 % 2^16 = 3). However, you need to set it back to 65539 to validate the MIC and decrypt it.