Snapdragon® Telematics Application Framework (TelAF) Interface Specification
taf_hms_client.c File Reference
#include "taf_hms_interface.h"
#include "taf_hms_messages.h"
#include "taf_hms_service.h"

Data Structures

struct  _ClientThreadData_t
 

Macros

#define LOCK_INIT   le_mutex_Lock(le_ifgen_InitMutexRef);
 Locks the mutex. More...
 
#define UNLOCK_INIT   le_mutex_Unlock(le_ifgen_InitMutexRef);
 Unlocks the mutex. More...
 

Functions

 LE_MEM_DEFINE_STATIC_POOL (taf_hms_ClientThreadData, LE_CDATA_COMPONENT_COUNT, sizeof(_ClientThreadData_t))
 
static le_result_t InitClientForThread (bool isBlocking)
 
static _ClientThreadData_tGetClientThreadDataPtr (void)
 
 __attribute__ ((unused))
 
static void ClientThreadDestructor (void *objPtr)
 
static void InitCommonData (void)
 
static le_result_t DoConnectService (bool isBlocking)
 
void taf_hms_ConnectService (void)
 
le_result_t taf_hms_TryConnectService (void)
 
static void SessionCloseHandler (le_msg_SessionRef_t sessionRef, void *contextPtr)
 
void taf_hms_SetServerDisconnectHandler (taf_hms_DisconnectHandler_t disconnectHandler, void *contextPtr)
 
static void NonExitSessionCloseHandler (le_msg_SessionRef_t sessionRef, void *contextPtr)
 
void taf_hms_SetNonExitServerDisconnectHandler (taf_hms_DisconnectHandler_t disconnectHandler, void *contextPtr)
 
void taf_hms_DisconnectService (void)
 
le_result_t taf_hms_GetCpuLoad (double *cpuCurrentLoadPtr)
 
uint32_t taf_hms_GetCpuCoreNum (void)
 
le_result_t taf_hms_GetIndvCoreUsage (uint32_t coreID, double *cpuUsagePtr)
 
le_result_t taf_hms_GetRamMemInfo (uint32_t *ramTotalMemPtr, uint32_t *ramUsedMemPtr, uint32_t *ramFreeMemPtr)
 
taf_hms_UbiDevInfoListRef_t taf_hms_GetUbiDevInfoList (void)
 
taf_hms_UbiDevInfoRef_t taf_hms_GetFirstUbiDevInfo (taf_hms_UbiDevInfoListRef_t ubiDevInfoListRef)
 
le_result_t taf_hms_DeleteUbiDevInfoList (taf_hms_UbiDevInfoListRef_t ubiDevInfoListRef)
 
taf_hms_UbiDevInfoRef_t taf_hms_GetNextUbiDevInfo (taf_hms_UbiDevInfoListRef_t ubiDevInfoListRef)
 
le_result_t taf_hms_GetUbiDevId (taf_hms_UbiDevInfoRef_t ubiDevInfoRef, uint32_t *ubiDevIdPtr)
 
le_result_t taf_hms_GetUbiDevMaxEraseCnt (taf_hms_UbiDevInfoRef_t ubiDevInfoRef, uint32_t *ubiEraseCntPtr)
 
le_result_t taf_hms_GetUbiDevBadBlkCnt (taf_hms_UbiDevInfoRef_t ubiDevInfoRef, uint32_t *ubiBbCntPtr)
 
taf_hms_UbiVolInfoRef_t taf_hms_GetFirstUbiVolInfo (taf_hms_UbiDevInfoRef_t ubiDevInfoRef)
 
taf_hms_UbiVolInfoRef_t taf_hms_GetNextUbiVolInfo (taf_hms_UbiDevInfoRef_t ubiDevInfoRef)
 
le_result_t taf_hms_GetUbiVolId (taf_hms_UbiVolInfoRef_t ubiVolInfoRef, uint32_t *ubiVolIdPtr)
 
le_result_t taf_hms_GetUbiVolName (taf_hms_UbiVolInfoRef_t ubiVolInfoRef, char *ubiVolName, size_t ubiVolNameSize)
 
le_result_t taf_hms_GetUbiVolSize (taf_hms_UbiVolInfoRef_t ubiVolInfoRef, uint32_t *ubiVolSizePtr)
 
taf_hms_MtdDevInfoListRef_t taf_hms_GetMtdDevInfoList (void)
 
le_result_t taf_hms_DeleteMtdDevInfoList (taf_hms_MtdDevInfoListRef_t mtdDevInfoListRef)
 
