PebbleOS
Loading...
Searching...
No Matches
Modules | Data Structures | Macros | Typedefs | Enumerations | Functions
Protobuf log

Protobuf payloads of measurements or events sent to the phone. More...

Modules

 Activity session log
 Activity sessions logged as protobuf events.
 
 Heart rate log
 Heart rate samples logged as protobuf measurements.
 
 Protobuf log internals
 Record header and session structure.
 
 Payload decoding
 Decoders of encoded payloads, for debugging and unit tests.
 
 Encoding helpers
 nanopb encode callbacks used to build payloads.
 

Data Structures

struct  ProtobufLogConfig
 Session configuration. More...
 
union  ProtobufLogConfig.__unnamed74__
 
struct  ProtobufLogConfig.__unnamed74__.measurements
 Configuration of ProtobufLogType_Measurements sessions. More...
 
struct  ProtobufLogConfig.__unnamed74__.events
 Configuration of ProtobufLogType_Events sessions, empty. More...
 

Macros

#define ProtobufLogMeasurementType_TimeMS   pebble_pipeline_MeasurementSet_Type_TimeMS
 Time in milliseconds.
 
#define ProtobufLogMeasurementType_VMC   pebble_pipeline_MeasurementSet_Type_VMC
 Vector magnitude counts, a unitless measure of total activity.
 
#define ProtobufLogMeasurementType_Steps   pebble_pipeline_MeasurementSet_Type_Steps
 Accumulated steps.
 
#define ProtobufLogMeasurementType_DistanceCM   pebble_pipeline_MeasurementSet_Type_DistanceCM
 Distance in centimeters.
 
#define ProtobufLogMeasurementType_RestingGCalories    pebble_pipeline_MeasurementSet_Type_RestingGCalories
 Resting calories, in gram calories.
 
#define ProtobufLogMeasurementType_ActiveGCalories    pebble_pipeline_MeasurementSet_Type_ActiveGCalories
 Active calories, in gram calories.
 
#define ProtobufLogMeasurementType_BPM   pebble_pipeline_MeasurementSet_Type_BPM
 Heart rate in beats per minute.
 
#define ProtobufLogMeasurementType_RR   pebble_pipeline_MeasurementSet_Type_RR
 Heart rate variability, peak to peak time in milliseconds.
 
#define ProtobufLogMeasurementType_Orientation   pebble_pipeline_MeasurementSet_Type_Orientation
 Orientation.
 
#define ProtobufLogMeasurementType_Light   pebble_pipeline_MeasurementSet_Type_Light
 Ambient light.
 
#define ProtobufLogMeasurementType_Temperature   pebble_pipeline_MeasurementSet_Type_Temperature
 Watch temperature in kelvin.
 
#define ProtobufLogMeasurementType_HRQuality   pebble_pipeline_MeasurementSet_Type_HRQuality
 Heart rate signal quality.
 
#define ProtobufLogActivityType_UnknownType   pebble_pipeline_ActivityType_InternalType_UnknownType
 Unknown activity.
 
#define ProtobufLogActivityType_Sleep   pebble_pipeline_ActivityType_InternalType_Sleep
 Sleep.
 
#define ProtobufLogActivityType_DeepSleep   pebble_pipeline_ActivityType_InternalType_DeepSleep
 Deep sleep.
 
#define ProtobufLogActivityType_Nap   pebble_pipeline_ActivityType_InternalType_Nap
 Nap.
 
#define ProtobufLogActivityType_DeepNap   pebble_pipeline_ActivityType_InternalType_DeepNap
 Deep nap.
 
#define ProtobufLogActivityType_Walk   pebble_pipeline_ActivityType_InternalType_Walk
 Walk.
 
#define ProtobufLogActivityType_Run   pebble_pipeline_ActivityType_InternalType_Run
 Run.
 
#define ProtobufLogActivityType_Open   pebble_pipeline_ActivityType_InternalType_Open
 Open workout.
 
#define PLOG_MAX_SENDER_ID_LEN   64
 Size of a buffer holding the payload sender ID, the watch serial number.
 
#define PLOG_MAX_SENDER_TYPE_LEN   64
 Size of a buffer holding the payload sender type.
 
