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

BLE Basic Infrastructure #788

Merged
merged 59 commits into from
Oct 27, 2024
Merged

BLE Basic Infrastructure #788

merged 59 commits into from
Oct 27, 2024

Conversation

bakerstu
Copy link
Owner

@bakerstu bakerstu commented Mar 10, 2024

Adds manufacturer-independent infrastructure for a BLE-based connection protocol, and OpenLCB's implemnentation classes and constants.

  • Adds abstract classes for defining BLE Advertisements and Services.
  • Adds concrete implementation of these with encoding the specific advertisements for GATT-based central and peripheral for OpenLCB, including the necessary UUID constants.
  • Adds a Port implementation for DirectHub for sending text data (e.g. gridconnect frames) over BLE.

Since this is all manufacturer-independent, there are no external dependencies involved, but it also means that in itself, this basic infrastructure does not work. A significant amount of additional code is needed to tie this todether with a specific manufacturer's BLE stack.

Misc changes:

  • Makes SimpleStack be able to expose the PIP bytes via a direct API
  • Fixes a compiler warning on LinkedDataBuffer

@bakerstu bakerstu requested a review from balazsracz March 10, 2024 05:00
balazsracz and others added 17 commits July 12, 2024 22:41
- Handles the case when the src or dst buffer is empty.
- Detects when the append happens exactly at a buffer boundary and the
  buffers are already linked buffer.
- Adds a parameter that makes this work even when the link is not there yet
This fixes a buffer refcount bug when a buffer ended up with a zero length
and too few refs.
- MTU < 500.
- do_write needs to be repeated, so we call it via the executor.
We took over o.free_ but this makes the current buffer appendable, which is wrong.
@@ -60,6 +62,10 @@ public:
///
using SendFunction = std::function<void(const uint8_t *data, size_t len)>;

/// How big can a single attribute write be? ESP's BLE implementation says
/// 600 bytes. We keep some buffer.
static constexpr size_t MAX_BYTES_PER_WRITE = 500;
Copy link
Collaborator

Choose a reason for hiding this comment

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

fyi, ble core specification is 512b. I'd likely drop to ~450b as a default (or move to a config constant)

Copy link
Collaborator

Choose a reason for hiding this comment

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

There is apparently also an MTU negotiation happening after the connection gets established. So this likely won't work just as is. Then the negiatiated MTU is not the maximum value that you can transmit, because there is some protocol headers as well.

@balazsracz balazsracz changed the title [WIP] BLE Basic Infrastructure BLE Basic Infrastructure Oct 27, 2024
@balazsracz balazsracz merged commit eb8ed8b into master Oct 27, 2024
8 checks passed
@balazsracz balazsracz deleted the bakerstu-ble-basics branch October 27, 2024 15:53
balazsracz added a commit that referenced this pull request Jan 16, 2025
* master: (76 commits)
  Fixes some compile errors in nucleo and bracz.acc.
  ESP-IDF CMakeLists (#800)
  BLE Basic Infrastructure (#788)
  Handles unhandled-addressed-messages by generating an OIR reply. (#798)
  Adds factory reset handler to linux:io_board. (#797)
  Fixes a standards compliance issue with the alias conflict handler. (#793)
  Bug fixes in DataBuffer (#791)
  Fixes race conditions in HubDeviceSelect. (#795)
  Fixes missing translation of enums when reading the security mode from a simplelink profile. (#796)
  Fixes flaky IfCanStress.test. (#794)
  Pin esp32 platform to 2.0.x (#792)
  Fixes detecting EOF in the memory config protocol handler. (#789)
  Adds a new hub application using DirectHub (#761)
  High-performance hub component for dealing with many sockets and high throughput (#760)
  Fix build of esp8266 train implementation.
  Removes unnecessary includes that might not exist on an embedded compiler.
  Fix compilation of TempFile under esp8266.
  Add libatomic to esp8266 nonos target.
  Fix compile errors in time_client app.
  Fixes in file memory space: (#786)
  ...
balazsracz added a commit that referenced this pull request Jan 18, 2025
* master:
  Fixes some compile errors in nucleo and bracz.acc.
  ESP-IDF CMakeLists (#800)
  BLE Basic Infrastructure (#788)
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.

3 participants