Import of the watch repository from Pebble

This commit is contained in:
Matthieu Jeanson 2024-12-12 16:43:03 -08:00 committed by Katharine Berry
commit 3b92768480
10334 changed files with 2564465 additions and 0 deletions

View file

@ -0,0 +1,3 @@
# UUID is 32 letters plus 4 optional dashes, see:
# 123e4567-e89b-12d3-a456-426655440000 (8-4-4-4-12)
pebble.pipeline.ActivityType.custom_type max_size:36

View file

@ -0,0 +1,120 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
These schemas define the structures to communicate activity/workout types
as well the structures of how they are uploaded from the watch to the phone
and the pipeline API.
*/
syntax = "proto2";
package pebble.pipeline;
option java_package = "com.getpebble.pipeline";
import "measurements.proto";
message ActivityInterval {
required uint32 offset_sec = 1; /// Relative to event.time_utc
required uint32 duration_sec = 2;
}
/**
* Supposed to be a child of `Event`.
*
* The "start time" is `event.time_utc` and
* the "end time" is `event.time_utc + event.duration`.
* The "effective duration" is the sum of all `duration_sec` of the `intervals`.
*/
message ActivitySession {
enum StartReason {
UnknownReason = 0; /// Protocol Buffers uses the first enum as the default
Automatic = 1;
Manual = 2;
AutomaticConvertedToManual = 3;
}
message Summary {
repeated MeasurementSet.Type types = 1; /// denotes types and order of packed data in each Sample
required Measurement measurement = 2;
}
required ActivityType type = 1;
required StartReason start_reason = 5;
/**
* On pause and resume a new interval is created.
*
* Number of intervals should be 1 or more.
*/
repeated ActivityInterval intervals = 6;
/**
* Sum/averages of various metrics during the activity but
* excluding breaks (i.e. steps should not be counted while
* activity is paused).
*/
optional Summary summary = 7;
}
message ActivityType {
enum InternalType {
UnknownType = 0; /// Protocol Buffers uses the first enum as the default
Sleep = 1;
DeepSleep = 2;
Nap = 3;
DeepNap = 4;
Walk = 5;
Run = 6;
Open = 7;
// to be continued
}
oneof type {
InternalType internal_type = 1;
string custom_type = 2; /// Identifier, locally unique to Pebble/Phone
}
optional string name = 3;
}
/**
* Used to send configuration down to the watch.
*/
message ActivityPreset {
enum Widget {
UnknownWidget = 0; /// Protocol Buffers uses the first enum as the default
PaceTimePerDistance = 1;
SpeedDistancePerTime = 2;
HeartRateBeatsPerMinute = 3;
// to be continued
}
required ActivityType type = 1;
optional Widget main_widget = 4;
repeated Widget bottom_widgets = 5; /// (Probably up to 3)
}
/**
* Container used to send presets down to the watch.
*/
message ActivityPresetList {
repeated ActivityPreset presets = 1;
}

View file

@ -0,0 +1,56 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
These schemas define entities that are reused in multiple places in other
message schemas such as users, locations, and devices
*/
syntax = "proto2";
package pebble.pipeline;
option java_package="com.getpebble.pipeline";
message Version {
required uint32 major = 4;
required uint32 minor = 5;
optional string patch = 6;
}
message LocationInfo {
message LatLon {
required float lat = 1;
required float lon = 2;
}
optional LatLon geo = 1;
optional string ip_address = 2;
optional string location_str = 3;
}
/**
Tiers refer to any system that might receive or send data along the pipeline
such as watches and phones
*/
message Tier {
required string type = 1;
required string id = 2; /// ID string for the device or system, which may or may not conform to a true UUID. eg serial_number for a pebble watch
optional LocationInfo location = 3;
optional string comment = 4;
optional Version version = 5;
}
message User {
required string id = 1;
}

View file

@ -0,0 +1,46 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
Events represent discrete moments in time or windows in time where something
happened.
*/
syntax = "proto2";
package pebble.pipeline;
option java_package = "com.getpebble.pipeline";
import "activity.proto";
import "common.proto";
message Event {
enum Type {
UnknownEvent = 0; /// Protocol Buffers uses the first enum as the default
ActivitySessionEvent = 1;
// NotificationEvent = 2;
// ViewHealthChart = 3;
}
required bytes uuid = 1; /// 16-byte uuid for efficient message size
optional User user = 2; /// can usually be omitted and included in Requests
required Type type = 4; /// string types are more sanely extensible, but enum types would be more typo resistant and smaller message size
required uint32 time_utc = 5; /// when the event occured (unix epoch seconds)
required sint32 utc_to_local = 6; /// time_utc + utc_to_local = time_local. sint32 stores neg number efficiently. need to recast before adding to time_utc, but saves storage
optional uint32 created_time_utc = 7; /// events may be created at times other than their occurance
optional uint32 duration = 8; /// in same units as time_utc (sec)
optional LocationInfo location = 9;
optional ActivitySession activity_session = 10;
// We will add the additional properties for events needed here later
}