#define PLOG_MAX_SENDER_VERSION_PATCH_LEN   FW_METADATA_VERSION_TAG_BYTES
 Size of a buffer holding the payload sender version patch string.
 
#define PLOG_PAYLOAD_SENDER_TYPE   "watch"
 Payload sender type.
 
#define PLOG_DLS_RECORD_SIZE   DLS_SESSION_MAX_BUFFERED_ITEM_SIZE
 Size of the data logging records, and maximum encoded message size.
 

Typedefs

typedef pebble_pipeline_MeasurementSet_Type ProtobufLogMeasurementType
 Measurement type.
 
typedef pebble_pipeline_ActivityType_InternalType ProtobufLogActivityType
 Activity type.
 
typedef void * ProtobufLogRef
 Session handle.
 
typedef bool(* ProtobufLogTransportCB) (uint8_t *buffer, size_t buf_size)
 Transport sending an encoded record.
 

Enumerations

enum  ProtobufLogType { ProtobufLogType_Measurements , ProtobufLogType_Events }
 Session payload type. More...
 

Functions

bool protobuf_log_init (void)
 Initialize the service.
 
ProtobufLogRef protobuf_log_create (ProtobufLogConfig *config, ProtobufLogTransportCB transport, size_t max_encoded_msg_size)
 Create a session.
 
bool protobuf_log_session_add_measurements (ProtobufLogRef session, time_t sample_utc, uint32_t num_values, uint32_t *values)
 Add a sample to a measurement session.
 
bool protobuf_log_session_add_event (ProtobufLogRef session_ref, pebble_pipeline_Event *event)
 Add an event to an event session.
 
bool protobuf_log_session_flush (ProtobufLogRef session)
 Encode and send the data accumulated so far.
 
bool protobuf_log_session_delete (ProtobufLogRef session)
 Flush and free a session.
 

Detailed Description

Protobuf payloads of measurements or events sent to the phone.

Samples are accumulated into a pebble_pipeline_Payload (schemas in fw/services/protobuf_log/proto) until it fills a record, which is then handed to the session's transport. The default transport logs each record, prefixed by a PLogMessageHdr and zero padded to PLOG_DLS_RECORD_SIZE, to a buffered Data logging session with tag DlsSystemTagProtobufLogSession.

Measurement sessions log samples with a fixed set of values, such as heart rate BPM and quality. Event sessions log pebble_pipeline_Event, such as activity sessions.

};
.measurements = { .num_types = ARRAY_LENGTH(types), .types = types },
};
ProtobufLogRef log = protobuf_log_create(&config, NULL, 0);
uint32_t values[] = { bpm, quality };
time_t rtc_get_time(void)
Get the current time.
void * ProtobufLogRef
Measurements log handle.
Definition activity_private.h:449
ProtobufLogType type
Payload type.
Definition protobuf_log.h:122
Session configuration.
Definition protobuf_log.h:120
pebble_pipeline_MeasurementSet_Type ProtobufLogMeasurementType
Measurement type.
Definition protobuf_log.h:51
bool protobuf_log_session_delete(ProtobufLogRef session)
Flush and free a session.
ProtobufLogRef protobuf_log_create(ProtobufLogConfig *config, ProtobufLogTransportCB transport, size_t max_encoded_msg_size)
Create a session.
#define ProtobufLogMeasurementType_BPM
Heart rate in beats per minute.
Definition protobuf_log.h:70
bool protobuf_log_session_add_measurements(ProtobufLogRef session, time_t sample_utc, uint32_t num_values, uint32_t *values)
Add a sample to a measurement session.
#define ProtobufLogMeasurementType_HRQuality
Heart rate signal quality.
Definition protobuf_log.h:80
@ ProtobufLogType_Measurements
Samples of a fixed set of measurements.
Definition protobuf_log.h:114
#define ARRAY_LENGTH(array)
Calculate the length of an array, based on the size of the element type.
Definition size.h:18

Data Structure Documentation

◆ ProtobufLogConfig

struct ProtobufLogConfig

Session configuration.

Data Fields
union ProtobufLogConfig.__unnamed74__ __unnamed__
ProtobufLogType type Payload type.

◆ ProtobufLogConfig.__unnamed74__