taf_hms_MtdDevInfoRef_t taf_hms_GetFirstMtdDevInfo (taf_hms_MtdDevInfoListRef_t mtdDevInfoListRef)
 
taf_hms_MtdDevInfoRef_t taf_hms_GetNextMtdDevInfo (taf_hms_MtdDevInfoListRef_t mtdDevInfoListRef)
 
le_result_t taf_hms_GetMtdDevName (taf_hms_MtdDevInfoRef_t mtdDevInfoRef, char *mtdName, size_t mtdNameSize)
 
le_result_t taf_hms_GetMtdDevBlkSize (taf_hms_MtdDevInfoRef_t mtdDevInfoRef, uint32_t *mtdBlkSizePtr)
 
le_result_t taf_hms_GetMtdDevId (taf_hms_MtdDevInfoRef_t mtdDevInfoRef, uint32_t *mtdDevIdPtr)
 
le_result_t taf_hms_GetMtdDevBlkCnt (taf_hms_MtdDevInfoRef_t mtdDevInfoRef, uint32_t *mtdBlkCntPtr)
 

Variables

static le_mem_PoolRef_t _ClientThreadDataPool
 
static pthread_key_t _ThreadDataKey
 
static bool CommonDataInitialized = false
 
le_mutex_Ref_t le_ifgen_InitMutexRef
 

Macro Definition Documentation

◆ LOCK_INIT

#define LOCK_INIT   le_mutex_Lock(le_ifgen_InitMutexRef);

Locks the mutex.

◆ UNLOCK_INIT

#define UNLOCK_INIT   le_mutex_Unlock(le_ifgen_InitMutexRef);

Unlocks the mutex.

Function Documentation

◆ LE_MEM_DEFINE_STATIC_POOL()

