From a83ba64f92e76f6bcbd1bd2c96777ea67cd9493d Mon Sep 17 00:00:00 2001 From: Gilbert Montague Date: Fri, 18 Jul 2025 12:16:40 -0700 Subject: [PATCH 1/8] feature: Add device settings --- api/device.proto | 19 +++++++++++++++++++ api/synapse.proto | 3 +++ 2 files changed, 22 insertions(+) diff --git a/api/device.proto b/api/device.proto index aac8440..c1e9b08 100644 --- a/api/device.proto +++ b/api/device.proto @@ -5,6 +5,8 @@ package synapse; import "api/node.proto"; import "api/status.proto"; +import "google/protobuf/field_mask.proto"; + message Peripheral { enum Type { kUnknown = 0; @@ -34,3 +36,20 @@ message DeviceConfiguration { repeated NodeConfig nodes = 1; repeated NodeConnection connections = 2; } + + +// Device settings that are configurable by the user +message DeviceSettings { + string name = 1; + +} + +message UpdateDeviceSettingsRequest { + DeviceSettings settings = 1; + google.protobuf.FieldMask update_mask = 2; +} + +message UpdateDeviceSettingsResponse { + Status status = 1; + DeviceSettings updated_settings = 2; +} diff --git a/api/synapse.proto b/api/synapse.proto index 9f55287..23adcdd 100644 --- a/api/synapse.proto +++ b/api/synapse.proto @@ -28,4 +28,7 @@ service SynapseDevice { rpc GetLogs(LogQueryRequest) returns (LogQueryResponse) {} rpc TailLogs(TailLogsRequest) returns (stream LogEntry) {} + + rpc GetDeviceSettings(google.protobuf.Empty) returns (DeviceSettings) {} + rpc UpdateDeviceSettings(UpdateDeviceSettingsRequest) returns (UpdateDeviceSettingsResponse) {} } From 780f65d65f25b2603da886813cf5db21ad91aecc Mon Sep 17 00:00:00 2001 From: Gilbert Montague Date: Fri, 18 Jul 2025 16:03:38 -0700 Subject: [PATCH 2/8] Just use a query --- api/device.proto | 3 +++ api/query.proto | 3 +++ api/synapse.proto | 1 - 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/api/device.proto b/api/device.proto index c1e9b08..366d17b 100644 --- a/api/device.proto +++ b/api/device.proto @@ -41,7 +41,10 @@ message DeviceConfiguration { // Device settings that are configurable by the user message DeviceSettings { string name = 1; +} +message ListSettingsQuery { + } message UpdateDeviceSettingsRequest { diff --git a/api/query.proto b/api/query.proto index eaf432b..0c3d37b 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; + ListSettingsQuery list_settings_query = 6; } } diff --git a/api/synapse.proto b/api/synapse.proto index 23adcdd..135236c 100644 --- a/api/synapse.proto +++ b/api/synapse.proto @@ -29,6 +29,5 @@ service SynapseDevice { rpc GetLogs(LogQueryRequest) returns (LogQueryResponse) {} rpc TailLogs(TailLogsRequest) returns (stream LogEntry) {} - rpc GetDeviceSettings(google.protobuf.Empty) returns (DeviceSettings) {} rpc UpdateDeviceSettings(UpdateDeviceSettingsRequest) returns (UpdateDeviceSettingsResponse) {} } From eaed354276d528c71b3ea2c7f422e4b74d58d42c Mon Sep 17 00:00:00 2001 From: Gilbert Montague Date: Fri, 18 Jul 2025 16:11:14 -0700 Subject: [PATCH 3/8] Just use a query --- api/device.proto | 4 ++-- api/query.proto | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api/device.proto b/api/device.proto index 366d17b..174d508 100644 --- a/api/device.proto +++ b/api/device.proto @@ -43,8 +43,8 @@ message DeviceSettings { string name = 1; } -message ListSettingsQuery { - +message GetSettingsQuery { + } message UpdateDeviceSettingsRequest { diff --git a/api/query.proto b/api/query.proto index 0c3d37b..1ecbc09 100644 --- a/api/query.proto +++ b/api/query.proto @@ -57,7 +57,7 @@ message QueryRequest { SampleQuery sample_query = 3; SelfTestQuery self_test_query = 4; ListTapsQuery list_taps_query = 5; - ListSettingsQuery list_settings_query = 6; + GetSettingsQuery get_settings_query = 6; } } From 5bfe00dd495f2c5b35b1f4bf149ecd4af79282fe Mon Sep 17 00:00:00 2001 From: Gilbert Montague Date: Fri, 18 Jul 2025 16:12:50 -0700 Subject: [PATCH 4/8] Just use a query --- api/device.proto | 4 ++++ api/query.proto | 1 + 2 files changed, 5 insertions(+) diff --git a/api/device.proto b/api/device.proto index 174d508..8a69b1d 100644 --- a/api/device.proto +++ b/api/device.proto @@ -47,6 +47,10 @@ message GetSettingsQuery { } +message GetSettingsResponse { + DeviceSettings settings = 1; +} + message UpdateDeviceSettingsRequest { DeviceSettings settings = 1; google.protobuf.FieldMask update_mask = 2; diff --git a/api/query.proto b/api/query.proto index 1ecbc09..0e55a56 100644 --- a/api/query.proto +++ b/api/query.proto @@ -74,6 +74,7 @@ message QueryResponse { ImpedanceResponse impedance_response = 3; SelfTestResponse self_test_response = 4; ListTapsResponse list_taps_response = 5; + GetSettingsResponse get_settings_response = 6; } } From c0f69de2f9557dbca83c456ea128a8d7433cefa9 Mon Sep 17 00:00:00 2001 From: Gilbert Montague Date: Fri, 18 Jul 2025 17:41:55 -0700 Subject: [PATCH 5/8] Don't use a field mask --- api/device.proto | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/api/device.proto b/api/device.proto index 8a69b1d..36eb8e0 100644 --- a/api/device.proto +++ b/api/device.proto @@ -5,8 +5,6 @@ package synapse; import "api/node.proto"; import "api/status.proto"; -import "google/protobuf/field_mask.proto"; - message Peripheral { enum Type { kUnknown = 0; @@ -52,8 +50,8 @@ message GetSettingsResponse { } message UpdateDeviceSettingsRequest { + // If ia field isn't populated, it will not be changed DeviceSettings settings = 1; - google.protobuf.FieldMask update_mask = 2; } message UpdateDeviceSettingsResponse { From ab930239d98d4578983a1d5c61cc38ef049ee9f2 Mon Sep 17 00:00:00 2001 From: Gilbert Montague Date: Mon, 21 Jul 2025 12:03:45 -0700 Subject: [PATCH 6/8] add time info --- api/device.proto | 3 +++ api/time.proto | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/api/device.proto b/api/device.proto index 36eb8e0..463a89f 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 { @@ -39,6 +40,8 @@ message DeviceConfiguration { // Device settings that are configurable by the user message DeviceSettings { string name = 1; + + TimeSource time_source = 2; } message GetSettingsQuery { diff --git a/api/time.proto b/api/time.proto index a0fd3a4..64b092e 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; +} \ No newline at end of file From bc4bae32ff40fa0accca3084399ee8372e158553 Mon Sep 17 00:00:00 2001 From: Gilbert Montague Date: Mon, 21 Jul 2025 12:04:19 -0700 Subject: [PATCH 7/8] lint --- api/device.proto | 1 - api/time.proto | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/api/device.proto b/api/device.proto index 463a89f..c4633ee 100644 --- a/api/device.proto +++ b/api/device.proto @@ -40,7 +40,6 @@ message DeviceConfiguration { // Device settings that are configurable by the user message DeviceSettings { string name = 1; - TimeSource time_source = 2; } diff --git a/api/time.proto b/api/time.proto index 64b092e..429a07e 100644 --- a/api/time.proto +++ b/api/time.proto @@ -49,4 +49,4 @@ enum TimeSource { // 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; -} \ No newline at end of file +} From d2b6182db68706d13398e8b7b7606fc7f1850284 Mon Sep 17 00:00:00 2001 From: Gilbert Montague Date: Mon, 21 Jul 2025 16:29:06 -0700 Subject: [PATCH 8/8] typo --- api/device.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/device.proto b/api/device.proto index c4633ee..af221dc 100644 --- a/api/device.proto +++ b/api/device.proto @@ -52,7 +52,7 @@ message GetSettingsResponse { } message UpdateDeviceSettingsRequest { - // If ia field isn't populated, it will not be changed + // If a field isn't populated, it will not be changed DeviceSettings settings = 1; }