union ProtobufLogConfig.__unnamed74__
Data Fields
struct ProtobufLogConfig.__unnamed74__.events events Configuration of ProtobufLogType_Events sessions, empty.
struct ProtobufLogConfig.__unnamed74__.measurements measurements Configuration of ProtobufLogType_Measurements sessions.

◆ ProtobufLogConfig.__unnamed74__.measurements

struct ProtobufLogConfig.__unnamed74__.measurements

Configuration of ProtobufLogType_Measurements sessions.

Data Fields
uint8_t num_types Number of values in each sample.
ProtobufLogMeasurementType * types Type of each value, num_types entries.

Copied by protobuf_log_create().

◆ ProtobufLogConfig.__unnamed74__.events

struct ProtobufLogConfig.__unnamed74__.events

Configuration of ProtobufLogType_Events sessions, empty.

Macro Definition Documentation

◆ PLOG_DLS_RECORD_SIZE

#define PLOG_DLS_RECORD_SIZE   DLS_SESSION_MAX_BUFFERED_ITEM_SIZE

Size of the data logging records, and maximum encoded message size.

◆ PLOG_MAX_SENDER_ID_LEN

#define PLOG_MAX_SENDER_ID_LEN   64

Size of a buffer holding the payload sender ID, the watch serial number.

◆ PLOG_MAX_SENDER_TYPE_LEN

#define PLOG_MAX_SENDER_TYPE_LEN   64

Size of a buffer holding the payload sender type.

◆ PLOG_MAX_SENDER_VERSION_PATCH_LEN

#define PLOG_MAX_SENDER_VERSION_PATCH_LEN   FW_METADATA_VERSION_TAG_BYTES

Size of a buffer holding the payload sender version patch string.

◆ PLOG_PAYLOAD_SENDER_TYPE

#define PLOG_PAYLOAD_SENDER_TYPE   "watch"

Payload sender type.

◆ ProtobufLogActivityType_DeepNap

#define ProtobufLogActivityType_DeepNap   pebble_pipeline_ActivityType_InternalType_DeepNap

Deep nap.

◆ ProtobufLogActivityType_DeepSleep

#define ProtobufLogActivityType_DeepSleep   pebble_pipeline_ActivityType_InternalType_DeepSleep

Deep sleep.

◆ ProtobufLogActivityType_Nap

#define ProtobufLogActivityType_Nap   pebble_pipeline_ActivityType_InternalType_Nap

Nap.

◆ ProtobufLogActivityType_Open

#define ProtobufLogActivityType_Open   pebble_pipeline_ActivityType_InternalType_Open

Open workout.

◆ ProtobufLogActivityType_Run

#define ProtobufLogActivityType_Run   pebble_pipeline_ActivityType_InternalType_Run

Run.

◆ ProtobufLogActivityType_Sleep

#define ProtobufLogActivityType_Sleep   pebble_pipeline_ActivityType_InternalType_Sleep

Sleep.

◆ ProtobufLogActivityType_UnknownType

#define ProtobufLogActivityType_UnknownType   pebble_pipeline_ActivityType_InternalType_UnknownType

Unknown activity.

◆ ProtobufLogActivityType_Walk

#define ProtobufLogActivityType_Walk   pebble_pipeline_ActivityType_InternalType_Walk

Walk.

◆ ProtobufLogMeasurementType_ActiveGCalories

#define ProtobufLogMeasurementType_ActiveGCalories    pebble_pipeline_MeasurementSet_Type_ActiveGCalories

Active calories, in gram calories.

◆ ProtobufLogMeasurementType_BPM

#define ProtobufLogMeasurementType_BPM   pebble_pipeline_MeasurementSet_Type_BPM

Heart rate in beats per minute.

◆ ProtobufLogMeasurementType_DistanceCM

#define ProtobufLogMeasurementType_DistanceCM   pebble_pipeline_MeasurementSet_Type_DistanceCM

Distance in centimeters.

◆ ProtobufLogMeasurementType_HRQuality

#define ProtobufLogMeasurementType_HRQuality   pebble_pipeline_MeasurementSet_Type_HRQuality

Heart rate signal quality.

◆ ProtobufLogMeasurementType_Light

#define ProtobufLogMeasurementType_Light   pebble_pipeline_MeasurementSet_Type_Light

Ambient light.

◆ ProtobufLogMeasurementType_Orientation

