I am currently trying to setup a BLE Connection between a ESP32-ST and a BGM111 from Silabs.
I can connect to the service and find the characteristic I want but whenever i try to read the value i get
E (36655) BT: GATT_READ_NOT_PERMIT
Aswell when I want to apply the BGM for notifications I get
E (36155) BT: format mismatch
which indicates that the chips are somehow using different BLE protocols.
When I try to read/write the value with another esp32 it just works fine so the basic setup of my BLE Server should be ok.
So is there anything I have to take into account when I connect a non-ESP32 BLE device to a esp32 ? I really need a new idea how to debug that error.
The Error Messages are generated in esp-idf/components/bt/bluedroid/stack/gatt/gatt_db.c
Here is my ESP32 code based on the BLE Server Example of arduino-espressif:
Code: Select all
#if (ARDUINO >= 100)
#include <Arduino.h>
#else
#include <WProgram.h>
#endif
#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <BLE2902.h>
#include <string>
#include <sstream>
#include <vector>
#include <esp_log.h>
#include <cstdio>
BLECharacteristic *dist;
bool deviceConnected = false;
uint8_t value = 0;
// See the following for generating UUIDs:
// https://www.uuidgenotifynerator.net/
#define SERVICE_UUID "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
#define CHARACTERISTIC_UUID1 "beb5483e-36e1-4688-b7f5-ea07361b26a8"
class MyServerCallbacks: public BLEServerCallbacks {
void onConnect(BLEServer* pServer) {
deviceConnected = true;
};
void onDisconnect(BLEServer* pServer) {
deviceConnected = false;
}
};
#define createCharact(uuid,charac,pService) charac =pService->createCharacteristic(uuid, \
BLECharacteristic::PROPERTY_READ | \
BLECharacteristic::PROPERTY_WRITE | \
BLECharacteristic::PROPERTY_NOTIFY | \
BLECharacteristic::PROPERTY_INDICATE | \
BLECharacteristic::PROPERTY_WRITE_NR \
); \
charac->addDescriptor(new BLE2902());
void createChars(BLEService *pService) {
createCharact(CHARACTERISTIC_UUID2, dist, pService);
}
int print_F(const char* msg,va_list list){
char temp[200];
vsprintf(temp,msg,list);
Serial.print(temp);
return 0;
}
void setup() {
esp_log_level_set("*", ESP_LOG_VERBOSE);
esp_log_set_vprintf(print_F);
// Create the BLE Device
BLEDevice::init("RBase");
// Create the BLE Server
BLEServer *pServer = BLEDevice::createServer();
pServer->setCallbacks(new MyServerCallbacks());
// Create the BLE Service
BLEService *pService = pServer->createService(SERVICE_UUID);
createChars(pService);
// Start the service
pService->start();
pServer->getAdvertising()->addServiceUUID(BLEUUID(SERVICE_UUID));
pServer->getAdvertising()->start();
dist->setValue("hallo");
}
void loop() {
//wait for a change of value
std::string temp=dist->getValue();
if(temp != "hallo")
Serial.println(temp.c_str());
delay(50);
}
ets Jun 8 2016 00:22:57
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:956
load:0x40078000,len:0
load:0x40078000,len:13076
entry 0x40078a58
Starting up
Gestartet
E (79543) BT: format mismatch
E (80043) BT: GATT_READ_NOT_PERMIT
E (80543) BT: GATT_READ_NOT_PERMIT
E (81043) BT: GATT_READ_NOT_PERMIT
E (81543) BT: GATT_READ_NOT_PERMIT
E (82043) BT: GATT_READ_NOT_PERMIT