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

Async WiFi #125

Merged
merged 6 commits into from
Feb 9, 2023
Merged

Async WiFi #125

merged 6 commits into from
Feb 9, 2023

Conversation

MabezDev
Copy link
Member

@MabezDev MabezDev commented Feb 9, 2023

This PR adds embassy_net support to esp-wifi, along with a embassy based DHCP example. Currently connecting to WiFi is blocking, and is completed before starting the executor. This is mainly due to the embedded_svc traits for wifi being blocking at the moment, but we could easily add our own async interface to WiFiDevice in another PR.

TODO

- Add embassy_net::Driver impl for WifiDevice
- Add embassy_dhcp example
- Update README with embassy_dhcp running instruction

Notes:

TCP connection may fail a few times until the esp gets an IP address, it
seems there is no way to await dhcp completion in embassy_net yet.
- Whilst other embassy crates can be used behind the async feature,
  embassy-net should be put behind its own feature
@MabezDev MabezDev requested review from bjoernQ and jessebraham and removed request for bjoernQ February 9, 2023 14:20
@bjoernQ
Copy link
Contributor

bjoernQ commented Feb 9, 2023

Awesome! ❤️

I also don't see any problems from using embedded-io 0.4.0 in bleps - no idea if I hallucinated that before 🤷‍♂️ will merge that

but there is a crash now with the ESP32-S3 BLE example

Exception occured Illegal Context { PC: 4037d705, PS: 60f35, A0: 8003589a, A1: 3fce65d0, A2: 40055bc0, A3: 8003589a, A4: 2000000, A5: 59e0966, A6: 5000966, A7: 0, A8: 8037d700, A9: 3fce65b0, A10: 0, A11: 4920966, A12: 6000e000, A13: 900, A14: 3, A15: 3fc9d55c, SAR: 1c, EXCCAUSE: 0, EXCVADDR: 0, LBEG: 4201cb9d, LEND: 4201cbca, LCOUNT: 0, THREADPTR: 0, SCOMPARE1: 0, BR: 0, ACCLO: 0, ACCHI: 0, M0: 0, M1: 0, M2: 0, M3: 0, F64R_LO: e24573d5, F64R_HI: a97a584b, F64S: 8a66afe, FCR: 0, FSR: 0, F0: 0, F1: 0, F2: 0, F3: 0, F4: 0, F5: 0, F6: 0, F7: 0, F8: 0, F9: 0, F10: 0, F11: 0, F12: 0, F13: 0, F14: 0, F15: 0 }
0x4037d705
0x4037d705 - ram_chip_i2c_writeReg
    at ??:??
0x4003589a
0x4003589a - rom_rx_gain_force
    at ??:??
0x40035939
0x40035939 - rom_rx_gain_force
    at ??:??
0x4201e658
0x4201e658 - i2c_bbpll_set
    at ??:??
0x4201b1fa
0x4201b1fa - rf_init
    at ??:??
0x4201b5de
0x4201b5de - register_chipv7_phy
    at ??:??
0x420035f1
0x420035f1 - _ZN8esp_wifi14common_adapter13chip_specific10phy_enable17h33114ba888ea67b2E
    at ??:??
0x4200497b
0x4200497b - _ZN8esp_wifi3ble4btdm8ble_init17h02ed34598bf544b0E
    at ??:??
0x4200291a
0x4200291a - _ZN8esp_wifi10initialize17h5b7ae473b13c5375E
    at ??:??
0x420016c5
0x420016c5 - main
    at ??:??
0x420063c4
0x420063c4 - Reset
    at ??:??
0x40378d71
0x40378d71 - ESP32Reset
    at ??:??

@MabezDev
Copy link
Member Author

MabezDev commented Feb 9, 2023

but there is a crash now with the ESP32-S3 BLE example

Looks like we're running into the loop optimization issue again, "-C", "target-feature=-loop", with a git version of xtensa-lx-rt and it works in release (also works in debug btw). We should cut a release of xtensa-lx-rt and default to disabling loop optimization for now I think.

@bjoernQ
Copy link
Contributor

bjoernQ commented Feb 9, 2023

but there is a crash now with the ESP32-S3 BLE example

Looks like we're running into the loop optimization issue again, "-C", "target-feature=-loop", with a git version of xtensa-lx-rt and it works in release (also works in debug btw). We should cut a release of xtensa-lx-rt and default to disabling loop optimization for now I think.

Ah yes - I once again forgot about that - I agree and it shouldn't hold us back from getting this in

README.md Show resolved Hide resolved
@MabezDev MabezDev requested a review from bjoernQ February 9, 2023 15:34
Copy link
Contributor

@bjoernQ bjoernQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MabezDev MabezDev merged commit d1bf3a3 into esp-rs:main Feb 9, 2023
MabezDev added a commit to MabezDev/esp-wifi that referenced this pull request Feb 12, 2023
* Async WiFi with embassy

- Add embassy_net::Driver impl for WifiDevice
- Add embassy_dhcp example
- Update README with embassy_dhcp running instruction

Notes:

TCP connection may fail a few times until the esp gets an IP address, it
seems there is no way to await dhcp completion in embassy_net yet.

* Put embassy-net behind feature

- Whilst other embassy crates can be used behind the async feature,
  embassy-net should be put behind its own feature

* wait for dhcp to complete in example

* fmt

* Simplify embedded-io import

* Update README, use new bleps
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.

None yet

2 participants