The ANCS Client Application is an example that implements an Apple Notification Center Service client. This client receives iOS notifications and is therefore a Notification Consumer. It can be connected with a Notification Provider, typically an iPhone or some other Apple device, which functions as ANCS server.
For detailed information about the Apple Notification Center Service, see Apple's iOS Developer Library.
When the application is connected to a Notification Provider, it receives and prints incoming notifications on the UART. Pressing Button 2 requests the attributes of the last received notification. For example, if the notification indicates a new email, notification attributes contain the title, the message, the date, and so on. If any attributes are received, they are printed to the UART.
- Note
- This application is not power optimized!
-
The application will stop advertising after 3 minutes and go to system-off mode. Push Button 1 to restart advertising.
Setup
The name of the example is ble_app_ancs_s130_pca10028. If you are not using the Keil Pack Installer, you can find the source code and project file of the example in the following folder: <InstallFolder>\examples\ble_peripheral\ble_app_ancs
Button assignments - in addition to those defined in BSP BLE Button Assignments:
- During connection:
- Button 2: Send iOS notification message attributes (content) on UART.
Testing
The ANCS Client Application can be tested with an iOS device (for example, an iPhone) or by using Master Control Panel.
To test using an iPhone:
- Start a COM listener like PUTTY and connect to the used COM port with the following UART settings:
-
Baud rate: 115.200 (Note that this value differs from the baud rate used in most other examples.)
-
8 data bits
-
1 stop bit
-
No parity
-
HW flow control: RTS/CTS
- Compile and program the application. Observe that the BSP_INDICATE_ADVERTISING state is indicated.
- Select the device in the iOS settings -> Bluetooth menu and connect.
- Observe that the BSP_INDICATE_CONNECTED state is indicated.
- Observe that all notifications that are displayed in the iOS notification tab also show up on the UART from the device.
You can also test the application with the Master Control Panel by performing the following steps:
- Start a COM listener like PUTTY and connect to the used COM port with the following UART settings:
-
Baud rate: 115.200 (Note that this value differs from the baud rate used in most other examples.)
-
8 data bits
-
1 stop bit
-
No parity
-
HW flow control: RTS/CTS
- Compile and program the application. Observe that the BSP_INDICATE_ADVERTISING state is indicated.
- In the Master Control Panel, create the Apple Notification Center Service (ANCS) server by completing the following steps:
- Click File -> Server setup. In the window that opens up, click File -> Load setup.
- In the resulting window, navigate to the
<InstallFolder>\examples\ble_peripheral\ble_app_ancs_c
folder. If you are using Keil packs, this folder is located at <KeilFolder>\ARM\Pack\NordicSemiconductor\nRF_Examples\<version>\ble_peripheral\ble_app_ancs_c
. Load the file ANCS_central.bin
.
- Stop the server, and then start it again.
- You must keep the Server setup window open.
- Select the device from Master Control Panel (the device will be advertising as 'ANCS').
- Connect and bond.
- Observe that the BSP_INDICATE_CONNECTED state is indicated.
- Observe that the server is started.
- After bonding, verify in the Server setup that the Client Characteristic Configuration descriptors (CCCD) for 0x120D and 0xC6E9 are set to 0001.
- Send an iOS notification to the application: In the Server setup, set the value of Notification Source (characteristic 0x120D) to 00-01-06-02-01-02-03-04 and click Update.
- Verify that the UART data is received as follows:
Notification
Event: Added
Category ID: Email
Category Cnt:2
UID: 67305985
Flags:
Silent
- Press Button 2 to request notification attributes for the iOS notification received before.
- In the Server setup, verify that the CCCD for 0xD8F3 is updated to 00-01-02-03-04-01-20-00-02-20-00-03-20-00-04-05-06-07.
- Respond to the get attribute request by sending two notification attributes, Title and Message. To do this, set the Data Source (Characteristic 0xC6E9) in the Server setup to 00-01-02-03-04-01-03-00-6E-52-46-03-03-00-34-32-32.
- Verify that the UART data is received as follows:
Title: nRF
Message: 422
- Disconnect from the Master Control Panel and observe that the BSP_INDICATE_ADVERTISING_WHITELIST state is indicated.
- Wait until the application goes to system-off (BSP_INDICATE_IDLE).
- Press Button 1 and connect to the Master Control Panel. Observe that the BSP_INDICATE_CONNECTED state is indicated.
- Disconnect from the Master Control Panel.