Virgil IoT KIT
Typedefs | Functions
fldt-server.h File Reference

FLDT for server. More...

#include <virgil/iot/update/update.h>
#include <virgil/iot/protocols/snap/snap-structs.h>
#include <virgil/iot/status_code/status_code.h>

Go to the source code of this file.

Typedefs

typedef vs_status_e(* vs_fldt_server_add_filetype_cb) (const vs_update_file_type_t *file_type, vs_update_interface_t **update_ctx)
 Add new file type callback. More...
 

Functions

const vs_snap_service_tvs_snap_fldt_server (const vs_mac_addr_t *gateway_mac, vs_fldt_server_add_filetype_cb add_filetype)
 FLDT Server SNAP Service implementation. More...
 
vs_status_e vs_fldt_server_add_file_type (const vs_update_file_type_t *file_type, vs_update_interface_t *update_context, bool broadcast_file_info)
 Add file type. More...
 

Detailed Description

FLDT for server.

FLDT service is used to download new file version from gateway to client. This module is used to process server part of FLDT protocol.

FLDT Server Usage

Server side sends new file versions provided by vs_fldt_server_add_file_type call. Also it sends information about present files by client requests. Files must be previously listed by vs_fldt_server_add_file_type call. If requested file has not been added, #vs_fldt_server_add_filetype callback is called to provide such information. In most case it used to output new file version information and gateway address. To successfully file broadcasting vs_update_interface_t must be provided for each file type. You can see function vs_firmware_update_file_type for Firmware example and vs_tl_update_file_type for Trust List one.

Here you can see an example of FLDT server initialization :

const vs_snap_service_t *snap_fldt_server;
const vs_mac_addr_t mac_addr;
snap_fldt_server = vs_snap_fldt_server( &mac_addr, _add_filetype );
"Cannot register FLDT server service" );
"Unable to add Firmware file type" );
"Unable to add Trust List file type" );
*

You can see #vs_fldt_server_add_filetype function example below :

_add_filetype(const vs_update_file_type_t *file_type, vs_update_interface_t **update_ctx) {
switch (file_type->type) {
*update_ctx = vs_firmware_update_ctx();
break;
*update_ctx = vs_tl_update_ctx();
break;
default:
VS_LOG_ERROR("Unsupported file type : %d", file_type->type);
}
return VS_CODE_OK;
}

Typedef Documentation

◆ vs_fldt_server_add_filetype_cb

typedef vs_status_e(* vs_fldt_server_add_filetype_cb) (const vs_update_file_type_t *file_type, vs_update_interface_t **update_ctx)

Add new file type callback.

Callback for vs_snap_fldt_server function. This callback is used when gateway receives request for file type that has not been added by vs_fldt_server_add_file_type call.

Warning
Valid pointer to the update context with all implementations must be provided.
Note
In next release default implementation for Firmware and Trust List will be provided.
Parameters
[in]file_typeFile type descriptor. Cannot be NULL.
[in,out]update_ctxPointer to store update nont NULL context pointer for new file type. Cannot be NULL.
Returns
VS_CODE_OK in case of success or error code.

Function Documentation

◆ vs_fldt_server_add_file_type()

vs_status_e vs_fldt_server_add_file_type ( const vs_update_file_type_t file_type,
vs_update_interface_t update_context,
bool  broadcast_file_info 
)

Add file type.

FLDT server has the list of file types that it processes. This call adds new file type or update previously added one.

Parameters
[in]file_typeFile type to be added. Must not be NULL.
[in]update_ctxUpdate context for current file type. Must not be NULL.
[in]broadcast_file_infotrue if gateways has to broadcast information about file provided.
Returns
VS_CODE_OK in case of success or error code.

◆ vs_snap_fldt_server()

const vs_snap_service_t* vs_snap_fldt_server ( const vs_mac_addr_t gateway_mac,
vs_fldt_server_add_filetype_cb  add_filetype 
)

FLDT Server SNAP Service implementation.

This call returns FLDT server implementation. It must be called before any FLDT call.

Parameters
[in]gateway_macGateway's MAC address. Must not be NULL.
[in]add_filetypeCallback. Must not be NULL.
Returns
vs_snap_service_t SNAP service description. Use this pointer to call vs_snap_register_service.
vs_firmware_update_file_type
const vs_update_file_type_t * vs_firmware_update_file_type(void)
Return firmware file type for Update library.
vs_snap_fldt_server
const vs_snap_service_t * vs_snap_fldt_server(const vs_mac_addr_t *gateway_mac, vs_fldt_server_add_filetype_cb add_filetype)
FLDT Server SNAP Service implementation.
vs_update_file_type_t
File type information.
Definition: update.h:70
vs_status_e
vs_status_e
Status code.
Definition: status_code.h:77
vs_mac_addr_t
MAC address.
Definition: snap-structs.h:252
STATUS_CHECK
#define STATUS_CHECK(OPERATION, MESSAGE,...)
Status code check and perform goto terminate if non-successful.
Definition: status_code.h:145
vs_tl_update_ctx
vs_update_interface_t * vs_tl_update_ctx(void)
Update interface for Trust List.
VS_LOG_ERROR
#define VS_LOG_ERROR(FRMT,...)
Log message with VS_LOGLEV_ERROR level.
Definition: logger.h:167
VS_CODE_OK
@ VS_CODE_OK
Successful operation.
Definition: status_code.h:80
VS_UPDATE_FIRMWARE
@ VS_UPDATE_FIRMWARE
Firmware files for different manufactures and device types.
Definition: update.h:64
vs_fldt_server_add_file_type
vs_status_e vs_fldt_server_add_file_type(const vs_update_file_type_t *file_type, vs_update_interface_t *update_context, bool broadcast_file_info)
Add file type.
vs_firmware_update_ctx
vs_update_interface_t * vs_firmware_update_ctx(void)
Return firmware Update interface.
vs_snap_service_t
SNAP service descriptor.
Definition: snap-structs.h:312
vs_tl_update_file_type
const vs_update_file_type_t * vs_tl_update_file_type(void)
Trust List file type.
VS_UPDATE_TRUST_LIST
@ VS_UPDATE_TRUST_LIST
Trust List files.
Definition: update.h:65
vs_update_interface_t
Update interface context.
Definition: update.h:284
vs_update_file_type_t::type
uint16_t type
vs_update_file_type_id_t
Definition: update.h:71
VS_CODE_ERR_UNSUPPORTED_PARAMETER
@ VS_CODE_ERR_UNSUPPORTED_PARAMETER
Unsupported parameter.
Definition: status_code.h:85
vs_snap_register_service
vs_status_e vs_snap_register_service(const vs_snap_service_t *service)
Register SNAP service.