Linux LITE MBIM  MBPL_SDK_R25_ENG3
Data Structures | Files | Typedefs | Enumerations | Functions
MBIM layer (lite-mbim)

Data Structures

struct  MBIM_TRANSPORT_ERR_INFO
 
struct  MbimTransport
 
struct  MbimTransaction
 
struct  MbimIndicator
 
struct  MbimSyncObject
 

Files

file  MbimTransport.h
 
file  MbimTransaction.h
 
file  MbimIndicator.h
 
file  MbimSyncObject.h
 
file  BasicConnectDeviceService.h
 

Typedefs

typedef void(* MBIM_TRANSPORT_ERR_CALLBACK) (void *pErrCallbackContext, MBIM_TRANSPORT_ERR_INFO err_info)
 
typedef struct MbimTransport MbimTransport
 
typedef void(* MBIM_DONE_CALLBACK) (uint32_t status, uint32_t transactionId, uint8_t *informationBuffer, uint32_t informationBufferLength, void *pDoneCallbackContext)
 
typedef struct MbimTransaction MbimTransaction
 
typedef void(* MBIM_INDICATION_CALLBACK) (uint8_t *deviceServiceId, uint32_t cid, uint8_t *informationBuffer, uint32_t informationBufferLength, void *pIndicationCallbackContext)
 
typedef struct MbimIndicator MbimIndicator
 
typedef struct MbimSyncObject MbimSyncObject
 

Enumerations

enum  MBIM_TRANSPORT_ERR_TYPE { MBIM_TRANSPORT_ERR_UNKNOWN, MBIM_TRANSPORT_ERR_READ, MBIM_TRANSPORT_ERR_WRITE }
 

Functions

int MbimTransport_Initialize (MbimTransport *pThis, char *devicePath, uint32_t maxExpectedInformationLength)
 
void MbimTransport_ShutDown (MbimTransport *pThis)
 
int MbimTransport_SendCommand (MbimTransport *pThis, const uint8_t *deviceServiceId, uint32_t cid, uint32_t commandType, uint8_t *informationBuffer, uint16_t informationBufferLength, MbimTransaction *pTransaction)
 
uint32_t MbimTransport_GetNextTransactionId (MbimTransport *pThis)
 
void MbimTransport_CancelTransaction (MbimTransport *pThis, uint32_t transactionId)
 
void MbimTransport_AttachIndicator (MbimTransport *pThis, MbimIndicator *pIndicator)
 
void MbimTransport_DetachIndicator (MbimTransport *pThis, MbimIndicator *pIndicator)
 
void MbimTransport_RegisterErrCallback (MbimTransport *pThis, MBIM_TRANSPORT_ERR_CALLBACK pErrCallback, void *pErrCallbackContext)
 
void MbimTransaction_Initialize (MbimTransaction *pThis, uint32_t transactionId, MBIM_DONE_CALLBACK pDoneCallback, void *pDoneCallbackContext)
 
void MbimIndicator_Initialize (MbimIndicator *pThis, MBIM_INDICATION_CALLBACK pIndicationCallback, void *pIndicationCallbackContext)
 
int MbimSyncObject_Initialize (MbimSyncObject *pThis, uint8_t *informationBuffer, uint32_t informationBufferLength)
 
int MbimSyncObject_Destroy (MbimSyncObject *pThis)
 
int MbimSyncObject_Lock (MbimSyncObject *pThis)
 
int MbimSyncObject_Unlock (MbimSyncObject *pThis)
 
int MbimSyncObject_Wait (MbimSyncObject *pThis)
 
int MbimSyncObject_TimedWait (MbimSyncObject *pThis, time_t timeoutSeconds)
 
int MbimSyncObject_Signal (MbimSyncObject *pThis)
 
void MbimSyncObject_DoneCallback (uint32_t status, uint32_t transactionId, uint8_t *informationBuffer, uint32_t informationBufferLength, void *pDoneCallbackContext)
 

Detailed Description

Typedef Documentation

◆ MBIM_TRANSPORT_ERR_CALLBACK