LE_MEM_DEFINE_STATIC_POOL ( taf_hms_ClientThreadData  ,
LE_CDATA_COMPONENT_COUNT  ,
sizeof(_ClientThreadData_t  
)

Static pool for client threads.

◆ InitClientForThread()

static le_result_t InitClientForThread ( bool  isBlocking)
static

Initialize thread specific data, and connect to the service for the current thread.

Returns
  • LE_OK if the client connected successfully to the service.
  • LE_UNAVAILABLE if the server is not currently offering the service to which the client is bound.
  • LE_NOT_PERMITTED if the client interface is not bound to any service (doesn't have a binding).
  • LE_COMM_ERROR if the Service Directory cannot be reached.

◆ GetClientThreadDataPtr()

static _ClientThreadData_t* GetClientThreadDataPtr ( void  )
static

Get a pointer to the client thread data for the current thread.

If the current thread does not have client data, then NULL is returned

◆ __attribute__()

__attribute__ ( (unused)  )

Return the sessionRef for the current thread.

If the current thread does not have a session ref, then this is a fatal error.

◆ ClientThreadDestructor()

static void ClientThreadDestructor ( void *  objPtr)
static

Destructor function for client thread objects.

◆ InitCommonData()

static void InitCommonData ( void  )
static

Init data that is common across all threads.

◆ DoConnectService()

static le_result_t DoConnectService ( bool  isBlocking)
static

Connect to the service, using either blocking or non-blocking calls.

This function implements the details of the public ConnectService functions.

Returns
  • LE_OK if the client connected successfully to the service.
  • LE_UNAVAILABLE if the server is not currently offering the service to which the client is bound.
  • LE_NOT_PERMITTED if the client interface is not bound to any service (doesn't have a binding).
  • LE_COMM_ERROR if the Service Directory cannot be reached.

◆ taf_hms_ConnectService()

void taf_hms_ConnectService ( void  )

Connect the current client thread to the service providing this API. Block until the service is available.

For each thread that wants to use this API, either ConnectService or TryConnectService must be called before any other functions in this API. Normally, ConnectService is automatically called for the main thread, but not for any other thread. For details, see apiFilesC_client.

This function is created automatically.

◆ taf_hms_TryConnectService()

le_result_t taf_hms_TryConnectService ( void  )

Try to connect the current client thread to the service providing this API. Return with an error if the service is not available.

For each thread that wants to use this API, either ConnectService or TryConnectService must be called before any other functions in this API. Normally, ConnectService is automatically called for the main thread, but not for any other thread. For details, see apiFilesC_client.

This function is created automatically.

Returns
  • LE_OK if the client connected successfully to the service.
  • LE_UNAVAILABLE if the server is not currently offering the service to which the client is bound.
  • LE_NOT_PERMITTED if the client interface is not bound to any service (doesn't have a binding).
  • LE_COMM_ERROR if the Service Directory cannot be reached.

◆ SessionCloseHandler()

static void SessionCloseHandler ( le_msg_SessionRef_t  sessionRef,
void *  contextPtr 
)
static

◆ taf_hms_SetServerDisconnectHandler()

void taf_hms_SetServerDisconnectHandler ( taf_hms_DisconnectHandler_t  disconnectHandler,
void *  contextPtr 
)

Set handler called when server disconnection is detected.

When a server connection is lost, call this handler then exit with LE_FATAL. If a program wants to continue without exiting, it should call longjmp() from inside the handler.

◆ NonExitSessionCloseHandler()

static void NonExitSessionCloseHandler ( le_msg_SessionRef_t  sessionRef,
void *  contextPtr 
)
static

◆ taf_hms_SetNonExitServerDisconnectHandler()

void taf_hms_SetNonExitServerDisconnectHandler ( taf_hms_DisconnectHandler_t  disconnectHandler,
void *  contextPtr 
)

Set handler called when server disconnection is detected without exiting.

When a server connection is lost, call this handler without exit.

Warning
When using the API, it needs the application developer to handle some cases like re-connecting and recycling the resources. For most of cases, it is safe to use SetServerDisconnectHandler.

◆ taf_hms_DisconnectService()

void taf_hms_DisconnectService ( void  )

Disconnect the current client thread from the service providing this API.

Normally, this function doesn't need to be called. After this function is called, there's no longer a connection to the service, and the functions in this API can't be used. For details, see apiFilesC_client.

This function is created automatically.

◆ taf_hms_GetCpuLoad()

le_result_t taf_hms_GetCpuLoad ( double *  cpuCurrentLoadPtr)

Gets the total CPU usage from " /proc/stat ".

Returns
  • LE_FAULT Failed.
  • LE_OK Succeeded.
Parameters
[out]cpuCurrentLoadPtrCPU Total Usage.

◆ taf_hms_GetCpuCoreNum()

uint32_t taf_hms_GetCpuCoreNum ( void  )

Gets number of CPU core from " /proc/cpuinfo ".

Returns
  • LE_FAULT Failed.
  • LE_OK Succeeded.

◆ taf_hms_GetIndvCoreUsage()

le_result_t taf_hms_GetIndvCoreUsage ( uint32_t  coreID,
double *  cpuUsagePtr 
)

Gets the CPU usage of each core from " /proc/stat ". The API provides total CPU usage of each core ranging from 0 to 100 %. The coreID range can be 0 - (cpuCoreNum-1), the result value can be LE_OK.

Returns
  • LE_FAULT Failed.
  • LE_OK Succeeded.
Parameters
[in]coreIDCore ID
[out]cpuUsagePtrcpuUsage

◆ taf_hms_GetRamMemInfo()

le_result_t taf_hms_GetRamMemInfo ( uint32_t *  ramTotalMemPtr,
uint32_t *  ramUsedMemPtr,
uint32_t *  ramFreeMemPtr 
)

Gets the meminfo value from " /proc/meminfo ".

Returns
  • LE_FAULT Failed.
  • LE_OK Succeeded.
Parameters
[out]ramTotalMemPtrTotal Memory in kB.
[out]ramUsedMemPtrUsed Memory in kB.
[out]ramFreeMemPtrFree memory in kB.

◆ taf_hms_GetUbiDevInfoList()

taf_hms_UbiDevInfoListRef_t taf_hms_GetUbiDevInfoList ( void  )

Gets the list of available UBI device information.

Returns
  • NULL No information found.
  • taf_hms_UbiDevInfoListRef The UBI device Info list object reference.

◆ taf_hms_GetFirstUbiDevInfo()

taf_hms_UbiDevInfoRef_t taf_hms_GetFirstUbiDevInfo ( taf_hms_UbiDevInfoListRef_t  ubiDevInfoListRef)

Gets the first UBI device Info object reference in the list of the UbiDevInfoList retrieved with taf_hms_GetUbiDevInfoList().

Returns
  • NULL No information found.
  • taf_hms_UbiDevInfoListRef The UBI device Info object reference.
Parameters
[in]ubiDevInfoListRefUBI device list reference

◆ taf_hms_DeleteUbiDevInfoList()

le_result_t taf_hms_DeleteUbiDevInfoList ( taf_hms_UbiDevInfoListRef_t  ubiDevInfoListRef)

Deletes the UbiDevInfoList list retrieved with taf_hms_GetUbiDevInfoList().

Returns
  • LE_BAD_PARAMETER – Bad parameters.
  • LE_OK – Succeeded.
Parameters
[in]ubiDevInfoListRefUBI device list reference

◆ taf_hms_GetNextUbiDevInfo()

taf_hms_UbiDevInfoRef_t taf_hms_GetNextUbiDevInfo ( taf_hms_UbiDevInfoListRef_t  ubiDevInfoListRef)

Gets the next UBI device Info object reference in the list of the UBIInfoList retrieved with taf_hms_GetUBIInfoList().

Returns
  • NULL No information found.
  • taf_hms_UbiDevInfoListRef The UBI device Info object reference.
Parameters
[in]ubiDevInfoListRefUBI device list reference

◆ taf_hms_GetUbiDevId()

le_result_t taf_hms_GetUbiDevId ( taf_hms_UbiDevInfoRef_t  ubiDevInfoRef,
uint32_t *  ubiDevIdPtr 
)

Gets UBI device ID

Returns
  • LE_FAULT Failed.
  • LE_OK Succeeded.
Parameters
[in]ubiDevInfoRefUBI device Info reference.
[out]ubiDevIdPtrUBI device ID

◆ taf_hms_GetUbiDevMaxEraseCnt()

le_result_t taf_hms_GetUbiDevMaxEraseCnt ( taf_hms_UbiDevInfoRef_t  ubiDevInfoRef,
uint32_t *  ubiEraseCntPtr 
)

Gets UBI information for current maximum erase count from " /sys/class/ubi/ubi%d/ ".

Returns
  • LE_FAULT Failed.
  • LE_OK Succeeded.
Parameters
[in]ubiDevInfoRefUBI device Info reference.
[out]ubiEraseCntPtrErase count.

◆ taf_hms_GetUbiDevBadBlkCnt()

le_result_t taf_hms_GetUbiDevBadBlkCnt ( taf_hms_UbiDevInfoRef_t  ubiDevInfoRef,
uint32_t *  ubiBbCntPtr 
)

Gets UBI information for bad block count from " /sys/class/ubi/ubi%d/ ".

Returns
  • LE_FAULT Failed.
  • LE_OK Succeeded.
Parameters
[in]ubiDevInfoRefUBI device Info reference.
[out]ubiBbCntPtrBad Block count.

◆ taf_hms_GetFirstUbiVolInfo()

taf_hms_UbiVolInfoRef_t taf_hms_GetFirstUbiVolInfo ( taf_hms_UbiDevInfoRef_t  ubiDevInfoRef)

Gets the first UBI volume Info object reference in the list of the UbiVolInfoList retrieved with taf_hms_GetUbiDevInfoList().

Returns
  • NULL No information found.
  • taf_hms_UbiVolInfoListRef The UBI device Info object reference.
Parameters
[in]ubiDevInfoRefUBI device Info reference.

◆ taf_hms_GetNextUbiVolInfo()

taf_hms_UbiVolInfoRef_t taf_hms_GetNextUbiVolInfo ( taf_hms_UbiDevInfoRef_t  ubiDevInfoRef)

Gets the next UBI volume Info object reference in the list of the UbiVolInfoList retrieved with taf_hms_GetUbiDevInfoList().

Returns
  • NULL No information found.
  • taf_hms_UbiVolInfoListRef The UBI volume Info object reference.
Parameters
[in]ubiDevInfoRefUBI device Info reference.

◆ taf_hms_GetUbiVolId()

le_result_t taf_hms_GetUbiVolId ( taf_hms_UbiVolInfoRef_t  ubiVolInfoRef,
uint32_t *  ubiVolIdPtr 
)

Gets UBI volume ID.

Returns
  • LE_FAULT Failed.
  • LE_OK Succeeded.
Parameters
[in]ubiVolInfoRef
[out]ubiVolIdPtr

◆ taf_hms_GetUbiVolName()

le_result_t taf_hms_GetUbiVolName ( taf_hms_UbiVolInfoRef_t  ubiVolInfoRef,
char *  ubiVolName,
size_t  ubiVolNameSize 
)

Gets name of UBI volume.

Returns
  • LE_FAULT Failed.
  • LE_OK Succeeded.
Parameters
[in]ubiVolInfoRefUBI device Info reference.
[out]ubiVolNameUBI volume name.
[in]ubiVolNameSize

◆ taf_hms_GetUbiVolSize()

le_result_t taf_hms_GetUbiVolSize ( taf_hms_UbiVolInfoRef_t  ubiVolInfoRef,
uint32_t *  ubiVolSizePtr 
)

Gets size of UBI volume in bytes.

Returns
  • LE_FAULT Failed.
  • LE_OK Succeeded.
Parameters
[in]ubiVolInfoRefUBI device Info reference.
[out]ubiVolSizePtrUBI volume size.

◆ taf_hms_GetMtdDevInfoList()

taf_hms_MtdDevInfoListRef_t taf_hms_GetMtdDevInfoList ( void  )

Gets the list of available MTD Node.

Returns
  • NULL No information found.
  • taf_hms_MtdInfoListRef The MtdInfo list object reference.

◆ taf_hms_DeleteMtdDevInfoList()

le_result_t taf_hms_DeleteMtdDevInfoList ( taf_hms_MtdDevInfoListRef_t  mtdDevInfoListRef)

Deletes the MtdInfoList list retrieved with taf_hms_GetMtdInfoList().

Returns
  • LE_BAD_PARAMETER – Bad parameters.
  • LE_OK – Succeeded.
Parameters
[in]mtdDevInfoListRefMTD device list reference

◆ taf_hms_GetFirstMtdDevInfo()

taf_hms_MtdDevInfoRef_t taf_hms_GetFirstMtdDevInfo ( taf_hms_MtdDevInfoListRef_t  mtdDevInfoListRef)

Gets the first MtdInfo object reference in the list of the MtdInfoList retrieved with taf_hms_GetMtdInfoList().

Returns
  • NULL No information found.
  • taf_hms_MtdInfoListRef The MtdInfo object reference.
Parameters
[in]mtdDevInfoListRefMTD node list reference

◆ taf_hms_GetNextMtdDevInfo()

taf_hms_MtdDevInfoRef_t taf_hms_GetNextMtdDevInfo ( taf_hms_MtdDevInfoListRef_t  mtdDevInfoListRef)

Gets the next MtdInfo object reference in the list of the MtdInfoList retrieved with taf_hms_GetMtdInfoList().

Returns
  • NULL No information found.
  • taf_hms_MtdInfoListRef The MtdInfo object reference.
Parameters
[in]mtdDevInfoListRefMTD node list reference

◆ taf_hms_GetMtdDevName()

le_result_t taf_hms_GetMtdDevName ( taf_hms_MtdDevInfoRef_t  mtdDevInfoRef,
char *  mtdName,
size_t  mtdNameSize 
)

Gets MTD information for name from " /sys/class/mtd/mtd%d/ ".

Returns
  • LE_FAULT Failed.
  • LE_OK Succeeded.
Parameters
[in]mtdDevInfoRefMTD Info reference.
[out]mtdNameMTD name.
[in]mtdNameSize

◆ taf_hms_GetMtdDevBlkSize()

le_result_t taf_hms_GetMtdDevBlkSize ( taf_hms_MtdDevInfoRef_t  mtdDevInfoRef,
uint32_t *  mtdBlkSizePtr 
)

Gets MTD information for block size in bytes.

Returns
  • LE_FAULT Failed.
  • LE_OK Succeeded.
Parameters
[in]mtdDevInfoRefMTD Info reference.
[out]mtdBlkSizePtrBad block size.

◆ taf_hms_GetMtdDevId()

le_result_t taf_hms_GetMtdDevId ( taf_hms_MtdDevInfoRef_t  mtdDevInfoRef,
uint32_t *  mtdDevIdPtr 
)

Gets MTD information for device ID.

Returns
  • LE_FAULT Failed.
  • LE_OK Succeeded.
Parameters
[in]mtdDevInfoRefMTD Info reference.
[out]mtdDevIdPtrDevice ID.

◆ taf_hms_GetMtdDevBlkCnt()

le_result_t taf_hms_GetMtdDevBlkCnt ( taf_hms_MtdDevInfoRef_t  mtdDevInfoRef,
uint32_t *  mtdBlkCntPtr 
)

Gets MTD information for block count.

Returns
  • LE_FAULT Failed.
  • LE_OK Succeeded.
Parameters
[in]mtdDevInfoRefMTD Info reference.
[out]mtdBlkCntPtrBlock count.

Variable Documentation

◆ _ClientThreadDataPool

le_mem_PoolRef_t _ClientThreadDataPool
static

The memory pool for client thread objects

◆ _ThreadDataKey

pthread_key_t _ThreadDataKey
static

Key under which the pointer to the Thread Object (_ClientThreadData_t) will be kept in thread-local storage. This allows a thread to quickly get a pointer to its own Thread Object.

◆ CommonDataInitialized

bool CommonDataInitialized = false
static

This global flag is shared by all client threads, and is used to indicate whether the common data has been initialized.

Warning
Use InitMutex, defined below, to protect accesses to this data.

◆ le_ifgen_InitMutexRef

le_mutex_Ref_t le_ifgen_InitMutexRef

Mutex and associated macros for use with the above CommonDataInitialized.