[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:
Thomas M
2021-04-16 00:37:33 +02:00
committed by GitHub
parent 223acb3511
commit 41c372c143
12 changed files with 609 additions and 6 deletions

13
libraries/BluetoothSerial/src/BluetoothSerial.h Executable file → Normal file
View File

@ -21,12 +21,15 @@
#include "Arduino.h"
#include "Stream.h"
#include <esp_gap_bt_api.h>
#include <esp_spp_api.h>
#include <functional>
#include "BTScan.h"
typedef std::function<void(const uint8_t *buffer, size_t size)> BluetoothSerialDataCb;
typedef std::function<void(uint32_t num_val)> ConfirmRequestCb;
typedef std::function<void(boolean success)> AuthCompleteCb;
typedef std::function<void(BTAdvertisedDevice* pAdvertisedDevice)> BTAdvertisedDeviceCb;
class BluetoothSerial: public Stream
{
@ -63,6 +66,16 @@ class BluetoothSerial: public Stream
bool isReady(bool checkMaster=false, int timeout=0);
bool disconnect();
bool unpairDevice(uint8_t remoteAddress[]);
BTScanResults* discover(int timeout=0x30*1280);
bool discoverAsync(BTAdvertisedDeviceCb cb, int timeout=0x30*1280);
void discoverAsyncStop();
void discoverClear();
BTScanResults* getScanResults();
const int INQ_TIME = 1280; // Inquire Time unit 1280 ms
const int MIN_INQ_TIME = (ESP_BT_GAP_MIN_INQ_LEN * INQ_TIME);
const int MAX_INQ_TIME = (ESP_BT_GAP_MAX_INQ_LEN * INQ_TIME);
operator bool() const;
private: