WISP ERT (Client)  1.0.0
The WISP Extended Runtime (WISP side)
endpoint.h File Reference
#include <wio.h>
#include "defs.h"
#include "transmission.h"

Go to the source code of this file.

Data Structures

struct  wtp_t
 WTP endpoint type. More...
 

Functions

wtp_status_t wtp_init (wtp_t *self, uint8_t *epc_mem, uint16_t epc_buf_size, uint8_t *read_mem, uint8_t *write_mem, uint16_t window_size, uint16_t timeout, uint16_t tx_buf_size, uint16_t rx_buf_size, uint8_t n_send, uint8_t n_recv)
 Initialize WTP endpoint. More...
 
wtp_status_t wtp_fini (wtp_t *self)
 Finalize WTP endpoint. More...
 
wtp_status_t wtp_connect (wtp_t *self)
 Connect to WTP server. More...
 
wtp_status_t wtp_close (wtp_t *self)
 Disconnect from WTP server. More...
 
wtp_status_t wtp_send (wtp_t *self, uint8_t *data, uint16_t size, void *cb_data, wio_callback_t cb)
 Send message to WTP server. More...
 
wtp_status_t wtp_recv (wtp_t *self, void *cb_data, wio_callback_t cb)
 Receive message from WTP server. More...
 
wtp_status_t wtp_on_event (wtp_t *self, wtp_event_t event, void *cb_data, wio_callback_t cb)
 Set WTP event handler. More...
 
wtp_status_t wtp_trigger_event (wtp_t *self, wtp_event_t event, wtp_status_t status, void *result)
 Trigger WTP event. More...
 
wtp_status_t wtp_load_read_mem (wtp_t *self)
 Load RFID READ memory for WTP communication. More...
 
wtp_status_t wtp_handle_blockwrite (wtp_t *self)
 Handle RFID BLOCKWRITE operation. More...
 
wtp_status_t wtp_verify_checksum (wtp_t *self, wio_buf_t *write_buf)
 Verify the checksum of received WTP packet. More...
 
uint8_t wtp_xor_checksum (uint8_t *mem, uint16_t begin, uint16_t end)
 WTP Xor checksum function. More...
 

Function Documentation

◆ wtp_close()

wtp_status_t wtp_close ( wtp_t self)

Disconnect from WTP server.

Parameters
selfWTP endpoint instance.
Returns
Error code if failed, otherwise WIO_OK.

◆ wtp_connect()

wtp_status_t wtp_connect ( wtp_t self)

Connect to WTP server.

Parameters
selfWTP endpoint instance.
Returns
Error code if failed, otherwise WIO_OK.

◆ wtp_fini()

wtp_status_t wtp_fini ( wtp_t self)

Finalize WTP endpoint.

Parameters
selfWTP endpoint instance.
Returns
WIO_OK.

◆ wtp_handle_blockwrite()

wtp_status_t wtp_handle_blockwrite ( wtp_t self)

Handle RFID BLOCKWRITE operation.

Parameters
selfWTP endpoint instance.
Returns
Error code if failed, otherwise WIO_OK.

◆ wtp_init()

wtp_status_t wtp_init ( wtp_t self,
uint8_t *  epc_mem,
uint16_t  epc_buf_size,
uint8_t *  read_mem,
uint8_t *  write_mem,
uint16_t  window_size,
uint16_t  timeout,
uint16_t  tx_buf_size,
uint16_t  rx_buf_size,
uint8_t  n_send,
uint8_t  n_recv 
)

Initialize WTP endpoint.

Parameters
selfWTP endpoint instance.
epc_memEPC-96 data section memory.
epc_buf_sizeSize of the EPC-96 data section.
read_memRead memory.
write_memBlockWrite memory.
window_sizeWTP sliding window size.
timeoutWTP packet retransmission timeout.
tx_buf_sizeTransmit control buffer size.
rx_buf_sizeReceive control buffer size.
n_sendCapacity of send callbacks.
n_recvCapacity of receive callbacks.
Returns
WIO_ERR_NO_MEMORY if memory allocation failed, otherwise WIO_OK.

◆ wtp_load_read_mem()

wtp_status_t wtp_load_read_mem ( wtp_t self)

Load RFID READ memory for WTP communication.

Parameters
selfWTP endpoint instance.
Returns
Error code if failed, otherwise WIO_OK.

◆ wtp_on_event()

wtp_status_t wtp_on_event ( wtp_t self,
wtp_event_t  event,
void *  cb_data,
wio_callback_t  cb 
)

Set WTP event handler.

Parameters
selfWTP endpoint instance.
eventWTP event.
cb_dataCallback closure data.
cbCallback function.
Returns
WIO_ERR_INVALID for invalid event, otherwise WIO_OK.

◆ wtp_recv()

wtp_status_t wtp_recv ( wtp_t self,
void *  cb_data,
wio_callback_t  cb 
)

Receive message from WTP server.

Parameters
selfWTP endpoint instance.
cb_dataCallback closure data.
cbCallback function.
Returns
WIO_ERR_NO_MEMORY if no memory available for storing callback, otherwise WIO_OK.

◆ wtp_send()

wtp_status_t wtp_send ( wtp_t self,
uint8_t *  data,
uint16_t  size,
void *  cb_data,
wio_callback_t  cb 
)

Send message to WTP server.

Parameters
selfWTP endpoint instance.
dataData to send.
sizeSize of data.
cb_dataCallback closure data.
cbCallback function.
Returns
Error code if failed, otherwise WIO_OK.

◆ wtp_trigger_event()

wtp_status_t wtp_trigger_event ( wtp_t self,
wtp_event_t  event,
wtp_status_t  status,
void *  result 
)

Trigger WTP event.

Parameters
selfWTP endpoint instance.
eventWTP event.
statusEvent status.
resultEvent result.
Returns
Status code returned by repsective callback function.

◆ wtp_verify_checksum()

wtp_status_t wtp_verify_checksum ( wtp_t self,
wio_buf_t write_buf 
)

Verify the checksum of received WTP packet.

Parameters
selfWTP endpoint instance.
write_bufReceived WTP packets buffer.
Returns
Error code if checksum validation failed, otherwise WIO_OK.

◆ wtp_xor_checksum()

uint8_t wtp_xor_checksum ( uint8_t *  mem,
uint16_t  begin,
uint16_t  end 
)

WTP Xor checksum function.

Parameters
memMemory to calculate checksum.
beginBegin index for checksum calculation.
endEnd index for checksum calculation.
Returns
Xor checksum for given range of memory.