COSA
An Object-Oriented Platform for Arduino Programming
CC3000::Driver Class Reference

#include <CC3000.hh>

Inheritance diagram for CC3000::Driver:
Inheritance graph
Collaboration diagram for CC3000::Driver:
Collaboration graph

Public Types

enum  Protocol {
  TCP = SOCK_STREAM, UDP = SOCK_DGRAM, IPRAW = SOCK_RAW, MACRAW = SOCK_RDM,
  PPPoE = SOCK_SEQPACKET
}
 

Public Member Functions

 Driver ()
 
virtual int available ()
 
virtual int room ()
 
virtual int write (const void *buf, size_t size)
 
virtual int write_P (const void *buf, size_t size)
 
virtual int read (void *buf, size_t size)
 
virtual int flush ()
 
virtual int open (Protocol proto, uint16_t port, uint8_t flag)
 
virtual int close ()
 
virtual int listen ()
 
virtual int accept ()
 
virtual int connect (uint8_t addr[4], uint16_t port)
 
virtual int connect (const char *hostname, uint16_t port)
 
virtual int is_connected ()
 
virtual int disconnect ()
 
virtual int datagram (uint8_t addr[4], uint16_t port)
 
virtual int recv (void *buf, size_t len)
 
virtual int recv (void *buf, size_t len, uint8_t src[4], uint16_t &port)
 
void src (INET::addr_t &addr) const
 
Protocol proto () const
 
uint16_t port () const
 
virtual int write (const iovec_t *vec)
 
virtual int getchar ()
 
virtual int read (iovec_t *vec)
 
int send (const void *buf, size_t len)
 
int send (const void *buf, size_t len, uint8_t dest[4], uint16_t port)
 
int send_P (const void *buf, size_t len)
 
int send_P (const void *buf, size_t len, uint8_t dest[4], uint16_t port)
 
void non_blocking ()
 
void blocking ()
 
bool is_blocking () const
 
void eol (Mode mode)
 
Mode eol () const
 
virtual int putchar (char c)
 
virtual int puts (const char *s)
 
virtual int puts (str_P s)
 
virtual int peekchar ()
 
virtual int peekchar (char c)
 
virtual char * gets (char *s, size_t count)
 
virtual void empty ()
 

Static Public Attributes

static const uint16_t DYNAMIC_PORT = 49152
 

Protected Member Functions

virtual int write (const void *buf, size_t size, bool progmem)
 
virtual int send (const void *buf, size_t len, bool progmem)
 
virtual int send (const void *buf, size_t len, uint8_t dest[4], uint16_t port, bool progmem)
 

Protected Attributes

CC3000m_dev
 
uint8_t m_hndl
 
uint8_t m_ip [4]
 
int m_port
 
INET::addr_t m_src
 
uint8_t m_proto
 
bool m_blocking
 
Mode m_eol
 

Friends

class CC3000
 

Detailed Description

CC3000 Single-Chip Internet-enable WiFi Driver. Implements the Cosa/Socket interface.

Definition at line 44 of file CC3000.hh.

Member Enumeration Documentation

enum Socket::Protocol
inherited

Socket type.

Enumerator
TCP 
UDP 
IPRAW 
MACRAW 
PPPoE 

Definition at line 37 of file Socket.hh.

Constructor & Destructor Documentation

CC3000::Driver::Driver ( )
inline

Default constructor.

Definition at line 48 of file CC3000.hh.

Member Function Documentation

int CC3000::Driver::accept ( )
virtual

Check for incoming requests from clients. Return zero if the socket has accepted a request and a connection is established.

Returns
zero if successful otherwise negative error code.

Implements Socket.

Definition at line 183 of file CC3000.cpp.

int CC3000::Driver::available ( )
virtual

Returns true if data is available in receiver buffer otherwise false.

Returns
bool.

Reimplemented from IOStream::Device.

Definition at line 127 of file CC3000.cpp.

void IOStream::Device::blocking ( )
inlineinherited

Set blocking mode.

Definition at line 85 of file IOStream.hh.

int CC3000::Driver::close ( )
virtual

Close the socket.

Returns
zero if successful otherwise negative error code.

Implements Socket.

Definition at line 171 of file CC3000.cpp.

int CC3000::Driver::connect ( uint8_t  addr[4],
uint16_t  port 
)
virtual

Connect the socket to the given address and port; client mode.

