init
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
# Nanopb options for control_communication.proto
|
||||
# Adjust these limits as needed for memory/performance.
|
||||
|
||||
# RfidId
|
||||
control_communication.RfidId.value max_length:8
|
||||
|
||||
# DeviceCommunicationSyncRequest
|
||||
# Limit number of log entries and their key/value sizes.
|
||||
control_communication.SyncRequest.logs max_count:50
|
||||
@@ -0,0 +1,16 @@
|
||||
syntax = "proto3";
|
||||
package control_communication;
|
||||
|
||||
message RfidId {
|
||||
uint32 value = 1;
|
||||
}
|
||||
|
||||
message SyncResponse {
|
||||
int64 currentTime = 1;
|
||||
bool pendingChanges = 2;
|
||||
}
|
||||
|
||||
message SyncRequest {
|
||||
optional int64 lastSync = 1;
|
||||
map<uint64, uint32> accessLogs = 2;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
# Nanopb options for device.proto
|
||||
|
||||
# DeviceInfo
|
||||
device.DeviceInfo.device_id max_length:18
|
||||
device.DeviceInfo.firmware_version max_length:8
|
||||
device.DeviceInfo.hardware_version max_length:8
|
||||
device.DeviceInfo.sta_ip max_length:16
|
||||
device.DeviceInfo.sta_gateway max_length:16
|
||||
device.DeviceInfo.ap_ip max_length:16
|
||||
|
||||
# DeviceLogEntry
|
||||
device.DeviceLogEntry.message max_length:128
|
||||
|
||||
# DeviceStatus
|
||||
device.DeviceStatus.logs max_length:20
|
||||
@@ -0,0 +1,46 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package device;
|
||||
|
||||
// WiFi connection state enumeration
|
||||
enum WifiConnectionState {
|
||||
WIFI_DISCONNECTED = 0;
|
||||
WIFI_CONNECTED = 1;
|
||||
WIFI_CONNECTING = 2;
|
||||
WIFI_FAILED = 3;
|
||||
}
|
||||
|
||||
// Device information
|
||||
message DeviceInfo {
|
||||
string device_id = 1;
|
||||
string firmware_version = 2;
|
||||
string hardware_version = 3;
|
||||
uint32 uptime_seconds = 4;
|
||||
// STA mode info
|
||||
WifiConnectionState sta_connection_state = 5;
|
||||
string sta_ip = 6;
|
||||
string sta_gateway = 7;
|
||||
int32 sta_signal_strength = 8; // Signal strength in dBm
|
||||
// AP mode info
|
||||
WifiConnectionState ap_connection_state = 9;
|
||||
string ap_ip = 10;
|
||||
uint32 ap_client_count = 11;
|
||||
}
|
||||
|
||||
enum DeviceLogLevel {
|
||||
LOG_LEVEL_DEBUG = 0;
|
||||
LOG_LEVEL_INFO = 1;
|
||||
LOG_LEVEL_WARN = 2;
|
||||
LOG_LEVEL_ERROR = 3;
|
||||
}
|
||||
|
||||
message DeviceLogEntry {
|
||||
int64 timestamp = 1; // Unix timestamp in milliseconds
|
||||
DeviceLogLevel level = 2;
|
||||
string message = 3;
|
||||
}
|
||||
|
||||
message DeviceStatus {
|
||||
DeviceInfo info = 1;
|
||||
repeated DeviceLogEntry logs = 2;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
# Nanopb options for hardware.proto
|
||||
|
||||
# LED configuration
|
||||
hardware.FadeParams.colors max_count:5
|
||||
|
||||
hardware.SensorOTAEnable.ssid max_length:32
|
||||
hardware.SensorOTAEnable.password max_length:64
|
||||
hardware.SensorOTAEnable.static_ip max_length:16
|
||||
hardware.SensorOTAEnable.netmask max_length:16
|
||||
hardware.SensorOTAEnable.gateway max_length:16
|
||||
hardware.SensorOTAEnableResponse.ip_address max_length:16
|
||||
hardware.SensorOTAEnableResponse.error_message max_length:64
|
||||
@@ -0,0 +1,104 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package hardware;
|
||||
|
||||
// LED animation types
|
||||
enum LedAnimation {
|
||||
LED_ANIMATION_STATIC = 0;
|
||||
LED_ANIMATION_PULSE = 1;
|
||||
LED_ANIMATION_FADE = 2;
|
||||
LED_ANIMATION_FLICKER = 3;
|
||||
}
|
||||
|
||||
// Hardware configuration
|
||||
message HardwareConfig {
|
||||
uint32 hold_duration_ms = 1;
|
||||
bool override = 2;
|
||||
uint32 relay_pin = 3;
|
||||
uint32 sensor_rx_pin = 4;
|
||||
uint32 sensor_tx_pin = 5;
|
||||
LedConfig on_open_led = 6;
|
||||
LedConfig default_led = 7;
|
||||
LedConfig on_invalid_led = 8;
|
||||
bool enable_serial_sensor = 9;
|
||||
// repeated char sensor_api_key = 10;
|
||||
// bool enable_ws_sensor = 11;
|
||||
LedConfig on_override_open_led = 12;
|
||||
LedConfig on_interception_led = 13;
|
||||
}
|
||||
|
||||
// LED configuration
|
||||
message LedConfig {
|
||||
// General properties that apply to all animations
|
||||
uint32 brightness = 1; // 0-255
|
||||
uint32 duration_ms = 2; // 0 for indefinite
|
||||
|
||||
oneof animation_params {
|
||||
StaticParams static_params = 3;
|
||||
PulseParams pulse_params = 4;
|
||||
FadeParams fade_params = 5;
|
||||
FlickerParams flicker_params = 6;
|
||||
}
|
||||
}
|
||||
|
||||
// Define the specific parameters for each animation type
|
||||
message StaticParams {
|
||||
uint32 color = 1;
|
||||
}
|
||||
message PulseParams {
|
||||
uint32 color = 1;
|
||||
uint32 speed_ms = 2;
|
||||
}
|
||||
message FadeParams {
|
||||
repeated uint32 colors = 1; // Fade between these colors
|
||||
uint32 speed_ms = 2;
|
||||
}
|
||||
message FlickerParams {
|
||||
uint32 color = 1;
|
||||
uint32 intensity = 2; // e.g., 0-100
|
||||
}
|
||||
|
||||
message RfidReading {
|
||||
uint32 card_id = 1;
|
||||
}
|
||||
|
||||
message SensorToControlMessage {
|
||||
uint32 sensor_id = 1;
|
||||
oneof payload {
|
||||
RfidReading rfid_reading = 2;
|
||||
SensorOTAEnableResponse ota_response = 3;
|
||||
// Add other sensor message types as needed
|
||||
}
|
||||
}
|
||||
|
||||
message SensorOTAEnable {
|
||||
string ssid = 1;
|
||||
string password = 2;
|
||||
uint32 timeout_seconds = 3;
|
||||
bool as_station_mode = 4;
|
||||
bool use_static_ip = 5;
|
||||
string static_ip = 6;
|
||||
string netmask = 7;
|
||||
string gateway = 8;
|
||||
}
|
||||
|
||||
message SensorRestart {
|
||||
}
|
||||
|
||||
|
||||
message SensorOTAEnableResponse {
|
||||
bool success = 1;
|
||||
string ip_address = 2;
|
||||
string error_message = 3;
|
||||
}
|
||||
|
||||
|
||||
message ControlToSensorMessage {
|
||||
uint32 control_id = 1;
|
||||
oneof payload {
|
||||
LedConfig led_config = 2;
|
||||
SensorOTAEnable ota_enable = 3;
|
||||
SensorRestart restart = 4;
|
||||
// Add other control message types as needed
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
# Nanopb options for settings.proto
|
||||
|
||||
# SettingsData
|
||||
settings.SettingsData.sync_server_url max_length:256
|
||||
settings.SettingsData.device_api_key max_length:64
|
||||
settings.SettingsData.station_ssid max_length:32
|
||||
settings.SettingsData.station_password max_length:64
|
||||
settings.SettingsData.ap_ssid max_length:32
|
||||
settings.SettingsData.ap_password max_length:64
|
||||
|
||||
# UpdateSettingsResponse
|
||||
settings.UpdateSettingsResponse.error max_length:96
|
||||
@@ -0,0 +1,57 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package settings;
|
||||
|
||||
// WiFi mode enumeration
|
||||
enum WifiMode {
|
||||
WIFI_MODE_UNSPECIFIED = 0;
|
||||
WIFI_MODE_STATION = 1;
|
||||
WIFI_MODE_AP = 2;
|
||||
WIFI_MODE_AP_STATION = 3;
|
||||
}
|
||||
|
||||
// Log level enumeration
|
||||
enum LogLevel {
|
||||
LOG_LEVEL_DEBUG = 0;
|
||||
LOG_LEVEL_INFO = 1;
|
||||
LOG_LEVEL_WARN = 2;
|
||||
LOG_LEVEL_ERROR = 3;
|
||||
}
|
||||
|
||||
// Settings data structure
|
||||
message SettingsData {
|
||||
string sync_server_url = 1;
|
||||
string device_api_key = 2;
|
||||
uint32 sync_interval_seconds = 3;
|
||||
bool auto_sync = 4;
|
||||
WifiMode wifi_mode = 5;
|
||||
string station_ssid = 6;
|
||||
string station_password = 7;
|
||||
string ap_ssid = 8;
|
||||
string ap_password = 9;
|
||||
uint32 ap_channel = 10;
|
||||
bool enable_fallback_ap = 11;
|
||||
int64 updated_at = 12; // Unix timestamp in milliseconds
|
||||
uint32 version = 13; // Settings version for change tracking
|
||||
LogLevel log_level = 14;
|
||||
}
|
||||
|
||||
// Request to get current settings
|
||||
message GetSettingsRequest {
|
||||
}
|
||||
|
||||
// Response with current settings
|
||||
message GetSettingsResponse {
|
||||
SettingsData settings = 1;
|
||||
}
|
||||
|
||||
// Request to update settings
|
||||
message UpdateSettingsRequest {
|
||||
SettingsData settings = 1;
|
||||
}
|
||||
|
||||
// Response to settings update
|
||||
message UpdateSettingsResponse {
|
||||
bool success = 1;
|
||||
optional string error = 2;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
# Nanopb options for webui.proto
|
||||
|
||||
# Use callback-based strings for dynamic memory allocation
|
||||
# No max_length specified to enable callbacks
|
||||
webui.WebUiLoginRequest.username max_length:32
|
||||
webui.WebUiLoginRequest.password max_length:64
|
||||
|
||||
# WebUiLoginResponse
|
||||
webui.WebUiLoginResponse.token max_length:128
|
||||
webui.WebUiLoginResponse.error max_length:96
|
||||
|
||||
# WebUiUser
|
||||
webui.WebUiUser.username max_length:32
|
||||
webui.WebUiUser.password_hash max_length:32
|
||||
|
||||
# GetUsersResponse
|
||||
webui.GetUsersResponse.usernames max_length:32
|
||||
|
||||
# AddUserRequest
|
||||
webui.AddUserRequest.username max_length:32
|
||||
webui.AddUserRequest.password max_length:64
|
||||
|
||||
# DeleteUserRequest
|
||||
webui.DeleteUserRequest.username max_length:32
|
||||
|
||||
# UpdateUserPasswordRequest
|
||||
webui.UpdateUserPasswordRequest.username max_length:32
|
||||
webui.UpdateUserPasswordRequest.new_password max_length:64
|
||||
|
||||
# Response errors
|
||||
webui.AddUserResponse.error max_length:96
|
||||
webui.DeleteUserResponse.error max_length:96
|
||||
webui.UpdateUserPasswordResponse.error max_length:96
|
||||
|
||||
# WebUiAuthCheckResponse
|
||||
webui.WebUiAuthCheckResponse.username max_length:32
|
||||
@@ -0,0 +1,83 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package webui;
|
||||
|
||||
// Login request from Web UI
|
||||
message WebUiLoginRequest {
|
||||
string username = 1; // 1-32 chars
|
||||
string password = 2; // 1-64 chars (plain or hashed)
|
||||
}
|
||||
|
||||
// Login response
|
||||
message WebUiLoginResponse {
|
||||
bool success = 1;
|
||||
optional string token = 2; // session/JWT when success
|
||||
optional string error = 3; // error message when failed
|
||||
}
|
||||
|
||||
// Logout response
|
||||
message WebUiLogoutResponse {
|
||||
bool success = 1;
|
||||
string error = 2;
|
||||
}
|
||||
|
||||
// User data structure
|
||||
message WebUiUser {
|
||||
string username = 1; // 1-32 chars
|
||||
bytes password_hash = 2; // 32 bytes (SHA-256)
|
||||
}
|
||||
|
||||
// User list (max 5 users)
|
||||
message WebUiUserList {
|
||||
repeated WebUiUser users = 1;
|
||||
}
|
||||
|
||||
// Request to get users
|
||||
message GetUsersRequest {
|
||||
}
|
||||
|
||||
// Response with users
|
||||
message GetUsersResponse {
|
||||
repeated string usernames = 1; // List of usernames
|
||||
}
|
||||
|
||||
// Request to add user
|
||||
message AddUserRequest {
|
||||
string username = 1;
|
||||
string password = 2;
|
||||
}
|
||||
|
||||
// Response to add user
|
||||
message AddUserResponse {
|
||||
bool success = 1;
|
||||
optional string error = 2; // e.g., "table full", "user exists"
|
||||
}
|
||||
|
||||
// Request to delete user
|
||||
message DeleteUserRequest {
|
||||
string username = 1;
|
||||
}
|
||||
|
||||
// Response to delete user
|
||||
message DeleteUserResponse {
|
||||
bool success = 1;
|
||||
optional string error = 2; // e.g., "user not found"
|
||||
}
|
||||
|
||||
// Request to update user password
|
||||
message UpdateUserPasswordRequest {
|
||||
string username = 1;
|
||||
string new_password = 2;
|
||||
}
|
||||
|
||||
// Response to update user password
|
||||
message UpdateUserPasswordResponse {
|
||||
bool success = 1;
|
||||
optional string error = 2; // e.g., "user not found"
|
||||
}
|
||||
|
||||
// Auth check response
|
||||
message WebUiAuthCheckResponse {
|
||||
bool authenticated = 1;
|
||||
optional string username = 2;
|
||||
}
|
||||
Reference in New Issue
Block a user