Skip to content

Commit b516af5

Browse files
committed
Renamed SPP and SPPi library to SPPServer and SPPClient respectively
1 parent ee90afd commit b516af5

File tree

7 files changed

+41
-40
lines changed

7 files changed

+41
-40
lines changed

SPPi.cpp renamed to SPPClient.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020

2121

22-
#include "SPPi.h"
22+
#include "SPPClient.h"
2323
// To enable serial debugging see "settings.h"
2424
//#define EXTRADEBUG // Uncomment to get even more debugging data
2525
//#define PRINTREPORT // Uncomment to print the report sent to the Arduino
@@ -29,7 +29,7 @@
2929
*/
3030
const uint8_t rfcomm_uuid_sign[6] PROGMEM = { 0x35, 0x05, 0x19, 0x00, 0x03, 0x08 };
3131

32-
SPPi::SPPi(BTD *p, const char* name, const char* pin, bool pair, uint8_t *addr) :
32+
SPPClient::SPPClient(BTD *p, const char* name, const char* pin, bool pair, uint8_t *addr) :
3333
SPPBase(p)
3434
{
3535
if (pBtd)
@@ -54,7 +54,7 @@ SPPBase(p)
5454
Reset();
5555
}
5656

57-
void SPPi::Reset() {
57+
void SPPClient::Reset() {
5858
connected = false;
5959
RFCOMMConnected = false;
6060
SDPConnected = false;
@@ -66,7 +66,7 @@ void SPPi::Reset() {
6666
rfcomm_found = false;
6767
}
6868

69-
void SPPi::ACLData(uint8_t *l2capinbuf) {
69+
void SPPClient::ACLData(uint8_t *l2capinbuf) {
7070

7171
#ifdef EXTRADEBUG
7272
Notify(PSTR("\r\nIncoming Packet: "), 0x80);
@@ -546,7 +546,7 @@ void SPPi::ACLData(uint8_t *l2capinbuf) {
546546
}
547547
}
548548

549-
void SPPi::Run() {
549+
void SPPClient::Run() {
550550
if (pBtd->pairWithOtherDevice){
551551
if (l2cap_sdp_state == L2CAP_SDP_WAIT) {
552552
if (pBtd->connectToOtherDevice && !pBtd->l2capConnectionClaimed && !connected) {
@@ -567,11 +567,11 @@ void SPPi::Run() {
567567
/************************************************************/
568568
/* SDP Commands */
569569
/************************************************************/
570-
void SPPi::SDP_Command(uint8_t *data, uint8_t nbytes) { // See page 223 in the Bluetooth specs
570+
void SPPClient::SDP_Command(uint8_t *data, uint8_t nbytes) { // See page 223 in the Bluetooth specs
571571
pBtd->L2CAP_Command(hci_handle, data, nbytes, sdp_dcid[0], sdp_dcid[1]);
572572
}
573573

574-
void SPPi::SDP_Service_Search_Attr(uint8_t transactionIDHigh, uint8_t transactionIDLow, uint8_t remainingLen) {
574+
void SPPClient::SDP_Service_Search_Attr(uint8_t transactionIDHigh, uint8_t transactionIDLow, uint8_t remainingLen) {
575575
l2capoutbuf[0] = SDP_SERVICE_SEARCH_ATTRIBUTE_REQUEST_PDU;
576576
l2capoutbuf[1] = transactionIDHigh;
577577
l2capoutbuf[2] = transactionIDLow;
@@ -617,11 +617,11 @@ void SPPi::SDP_Service_Search_Attr(uint8_t transactionIDHigh, uint8_t transactio
617617
/************************************************************/
618618
/* RFCOMM Commands */
619619
/************************************************************/
620-
void SPPi::RFCOMM_Command(uint8_t* data, uint8_t nbytes) {
620+
void SPPClient::RFCOMM_Command(uint8_t* data, uint8_t nbytes) {
621621
pBtd->L2CAP_Command(hci_handle, data, nbytes, rfcomm_dcid[0], rfcomm_dcid[1]);
622622
}
623623

624-
void SPPi::parseAttrReply(uint8_t *l2capinbuf) {
624+
void SPPClient::parseAttrReply(uint8_t *l2capinbuf) {
625625
if ((l2capinbuf[2] + 4) < 15) return; // Sanity check
626626

627627
if (rfcomm_found) {

SPPi.h renamed to SPPClient.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
04.04.2014, Magictale Electronics
1919
*/
2020

21-
#ifndef _sppi_h_
22-
#define _sppi_h_
21+
#ifndef _sppclient_h_
22+
#define _sppclient_h_
2323

2424
#include "SPPBase.h"
2525

@@ -45,20 +45,20 @@
4545
* This BluetoothService class a Serial Port Protocol (SPP) client.
4646
* It inherits the Arduino Stream class. This allows it to use all the standard Arduino print functions.
4747
*/
48-
class SPPi : public SPPBase {
48+
class SPPClient : public SPPBase {
4949
public:
5050
/**
51-
* Constructor for the SPPi class.
51+
* Constructor for the SPPClient class.
5252
* @param p Pointer to BTD class instance.
5353
* @param name Set the name to BTD#btdName. If argument is omitted, then "Arduino" will be used.
5454
* @param pin Write the pin to BTD#btdPin. If argument is omitted, then "0000" will be used.
5555
* @param pair Set this to true if you want to pair with a device.
5656
* @param addr Set this to the address you want to connect to.
5757
*/
58-
SPPi(BTD *p, const char *name = "Arduino", const char *pin = "0000", bool pair = false, uint8_t *addr = NULL);
58+
SPPClient(BTD *p, const char *name = "Arduino", const char *pin = "0000", bool pair = false, uint8_t *addr = NULL);
5959

6060
#if GCC_VERSION > 40700 // Test for GCC > 4.7.0
61-
SPPi(BTD *p, bool pair = false, uint8_t *addr = NULL) : SPPi(p, "Arduino", "0000", pair, addr) {}; // Use a delegating constructor
61+
SPPClient(BTD *p, bool pair = false, uint8_t *addr = NULL) : SPPClient(p, "Arduino", "0000", pair, addr) {}; // Use a delegating constructor
6262
#endif
6363

6464
/** @name SPPBase implementation */

SPP.cpp renamed to SPPServer.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
1616
*/
1717

18-
#include "SPP.h"
18+
#include "SPPServer.h"
1919
// To enable serial debugging see "settings.h"
2020
//#define EXTRADEBUG // Uncomment to get even more debugging data
2121
//#define PRINTREPORT // Uncomment to print the report sent to the Arduino
2222

23-
SPP::SPP(BTD *p, const char *name, const char *pin, bool pair, uint8_t *addr) :
23+
SPPServer::SPPServer(BTD *p, const char *name, const char *pin, bool pair, uint8_t *addr) :
2424
SPPBase(p)
2525
{
2626
if(pBtd)
@@ -45,7 +45,7 @@ SPPBase(p)
4545
Reset();
4646
}
4747

48-
void SPP::Reset() {
48+
void SPPServer::Reset() {
4949
connected = false;
5050
RFCOMMConnected = false;
5151
SDPConnected = false;
@@ -56,7 +56,7 @@ void SPP::Reset() {
5656
sppIndex = 0;
5757
}
5858

59-
void SPP::ACLData(uint8_t *l2capinbuf) {
59+
void SPPServer::ACLData(uint8_t *l2capinbuf) {
6060
if(!connected) {
6161
if(l2capinbuf[8] == L2CAP_CMD_CONNECTION_REQUEST) {
6262
if((l2capinbuf[12] | (l2capinbuf[13] << 8)) == SDP_PSM && !pBtd->sdpConnectionClaimed) {
@@ -398,7 +398,7 @@ void SPP::ACLData(uint8_t *l2capinbuf) {
398398
}
399399
}
400400

401-
void SPP::Run() {
401+
void SPPServer::Run() {
402402
if(waitForLastCommand && (millis() - timer) > 100) { // We will only wait 100ms and see if the UIH Remote Port Negotiation Command is send, as some deviced don't send it
403403
#ifdef DEBUG_USB_HOST
404404
Notify(PSTR("\r\nRFCOMM Connection is now established - Automatic\r\n"), 0x80);
@@ -411,7 +411,7 @@ void SPP::Run() {
411411
send(); // Send all bytes currently in the buffer
412412
}
413413

414-
void SPP::SDP_task() {
414+
void SPPServer::SDP_task() {
415415
switch(l2cap_sdp_state) {
416416
case L2CAP_SDP_WAIT:
417417
if(l2cap_check_flag(L2CAP_FLAG_CONNECTION_SDP_REQUEST)) {
@@ -460,7 +460,7 @@ void SPP::SDP_task() {
460460
}
461461
}
462462

463-
void SPP::RFCOMM_task() {
463+
void SPPServer::RFCOMM_task() {
464464
switch(l2cap_rfcomm_state) {
465465
case L2CAP_RFCOMM_WAIT:
466466
if(l2cap_check_flag(L2CAP_FLAG_CONNECTION_RFCOMM_REQUEST)) {
@@ -502,11 +502,11 @@ void SPP::RFCOMM_task() {
502502
/************************************************************/
503503
/* SDP Commands */
504504
/************************************************************/
505-
void SPP::SDP_Command(uint8_t *data, uint8_t nbytes) { // See page 223 in the Bluetooth specs
505+
void SPPServer::SDP_Command(uint8_t *data, uint8_t nbytes) { // See page 223 in the Bluetooth specs
506506
pBtd->L2CAP_Command(hci_handle, data, nbytes, sdp_scid[0], sdp_scid[1]);
507507
}
508508

509-
void SPP::serviceNotSupported(uint8_t transactionIDHigh, uint8_t transactionIDLow) { // See page 235 in the Bluetooth specs
509+
void SPPServer::serviceNotSupported(uint8_t transactionIDHigh, uint8_t transactionIDLow) { // See page 235 in the Bluetooth specs
510510
l2capoutbuf[0] = SDP_SERVICE_SEARCH_ATTRIBUTE_RESPONSE_PDU;
511511
l2capoutbuf[1] = transactionIDHigh;
512512
l2capoutbuf[2] = transactionIDLow;
@@ -523,7 +523,7 @@ void SPP::serviceNotSupported(uint8_t transactionIDHigh, uint8_t transactionIDLo
523523
SDP_Command(l2capoutbuf, 10);
524524
}
525525

526-
void SPP::serialPortResponse1(uint8_t transactionIDHigh, uint8_t transactionIDLow) {
526+
void SPPServer::serialPortResponse1(uint8_t transactionIDHigh, uint8_t transactionIDLow) {
527527
l2capoutbuf[0] = SDP_SERVICE_SEARCH_ATTRIBUTE_RESPONSE_PDU;
528528
l2capoutbuf[1] = transactionIDHigh;
529529
l2capoutbuf[2] = transactionIDLow;
@@ -581,7 +581,7 @@ void SPP::serialPortResponse1(uint8_t transactionIDHigh, uint8_t transactionIDLo
581581
SDP_Command(l2capoutbuf, 48);
582582
}
583583

584-
void SPP::serialPortResponse2(uint8_t transactionIDHigh, uint8_t transactionIDLow) {
584+
void SPPServer::serialPortResponse2(uint8_t transactionIDHigh, uint8_t transactionIDLow) {
585585
l2capoutbuf[0] = SDP_SERVICE_SEARCH_ATTRIBUTE_RESPONSE_PDU;
586586
l2capoutbuf[1] = transactionIDHigh;
587587
l2capoutbuf[2] = transactionIDLow;
@@ -623,16 +623,16 @@ void SPP::serialPortResponse2(uint8_t transactionIDHigh, uint8_t transactionIDLo
623623
SDP_Command(l2capoutbuf, 33);
624624
}
625625

626-
void SPP::l2capResponse1(uint8_t transactionIDHigh, uint8_t transactionIDLow) {
626+
void SPPServer::l2capResponse1(uint8_t transactionIDHigh, uint8_t transactionIDLow) {
627627
serialPortResponse1(transactionIDHigh, transactionIDLow); // These has to send all the supported functions, since it only supports virtual serialport it just sends the message again
628628
}
629629

630-
void SPP::l2capResponse2(uint8_t transactionIDHigh, uint8_t transactionIDLow) {
630+
void SPPServer::l2capResponse2(uint8_t transactionIDHigh, uint8_t transactionIDLow) {
631631
serialPortResponse2(transactionIDHigh, transactionIDLow); // Same data as serialPortResponse2
632632
}
633633
/************************************************************/
634634
/* RFCOMM Commands */
635635
/************************************************************/
636-
void SPP::RFCOMM_Command(uint8_t* data, uint8_t nbytes) {
636+
void SPPServer::RFCOMM_Command(uint8_t* data, uint8_t nbytes) {
637637
pBtd->L2CAP_Command(hci_handle, data, nbytes, rfcomm_scid[0], rfcomm_scid[1]);
638638
}

SPP.h renamed to SPPServer.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,26 @@
1515
1616
*/
1717

18-
#ifndef _spp_h_
19-
#define _spp_h_
18+
#ifndef _sppserver_h_
19+
#define _sppserver_h_
2020

2121
#include "SPPBase.h"
2222

2323
/**
2424
* This BluetoothService class a Serial Port Protocol (SPP) server.
2525
* It inherits the Arduino Stream class. This allows it to use all the standard Arduino print functions.
2626
*/
27-
class SPP : public SPPBase {
27+
class SPPServer : public SPPBase {
2828
public:
2929
/**
30-
* Constructor for the SPP class.
30+
* Constructor for the SPPServer class.
3131
* @param p Pointer to BTD class instance.
3232
* @param name Set the name to BTD#btdName. If argument is omitted, then "Arduino" will be used.
3333
* @param pin Write the pin to BTD#btdPin. If argument is omitted, then "0000" will be used.
3434
* @param pair Set this to true if you want to pair with a device.
3535
* @param addr Set this to the address you want to connect to.
3636
*/
37-
SPP(BTD *p, const char *name = "Arduino", const char *pin = "0000", bool pair = false, uint8_t *addr = NULL);
37+
SPPServer(BTD *p, const char *name = "Arduino", const char *pin = "0000", bool pair = false, uint8_t *addr = NULL);
3838

3939
/** @name SPPBase implementation */
4040
/**

examples/Bluetooth/SPP/SPPClient/SPPClient.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
send me an e-mail: [email protected]
55
*/
66

7-
#include <SPPi.h>
7+
#include <SPPClient.h>
88
#include <usbhub.h>
99
// Satisfy IDE, which only needs to see the include statment in the ino.
1010
#ifdef dobogusinclude
@@ -17,7 +17,7 @@ USB Usb;
1717
BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
1818

1919
uint8_t addr[6] = { 0x71, 0xB4, 0xB0, 0xC8, 0xBC, 0xC8 }; // Set this to the Bluetooth address you want to connect to
20-
SPPi SerialBT(&Btd, true, addr);
20+
SPPClient SerialBT(&Btd, "Arduino", "0000", true, addr);
2121

2222
boolean firstMessage = true;
2323

examples/Bluetooth/SPP/SPPServer/SPPServer.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
send me an e-mail: [email protected]
55
*/
66

7-
#include <SPP.h>
7+
#include <SPPServer.h>
88
#include <usbhub.h>
99
// Satisfy IDE, which only needs to see the include statment in the ino.
1010
#ifdef dobogusinclude
@@ -17,8 +17,8 @@ USB Usb;
1717
BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
1818

1919
/* You can create the instance of the class in two ways */
20-
SPP SerialBT(&Btd); // This will set the name to the defaults: "Arduino" and the pin to "0000"
21-
//SPP SerialBT(&Btd, "Lauszus's Arduino", "1234"); // You can also set the name and pin like so
20+
SPPServer SerialBT(&Btd); // This will set the name to the defaults: "Arduino" and the pin to "0000"
21+
//SPPServer SerialBT(&Btd, "Lauszus's Arduino", "1234"); // You can also set the name and pin like so
2222

2323
boolean firstMessage = true;
2424

keywords.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ Y LITERAL1
236236
# Datatypes (KEYWORD1)
237237
####################################################
238238

239-
SPP KEYWORD1
239+
SPPServer KEYWORD1
240+
SPPClient KEYWORD1
240241

241242
####################################################
242243
# Methods and Functions (KEYWORD2)

0 commit comments

Comments
 (0)