summaryrefslogtreecommitdiff
path: root/samples/demo_netxduo_https.c
diff options
context:
space:
mode:
authorFrédéric Desbiens <[email protected]>2025-10-02 15:52:16 +0100
committerGitHub <[email protected]>2025-10-02 15:52:16 +0100
commit8d84ebe7038e2b6114236c284093910558550492 (patch)
tree365a6bda34bb5186699d040e224773be17c4eb70 /samples/demo_netxduo_https.c
parent5af33d7d55e67dc93ddff52ec6eb74674c69cbb7 (diff)
parent582a3604fb3cef42cf53e179697fdd7f47481eb4 (diff)
Merge pull request #343 from eclipse-threadx/devv.6.4.4.202503_rel
Merge changes in preparation of the v6.4.4.202503 release.
Diffstat (limited to 'samples/demo_netxduo_https.c')
-rw-r--r--samples/demo_netxduo_https.c49
1 files changed, 41 insertions, 8 deletions
diff --git a/samples/demo_netxduo_https.c b/samples/demo_netxduo_https.c
index c4553a67..27ad9784 100644
--- a/samples/demo_netxduo_https.c
+++ b/samples/demo_netxduo_https.c
@@ -1,3 +1,14 @@
+/***************************************************************************
+ * Copyright (c) 2024 Microsoft Corporation
+ * Copyright (c) 2025 Eclipse ThreadX contributors
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the MIT License which is available at
+ * https://opensource.org/licenses/MIT.
+ *
+ * SPDX-License-Identifier: MIT
+ **************************************************************************/
+
/* This is a small demo of the NetX Web HTTP Client/Server API running on a
high-performance NetX TCP/IP stack. */
/* This demo works for IPv4 only */
@@ -358,8 +369,10 @@ extern const NX_SECURE_TLS_CRYPTO nx_crypto_tls_ciphers;
#endif /*NX_WEB_HTTPS_ENABLE */
/* Define the RAM disk memory for FileX demo. */
+#define TOTAL_SECTORS 256
+#define SECTOR_SIZE 512
static UCHAR media_memory[4096];
-static CHAR ram_disk_memory[4096];
+static CHAR ram_disk_memory[TOTAL_SECTORS*SECTOR_SIZE];
static FX_MEDIA ram_disk;
/* HTTP server stack area. */
@@ -712,12 +725,15 @@ void https_server_thread_entry(ULONG thread_input)
UINT status;
UINT server_port;
-
-
NX_PARAMETER_NOT_USED(thread_input);
-
- fx_media_format(&ram_disk,
+ /* Format the RAM disk - the memory for the RAM disk was setup in
+ tx_application_define above.
+
+ Important Note: The user must ensure there is enough RAM for the format
+ specified. Otherwise, memory corruption can occur.
+ */
+ status = fx_media_format(&ram_disk,
_fx_ram_driver, // Driver entry
ram_disk_memory, // RAM disk memory pointer
media_memory, // Media buffer pointer
@@ -726,14 +742,31 @@ UINT server_port;
1, // Number of FATs
32, // Directory Entries
0, // Hidden sectors
- 256, // Total sectors
- 512, // Sector size
+ TOTAL_SECTORS, // Total sectors
+ SECTOR_SIZE, // Sector size
8, // Sectors per cluster
1, // Heads
1); // Sectors per track
+ /* Determine if the RAM disk format was successful. */
+ if (status != FX_SUCCESS)
+ {
+ /* Error formatting the RAM disk. */
+ printf("HTTPS RAM disk format failed, error: %x\n", status);
+ return;
+ }
+
/* Open the RAM disk. */
- fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, media_memory, sizeof(media_memory)) ;
+ status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver,
+ ram_disk_memory, media_memory, sizeof(media_memory));
+
+ /* Determine if the RAM disk open was successful. */
+ if (status != FX_SUCCESS)
+ {
+ /* Error formatting the RAM disk. */
+ printf("HTTPS RAM disk open failed, error: %x\n", status);
+ return;
+ }
fx_file_create(&ram_disk, "TEST.TXT");