typedef void(* MBIM_TRANSPORT_ERR_CALLBACK) (void *pErrCallbackContext, MBIM_TRANSPORT_ERR_INFO err_info)

MBIM transport error callback function.

Parameters
[in]pErrCallbackContextUser context of the callback function
[in]err_infoA MBIM_TRANSPORT_ERR_INFO structure which contains the detailed error info.
Returns
None

◆ MbimTransport

typedef struct MbimTransport MbimTransport

This structure abstracts a MBIM transport layer. It is responsible for applying MBIM headers to packets destined for MBIM device services and forwarding them to the device. It is responsible for receiving MBIM packets from the device. On the basis of MBIM headers, it assembles multi-fragment responses and indications and delivers them back to user.

Parameters
deviceFd
  • File descriptor of device.
devRemoved
  • Flag indicating device has been removed.
shutdownFd
  • Event descriptor. Used to signal read thread to terminate.
writeLock
  • Provides mutual exclusion for write operations.
readThread
  • Thread responsible for reading from device.
transactionId
  • MBIM transaction ID. Upper limit 0xffffffff. Never 0. Increments for each transaction.
transactionIdLock
  • Mutex to make transactionId access thread-safe.
transactionList
  • Head of linked list of outstanding transactions.
transactionListLock
  • Provides thread safety for the transaction list.
pIncomingMessage
  • Private workspace to assemble incoming information fragments.
indicatorList
  • Head of linked list of indicators which are called when MBIM indications are received.
indicatorListLock
  • Provides thread safety for the indicators list.
pErrCallback
  • Callback function called by MbimTransport when an error has occurred
pErrCallbackContext

◆ MBIM_DONE_CALLBACK

typedef void(* MBIM_DONE_CALLBACK) (uint32_t status, uint32_t transactionId, uint8_t *informationBuffer, uint32_t informationBufferLength, void *pDoneCallbackContext)

This function prototype represents the callback which is called by the MBIM transport when a MBIM transaction completes.

Parameters
[in]statusMBIM status of the MBIM transaction.
[in]transactionIdTransaction ID of associated MBIM transaction.
[in]informationBufferTransaction response's informationBuffer.
[in]informationBufferLengthNumber of bytes in transaction response's informationBuffer.
[in]pDoneCallbackContextUser context supplied when transaction was initialized.

◆ MbimTransaction

This structure abstracts a MBIM transaction. It is responsible for tracking a MBIM request to its response.

Parameters
pPrev
  • A link so that this object can be stored in a linked list by the transport layer. This points to the previous object or NULL if this is the first object in the list.
pNext
  • A link so that this object can be stored in a linked list by the transport layer. This points to the next object or NULL if this is the last object in the list.
transactionId
  • MBIM transaction ID. Can never be 0.
pDoneCallback
  • User callback for MBIM response.
pDoneCallbackContext
  • User context for user callback.
status
  • MBIM status of response, typically contained in first response fragment.

◆ MBIM_INDICATION_CALLBACK

typedef void(* MBIM_INDICATION_CALLBACK) (uint8_t *deviceServiceId, uint32_t cid, uint8_t *informationBuffer, uint32_t informationBufferLength, void *pIndicationCallbackContext)

This funcion prototype represents the callback which is called by the MBIM transport when a MBIM indication is received.

Parameters
[in]informationBufferIndication's informationBuffer.
[in]informationBufferLengthNumber of bytes in indication's informationBuffer.
[in]pIndicationCallbackContextUser context supplied when indicator was initialized.

◆ MbimIndicator

typedef struct MbimIndicator MbimIndicator

This structure abstracts a MBIM indication callback. Users who wish to be notified of MBIM indications can register one of these objects with the MbimTransport object using MbimTransport_AttachIndicator/MbimTransport_DetachIndicator calls.

Parameters
pPrev
  • A link so that this object can be stored in a linked list by the transport layer. This points to the previous object or NULL if this is the first object in the list.
pNext
  • A link so that this object can be stored in a linked list by the transport layer. This points to the next object or NULL if this is the last object in the list.
