nRF51 SDK - S110 SoftDevice
|
The Heart Rate Application is a firmware example that implements the Heart Rate profile using the Nordic nRF51822 evaluation board.
The source code and project file can be found in the <InstallFolder>\Nordic\nrf51822\Board\pca10001\s110\ble_app_hrs
folder.
The application includes the three services in the Heart Rate profile:
In addition, the use of the ADC to measure the battery level is also demonstrated.
When the application starts, two timers are started which control when the heart rate value and battery level should be sent.
Heart rate measurement:
When the peer has enabled notification for heart rate, the application starts sending heart rate with a value that is average of MIN_HEART_RATE and MAX_HEART_RATE defined in main.c. When Button 0 is pressed, the heart rate is incremented by HEART_RATE_CHANGE (defined in main.c). When Button 1 is pressed, the heart rate is decremented by HEART_RATE_CHANGE. If the user presses a button more than once within the time defined by HEART_RATE_MEAS_INTERVAL (in main.c), then the heart rate shall be incremented/decremented that many times before the next notification is sent.
Battery level measurement:
When the peer has enabled notification for Battery Level, the application begins sending the battery level as notifications. Note that the measurement is made every 2 seconds. But as per the Battery Service Specification, the notification of battery level will be sent only if the it has changed.
The ADC is used to measure the battery level. Every time a new battery measurement has to be sent, a fresh measurement is made.
Compiler Optimization:
This example is optimized for reduced power consumption. Therefore the default optimization level for this example application is 'Level 3', (-O3
) and 'Optimize for Time', (-Otime
). If the Keil debugger is needed for debugging purposes, then the optimization level should be changed to 'Level 0', (-O0
) and 'Optimize for Time' should be removed in order to ease the use of the debugger.
LED assignments:
Buttons assignments:
The Heart Rate Application can be tested using the "nRF Toolbox" app, available on both iOS (Apple Store) and Android (Google Play).
It can also be tested using the Master Control Panel as follows: