nRF5 SDK v12.1.0
Apple Notification Center Service (ANCS) Client Application
This example requires one of the following SoftDevices: S130, S132

Important: Before you run this example, make sure to program the SoftDevice.

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

You can find the source code and the project file of the example in the following folder: <InstallFolder>\examples\ble_peripheral\ble_app_ancs_c

Button assignments - in addition to those defined in BSP BLE Button Assignments:

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:

  1. Start a terminal emulator like PuTTY and connect to the used COM port with the following UART settings:
    • Baud rate: 115.200
    • 8 data bits
    • 1 stop bit
    • No parity
    • HW flow control: RTS/CTS
  2. Compile and program the application. Observe that the BSP_INDICATE_ADVERTISING state is indicated.
  3. Select the device in the iOS settings -> Bluetooth menu and connect.
  4. Observe that the BSP_INDICATE_CONNECTED state is indicated.
  5. 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:

  1. Start a terminal emulator like PuTTY and connect to the used COM port with the following UART settings:
    • Baud rate: 115.200
    • 8 data bits
    • 1 stop bit
    • No parity
    • HW flow control: RTS/CTS
  2. Compile and program the application. Observe that the BSP_INDICATE_ADVERTISING state is indicated.
  3. 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. Load the file ANCS_central.bin.
    • Stop the server, and then start it again.
    • You must keep the Server setup window open.
  4. Select the device from Master Control Panel (the device will be advertising as 'ANCS').
  5. Connect and bond.
  6. Observe that the BSP_INDICATE_CONNECTED state is indicated.
  7. Observe that the server is started.
  8. After bonding, verify in the Server setup that the Client Characteristic Configuration descriptors (CCCD) for 0x120D and 0xC6E9 are set to 0001.
  9. 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.
  10. Verify that the UART data is received as follows:
    Notification
    Event:       Added
    Category ID: Email
    Category Cnt:2
    UID:         67305985
    Flags:
     Silent
    
  11. Press Button 2 to request notification attributes for the iOS notification received before.
  12. 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.
  13. 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.
  14. Verify that the UART data is received as follows:
    Title: nRF
    Message: 422
    
  15. Disconnect from the Master Control Panel and observe that the BSP_INDICATE_ADVERTISING_WHITELIST state is indicated.
  16. Wait until the application goes to system-off (BSP_INDICATE_IDLE).
  17. Press Button 1 and connect to the Master Control Panel. Observe that the BSP_INDICATE_CONNECTED state is indicated.
  18. Disconnect from the Master Control Panel.

Documentation feedback | Developer Zone | Subscribe | Updated