BLEAncs is a helper class that enables you to receive notifications from the Apple Notification Center Service from devices such as an iPhone or iPad. It can be used to receive alerts such as incoming or missed calls, email messages, or most alerts that appear on the mobile device's screen when locked.
API
Because the BLEAncs class is a work in progress, the latest public API for the BLEAncs helper class should be viewed here.
ANCS OLED Example
The ancs_oled example uses the Adafruit FeatherWing OLED to display any incoming alerts.
Sketch Requirements
In order to use this example sketch the following libraries must be installed on your system:
- Adafruit_GFX (Github source)
- Adafruit_SSD1306 (Github source)
- Version 0.6.0 or higher of the Bluefruit nRF52 BSP
Loading the Sketch
The ancs_oled sketch can be loaded via the examples menu under Peripheral > ancs_oled:
With the sketch loaded, you can build the firmware and then flash it to your device via the Upload button or menu option:
Once the sketch is running on the nRF52 Feather you can proceed with the one-time pairing process, described below.
Pairing to your Mobile Device
Before you can start receiving notifications, you will need to 'pair' the nRF52 Feather and the mobile device.
The pairing process causes a set of keys to be exchanged and stored on the two devices so that each side knows it is talking to the same device it originally bonded with, and preventing any devices in the middle from eavesdropping on potentially sensitive data.
The one-time pairing process is described below, and assumes you are already running the ancs_oled sketch on your nRF52 device.
1. In the Settings app go to Bluetooth:
2. Scroll to the bottom of the list of 'My Devices' and click on Bluefruit52 under Other Devices:
3. When the pairing dialog box comes up, click the Pair button:
4. Wait for the pairing process to complete, at which point Bluefruit52 should appear in the My Devices list with the Connected status:
Wait for Alerts
At this point, any alerts that the mobile device generates will be displayed on the OLED display along with the notification category and date:
Certain alerts (such as incoming calls) can also have actions associated with them, making use of the three buttons on the left-hand side of the display to decide which action to take.
In the ancs_oled example, we have a special section of code for incoming calls where you can accept or decline a call with an appropriate button press:
// Check buttons uint32_t presedButtons = readPressedButtons(); if ( myNotifs[activeIndex].ntf.categoryID == ANCS_CAT_INCOMING_CALL ) { /* Incoming call event * - Button A to accept call * - Button C to decline call */ if ( presedButtons & bit(BUTTON_A) ) { bleancs.actPositive(myNotifs[activeIndex].ntf.uid); } if ( presedButtons & bit(BUTTON_C) ) { bleancs.actNegative(myNotifs[activeIndex].ntf.uid); } }
Text editor powered by tinymce.