Trill SDK Methods
Methods:
1. trill_init : This method should be called to Initialise the SDK.
This is also the first function to be called before SDK can be used.
@param init_opt Initialization options. Refer to trill_init_opts_t
@param handle SDK Handle. Preserve it to pass with other calls.
Return: int 0 on success else negative error code.
2. int trill_process(void handle): Rx path processing function. Call from a separate task/thread in a loop. Refer to example code.
@param handle - SDK Handle. Handle returned during init.
Processing state:
TRILL_PROC_CTS_SEARCH = Trigger search mode. Negative error code if there is any error.
TRILL_PROC_DEMOD_PROGRESS = Demodulation in progress.
TRILL_PROC_MOD_PACKET_SENT = Modulated packet was sent.
Negative error code.
Return: int
3. int trill_add_audio_block(void handle, const void* block): Call when next Rx audio block is available. The block size should be same as given in the SDK initialization options. This function can be called from ISR.
@param block Block data address. Block can be reused after call returns.
@param handle - SDK Handle. Handle returned during init.
Return: int 0 on success else negative error code.
4. int trill_acquire_audio_block(void handle, short** addr, int en_blocking): Call when next Tx audio block can be sent This function will not block even when no Tx block is available from audio buffer, when this scenario occurs it will lead to Tx underrun.
This function can be called from ISR.
The size of the acquired block is same as given in the SDK initialization options.
@param addr Address of the block inside the audio buffer. Caller should copy the data and call trill_release_audio_block.
@param en_blocking If non-zero, call will block until audio block is available. Set to zero if calling from ISR. Set to non-zero if calling from task/thread.
@param handle - SDK Handle. Handle returned during init.
Return: int 0 on success else TRILL_ERR_AUDIO_TX_BLOCK_NOT_AVAILABLE when no Tx block is available.
5. int trill_release_audio_block(void handle): Call after successfully acquiring a Tx audio block to return it to Tx audio buffer.
@param handle - SDK Handle. Handle returned during init.
Return: int
6. int trill_tx_data(void handle, trill_tx_params_t* security_params, unsigned char* data, unsigned int data_len) :
Send Tx Packet. Call it from a task/thread other than the one being used to call trill_process.
When this function returns success, packet is prepared but not yet sent. When sent successfully data link layer will send notification callback
@param security_params Refer to trill_tx_params_t
@param data Payload data to be sent. data pointer can be reused after the function returns.
@param data_len Payload size in bytes.
@param handle - SDK Handle. Handle returned during init.
Return: int 0 on packet accepted to be sent else negative error code.
7. trill_tx_abort(void handle): Abort Tx data if in progress or about to be sent. Even after successful abort there might be unread audio blocks in audio buffer. These need to be flushed out by application.
@param handle - SDK Handle. Handle returned during init.
Return: int 0 on success else negative error code.
8. int trill_get_device_id(const char* buf) : Retrieve the device ID of this MCU as represented by SDK internally. Use the retrieved device id for data exchange with server APIs.
@param buf Address of the buffer to receive null terminated device id string.
Return: int 0 on success else negative error code.
9. int trill_is_device_verified(void handle): brief Can be used to verify whether device License is valid.
Return: int Positive number if License is valid else 0. /
10. trill_deinit(void handle): DeInitialize the SDK and release all memories.
@param handle - SDK Handle. Handle returned during init.
Return: int error code
Please refer to troubleshooting guide for the errors that can be returned by the above methods.
Last updated