mirror of
https://github.com/Smartphone-Companions/ESP32-ANCS-Notifications.git
synced 2025-01-22 11:28:29 +00:00
Added more complete example. Name change.
This commit is contained in:
parent
e9437983cb
commit
7f6709fb3c
19
README.md
19
README.md
@ -13,12 +13,12 @@ This library is designed to follow the standard Arduino library style, and be as
|
||||
|
||||
## Installation
|
||||
|
||||
Put the unzipped library code into your ~/arduino/libraries/ folder, under a ESP32NotificationsLib subfolder:
|
||||
Put the unzipped library code into your ~/arduino/libraries/ folder, under an ESP32-ANCS-Notifications subfolder:
|
||||
|
||||
Or use git:
|
||||
```
|
||||
cd ~/arduino/libraries/
|
||||
git clone git@github.com:Smartphone-Companions/ESP32NotificationsLib.git
|
||||
git clone git@github.com:Smartphone-Companions/ESP32-ANCS-Notifications.git
|
||||
```
|
||||
|
||||
Then you should see the examples and be able to include the library in your projects with:
|
||||
@ -43,6 +43,21 @@ 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 Notification * notification) {
|
||||
Serial.println(notification->title.c_str());
|
||||
|
Loading…
Reference in New Issue
Block a user