Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The C array having been generated by this utility then have to be included into your project’s application (see file static_files.h for complete example). Finally, prior to being able to access the files on the static file system, you need to initialize it and add the files to it, just like it is being done in the listing below.

Code Block
languagecpp
titleListing - Example code of static file system usage
linenumberstrue
static  void  AppTaskStart (void  *p_arg) 
{
  [...]
  HTTPs_FS_Init();                                               (1)
  HTTPs_FS_AddFile((CPU_CHAR *)&STATIC_INDEX_HTML_NAME[0],       (2)
                   (void     *)&index_html[0],
                   (CPU_INT32U) STATIC_INDEX_HTML_LEN);
  HTTPs_FS_AddFile ((CPU_CHAR *)&STATIC_LOGO_GIF_NAME[0],
                    (void     *)&logo_gif[0], 
                    (CPU_INT32U) STATIC_LOGO_GIF_LEN);
  HTTPs_FS_AddFile ((CPU_CHAR *)&STATIC_404_HTML_NAME[0],
                    (void     *)¬_found_html[0], 
                    (CPU_INT32U) STATIC_404_HTML_LEN);
  [...]
}


Panel
bgColor#f0f0f0

(1) Initialize the static file system.

(2) Add files to the static file system.



Python Script

A python script named GenerateFS.py is also offered in the µC/HTTP package allowing to convert files into C arrays. The script can be useful if many files are to be converted since it support recursion inside a folder. The script also generate C files (generated_fs.c/.h) with the function to call to include all the C arrays generated.

...