Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onRead sequence question. #816

Closed
DontSerious opened this issue Dec 21, 2024 · 6 comments · Fixed by #840
Closed

onRead sequence question. #816

DontSerious opened this issue Dec 21, 2024 · 6 comments · Fixed by #840

Comments

@DontSerious
Copy link

DontSerious commented Dec 21, 2024

Last version i used is 1.4.3, when i try to read value from esp32, the value that i get is after onRead process(i will call a setValue() inside onRead())

void onRead(NimBLECharacteristic *characteristic, NimBLEConnInfo &connInfo)
    {
        String rxValue = getCurrentPatternName();
        characteristic->setValue(rxValue);
        Serial.println("pathName on Read: " + rxValue);
    }

After i update to 2.1.1, when i try to read value, the value is old value which is last time i call setValue().
Right now, i want to know if this sequence is change and is there a way to change the sequence from the code.

@DontSerious DontSerious closed this as not planned Won't fix, can't repro, duplicate, stale Dec 21, 2024
@h2zero
Copy link
Owner

h2zero commented Dec 21, 2024

Not sure why you closed this, did you resolve your issue?

@puzrin
Copy link

puzrin commented Jan 4, 2025

@h2zero I have the same issue when I try to migrate from 1.4.2.

I use the same long characteristic to write/read chunked data. Desktop client splits blob into multiple chunks and writes those to device's characteristic. Then tries to get response, reading chunks fro the same characteristic.

In onRead, I make setValue() to fill with response chunks, but the desktop client receives the last value it's written before. It behaves like setValue() did nothing (but I don't know what happens under the hood).

Do you have ideas how to fix/workaround this?

Ref: puzrin/reflow_micro@138dcd0

@h2zero
Copy link
Owner

h2zero commented Jan 4, 2025

@puzrin Can you please add -D CONFIG_NIMBLE_CPP_DEBUG_ASSERT_ENABLED=1 and -D CONFIG_NIMBLE_CPP_LOG_LEVEL=4 to your build flags and post the logs?

@h2zero h2zero reopened this Jan 4, 2025
@puzrin
Copy link

puzrin commented Jan 4, 2025

--- Terminal on /dev/ttyACM1 | 9600 8-N-1
--- Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
ESP-ROM:esp32c3-api1-20210207
[INFO]: State => Init
[INFO]: State => Idle
[INFO]: BLE initialized
D NimBLEServer: >> handleGapEvent: 
D NimBLEServer: << handleGapEvent
D NimBLEServer: >> handleGapEvent: 
D NimBLEServer: << handleGapEvent
D NimBLEServer: >> handleGapEvent: 
I NimBLEServer: mtu update event; conn_handle=1 mtu=255
D NimBLEServer: << handleGapEvent
[INFO]: BLE: Device connected, conn_handle 1
[INFO]: BLE: MTU updated to 255, conn_handle 1
D NimBLEServer: >> handleGapEvent: 
I NimBLEServer: subscribe event; attr_handle=8, subscribed: true
D NimBLEServer: << handleGapEvent
D NimBLEServer: Gatt Write event
D NimBLEServer: Gatt Read event
D NimBLEServer: Gatt Write event
D NimBLEServer: Gatt Read event
[INFO]: BLE AUTH: Received chunk of length 28
[INFO]: BLE AUTH: Sending response chunk of length 83
[INFO]: BLE AUTH: Received chunk of length 28
[INFO]: BLE AUTH: Sending response chunk of length 83
D NimBLEServer: Gatt Write event
D NimBLEServer: Gatt Read event
D NimBLEServer: Gatt Write event
D NimBLEServer: Gatt Read event
[INFO]: BLE AUTH: Received chunk of length 28
[INFO]: BLE AUTH: Sending response chunk of length 83
[INFO]: BLE AUTH: Received chunk of length 28
[INFO]: BLE AUTH: Sending response chunk of length 83
D NimBLEServer: Gatt Write event
D NimBLEServer: Gatt Read event
D NimBLEServer: Gatt Write event
D NimBLEServer: Gatt Read event
[INFO]: BLE AUTH: Received chunk of length 28
[INFO]: BLE AUTH: Sending response chunk of length 83
[INFO]: BLE AUTH: Received chunk of length 28
[INFO]: BLE AUTH: Sending response chunk of length 83
D NimBLEServer: >> handleGapEvent: 
I NimBLEServer: subscribe event; attr_handle=8, subscribed: false
D NimBLEServer: << handleGapEvent
D NimBLEServer: >> handleGapEvent: 
D NimBLEAdvertising: >> Advertising start: duration=0, dirAddr=NULL
D NimBLEAdvertising: << Advertising start
D NimBLEServer: << handleGapEvent
[INFO]: BLE: Device disconnected, conn_handle 1
[INFO]: BLE: Session destroyed

[INFO] are messages of my app logger work. It writes in background, order can be not in sync with your log messages. On desktop read gives 28 byte (as been sent) instead of 83.

@h2zero
Copy link
Owner

h2zero commented Jan 5, 2025

Thanks @puzrin I have open #840 to resolve this

@DontSerious
Copy link
Author

DontSerious commented Jan 7, 2025

Sry, I changed my function workflow and everything worked again because I felt like I didn't understand the workflow of this library. So I close it...thx for your work sincerely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants