SPMA080 April 2021 TM4C1292NCPDT , TM4C1292NCPDT , TM4C1292NCZAD , TM4C1292NCZAD , TM4C1294KCPDT , TM4C1294KCPDT , TM4C1294NCPDT , TM4C1294NCPDT , TM4C1294NCZAD , TM4C1294NCZAD , TM4C1299KCZAD , TM4C1299KCZAD , TM4C1299NCZAD , TM4C1299NCZAD , TM4C129DNCPDT , TM4C129DNCPDT , TM4C129DNCZAD , TM4C129DNCZAD , TM4C129EKCPDT , TM4C129EKCPDT , TM4C129ENCPDT , TM4C129ENCPDT , TM4C129ENCZAD , TM4C129ENCZAD , TM4C129LNCZAD , TM4C129LNCZAD , TM4C129XKCZAD , TM4C129XKCZAD , TM4C129XNCZAD , TM4C129XNCZAD
Once the HTML file is converted to a memory image, the file is declared to the EFS file system by calling the function efs_createfile(). All the HTML files are typically created at the same time, during initialization, before the HTTP server is actually invoked. In the enet_httpServer_tirtos example code, there are two functions used, AddWebFiles() and RemoveWebFiles(). These functions include all the code necessary to initialize and clean up the EFS file environment.
Below is the snippet of example code to declare HTML files to EFS.
/* file system header file */
#include "fs/index.h"
#include "fs/about.h"
#include "fs/overview.h"
Snip…
Int getTime(SOCKET s, int length)
{
Char buf[200];
static UInt scalar = 0;
Snip…
Void AddWebFiles(Void)
{
efs_createfile("index.html", INDEX_SIZE, (UINT8 *)INDEX);
efs_createfile("overview.htm", OVERVIEW_SIZE, (UINT8 *)OVERVIEW);
efs_createfile("about.htm", ABOUT_SIZE, (UINT8 *)ABOUT);
Snip…
efs_createfile("getTime.cgi", 0, (UINT8 *)&getTime);
Snip…
Void RemoveWebFiles(Void)
{
efs_destroyfile("index.html");
efs_destroyfile("overview.htm");
efs_destroyfile("about.htm");
Snip…
efs_destroyfile("getTime.cgi");
Snip…
Figure 8-6 shows where the two hook functions AddWebFiles() and RemoveWebFiles() are declared in the NDK configuration.
Once the above code is run, the EFS system is ready for the HTTP server to serve up the content.