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 printFlashString (const __FlashStringHelper *ifsh, bool newline)
 
void println (void)
 
void printNumber (uint8_t n)
 
void printNumberln (uint8_t n)
 
void printNumber (int8_t n)
 
void printNumberln (int8_t n)
 
void printNumber (uint16_t n)
 
void printNumberln (uint16_t n)
 
void printNumber (int16_t n)
 
void printNumberln (int16_t n)
 
void printNumber (uint32_t n)
 
void printNumberln (uint32_t n)
 
void printNumber (int32_t n)
 
void printNumberln (int32_t n)
 
void intToString (int32_t input, char *output)
 
void intToString (uint32_t input, char *output)
 
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 84 of file SPP.cpp.

void SPP::Run ( )
virtual

Used to establish the connection automatically.

Reimplemented from BluetoothService.

Definition at line 401 of file SPP.cpp.

void SPP::Reset ( )
virtual

Use this to reset the service.

Reimplemented from BluetoothService.

Definition at line 63 of file SPP.cpp.

void SPP::disconnect ( )
virtual

Used this to disconnect the virtual serial port.

Reimplemented from BluetoothService.

Definition at line 72 of file SPP.cpp.

void SPP::print ( const String &  str)

Used to send Arduino String data type.

Parameters
strString to send.

Definition at line 721 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 774 of file SPP.cpp.

void SPP::print ( const char *  str)

Used to send standard strings.

Parameters
strString to send.

Definition at line 739 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 779 of file SPP.cpp.

void SPP::print ( uint8_t  data)
inline

Used to send single bytes.

Parameters
dataData to send.

Definition at line 147 of file SPP.h.

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 786 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 757 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 791 of file SPP.cpp.

void SPP::print ( const __FlashStringHelper *  ifsh)
inline

Used to print strings stored in flash. Use "SerialBT.print(F("String"));" to print a string stored in flash.

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

Definition at line 174 of file SPP.h.

void SPP::println ( const __FlashStringHelper *  ifsh)
inline

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 182 of file SPP.h.

void SPP::printFlashString ( const __FlashStringHelper *  ifsh,
bool  newline 
)

Helper function to print a string stored in flash.

Parameters
ifshString stored in flash you want to print.
newlineSet this to true to include newline and carriage return.

Definition at line 799 of file SPP.cpp.

void SPP::println ( void  )

Use this to print newline and carriage return.

Definition at line 821 of file SPP.cpp.

void SPP::printNumber ( uint8_t  n)
inline

Used to print unsigned integers.

Parameters
nUnsigned integer to send.

Definition at line 200 of file SPP.h.

void SPP::printNumberln ( uint8_t  n)
inline

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

Parameters
nUnsigned integer to send.

Definition at line 208 of file SPP.h.

void SPP::printNumber ( int8_t  n)
inline

Used to print signed integers.

Parameters
nSigned integer to send.

Definition at line 216 of file SPP.h.

void SPP::printNumberln ( int8_t  n)
inline

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

Parameters
nSigned integer to send.

Definition at line 224 of file SPP.h.

void SPP::printNumber ( uint16_t  n)
inline

Used to print unsigned integers.

Parameters
nUnsigned integer to send.

Definition at line 232 of file SPP.h.

void SPP::printNumberln ( uint16_t  n)
inline

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

Parameters
nUnsigned integer to send.

Definition at line 240 of file SPP.h.

void SPP::printNumber ( int16_t  n)
inline

Used to print signed integers.

Parameters
nSigned integer to send.

Definition at line 248 of file SPP.h.

void SPP::printNumberln ( int16_t  n)
inline

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

Parameters
nSigned integer to send.

Definition at line 256 of file SPP.h.

void SPP::printNumber ( uint32_t  n)

Used to print unsigned integers.

Parameters
nUnsigned integer to send.

Definition at line 827 of file SPP.cpp.

void SPP::printNumberln ( uint32_t  n)

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

Parameters
nUnsigned integer to send.

Definition at line 833 of file SPP.cpp.

void SPP::printNumber ( int32_t  n)

Used to print signed integers.

Parameters
nSigned integer to send.

Definition at line 840 of file SPP.cpp.

void SPP::printNumberln ( int32_t  n)

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

Parameters
nSigned integer to send.

Definition at line 846 of file SPP.cpp.

void SPP::intToString ( int32_t  input,
char *  output 
)

Helper function to convert from an unsigned integer to a string.

Parameters
inputUnsigned integer to convert.
outputOutput buffer.

Definition at line 853 of file SPP.cpp.

void SPP::intToString ( uint32_t  input,
char *  output 
)

Helper function to convert from a signed integer to a string.

Parameters
inputSigned integer to convert.
outputOutput buffer.

Definition at line 863 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 881 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 887 of file SPP.cpp.

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

Helper function to convert from a double to a 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 894 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 319 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 923 of file SPP.cpp.

void SPP::flush ( )
inline

Discard all the bytes in the buffer.

Definition at line 329 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: