Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions API.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# BLEPeripheral
# BLEPeripheralObserver

## Constructor
Creates the BLEPeripheral object. Pin Arguments are optional as pins are self detecting. See https://github.com/sandeepmistry/arduino-BLEPeripheral#pinouts
Creates the BLEPeripheralObserver object. Pin Arguments are optional as pins are self detecting. See https://github.com/sandeepmistry/arduino-BLEPeripheral#pinouts

```c
BLEPeripheral(unsigned char req = BLE_DEFAULT_REQ, unsigned char rdy = BLE_DEFAULT_RDY, unsigned char rst = BLE_DEFAULT_RST);
BLEPeripheralObserver(unsigned char req = BLE_DEFAULT_REQ, unsigned char rdy = BLE_DEFAULT_RDY, unsigned char rst = BLE_DEFAULT_RST);
```
* req - REQ pin
* rdy - RDY pin
Expand Down Expand Up @@ -45,7 +45,7 @@ void setAdvertisingInterval(unsigned short advertisingInterval);
Sets the connection interval to use after a connection has been established.

```c
void setConnectionInterval(unsigned short minimumConnectionInterval, unsigned short maximumConnectionInterval);
void setConnectionInterval(unsigned short minimumConnectionInterval, unsigned short maximumConnectionInterval);
```

* minimumConnectionInterval - minimum connection interval in 1.25 ms increments
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Arduino BLEPeripheral
# Arduino BLEPeripheralObserver

[![Build Status](https://travis-ci.org/sandeepmistry/arduino-BLEPeripheral.svg?branch=master)](https://travis-ci.org/sandeepmistry/arduino-BLEPeripheral) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/sandeepmistry/arduino-BLEPeripheral?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Expand All @@ -15,7 +15,7 @@ This is heavily based on @sandeepmistry's [arduino-BLEPeripheral](https://github
* [nRF51822](http://redbearlab.com/redbearlab-nrf51822)
* [BLE Nano](http://redbearlab.com/blenano/)
* [RFduino](http://www.rfduino.com) with [Arduino Add-on](https://github.com/RFduino/RFduino)

**WARNING**: Adafruit nRF51 boards are **NOT** compatible with this library, this includes the [Bluefruit LE UART Friend](https://www.adafruit.com/products/2479), [Bluefruit LE SPI Friend](https://www.adafruit.com/products/2633), [Bluefruit LE Shield](https://www.adafruit.com/products/2746), [Flora Wearable Bluefruit LE Module](https://www.adafruit.com/products/2487), [Feather 32u4 Bluefruit LE](https://www.adafruit.com/products/2829), and [Feather M0 Bluefruit LE](https://www.adafruit.com/products/2995).

### Nordic Semiconductor nRF51 or nRF52 based boards
Expand Down
2 changes: 1 addition & 1 deletion examples/HID/HID_joystick_mouse/HID_joystick_mouse.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Sandeep Mistry. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

// Import libraries (BLEPeripheral depends on SPI)
// Import libraries (BLEPeripheralObserver depends on SPI)
#include <SPI.h>
#include <BLEHIDPeripheral.h>
#include <BLEMouse.h>
Expand Down
2 changes: 1 addition & 1 deletion examples/HID/HID_keyboard/HID_keyboard.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Sandeep Mistry. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

// Import libraries (BLEPeripheral depends on SPI)
// Import libraries (BLEPeripheralObserver depends on SPI)
#include <SPI.h>
#include <BLEHIDPeripheral.h>
#include <BLEKeyboard.h>
Expand Down
2 changes: 1 addition & 1 deletion examples/HID/HID_keypad/HID_keypad.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Sandeep Mistry. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

// Import libraries (BLEPeripheral depends on SPI)
// Import libraries (BLEPeripheralObserver depends on SPI)
#include <SPI.h>
#include <BLEHIDPeripheral.h>
#include <BLEKeyboard.h>
Expand Down
2 changes: 1 addition & 1 deletion examples/HID/HID_test/HID_test.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Sandeep Mistry. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

// Import libraries (BLEPeripheral depends on SPI)
// Import libraries (BLEPeripheralObserver depends on SPI)
#include <SPI.h>
#include <BLEHIDPeripheral.h>
#include <BLEMouse.h>
Expand Down
2 changes: 1 addition & 1 deletion examples/HID/HID_volume/HID_volume.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Sandeep Mistry. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

// Import libraries (BLEPeripheral depends on SPI)
// Import libraries (BLEPeripheralObserver depends on SPI)
#include <SPI.h>
#include <BLEHIDPeripheral.h>
#include <BLEMultimedia.h>
Expand Down
38 changes: 19 additions & 19 deletions examples/ancs/ancs.ino
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright (c) Sandeep Mistry. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

// Import libraries (BLEPeripheral depends on SPI)
// Import libraries (BLEPeripheralObserver depends on SPI)
#include <SPI.h>
#include <BLEPeripheral.h>
#include <BLEPeripheralObserver.h>

#include <BLEUtil.h>

//custom boards may override default pin definitions with BLEPeripheral(PIN_REQ, PIN_RDY, PIN_RST)
BLEPeripheral blePeripheral = BLEPeripheral();
//custom boards may override default pin definitions with BLEPeripheralObserver(PIN_REQ, PIN_RDY, PIN_RST)
BLEPeripheralObserver blePeriphObserv = BLEPeripheralObserver();
BLEBondStore bleBondStore;

// remote services
Expand All @@ -29,38 +29,38 @@ void setup() {
// clears bond data on every boot
bleBondStore.clearData();

blePeripheral.setBondStore(bleBondStore);
blePeriphObserv.setBondStore(bleBondStore);

blePeripheral.setServiceSolicitationUuid(ancsService.uuid());
blePeripheral.setLocalName("ANCS");
blePeriphObserv.setServiceSolicitationUuid(ancsService.uuid());
blePeriphObserv.setLocalName("ANCS");

// set device name and appearance
blePeripheral.setDeviceName("Arduino ANCS");
blePeripheral.setAppearance(0x0080);
blePeriphObserv.setDeviceName("Arduino ANCS");
blePeriphObserv.setAppearance(0x0080);

blePeripheral.addRemoteAttribute(ancsService);
blePeripheral.addRemoteAttribute(ancsNotificationSourceCharacteristic);
// blePeripheral.addRemoteAttribute(ancsControlPointCharacteristic);
// blePeripheral.addRemoteAttribute(ancsDataSourceCharacteristic);
blePeriphObserv.addRemoteAttribute(ancsService);
blePeriphObserv.addRemoteAttribute(ancsNotificationSourceCharacteristic);
// blePeriphObserv.addRemoteAttribute(ancsControlPointCharacteristic);
// blePeriphObserv.addRemoteAttribute(ancsDataSourceCharacteristic);

// assign event handlers for connected, disconnected to peripheral
blePeripheral.setEventHandler(BLEConnected, blePeripheralConnectHandler);
blePeripheral.setEventHandler(BLEDisconnected, blePeripheralDisconnectHandler);
blePeripheral.setEventHandler(BLEBonded, blePeripheralBondedHandler);
blePeripheral.setEventHandler(BLERemoteServicesDiscovered, blePeripheralRemoteServicesDiscoveredHandler);
blePeriphObserv.setEventHandler(BLEConnected, blePeripheralConnectHandler);
blePeriphObserv.setEventHandler(BLEDisconnected, blePeripheralDisconnectHandler);
blePeriphObserv.setEventHandler(BLEBonded, blePeripheralBondedHandler);
blePeriphObserv.setEventHandler(BLERemoteServicesDiscovered, blePeripheralRemoteServicesDiscoveredHandler);

// assign event handlers for characteristic
ancsNotificationSourceCharacteristic.setEventHandler(BLEValueUpdated, ancsNotificationSourceCharacteristicValueUpdated);
// ancsDataSourceCharacteristic.setEventHandler(BLEValueUpdated, ancsDataSourceCharacteristicCharacteristicValueUpdated);

// begin initialization
blePeripheral.begin();
blePeriphObserv.begin();

Serial.println(F("BLE Peripheral - ANCS"));
}

void loop() {
blePeripheral.poll();
blePeriphObserv.poll();
}

void blePeripheralConnectHandler(BLECentral& central) {
Expand Down
2 changes: 1 addition & 1 deletion examples/iBeacon/iBeacon.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Sandeep Mistry. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#include <BLEPeripheral.h>
#include <BLEPeripheralObserver.h>
#include <iBeacon.h>

#if !defined(NRF51) && !defined(NRF52) && !defined(__RFduino__)
Expand Down
26 changes: 13 additions & 13 deletions examples/ir_bridge/ir_bridge.ino
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Sandeep Mistry. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

// Import libraries (BLEPeripheral depends on SPI)
// Import libraries (BLEPeripheralObserver depends on SPI)
#include <SPI.h>
#include <BLEPeripheral.h>
#include <BLEPeripheralObserver.h>

// https://github.com/shirriff/Arduino-IRremote
#include <IRremote.h>
Expand All @@ -25,8 +25,8 @@ IRsend irSend = IRsend(/*IR_SEND_
IRrecv irRecv = IRrecv(IR_RECV_PIN);
IRValue irValue;

//custom boards may override default pin definitions with BLEPeripheral(PIN_REQ, PIN_RDY, PIN_RST)
BLEPeripheral blePeripheral = BLEPeripheral();
//custom boards may override default pin definitions with BLEPeripheralObserver(PIN_REQ, PIN_RDY, PIN_RST)
BLEPeripheralObserver blePeriphObserv = BLEPeripheralObserver();

// create service and characteristics
BLEService irService = BLEService("00004952-0000-bbbb-0123-456789abcdef");
Expand All @@ -38,20 +38,20 @@ void setup() {
Serial.begin(115200);

// set advertised local name and service UUID
blePeripheral.setLocalName("IR");
blePeripheral.setAdvertisedServiceUuid(irService.uuid());
blePeriphObserv.setLocalName("IR");
blePeriphObserv.setAdvertisedServiceUuid(irService.uuid());

// add service and characteristics
blePeripheral.addAttribute(irService);
blePeripheral.addAttribute(irOutputCharacteristic);
blePeripheral.addAttribute(irInputCharacteristic);
blePeriphObserv.addAttribute(irService);
blePeriphObserv.addAttribute(irOutputCharacteristic);
blePeriphObserv.addAttribute(irInputCharacteristic);

// assign event handlers for connected, disconnected to peripheral
blePeripheral.setEventHandler(BLEConnected, blePeripheralConnectHandler);
blePeripheral.setEventHandler(BLEDisconnected, blePeripheralDisconnectHandler);
blePeriphObserv.setEventHandler(BLEConnected, blePeripheralConnectHandler);
blePeriphObserv.setEventHandler(BLEDisconnected, blePeripheralDisconnectHandler);

// begin initialization
blePeripheral.begin();
blePeriphObserv.begin();

Serial.println(F("BLE IR Peripheral"));

Expand All @@ -63,7 +63,7 @@ void setup() {

void loop() {
// poll peripheral
blePeripheral.poll();
blePeriphObserv.poll();

// poll the ouput characteristic
pollIrOutput();
Expand Down
20 changes: 10 additions & 10 deletions examples/led/led.ino
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Copyright (c) Sandeep Mistry. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

// Import libraries (BLEPeripheral depends on SPI)
// Import libraries (BLEPeripheralObserver depends on SPI)
#include <SPI.h>
#include <BLEPeripheral.h>
#include <BLEPeripheralObserver.h>

// LED pin
#define LED_PIN 3

//custom boards may override default pin definitions with BLEPeripheral(PIN_REQ, PIN_RDY, PIN_RST)
BLEPeripheral blePeripheral = BLEPeripheral();
//custom boards may override default pin definitions with BLEPeripheralObserver(PIN_REQ, PIN_RDY, PIN_RST)
BLEPeripheralObserver blePeriphObserv = BLEPeripheralObserver();

// create service
BLEService ledService = BLEService("19b10000e8f2537e4f6cd104768a1214");
Expand All @@ -27,21 +27,21 @@ void setup() {
pinMode(LED_PIN, OUTPUT);

// set advertised local name and service UUID
blePeripheral.setLocalName("LED");
blePeripheral.setAdvertisedServiceUuid(ledService.uuid());
blePeriphObserv.setLocalName("LED");
blePeriphObserv.setAdvertisedServiceUuid(ledService.uuid());

// add service and characteristic
blePeripheral.addAttribute(ledService);
blePeripheral.addAttribute(switchCharacteristic);
blePeriphObserv.addAttribute(ledService);
blePeriphObserv.addAttribute(switchCharacteristic);

// begin initialization
blePeripheral.begin();
blePeriphObserv.begin();

Serial.println(F("BLE LED Peripheral"));
}

void loop() {
BLECentral central = blePeripheral.central();
BLECentral central = blePeriphObserv.central();

if (central) {
// central connected to peripheral
Expand Down
24 changes: 12 additions & 12 deletions examples/led_callback/led_callback.ino
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Copyright (c) Sandeep Mistry. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

// Import libraries (BLEPeripheral depends on SPI)
// Import libraries (BLEPeripheralObserver depends on SPI)
#include <SPI.h>
#include <BLEPeripheral.h>
#include <BLEPeripheralObserver.h>

// LED pin
#define LED_PIN 3

//custom boards may override default pin definitions with BLEPeripheral(PIN_REQ, PIN_RDY, PIN_RST)
BLEPeripheral blePeripheral = BLEPeripheral();
//custom boards may override default pin definitions with BLEPeripheralObserver(PIN_REQ, PIN_RDY, PIN_RST)
BLEPeripheralObserver blePeriphObserv = BLEPeripheralObserver();

// create service
BLEService ledService = BLEService("19b10000e8f2537e4f6cd104768a1214");
Expand All @@ -27,29 +27,29 @@ void setup() {
pinMode(LED_PIN, OUTPUT);

// set advertised local name and service UUID
blePeripheral.setLocalName("LED");
blePeripheral.setAdvertisedServiceUuid(ledService.uuid());
blePeriphObserv.setLocalName("LED");
blePeriphObserv.setAdvertisedServiceUuid(ledService.uuid());

// add service and characteristic
blePeripheral.addAttribute(ledService);
blePeripheral.addAttribute(switchCharacteristic);
blePeriphObserv.addAttribute(ledService);
blePeriphObserv.addAttribute(switchCharacteristic);

// assign event handlers for connected, disconnected to peripheral
blePeripheral.setEventHandler(BLEConnected, blePeripheralConnectHandler);
blePeripheral.setEventHandler(BLEDisconnected, blePeripheralDisconnectHandler);
blePeriphObserv.setEventHandler(BLEConnected, blePeripheralConnectHandler);
blePeriphObserv.setEventHandler(BLEDisconnected, blePeripheralDisconnectHandler);

// assign event handlers for characteristic
switchCharacteristic.setEventHandler(BLEWritten, switchCharacteristicWritten);

// begin initialization
blePeripheral.begin();
blePeriphObserv.begin();

Serial.println(F("BLE LED Peripheral"));
}

void loop() {
// poll peripheral
blePeripheral.poll();
blePeriphObserv.poll();
}

void blePeripheralConnectHandler(BLECentral& central) {
Expand Down
22 changes: 11 additions & 11 deletions examples/led_switch/led_switch.ino
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Copyright (c) Sandeep Mistry. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

// Import libraries (BLEPeripheral depends on SPI)
// Import libraries (BLEPeripheralObserver depends on SPI)
#include <SPI.h>
#include <BLEPeripheral.h>
#include <BLEPeripheralObserver.h>

// LED and button pin
#define LED_PIN 3
#define BUTTON_PIN 4

//custom boards may override default pin definitions with BLEPeripheral(PIN_REQ, PIN_RDY, PIN_RST)
BLEPeripheral blePeripheral = BLEPeripheral();
//custom boards may override default pin definitions with BLEPeripheralObserver(PIN_REQ, PIN_RDY, PIN_RST)
BLEPeripheralObserver blePeriphObserv = BLEPeripheralObserver();

// create service
BLEService ledService = BLEService("19b10010e8f2537e4f6cd104768a1214");
Expand All @@ -30,23 +30,23 @@ void setup() {
pinMode(BUTTON_PIN, INPUT);

// set advertised local name and service UUID
blePeripheral.setLocalName("LED Switch");
blePeripheral.setAdvertisedServiceUuid(ledService.uuid());
blePeriphObserv.setLocalName("LED Switch");
blePeriphObserv.setAdvertisedServiceUuid(ledService.uuid());

// add service and characteristics
blePeripheral.addAttribute(ledService);
blePeripheral.addAttribute(switchCharacteristic);
blePeripheral.addAttribute(buttonCharacteristic);
blePeriphObserv.addAttribute(ledService);
blePeriphObserv.addAttribute(switchCharacteristic);
blePeriphObserv.addAttribute(buttonCharacteristic);

// begin initialization
blePeripheral.begin();
blePeriphObserv.begin();

Serial.println(F("BLE LED Switch Peripheral"));
}

void loop() {
// poll peripheral
blePeripheral.poll();
blePeriphObserv.poll();

// read the current button pin state
char buttonValue = digitalRead(BUTTON_PIN);
Expand Down
Loading