Giter Site home page Giter Site logo

shentqlf / esp32-ancs-notifications Goto Github PK

View Code? Open in Web Editor NEW

This project forked from smartphone-companions/esp32-ancs-notifications

0.0 0.0 0.0 59 KB

Easy-to-use Arduino library for interfacing an ESP 32 with Bluetooth LE ANCS mobile device notifications.

License: GNU General Public License v3.0

C++ 100.00%

esp32-ancs-notifications's Introduction

arduino-library-badge

ESP32 ANCS Notifications

Easy-to-use Arduino library for interfacing an ESP 32 with Bluetooth LE mobile device notifications.

This library is designed to follow the standard Arduino library style, and be as easy to use and clear as possible for non-programmers (i.e. no lambda functions, threads, new C++ language features, etc.)

Features

  • Support notifications on your device with a few lines of Arduino code.
  • Easily start re-advertising the ESP 32 device if BLE connection is lost.
  • Apple ANCS notification support, with advanced message details.
  • Use actions to accept or reject incoming calls.

Installation

ESP-32 Core Library

You need to install the ESP32 core libraries. If you are getting build errors, it's possible you have an old version of the core libraries without BLE support. The install instructions for your specific OS are here: https://github.com/espressif/arduino-esp32

Using Arduino Library Manager

From Arduino IDE, go to menu Sketch -> Include Library -> Manage Libraries... In Library Manager Window, search "ANCS" in the search form then select "ESP32 BLE ANCS Notifications" Click "Install" button.

Manual installation

Download zip file from this repository by selecting the green "Code" dropdown at the top of repository, select "Download ZIP" From Arduino IDE, select menu Sketch -> Include Library -> Add .ZIP Library...

Or use git:

cd ~/arduino/libraries/
git clone [email protected]:Smartphone-Companions/ESP32-ANCS-Notifications.git

Then you should see the examples and be able to include the library in your projects with:

 #include "esp32notifications.h"

OSX Troubleshooting

Usage

This works like a standard Arduino library. Here's a minimal example:

// Create an interface to the BLE notification library at the top of your sketch
BLENotifications notifications;

// Start looking for a device connection
notifications.begin("BLEConnection device name");

// This callback will be called when a Bluetooth LE connection is made or broken.
// You can update the ESP 32's UI or take other action here.
void onBLEStateChanged(BLENotifications::State state) {
  switch(state) {
      case BLENotifications::StateConnected:
          Serial.println("StateConnected - connected to a phone or tablet"); 
          break;

      case BLENotifications::StateDisconnected:
          Serial.println("StateDisconnected - disconnected from a phone or tablet"); 
          notifications.startAdvertising(); 
          break; 
  }
}

// Setup a callback for when a notification arrives
void onNotificationArrived(const ArduinoNotification * notification, Notification * rawData) {
    Serial.println(notification->title);
}

// Register the callback to be informed when a notification arrives
notifications.setConnectionStateChangedCallback(onBLEStateChanged);
notifications.setNotificationCallback(onNotificationArrived);

Note that the Espressif BLE libraries are very large, so you may need to increase your partition scheme to "Large" in the Arduino IDE.

See the ble_connection example for a more fully-featured example.

History / Acknowledgements

Based on the work of CarWatch, Hackwatch, and S-March. This project was created to hide the complicated BLE notification internals behind a standard, easy-to-use Arduino library.

To see a real-world project, https://github.com/jhud/hackwatch uses this library.

esp32-ancs-notifications's People

Contributors

alainbellet avatar jhud avatar m-hertig avatar sirfragles avatar

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.