Snapdragon® Telematics Application Framework (TelAF) Interface Specification
taf_someipClnt_client.c File Reference

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_someipClnt_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_someipClnt_ConnectService (void)
 
le_result_t taf_someipClnt_TryConnectService (void)
 
static void SessionCloseHandler (le_msg_SessionRef_t sessionRef, void *contextPtr)
 
void taf_someipClnt_SetServerDisconnectHandler (taf_someipClnt_DisconnectHandler_t disconnectHandler, void *contextPtr)
 
static void NonExitSessionCloseHandler (le_msg_SessionRef_t sessionRef, void *contextPtr)
 
void taf_someipClnt_SetNonExitServerDisconnectHandler (taf_someipClnt_DisconnectHandler_t disconnectHandler, void *contextPtr)
 
void taf_someipClnt_DisconnectService (void)
 
uint16_t taf_someipClnt_GetClientId (void)
 
le_result_t taf_someipClnt_GetClientIdEx (const char *LE_NONNULL ifName, uint16_t *clientIdPtr)
 
taf_someipClnt_ServiceRef_t taf_someipClnt_RequestService (uint16_t serviceId, uint16_t instanceId)
 
taf_someipClnt_ServiceRef_t taf_someipClnt_RequestServiceEx (uint16_t serviceId, uint16_t instanceId, const char *LE_NONNULL ifName)
 
le_result_t taf_someipClnt_ReleaseService (taf_someipClnt_ServiceRef_t serviceRef)
 
le_result_t taf_someipClnt_GetState (taf_someipClnt_ServiceRef_t serviceRef, taf_someipClnt_State_t *statePtr)
 
le_result_t taf_someipClnt_GetVersion (taf_someipClnt_ServiceRef_t serviceRef, uint8_t *majVerPtr, uint32_t *minVerPtr)
 
taf_someipClnt_StateChangeHandlerRef_t taf_someipClnt_AddStateChangeHandler (taf_someipClnt_ServiceRef_t serviceRef, taf_someipClnt_StateChangeHandlerFunc_t handlerPtr, void *contextPtr)
 
void taf_someipClnt_RemoveStateChangeHandler (taf_someipClnt_StateChangeHandlerRef_t handlerRef)
 
taf_someipClnt_TxMsgRef_t taf_someipClnt_CreateMsg (taf_someipClnt_ServiceRef_t serviceRef, uint16_t methodId)
 
le_result_t taf_someipClnt_SetNonRet (taf_someipClnt_TxMsgRef_t msgRef)
 
le_result_t taf_someipClnt_SetReliable (taf_someipClnt_TxMsgRef_t msgRef)
 
le_result_t taf_someipClnt_SetTimeout (taf_someipClnt_TxMsgRef_t msgRef, uint32_t timeOut)
 
le_result_t taf_someipClnt_SetPayload (taf_someipClnt_TxMsgRef_t msgRef, const uint8_t *dataPtr, size_t dataSize)
 
le_result_t taf_someipClnt_DeleteMsg (taf_someipClnt_TxMsgRef_t msgRef)
 
void taf_someipClnt_RequestResponse (taf_someipClnt_TxMsgRef_t msgRef, taf_someipClnt_RespMsgHandlerFunc_t handlerPtr, void *contextPtr)
 
le_result_t taf_someipClnt_EnableEventGroup (taf_someipClnt_ServiceRef_t serviceRef, uint16_t eventGroupId, uint16_t eventId, taf_someipDef_EventType_t eventType)
 
le_result_t taf_someipClnt_DisableEventGroup (taf_someipClnt_ServiceRef_t serviceRef, uint16_t eventGroupId)
 
le_result_t taf_someipClnt_SubscribeEventGroup (taf_someipClnt_ServiceRef_t serviceRef, uint16_t eventGroupId)
 
le_result_t taf_someipClnt_UnsubscribeEventGroup (taf_someipClnt_ServiceRef_t serviceRef, uint16_t eventGroupId)
 
taf_someipClnt_EventMsgHandlerRef_t taf_someipClnt_AddEventMsgHandler (taf_someipClnt_ServiceRef_t serviceRef, uint16_t eventGroupId, taf_someipClnt_EventMsgHandlerFunc_t handlerPtr, void *contextPtr)
 
void taf_someipClnt_RemoveEventMsgHandler (taf_someipClnt_EventMsgHandlerRef_t handlerRef)
 

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_someipClnt_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_someipClnt_ConnectService()

void taf_someipClnt_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_someipClnt_TryConnectService()

le_result_t taf_someipClnt_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_someipClnt_SetServerDisconnectHandler()

void taf_someipClnt_SetServerDisconnectHandler ( taf_someipClnt_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_someipClnt_SetNonExitServerDisconnectHandler()

void taf_someipClnt_SetNonExitServerDisconnectHandler ( taf_someipClnt_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_someipClnt_DisconnectService()

void taf_someipClnt_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_someipClnt_GetClientId()

uint16_t taf_someipClnt_GetClientId ( void  )

Gets the SOME/IP client ID of client-service-instance on default network interface.

Returns
  • Client ID.

◆ taf_someipClnt_GetClientIdEx()

le_result_t taf_someipClnt_GetClientIdEx ( const char *LE_NONNULL  ifName,
uint16_t *  clientIdPtr 
)

Gets the SOME/IP client ID of client-service-instance on a dedicated network interface. The ifName shall match the device name specified in one of the JSON files.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Invalid parameters.
  • LE_NOT_FOUND – Client ID is not found.
Parameters
[in]ifNameNetwork interface name.
[out]clientIdPtrSOME/IP Client ID.

◆ taf_someipClnt_RequestService()

taf_someipClnt_ServiceRef_t taf_someipClnt_RequestService ( uint16_t  serviceId,
uint16_t  instanceId 
)

Requests a client-service-instance on default network interface and returns the reference to the client-service-instance.

Returns
  • Reference to the client-service-instance.
  • NULL if invalid parameters.
Parameters
[in]serviceIdService ID.
[in]instanceIdInstance ID.

◆ taf_someipClnt_RequestServiceEx()

taf_someipClnt_ServiceRef_t taf_someipClnt_RequestServiceEx ( uint16_t  serviceId,
uint16_t  instanceId,
const char *LE_NONNULL  ifName 
)

Requests a client-service-instance on a dedicated network interface and returns the reference to the client-service-instance. The ifName shall match the device name specified in one of the JSON files.

Returns
  • Reference to the client-service-instance.
  • NULL if invalid parameters.
Parameters
[in]serviceIdService ID.
[in]instanceIdInstance ID.
[in]ifNameNetwork interface name.

◆ taf_someipClnt_ReleaseService()

le_result_t taf_someipClnt_ReleaseService ( taf_someipClnt_ServiceRef_t  serviceRef)

Releases a client-service-instance.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Invalid parameters.
  • LE_NOT_PERMITTED – The service is not requested by the client.
  • LE_BUSY – The service still has active handlers or pending requests.
Parameters
[in]serviceRefService Reference.

◆ taf_someipClnt_GetState()

le_result_t taf_someipClnt_GetState ( taf_someipClnt_ServiceRef_t  serviceRef,
taf_someipClnt_State_t statePtr 
)

Gets the service state.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Invalid parameters.
  • LE_NOT_PERMITTED – The service is not requested by the client.
Parameters
[in]serviceRefService Reference.
[out]statePtrService State.

◆ taf_someipClnt_GetVersion()

le_result_t taf_someipClnt_GetVersion ( taf_someipClnt_ServiceRef_t  serviceRef,
uint8_t *  majVerPtr,
uint32_t *  minVerPtr 
)

Gets the service version.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Invalid parameters.
  • LE_NOT_PERMITTED – The service is not requested by the client.
  • LE_UNAVAILABLE – Service is unavailable.
Parameters
[in]serviceRefService Reference.
[out]majVerPtrMajor Version.
[out]minVerPtrMinor Version.

◆ taf_someipClnt_AddStateChangeHandler()

taf_someipClnt_StateChangeHandlerRef_t taf_someipClnt_AddStateChangeHandler ( taf_someipClnt_ServiceRef_t  serviceRef,
taf_someipClnt_StateChangeHandlerFunc_t  handlerPtr,
void *  contextPtr 
)

Add handler function for EVENT 'taf_someipClnt_StateChange'

This event provides information on the service state change.

Parameters
[in]serviceRefService Reference.
[in]handlerPtr
[in]contextPtr

◆ taf_someipClnt_RemoveStateChangeHandler()

void taf_someipClnt_RemoveStateChangeHandler ( taf_someipClnt_StateChangeHandlerRef_t  handlerRef)

Remove handler function for EVENT 'taf_someipClnt_StateChange'

Parameters
[in]handlerRef

◆ taf_someipClnt_CreateMsg()

taf_someipClnt_TxMsgRef_t taf_someipClnt_CreateMsg ( taf_someipClnt_ServiceRef_t  serviceRef,
uint16_t  methodId 
)

Creates a request message and sets the destination.

Returns
  • Reference to the request message.
  • NULL if invalid parameters.
Parameters
[in]serviceRefService Reference.
[in]methodIdMethod ID.

◆ taf_someipClnt_SetNonRet()

le_result_t taf_someipClnt_SetNonRet ( taf_someipClnt_TxMsgRef_t  msgRef)

Sets the request to a non-return-request(MT_REQUEST_NO_RETURN). By default, it is MT_REQUEST.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Invalid input parameters.
  • LE_NOT_PERMITTED – The message is not created by the client.
Parameters
[in]msgRefTx message reference.

◆ taf_someipClnt_SetReliable()

le_result_t taf_someipClnt_SetReliable ( taf_someipClnt_TxMsgRef_t  msgRef)

Uses TCP to send the request. By default, it uses UDP.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Invalid input parameters.
  • LE_NOT_PERMITTED – The message is not created by the client.
Parameters
[in]msgRefTx message reference.

◆ taf_someipClnt_SetTimeout()

le_result_t taf_someipClnt_SetTimeout ( taf_someipClnt_TxMsgRef_t  msgRef,
uint32_t  timeOut 
)

Sets the timeout in milliseconds for waiting for the response. By default, the timeout is 30000 ms. 0 means NEVER time out.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Invalid input parameters.
  • LE_NOT_PERMITTED – The message is not created by the client.
Parameters
[in]msgRefTx message reference.
[in]timeOutTimeout in milliseconds.

◆ taf_someipClnt_SetPayload()

le_result_t taf_someipClnt_SetPayload ( taf_someipClnt_TxMsgRef_t  msgRef,
const uint8_t *  dataPtr,
size_t  dataSize 
)

Sets the payload data of the request. By default, the payload is empty.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Invalid input parameters.
  • LE_NOT_PERMITTED – The message is not created by the client.
Parameters
[in]msgRefTx message reference.
[in]dataPtrPayload data.
[in]dataSize

◆ taf_someipClnt_DeleteMsg()

le_result_t taf_someipClnt_DeleteMsg ( taf_someipClnt_TxMsgRef_t  msgRef)

Deletes a request message.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Invalid input parameters.
  • LE_NOT_PERMITTED – The message is not created by the client.
Parameters
[in]msgRefTx message reference.

◆ taf_someipClnt_RequestResponse()

void taf_someipClnt_RequestResponse ( taf_someipClnt_TxMsgRef_t  msgRef,
taf_someipClnt_RespMsgHandlerFunc_t  handlerPtr,
void *  contextPtr 
)

Sends an asynchronous request message. The response handler will be called once the response is received or any errors occur.

NOTE: The request message will be automatically deleted after calling this API.

Parameters
[in]msgRefTx message reference.
[in]handlerPtrResponse message handler.
[in]contextPtr

◆ taf_someipClnt_EnableEventGroup()

le_result_t taf_someipClnt_EnableEventGroup ( taf_someipClnt_ServiceRef_t  serviceRef,
uint16_t  eventGroupId,
uint16_t  eventId,
taf_someipDef_EventType_t  eventType 
)

Enables an event group by adding an event into the group.

NOTE: This API can be called multiple times if there is more than one event to be added into the group. Currently, one event can only be added into one group, and one event group can be enabled only by one client.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Invalid input parameters.
  • LE_NOT_PERMITTED – The service is not requested by the client, or the event group is subscribed or enabled by another client, or the event is already added into another group.
  • LE_DUPLICATE – The event is already in this group.
Parameters
[in]serviceRefService Reference.
[in]eventGroupIdEvent Group ID.
[in]eventIdEvent ID.
[in]eventTypeEvent Type.

◆ taf_someipClnt_DisableEventGroup()

le_result_t taf_someipClnt_DisableEventGroup ( taf_someipClnt_ServiceRef_t  serviceRef,
uint16_t  eventGroupId 
)

Disables an event group and removes all events from the group.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Invalid input parameters.
  • LE_NOT_PERMITTED – The service is not requested by the client, or the event group is subscribed or already enabled by another client.
  • LE_DUPLICATE – The event group is not enabled.
Parameters
[in]serviceRefService Reference.
[in]eventGroupIdEvent Group ID.

◆ taf_someipClnt_SubscribeEventGroup()

le_result_t taf_someipClnt_SubscribeEventGroup ( taf_someipClnt_ServiceRef_t  serviceRef,
uint16_t  eventGroupId 
)

Subscribes an event group of a service.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Invalid input parameters.
  • LE_NOT_PERMITTED – The service is not requested by the client, or the event group is not enabled or already enabled by another client.
  • LE_DUPLICATE – The event group is already subscribed.
Parameters
[in]serviceRefService Reference.
[in]eventGroupIdEvent Group ID.

◆ taf_someipClnt_UnsubscribeEventGroup()

le_result_t taf_someipClnt_UnsubscribeEventGroup ( taf_someipClnt_ServiceRef_t  serviceRef,
uint16_t  eventGroupId 
)

Unsubscribes an event group of a service.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Invalid input parameters.
  • LE_NOT_PERMITTED – The service is not requested by the client, or the event group is not enabled or already enabled by another client.
  • LE_DUPLICATE – The event group is not subscribed.
Parameters
[in]serviceRefService Reference.
[in]eventGroupIdEvent Group ID.

◆ taf_someipClnt_AddEventMsgHandler()

taf_someipClnt_EventMsgHandlerRef_t taf_someipClnt_AddEventMsgHandler ( taf_someipClnt_ServiceRef_t  serviceRef,
uint16_t  eventGroupId,
taf_someipClnt_EventMsgHandlerFunc_t  handlerPtr,
void *  contextPtr 
)

Add handler function for EVENT 'taf_someipClnt_EventMsg'

This event provides information on an event message.

Parameters
[in]serviceRefService Reference.
[in]eventGroupIdEvent Group ID.
[in]handlerPtrEvent Handler.
[in]contextPtr

◆ taf_someipClnt_RemoveEventMsgHandler()

void taf_someipClnt_RemoveEventMsgHandler ( taf_someipClnt_EventMsgHandlerRef_t  handlerRef)

Remove handler function for EVENT 'taf_someipClnt_EventMsg'

Parameters
[in]handlerRef

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.