diff --git a/api/device.proto b/api/device.proto index aac8440..af221dc 100644 --- a/api/device.proto +++ b/api/device.proto @@ -4,6 +4,7 @@ package synapse; import "api/node.proto"; import "api/status.proto"; +import "api/time.proto"; message Peripheral { enum Type { @@ -34,3 +35,28 @@ message DeviceConfiguration { repeated NodeConfig nodes = 1; repeated NodeConnection connections = 2; } + + +// Device settings that are configurable by the user +message DeviceSettings { + string name = 1; + TimeSource time_source = 2; +} + +message GetSettingsQuery { + +} + +message GetSettingsResponse { + DeviceSettings settings = 1; +} + +message UpdateDeviceSettingsRequest { + // If a field isn't populated, it will not be changed + DeviceSettings settings = 1; +} + +message UpdateDeviceSettingsResponse { + Status status = 1; + DeviceSettings updated_settings = 2; +} diff --git a/api/query.proto b/api/query.proto index eaf432b..0e55a56 100644 --- a/api/query.proto +++ b/api/query.proto @@ -5,6 +5,7 @@ package synapse; import "api/channel.proto"; import "api/status.proto"; import "api/tap.proto"; +import "api/device.proto"; message SampleQuery { repeated Channel channels = 1; @@ -48,6 +49,7 @@ message QueryRequest { kSample = 2; kSelfTest = 3; kListTaps = 4; + kGetSettings = 5; } QueryType query_type = 1; oneof query { @@ -55,6 +57,7 @@ message QueryRequest { SampleQuery sample_query = 3; SelfTestQuery self_test_query = 4; ListTapsQuery list_taps_query = 5; + GetSettingsQuery get_settings_query = 6; } } @@ -71,6 +74,7 @@ message QueryResponse { ImpedanceResponse impedance_response = 3; SelfTestResponse self_test_response = 4; ListTapsResponse list_taps_response = 5; + GetSettingsResponse get_settings_response = 6; } } diff --git a/api/synapse.proto b/api/synapse.proto index 9f55287..135236c 100644 --- a/api/synapse.proto +++ b/api/synapse.proto @@ -28,4 +28,6 @@ service SynapseDevice { rpc GetLogs(LogQueryRequest) returns (LogQueryResponse) {} rpc TailLogs(TailLogsRequest) returns (stream LogEntry) {} + + rpc UpdateDeviceSettings(UpdateDeviceSettingsRequest) returns (UpdateDeviceSettingsResponse) {} } diff --git a/api/time.proto b/api/time.proto index a0fd3a4..429a07e 100644 --- a/api/time.proto +++ b/api/time.proto @@ -36,3 +36,17 @@ message TimeSyncPacket { fixed64 server_send_time_ns = 5; fixed64 client_receive_time_ns = 6; } + +// Defines the time synchronization method for device timestamps +enum TimeSource { + TIME_SOURCE_UNKNOWN = 0; + + // Use std::chrono::steady_clock (monotonic, immune to system time changes) + // Note: The epoch is implementation-defined (often system boot time) + TIME_SOURCE_STEADY_CLOCK = 1; + + // Calculate timestamps based on sample counter and sampling rate + // timestamp = (sample_counter / sample_rate) + initial_steady_clock_value + // Where initial_steady_clock_value = get_steady_clock_now() at start + TIME_SOURCE_SAMPLE_COUNTER = 2; +}