USB Host Shield 2.0
Public Member Functions | Public Attributes | List of all members
SPP Class Reference

#include <SPP.h>

Inheritance diagram for SPP:
Inheritance graph
[legend]
Collaboration diagram for SPP:
Collaboration graph
[legend]

Public Member Functions

 SPP (BTD *p, const char *name="Arduino", const char *pin="0000")
 
 operator bool ()
 
Serial port profile (SPP) Print functions
int available (void)
 
void flush (void)
 
int peek (void)
 
int read (void)
 
size_t write (uint8_t data)
 
size_t write (const uint8_t *data, size_t size)
 
void discard (void)
 
void send (void)
 
- Public Member Functions inherited from BluetoothService
 BluetoothService (BTD *p)
 
void attachOnInit (void(*funcOnInit)(void))
 

Public Attributes

bool connected
 

BluetoothService implementation

void disconnect ()
 
void ACLData (uint8_t *ACLData)
 
void Run ()
 
void Reset ()
 
void onInit ()
 

Additional Inherited Members

- Protected Member Functions inherited from BluetoothService
bool checkHciHandle (uint8_t *buf, uint16_t handle)
 
- Protected Attributes inherited from BluetoothService
void(* pFuncOnInit )(void)
 
BTDpBtd
 
uint16_t hci_handle
 
uint32_t l2cap_event_flag
 
uint8_t identifier
 

Detailed Description

This BluetoothService class implements the Serial Port Protocol (SPP). It inherits the Arduino Stream class. This allows it to use all the standard Arduino print and stream functions.

Definition at line 55 of file SPP.h.

Constructor & Destructor Documentation

◆ SPP()

SPP::SPP ( BTD p,
const char *  name = "Arduino",
const char *  pin = "0000" 
)

Constructor for the SPP class.

Parameters
pPointer to BTD class instance.
nameSet the name to BTD::btdName. If argument is omitted, then "Arduino" will be used.
pinWrite the pin to BTD::btdPin. If argument is omitted, then "0000" will be used.

Definition at line 45 of file SPP.cpp.

Member Function Documentation

◆ disconnect()

void SPP::disconnect ( )
virtual

Used this to disconnect the virtual serial port.

Implements BluetoothService.

Definition at line 72 of file SPP.cpp.

◆ operator bool()

SPP::operator bool ( )
inline

Used to provide Boolean tests for the class.

Returns
Return true if SPP communication is connected.

Definition at line 74 of file SPP.h.

◆ available()

int SPP::available ( void  )

Get number of bytes waiting to be read.

Returns
Return the number of bytes ready to be read.

Definition at line 797 of file SPP.cpp.

◆ flush()

void SPP::flush ( void  )
inline

Send out all bytes in the buffer.

Definition at line 88 of file SPP.h.

◆ peek()

int SPP::peek ( void  )

Used to read the next value in the buffer without advancing to the next one.

Returns
Return the byte. Will return -1 if no bytes are available.

Definition at line 805 of file SPP.cpp.

◆ read()

int SPP::read ( void  )

Used to read the buffer.

Returns
Return the byte. Will return -1 if no bytes are available.

Definition at line 811 of file SPP.cpp.

◆ write() [1/2]

size_t SPP::write ( uint8_t  data)

Writes the byte to send to a buffer. The message is send when either send() or after Usb.Task() is called.

Parameters
dataThe byte to write.
Returns
Return the number of bytes written.

Definition at line 742 of file SPP.cpp.

◆ write() [2/2]

size_t SPP::write ( const uint8_t *  data,
size_t  size 
)

Writes the bytes to send to a buffer. The message is send when either send() or after Usb.Task() is called.

Parameters
dataThe data array to send.
sizeSize of the data.
Returns
Return the number of bytes written.

Definition at line 754 of file SPP.cpp.

◆ discard()

void SPP::discard ( void  )

Discard all the bytes in the buffer.

Definition at line 801 of file SPP.cpp.

◆ send()

void SPP::send ( void  )

This will send all the bytes in the buffer. This is called whenever Usb.Task() is called, but can also be called via this function.

Definition at line 769 of file SPP.cpp.

◆ ACLData()

void SPP::ACLData ( uint8_t *  ACLData)
protectedvirtual

Used to pass acldata to the services.

Parameters
ACLDataIncoming acldata.

Implements BluetoothService.

Definition at line 84 of file SPP.cpp.

◆ Run()

void SPP::Run ( )
protectedvirtual

Used to establish the connection automatically.

Implements BluetoothService.

Definition at line 423 of file SPP.cpp.

◆ Reset()

void SPP::Reset ( )
protectedvirtual

Use this to reset the service.

Implements BluetoothService.

Definition at line 60 of file SPP.cpp.

◆ onInit()

void SPP::onInit ( )
protectedvirtual

Called when a device is successfully initialized. Use attachOnInit(void (*funcOnInit)(void)) to call your own function. This is useful for instance if you want to set the LEDs in a specific way.

Implements BluetoothService.

Definition at line 433 of file SPP.cpp.

Member Data Documentation

◆ connected

bool SPP::connected

Variable used to indicate if the connection is established.

Definition at line 78 of file SPP.h.


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