WebRadioApp  0.1
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
TcpClient Class Reference

TcpClient Object. More...

#include <tcp_client.h>

Collaboration diagram for TcpClient:

Public Member Functions

 TcpClient (Mp3Player *mp3, struct netif *connection)
 Construct a new Tcp Client object. More...
 
void connect (ip_addr_t DestIPaddr, uint16_t DEST_PORT)
 Tcp Client object and Connects to the TCP server. More...
 
void disconnect (void)
 disconnects the TCP server More...
 
void connectionClose (struct tcp_pcb *tpcb, struct client *es)
 This function is used to close the tcp connection with server. More...
 
void process (void)
 Process object. More...
 
void analysisOfMetaInfo (void)
 Analyse and display metainfo, if present. More...
 
void updateStation (void)
 On station change disconnect and delete all buffers, then reconnect with new station. More...
 
void gateActivities (void)
 Gate for all activites that are admitted every 1s. More...
 
void adjustBuffer ()
 
  • Adjust speed of danger of buffer overfill: consume items slower
More...
 

Data Fields

Mp3Playerm_mp3
 
Stationstations = Stationlist
 
DNS_desc_tserver = Server
 
struct netif * gnetif
 
struct clientes = (struct client *)mem_malloc(sizeof(struct client))
 

Private Member Functions

void clearAudioBuffer (void)
 
void clearFileReadBuffer (void)
 

Static Private Member Functions

static err_t connected (void *arg, struct tcp_pcb *tpcb, err_t err)
 Function called when TCP connection established. More...
 
static err_t recv (void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)
 tcp_receiv callback More...
 
static void send (struct tcp_pcb *tpcb, struct client *es)
 function used to send data More...
 
static err_t poll (void *arg, struct tcp_pcb *tpcb)
 This function implements the tcp_poll callback function. More...
 
static err_t sent (void *arg, struct tcp_pcb *tpcb, u16_t len)
 This function implements the tcp_sent LwIP callback (called when ACK is received from remote host for sent data) More...
 

Detailed Description

TcpClient Object.


Constructor & Destructor Documentation

◆ TcpClient()

TcpClient::TcpClient ( Mp3Player mp3,
struct netif *  connection 
)
inline

Construct a new Tcp Client object.

Parameters
mp3
connection

Member Function Documentation

◆ adjustBuffer()

void TcpClient::adjustBuffer ( )

  • Adjust speed of danger of buffer overfill: consume items slower

  • Adjust speed if danger of buffer underrun: consume items faster

Here is the caller graph for this function:

◆ analysisOfMetaInfo()

void TcpClient::analysisOfMetaInfo ( void  )

Analyse and display metainfo, if present.


Here is the caller graph for this function:

◆ clearAudioBuffer()

void TcpClient::clearAudioBuffer ( void  )
inlineprivate

References AUDIO_BUFFER_SIZE.

◆ clearFileReadBuffer()

void TcpClient::clearFileReadBuffer ( void  )
inlineprivate

◆ connect()

void TcpClient::connect ( ip_addr_t  DestIPaddr,
uint16_t  DEST_PORT 
)

Tcp Client object and Connects to the TCP server.

Parameters
DestIPaddr
DEST_PORT

◆ connected()

static err_t TcpClient::connected ( void arg,
struct tcp_pcb *  tpcb,
err_t  err 
)
inlinestaticprivate

Function called when TCP connection established.

Parameters
tpcbpointer on the connection contol block
errwhen connection correctly established err should be ERR_OK
Return values
err_treturned error

References err, es, ES_CONNECTED, httpstr, client::p_tx, client::pcb, and client::state.

◆ connectionClose()

void TcpClient::connectionClose ( struct tcp_pcb *  tpcb,
struct client es 
)

This function is used to close the tcp connection with server.

Parameters
tpcbtcp connection control block
espointer on client structure
Return values
None

◆ disconnect()

void TcpClient::disconnect ( void  )

disconnects the TCP server


◆ gateActivities()

void TcpClient::gateActivities ( void  )

Gate for all activites that are admitted every 1s.


Here is the caller graph for this function:

◆ poll()

static err_t TcpClient::poll ( void arg,
struct tcp_pcb *  tpcb 
)
inlinestaticprivate

This function implements the tcp_poll callback function.

Parameters
argpointer on argument passed to callback
tpcbtcp connection control block
Return values
err_terror code

References es, ES_CLOSING, client::p_tx, and client::state.

◆ process()

void TcpClient::process ( void  )

Process object.


Here is the caller graph for this function:

◆ recv()

static err_t TcpClient::recv ( void arg,
struct tcp_pcb *  tpcb,
struct pbuf *  p,
err_t  err 
)
inlinestaticprivate

tcp_receiv callback

Parameters
argargument to be passed to receive callback
tpcbtcp connection control block
errreceive error code
Return values
err_tretuned error

References curr_len, data_with_metainfo, err, es, ES_CLOSING, ES_CONNECTED, initial_pipe, inserted_len, insertion_point, insertion_point_maximum, items, lencounter, message_count, meta_info_len, meta_start_index, meta_string, metainfo_present, metaint, metainterval, metnum, msg_len_max, p, client::p_tx, payloadtemp, ptr2, sent_len, startnameptr, client::state, stationname, strptr, TCPBUFF_MAXITEMS, and totaldatacount.

◆ send()

static void TcpClient::send ( struct tcp_pcb *  tpcb,
struct client es 
)
inlinestaticprivate

function used to send data

Parameters
tpcbtcp control block
espointer on structure of type client containing info on data to be sent
Return values
None

References es, and client::p_tx.

◆ sent()

static err_t TcpClient::sent ( void arg,
struct tcp_pcb *  tpcb,
u16_t  len 
)
inlinestaticprivate

This function implements the tcp_sent LwIP callback (called when ACK is received from remote host for sent data)

Parameters
argpointer on argument passed to callback
tcp_pcbtcp connection control block
lenlength of data sent
Return values
err_treturned error code

References es, and client::p_tx.

◆ updateStation()

void TcpClient::updateStation ( void  )

On station change disconnect and delete all buffers, then reconnect with new station.


Here is the caller graph for this function:

Field Documentation

◆ es

struct client* TcpClient::es = (struct client *)mem_malloc(sizeof(struct client))

allocate structure es to maintain tcp connection informations

◆ gnetif

struct netif* TcpClient::gnetif

◆ m_mp3

Mp3Player* TcpClient::m_mp3

◆ server

DNS_desc_t* TcpClient::server = Server

◆ stations

Station* TcpClient::stations = Stationlist

The documentation for this class was generated from the following file: