ESP32 C3 (Super Mini) whit Samsung Galaxy S23+ and later
My code works well on several Samsung Android devices, but it doesn't work on the Galaxy S23 and later.
What parameters and settings should I add to make it work on the Galaxy S23 and later?
I'm using:
pServer->updateConnParams(connInfo.getConnHandle(), 24, 48, 0, 180)
I would just remove that line completely and see if it works.
Thanks for the reply h2zero. I tested without this line, and it still doesn't work.
I can't solve this problem. The ESP can't be seen on Galaxy S23 and later smartphones, but it works perfectly on earlier versions. The sample codes provided with the library also don't work on these devices. Could it be something related to MTU? Where am I going wrong? What do you recommend?
My code:
#include <NimBLEDevice.h>
NimBLECharacteristic* pCharacteristic = nullptr;
bool deviceConnected = false;
uint8_t connectedDevices = 0;
#define MAX_CONNECTIONS 2
#define SERVICE_UUID "0000FFE0-0000-1000-8000-00805F9B34FB" // (0000181a-0000-1000-8000-00805f9b34fb 6e400001-b5a3-f393-e0a9-e50e24dcca9e 0000FFE0-0000-1000-8000-00805F9B34FB 00001800-0000-1000-8000-00805F9B34FB
#define CHARACTERISTIC_UUID "0000FFE1-0000-1000-8000-00805F9B34FB" // (00002a6d-0000-1000-8000-00805f9b34fb 6e400003-b5a3-f393-e0a9-e50e24dcca9e 0000FFE1-0000-1000-8000-00805F9B34FB 00002902-0000-1000-8000-00805f9b34fb
class ServerCallbacks : public NimBLEServerCallbacks {
void onConnect(NimBLEServer* pServer, NimBLEConnInfo& connInfo) override {
connectedDevices++;
//Serial.printf("Device connected, total: %d\n", connectedDevices);
if (connectedDevices >= MAX_CONNECTIONS) {
NimBLEDevice::stopAdvertising();
//Serial.println("Max connections reached, advertising stopped");
}
else {
NimBLEDevice::startAdvertising();
}
pServer->updateConnParams(connInfo.getConnHandle(), 24, 48, 0, 180);
deviceConnected = true;
};
void onDisconnect(NimBLEServer* pServer, NimBLEConnInfo& connInfo, int reason) override {
connectedDevices--;
//Serial.printf("Device connected, total: %d\n", connectedDevices);
if (connectedDevices < MAX_CONNECTIONS) {
NimBLEDevice::startAdvertising();
//Serial.println("Advertising restarted");
}
}
} serverCallbacks;
void onAdvComplete(NimBLEAdvertising* pAdvertising) {
if (deviceConnected) {
return;
}
pAdvertising->setScanFilter(false, false);
pAdvertising->start();
}
void setup() {
NimBLEDevice::init("ESP SERVER");
NimBLEServer* pServer = NimBLEDevice::createServer();
pServer->setCallbacks(&serverCallbacks);
pServer->advertiseOnDisconnect(true);
NimBLEService* pService = pServer->createService(SERVICE_UUID);
pCharacteristic =
pService->createCharacteristic(CHARACTERISTIC_UUID,
NIMBLE_PROPERTY::WRITE | NIMBLE_PROPERTY::NOTIFY);
pService->start();
NimBLEAdvertising* pAdvertising = NimBLEDevice::getAdvertising();
pAdvertising->setName("ESP SERVER");
pAdvertising->addServiceUUID(SERVICE_UUID);
pAdvertising->enableScanResponse(false);
pAdvertising->setAdvertisingCompleteCallback(onAdvComplete);
pAdvertising->start();
}
void loop() {
//
}
There's nothing wrong with your code, and I am not able to reproduce any issues. This is probably an issue with the client device.
Thank you h2zero