VitroIO SDK
Software development kit for Vitro Shard.
Loading...
Searching...
No Matches
vitroio::sdk::IoTBlock Class Reference

Class is an API for creating and sending IoT Blocks. More...

#include <iot-block.h>

Public Types

enum  IoTBlock_Sizes_t { SIZE_S = 16 , SIZE_M = 128 , SIZE_L = 512 , SIZE_XL = 1024 }
 IoTBlock predefined sizes. More...
 

Public Member Functions

struct __attribute__ ((packed)) Frame
 Structure contains node's data needed for encryption and final CAN frame. More...
 
 IoTBlock (Transport_layer *comm)
 Construct a new IoT Block object. More...
 
int make (uint32_t data, uint32_t parameter)
 Prepare IoT block consisting of the Initialize Vector, encrypted data, parameter ID, node Id, timestamp, digest, and signature. More...
 
int make (void *data, size_t dataLen, uint32_t parameter)
 Prepare IoT block consisting of the Initialize Vector, encrypted data, parameter ID, node Id, timestamp, digest, and signature. More...
 
int make (void *data, IoTBlock_Sizes_t size, uint32_t parameter)
 Prepare IoT block consisting of the Initialize Vector, encrypted data, parameter ID, node Id, timestamp, digest, and signature. Make sure that there is enough data for given size. More...
 
void send ()
 Send IoT Block by chosen transport layer. Before sending, the Block has to be prepared with the make() method. More...
 
Frame * get_frame ()
 Return pointer to Frame structure. The structure contains whole IoT block. More...
 
uint8_t * get_frame_as_array ()
 Return pointer to uint8_t array of CAN_DATA_SIZE size. The array contains whole IoT block. More...
 
void print ()
 Prints whole Iot Block data. More...
 
uint32_t get_blob_size ()
 Get the blob size. More...
 

Detailed Description

Class is an API for creating and sending IoT Blocks.

The class wraps all crypto operations needed for creating IoT blocks. The last prepared block is stored in an object of this class and the pointer to the block can be acquired with get_iot().

Member Enumeration Documentation

◆ IoTBlock_Sizes_t

IoTBlock predefined sizes.

Enumerator
SIZE_S 
SIZE_M 
SIZE_L 
SIZE_XL 

Constructor & Destructor Documentation

◆ IoTBlock()

vitroio::sdk::IoTBlock::IoTBlock ( Transport_layer comm)

Construct a new IoT Block object.

Parameters
commPointer to transport layer to be used.

Member Function Documentation

◆ __attribute__()

struct vitroio::sdk::IoTBlock::__attribute__ ( (packed)  )
inline

Structure contains node's data needed for encryption and final CAN frame.

All members of structure are required to be sent in CAN frame. Sensor's value is encrypted and together with Intialization Vector creates blob. nodeID, parameterID and timestamp are evident and placed at the top of encrypted data. digest is a result of SHA256 hash function on blob + parameterID + nodeID + timestamp. signature is created only on digest.

Note
Structure has packed attribute to ensure that it is placed in non-padded, contiguous memory area

◆ get_blob_size()

uint32_t vitroio::sdk::IoTBlock::get_blob_size ( )

Get the blob size.

Returns
uint32_t

◆ get_frame()

Frame * vitroio::sdk::IoTBlock::get_frame ( )

Return pointer to Frame structure. The structure contains whole IoT block.

◆ get_frame_as_array()

uint8_t * vitroio::sdk::IoTBlock::get_frame_as_array ( )

Return pointer to uint8_t array of CAN_DATA_SIZE size. The array contains whole IoT block.

◆ make() [1/3]

int vitroio::sdk::IoTBlock::make ( uint32_t  data,
uint32_t  parameter 
)

Prepare IoT block consisting of the Initialize Vector, encrypted data, parameter ID, node Id, timestamp, digest, and signature.

Parameters
datasensor data value
parametersensor's data type ID
Returns
Returns 0 if IoT-Block has been created, error otherwise

◆ make() [2/3]

int vitroio::sdk::IoTBlock::make ( void *  data,
IoTBlock_Sizes_t  size,
uint32_t  parameter 
)

Prepare IoT block consisting of the Initialize Vector, encrypted data, parameter ID, node Id, timestamp, digest, and signature. Make sure that there is enough data for given size.

Parameters
dataPointer to data to be encrypted
sizeIoTBlock size IoTBlock_Sizes_t
parameterParameter ID
Returns
Returns 0 if IoT-Block has been created, error otherwise

◆ make() [3/3]

int vitroio::sdk::IoTBlock::make ( void *  data,
size_t  dataLen,
uint32_t  parameter 
)

Prepare IoT block consisting of the Initialize Vector, encrypted data, parameter ID, node Id, timestamp, digest, and signature.

Parameters
dataPointer to data to be encrypted
dataLenLength of data given
parameterParameter ID
Returns
Returns 0 if IoT-Block has been created, error otherwise

◆ print()

void vitroio::sdk::IoTBlock::print ( )

Prints whole Iot Block data.

◆ send()

void vitroio::sdk::IoTBlock::send ( )

Send IoT Block by chosen transport layer. Before sending, the Block has to be prepared with the make() method.