mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-14 10:21:49 +00:00
heart rate server: docu
This commit is contained in:
parent
46e18d797d
commit
d5d6b232dd
@ -4,8 +4,8 @@ BTstack allows to implement and use GATT Services in a modular way.
|
||||
To use an already implemented GATT Service, you only have to add it to your application's
|
||||
GATT file with:
|
||||
|
||||
- *#import <service_name.gatt>* for .gatt files located in *src/ble/gatt-service*
|
||||
- *#import "service_name.gatt"* for .gatt files located in the same folder as your application's .gatt file.
|
||||
- `#import <service_name.gatt>` for .gatt files located in *src/ble/gatt-service*
|
||||
- `#import "service_name.gatt"` for .gatt files located in the same folder as your application's .gatt file.
|
||||
|
||||
Each service will have an API at *src/ble/gatt-service/service_name_server.h. To activate it, you need
|
||||
to call *service_name_init(..)*. Please see the .h file for details.
|
||||
@ -14,7 +14,38 @@ to call *service_name_init(..)*. Please see the .h file for details.
|
||||
|
||||
The Battery Service allows to query your device's battery level in a standardized way.
|
||||
|
||||
To use with your application, add `#import <batery_service.gatt>` to your .gatt file.
|
||||
After adding it to your .gatt file, you call *battery_service_server_init(value)* with the
|
||||
current value of your battery. The valid range for the battery level is 0-100.
|
||||
|
||||
If the battery level changes, you can call *battery_service_server_set_battery_value(value)*. The service supports sending Notifications if the client enables them.
|
||||
|
||||
|
||||
### Heart Rate Service {#sec:HeartRateService}}
|
||||
|
||||
The heart rate service server provides heart rate measurements via notifications.
|
||||
|
||||
Each notification reports the heart rate measurement in beats per minute, and if enabled,
|
||||
the total energy expended in kilo Joules, as well as RR-intervals in 1/1024 seconds resolution.
|
||||
|
||||
The Energy Expended field represents the accumulated energy expended
|
||||
in kilo Joules since the last time it was reset. If the maximum value of 65535
|
||||
kilo Joules is reached, it will remain at this value, until a reset command
|
||||
from the client is received.
|
||||
|
||||
The RR-Interval represents the time between two consecutive R waves in
|
||||
an Electrocardiogram (ECG) waveform. If needed, the RR-Intervals are sent in
|
||||
multiple notifications.
|
||||
|
||||
To use with your application, add `#import <heart_rate_service.gatt>` to your .gatt file.
|
||||
After adding it to your .gatt file, you call *heart_rate_server_init(body_sensor_location, energy_expended_supported)*
|
||||
with the intended sensor location, and a flag indicating if energy expanded is supported.
|
||||
|
||||
If heart rate measurement changes, you can call
|
||||
*heart_rate_service_server_update_heart_rate_values(heart_rate_bpm, service_sensor_contact_status, rr_interval_count, rr_intervals)*.
|
||||
This function will trigger sending Notifications if the client enables them.
|
||||
|
||||
If energy expanded is supported, you can call *heart_rate_service_add_energy_expended(energy_expended_kJ)*
|
||||
with the newly expanded energy. The accumulated energy expended value
|
||||
will be emitted with the next heart rate measurement.
|
||||
|
||||
|
@ -37,10 +37,6 @@
|
||||
|
||||
#define __BTSTACK_FILE__ "heart_rate_service_server.c"
|
||||
|
||||
/**
|
||||
* Implementation of the GATT Battery Service Server
|
||||
* To use with your application, add '#import <heart_rate_service.gatt' to your .gatt file
|
||||
*/
|
||||
|
||||
#include "bluetooth.h"
|
||||
#include "btstack_defines.h"
|
||||
@ -85,10 +81,8 @@ typedef struct {
|
||||
uint16_t sensor_location_value_handle;
|
||||
heart_rate_service_body_sensor_location_t sensor_location;
|
||||
|
||||
// characteristic: Hear Rate Control Point
|
||||
// uint8_t HEART_RATE_reset_energy_expended;
|
||||
// characteristic: Heart Rate Control Point
|
||||
uint16_t control_point_value_handle;
|
||||
|
||||
} heart_rate_t;
|
||||
|
||||
static att_service_handler_t heart_rate_service;
|
||||
@ -242,13 +236,13 @@ void heart_rate_service_add_energy_expended(uint16_t energy_expended_kJ){
|
||||
}
|
||||
}
|
||||
|
||||
void heart_rate_service_server_update_heart_rate_values(uint16_t beats_per_minute,
|
||||
void heart_rate_service_server_update_heart_rate_values(uint16_t heart_rate_bpm,
|
||||
heart_rate_service_sensor_contact_status_t sensor_contact, int rr_interval_count, uint16_t * rr_intervals){
|
||||
heart_rate_t * instance = &heart_rate;
|
||||
|
||||
printf("update_heart_rate_values, notify %u con_handle %04x\n", instance->measurement_client_configuration_descriptor_notify, instance->con_handle);
|
||||
|
||||
instance->measurement_bpm = beats_per_minute;
|
||||
instance->measurement_bpm = heart_rate_bpm;
|
||||
instance->sensor_contact = sensor_contact;
|
||||
instance->rr_interval_count = rr_interval_count;
|
||||
instance->rr_intervals = rr_intervals;
|
||||
|
@ -44,10 +44,43 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Implementation of the GATT Heart Rate Server
|
||||
* To use with your application, add '#import <heart_rate_service.gatt' to your .gatt file
|
||||
* Implementation of the GATT Heart Rate Service Server
|
||||
*/
|
||||
|
||||
// *****************************************************************************
|
||||
/* GATT_SERVICE_SERVER_START(heart_rate_service_server){Heart Rate Service}
|
||||
*
|
||||
* The heart rate service server provides heart rate measurements via
|
||||
* notifications.
|
||||
*
|
||||
* Each notification reports the heart rate measurement in beats per minute, and if enabled,
|
||||
* the total energy expended in kilo Joules, as well as RR-intervals in 1/1024 seconds resolution.
|
||||
*
|
||||
* The Energy Expended field represents the accumulated energy expended
|
||||
* in kilo Joules since the last time it was reset. If the maximum value of 65535
|
||||
* kilo Joules is reached, it will remain at this value, until a reset command
|
||||
* from the client is received.
|
||||
*
|
||||
* The RR-Interval represents the time between two consecutive R waves in
|
||||
* an Electrocardiogram (ECG) waveform. If needed, the RR-Intervals are sent in
|
||||
* multiple notifications.
|
||||
*
|
||||
* To use with your application, add `#import <heart_rate_service.gatt>` to your .gatt file.
|
||||
* After adding it to your .gatt file, you call *heart_rate_server_init(body_sensor_location, energy_expended_supported)*
|
||||
* with the intended sensor location, and a flag indicating if energy expanded is supported.
|
||||
*
|
||||
* If heart rate measurement changes, you can call
|
||||
* *heart_rate_service_server_update_heart_rate_values(heart_rate_bpm, service_sensor_contact_status, rr_interval_count, rr_intervals)*.
|
||||
* This function will trigger sending Notifications if the client enables them.
|
||||
*
|
||||
* If energy expanded is supported, you can call *heart_rate_service_add_energy_expended(energy_expended_kJ)*
|
||||
* with the newly expanded energy. The accumulated energy expended value
|
||||
* will be emitted with the next heart rate measurement.
|
||||
*
|
||||
*/
|
||||
// *****************************************************************************
|
||||
/* GATT_SERVICE_SERVER_END */
|
||||
|
||||
/* API_START */
|
||||
|
||||
typedef enum {
|
||||
|
Loading…
x
Reference in New Issue
Block a user