Skip to content

BLERead event handler called twice? #272

Open
@kk7ds

Description

@kk7ds

I'm using an Arduino Nano RP2040 Connect with the NINA module. I've got a service that exposes some string characteristics that I want to feed a different value to each time they're read. I've set an eventhandler for BLERead, which is called. However, it seems to always be called twice on each read. I thought maybe this was a problem with the mobile app I'm writing, but I tried a BLE test/scanner app and each time I read the characteristic, the event handler is called twice.

Surely this is not intentional right? Am I doing something wrong that causes me to be called twice? I've looked through the AndroidBLE code a bit and I don't see any indication that I should be called twice. Even if I don't change the value, the handler is called twice.

Here's roughly what I'm doing:

void iter_temp_log(BLEDevice *central, BLECharacteristic c) {
    Serial.println("CALLED!");
}

void setup() {
    BLE.setLocalName("Remote Level");
    BLE.setAdvertisedService(levelservice);
    levelservice.addCharacteristic(templog);
    BLE.addService(levelservice);
    BLE.advertise();
    templog.setEventHandler(BLERead, iter_temp_log);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: imperfectionPerceived defect in any part of project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions