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

Add ESP-32 Wi-Fi and BLE driver #352

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

chrissnow
Copy link

Summary of changes

Add Renesas ESP-32 driver which adds Wi-Fi and BLE support to any target with a serial port at very low cost

Impact of changes

Migration actions required

Documentation

TBC?


Pull request type

[] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[] No Tests required for this change (E.g docs only update)
[] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

@multiplemonomials
Copy link
Collaborator

Is there an Mbed board that has an ESP32 on it? One of the Renesas ones it seems like?

@chrissnow
Copy link
Author

Both GR-LCYHEE and GR-PEACH.
It's useful to anybody that wants to add Wi-Fi and ble to any target at very low cost also.

@multiplemonomials
Copy link
Collaborator

Might have to order one of those boards to run the wifi tests on it, unless you have one

@multiplemonomials
Copy link
Collaborator

@chrissnow would you be able to take a look at these CI failures? Also could you confirm whether you have a board with this chip on it to test on?

@chrissnow
Copy link
Author

@multiplemonomials it build OK so I wonder whey it's failing, can mbed.h not be included here?
I notice the ESP8266 driver includes various internal headers instead which may be the answer.

I don't have a Renesas board, but do have various ESP32 dev boards, we have one attached to a STM32 for testing.
You just need to flash the ESP-AT firmware and connect the UART, ideally with flow control!

I will tidy up and report back but it might be next week now.

@multiplemonomials
Copy link
Collaborator

multiplemonomials commented Sep 25, 2024

Yeah I think that things inside mbed os should include only the specific headers they need (e.g. NetworkInterface.h) rather than the top level mbed.h

@chrissnow
Copy link
Author

Not yet fully tested but issues should now be resolved.

@@ -566,7 +566,7 @@ spif_bd_error SPIFBlockDevice::_spi_send_program_command(int prog_inst, const vo
spif_bd_error SPIFBlockDevice::_spi_send_erase_command(int erase_inst, bd_addr_t addr, bd_size_t size)
{
tr_debug("Erase Inst: 0x%xh, addr: %llu, size: %llu", erase_inst, addr, size);
addr = (((int)addr) & 0xFFFFF000);
//addr = (((int)addr) & 0xFFFFF000);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wait, why are we changing this?

Copy link
Author

Choose a reason for hiding this comment

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

That shouldn't be in there, need a separate PR for that.

@multiplemonomials
Copy link
Collaborator

@chrissnow thanks for your work on this! Could you take a look at the failing doc and style checks? It can't be merged until those are resolved. If you give me push access to your repo, I can take a look though!

@chrissnow
Copy link
Author

I'm still testing it and want to figure out the reset timing a bit more but it seems to be working fine.

The driver doesn't check return codes enough and blindly continues which probably want looking at.

@zhiyong-ft
Copy link

@chrissnow Mr. Snow, have you tested auto-reconnect of ESP32 modules? I briefly tested it by powering cycle AP, ESP32 doesn't seem automatically reconnect at all, even with the following line added into the start up routine:

bool ESP32::_startup_wifi()
{
    _startup_common();

    if (_init_end_wifi) {
        return true;
    }

    bool success = _parser.send("AT+CWMODE=%d", _wifi_mode)
                && _parser.recv("OK")
                && _parser.send("AT+CIPMUX=1")
                && _parser.recv("OK")
                && _parser.send("AT+CWAUTOCONN=0")
                && _parser.recv("OK")
                // The following line supposedly turn on automatic reconnect, default is 0, 0, disabled
                && _parser.send("AT+CWRECONNCFG=%d, %d", _reconnect_interval, _reconnect_max_attempts)
                && _parser.recv("OK")
                && _parser.send("AT+CWQAP")
                && _parser.recv("OK");
    if (success) {
        _init_end_wifi = true;
    }

    return success;
}

@chrissnow
Copy link
Author

@zhiyong-ft good to hear someone else is interested in this :-)

I haven't spent too much time testing this and certainly not auto reconnect.

I do however know the current code doesn't work in non-blocking mode and I cant see an easy way to implement it given the AT response wont return until it's timed out.

I'm also not sure how well auto reconnect is going to behave with the mbed stack, it could handle the unsolicited connected\disconnected messages but would need work I think.

Help would be welcome on it :-)

@multiplemonomials I don't think I can easily grant you write access to this repo\branch because there's a few branches we use for production.

Would it let you submit a PR against it?

@multiplemonomials
Copy link
Collaborator

To fix the style, just run ./run-formatter.sh in the root directory of the repo. That will use astyle to format everything. (you'll need to install astyle if you don't have it).

For the docs check failures, it looks like there are just 5-10 function doc comment issues that need to be fixed. Let me know if you need help finding the issues!

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.

4 participants