A toy-level BLE peripheral stack

Related tags

Miscellaneous bleps
Overview

bleps - A toy-level BLE peripheral stack

This is a BLE peripheral stack in Rust. (no-std / no-alloc)

To use it you need an implementation of embedded-io offering communication with HCI.

This is early POC / WIP! You are warned!

The goal is just to have something that works for testing and demos. I have no plan to add advanced features like pairing and bonding (while it should be possible to add that).

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or

You might also like...
Simple tray application which shows battery level for HyperX Cloud Flight Wireless Headset.
Simple tray application which shows battery level for HyperX Cloud Flight Wireless Headset.

HyperX Cloud Flight Battery Monitoring Introduction Simple tray application which shows battery level for HyperX Cloud Flight Wireless Headset. Screen

A collection of compilers based around compiling a high level language to a Brainfuck dialect.
A collection of compilers based around compiling a high level language to a Brainfuck dialect.

tf A collection of compilers based around compiling a high level language to a Brainfuck dialect. Built at, and for, the VolHacks V hackathon during O

A high-level Rust crate around the Discord API, aimed to be easy and straight-forward to use.
A high-level Rust crate around the Discord API, aimed to be easy and straight-forward to use.

rs-cord A high-level Rust crate around the Discord API, aimed to be easy and straight-forward to use. Documentation • Crates.io • Discord Navigation M

High-level PortMidi bindings and wrappers for Rust

High-level PortMidi bindings and wrappers for Rust

An upper-level course for CS majors on formal languages theory and compilers.

CS4100 Introduction to Formal Languages and Compilers Spring 2022 An upper-level course for CS majors on formal languages theory and compilers. Topics

High-level, optionally asynchronous Rust bindings to llama.cpp

llama_cpp-rs Safe, high-level Rust bindings to the C++ project of the same name, meant to be as user-friendly as possible. Run GGUF-based large langua

Community SVD file, peripheral access crate in embedde Rust for WinnerMicro W800, W801 & W806 chip

Community SVD file, peripheral access crate in embedde Rust for WinnerMicro W800, W801 & W806 chip

RTIC monotonic implementation using the RP2040's Timer peripheral

rp2040-monotonic RTIC monotonic implementation using the RP2040's Timer peripheral. Documentation License Licensed under either of Apache License, Ver

Moca-hcho - Bluetooth 5 BLE formaldehyde/temperature/humidity sensor beacon
Moca-hcho - Bluetooth 5 BLE formaldehyde/temperature/humidity sensor beacon

moca-hcho: Bluetooth 5 BLE formaldehyde/temperature/humidity sensor beacon moca-hcho is a simple Bluetooth Low Energy sensor beacon that uses a Sensir

The hacker's BLE (bluetooth low energy) browser terminal app
The hacker's BLE (bluetooth low energy) browser terminal app

Blendr is a terminal UI app for browsing BLE (Bluetooth Low Energy) devices. It allows you to inspect, search, connect, and analyze data coming from B

HAL for the CH58x family of microcontrollers. BLE 5.3, RISC-V Qingke V4.

ch58x-hal HAL for the CH58x RISC-V BLE microcotrollers from WCH. This crate is under random and active development. DO NOT USE in production. This sho

Stack buffer provides alternatives to Buf{Reader,Writer} allocated on the stack instead of the heap.

StackBuf{Reader,Writer} Stack buffer provides alternatives to BufReader and BufWriter allocated on the stack instead of the heap. Its implementation i

The most primitive and the fastest implementation of a fixed-size last-in-first-out stack on stack in Rust, for Copy-implementing types

This is the simplest and the fastest (faster than Vec!) implementation of a last-in-first-out stack data structure, on stack, when stack elements are

A toy ray tracer in Rust
A toy ray tracer in Rust

tray_rust - A Toy Ray Tracer in Rust tray_rust is a toy physically based ray tracer built off of the techniques discussed in Physically Based Renderin

sublingual: toy versions of existing programming languages

sublingual: toy versions of existing programming languages This is a collection of toy languages created by taking much "larger" languages (e.g. Rust)

Milho (corn in portuguese) is a toy dialect of Lisp written as a way to learn more about compilers

