Skip to content

not returning to arduino loop #927

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

Open
vcmorini opened this issue Nov 25, 2019 · 6 comments
Open

not returning to arduino loop #927

vcmorini opened this issue Nov 25, 2019 · 6 comments

Comments

@vcmorini
Copy link

Hello
When I am scanning-->connecting with my BLE device, and a Ticker function, or MQTT message comes into play at the same time, sometimes my ESP32 never goes back to the arduino loop.

It remains only executing the attached Ticker functions, but never back to my loop, until my watchdog (a function attached to another Ticker) is triggered, rebooting the ESP32.
Could it be a problem of a missing "return" at the end of the attached Ticker function, even if the function return is void? Or maybe a thread/semaphore/priority task issue?
What are your suggestions?
What can I study in order to solve this issue?

Many thanks!

@vcmorini
Copy link
Author

@chegewara I know you have a tight schedule.
I will tag you in hope you can give me your suggestion when you are free, since your opinion weights a lot to me.
Many thanks for your contribution to this library so far!

@chegewara
Copy link
Collaborator

Its hard to say without code or logs.

@thomastech
Copy link

Or maybe a thread/semaphore/priority task issue?

In case it helps your situation, see the discussion about xSemaphoreTake found here:
#874

  • Thomas

@vcmorini
Copy link
Author

vcmorini commented Jan 5, 2020

Or maybe a thread/semaphore/priority task issue?

In case it helps your situation, see the discussion about xSemaphoreTake found here:
#874

  • Thomas

Thanks Thomas, this is exactly the issue.

For reference, the verbose:
Forming a BLE connection to: 00:1a:22:12:db:ff
[V][BLEDevice.cpp:60] createClient(): >> createClient
[V][BLEDevice.cpp:66] createClient(): << createClient
[V][BLEClient.cpp:96] connect(): >> connect(00:1a:22:12:db:a1)
[I][BLEDevice.cpp:593] addPeerDevice(): add conn_id: 1, GATT role: client
[D][FreeRTOS.cpp:189] take(): Semaphore taking: name: RegEvt (0x3ffdc838), owner: <N/A> for connect
[D][FreeRTOS.cpp:198] take(): Semaphore taken: name: RegEvt (0x3ffdc838), owner: connect
[V][FreeRTOS.cpp:63] wait(): >> wait: Semaphore waiting: name: RegEvt (0x3ffdc838), owner: connect for connect
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 0
[D][BLEDevice.cpp:148] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 0
[V][BLEUtils.cpp:1283] dumpGattClientEvent(): GATT Event: Unknown
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 0
[D][BLEClient.cpp:158] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[V][FreeRTOS.cpp:143] give(): Semaphore giving: name: RegEvt (0x3ffdc838), owner: connect
[V][FreeRTOS.cpp:77] wait(): << wait: Semaphore released: name: RegEvt (0x3ffdc838), owner: <N/A>
[D][FreeRTOS.cpp:189] take(): Semaphore taking: name: OpenEvt (0x3ffdc898), owner: <N/A> for connect
[D][FreeRTOS.cpp:198] take(): Semaphore taken: name: OpenEvt (0x3ffdc898), owner: connect
[V][FreeRTOS.cpp:63] wait(): >> wait: Semaphore waiting: name: OpenEvt (0x3ffdc898), owner: connect for connect
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 40
[D][BLEDevice.cpp:148] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 40
[V][BLEUtils.cpp:1283] dumpGattClientEvent(): GATT Event: Unknown
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 40
[D][BLEClient.cpp:158] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[D][BLEDevice.cpp:577] updatePeerDevice(): update conn_id: 4, GATT role: client
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 2
[D][BLEDevice.cpp:148] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 2
[V][BLEUtils.cpp:1283] dumpGattClientEvent(): GATT Event: Unknown
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 2
[D][BLEClient.cpp:158] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[V][FreeRTOS.cpp:143] give(): Semaphore giving: name: OpenEvt (0x3ffdc898), owner: connect
[V][FreeRTOS.cpp:77] wait(): << wait: Semaphore released: name: OpenEvt (0x3ffdc898), owner: <N/A>
[V][BLEClient.cpp:129] connect(): << connect(), rc=1
[V][BLEClient.cpp:377] getService(): >> getService: uuid: 3e135142-654f-9090-134a-a6ff5bb77046
[V][BLEClient.cpp:413] getServices(): >> getServices
[V][BLEClient.cpp:71] clearServices(): >> clearServices
[V][BLEClient.cpp:78] clearServices(): << clearServices
[D][FreeRTOS.cpp:189] take(): Semaphore taking: name: SearchCmplEvt (0x3ffdc8f8), owner: <N/A> for getServices
[D][FreeRTOS.cpp:198] take(): Semaphore taken: name: SearchCmplEvt (0x3ffdc8f8), owner: getServices
[V][FreeRTOS.cpp:63] wait(): >> wait: Semaphore waiting: name: SearchCmplEvt (0x3ffdc8f8), owner: getServices for getServices

@vcmorini
Copy link
Author

vcmorini commented Jan 6, 2020

Dear Mr. @chegewara ,
Can this function:
void notifyCallback(BLERemoteCharacteristic* pBLERemoteCharacteristic, uint8_t* pData, size_t length, bool isNotify) { ...

Be considered an Interrupt Service Routine (ISR)? I ask this because I am in doubt which type of FreeRTOS functions I should use inside it, i.e. if I should use fncFromISR (e.g. https://freertos.org/xSemaphoreTakeFromISR.html) functions or the standard ones.

Many thanks!

@chegewara
Copy link
Collaborator

No, this is regular function, no need to use xxxfromISR in it.

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

No branches or pull requests

3 participants