Conviva Client Library
Data Fields
ccl_platform_t Struct Reference

Encapsulates function pointers for system utilities like logging, timers, locks, etc. More...

#include <ccl_platform_if.h>

Collaboration diagram for ccl_platform_t:
Collaboration graph
[legend]

Data Fields

void(* save_data )(const char *data, unsigned int length, ccl_save_callback func)
 Save data on local storage. More...
 
void(* load_data )(ccl_load_callback func)
 Retrieve data from persistent storage. More...
 
void(* http_post_request )(const char *url, const char *content_type, const char *request, unsigned int request_length, unsigned int timeout, ccl_http_callback func, void *http_data)
 Send a request over the HTTP post method. More...
 
void(* console_log )(const char *message)
 Log debugging messages to the console. More...
 
uint64_t(* epoch_time_ms )(void)
 Fetch the current time since Unix epoch, in milliseconds. More...
 
void(* get_platform_metadata )(ccl_platform_metadata_t *platform_metadata)
 Provide metadata specific to this platform. More...
 
void *(* create_timer )(ccl_timer_callback func, void *timer_data, unsigned int initial_time, unsigned int interval)
 Create a new periodic timer. More...
 
void(* destroy_timer )(void *timer_handle)
 Destroy an existing periodic timer. More...
 
int(* rand )(void)
 Generate a random number. More...
 
void *(* mutex_init )(void)
 Initialize a mutex. More...
 
void(* mutex_lock )(void *lock)
 Lock a mutex. More...
 
void(* mutex_unlock )(void *lock)
 Unlock a mutex. More...
 
void(* mutex_destroy )(void *lock)
 Destroy the mutex. More...
 
void *(* rwlock_init )(void)
 Initialize a read-write lock object. if the read/write lock doen't exist then use existing mutex lock. More...
 
void(* rwlock_rdlock )(void *rwlock)
 Lock a read-write lock object for reading. If it is not exist then use mutex lock. More...
 
void(* rwlock_wrlock )(void *rwlock)
 Lock a read-write lock object for writing. If it is not exist use existing mutex lock. More...
 
void(* rwlock_unlock )(void *rwlock)
 Unlock a read-write lock object. More...
 
void(* rwlock_destroy )(void *rwlock)
 Destroy a read-write lock object. More...
 
void *(* mem_alloc )(size_t mem_size)
 Allocates memory for the specified size. More...
 
void(* mem_free )(void *memory)
 Frees the memory. More...
 
int(* base64_encode )(const unsigned char *input_msg, const int input_msg_len, unsigned char *output_msg, const int output_msg_max_len)
 Converts input message to base64 message. More...
 
ccl_crypto_t crypto_funcs
 Cryptographic callback functions. More...
 

Detailed Description

Encapsulates function pointers for system utilities like logging, timers, locks, etc.

Field Documentation

◆ base64_encode

int(* ccl_platform_t::base64_encode) (const unsigned char *input_msg, const int input_msg_len, unsigned char *output_msg, const int output_msg_max_len)

Converts input message to base64 message.

Parameters
input_msgInput message to be converted.
input_msg_lenInput message length in bytes.
output_msgMemory buffer for output message after converting. Memory will be provided by SDK
output_msg_max_lenMax length for output message in bytes.
Returns
  • Returns output message size

◆ console_log

void(* ccl_platform_t::console_log) (const char *message)

Log debugging messages to the console.

Parameters
messageMessage to be logged to the console.

◆ create_timer

void*(* ccl_platform_t::create_timer) (ccl_timer_callback func, void *timer_data, unsigned int initial_time, unsigned int interval)

Create a new periodic timer.

Parameters
funcFunction to be regularly invoked by the timer.
timer_dataOpaque data for the function.
initial_timeInitial delay before the timer is created. In milliseconds.
intervalInvoke the function every interval. In milliseconds.
Returns
Timer handle for later use with ccl_platform_t::destroy_timer.

◆ crypto_funcs

ccl_crypto_t ccl_platform_t::crypto_funcs

Cryptographic callback functions.

Callback functions defined by the application These functions will be called by SDK when needed

◆ destroy_timer

void(* ccl_platform_t::destroy_timer) (void *timer_handle)

Destroy an existing periodic timer.

Parameters
timer_handleTimer handle obtained via ccl_platform_t::create_timer.

◆ epoch_time_ms

uint64_t(* ccl_platform_t::epoch_time_ms) (void)

Fetch the current time since Unix epoch, in milliseconds.

Returns
Current time since Unix epoch, in milliseconds.

◆ get_platform_metadata

void(* ccl_platform_t::get_platform_metadata) (ccl_platform_metadata_t *platform_metadata)

Provide metadata specific to this platform.

Parameters
platform_metadataPointer to ccl_platform_metadata_t to be fill in with relevant metadata.

◆ http_post_request

void(* ccl_platform_t::http_post_request) (const char *url, const char *content_type, const char *request, unsigned int request_length, unsigned int timeout, ccl_http_callback func, void *http_data)

Send a request over the HTTP post method.

The function should be a non-blocking call and return quickly.
The recommended timeout for the HTTP request should be enforced.
For HTTPS URLs, SSL must be supported.

Parameters
urlURL of the HTTP resource to make the request to.
content_typeContent type to be used in HTTP headers.
requestData to be sent for POST requests.
request_lengthLength of the data to be sent for POST requests.
timeoutRecommended timeout for the HTTP request.
Cancel the request and callback Conviva with CCL_ERROR when timeout is reached.
funcCallback to communicate success status and HTTP response to Conviva.
http_dataOpaque HTTP context to pass along with the callback.

◆ load_data

void(* ccl_platform_t::load_data) (ccl_load_callback func)

Retrieve data from persistent storage.

Parameters
funcCallback function to notifiy the data.
Note
The returned string will be freed by Conviva.

◆ mem_alloc

void*(* ccl_platform_t::mem_alloc) (size_t mem_size)

Allocates memory for the specified size.

Parameters
mem_sizeMemory size to be allocated.
Returns
Allocated memory pointer otherwise NULL

◆ mem_free

void(* ccl_platform_t::mem_free) (void *memory)

Frees the memory.

Parameters
memoryMemory pointer that needs to be freed

◆ mutex_destroy

void(* ccl_platform_t::mutex_destroy) (void *lock)

Destroy the mutex.

Parameters
lockMutex to be destroyed.

◆ mutex_init

void*(* ccl_platform_t::mutex_init) (void)

Initialize a mutex.

Returns
New mutex.

◆ mutex_lock

void(* ccl_platform_t::mutex_lock) (void *lock)

Lock a mutex.

Parameters
lockMutex to be locked.

◆ mutex_unlock

void(* ccl_platform_t::mutex_unlock) (void *lock)

Unlock a mutex.

Parameters
lockMutex to be unlocked.

◆ rand

int(* ccl_platform_t::rand) (void)

Generate a random number.

Returns
A random number.

◆ rwlock_destroy

void(* ccl_platform_t::rwlock_destroy) (void *rwlock)

Destroy a read-write lock object.

Parameters
rwlockRead-write lock object to be destroyed.

◆ rwlock_init

void*(* ccl_platform_t::rwlock_init) (void)

Initialize a read-write lock object. if the read/write lock doen't exist then use existing mutex lock.

Returns
New read-write lock object.

◆ rwlock_rdlock

void(* ccl_platform_t::rwlock_rdlock) (void *rwlock)

Lock a read-write lock object for reading. If it is not exist then use mutex lock.

Parameters
rwlockRead-write lock object to be locked for reading.

◆ rwlock_unlock

void(* ccl_platform_t::rwlock_unlock) (void *rwlock)

Unlock a read-write lock object.

Parameters
rwlockRead-write lock object to be unlocked.

◆ rwlock_wrlock

void(* ccl_platform_t::rwlock_wrlock) (void *rwlock)

Lock a read-write lock object for writing. If it is not exist use existing mutex lock.

Parameters
rwlockRead-write lock object to be locked for writing.

◆ save_data

void(* ccl_platform_t::save_data) (const char *data, unsigned int length, ccl_save_callback func)

Save data on local storage.

Parameters
dataData to be saved.
lengthLength of the Data.
funcCallback function to notifiy the status of saving operation.
Note
Data will not exceed 1000 bytes.
Data should be persisted for as long as possible, across application/device restarts.