Error 908: the permission bluetooth connect has been denied. please enable it in the settings app

If you enabled the permission in Settings this should work. If it still doesn't, for whatever reason, try the blocks in my post.

BTW, BluetoothClient is work.

is it for BLE? i did not find some of the function, i.e. call.SroreValue...how about the pair key?

BTW, I would like to thank you for your support!

when i add BluetoothClient1 the error massage is disappear, but not show list of Bluetooth devices

Use the latest version of the BLE extension

Taifun

I used 20230728 which is not work, let me try the old version

No change, i also used the latest version.

does a BLE device must be exist to show in the list?

The good thing about your question is that you asked it yourself.

(It probably makes little sense to test a Bluetooth app alone in the forest. :wink:)

2 Likes

haha,... I mean I have esp32 worked for BluetoothClient1. does the esp32 must configured for BLE?

It is all about Bluetooth classic. I want the BLE, to connect multiple device to a single app.

First sentence:

yes, but the all examples are for classic

I configured the esp32 for BLE, still not shown in the device list

/*

  Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleNotify.cpp

  Ported to Arduino ESP32 by Evandro Copercini

  updated by chegewara and MoThunderz

*/

#include <BLEDevice.h>

#include <BLEServer.h>

#include <BLEUtils.h>

#include <BLE2902.h>

BLEServer* pServer = NULL;

BLECharacteristic* pCharacteristic = NULL;

BLEDescriptor *pDescr;

BLE2902 *pBLE2902;

bool deviceConnected = false;

bool oldDeviceConnected = false;

uint32_t value = 0;

// See the following for generating UUIDs:

// https://www.uuidgenerator.net/

#define SERVICE_UUID        "4fafc201-1fb5-459e-8fcc-c5c9c331914b"

#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"

class MyServerCallbacks: public BLEServerCallbacks {

    void onConnect(BLEServer* pServer) {

      deviceConnected = true;

    };

    void onDisconnect(BLEServer* pServer) {

      deviceConnected = false;

    }

};

void setup() {

  Serial.begin(115200);

  // Create the BLE Device

  BLEDevice::init("ESP32");

  // Create the BLE Server

  pServer = BLEDevice::createServer();

  pServer->setCallbacks(new MyServerCallbacks());

  // Create the BLE Service

  BLEService *pService = pServer->createService(SERVICE_UUID);

  // Create a BLE Characteristic

  pCharacteristic = pService->createCharacteristic(

                      CHARACTERISTIC_UUID,

                      BLECharacteristic::PROPERTY_NOTIFY

                    );                  

  // Create a BLE Descriptor

 

  pDescr = new BLEDescriptor((uint16_t)0x2901);

  pDescr->setValue("A very interesting variable");

  pCharacteristic->addDescriptor(pDescr);

 

  pBLE2902 = new BLE2902();

  pBLE2902->setNotifications(true);

  pCharacteristic->addDescriptor(pBLE2902);

  // Start the service

  pService->start();

  // Start advertising

  BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();

  pAdvertising->addServiceUUID(SERVICE_UUID);

  pAdvertising->setScanResponse(false);

  pAdvertising->setMinPreferred(0x0);  // set value to 0x00 to not advertise this parameter

  BLEDevice::startAdvertising();

  Serial.println("Waiting a client connection to notify...");

}

void loop() {

    // notify changed value

    if (deviceConnected) {

        pCharacteristic->setValue(value);

        pCharacteristic->notify();

        value++;

        delay(1000);

    }

    // disconnecting

    if (!deviceConnected && oldDeviceConnected) {

        delay(500); // give the bluetooth stack the chance to get things ready

        pServer->startAdvertising(); // restart advertising

        Serial.println("start advertising");

        oldDeviceConnected = deviceConnected;

    }

    // connecting

    if (deviceConnected && !oldDeviceConnected) {

        // do stuff here on connecting

        oldDeviceConnected = deviceConnected;

    }

} 

For additional information,
The developer of this code said:
"Confirmed to work on:ESP32-WROOM-32D

Does not work on (will not connect):
ESP32-WROOM-32"

My is ESP32-WROOM-32

good news, i found it in the list, but not connect. i found similar question in this forum, but not resolved (ESP32-WROOM-32 Does not Work with MIT App Inventor in BLE Mode (BluetoothLE)?)

waiting your support

when I add location sensor it shows the list of Bluetooth devices
image