这里首先介绍是第一种方式,采用 Blocking 的方式,在一个 main loop 中发送数据。
第一步:调用 tlc_init 方法,进行TRDP协议栈初始化。
/** Initialize the TRDP stack.
*
* tlc_init initializes the memory subsystem and takes a function pointer to an output function for logging.
*
* @param[in] pPrintDebugString Pointer to debug print function
* @param[in] pRefCon user context
* @param[in] pMemConfig Pointer to memory configuration
*
* @retval TRDP_NO_ERR no error
* @retval TRDP_MEM_ERR memory allocation failed
* @retval TRDP_PARAM_ERR initialization error
*/
EXT_DECL TRDP_ERR_T tlc_init (
const TRDP_PRINT_DBG_T pPrintDebugString,
void *pRefCon,
const TRDP_MEM_CONFIG_T *pMemConfig)
第二步:调用 tlc_openSession 方法,取得 类型为TRDP_APP_SESSION_T 的TRDP协议栈的唯一的Handle。
/** Open a session with the TRDP stack.
*
* tlc_openSession returns in pAppHandle a unique handle to be used in further calls to the stack.
*
* @param[out] pAppHandle A handle for further calls to the trdp stack
* @param[in] ownIpAddr Own IP address, can be different for each process in multihoming systems,
* if zero, the default interface / IP will be used.
* @param[in] leaderIpAddr IP address of redundancy leader
* @param[in] pMarshall Pointer to marshalling configuration
* @param[in] pPdDefault Pointer to default PD configuration
* @param[in] pMdDefault Pointer to default MD configuration
* @param[in] pProcessConfig Pointer to process configuration
* only option parameter is used here to define session behavior