Methods and Callbacks


  1. trill_data_link_cb_t : Function for datalink callback event

eg- (trill_data_link_cb_t)(const trill_data_link_event_params_t params);

trill_data_link_event_params_t : Data Link layer callback parameters containing:

  1. event :Event code. Refer to trill_data_link_event_t

  2. payload: Payload data. Pointer should not be used after returning from this callback.

  3. payload_len: Length of the payload in bytes.

  4. ssi: Security scheme that was used for this packet.

  5. data_cfg_range: Range Config of received data.

  6. user_data: User provided data.

  7. channel: which channel the data was received from.

2. 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.

3. int trill_process(void handle): Rx path processing function. Call from a separate task/thread in a loop. Refer to example code.

Processing state:

  • TRILL_PROC_CTS_SEARCH = CTS Hunting mode.

  • TRILL_PROC_DEMOD_PROGRESS = Demodulation in progress.

  • TRILL_PROC_MOD_PACKET_SENT = Modulated packet was sent.

  • Negative error code.

Return: int

4. 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.

Return: int 0 on success else negative error code.

5. 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.

Return: int 0 on success else TRILL_ERR_AUDIO_TX_BLOCK_NOT_AVAILABLE when no Tx block is available.

6. int trill_release_audio_block(void handle): Call after successfully acquiring a Tx audio block to return it to Tx audio buffer.

Return: int

7. 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_input / trill_process_output functions.

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.

Return: int 0 on packet accepted to be sent else negative error code.

8. 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

Return: int 0 on success else negative error code.

9. 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.

10. 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. /

11. trill_deinit(void handle): DeInitialize the SDK and release all memories.

  • @param handle

Return: int error code

Please refer to troubleshooting guide for the errors that can be returned by the above methods.

Last updated