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

Consider using HCI protocol for low-level BLE interface #1292

Closed
dhalbert opened this issue Oct 22, 2018 · 4 comments · Fixed by #3310
Closed

Consider using HCI protocol for low-level BLE interface #1292

dhalbert opened this issue Oct 22, 2018 · 4 comments · Fixed by #3310

Comments

@dhalbert
Copy link
Collaborator

HCI is a binary protocol that can be sent over a serial connection, SPI, or via an API. Its messages control a BLE device. It is implemented in the nRF Softdevice, and is also provided on many standalone BLE chips.

We could use HCI as the lowest-level part of a CircuitPython BLE implementation. For example:

  1. Specific service providers (highest level) - implemented in Python
  2. Classic BLE API: Service, Characteristic, Peripheral, Central, advertising, etc. - implemented in Python
  3. HCI layer, implemented in Python or as a native C module.

The advantage is that different BLE hardware can be swapped out at the lowest level, without changing the upper levels. Level 3. could take an HCI destination that's a serial or SPI connection or an API module.

There's a MicroPython implementation of 3. in Python: https://github.com/dmazzella/uble. It's fairly large.

Discussed in audio here: https://diode.zone/videos/watch/d89b7f1e-0c80-413e-88d6-a4468ef9a94d BLE discussion starts at 54:45; HCI discussion is toward the end of that discussion.

Tagging @ktown @arturo182

@uhrheber
Copy link

See Zephyr project: https://github.com/zephyrproject-rtos/zephyr

They've already implemented HCI over serial, SPI, USB, etc., also for the nRF.
Micropython can run on top of Zephyr, I don't know if that port is still alive in circuitpython.

@dhalbert
Copy link
Collaborator Author

We've discussed using Zephyr or MyNewt as well, but that's a major change and probably for a later version (some discussion in the audio above). Zephyr and MyNewt have support for the chips we support, but it's not complete - we'd have to port our current drivers into the RTOS's driver structure.

@uhrheber
Copy link

That'd have some advantages. You'd have to write the drivers only once, and then have them available for both C and CircuitPython (or other high-level languages, like node.js, Lua, etc.).
Porting to new platforms, like RISC-V, would be easier.
But it would also collide with ports, that already use an OS, like the ESP ports, that use FreeRTOS.

@tannewt tannewt modified the milestones: 4.0 Beta, Long term Nov 29, 2018
@tannewt
Copy link
Member

tannewt commented Nov 29, 2018

Going to punt this to long term. For 4.0 we'll use the SD.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants