Skip to content

Fixed incorrect usage of xEventGroupWaitBits #3446

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

Merged
merged 2 commits into from
Nov 11, 2019
Merged

Conversation

wolph
Copy link
Contributor

@wolph wolph commented Nov 3, 2019

Related discussion in #3219

@IonicEV
Copy link
Contributor

IonicEV commented Nov 4, 2019

You may get note on bool vs. wait bitwise value. Originally, those changes resulted in logic errors by mistake. It may fail equal operator logic: (true == bit), as true most likely defined as 1, so 1 != 2, or 4 or 8 & etc. It would only work with bit = 1. It does not affect the existing code though.

@me-no-dev
Copy link
Member

please bring back the braces and check if it's different than 0. While non-null value is technically TRUE, I would like the code to show that properly :)

@wolph
Copy link
Contributor Author

wolph commented Nov 11, 2019

I've added the != 0 and I've added parentheses (I assume you meant those instead of braces? Braces are { and })

@me-no-dev
Copy link
Member

surely :D excuse my "English". braces, brackets, parentheses... it's a bit confusing

@me-no-dev me-no-dev merged commit bc3d113 into espressif:master Nov 11, 2019
@wolph
Copy link
Contributor Author

wolph commented Nov 11, 2019

I know how it can be, English is not my native language either :)

@me-no-dev
Copy link
Member

to me:

  • ( braces
  • { curly braces
  • [ square braces / brackets
  • parentheses sounds like it should be ' or "
  • my own language sounds strange to me... go figure

@ItsShunya
Copy link

ItsShunya commented Nov 28, 2019

I'm having some trouble connecting my ESP32-WROOM-32 to any other device via bluetooth. I'm using the SerialtoSerialBTM example with the address and name modified only. The log I'm getting from the debug is the following:


[W][esp32-hal-psram.c:30] psramInit(): PSRAM init failed!
[I][BluetoothSerial.cpp:514] _init_bt(): device name set
[I][BluetoothSerial.cpp:227] esp_spp_cb(): ESP_SPP_INIT_EVT
[I][BluetoothSerial.cpp:120] btSetPin(): pin set
The device started in master mode, make sure remote BT device is on!
[I][BluetoothSerial.cpp:726] connect(): master : remoteAddress
[I][BluetoothSerial.cpp:292] esp_spp_cb(): ESP_SPP_DISCOVERY_COMP_EVT
Failed to connect. Make sure remote device is available and in range, then restart app.

I've seen that it sets the address right, and when doing the connect() function it returns false when doing waitForConnect(SCAN_TIMEOUT)
I believe that problem comes from the following line that was modified in this merge.
return (xEventGroupWaitBits(_spp_event_group, SPP_CONNECTED, pdFALSE, pdTRUE, xTicksToWait) & SPP_CONNECTED) != 0;

I've tried to connect to multiple deviced and it always returns false, any way to fix this?

Update: I've tried the same program using another ESP32-WROOM-32 that I had and the problem is the same

@atanisoft
Copy link
Collaborator

@Shunyavic open an issue for your issue rather than hijack a merged PR.

@wolph
Copy link
Contributor Author

wolph commented Nov 28, 2019

While this code fixes the bug that it was erroneously telling you it worked, it doesn't fix anything else.

I haven't been able to get the master mode working well either

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 this pull request may close these issues.

5 participants