pIndicationCallback
  • User callback for MBIM indication.
pIndicationCallbackContext
  • User context for user callback.

◆ MbimSyncObject

This structure is a wrapper around a mutex and condition object and an external buffer. It is a convenience object which may be used to create synchronous MBIM APIs.

Parameters
mutex
  • For thread safety.
condition
  • Triggered on completion.
status
  • The returned MBIM transaction status.
informationBuffer
  • Buffer to which the transaction response's informationBuffer will be copied.
informationBufferLength
  • Set to maximum expected size in bytes of transaction response's informationBuffer. On request completion, it is set to size of transaction response's informationBuffer.

Enumeration Type Documentation

◆ MBIM_TRANSPORT_ERR_TYPE

MBIM transport error type definitions

Function Documentation

◆ MbimTransport_Initialize()

int MbimTransport_Initialize ( MbimTransport pThis,
char *  devicePath,
uint32_t  maxExpectedInformationLength 
)

Initialize this MBIM transport object.

Parameters
[in]pThisThe primary object of this call.
[in]devicePathAbsolute path to device.
[in]maxExpectedInformationLengthMaximum expected length of information content.
Returns
0 on success, < 0 on failure.
Note
maxExpectedInformationLength is used to allocate a buffer for assembling fragments for incoming command responses and indications.

◆ MbimTransport_ShutDown()

void MbimTransport_ShutDown ( MbimTransport pThis)

Shut down this MBIM transport object.

Parameters
[in]pThisThe primary object of this call.

◆ MbimTransport_SendCommand()

int MbimTransport_SendCommand ( MbimTransport pThis,
const uint8_t *  deviceServiceId,
uint32_t  cid,
uint32_t  commandType,
uint8_t *  informationBuffer,
uint16_t  informationBufferLength,
MbimTransaction pTransaction 
)

Send a MBIM command to the device and return immediately.

Parameters
[in]pThisThe primary object of this call.
[in]deviceServiceIdDevice service UUID which is recipient of command.
[in]cidCommand ID (CID) which is specific to that device service.
[in]commandType1 = set, 0 = get.
[in]informationBufferBuffer of information content.
[in]informationBufferLengthSize in bytes of information content.
[in]pTransactionTransaction object which will track the command/response.
Returns
0 on success, < 0 on failure.
Note
pTransaction must have been initialized with MbimTransaction_Initialize prior to this call.

◆ MbimTransport_GetNextTransactionId()

uint32_t MbimTransport_GetNextTransactionId ( MbimTransport pThis)

Returns next transaction ID for MBIM transport.

Parameters
[in]pThisThe primary object of this call.
Returns
transaction ID

◆ MbimTransport_CancelTransaction()

void MbimTransport_CancelTransaction ( MbimTransport pThis,
uint32_t  transactionId 
)

Cancel an outstanding MBIM transaction.

Parameters
[in]pThisThe primary object of this call.
[in]transactionIdID of transaction to be cancelled.

◆ MbimTransport_AttachIndicator()

void MbimTransport_AttachIndicator ( MbimTransport pThis,
MbimIndicator pIndicator 
)

Attaches a MBIM indicator to this MBIM transport object.

Parameters
[in]pThisThe primary object of this call.
[in]pIndicatorIndicator to be attached.

◆ MbimTransport_DetachIndicator()

void MbimTransport_DetachIndicator ( MbimTransport pThis,
MbimIndicator pIndicator 
)

Detaches a MBIM indicator to this MBIM transport object.

Parameters
[in]pThisThe primary object of this call.
[in]pIndicatorIndicator to be detached.

◆ MbimTransport_RegisterErrCallback()

void MbimTransport_RegisterErrCallback ( MbimTransport pThis,
MBIM_TRANSPORT_ERR_CALLBACK  pErrCallback,
void *  pErrCallbackContext 
)

This function is for client applications to register for lite-mbim transport error notifications. The most recent callback registration is the only function that is invoked when device is removed.

