64 lines
1.6 KiB
Arduino
64 lines
1.6 KiB
Arduino
#include <NimBLEDevice.h>
|
|
|
|
static const char* TARGET_ADDRESS = "a5:c2:37:2c:05:dc";
|
|
|
|
void setup() {
|
|
Serial.begin(115200);
|
|
delay(1000);
|
|
|
|
Serial.println();
|
|
Serial.println("=== ESP32 BLE Service Discovery ===");
|
|
Serial.print("Target: ");
|
|
Serial.println(TARGET_ADDRESS);
|
|
|
|
NimBLEDevice::init("OverlandController");
|
|
NimBLEDevice::setPower(ESP_PWR_LVL_P9);
|
|
|
|
NimBLEAddress address(std::string(TARGET_ADDRESS), BLE_ADDR_PUBLIC);
|
|
NimBLEClient* client = NimBLEDevice::createClient();
|
|
|
|
Serial.println("Connecting...");
|
|
bool connected = client->connect(address);
|
|
|
|
if (!connected) {
|
|
Serial.println("Connect failed.");
|
|
return;
|
|
}
|
|
|
|
Serial.println("Connected.");
|
|
Serial.println("Discovering services...");
|
|
|
|
const std::vector<NimBLERemoteService*>& services = client->getServices(true);
|
|
|
|
Serial.print("Service count: ");
|
|
Serial.println(services.size());
|
|
|
|
for (NimBLERemoteService* service : services) {
|
|
Serial.print("Service UUID: ");
|
|
Serial.println(service->getUUID().toString().c_str());
|
|
|
|
const std::vector<NimBLERemoteCharacteristic*>& chars =
|
|
service->getCharacteristics(true);
|
|
|
|
for (NimBLERemoteCharacteristic* ch : chars) {
|
|
Serial.print(" Characteristic UUID: ");
|
|
Serial.print(ch->getUUID().toString().c_str());
|
|
|
|
Serial.print(" props:");
|
|
|
|
if (ch->canRead()) Serial.print(" READ");
|
|
if (ch->canWrite()) Serial.print(" WRITE");
|
|
if (ch->canWriteNoResponse()) Serial.print(" WRITE_NR");
|
|
if (ch->canNotify()) Serial.print(" NOTIFY");
|
|
|
|
Serial.println();
|
|
}
|
|
}
|
|
|
|
client->disconnect();
|
|
Serial.println("Done.");
|
|
}
|
|
|
|
void loop() {
|
|
}
|