Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

BLEServer double callback on WRITE and WRITE_NR #11805

Closed
Assignees
Labels
Area: BLEIssues related to BLE
@Brisk4t

Description

Board

ESP32S3-WROOM-1, ESP32S3 Supermini (Adafruit Feather Clone)

Device Description

Supermini - Bare pcb programmed over USB, serial output over USB
WROOM - WROOM module on breadboard, programmed over UART, serial over UART

Hardware Configuration

FT232 on WROOM tx and rx.

Version

v3.3.0

Type

Bug

IDE Name

Arduino IDE

Operating System

Windows 11

Flash frequency

80MHz

PSRAM enabled

no

Upload speed

921600

Description

When running the BLE->Write example, writing to the characteristic results in the onWrite callback triggering twice.

Data is sent using the NRF Connect Android app.

Sketch

#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>
// 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 MyCallbacks : public BLECharacteristicCallbacks {
 void onWrite(BLECharacteristic *pCharacteristic) {
 String value = pCharacteristic->getValue();
 if (value.length() > 0) {
 Serial.println("*********");
 Serial.print("New value: ");
 for (int i = 0; i < value.length(); i++) {
 Serial.print(value[i]);
 }
 Serial.println();
 Serial.println("*********");
 }
 }
};
void setup() {
 Serial.begin(115200);
 Serial.println("1- Download and install an BLE scanner app in your phone");
 Serial.println("2- Scan for BLE devices in the app");
 Serial.println("3- Connect to MyESP32");
 Serial.println("4- Go to CUSTOM CHARACTERISTIC in CUSTOM SERVICE and write something");
 Serial.println("5- See the magic =)");
 BLEDevice::init("MyESP32");
 BLEServer *pServer = BLEDevice::createServer();
 BLEService *pService = pServer->createService(SERVICE_UUID);
 BLECharacteristic *pCharacteristic =
 pService->createCharacteristic(CHARACTERISTIC_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE_NR);
 pCharacteristic->setCallbacks(new MyCallbacks());
 pCharacteristic->setValue("Hello World");
 pService->start();
 BLEAdvertising *pAdvertising = pServer->getAdvertising();
 pAdvertising->start();
}
void loop() {
 // put your main code here, to run repeatedly:
 delay(2000);
}

Debug Message

// Comment: Write value "hi" as TEXT (UTF-8) 
*********
New value: hi
*********
*********
New value: hi
*********

Other Steps to Reproduce

I was running Bluedroid from PIO Arduino Esp32 core (2.x.x) and the same sketch prints only once for each WRITE or WRITE_NR sent.

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Labels

Area: BLEIssues related to BLE

Type

Projects

No projects

Milestone

No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      AltStyle によって変換されたページ (->オリジナル) /