1

Code using BluetoothSerial api disconnects immediately after establishing connection with my laptop running Ubuntu 18.04. If instead of BluetoothSerial BLEDevice api is used, the connection stays connected. See minimal examples below. Another peculiar observation is that connection with my Android phone is stable when running BluetoothSerial example below.

How to make BT connect properly with both the phone and laptop? The chip running the code is esp32-wroom-32d.

Minimal code with BT disconnecting from laptop Ubuntu 18.04 after roughly a second (from SerialToSerialBT example):

#include "BluetoothSerial.h"

BluetoothSerial SerialBT;

void setup() {
  SerialBT.begin("ESP32 SerialBT");
}

void loop() {
} 

Minimal code with stable BT connection (from BLE_notify example):

#include <BLEDevice.h>
#include <BLEServer.h>

BLEServer* pServer = NULL;

void setup() {
  BLEDevice::init("ESP32");

  pServer = BLEDevice::createServer();
  pServer->setCallbacks(new BLEServerCallbacks());

  BLEDevice::startAdvertising();
}

void loop() {   
}

UPDATE:

  • Updating Ubuntu to 20.04 did not help.

1 Answer 1

1

I know this is old but I had the same issue using bluetoothserial.h. But by using rfcomm

rfcomm bind 0 <bluetooth MAC ADDRESS>

and then my example command sent to serialBT

echo -ne ">LOOOCR" > /dev/rfcomm0

/dev/rfcomm0 being the device created with the bind. It even still shows as disconnected in the Ubunutu 20.04 bluetooth GUI. For what it's worth I think it is the same on all devices. Until you connect to the BT serial port it is only Paired. But someone with greater knowledge than myself can explain.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.