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

FLDT for client. More...

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

Go to the source code of this file.

Typedefs

typedef void(* vs_fldt_got_file) (vs_update_file_type_t *file_type, const vs_file_version_t *prev_file_ver, const vs_file_version_t *new_file_ver, vs_update_interface_t *update_interface, const vs_mac_addr_t *gateway, bool successfully_updated)
 Got new file callback. More...
 

Functions

const vs_snap_service_tvs_snap_fldt_client (vs_fldt_got_file got_file_callback)
 FLDT Client SNAP Service implementation. More...
 
vs_status_e vs_fldt_client_add_file_type (const vs_update_file_type_t *file_type, vs_update_interface_t *update_interface)
 Add file type. More...
 
vs_status_e vs_fldt_client_request_all_files (void)
 Request all files data. More...
 

Detailed Description

FLDT for client.

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

FLDT Client Usage

Client side downloads new file versions and checks them. vs_fldt_got_file function is called after file upgrading. In most case it used to output new file version information and gateway address.

Warning
User has to provide vs_fldt_got_file function implementation for FLDT Client.

To successfully file downloading process 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 client initialization :

const vs_snap_service_t *snap_fldt_client;
snap_fldt_client = vs_snap_fldt_client( _on_file_updated );
STATUS_CHECK( vs_snap_register_service( snap_fldt_client ), "Cannot register FLDT client service");
"Unable to add Firmware file type" );
"Unable to add Trust List file type" );

You can see minimalistic vs_fldt_got_file function example below :

void _on_file_updated(vs_update_file_type_t *file_type,
const vs_file_version_t *prev_file_ver,
const vs_file_version_t *new_file_ver,
vs_update_interface_t *update_interface,
const vs_mac_addr_t *gateway,
bool successfully_updated) {
(void) prev_file_ver;
(void) new_file_ver;
(void) update_interface;
(void) gateway;
switch(file_type->type) {
case VS_UPDATE_FIRMWARE : VS_LOG_INFO( "New Firmware has been loaded" ); break;
case VS_UPDATE_TRUST_LIST : VS_LOG_INFO( "New Trust List has been loaded" ); break;
}
if (file_type->type == VS_UPDATE_FIRMWARE && successfully_updated) {
_app_restart();
}
}

In this example _app_restart() function is called for firmware that has been successfully updated.

Typedef Documentation

◆ vs_fldt_got_file

typedef void(* vs_fldt_got_file) (vs_update_file_type_t *file_type, const vs_file_version_t *prev_file_ver, const vs_file_version_t *new_file_ver, vs_update_interface_t *update_interface, const vs_mac_addr_t *gateway, bool successfully_updated)

Got new file callback.

Callback for vs_snap_fldt_client function. This callback is used when new file has been fully loaded. See #fldt_client_usage for details.

Parameters
[in]file_typeFile type descriptor. Cannot be NULL.
[in]prev_file_verCurrent file version before loading new one. Cannot be NULL.
[in]new_file_verHas been loaded file version. Cannot be NULL.
[in]update_interfaceUpdate interface for current file type. Cannot be NULL.
[in]gatewayGateway's MAC address. Cannot be NULL.
[in]successfully_updatedTrue if file has been successfully updated.

Function Documentation

◆ vs_fldt_client_add_file_type()

vs_status_e vs_fldt_client_add_file_type ( const vs_update_file_type_t file_type,
vs_update_interface_t update_interface 
)

Add file type.

FLDT client 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_interfaceUpdate interface for current file type. Must not be NULL.
Returns
VS_CODE_OK in case of success or error code.

◆ vs_fldt_client_request_all_files()

vs_status_e vs_fldt_client_request_all_files ( void  )

Request all files data.

Request information about all previously registered files. This function can be executed after gateway restart notification.

Returns
VS_CODE_OK in case of success or error code.

◆ vs_snap_fldt_client()

const vs_snap_service_t* vs_snap_fldt_client ( vs_fldt_got_file  got_file_callback)

FLDT Client SNAP Service implementation.

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

Parameters
[in]got_file_callbackCallback. 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_update_file_type_t
File type information.
Definition: update.h:70
VS_LOG_INFO
#define VS_LOG_INFO(FRMT,...)
Log message with VS_LOGLEV_INFO level.
Definition: logger.h:155
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_file_version_t
File version information.
Definition: provision-structs.h:216
VS_UPDATE_FIRMWARE
@ VS_UPDATE_FIRMWARE
Firmware files for different manufactures and device types.
Definition: update.h:64
vs_firmware_update_ctx
vs_update_interface_t * vs_firmware_update_ctx(void)
Return firmware Update interface.
vs_fldt_client_add_file_type
vs_status_e vs_fldt_client_add_file_type(const vs_update_file_type_t *file_type, vs_update_interface_t *update_interface)
Add file type.
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_snap_fldt_client
const vs_snap_service_t * vs_snap_fldt_client(vs_fldt_got_file got_file_callback)
FLDT Client SNAP Service implementation.
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_snap_register_service
vs_status_e vs_snap_register_service(const vs_snap_service_t *service)
Register SNAP service.