#define ProtobufLogMeasurementType_Orientation   pebble_pipeline_MeasurementSet_Type_Orientation

Orientation.

◆ ProtobufLogMeasurementType_RestingGCalories

#define ProtobufLogMeasurementType_RestingGCalories    pebble_pipeline_MeasurementSet_Type_RestingGCalories

Resting calories, in gram calories.

◆ ProtobufLogMeasurementType_RR

#define ProtobufLogMeasurementType_RR   pebble_pipeline_MeasurementSet_Type_RR

Heart rate variability, peak to peak time in milliseconds.

◆ ProtobufLogMeasurementType_Steps

#define ProtobufLogMeasurementType_Steps   pebble_pipeline_MeasurementSet_Type_Steps

Accumulated steps.

◆ ProtobufLogMeasurementType_Temperature

#define ProtobufLogMeasurementType_Temperature   pebble_pipeline_MeasurementSet_Type_Temperature

Watch temperature in kelvin.

◆ ProtobufLogMeasurementType_TimeMS

#define ProtobufLogMeasurementType_TimeMS   pebble_pipeline_MeasurementSet_Type_TimeMS

Time in milliseconds.

◆ ProtobufLogMeasurementType_VMC

#define ProtobufLogMeasurementType_VMC   pebble_pipeline_MeasurementSet_Type_VMC

Vector magnitude counts, a unitless measure of total activity.

Typedef Documentation

◆ ProtobufLogActivityType

typedef pebble_pipeline_ActivityType_InternalType ProtobufLogActivityType

Activity type.

◆ ProtobufLogMeasurementType

typedef pebble_pipeline_MeasurementSet_Type ProtobufLogMeasurementType

Measurement type.

◆ ProtobufLogRef

typedef void* ProtobufLogRef

Session handle.

◆ ProtobufLogTransportCB

typedef bool(* ProtobufLogTransportCB) (uint8_t *buffer, size_t buf_size)

Transport sending an encoded record.

Parameters
bufferRecord, a PLogMessageHdr followed by the encoded payload. The buffer is PLOG_DLS_RECORD_SIZE bytes long and may be padded in place.
buf_sizeRecord size in bytes.
Returns
true on success.

Enumeration Type Documentation

◆ ProtobufLogType

Session payload type.

Enumerator
ProtobufLogType_Measurements 

Samples of a fixed set of measurements.

ProtobufLogType_Events 

pebble_pipeline_Event items.

Function Documentation

◆ protobuf_log_create()

ProtobufLogRef protobuf_log_create ( ProtobufLogConfig *  config,
ProtobufLogTransportCB  transport,
size_t  max_encoded_msg_size 
)

Create a session.

Parameters
configSession configuration.
transportTransport, or NULL to log to data logging.
max_encoded_msg_sizeMaximum record size, at most PLOG_DLS_RECORD_SIZE. 0, the usual value, selects PLOG_DLS_RECORD_SIZE.
Returns
Session, or NULL on error.

◆ protobuf_log_init()

bool protobuf_log_init ( void  )

Initialize the service.

Returns
true.

◆ protobuf_log_session_add_event()

bool protobuf_log_session_add_event ( ProtobufLogRef  session_ref,
pebble_pipeline_Event *  event 
)

Add an event to an event session.

The accumulated data is encoded and sent once a record is full.

Parameters
session_refSession.
eventEvent.
Returns
true on success.

◆ protobuf_log_session_add_measurements()

bool protobuf_log_session_add_measurements ( ProtobufLogRef  session,
time_t  sample_utc,
uint32_t  num_values,
uint32_t *  values 
)

Add a sample to a measurement session.

The accumulated data is encoded and sent once a record is full.

Parameters
sessionSession.
sample_utcSample UTC time.
num_valuesNumber of entries in values, equal to the configured number of types.
valuesSample values, in the configured type order.
Returns
true on success.

◆ protobuf_log_session_delete()

bool protobuf_log_session_delete ( ProtobufLogRef  session)

Flush and free a session.

Parameters
sessionSession, may be NULL.
Returns
true.

◆ protobuf_log_session_flush()

bool protobuf_log_session_flush ( ProtobufLogRef  session)

Encode and send the data accumulated so far.

The session is restarted even if sending fails.

Parameters
sessionSession.
Returns
true on success.