Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: UsbHostMAX3421E_Hello
SPP Class Reference
This BluetoothService class implements the Serial Port Protocol (SPP). More...
#include <SPP.h>
Inherits BluetoothService.
Public Member Functions | |
SPP (BTD *p, const char *name="Arduino", const char *pin="0000") | |
Constructor for the SPP class. | |
operator bool () | |
Used to provide Boolean tests for the class. | |
void | attachOnInit (void(*funcOnInit)(void)) |
Used to call your own function when the device is successfully initialized. | |
Serial port profile (SPP) Print functions | |
int | available (void) |
Get number of bytes waiting to be read. | |
void | flush (void) |
Send out all bytes in the buffer. | |
int | peek (void) |
Used to read the next value in the buffer without advancing to the next one. | |
int | read (void) |
Used to read the buffer. | |
size_t | write (uint8_t data) |
Writes the byte to send to a buffer. | |
size_t | write (const uint8_t *data, size_t size) |
Writes the bytes to send to a buffer. | |
void | write (uint8_t data) |
Writes the byte to send to a buffer. | |
void | write (const uint8_t *data, size_t size) |
Writes the bytes to send to a buffer. | |
void | discard (void) |
Discard all the bytes in the buffer. | |
void | send (void) |
This will send all the bytes in the buffer. | |
Data Fields | |
bool | connected |
Variable used to indicate if the connection is established. | |
Protected Member Functions | |
bool | checkHciHandle (uint8_t *buf, uint16_t handle) |
Used to check if the incoming L2CAP data matches the HCI Handle. | |
Protected Attributes | |
void(* | pFuncOnInit )(void) |
Pointer to function called in onInit(). | |
BTD * | pBtd |
Pointer to BTD instance. | |
uint16_t | hci_handle |
The HCI Handle for the connection. | |
uint32_t | l2cap_event_flag |
L2CAP flags of received Bluetooth events. | |
uint8_t | identifier |
Identifier for L2CAP commands. | |
BluetoothService implementation | |
void | disconnect () |
Used this to disconnect the virtual serial port. | |
void | ACLData (uint8_t *ACLData) |
Used to pass acldata to the services. | |
void | Run () |
Used to establish the connection automatically. | |
void | Reset () |
Use this to reset the service. | |
void | onInit () |
Called when a device is successfully initialized. |
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 62 of file SPP.h.
Constructor & Destructor Documentation
Constructor for the SPP class.
- Parameters:
-
p Pointer to BTD class instance. name Set the name to BTD::btdName. If argument is omitted, then "Arduino" will be used. pin Write the pin to BTD::btdPin. If argument is omitted, then "0000" will be used.
Member Function Documentation
void ACLData | ( | uint8_t * | ACLData ) | [protected, virtual] |
Used to pass acldata to the services.
- Parameters:
-
ACLData Incoming acldata.
Implements BluetoothService.
void attachOnInit | ( | void(*)(void) | funcOnInit ) | [inherited] |
int available | ( | void | ) |
Get number of bytes waiting to be read.
- Returns:
- Return the number of bytes ready to be read.
bool checkHciHandle | ( | uint8_t * | buf, |
uint16_t | handle | ||
) | [protected, inherited] |
void discard | ( | void | ) |
Discard all the bytes in the buffer.
void disconnect | ( | ) | [virtual] |
Used this to disconnect the virtual serial port.
Implements BluetoothService.
void onInit | ( | ) | [protected, virtual] |
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.
operator bool | ( | ) |
int 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.
int read | ( | void | ) |
Used to read the buffer.
- Returns:
- Return the byte. Will return -1 if no bytes are available.
void Reset | ( | ) | [protected, virtual] |
void Run | ( | ) | [protected, virtual] |
Used to establish the connection automatically.
Implements BluetoothService.
void 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.
void 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:
-
data The data array to send. size Size of the data.
void write | ( | uint8_t | data ) |
size_t write | ( | const uint8_t * | data, |
size_t | size | ||
) |
void 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:
-
data The byte to write.
Field Documentation
bool connected |
uint16_t hci_handle [protected, inherited] |
uint8_t identifier [protected, inherited] |
uint32_t l2cap_event_flag [protected, inherited] |
void(* pFuncOnInit)(void) [protected, inherited] |
Generated on Tue Jul 12 2022 18:12:05 by
