Giter Site home page Giter Site logo

eagi223 / esp-idf_bluetooth_multi-service Goto Github PK

View Code? Open in Web Editor NEW
62.0 5.0 10.0 42 KB

A modularized, simplified template for adding Bluetooth LE with multiple services to an ESP32 project using the ESP-IDF

License: Apache License 2.0

CMake 0.39% Makefile 1.53% C 98.08%
esp-idf bluetooth-low-energy gatt-server esp32 ble espressif

esp-idf_bluetooth_multi-service's Introduction

This goal for this project is to provide a template for modular, quick and easy BLE Gatt Server development on the ESP32 using the ESP IDF. To facilitate this, the ble service table example from the ESP IDF was modified and broken into four main sections. This example should run without any need for edits.

Requirements:

  • min 4mb ram configured in make menuconfig/Serial flasher config/Flash size
  • ble enabled in make menuconfig/Component config/Bluetooth/Bluetooth
  • min ESP-IDF v3.0 (should work, but have only tested on v3.1 beta)

This is a work in progress and was just quickly thrown together and generalized from code in another project! I'm not currently focusing a lot of time on it, but more adding to it as I fine tune the files in projects that I'm currently using this structure in.

Feel free to PR the repo. I'll try to get changes merged quickly.

Special thanks to Jesse Bahr who originally seperated out the interface/gatts/gap.

Future Development:

  • Add BLE Notify/Indicate
  • Add comments/documentation throughout
  • Add Doxygen support
  • General Cleanup

Main Sections:

ble_interface - This provides the only calls you will need to enable/disable Bluetooth LE. Calling ble_interface_init() sets up the bluetooth hardware, gap, and gatt server then begins the advertising process. ble_interface_deinit() nicely shuts down Bluetooth and performs all the ESP IDF suggested calls to deallocate resources.

ble_gap - This manages the Bluetooth advertising setup and data. This is the source file you would edit to change the advertising name, data, and settings. No need to call the init/deinit functions. ble_interface takes care of that for you.

ble_gatt_server - This manages the Bluetooth server handling. You will need to edit the commented areas in the gatts_profile_event_handler() function to add new services.

ble_services - This directory contains a template file for a service. This template provides a quick and easy example that creates a services with characteristics that can be read from/written to.

esp-idf_bluetooth_multi-service's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

esp-idf_bluetooth_multi-service's Issues

release classic bt memory

I suggest

ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));

should be done before initializing BLE, otherwise I ran out of RAM (4Meg RAM)

Clarification on ESP_GATT_AUTO_RSP/ESP_GATT_RSP_BY_APP

Hi,
Thank you for your code, I started from that to build my BLE section.
I'm confused about the different behavior of ESP_GATT_AUTO_RSP/ESP_GATT_RSP_BY_APP.
If I use ESP_GATT_AUTO_RSP in read and write, the stack works for us and automatically send responses, but are the ESP_GATTS_[READ|WRITE|EXEC_WRITE]_EVT still triggered after?
If yes, in your code you however send responses and manage read and write with your functions, but aren't them a duplicate of what the stack already done? How do you recognize if an attribute is managed by the stack or not?
Thank you for your help!

document support for long read

I see there is support for long write (prepare/exec write) and it works with Android. But I also need long read. It seems the example is missing the logic to split-up a read.

(I know this example is based off ESP-IDF example- which is also missing the long read https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/gatt_server_service_table )

Here's an implementation in C++.
https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/BLECharacteristic.cpp#L348 I am trying to use it as a guide to implement into this c project structure.

Please let me know if it's already been done or there is a better way.

Thanks!

@eagi223 @phatpaul, this example really helped clear up how to get multiple services running on the ESP32. Thanks for putting this out in the open for everyone to learn from!

(P.s. no issue! Finally settled on an issue as the best way to say thanks, feel free to close immediately)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.