Data Transmission
This is the header file for "psdk_data_transmission.c", defining the structure and (exported) function prototypes.
Catalog
Typedef Function
ReceiveDataFromMobileCallback
ReceiveDataFromOsdkCallbackFunction
PsdkDataTransmission_Init
PsdkDataTransmission_DeInit
PsdkDataTransmission_RegReceiveDataFromMobileCallback
PsdkDataTransmission_RegReceiveDataFromOsdkCallback
PsdkDataTransmission_SendDataToMobile
PsdkDataTransmission_SendDataToOsdk
PsdkDataTransmission_GetSendToMobileState
PsdkDataTransmission_GetSendToOsdkState
PsdkDataTransmission_GetDataStreamRemoteAddress
PsdkDataTransmission_SendDataStream
PsdkDataTransmission_GetDataStreamState
Typedef Function
typedef function ReceiveDataFromMobileCallback
Function:Receive data from Mobile App | product:all |
Prototype of callback function used to receive data that come from Mobile App or MSDK.
NOTE Developer can not execute blocking style operations or functions in callback function, because that will block PSDK root thread, causing problems such as slow system response, payload disconnection or infinite loop.
typedef T_PsdkReturnCode (*ReceiveDataFromMobileCallback)(const uint8_t *data, uint16_t len);
data:pointer to data.
len:length of data.
Return
The details for the return code please refer to:PsdkErrorCode
typedef function ReceiveDataFromOsdkCallback
Function:Receive data from onboard computer | product:all |
Prototype of callback function used to receive data that come from onboard computer.
NOTE Developer can not execute blocking style operations or functions in callback function, because that will block PSDK root thread, causing problems such as slow system response, payload disconnection or infinite loop.
typedef T_PsdkReturnCode (*ReceiveDataFromOsdkCallback)(const uint8_t *data, uint16_t len);
data:pointer to data.
len:length of data.
Return
The details for the return code please refer to:PsdkErrorCode
Function
function PsdkDataTransmission_Init
Function:Initialise data transmission module | product:all |
Initialise data transmission module in block mode. Developer Should call this function before sending data to Mobile App/onboard computer or receiving data.
NOTE Max execution time of this function is slightly larger than 500ms.
T_PsdkReturnCode PsdkDataTransmission_Init(void);
Return
The details for the return code please refer to:PsdkErrorCode
function PsdkDataTransmission_DeInit
Function:Deinitialize data transmission module | product:all |
Deinitialize data transmission module. User can call this function to release all resources that data transmission module have occupied from the system and restore the state of internal variables when functions of data transmission module will no longer be used or exit program.
T_PsdkReturnCode PsdkDataTransmission_DeInit(void);
Return
The details for the return code please refer to:PsdkErrorCode
function PsdkDataTransmission_RegReceiveDataFromMobileCallback
Function:Receive data from mobile | product:all |
Register callback function used to receive data from Mobile App. After registering this callback function, callback function will be called automatically when system receive data from Mobile App.
T_PsdkReturnCode PsdkDataTransmission_RegReceiveDataFromMobileCallback(ReceiveDataFromMobileCallback callback);
callback:pointer to callback function.
Return
The details for the return code please refer to:PsdkErrorCode
function PsdkDataTransmission_RegReceiveDataFromOsdkCallback
Function:Receive data from onboard computer | product:all |
Register callback function used to receive data from onboard computer. After registering this callbackfunction, callback function will be called automatically when system receive data from onboard computer.
T_PsdkReturnCode PsdkDataTransmission_RegReceiveDataFromOsdkCallback(ReceiveDataFromOsdkCallback callback);
callback:pointer to callback function.
Return
The details for the return code please refer to:PsdkErrorCode
function PsdkDataTransmission_SendDataToMobile
Function:Send data to mobile | product:all |
Send data to Mobile App via command channel.
NOTE
- If actual bandwidth is below limitation, data can be sent to the endpoint directly. If exceeds the limitation, firstly data will be stored to buffer of the flow controller and be sent to endpoint after a period (an integer multiple of 1s, the exact time depends on bandwidth limitation and buffer size). If the buffer is full, data be will discarded. The capacity of flow controller buffer is 512 bytes.
- Must ensure actual bandwidth is less than bandwidth limitation of corresponding channel or stream, please refer to developer documentation or state of channel/stream for details related to bandwidth limitation. User can get state of "sendToMobile" command channel by PsdkDataTransmission_GetSendToMobileState() function. If actual bandwidth exceeds the limitation or busy state is set, the user should stop transmitting data or decrease amount of data to be sent.
- Max size of data package sent to Mobile App on a physical link of command channel is 128. If the length of data to be sent is greater than 128, data to be sent will be divided into multiple packages to send, and the user will also receive multiple data packages on the Mobile App.
T_PsdkReturnCode PsdkDataTransmission_SendDataToMobile(const uint8_t *data, uint8_t len);
data:pointer to data to be sent.
len:length of data to be sent, unit: byte.
Return
The details for the return code please refer to:PsdkErrorCode
function PsdkDataTransmission_SendDataToOsdk
Send data to the onboard computer | product:all |
Send data to the onboard computer via command channel.
NOTE
- If actual bandwidth is below limitation, data can be sent to the endpoint directly. If exceeds the limitation, firstly data will be stored to buffer of the flow controller and be sent to endpoint after a period (an integer multiple of 1s, the exact time depends on bandwidth limitation and buffer size). If the buffer is full, data will be discarded. The capacity of flow controller buffer is 512 bytes.
- Must ensure actual bandwidth is less than bandwidth limitation of corresponding channel or stream, please refer to developer documentation or state of channel/stream for details related to bandwidth limitation. User can get state of "sendToOsdk" command channel via PsdkDataTransmission_GetSendToOsdkState() function. If actual bandwidth exceeds the limitation or busy state is set, the user should stop transmitting data or decrease amount of data to be sent.
- Max size of data package sent to an onboard computer on the physical link of command channel is 255. If the length of data to be sent is greater than 255, data to be sent will be divided into multiple packages to send, and the user will also receive multiple data packages on the onboard computer.
T_PsdkReturnCode PsdkDataTransmission_SendDataToOsdk(const uint8_t *data, uint8_t len);
data:pointer to data to be sent.
len:length of data to be sent, unit: byte.
Return
The details for the return code please refer to:PsdkErrorCode
function PsdkDataTransmission_GetSendToMobileState
Function:Get data transmission state of "sendToMobile" command channel. | product:all |
Get data transmission state of "sendToMobile" command channel. User can use the state as base for controlling data transmission between payload and Mobile App.
T_PsdkReturnCode PsdkDataTransmission_GetSendToMobileState(T_PsdkDataChannelState *state);
state:pointer to "sendToMobile" command channel state.
Return
The details for the return code please refer to:PsdkErrorCode
function PsdkDataTransmission_GetSendToOsdkState
Function: Get data transmission state of "sendToOsdk" command channel | product:all |
Get data transmission state of "sendToOsdk" command channel.
User can use the state as base for controlling data transmission between payload and onboard computer.
T_PsdkReturnCode PsdkDataTransmission_GetSendToOsdkState(T_PsdkDataChannelState *state);
state: pointer to "sendToOsdk" command channel state.
Return
The details for the return code please refer to:PsdkErrorCode
function PsdkDataTransmission_GetDataStreamRemoteAddress
Function: Get the network remote address for sending data stream | product:all |
NOTE
- Users can get the destination address of custom data transmission, and send custom data independently through other subsystems in heterogeneous system.
T_PsdkReturnCode PsdkDataTransmission_GetDataStreamRemoteAddress(char *ipAddr, uint16_t *port);
ipAddr: the remote ip address for sending data stream
port: the remote port for sending data stream
Return
The details for the return code please refer to:PsdkErrorCode
function PsdkDataTransmission_SendDataStream
Function:Send data to Mobile App on data channel. | product:all |
Send data stream to Mobile App on the data channel.
NOTE
- This function can be used only in Linux operating system.
- Must ensure actual bandwidth is less than bandwidth limitation of corresponding channel or stream, please refer to developer documentation and state of channel/stream for details related to bandwidth limitation. User can get state of "dataStream" channel via PsdkDataTransmission_GetDataStreamState() function. If actual bandwidth exceeds the limitation or busy state is set, the user should stop transmitting data or decrease amount of data to be sent. Otherwise, data may be discarded.
T_PsdkReturnCode PsdkDataTransmission_SendDataStream(const uint8_t *data, uint16_t len);
data:pointer to data to be sent.
len:length of data to be sent via data stream, and it must be less than or equal to 65000, unit: byte.
Return
The details for the return code please refer to:PsdkErrorCode
function PsdkDataTransmission_GetDataStreamState
Function:Get data transmission state | product:all |
Get data transmission state of "dataStream" channel. User can use the state as base for controlling data transmission of data stream. This function exists and can be used only in Linux operation system.
NOTE Only Linux support this feature.
T_PsdkReturnCode PsdkDataTransmission_GetDataStreamState(T_PsdkDataChannelState *state);
state:pointer to "dataStream" channel state.
Return
The details for the return code please refer to:PsdkErrorCode