From 0d08a99aa3f5d3619706839ee34d7606a05d2cfe Mon Sep 17 00:00:00 2001
From: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com>
Date: Thu, 30 May 2024 08:57:23 +0800
Subject: [PATCH] Add CELLULAR_CONFIG_PKTIO_READ_BUFFER_SIZE config (#173)
* Add CELLULAR_CONFIG_PKTIO_READ_BUFFER_SIZE config
---
docs/doxygen/pages.dox | 3 +++
source/include/cellular_config_defaults.h | 13 +++++++++++++
source/include/private/cellular_common_internal.h | 2 +-
3 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/docs/doxygen/pages.dox b/docs/doxygen/pages.dox
index 6811a52c..206efa77 100644
--- a/docs/doxygen/pages.dox
+++ b/docs/doxygen/pages.dox
@@ -196,6 +196,9 @@ Some configuration settings are C pre-processor constants, and some are function
@section CELLULAR_CONFIG_PLATFORM_FREERTOS
@copydoc CELLULAR_CONFIG_PLATFORM_FREERTOS
+@section CELLULAR_CONFIG_PKTIO_READ_BUFFER_SIZE
+@copydoc CELLULAR_CONFIG_PKTIO_READ_BUFFER_SIZE
+
@section CELLULAR_MODEM_NO_EPS_NETWORK
@brief Macro to disable querying evolved packet system (EPS) network registration status in Cellular_CommonGetServiceStatus.
@note Cellular modem porting can define this macro in cellular_config.h to disable this function.
diff --git a/source/include/cellular_config_defaults.h b/source/include/cellular_config_defaults.h
index 618da42b..05eb36db 100644
--- a/source/include/cellular_config_defaults.h
+++ b/source/include/cellular_config_defaults.h
@@ -503,6 +503,19 @@
#define PlatformQueue_Delete vQueueDelete
#endif /* if CELLULAR_CONFIG_PLATFORM_FREERTOS */
+/**
+ * @brief Pktio read buffer size.
+ *
+ * The pktio read buffer size should be configured to greater than the maximum AT command
+ * response size, which is typically the TCP socket receive command response packet size.
+ *
+ * Possible values:`Any positive integer`
+ * Default value (if undefined): 1600
+ */
+#ifndef CELLULAR_CONFIG_PKTIO_READ_BUFFER_SIZE
+ #define CELLULAR_CONFIG_PKTIO_READ_BUFFER_SIZE 1600U
+#endif
+
/**
* @brief Macro that is called in the cellular library for logging "Error" level
* messages.
diff --git a/source/include/private/cellular_common_internal.h b/source/include/private/cellular_common_internal.h
index 5b6e073d..4b9fe3f5 100644
--- a/source/include/private/cellular_common_internal.h
+++ b/source/include/private/cellular_common_internal.h
@@ -48,7 +48,7 @@
/*-----------------------------------------------------------*/
-#define PKTIO_READ_BUFFER_SIZE ( 1600U ) /* This should be larger than TCP packet size. */
+#define PKTIO_READ_BUFFER_SIZE ( CELLULAR_CONFIG_PKTIO_READ_BUFFER_SIZE )
#define PKTIO_WRITE_BUFFER_SIZE ( CELLULAR_AT_CMD_MAX_SIZE )
/*-----------------------------------------------------------*/