Parameters
[in]pThisThe primary object of this call.
[in]pErrCallbackA valid function pointer to be notified when transport error occurred. NULL to disable callback notifications.
[in]pErrCallbackContextUser context when transport error callback is called.
Returns
None

◆ MbimTransaction_Initialize()

void MbimTransaction_Initialize ( MbimTransaction pThis,
uint32_t  transactionId,
MBIM_DONE_CALLBACK  pDoneCallback,
void *  pDoneCallbackContext 
)

Initialize MBIM transaction.

Parameters
[in]pThisThe primary object of this call.
[in]transactionIdTransaction ID obtained from a call to MbimTransport_GetNextTransactionId.
[in]pDoneCallbackUser function to be be called when MBIM response is received.
[in]pDoneCallbackContextA user context for callback.

◆ MbimIndicator_Initialize()

void MbimIndicator_Initialize ( MbimIndicator pThis,
MBIM_INDICATION_CALLBACK  pIndicationCallback,
void *  pIndicationCallbackContext 
)

Initialize the indicator object.

Parameters
[in]pThisThe primary object of this call.
[in]pIndicationCallbackUser function to be be called when MBIM indication is received.
[in]pIndicationCallbackContextA user context for callback.

◆ MbimSyncObject_Initialize()

int MbimSyncObject_Initialize ( MbimSyncObject pThis,
uint8_t *  informationBuffer,
uint32_t  informationBufferLength 
)

Initialize sync object.

Parameters
[in]pThis
  • The primary object of this call.
[in]informationBuffer
  • Buffer to which the transaction response's informationBuffer will be copied.
[in]informationBufferLength
  • Maximum expected size in bytes of transaction response's informationBuffer.
Returns
0 on success, < 0 on failure.

◆ MbimSyncObject_Destroy()

int MbimSyncObject_Destroy ( MbimSyncObject pThis)

Destroy sync object.

Parameters
[in]pThisThe primary object of this call.
Returns
0 on success, < 0 on failure.

◆ MbimSyncObject_Lock()

int MbimSyncObject_Lock ( MbimSyncObject pThis)

Lock sync object.

Parameters
[in]pThisThe primary object of this call.
Returns
0 on success, < 0 on failure.

◆ MbimSyncObject_Unlock()

int MbimSyncObject_Unlock ( MbimSyncObject pThis)

Unlock sync object.

Parameters
[in]pThisThe primary object of this call.
Returns
0 on success, < 0 on failure.

◆ MbimSyncObject_Wait()

int MbimSyncObject_Wait ( MbimSyncObject pThis)

Block, waiting on sync object.

Parameters
[in]pThisThe primary object of this call.
Returns
0 on success, < 0 on failure.

◆ MbimSyncObject_TimedWait()

int MbimSyncObject_TimedWait ( MbimSyncObject pThis,
time_t  timeoutSeconds 
)

Block, waiting on sync object for a number of seconds.

Parameters
[in]pThisThe primary object of this call.
[in]timeoutSecondsTimeout in seconds before abondoning wait.
Returns
0 on success, ETIMEDOUT, or < 0 on failure.

◆ MbimSyncObject_Signal()

int MbimSyncObject_Signal ( MbimSyncObject pThis)

Signal sync object. Waiting thread should wake up.

Parameters
[in]pThisThe primary object of this call.
Returns
0 on success, or < 0 on failure.

◆ MbimSyncObject_DoneCallback()

void MbimSyncObject_DoneCallback ( uint32_t  status,
uint32_t  transactionId,
uint8_t *  informationBuffer,
uint32_t  informationBufferLength,
void *  pDoneCallbackContext 
)

This funcion copies MBIM command response's informationBuffer to this object's informationBuffer and signals the waiting thread.

Parameters
[in]statusMBIM status of the MBIM transaction.
[in]transactionIdTransaction ID of associated MBIM transaction.
[in]informationBufferTransaction response's informationBuffer.
[in]informationBufferLengthNumber of bytes in transaction response's informationBuffer.
[in]pDoneCallbackContextPointer to this sync object.

Copyright (c) 2011-2020 Sierra Wireless, Inc. All rights reserved