Fix an issue that an incorrect timeout period was used while wait for Wi-Fi resource for PAF (#39504)

* Resolve an issue that an incorrect timeout period was used while waiting for the Wi-Fi resource in PAF

Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com>

* Restyled by clang-format

* Add to also start "wait_resource" timer if the SendQueue is not null

Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com>

* Update src/wifipaf/WiFiPAFEndPoint.cpp

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Fix the incorrect checking condition to start the "wait_resource" timer

Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com>

---------

Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com>
Co-authored-by: Restyled.io <commits@restyled.io>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
diff --git a/src/wifipaf/WiFiPAFEndPoint.cpp b/src/wifipaf/WiFiPAFEndPoint.cpp
index 85bb79f..9667f13 100644
--- a/src/wifipaf/WiFiPAFEndPoint.cpp
+++ b/src/wifipaf/WiFiPAFEndPoint.cpp
@@ -72,8 +72,7 @@
 #define WIFIPAF_ACK_SEND_TIMEOUT_MS 2500
 #define WIFIPAF_WAIT_RES_TIMEOUT_MS 1000
 // Drop the connection if network resources remain unavailable for the period.
-// Known condition: If the remote side is awaiting an ACK packet, the wait time must not exceed PAFTP_ACK_TIMEOUT_MS.
-#define WIFIPAF_MAX_RESOURCE_BLOCK_COUNT (PAFTP_ACK_TIMEOUT_MS / WIFIPAF_WAIT_RES_TIMEOUT_MS)
+#define WIFIPAF_MAX_RESOURCE_BLOCK_COUNT (PAFTP_CONN_IDLE_TIMEOUT_MS / WIFIPAF_WAIT_RES_TIMEOUT_MS)
 
 /**
  *  @def WIFIPAF_WINDOW_NO_ACK_SEND_THRESHOLD
@@ -603,7 +602,7 @@
         return CHIP_NO_ERROR;
     }
 
-    if (!mWiFiPafLayer->mWiFiPAFTransport->WiFiPAFResourceAvailable())
+    if (!mWiFiPafLayer->mWiFiPAFTransport->WiFiPAFResourceAvailable() && (!mAckToSend.IsNull() || !mSendQueue.IsNull()))
     {
         // Resource is currently unavailable, send packets later
         StartWaitResourceTimer();
@@ -1097,7 +1096,6 @@
         else
         {
             ChipLogDebugWiFiPAFEndPoint(WiFiPAF, "starting send-ack timer");
-
             // Send ack when timer expires.
             err = StartSendAckTimer();
             SuccessOrExit(err);
@@ -1201,7 +1199,7 @@
     }
     if (!mTimerStateFlags.Has(TimerStateFlag::kWaitResTimerRunning))
     {
-        ChipLogDebugWiFiPAFEndPoint(WiFiPAF, "starting new SendAckTimer");
+        ChipLogDebugWiFiPAFEndPoint(WiFiPAF, "starting new WaitResTimer");
         const CHIP_ERROR timerErr = mWiFiPafLayer->mSystemLayer->StartTimer(
             System::Clock::Milliseconds32(WIFIPAF_WAIT_RES_TIMEOUT_MS), HandleWaitResourceTimeout, this);
         ReturnErrorOnFailure(timerErr);