Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Example code
#include  <Source/http-s.h>
#include  <FS/uC-FS-V4/net_fs_v4.h>                             /* See Note #4.                                         */
 
CPU_BOOLEAN  AppHTTPsInit (void)
{
    HTTPs_INSTANCE  *p_https_instance;
    HTTPs_ERR        http_err;

    /* TODO:                                                                                                            */
    /*      Prerequisites modules must be initialized prior calling any of the following functions. See Note #1.        */
    /*      Make sure File System (such as uC/FS) is initialized before starting the instance. See Note #2.             */
    /*      Make sure Files that must serve by the web server is loaded in the file system. See Note #2.                */

                                                                /* -------------- INITALIZE HTTPS MODULE -------------- */
    http_err = HTTPs_Init();                                    /* See Note #3.                                         */
    if (http_err != HTTPs_ERR_NONE) {
        return (DEF_FAIL);
    }

                                                                /* ---------- INITALIZE WEB SERVER INSTANCE ----------- */
    p_https_instance = HTTPs_InstanceInit(&HTTPs_CfgInstance_0, /* Instance configuration. See Note #4a.                */
                                          &NetFS_API_FS_V4,     /* File system  API.See Note #4b.                       */
                                          &http_err);
    if (http_err != HTTPs_ERR_NONE) {
        return (DEF_FAIL);
    }

                                                                /* ------------ START WEB SERVER INSTANCE ------------- */
    HTTPs_InstanceStart(p_https_instance,                       /* Instance handle. See Note #5.                        */
                       &http_err);
    if (http_err != HTTPs_ERR_NONE) {
        return (DEF_FAIL);
    }
    return (DEF_OK);
}

 

  1. Prerequisite modules must be initialized before calling any uC/HTTPs functions.

  2. Obviously before starting or trying to reach web server. The files must loaded in the file system to be able to get it using an HTTP client.

  3. Prior to do any call to uC/HTTPs, the module must be initialized. This is done by calling HTTPs_Init(). If the process is successful, the Web server internal data structures are initialized.

  4. Each web server must be initialized before it can be started or stopped. HTTPs_InstanceInit() is responsible to allocate memory for the instance, initialize internal data structure and create the web server instance's task..

    1. The first argument is the instance configuration, which should be modified following you requirements. The intance's configuration set the server's port, the number of connection that can be accepted, the hooks functions, etc.

    2. The second argument is the pointer to the File system port API. uC/HTTPs is using the API defined by the uC/TCP-IP Network file system abstraction layer to access the File system. The API structure can be found in:

      1. The uC/TCP-IP Network file system abstraction layer folder for traditional file system;

        '$uC-TCPIP/FS/<fs>/net_<fs>.h'
        NetFS_API_FS_V4
         

      2. The static file system API is located under uC/HTTPs File system folder;

        '$uc-HTTPs/FS/Static/http-s_fs_static.h'
        HTTPs_FS_API_Static
         

  5. Once a web server instance is initialized, it can be started using HTTPs_InstanceStart() to become come accessible. This function start the web server instance's task. Each instance has is own task and all accepted connection is processed with this single task.

 

 

  • No labels