nRF51 SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Proximity Application

Proximity Application

The Proximity Application is a firmware example that implements the Proximity profile using the hardware delivered in the nRF51822 Development Kit. The Proximity profile alerts the user when connected devices are too far apart.

The source code and project file can be found in the <InstallFolder>\Nordic\nrf51822\Board\nrf6310\s110\ble_app_proximity folder.

The application includes all three services in the Proximity profile:

In addition, use of the Battery Service and Bonds and Persistent Data Manager are also demonstrated.

At each power up and disconnect, the Proximity Application will do 20 seconds of fast advertising with whitelist followed by 40 seconds of fast advertising without whitelist. It will then switch to slow advertising mode, and the Slow Advertising Mode LED (see below) is lit. When the link is lost, or when an alert is signaled using the Immediate Alert Service, an alert is indicated using the Mild Alert State LED or the High Alert State LED (see below), depending on the value of the Alert Level characteristic.

Note
This application is not power optimised!
  • The device will have to be in bonded state to change any characteristic in this application.
  • TX Power Level characteristic is not writable.
  • The application will stop advertising and go to system-off mode after
    • 3 minutes and 30 seconds, if no advertising with whitelist was done OR
    • 4 minutes, if advertising with whitelist was done.

      Push the button 0 restart advertising, or button 1 to erase all bonds and restart advertising.

  • Upon disconnecting a bonded connection, the application will advertise with whitelist for ADV_INTERVAL_FAST_PERIOD seconds. After this timeout the application will be able to bond to a new central.

Setup

Instructions on how to set up the nRFgo Motherboard: nRFgo Motherboard Setup (nRF6310).

LED assignments:

  • LED 0: Advertising
  • LED 1: Connected
  • LED 2: Mild alert state
  • LED 3: High alert state
  • LED 4: Slow advertising mode
  • LED 5: Immediate Alert Service has been discovered at the peer.
  • LED 6: Advertising with Whitelist.
  • LED 7: Asserted (i.e. an assert check in the application has failed)

Buttons assignments:

  • Button 0: Wake-up from system-off and restart advertising. In connected state, this button is used raise/clear High Alert to the central which has an Immediate Alert Service instance.
  • Button 1: Wake-up from system-off erase all bonds and restart advertising.

Testing

The Proximity Application can be tested using the nRFUtility iOS Demo App (listed as "nRFready Utility" on Apple Store) on an iPhone 4s or the 'new iPad' (running on iOS version 5 or higher). The Find Me locater functionality of this application can be tested with an iPhone running iOS version 6 or higher. Note: When testing the nRFUtility app on iOS6, it must be noted that when touching the 'Disconnect' button the iOS device will not disconnect immediately. This issue is not seen on iOS5.

This application (except the Find Me locater functionality) can also be tested using nRF Utility app for Android (listed as "nRF Utility" in Google play).

The Proximity Application can be tested using the Master Control Panel as follows:

  1. Compile and program the application. Observe that the Advertising LED is lit.
  2. Connect to the device from Master Control Panel (the device will be advertising as 'Nordic_Prox'), then bond and perform service discovery. Observe that the Connected LED is lit, and the Advertising LED is off.
  3. Set the AlertLevel characteristic in Immediate Alert Service to 1 (click the 'hex' radio button, enter '01' in the text box and click the 'Send update' button), and observe that the Mild alert state LED is lit.
  4. Change the AlertLevel value to 2, and observe that the High alert state LED is lit.
  5. Change the AlertLevel value to 0, and observe that none of the alert state LEDs is lit.
  6. Set the AlertLevel characteristic in Link Loss Service to 1.
  7. Simulate a link loss situation (by e.g. shielding the Master Emulator), and observe that both the Mild alert state and Advertising LEDs are lit, and the Connected LED is off.
  8. Reconnect, and observe that only the Connected LED is lit.
  9. Set the AlertLevel characteristic in Link Loss Service to 2.
  10. Simulate a link loss situation by e.g. disconnecting the Master Emulator, and observe that the High alert state and Advertising LEDs are lit, and the Connected LED is off.
  11. Reconnect, and observe that only the Connected LED is lit.
  12. Select the TxPowerLevel characteristic in TX Power Service, click the 'Read' button and verify that it was successfully read.
  13. Click the 'Enable services' button to start notification of Battery Level and observe that the battery level is notified periodically.
  14. Disconnect from the Master Control Panel and observe that the only the advertising LEDs are lit (first both advertising and whitelist LEDs, then only advertising LED, then both advertising and slow advertising mode LEDs).
  15. Wait until the application goes to system-off (all LEDs off).
  16. Press button 0 and connect to the Master Control Panel. Observe that Connected LED is lit and that the battery level is notified periodically.
  17. Disconnect from the Master Control Panel.
  18. Connect with a different central and bond and disconnect.
  19. Wait until the application goes to system-off (all LEDs off).
  20. Press button 0 and re-connect to the first Master Control Panel. Observe that Connected LED is lit and that the battery level is notified periodically.
  21. Disconnect from the Master Control Panel.
  22. Connect with the second central and observe that the link encryption is on and that the battery level is not notified.
  23. Disconnect from the second central and wait for the application to go to system-off.
  24. Press button 1 (erase bonds) and connect with the first Master Control Panel. Observe that the link encryption is OFF and that no notifications are received.
  25. Disconnect from Master Control Panel.

Testing Find Me locater (Immediate Alert Service Client) functionality:

  1. In the Master Control Panel create the Immediate Alert Service (IAS) server by doing the following steps:
    • Click File -> Server Setup. In the window that opened up, click File -> Load setup.
    • In the resulting window, navigate to ble_app_proximity folder and load the file named findMeMasterServer.bin.
    • Click 'Stop Server' button and then 'Start Server'. This would restart the server with Immediate Alert Service configured.
    • It is important to keep the 'Server Setup' window opened.
  2. Go to the Master Control Panel main window, and connect to the device.
  3. Observe that LED 5 is lit. This indicates that the Services and Characteristic discovery initiated by the device is complete and it has successfully discovered the IAS instance at the peer.
  4. Press button 0 and observe that the AlertLevel value at the 'Server setup' window of the Master Control Panel changes to 02. This indicates that the device was able to signal a High Alert to the central.
  5. Press button 0 again and observe that the AlertLevel value changes to 00. This indicates that the device was able to clear the High Alert previously signalled to the central.