Parameters
[in]addrdestination address.
[in]portdestination port.
Returns
zero if successful otherwise negative error code.

Implements Socket.

Definition at line 189 of file CC3000.cpp.

int CC3000::Driver::connect ( const char *  hostname,
uint16_t  port 
)
virtual

Connect the socket to the given hostname and port; client mode. Returns zero if connection established otherwise negative error code.

Parameters
[in]hostnamestring.
[in]portdestination port.
Returns
zero if successful otherwise negative error code.

Implements Socket.

Definition at line 195 of file CC3000.cpp.

int CC3000::Driver::datagram ( uint8_t  addr[4],
uint16_t  port 
)
virtual

Start the construction of a datagram to the given address and port.

Parameters
[in]addrdestination address.
[in]portdestination port.
Returns
zero if successful otherwise negative error code.

Implements Socket.

Definition at line 215 of file CC3000.cpp.

int CC3000::Driver::disconnect ( )
virtual

Disconnect socket from server.

Returns
zero if successful otherwise negative error code.

Implements Socket.

Definition at line 209 of file CC3000.cpp.

void IOStream::Device::empty ( )
virtualinherited

Empty internal device buffers.

Reimplemented in Soft::UART, UART, and IOBuffer< SIZE >.

Definition at line 175 of file IOStream_Device.cpp.

void IOStream::Device::eol ( Mode  mode)
inlineinherited

Set end of line mode.

Parameters
[in]modefor end of line.

Definition at line 103 of file IOStream.hh.

Mode IOStream::Device::eol ( ) const
inlineinherited

Get end of line mode.

Returns
mode.

Definition at line 112 of file IOStream.hh.

int CC3000::Driver::flush ( )
virtual

Flush internal device buffers. Wait for device to become idle.

Returns
zero(0) or negative error code.

Reimplemented from IOStream::Device.

Definition at line 155 of file CC3000.cpp.

virtual int Socket::getchar ( )
inlinevirtualinherited

Read character from device.

Returns
character or EOF(-1).

Reimplemented from IOStream::Device.

Definition at line 115 of file Socket.hh.

char * IOStream::Device::gets ( char *  s,
size_t  count 
)
virtualinherited

Read string terminated by new-line or until size into given string buffer. Returns pointer to string or NULL if empty line.

Parameters
[in]sstring buffer to read into.
[in]countmax number of bytes to read.
Returns
string pointer or NULL.

Definition at line 118 of file IOStream_Device.cpp.

bool IOStream::Device::is_blocking ( ) const
inlineinherited

Is blocking mode?

Returns
bool.

Definition at line 94 of file IOStream.hh.

int CC3000::Driver::is_connected ( )
virtual

Returns positive integer if a connection is established, zero is not yet established, otherwise a negative error code.

Returns
positive integer connected, zero if not otherwise negative error code.

Implements Socket.

Definition at line 203 of file CC3000.cpp.

int CC3000::Driver::listen ( )
virtual

Mark socket for incoming requests; server mode.

Returns
zero if successful otherwise negative error code.

Implements Socket.

Definition at line 177 of file CC3000.cpp.

void IOStream::Device::non_blocking ( )
inlineinherited

Set non-blocking mode.

Definition at line 77 of file IOStream.hh.

int CC3000::Driver::open ( Protocol  proto,
uint16_t  port,
uint8_t  flag 
)
virtual

Initiate socket to the given protocol and possible port.

Parameters
[in]protoprotocol.
[in]portsource port.
[in]flagsocket options.
Returns
zero if successful otherwise negative error code.

Implements Socket.

Definition at line 162 of file CC3000.cpp.

int IOStream::Device::peekchar ( )
virtualinherited

Peek at the next character from device.

Returns
character or EOF(-1).

Reimplemented in Soft::UART, UART, and IOBuffer< SIZE >.

Definition at line 99 of file IOStream_Device.cpp.

int IOStream::Device::peekchar ( char  c)
virtualinherited

Peek for the given character in device buffer. Return number of characters or EOF(-1).

Parameters
[in]ccharacter to peek for.
Returns
available or EOF(-1).

Reimplemented in Soft::UART, UART, and IOBuffer< SIZE >.

Definition at line 105 of file IOStream_Device.cpp.

uint16_t Socket::port ( ) const
inlineinherited

Get socket port.

Returns
port.

Definition at line 78 of file Socket.hh.

