-
Notifications
You must be signed in to change notification settings - Fork 126
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
WIP: feat(6lowpan_ble): Simplified esp_netif driver #600
base: master
Are you sure you want to change the base?
Commits on Jun 21, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 108e1ff - Browse repository at this point
Copy the full SHA 108e1ffView commit details -
feat: add debug print helper for BLE addresses
This dumps a BLE address to a static char buf. Note that this means it can only be used once per log line (as calling it twice means you'll overwrite that buffer).
Configuration menu - View commit details
-
Copy full SHA for 6721601 - Browse repository at this point
Copy the full SHA 6721601View commit details -
feat: add lowpan6_ble driver code
This is the "driver" or "glue" code for ESP-NETIF. See https://docs.espressif.com/projects/esp-idf/en/v5.2.1/esp32/api-reference/network/esp_netif_driver.html for a more detailed overview of I/O drivers in ESP-IDF. A quick overview though -- this module is responsible for the BLE side of LoWPAN6 BLE. Given a BLE address to connect to (up to the user to decide what address that is), it will: * establish an L2CAP connection with: * the correct Protocol Service Multiplexer (PSM) for the Internet Protocol Support Profile (IPSP) * the correct MTU for LoWPAN6 (1280, as required by IPv6) * on receipt of data, pass the received data to `esp_netif_receive` * register and provide methods for transmitting data FROM esp_netif via the L2CAP channel * forward events to the user (e.g., GAP connect/disconnect, so they can restart the discovery process on disconnect) The driver/glue code does _not_ perform any of the protocol side of LoWPAN6 BLE (i.e., we don't feed any data to LwIP): that will be the job of a custom NETIF layer.
Configuration menu - View commit details
-
Copy full SHA for e9c9f54 - Browse repository at this point
Copy the full SHA e9c9f54View commit details -
build: add missing LoWPAN6 sources from esp-lwip component
esp-lwip doesn't include the lowpan6 files in their build by default (fair enough, given that it's not officially supported). This is a quick workaround to pull those files in without changing ESP-IDF.
Configuration menu - View commit details
-
Copy full SHA for 3e5f490 - Browse repository at this point
Copy the full SHA 3e5f490View commit details -
feat: add custom lowpan6_ble_netif layer
This defines the netstack required to support LoWPAN6 BLE with LwIP. See https://docs.espressif.com/projects/esp-idf/en/v5.2.1/esp32/api-reference/network/esp_netif_driver.html for a more detailed overview of how this fits into ESP-NETIF. A quick summary here though. This module provides the "netstack": this is the configuration used by ESP-NETIF to initialize the netif given to it and to handle incoming data. In our case, this means initializing the netif as an rfc7668 netif and providing received data to `rfc7668_input`, as required by LwIP's LoWPAN6 BLE module. Also important is for us to set the local and peer addresses (used by LwIP when compressing IPv6 headers for transmission over BLE) and to set our link-local IPv6 address based on our BLE MAC address, as required by the LoWPAN6 BLE standard.
Configuration menu - View commit details
-
Copy full SHA for ab21d4b - Browse repository at this point
Copy the full SHA ab21d4bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 3e743e4 - Browse repository at this point
Copy the full SHA 3e743e4View commit details -
Configuration menu - View commit details
-
Copy full SHA for e77ce2d - Browse repository at this point
Copy the full SHA e77ce2dView commit details -
feat: add preprocessor conditionals for v4.3+ support
Registering custom LwIP netstack functions was not supported in ESP-IDF prior to v5.0: From [this comment thread](espressif/esp-idf#13600 (comment)) > yes, registering custom lwip IO functions wasn't possible in IDF < v5.0. > (still possible, if you redefine the opaque structs, like this) > https://github.com/david-cermak/eth-ap-nat/blob/2279344e18a0b98b5368999aac9441c59871e6fa/eth-ap-idf4.3/main/ethernet_example_main.c#L90-L96 There are two things we need to do to shim this custom I/O driver into ESP-NETIF for ESP-IDF v4 and co. The first is to add implicitly required #include before "esp_netif_types.h". This is fixed in v4.4+ by the following commit: espressif/esp-idf@822129e but not backported to v4.3 (fair enough, seeing as it's EOL). The second is to define a netstack config struct compatible with `struct esp_netif_netstack_config_t`, which was not publically exported prior to v5.0. We do so following the example linked above in the david-cermak/eth-ap-nat repo: * define `struct esp_netif_lwip_vanilla_config` * cast our netstack to `esp_netif_netstack_config_t*` `esp_netif_netstack_config_t` is just a union of `struct esp_netif_lwip_vanilla_config` and some other struct we don't care about, so while a bit sketchy this does actually work out (i.e., we can correctly cast between them).
Configuration menu - View commit details
-
Copy full SHA for cdece67 - Browse repository at this point
Copy the full SHA cdece67View commit details -
refactor: clean up handling of addresses on netif up/down
This commit introduces some helper functions for transforming BLE addresses into link-local addresses. This can be used by users to get the link-local address of their peer after establishing a connection.
Configuration menu - View commit details
-
Copy full SHA for 88a5d85 - Browse repository at this point
Copy the full SHA 88a5d85View commit details -
fix: add lwIP sources to lwIP target
We were adding the missing lwIP sources to `lowpan6_ble`. While this worked, it does break the link between `lwip` the target and the lwip lowpan6_ble sources. I bumped into this when enabling lwIP debug: some of their debug statements were failing ESP-IDF's -Werror=format checks. I tried to address this with: ``` idf_component_get_property(lwip lwip COMPONENT_LIB) target_compile_options(${lwip} PRIVATE -Wno-error=format) ``` but of course, the `lwip` target did not contain the sources that were causing an error -- `lowpan6_ble` did! Appending the sources to the `lwip` target is the more correct approach here.
Configuration menu - View commit details
-
Copy full SHA for f58cd53 - Browse repository at this point
Copy the full SHA f58cd53View commit details -
feat: add minimal support for LoWPAN6 BLE client
This is a first stab at the additional "stuff" we'd need to support a LoWPAN6 BLE client (the device that gets connected to rather than the one that connects).
Configuration menu - View commit details
-
Copy full SHA for df5ff94 - Browse repository at this point
Copy the full SHA df5ff94View commit details -
This example is a quick-and-dirty demo of how to communicate over LoWPAN6 BLE between 2 ESP devices. This demonstrates how to hook the lowpan6_ble component into the GAP discovery and connection process to ensure that generic networking APIs such as lwIP can successfully pass messages over our BLE connection.
Configuration menu - View commit details
-
Copy full SHA for 39d5ee7 - Browse repository at this point
Copy the full SHA 39d5ee7View commit details -
fix: free memory on failure to ble_l2cap_send
The `ble_l2cap_send` implementation has a comment that says: > Transmits a packet over an L2CAP channel. This function only consumes > the supplied mbuf on success. This means that on _failure_, we're responsible for freeing the supplied mbuf, otherwise we'll leak memory.
Configuration menu - View commit details
-
Copy full SHA for b810412 - Browse repository at this point
Copy the full SHA b810412View commit details -
This disconnects our L2CAP and GAP connections, if applicable.
Configuration menu - View commit details
-
Copy full SHA for bf66cb3 - Browse repository at this point
Copy the full SHA bf66cb3View commit details -
Configuration menu - View commit details
-
Copy full SHA for fd54c9a - Browse repository at this point
Copy the full SHA fd54c9aView commit details
Commits on Jun 25, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 2999835 - Browse repository at this point
Copy the full SHA 2999835View commit details