mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-07-03 13:56:32 +02:00
[2.0.0] BtClassic Discovery with info without connect (#4811)
Hey guys, so I wanted to do a BtClassic Discovery without the need to call connect and to list all found devices on a display and continue work with that list. I wasn't capable to test the example code with my file structure, but I did use the discovery already in some different situations. However when I noted that the Bluedroid stack won't let me enforce an RfComm SPP connection to a GPS Device (Skytraxx 2 plus, I guess its interface is built so simple that it doesn't advertise its SPP over SDP), I will probably have to switch to BtStack (BlueKitchen) and stop on this side meanwhile
This commit is contained in:
78
libraries/BluetoothSerial/src/BTAdvertisedDeviceSet.cpp
Normal file
78
libraries/BluetoothSerial/src/BTAdvertisedDeviceSet.cpp
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* BTAdvertisedDeviceSet.cpp
|
||||
*
|
||||
* Created on: Feb 5, 2021
|
||||
* Author: Thomas M. (ArcticSnowSky)
|
||||
*/
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#if defined(CONFIG_BT_ENABLED)
|
||||
|
||||
//#include <map>
|
||||
|
||||
#include "BTAdvertisedDevice.h"
|
||||
//#include "BTScan.h"
|
||||
|
||||
|
||||
BTAdvertisedDeviceSet::BTAdvertisedDeviceSet() {
|
||||
m_cod = 0;
|
||||
m_name = "";
|
||||
m_rssi = 0;
|
||||
|
||||
m_haveCOD = false;
|
||||
m_haveName = false;
|
||||
m_haveRSSI = false;
|
||||
} // BTAdvertisedDeviceSet
|
||||
|
||||
BTAddress BTAdvertisedDeviceSet::getAddress() { return m_address; }
|
||||
uint32_t BTAdvertisedDeviceSet::getCOD() { return m_cod; }
|
||||
std::string BTAdvertisedDeviceSet::getName() { return m_name; }
|
||||
int8_t BTAdvertisedDeviceSet::getRSSI() { return m_rssi; }
|
||||
|
||||
|
||||
bool BTAdvertisedDeviceSet::haveCOD() { return m_haveCOD; }
|
||||
bool BTAdvertisedDeviceSet::haveName() { return m_haveName; }
|
||||
bool BTAdvertisedDeviceSet::haveRSSI() { return m_haveRSSI; }
|
||||
|
||||
/**
|
||||
* @brief Create a string representation of this device.
|
||||
* @return A string representation of this device.
|
||||
*/
|
||||
std::string BTAdvertisedDeviceSet::toString() {
|
||||
std::string res = "Name: " + getName() + ", Address: " + getAddress().toString();
|
||||
if (haveCOD()) {
|
||||
char val[6];
|
||||
snprintf(val, sizeof(val), "%d", getCOD());
|
||||
res += ", cod: ";
|
||||
res += val;
|
||||
}
|
||||
if (haveRSSI()) {
|
||||
char val[4];
|
||||
snprintf(val, sizeof(val), "%d", getRSSI());
|
||||
res += ", rssi: ";
|
||||
res += val;
|
||||
}
|
||||
return res;
|
||||
} // toString
|
||||
|
||||
|
||||
void BTAdvertisedDeviceSet::setAddress(BTAddress address) {
|
||||
m_address = address;
|
||||
}
|
||||
|
||||
void BTAdvertisedDeviceSet::setCOD(uint32_t cod) {
|
||||
m_cod = cod;
|
||||
m_haveCOD = true;
|
||||
}
|
||||
|
||||
void BTAdvertisedDeviceSet::setName(std::string name) {
|
||||
m_name = name;
|
||||
m_haveName = true;
|
||||
}
|
||||
|
||||
void BTAdvertisedDeviceSet::setRSSI(int8_t rssi) {
|
||||
m_rssi = rssi;
|
||||
m_haveRSSI = true;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BT_ENABLED */
|
Reference in New Issue
Block a user