Protocol Socket::proto ( ) const
inlineinherited

Get socket protocol.

Returns
protocol.

Definition at line 69 of file Socket.hh.

int IOStream::Device::putchar ( char  c)
virtualinherited

Write character to device.

Parameters
[in]ccharacter to write.
Returns
character written or EOF(-1).

Reimplemented in FAT16::File, HD44780, ST7565, PCD8544, MAX72XX, VLCD, UART, Textbox, IOBuffer< SIZE >, RS485, WIO, and Soft::UAT.

Definition at line 36 of file IOStream_Device.cpp.

int IOStream::Device::puts ( const char *  s)
virtualinherited

Write null terminated string to device. Terminating null is not written.

Parameters
[in]sstring to write.
Returns
zero(0) or negative error code.

Definition at line 43 of file IOStream_Device.cpp.

int IOStream::Device::puts ( str_P  s)
virtualinherited

Write null terminated string from program memory to device. Terminating null is not written.

Parameters
[in]sstring in program memory to write.
Returns
zero(0) or negative error code.

Definition at line 54 of file IOStream_Device.cpp.

int CC3000::Driver::read ( void *  buf,
size_t  size 
)
virtual

Read data to given buffer with given size from device.

Parameters
[in]bufbuffer to read into.
[in]sizenumber of bytes to read.
Returns
number of bytes read or EOF(-1).

Reimplemented from Socket.

Definition at line 146 of file CC3000.cpp.

int IOStream::Device::read ( iovec_t vec)
virtualinherited

Read data to given buffers in null terminated io vector.

Parameters
[in]vecio vector with buffers to read into.
Returns
number of bytes read or EOF(-1).

Definition at line 157 of file IOStream_Device.cpp.

int CC3000::Driver::recv ( void *  buf,
size_t  len 
)
virtual

Receive data from connection-oriented socket. The data is stored in given buffer with given maximum number of bytes. Return number of bytes or negative error code.

Parameters
[in]bufbuffer pointer.
[in]lennumber of bytes in buffer.
Returns
number of bytes sent if successful otherwise negative error code.

Implements Socket.

Definition at line 223 of file CC3000.cpp.

int CC3000::Driver::recv ( void *  buf,
size_t  len,
uint8_t  src[4],
uint16_t &  port 
)
virtual

Receive datagram on connectionless socket into given buffer with given maximum size. Returns zero(0) if successful with information in Datagram otherwise negative error code.

Parameters
[in]bufbuffer pointer.
[in]lennumber of bytes in buffer.
[in]srcsource address.
[in]portsource port.
Returns
number of bytes received if successful otherwise negative error code.

Implements Socket.

Definition at line 229 of file CC3000.cpp.

int CC3000::Driver::room ( )
virtual

Number of bytes room in transmitter buffer before full will be sent.

Returns
bytes.

Reimplemented from IOStream::Device.

Definition at line 139 of file CC3000.cpp.

int Socket::send ( const void *  buf,
size_t  len 
)
inlineinherited

Send given data in buffer on connection-oriented socket. Return number of bytes or negative error code.

Parameters
[in]bufbuffer pointer.
[in]lennumber of bytes in buffer.
Returns
number of bytes sent if successful otherwise negative error code.

Definition at line 222 of file Socket.hh.

int CC3000::Driver::send ( const void *  buf,
size_t  len,
bool  progmem 
)
protectedvirtual

Send given data in buffer on connection-oriented socket. Boolean flag progmem defined if the buffer is in program memory. Return number of bytes or negative error code.

Parameters
[in]bufbuffer pointer.
[in]lennumber of bytes in buffer.
[in]progmemprogram memory pointer flag.
Returns
number of bytes sent if successful otherwise negative error code.

Implements Socket.

Definition at line 248 of file CC3000.cpp.

int CC3000::Driver::send ( const void *  buf,
size_t  len,
uint8_t  dest[4],
uint16_t  port,
bool  progmem 
)
protectedvirtual

Send given data on connectionless socket as a datagram to given destination address (dest:port). Return number of bytes sent or negative error code.

Parameters
[in]bufbuffer pointer.
[in]lennumber of bytes in buffer.
[in]destdestination address.
[in]portdestination port.
[in]progmemprogram memory pointer flag.
Returns
number of bytes sent if successful otherwise negative error code.

Implements Socket.

Definition at line 255 of file CC3000.cpp.