View file

@ -0,0 +1,86 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
Measurements represent recordings from sensors at regular intervals, or
algorithm outputs derived from such sensor data.
The structure works a bit like a csv. There is a header which describes the
type and order of the values stored in the data field.
When dealing with measurements it is important to consider if the signal you
are measuring is a sample an integral signal. Samples and integrals are
treated very different mathematically.
Samples only make sense to talk about at instants in time, while integrals
only make sense to talk about time windows. Heart rate and acceleration are
good examples of sample measurements, while steps and are good examples of
integral measurements.
For sequential integral measurements, one time window ends an instant before
the next measurement begins, therefore one only need to add an explicit end
to the last measurement (see time_end_utc)
Because of these assumptions, non-sequential integral measurements should
be broken into separate messages.
*/
syntax = "proto2";
package pebble.pipeline;
option java_package = "com.getpebble.pipeline";
import "common.proto";
message Measurement {
required uint32 offset_sec = 1; /// offset since timestamp (in seconds)
repeated uint32 data = 2 [packed=true];
}
message MeasurementSet {
enum HeartRateQuality {
NoAccel = 0;
OffWrist = 1;
NoSignal = 2;
Worst = 3;
Poor = 4;
Acceptable = 5;
Good = 6;
Excellent = 7;
}
enum Type { /// types of measuremetn samples we can take. minor changes to SI units to encode efficiently
UnknownEvent = 0; /// Protocol Buffers uses the first enum as the default
TimeMS = 1; /// more percise time, in milliseconds
VMC = 2; /// Vector Magnitude Counts. Rough measure of total activity. Unitless
Steps = 3; /// Accumulated steps. Unitless
DistanceCM = 4; /// Distance traveled. In centimeters
RestingGCalories = 5; /// Calories burned due to resting metabolic rate. In gram calories
ActiveGCalories = 6; /// Calories burned due to activity. In gram calories
BPM = 7; /// Heart rate. Beats per minutes
RR = 8; /// Heart rate variability. Peak to peak time in ms
Orientation = 9; /// Orientation of the watch. Some weird units
Light = 10; /// Ambient light.
Temperature = 11; /// Temperature of watch. Kelvin
HRQuality = 12; /// Quality of heart rate signal, a HeartRateQuality enum
}
required bytes uuid = 1; /// 16-byte uuid for efficient message size
optional User user = 2;
required uint32 time_utc = 3; /// time since epoch (in seconds)
required sint32 utc_to_local = 4; /// sint32 stores neg number efficiently. need to recast before adding to time_utc, but saves storage
optional bytes sensor_settings = 5; /// sensors might have all sorts of different modes or config that might be best represented as a byte blob
repeated Type types = 7; /// denotes types and order of packed data in each Sample
repeated Measurement measurements = 8;
optional uint32 time_end_utc = 9; /// end of last time window if data contains any integral signals
}

View file

@ -0,0 +1,49 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
Payloads are how data should be sent and collected from devices. A simple
normal flow would be for a watch to generate Events and Measurements,
bundle them into a Payload that is sent to mobile. Mobile would then take that
payload, as well as events and measurements generated on the mobile device
itself, and bundle them into it's own Payload message to send to the
Pipeline API
More complex patterns occur when the watch sends mupltiple Payloads, at
different times, to the mobile before it gets a chance to send the data on to
the web, or if multiple devices are connected simultaneously to one mobile
device.
*/
syntax = "proto2";
package pebble.pipeline;
option java_package = "com.getpebble.pipeline";
import "common.proto";
import "event.proto";
import "measurements.proto";
message Payload {
required Tier sender = 2; /// Tier info represents who is sending a message. Payloads are uniquely identified by sender and time
required uint32 send_time_utc = 3; /// latest send attmpt time
optional uint32 send_retry_count = 4;
optional User user = 6; /// User info apply to all sub-messages contained
repeated bytes payloads = 10; /// recursive payloads form a tree structure to store arbitrary message history efficiently
// base analytics types function as tree leaves
repeated Event events = 11;
repeated MeasurementSet measurement_sets = 12;
}

View file

@ -0,0 +1,19 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto2";
message SimpleMessage {
required int32 lucky_number = 1;
}

12
src/idl/nanopb/wscript Normal file
View file

@ -0,0 +1,12 @@
def configure(conf):
conf.load('protoc')
def build(bld):
bld.stlib(features="c cstlib",
source=bld.path.ant_glob('**/*.proto'),
includes=bld.path.abspath(),
target='proto_schemas',
use='pblibc nanopb idl_includes')
# vim:filetype=python

13
src/idl/wscript Normal file
View file

@ -0,0 +1,13 @@
def options(opt):
pass
def configure(conf):
conf.recurse('nanopb')
def build(bld):
bld(export_includes=bld.path.get_bld().abspath(), name='idl_includes')
bld.recurse('nanopb')
# vim:filetype=python