Bluetooth scan (ignores all devices except QXS-001)
Connection (uses SPP (Serial Port Profile))
Data reception (everything sent by QXS-001 is displayed on the serial monitor)
My problem is that when I press the buttons, no data is displayed on the serial monitor.
#include <BluetoothSerial.h>
BluetoothSerial SerialBT;
#define TARGET_NAME "QXS-001"
#define BT_DISCOVER_TIME 10000
BTAddress targetAddress;
int targetChannel = -1;
bool deviceFound = false;
void setup() {
Serial.begin(115200);
if (!SerialBT.begin("ESP32_Client", true)) {
Serial.println("Bluetooth init failed");
abort();
}
Serial.println("Scanning for Bluetooth devices...");
BTScanResults *results = SerialBT.getScanResults();
SerialBT.discoverAsync([](BTAdvertisedDevice *device) {
Serial.printf(
"Found device: %s\n",
device->toString().c_str()
);
if (device->getName() == TARGET_NAME) {
Serial.println(">>> TARGET DEVICE FOUND!");
targetAddress = device->getAddress();
deviceFound = true;
}
});
delay(BT_DISCOVER_TIME);
SerialBT.discoverAsyncStop();
if (!deviceFound) {
Serial.println("Target device not found");
return;
}
Serial.println("Scanning for SPP channels...");
auto channels = SerialBT.getChannels(targetAddress);
if (channels.empty()) {
Serial.println("No SPP channel found");
return;
}
targetChannel = channels.begin()->first;
Serial.printf(
"Connecting to %s on channel %d...\n",
targetAddress.toString().c_str(),
targetChannel
);
if (!SerialBT.connect(
targetAddress,
targetChannel,
ESP_SPP_SEC_NONE,
ESP_SPP_ROLE_MASTER)) {
Serial.println("Connection failed");
return;
}
Serial.println("Connected successfully!");
}
void loop() {
if (SerialBT.connected()) {
while (SerialBT.available()) {
char c = SerialBT.read();
Serial.print(c);
}
} else {
Serial.println("Disconnected");
delay(1000);
}
}
Serial Monitor
Scanning for Bluetooth devices...
Found device: Name: QXS-001, Address: 10:fa:c2:67:0b:a9, cod: 0x002540, rssi: -59
>>> TARGET DEVICE FOUND!
Scanning for SPP channels...
Connecting to 10:fa:c2:67:0b:a9 on channel 1...
Connected successfully!
This is likely a BLE 5.x device, not using an SPP profile with classical Bluetooth. On your ESP32, you would need to use the BLE APIs to connect as a GATT client and subscribe to the appropriate characteristics to detect button presses and control events. BluetoothSerial and SPP will not capture these inputs.
Do you have a link to the doc of this product ? what I've seen (an amazon listing) is that it's a 5.3 BLE device. So you won't get anything through classic BT and an SPP profile.
it's more likely an BLE HID with Consumer Control reports
If you use Kai Morich's App Serial Bluetooth Terminal App on an Android phone does it see the device as Bluetooth Classic or Bluetooth LE? Can it connect to what it finds?
This app lets you inspect the exact BLE services and characteristics exposed by the device and monitor its response to button presses.
As @J-M-L suggested, I also believe this is a BLE HID (Human Interface Device), which means your ESP32 must act as a BLE HID host.
You should be able to see the HID Service with UUID 0x1812.
Classic Bluetooth inquiry and BLE advertising are handled at the controller level. It’s possible that some devices respond to inquiry indirectly or expose a generic or legacy Class of Device that makes them visible during Classic scans even though they do not implement any Classic services. Visibility does not imply protocol compatibility.
SerialBT.getChannels returning channel 1 and connect succeeding only means that an RFCOMM channel was accepted at the link layer. It does not guarantee that the remote implements an SPP data service behind that channel. Many HID remotes accept an RFCOMM connection but never send payload data on it.
The decisive test is data flow. If pressing buttons produces no bytes on SerialBT.available(), then SPP is effectively nonfunctional for input, even though the connection reports success.