int Socket::send ( const void *  buf,
size_t  len,
uint8_t  dest[4],
uint16_t  port 
)
inlineinherited

Send given data in buffer on connectionless socket as a datagram to given destination address (dest:port). Return number of bytes sent or negative error code.

Parameters
[in]bufbuffer pointer.
[in]lennumber of bytes in buffer.
[in]destdestination address.
[in]portdestination port.
Returns
number of bytes sent if successful otherwise negative error code.

Definition at line 264 of file Socket.hh.

int Socket::send_P ( const void *  buf,
size_t  len 
)
inlineinherited

Send given data in program memory buffer on connection-oriented socket. Return number of bytes or negative error code.

Parameters
[in]bufprogram memory pointer.
[in]lennumber of bytes in buffer.
Returns
number of bytes sent if successful otherwise negative error code.

Definition at line 236 of file Socket.hh.

int Socket::send_P ( const void *  buf,
size_t  len,
uint8_t  dest[4],
uint16_t  port 
)
inlineinherited

Send given data in program memory buffer on connectionless socket as a datagram to given destination address (dest:port). Return number of bytes sent or negative error code.

Parameters
[in]bufbuffer pointer.
[in]lennumber of bytes in buffer.
[in]destdestination address.
[in]portdestination port.
Returns
number of bytes sent if successful otherwise negative error code.

Definition at line 281 of file Socket.hh.

void Socket::src ( INET::addr_t addr) const
inlineinherited

Get source machine address, network address and port.

Parameters
[out]addrnetwork address.

Definition at line 60 of file Socket.hh.

virtual int CC3000::Driver::write ( const void *  buf,
size_t  size 
)
inlinevirtual

Write data from buffer with given size to device.

Parameters
[in]bufbuffer to write.
[in]sizenumber of bytes to write.
Returns
number of bytes written or EOF(-1).

Reimplemented from Socket.

Definition at line 74 of file CC3000.hh.

int IOStream::Device::write ( const iovec_t vec)
virtualinherited

Write data from buffers in null terminated io vector.

Parameters
[in]vecio vector with buffers to write.
Returns
number of bytes written or EOF(-1).

Definition at line 87 of file IOStream_Device.cpp.

int CC3000::Driver::write ( const void *  buf,
size_t  size,
bool  progmem 
)
protectedvirtual

Write data from buffer with given size to device. Boolean flag progmem defined if the buffer is in program memory. Return number of bytes or negative error code.

Parameters
[in]bufbuffer to write.
[in]sizenumber of bytes to write.
[in]progmemprogram memory pointer flag.
Returns
number of bytes written or EOF(-1).

Reimplemented from Socket.

Definition at line 239 of file CC3000.cpp.

virtual int CC3000::Driver::write_P ( const void *  buf,
size_t  size 
)
inlinevirtual

Write data from buffer in program memory with given size to device.

Parameters
[in]bufbuffer to write.
[in]sizenumber of bytes to write.
Returns
number of bytes written or EOF(-1).

Reimplemented from Socket.

Definition at line 86 of file CC3000.hh.

Friends And Related Function Documentation

friend class CC3000
friend

Definition at line 45 of file CC3000.hh.

Member Data Documentation

const uint16_t Socket::DYNAMIC_PORT = 49152
staticinherited

First dynamic, private or ephemeral port number.

Definition at line 34 of file Socket.hh.

bool IOStream::Device::m_blocking
protectedinherited

Blocking state

Definition at line 248 of file IOStream.hh.

CC3000* CC3000::Driver::m_dev
protected

Parent device for CC3000 socket driver.

Definition at line 258 of file CC3000.hh.

Mode IOStream::Device::m_eol
protectedinherited

End of line mode

Definition at line 251 of file IOStream.hh.

uint8_t CC3000::Driver::m_hndl
protected

Socket handle. Should be same as socket index.

Definition at line 261 of file CC3000.hh.

uint8_t CC3000::Driver::m_ip[4]
protected

IP address.

Definition at line 264 of file CC3000.hh.

int CC3000::Driver::m_port
protected

Port.

Definition at line 267 of file CC3000.hh.

uint8_t Socket::m_proto
protectedinherited

Socket protocol if open otherwise zero(0).

Definition at line 305 of file Socket.hh.

INET::addr_t Socket::m_src
protectedinherited

Source address; MAC, IP and port.

Definition at line 302 of file Socket.hh.


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