4.1.8.5 System Service

The system service provides API's to set and get the system level details. The following table lists all the services exposed by the system service layer. The system service API prototype is as follows:
SYS_WINCS_RESULT_t SYS_WINCS_SYSTEM_SrvCtrl(SYS_WINCS_SYSTEM_SERVICE_t request, SYS_WINCS_SYSTEM_HANDLE_t systemHandle);
  1. Firmware Version Info structure
  2. Device Info structure
  3. Driver Version Info structure
Firmware Version Info structure
typedef struct
{
    /* Flag indicating if this information is valid. */
    bool isValid;

    /* Version number structure. */
    struct
    {
        /* Major version number. */
        uint16_t major;

        /* Major minor number. */
        uint16_t minor;

        /* Major patch number. */
        uint16_t patch;
    } version;

    /* Build date/time structure. */
    struct
    {
        uint8_t hash[APP_BUILD_HASH_SZ];

        uint32_t timeUTC;
    } build;
} APP_FIRMWARE_VERSION_INFO;
Device Info structure
typedef struct
{
    /* Flag indicating if this information is valid. */
    bool isValid;

    /* WINC device ID. */
    uint32_t id;

    /* Number of flash images. */
    uint8_t numImages;

    /* Information for each device image. */
    struct
    {
        /* Sequence number. */
        uint32_t seqNum;

        /* Version information. */
        uint32_t version;

        /* Source address. */
        uint32_t srcAddr;
    } image[APP_DI_IMAGE_INFO_NUM];
} DEVICE_INFO;
Driver Version Info structure
typedef struct
{
    /* Version number structure. */
    struct
    {
        /* Major version number. */
        uint16_t major;

        /* Major minor number. */
        uint16_t minor;

        /* Major patch number. */
        uint16_t patch;
    } version;
} DRIVER_VERSION_INFO;
The table below shows the various commands and options available for system service.
Table 4-9. System Service Options Table
Option/CommandInputRemarks
SYS_WINCS_SYSTEM_RESETNoneRequest/Trigger Reset the system
SYS_WINCS_SYSTEM_SW_REVFIRMWARE_VERSION_INFO structureRequest Software Revision
SYS_WINCS_SYSTEM_DEV_INFODEVICE_INFO structureRequest Device Info
SYS_WINCS_SYSTEM_GET_CERT_LISTNoneGet the available certificate list
SYS_WINCS_SYSTEM_GET_KEY_LISTDRIVER_VERSION_INFO structureGet the available private key list
SYS_WINCS_SYSTEM_DRIVER_VERBuffer array to read Driver versionRequest Driver version
SYS_WINCS_SYSTEM_SET_SYS_EVENT_CALLBACKCallback HandlerSet Driver system event callback
SYS_WINCS_SYSTEM_DEBUG_UART_SETNullDebug firmware logs
SYS_WINCS_SYSTEM_SET_DEBUG_REG_CLBKNullUser defined printf
Following are few examples to use the system service API's
/*
    System Service application
*/

void APP_WINCS02_Tasks ( void )
{
 
    /* Check the application's current state. */
    switch ( appData.state )
    {
        /* Application's initial state. */
        case APP_STATE_INIT:
        {
            SYS_STATUS status;
            SYS_WINCS_WIFI_SrvCtrl(SYS_WINCS_WIFI_GET_DRV_STATUS, &status);
 
            if (SYS_STATUS_READY == status)
            {
                appData.state = APP_STATE_WINCS_OPEN_DRIVER;
            }
            break;
        }
        case APP_STATE_WINCS_OPEN_DRIVER:
        {
            DRV_HANDLE wdrvHandle = DRV_HANDLE_INVALID;
            SYS_WINCS_WIFI_SrvCtrl(SYS_WINCS_WIFI_OPEN_DRIVER, &wdrvHandle);
            SYS_WINCS_WIFI_SrvCtrl(SYS_WINCS_WIFI_GET_DRV_HANDLE, &wdrvHandle);
            SYS_CONSOLE_PRINT("wdrvHandle : %d\r\n",wdrvHandle);
            appData.state = APP_STATE_WINCS_DEVICE_INFO;
            break;
        }
        case APP_STATE_WINCS_DEVICE_INFO:
        {
            APP_DRIVER_VERSION_INFO drvVersion;
            APP_FIRMWARE_VERSION_INFO fwVersion;
            APP_DEVICE_INFO devInfo;
            SYS_WINCS_RESULT_t status = SYS_WINCS_BUSY;
            status = SYS_WINCS_SYSTEM_SrvCtrl(SYS_WINCS_SYSTEM_SW_REV,&fwVersion);
            if(status == SYS_WINCS_PASS)
            {
                status = SYS_WINCS_SYSTEM_SrvCtrl(SYS_WINCS_SYSTEM_DEV_INFO, &devInfo);
            }
            if(status == SYS_WINCS_PASS)
            {
                status = SYS_WINCS_SYSTEM_SrvCtrl (SYS_WINCS_SYSTEM_DRIVER_VER, &drvVersion);
            }
            if(status == SYS_WINCS_PASS)
            {
                char buff[30];
                SYS_CONSOLE_PRINT("WINC: Device ID = %08x\r\n", devInfo.id);
                for (int i=0; i<devInfo.numImages; i++)
                {
                    SYS_CONSOLE_PRINT("%d: Seq No = %08x, Version = %08x, Source Address = %08x\r\n", i, devInfo.image[i].seqNum, devInfo.image[i].version, devInfo.image[i].srcAddr);
                }
                SYS_CONSOLE_PRINT("Firmware Version: %d.%d.%d ", fwVersion.version.major, fwVersion.version.minor, fwVersion.version.patch);
                strftime(buff, sizeof(buff), "%X %b %d %Y", localtime((time_t*)&fwVersion.build.timeUTC));
                SYS_CONSOLE_PRINT(" [%s]\r\n", buff);
                SYS_CONSOLE_PRINT("Driver Version: %d.%d.%d\r\n", drvVersion.version.major, drvVersion.version.minor, drvVersion.version.patch);
            }
        }    
    }
}