Milho (corn in portuguese) is a toy dialect of Lisp written as a way to learn more about compilers. There are implementations in rust and go

Turbine is a toy CLI app for converting Rails schema declarations into equivalent type declarations in other languages.

Turbine Turbine is a toy CLI app for converting Rails schema declarations into equivalent type declarations in other languages. It’s described as a to

Toy language that output pseudocode, pascal and graphviz dot

pseudoc pseudoc is a project I made for school because we needed to write our programs in three different formats: Pascal, pseudocode (similar in stru

A super-lightweight Lua microservice (toy) framework.

Hive A super-lightweight microservice (toy) framework written in Rust. It uses Lua as interface to provide simple, fun developing experience and fast

Comments
  • Uuid128 off by 1 error in advertising data?

    Uuid128 off by 1 error in advertising data?

     let connector = esp_wifi::ble::controller::BleConnector {};
            let hci = HciConnector::new(connector, esp_wifi::current_millis);
            let service_uuid = Uuid::Uuid128([0x00, 0x00, 0xab, 0xf0, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb]);
            let mut ble = Ble::new(&hci);
            ble.init().unwrap();
            ble.cmd_set_le_advertising_parameters().unwrap();
            let advertising_data = create_advertising_data(&[
                AdStructure::Flags(LE_GENERAL_DISCOVERABLE | BR_EDR_NOT_SUPPORTED),
                AdStructure::ServiceUuids128(&[service_uuid]),
                AdStructure::CompleteLocalName("BLE_TO_ISOTP"),
            ]);
            ble.cmd_set_le_advertising_data(advertising_data).unwrap();
            ble.cmd_set_le_advertise_enable(true).unwrap();
    
    Brandons-MacBook-Air:esp32-isotp-ble-bridge-rs brandonros 2022-10-26 11:14:41 $ cargo run --release
    warning: Patch `embassy-embedded-hal v0.1.0 (https://github.com/embassy-rs/embassy#ce1cba76)` was not used in the crate graph.
    Check that the patched package version and available features are compatible
    with the dependency requirements. If the patch has a different version from
    what is locked in the Cargo.lock file, run `cargo update` to use the new
    version. This may also occur with an optional dependency that is not enabled.
       Compiling esp-wifi v0.1.0 (https://github.com/esp-rs/esp-wifi?branch=main#7adb1658)
       Compiling esp32_isotp_ble_bridge_rs v0.1.0 (/Users/brandonros/Desktop/esp32-isotp-ble-bridge-rs)
    warning: unused variable: `wdt`
       --> src/main.rs:146:13
        |
    146 |     let mut wdt = timer_group0.wdt;
        |             ^^^ help: if this is intentional, prefix it with an underscore: `_wdt`
        |
        = note: `#[warn(unused_variables)]` on by default
    
    warning: variable does not need to be mutable
       --> src/main.rs:146:9
        |
    146 |     let mut wdt = timer_group0.wdt;
        |         ----^^^
        |         |
        |         help: remove this `mut`
        |
        = note: `#[warn(unused_mut)]` on by default
    
    warning: static `CHANNEL` is never used
      --> src/main.rs:34:8
       |
    34 | static CHANNEL: StaticCell<Channel<NoopRawMutex, u32, 4>> = StaticCell::new();
       |        ^^^^^^^
       |
       = note: `#[warn(dead_code)]` on by default
    
    warning: static `TIMER0` is never used
      --> src/main.rs:36:8
       |
    36 | static TIMER0: Mutex<RefCell<Option<Timer<Timer0<TIMG0>>>>> = Mutex::new(RefCell::new(None));
       |        ^^^^^^
    
    warning: static `TIMER1` is never used
      --> src/main.rs:37:8
       |
    37 | static TIMER1: Mutex<RefCell<Option<Timer<Timer1<TIMG0>>>>> = Mutex::new(RefCell::new(None));
       |        ^^^^^^
    
    warning: static `SERIAL0` is never used
      --> src/main.rs:38:8
       |
    38 | static SERIAL0: Mutex<RefCell<Option<Serial<UART0>>>> = Mutex::new(RefCell::new(None));
       |        ^^^^^^^
    
    warning: function `receiver_task` is never used
      --> src/main.rs:40:10
       |
    40 | async fn receiver_task(receiver: Receiver<'static, NoopRawMutex, u32, 4>) {
       |          ^^^^^^^^^^^^^
    
    warning: function `sender_task` is never used
      --> src/main.rs:59:10
       |
    59 | async fn sender_task(sender: Sender<'static, NoopRawMutex, u32, 4>) {
       |          ^^^^^^^^^^^
    
    warning: `esp32_isotp_ble_bridge_rs` (bin "esp32_isotp_ble_bridge_rs") generated 8 warnings
        Finished release [optimized] target(s) in 1.44s
         Running `espflash --monitor /dev/tty.usbserial-02728E37 --monitor-speed 115200 target/xtensa-esp32-none-elf/release/esp32_isotp_ble_bridge_rs`
    Serial port: /dev/tty.usbserial-02728E37
    Connecting...
    
    Chip type:         ESP32 (revision 3)
    Crystal frequency: 40MHz
    Flash size:        16MB
    Features:          WiFi, BT, Dual Core, 240MHz, Coding Scheme None
    MAC address:       94:b9:7e:57:4b:18
    App/part. size:    295984/16711680 bytes, 1.77%
    [00:00:01] ########################################      16/16      segment 0x1000                                                                                                                                                                                                                                                                                                                                                                 
    [00:00:00] ########################################       1/1       segment 0x8000                                                                                                                                                                                                                                                                                                                                                                 
    [00:00:16] ########################################     156/156     segment 0x10000                                                                                                                                                                                                                                                                                                                                                                
    Flashing has completed!
    Commands:
        CTRL+R    Reset chip
        CTRL+C    Exit
    
    ets Jul 29 2019 12:21:46
    rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
    configsip: 0, SPIWP:0xee
    clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
    mode:DIO, clock div:2
    load:0x3fff0048,len:12
    ho 0 tail 12 room 4
    load:0x3fff0054,len:4800
    load:0x40078000,len:17448
    0x40078000 - r_rwip_reset
        at ??:??
    load:0x4007c428,len:4840
    0x4007c428 - r_rwip_reset
        at ??:??
    entry 0x4007c6a0
    0x4007c6a0 - r_rwip_reset
        at ??:??
    WARN - coex_register_bt_cb 0x40081698
    0x40081698 - coex_bt_callback
        at ??:??
    WARN - coex_schm_register_btdm_callback 0x400df7dc
    0x400df7dc - coex_schm_btdm_callback
        at ??:??
    WARN - coex_wifi_channel_get
     
     
    !! A panic occured in '/Users/brandonros/.rustup/toolchains/esp/lib/rustlib/src/rust/library/core/src/slice/index.rs', at line 73, column 5
     
    PanicInfo {
        payload: Any { .. },
        message: Some(
            range end index 129 out of range for slice of length 128,
        ),
        location: Location {
            file: "/Users/brandonros/.rustup/toolchains/esp/lib/rustlib/src/rust/library/core/src/slice/index.rs",
            line: 73,
            col: 5,
        },
        can_unwind: true,
    }
     
    Backtrace:
     
    0x400dc009
    0x400dc009 - _ZN4core3ops8function6FnOnce9call_once17hf83c65e1c5683b9fE
        at ??:??
    0x400dc039
    0x400dc039 - _ZN4core10intrinsics17const_eval_select17h2e98052629cb9109E
        at ??:??
    0x400dc095
    0x400dc095 - _ZN4core5slice5index24slice_end_index_len_fail17h1a7d586e621fc8b7E
        at ??:??
    0x400d7fca
    0x400d7fca - _ZN5bleps12ad_structure23create_advertising_data17ha24b1c7a30ebd68cE
        at ??:??
    0x400d14ae
    0x400d14ae - _ZN97_$LT$core..future..from_generator..GenFuture$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$4poll17h4c7b5d09e6303bf8E
        at ??:??
    0x400d1c1c
    0x400d1c1c - _ZN16embassy_executor3raw20TaskStorage$LT$F$GT$4poll17h57ceb5a97861a96dE.llvm.11765450987655502707
        at ??:??
    0x400f7e27
    0x400f7e27 - _ZN16embassy_executor3raw8Executor4poll17hb27cb61edfd0c27cE
        at ??:??
    0x400d1c88
    0x400d1c88 - _ZN16embassy_executor4arch8Executor3run17h50320a162ae4a970E
        at ??:??
    0x400d1e45
    0x400d1e45 - main
        at ??:??
    0x400d947a
    0x400d947a - Reset
        at ??:??
    
    opened by brandonros 2
  • notify characteristic not supported

    notify characteristic not supported

        this.dataNotifyCharacteristic.startNotifications()
        this.dataNotifyCharacteristic.addEventListener('characteristicvaluechanged', (event) => {
          const value = event.target.value
          const payload = Buffer.from(value.buffer)
           ...
    

    is GATT characteristic value changing supported?

    ble.cmd_set_le_advertising_data(create_advertising_data(&[
                AdStructure::Flags(LE_GENERAL_DISCOVERABLE | BR_EDR_NOT_SUPPORTED),
                AdStructure::ServiceUuids16(&[
                    Uuid::Uuid16(0x1809)
                ]),
                AdStructure::CompleteLocalName("BLE_TO_ISOTP"),
            ])).unwrap();
    

    am I setting something wrong here?

    opened by brandonros 1
Owner
Björn Quentin
💖 Rust everywhere 💖
Björn Quentin
The most primitive and the fastest implementation of a fixed-size last-in-first-out stack on stack in Rust, for Copy-implementing types

This is the simplest and the fastest (faster than Vec!) implementation of a last-in-first-out stack data structure, on stack, when stack elements are

Yegor Bugayenko 10 Jun 18, 2023
Milho (corn in portuguese) is a toy dialect of Lisp written as a way to learn more about compilers

Milho (corn in portuguese) is a toy dialect of Lisp written as a way to learn more about compilers. There are implementations in rust and go

Celso Bonutti 27 May 4, 2022
JIT compiler and runtime for a toy language, using Cranelift

Hello! This is a simple demo that JIT-compiles a toy language, using Cranelift. It uses the new JIT interface in development here. JIT takes care of m

Bytecode Alliance 468 Jan 7, 2023
Payments Engine is a simple toy payments engine

Payments Engine is a simple toy payments engine that reads a series of transactions from a CSV, updates client accounts, handles disputes and chargebacks, and then outputs the state of clients accounts as a CSV.

Bogdan Arabadzhi 0 Feb 3, 2022
Toy: Layout-Engine

Toy: Layout-Engine

Oanakiaja 5 Mar 29, 2022
Ruxnasm is an assembler for Uxntal — a programming language for the Uxn stack-machine by Hundred Rabbits

Ruxnasm is an assembler for Uxntal — a programming language for the Uxn stack-machine by Hundred Rabbits. Ruxnasm strives to be an alternative to Uxnasm, featuring more user-friendly error reporting, warnings, and helpful hints, reminiscent of those seen in modern compilers for languages such as Rust or Elm.

Karol Belina 44 Oct 4, 2022
The language that eats the stack. Heavily inspired by porth which is inspired off of forth

Snack The language that eats the stack. Heavily inspired by porth which is inspired off of forth Install To use Snack you will need Rust and fasm Afte

Cowboy8625 2 Mar 20, 2022
Symbolically Executable Stack Machines in Rust

Symbolically Executable Stack Machines in Rust Symbolic Stack Machines is a library for implementing symbolically executable stack-based virtual machi

TannrA 64 Dec 28, 2022
Source code and documentation for our 'full stack on rust' meetup on 29-9-2022

Full stack on Rust This is the code and documentation repository for our 'Full stack on Rust' meetup on 29-9-2022. It includes step-by-step documentat

Baseflow 7 Oct 23, 2022
Open Source Application Stack & PaaS

mycelia Open Source Application Stack & PaaS Installation cargo xtask build NOTE: We opted for cargo-xtask because Cargo build.rs is not supported for

Mycelia 3 Sep 6, 2023