PebbleOS
Loading...
Searching...
No Matches
Functions
Health database

Health typicals and averages synced from the phone (BlobDBIdHealth). More...

Functions

bool health_db_get_typical_value (ActivityMetric metric, enum pbl_weekday day, int32_t *value_out)
 Get the typical value of a metric for a weekday.
 
bool health_db_get_monthly_average_value (ActivityMetric metric, int32_t *value_out)
 Get the average value of a metric over the last month.
 
bool health_db_get_typical_step_averages (enum pbl_weekday day, ActivityMetricAverages *averages)
 Get the typical step counts of a weekday, also known as "typical steps".
 
bool health_db_set_typical_values (ActivityMetric metric, enum pbl_weekday day, uint16_t *values, int num_values)
 Store typical step values for a weekday, for test and debug purposes only.
 
void health_db_init (void)
 Initialize the health database.
 
status_t health_db_insert (const uint8_t *key, int key_len, const uint8_t *val, int val_len)
 Insert or replace a record in the health database.
 
int health_db_get_len (const uint8_t *key, int key_len)
 Get the length of a record in the health database.
 
status_t health_db_read (const uint8_t *key, int key_len, uint8_t *val_out, int val_out_len)
 Read a record from the health database.
 
status_t health_db_delete (const uint8_t *key, int key_len)
 Delete a record from the health database.
 
status_t health_db_flush (void)
 Delete all records of the health database.
 
status_t health_db_compact (void)
 Compact the settings file backing the health database.
 

Detailed Description

Health typicals and averages synced from the phone (BlobDBIdHealth).

Function Documentation

◆ health_db_compact()

status_t health_db_compact ( void  )

Compact the settings file backing the health database.

Returns
S_SUCCESS on success, an error code otherwise.

◆ health_db_delete()

status_t health_db_delete ( const uint8_t *  key,
int  key_len 
)

Delete a record from the health database.

Parameters
keyKey data.
key_lenLength of key in bytes.
Returns
S_SUCCESS on success, an error code otherwise.

◆ health_db_flush()

status_t health_db_flush ( void  )

Delete all records of the health database.

Returns
S_SUCCESS on success, an error code otherwise.

◆ health_db_get_len()

int health_db_get_len ( const uint8_t *  key,
int  key_len 
)

Get the length of a record in the health database.

Parameters
keyKey data.
key_lenLength of key in bytes.
Returns
Length of the value in bytes, 0 if not found, or a negative error code.

◆ health_db_get_monthly_average_value()

bool health_db_get_monthly_average_value ( ActivityMetric  metric,
int32_t *  value_out 
)

Get the average value of a metric over the last month.

Only ActivityMetricStepCount and ActivityMetricSleepTotalSeconds are stored.

Parameters
metricMetric.
[out]value_outAverage value.
Returns
true on success, false if unknown or unsupported.

◆ health_db_get_typical_step_averages()

bool health_db_get_typical_step_averages ( enum pbl_weekday  day,
ActivityMetricAverages *  averages 
)

Get the typical step counts of a weekday, also known as "typical steps".

Parameters
dayWeekday.
[out]averagesStep averages; set to unknown when not available.
Returns
true on success.

◆ health_db_get_typical_value()

bool health_db_get_typical_value ( ActivityMetric  metric,
enum pbl_weekday  day,
int32_t *  value_out 
)

Get the typical value of a metric for a weekday.

Only sleep metrics have typical values. For typical steps use health_db_get_typical_step_averages().

Parameters
metricMetric.
dayWeekday.
[out]value_outTypical value.
Returns
true on success, false if unknown or unsupported.

◆ health_db_init()

void health_db_init ( void  )

Initialize the health database.

◆ health_db_insert()

status_t health_db_insert ( const uint8_t *  key,
int  key_len,
const uint8_t *  val,
int  val_len 
)

Insert or replace a record in the health database.

Keys are strings like monday_sleepData or average_dailySteps and values a multiple of 4 bytes. Movement data is only forwarded to the activity service and not stored; other records are stored and also forwarded.

Parameters
keyKey data.
key_lenLength of key in bytes.
valValue data.
val_lenLength of val in bytes.
Returns
S_SUCCESS on success, an error code otherwise.

◆ health_db_read()

status_t health_db_read ( const uint8_t *  key,
int  key_len,
uint8_t *  val_out,
int  val_out_len 
)

Read a record from the health database.

Parameters
keyKey data.
key_lenLength of key in bytes.
[out]val_outBuffer for the value.
val_out_lenSize of val_out in bytes.
Returns
S_SUCCESS on success, an error code otherwise.

◆ health_db_set_typical_values()

bool health_db_set_typical_values ( ActivityMetric  metric,
enum pbl_weekday  day,
uint16_t *  values,
int  num_values 
)

Store typical step values for a weekday, for test and debug purposes only.

Parameters
metricIgnored, step typicals are always written.
dayWeekday.
valuesValues to store.
num_valuesNumber of entries in values.
Returns
true on success.