USB Host Shield 2.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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="1234")
 
BluetoothService implementation
virtual void ACLData (uint8_t *ACLData)
 
virtual void Run ()
 
virtual void Reset ()
 
virtual void disconnect ()
 
Serial port profile (SPP) Print functions
void print (const String &str)
 
void println (const String &str)
 
void print (const char *str)
 
void println (const char *str)
 
void print (uint8_t data)
 
void println (uint8_t data)
 
void print (uint8_t *array, uint8_t length)
 
void println (uint8_t *array, uint8_t length)
 
void print (const __FlashStringHelper *ifsh)
 
void println (const __FlashStringHelper *ifsh)
 
void println (void)
 
void printNumber (int32_t n)
 
void printNumberln (int32_t n)
 
void printNumber (double n, uint8_t digits=2)
 
void printNumberln (double n, uint8_t digits=2)
 
void doubleToString (double input, char *output, uint8_t digits=2)
 
uint8_t available ()
 
uint8_t read ()
 
void flush ()
 

Public Attributes

bool connected
 

Detailed Description

This BluetoothService class implements the Serial Port Protocol (SPP).

Definition at line 93 of file SPP.h.

Constructor & Destructor Documentation

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

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 "1234" will be used.

Definition at line 45 of file SPP.cpp.

Member Function Documentation

void SPP::ACLData ( uint8_t *  ACLData)
virtual

Used to pass acldata to the services.

Parameters
ACLDataIncoming acldata.

Reimplemented from BluetoothService.

Definition at line 81 of file SPP.cpp.

void SPP::Run ( )
virtual

Used to establish the connection automatically.

Reimplemented from BluetoothService.

Definition at line 370 of file SPP.cpp.

void SPP::Reset ( )
virtual

Use this to reset the service.

Reimplemented from BluetoothService.

Definition at line 62 of file SPP.cpp.

void SPP::disconnect ( )
virtual

Used this to disconnect the virtual serial port.

Reimplemented from BluetoothService.

Definition at line 70 of file SPP.cpp.

void SPP::print ( const String &  str)

Used to send Arduino String data type.

Parameters
strString to send.

Definition at line 687 of file SPP.cpp.

void SPP::println ( const String &  str)

Same as print(const String &str), but will include newline and carriage return.

Parameters
strString to send.

Definition at line 753 of file SPP.cpp.

void SPP::print ( const char *  str)

Used to send standard strings.

Parameters
strString to send.

Definition at line 703 of file SPP.cpp.

void SPP::println ( const char *  str)

Same as print(const char* str), but will include newline and carriage return.

Parameters
strString to send.

Definition at line 757 of file SPP.cpp.

void SPP::print ( uint8_t  data)

Used to send single bytes.

Parameters
dataData to send.

Definition at line 719 of file SPP.cpp.

void SPP::println ( uint8_t  data)

Same as print(uint8_t data), but will include newline and carriage return.

Parameters
dataData to send.

Definition at line 763 of file SPP.cpp.

void SPP::print ( uint8_t *  array,
uint8_t  length 
)

Used to send arrays.

Parameters
arrayArray to send.
lengthNumber of bytes to send.

Definition at line 722 of file SPP.cpp.

void SPP::println ( uint8_t *  array,
uint8_t  length 
)

Same as print(uint8_t* array, uint8_t length), but will include newline and carriage return.

Parameters
arrayArray to send.
lengthNumber of bytes to send.

Definition at line 767 of file SPP.cpp.

void SPP::print ( const __FlashStringHelper *  ifsh)

Used to print strings stored in flash.

Parameters
ifshString to send - see: http://playground.arduino.cc/Learning/Memory.

Definition at line 737 of file SPP.cpp.

void SPP::println ( const __FlashStringHelper *  ifsh)

Same as print(const __FlashStringHelper *ifsh), but will include newline and carriage return.

Parameters
ifshString to send - see: http://playground.arduino.cc/Learning/Memory.

Definition at line 774 of file SPP.cpp.

void SPP::println ( void  )

Use this to print newline and carriage return.

Definition at line 792 of file SPP.cpp.

void SPP::printNumber ( int32_t  n)

Used to print signed integers.

Parameters
nIntegers to send.

Definition at line 798 of file SPP.cpp.

void SPP::printNumberln ( int32_t  n)

Same as printNumber(int32_t n), but will include newline and carriage return.

Parameters
nIntegers to send.

Definition at line 828 of file SPP.cpp.

void SPP::printNumber ( double  n,
uint8_t  digits = 2 
)

Used to print floating-point numbers.

Parameters
nFloating-point number to print.
digitsNumber of digits to send. If argument is omitted, then 2 digits will be used.

Definition at line 863 of file SPP.cpp.

void SPP::printNumberln ( double  n,
uint8_t  digits = 2 
)

Same as printNumber(double n, uint8_t digits), but will include newline and carriage return.

Parameters
nFloating-point number to print.
digitsNumber of digits to send. If argument is omitted, then 2 digits will be used.

Definition at line 868 of file SPP.cpp.

void SPP::doubleToString ( double  input,
char *  output,
uint8_t  digits = 2 
)

Helper function to convert from double to string.

Parameters
inputFloating-point number to convert.
outputOutput buffer.
digitsNumber of digits to convert. If argument is omitted, then 2 digits will be used.

Definition at line 876 of file SPP.cpp.

uint8_t SPP::available ( )
inline

Get number of bytes waiting to be read.

Returns
Return the number of bytes ready to be read.

Definition at line 211 of file SPP.h.

uint8_t SPP::read ( )

Used to read the buffer.

Returns
Return the byte. Will return 0 if no byte is available.

Definition at line 906 of file SPP.cpp.

void SPP::flush ( )
inline

Discard all the bytes in the buffer.

Definition at line 218 of file SPP.h.

Member Data Documentation

bool SPP::connected

Variable used to indicate if the connection is established.

Definition at line 118 of file SPP.h.


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