connection-refactoring-ai #2

Merged
lambda merged 3 commits from connection-refactoring-ai into main 1 week ago

@ -3197,6 +3197,7 @@ dependencies = [
"tauri",
"tauri-build",
"tauri-plugin-opener",
"thiserror 1.0.69",
"tokio",
"uuid",
]

@ -26,6 +26,7 @@ btleplug = "0.11.8"
tokio = { version = "1", features = ["rt-multi-thread", "macros", "time"] }
hex = "0.4"
uuid = "1.16.0"
thiserror = "1"
[profile.dev]
incremental = true # Compile your binary in smaller steps.

@ -1,10 +1,14 @@
#[derive(Debug)]
use thiserror::Error;
/// Ошибки BLE-слоя. В отличие от прежней заглушки сохраняют источник
/// (`btleplug::Error`), чтобы при отладке было видно, что именно пошло не так.
#[derive(Debug, Error)]
pub enum BleError {
SystemBleError
}
/// Не удалось запустить сканирование.
#[error("не удалось запустить сканирование BLE: {0}")]
ScanFailed(btleplug::Error),
impl From<btleplug::Error> for BleError {
fn from(_: btleplug::Error) -> Self {
BleError::SystemBleError
}
/// Не удалось получить список найденных устройств.
#[error("не удалось получить список BLE-устройств: {0}")]
PeripheralsFailed(btleplug::Error),
}

@ -2,5 +2,6 @@ mod error;
mod utils;
mod scanner;
pub use error::BleError;
pub use scanner::scan_devices;
pub use utils::normalize_uuid;

@ -4,75 +4,95 @@ use std::time::Duration;
use tokio::time;
use crate::ble::error::BleError;
use crate::device::Device;
use hex;
use uuid::{Uuid};
use uuid::Uuid;
/// Сервисы, по которым ищем датчики. Только целевые (HR / CSC / FTMS / мощность).
/// Battery (0x180F) и Device Info (0x180A) убраны: их рекламирует почти любое
/// BLE-устройство, из-за чего скан подхватывал много лишнего и подключался к нему.
static TARGET_UUIDS: &[Uuid] = &[
uuid_from_u16(0x180D), // Heart Rate
uuid_from_u16(0x1816), // Cycling Speed and Cadence
uuid_from_u16(0x1826), // Fitness Machine (FTMS)
uuid_from_u16(0x180F), // Battery Level
uuid_from_u16(0x180A), // Device info
uuid_from_u16(0x1818), // Power meter
uuid_from_u16(0x1818), // Cycling Power
];
const CONNECT_TIMEOUT: Duration = Duration::from_secs(5);
const DISCOVER_TIMEOUT: Duration = Duration::from_secs(5);
const DISCONNECT_TIMEOUT: Duration = Duration::from_secs(2);
pub async fn scan_devices(adapter: &Adapter, scan_seconds: u64) -> Result<Vec<Device>, BleError> {
let target_vec: Vec<Uuid> = TARGET_UUIDS.to_vec();
adapter
.start_scan(ScanFilter { services: TARGET_UUIDS.to_vec() })
.await
.map_err(BleError::ScanFailed)?;
adapter.start_scan(ScanFilter { services: target_vec.clone() }).await?;
time::sleep(Duration::from_secs(scan_seconds)).await;
let peripherals = adapter.peripherals().await.map_err(BleError::PeripheralsFailed)?;
let mut devices = Vec::new();
for peripheral in peripherals {
// Свойства берём из рекламы; если устройство уже пропало - пропускаем.
let Some(props) = peripheral.properties().await.unwrap_or(None) else {
continue;
};
for peripheral in adapter.peripherals().await? {
if let Some(props) = peripheral.properties().await? {
let svc_match = props.services.iter().any(|s| TARGET_UUIDS.iter().any(|t| t == s));
if !svc_match { continue; }
let svc_match = props.services.iter().any(|s| TARGET_UUIDS.contains(s));
if !svc_match {
continue;
}
let manuf = props.manufacturer_data.iter().next().map(|(_,v)| hex::encode(v));
// Для классификации по типу нужны характеристики - подключаемся, читаем,
// отключаемся (best-effort: при сбое устройство всё равно попадёт в список,
// просто без характеристик).
let characteristics = discover_characteristics(&peripheral).await;
let mut characteristics: Vec<String> = Vec::new();
let manuf = props.manufacturer_data.iter().next().map(|(_, v)| hex::encode(v));
let is_connected = peripheral.is_connected().await.unwrap_or(false);
if !is_connected {
let _ = tokio::time::timeout(Duration::from_secs(5), peripheral.connect()).await;
}
devices.push(Device {
id: peripheral.id().to_string(),
address: props.address.to_string(),
display_name: props.local_name,
rssi: props.rssi,
service_uuids: props.services.iter().map(|u| u.to_string()).collect(),
manufacturer_data: manuf,
metadata: None,
characteristics,
});
}
let _ = tokio::time::timeout(Duration::from_secs(5), peripheral.discover_services()).await;
let chars = peripheral.characteristics();
if !chars.is_empty() {
for ch in chars.iter() {
let entry = format!("{}::{}", ch.service_uuid, ch.uuid);
characteristics.push(entry);
}
} else {
for svc in peripheral.services().iter() {
for ch in svc.characteristics.iter() {
let entry = format!("{}::{}", svc.uuid, ch.uuid);
characteristics.push(entry);
}
}
}
adapter.stop_scan().await.ok();
Ok(devices)
}
if !is_connected {
let _ = tokio::time::timeout(Duration::from_secs(2), peripheral.disconnect()).await;
}
/// Подключается к устройству, читает характеристики и отключается.
/// Возвращает список характеристик в формате "service::characteristic".
/// Best-effort: неудачи connect/discover игнорируются.
async fn discover_characteristics(peripheral: &impl Peripheral) -> Vec<String> {
let was_connected = peripheral.is_connected().await.unwrap_or(false);
if !was_connected {
let _ = time::timeout(CONNECT_TIMEOUT, peripheral.connect()).await;
}
let _ = time::timeout(DISCOVER_TIMEOUT, peripheral.discover_services()).await;
devices.push(Device {
id: peripheral.id().to_string(),
address: props.address.to_string(),
display_name: props.local_name,
rssi: props.rssi,
service_uuids: props.services.iter().map(|u| u.to_string()).collect(),
manufacturer_data: manuf,
metadata: None,
characteristics,
});
let mut characteristics = Vec::new();
let chars = peripheral.characteristics();
if !chars.is_empty() {
for ch in chars.iter() {
characteristics.push(format!("{}::{}", ch.service_uuid, ch.uuid));
}
} else {
for svc in peripheral.services().iter() {
for ch in svc.characteristics.iter() {
characteristics.push(format!("{}::{}", svc.uuid, ch.uuid));
}
}
}
adapter.stop_scan().await.ok();
println!("{:?}", devices);
Ok(devices)
if !was_connected {
let _ = time::timeout(DISCONNECT_TIMEOUT, peripheral.disconnect()).await;
}
characteristics
}

@ -1,111 +0,0 @@
use serde::{Deserialize, Serialize};
use serde_json::Value;
use crate::ble::normalize_uuid;
#[derive(Debug, Serialize, Clone, Deserialize)]
pub struct Device {
pub id: String,
pub address: String,
pub display_name: Option<String>,
pub rssi: Option<i16>,
pub service_uuids: Vec<String>,
pub characteristics: Vec<String>,
pub manufacturer_data: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata: Option<Value>,
}
impl Device {}
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum DeviceType {
HrSensor,
CadSensor,
Trainer
}
pub fn get_device_types(device: &Device) -> Vec<DeviceType> {
let hr_services = ["180d"];
let hr_characteristics = ["2a37"];
let csc_services = ["1816"];
let csc_characteristics = ["2a5b"];
// trainer / cycling power / fitness machine / indoor bike
let trainer_services = ["1818", "1826"];
let trainer_characteristics = ["2a63", "2ad2", "2acc"]; // 2AD2 = Indoor Bike Data, 2ACC = Fitness Machine Characteristics, 2A63 = Cycling Power Measurement
// любые 2ADx характеристики (indoor bike related) — учитывать как признак каденса доступного в тренажёре
let indoor_bike_chars_prefix = "2ad"; // covers 2ad2,2ad5,2ad6,2ad8,2ad9,2ada etc.
// Нормализуем все UUIDs
let mut norms = Vec::with_capacity(device.service_uuids.len() + device.characteristics.len());
for u in device.service_uuids.iter().chain(device.characteristics.iter()) {
// Для характеристик, которые приходят в виде "service::characteristic", извлечём часть после "::"
let part = if let Some(idx) = u.find("::") {
&u[idx + 2..]
} else {
u.as_str()
};
norms.push(normalize_uuid(part));
}
let contains_any = |candidates: &[&str]| -> bool {
for cand in candidates {
let cand = cand.to_ascii_lowercase();
if norms.iter().any(|n| n == &cand || n.ends_with(&cand)) {
return true;
}
}
false
};
let mut out = Vec::new();
// Heart rate
if contains_any(&hr_services) || contains_any(&hr_characteristics) {
out.push(DeviceType::HrSensor);
}
// CSC / Cadence
if contains_any(&csc_services) || contains_any(&csc_characteristics) {
out.push(DeviceType::CadSensor);
}
// Trainer/Cycling power/Indoor bike
let is_trainer = contains_any(&trainer_services) || contains_any(&trainer_characteristics);
if is_trainer {
out.push(DeviceType::Trainer);
}
// Доп. логика: если найдены Indoor Bike Data (любые 2ADx characteristics), считаем, что устройство может отдавать cadence —
// добавляем CadSensor, даже если CSC (0x1816/0x2A5B) отсутствует.
let has_indoor_bike_char = norms.iter().any(|n| n.starts_with(indoor_bike_chars_prefix));
if has_indoor_bike_char && !out.contains(&DeviceType::CadSensor) {
out.push(DeviceType::CadSensor);
}
out
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_service_types_for_magene_speedcadence() {
let magene = Device {
id: "hci0/dev_F1_F2_7C_77_14_BE".into(),
address: "F1:F2:7C:77:14:BE".into(),
display_name: Some("10911-17".into()),
rssi: Some(-42),
service_uuids: vec!["00001816-0000-1000-8000-00805f9b34fb".into()],
characteristics: vec![],
manufacturer_data: Some("6b009f2a110300030072".into()),
metadata: None,
};
assert_eq!(get_device_types(&magene), [DeviceType::CadSensor]);
}
}

@ -1,2 +1,111 @@
pub mod device;
pub use device::Device;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use crate::ble::normalize_uuid;
#[derive(Debug, Serialize, Clone, Deserialize)]
pub struct Device {
pub id: String,
pub address: String,
pub display_name: Option<String>,
pub rssi: Option<i16>,
pub service_uuids: Vec<String>,
pub characteristics: Vec<String>,
pub manufacturer_data: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata: Option<Value>,
}
impl Device {}
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum DeviceType {
HrSensor,
CadSensor,
Trainer,
}
pub fn get_device_types(device: &Device) -> Vec<DeviceType> {
let hr_services = ["180d"];
let hr_characteristics = ["2a37"];
let csc_services = ["1816"];
let csc_characteristics = ["2a5b"];
// trainer / cycling power / fitness machine / indoor bike
let trainer_services = ["1818", "1826"];
let trainer_characteristics = ["2a63", "2ad2", "2acc"]; // 2AD2 = Indoor Bike Data, 2ACC = Fitness Machine Characteristics, 2A63 = Cycling Power Measurement
// любые 2ADx характеристики (indoor bike related) - учитывать как признак каденса доступного в тренажёре
let indoor_bike_chars_prefix = "2ad"; // covers 2ad2,2ad5,2ad6,2ad8,2ad9,2ada etc.
// Нормализуем все UUIDs
let mut norms = Vec::with_capacity(device.service_uuids.len() + device.characteristics.len());
for u in device.service_uuids.iter().chain(device.characteristics.iter()) {
// Для характеристик, которые приходят в виде "service::characteristic", извлечём часть после "::"
let part = if let Some(idx) = u.find("::") {
&u[idx + 2..]
} else {
u.as_str()
};
norms.push(normalize_uuid(part));
}
let contains_any = |candidates: &[&str]| -> bool {
for cand in candidates {
let cand = cand.to_ascii_lowercase();
if norms.iter().any(|n| n == &cand || n.ends_with(&cand)) {
return true;
}
}
false
};
let mut out = Vec::new();
// Heart rate
if contains_any(&hr_services) || contains_any(&hr_characteristics) {
out.push(DeviceType::HrSensor);
}
// CSC / Cadence
if contains_any(&csc_services) || contains_any(&csc_characteristics) {
out.push(DeviceType::CadSensor);
}
// Trainer/Cycling power/Indoor bike
let is_trainer = contains_any(&trainer_services) || contains_any(&trainer_characteristics);
if is_trainer {
out.push(DeviceType::Trainer);
}
// Доп. логика: если найдены Indoor Bike Data (любые 2ADx characteristics), считаем, что устройство может отдавать cadence -
// добавляем CadSensor, даже если CSC (0x1816/0x2A5B) отсутствует.
let has_indoor_bike_char = norms.iter().any(|n| n.starts_with(indoor_bike_chars_prefix));
if has_indoor_bike_char && !out.contains(&DeviceType::CadSensor) {
out.push(DeviceType::CadSensor);
}
out
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_service_types_for_magene_speedcadence() {
let magene = Device {
id: "hci0/dev_F1_F2_7C_77_14_BE".into(),
address: "F1:F2:7C:77:14:BE".into(),
display_name: Some("10911-17".into()),
rssi: Some(-42),
service_uuids: vec!["00001816-0000-1000-8000-00805f9b34fb".into()],
characteristics: vec![],
manufacturer_data: Some("6b009f2a110300030072".into()),
metadata: None,
};
assert_eq!(get_device_types(&magene), [DeviceType::CadSensor]);
}
}

@ -1,3 +1,3 @@
mod repo;
pub use repo::repo_from_devices;
pub use repo::{repo_from_devices, Repo};

@ -1,5 +1,5 @@
use serde::{Deserialize, Serialize};
use crate::{device::{device::{get_device_types, DeviceType}, Device}};
use crate::device::{Device, DeviceType, get_device_types};
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Repo {
@ -8,7 +8,7 @@ pub struct Repo {
#[serde(default)]
cad_sensors: Vec<Device>,
#[serde(default)]
trainers: Vec<Device>
trainers: Vec<Device>,
}
impl Repo {
@ -61,7 +61,7 @@ mod tests {
use super::*;
#[test]
fn test_service_types_for_magene_speedcadence() {
fn test_repo_classifies_magene_as_cadence_sensor() {
let magene = Device {
id: "hci0/dev_F1_F2_7C_77_14_BE".into(),
address: "F1:F2:7C:77:14:BE".into(),
@ -73,13 +73,10 @@ mod tests {
metadata: None,
};
let devices = vec![magene];
let x = repo_from_devices(devices);
let repo = repo_from_devices(vec![magene]);
println!("{:?}", x);
//assert_eq!(repo_from_devices(devices), Repo::new());
assert_eq!(2, 3);
assert_eq!(repo.cad_sensors.len(), 1);
assert!(repo.hr_sensors.is_empty());
assert!(repo.trainers.is_empty());
}
}

@ -5,24 +5,45 @@ mod state;
use std::sync::Arc;
use tauri::{AppHandle, Emitter, Manager, async_runtime};
use crate::{ble::scan_devices, device_repo::{repo_from_devices}};
use crate::{ble::scan_devices, device_repo::{repo_from_devices, Repo}};
use crate::state::State;
use btleplug::api::{Manager as ApiManager};
use btleplug::api::Manager as ApiManager;
use btleplug::platform::Manager as BleManager;
/// Сколько секунд сканируем BLE на старте.
const SCAN_SECONDS: u64 = 5;
#[tauri::command]
async fn init(app: AppHandle) -> Result<(),()> {
async fn init(app: AppHandle) -> Result<(), String> {
println!("init rideinn app");
let splash = app.get_webview_window("splashscreen").unwrap();
let connect = app.get_webview_window("connect").unwrap();
let repo = scan_and_classify(&app).await.map_err(|e| e.to_string())?;
present_repo(&app, repo).map_err(|e| e.to_string())?;
Ok(())
}
/// Этап 1: скан BLE-устройств и раскладка по типам датчиков.
async fn scan_and_classify(app: &AppHandle) -> Result<Repo, ble::BleError> {
let state = app.state::<State>();
let adapter = state.adapter.clone();
let repo = repo_from_devices((scan_devices(&adapter, 5).await).unwrap_or_default());
let devices = scan_devices(&adapter, SCAN_SECONDS).await?;
Ok(repo_from_devices(devices))
}
splash.close().unwrap();
connect.show().unwrap();
/// Этап 2: закрываем сплэш, показываем главное окно, отдаём список датчиков на фронт.
fn present_repo(app: &AppHandle, repo: Repo) -> Result<(), String> {
let splash = app
.get_webview_window("splashscreen")
.ok_or("окно splashscreen не найдено")?;
let main = app
.get_webview_window("main")
.ok_or("окно main не найдено")?;
app.emit_to("connect", "devices-loaded", repo).unwrap();
splash.close().map_err(|e| format!("не удалось закрыть splashscreen: {e}"))?;
main.show().map_err(|e| format!("не удалось показать main: {e}"))?;
app.emit("devices-loaded", repo)
.map_err(|e| format!("не удалось отправить событие devices-loaded: {e}"))?;
Ok(())
}
@ -36,8 +57,8 @@ pub fn run() {
let adapters = manager.adapters().await?;
let adapter = adapters.into_iter().next()
.ok_or_else(|| Box::<dyn std::error::Error>::from("No BLE adapter found"))?;
app.manage(State { adapter: Arc::new(adapter) } );
app.manage(State { adapter: Arc::new(adapter) });
Ok::<(), Box<dyn std::error::Error>>(())
})
})

@ -16,11 +16,6 @@
{
"label": "splashscreen",
"url": "splashscreen"
},
{
"label": "connect",
"url": "connect",
"visible": false
}
],
"security": {

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="32" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path fill="#F7DF1E" d="M0 0h256v256H0V0Z"></path><path d="m67.312 213.932l19.59-11.856c3.78 6.701 7.218 12.371 15.465 12.371c7.905 0 12.89-3.092 12.89-15.12v-81.798h24.057v82.138c0 24.917-14.606 36.259-35.916 36.259c-19.245 0-30.416-9.967-36.087-21.996m85.07-2.576l19.588-11.341c5.157 8.421 11.859 14.607 23.715 14.607c9.969 0 16.325-4.984 16.325-11.858c0-8.248-6.53-11.17-17.528-15.98l-6.013-2.58c-17.357-7.387-28.87-16.667-28.87-36.257c0-18.044 13.747-31.792 35.228-31.792c15.294 0 26.292 5.328 34.196 19.247l-18.732 12.03c-4.125-7.389-8.591-10.31-15.465-10.31c-7.046 0-11.514 4.468-11.514 10.31c0 7.217 4.468 10.14 14.778 14.608l6.014 2.577c20.45 8.765 31.963 17.7 31.963 37.804c0 21.654-17.012 33.51-39.867 33.51c-22.339 0-36.774-10.654-43.819-24.574"></path></svg>

Before

Width:  |  Height:  |  Size: 995 B

@ -1,6 +0,0 @@
<svg width="206" height="231" viewBox="0 0 206 231" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M143.143 84C143.143 96.1503 133.293 106 121.143 106C108.992 106 99.1426 96.1503 99.1426 84C99.1426 71.8497 108.992 62 121.143 62C133.293 62 143.143 71.8497 143.143 84Z" fill="#FFC131"/>
<ellipse cx="84.1426" cy="147" rx="22" ry="22" transform="rotate(180 84.1426 147)" fill="#24C8DB"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M166.738 154.548C157.86 160.286 148.023 164.269 137.757 166.341C139.858 160.282 141 153.774 141 147C141 144.543 140.85 142.121 140.558 139.743C144.975 138.204 149.215 136.139 153.183 133.575C162.73 127.404 170.292 118.608 174.961 108.244C179.63 97.8797 181.207 86.3876 179.502 75.1487C177.798 63.9098 172.884 53.4021 165.352 44.8883C157.82 36.3744 147.99 30.2165 137.042 27.1546C126.095 24.0926 114.496 24.2568 103.64 27.6274C92.7839 30.998 83.1319 37.4317 75.8437 46.1553C74.9102 47.2727 74.0206 48.4216 73.176 49.5993C61.9292 50.8488 51.0363 54.0318 40.9629 58.9556C44.2417 48.4586 49.5653 38.6591 56.679 30.1442C67.0505 17.7298 80.7861 8.57426 96.2354 3.77762C111.685 -1.01901 128.19 -1.25267 143.769 3.10474C159.348 7.46215 173.337 16.2252 184.056 28.3411C194.775 40.457 201.767 55.4101 204.193 71.404C206.619 87.3978 204.374 103.752 197.73 118.501C191.086 133.25 180.324 145.767 166.738 154.548ZM41.9631 74.275L62.5557 76.8042C63.0459 72.813 63.9401 68.9018 65.2138 65.1274C57.0465 67.0016 49.2088 70.087 41.9631 74.275Z" fill="#FFC131"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M38.4045 76.4519C47.3493 70.6709 57.2677 66.6712 67.6171 64.6132C65.2774 70.9669 64 77.8343 64 85.0001C64 87.1434 64.1143 89.26 64.3371 91.3442C60.0093 92.8732 55.8533 94.9092 51.9599 97.4256C42.4128 103.596 34.8505 112.392 30.1816 122.756C25.5126 133.12 23.9357 144.612 25.6403 155.851C27.3449 167.09 32.2584 177.598 39.7906 186.112C47.3227 194.626 57.153 200.784 68.1003 203.846C79.0476 206.907 90.6462 206.743 101.502 203.373C112.359 200.002 122.011 193.568 129.299 184.845C130.237 183.722 131.131 182.567 131.979 181.383C143.235 180.114 154.132 176.91 164.205 171.962C160.929 182.49 155.596 192.319 148.464 200.856C138.092 213.27 124.357 222.426 108.907 227.222C93.458 232.019 76.9524 232.253 61.3736 227.895C45.7948 223.538 31.8055 214.775 21.0867 202.659C10.3679 190.543 3.37557 175.59 0.949823 159.596C-1.47592 143.602 0.768139 127.248 7.41237 112.499C14.0566 97.7497 24.8183 85.2327 38.4045 76.4519ZM163.062 156.711L163.062 156.711C162.954 156.773 162.846 156.835 162.738 156.897C162.846 156.835 162.954 156.773 163.062 156.711Z" fill="#24C8DB"/>
</svg>

Before

Width:  |  Height:  |  Size: 2.5 KiB

@ -0,0 +1,8 @@
:root {
--jet: hsla(0, 0%, 21%, 1);
--gunmetal: hsla(216, 28%, 20%, 1);
--cadet-gray: hsla(212, 8%, 58%, 1);
--nyanza: hsla(114, 100%, 93%, 1);
--rojo: hsla(357, 73%, 50%, 1);
--basewhite: #f6f6f6;
}

@ -1,18 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="styles.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri App</title>
<script type="module" src="/connect.js" defer></script>
</head>
<body>
<main class="container">
<h1>Connect</h1>
<div id="app">
</div>
</main>
</body>
</html>

@ -1,7 +0,0 @@
const { once } = window.__TAURI__.event;
const { getCurrentWebviewWindow } = window.__TAURI__.webviewWindow;
const appWebview = getCurrentWebviewWindow();
appWebview.once("devices-loaded", (devices) => {
console.log("Devices are loaded", devices);
});

@ -9,10 +9,12 @@
</head>
<body>
<main class="container">
<h1>Welcome to RideInn</h1>
<div id="app">
</div>
</main>
<div class="screen" id="connect">
<h1>подключение датчиков</h1>
<div class="device-selection" id="hr-monitor-selection"><h2>чсс</h2></div>
<div class="device-selection" id="cadence-sensor-selection"><h2>каденс</h2></div>
<div class="device-selection" id="trainer-selection"><h2>станок</h2></div>
<button>начать</button>
</div>
</body>
</html>

@ -1 +1,7 @@
const { once } = window.__TAURI__.event;
once("devices-loaded", (devices) => {
console.log("Devices are loaded", devices);
});
console.log("hello from main.js");

@ -0,0 +1,78 @@
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
vertical-align: baseline;
box-sizing: border-box;
background: transparent;
}
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
ol, ul {
list-style: none;
}
img, picture, svg, video, iframe {
max-width: 100%;
height: auto;
display: block;
}
button, input, select, textarea {
font: inherit;
color: inherit;
background: transparent;
border: none;
padding: 0;
margin: 0;
outline: none;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
:focus {
outline: 2px solid Highlight;
outline-offset: 2px;
}
button, [role="button"], a[type="button"] {
cursor: pointer;
}
a {
color: inherit;
text-decoration: none;
background-color: transparent;
}
:disabled, [disabled] {
cursor: not-allowed;
opacity: 0.6;
pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.001ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.001ms !important;
scroll-behavior: auto !important;
}
}

@ -8,11 +8,7 @@
<script type="module" src="/init.js" defer></script>
</head>
<body>
<main class="container">
<h1>SplashScreen</h1>
<div id="app">
</div>
</main>
<body class="screen splashscreen">
<h1>поиск перефирии</h1>
</body>
</html>

@ -1,11 +1,14 @@
@import "./reset.css";
@import "./colors.css";
:root {
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
font-size: 16px;
line-height: 24px;
font-weight: 400;
color: #0f0f0f;
background-color: #f6f6f6;
color: var(--basewhite);
background-color: var(--jet);
font-synthesis: none;
text-rendering: optimizeLegibility;
@ -14,22 +17,42 @@
-webkit-text-size-adjust: 100%;
}
@media (prefers-color-scheme: dark) {
:root {
color: #f6f6f6;
background-color: #2f2f2f;
}
a:hover {
color: #24c8db;
}
input,
button {
color: #ffffff;
background-color: #0f0f0f98;
}
button:active {
background-color: #0f0f0f69;
}
body,
screen {
overflow: hidden;
}
.screen {
align-content: center;
display: grid;
height: 100vh;
justify-content: center;
width: 100vw;
}
#connect {
gap: 2em;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: repeat(3, 1fr);
padding: 2em;
}
#connect h1 {
grid-column: 1/-1;
justify-self: center;
align-self: end;
}
#connect button {
grid-column: 1/-1;
justify-self: center;
align-self: start;
}
.device-selection {
border: 1px solid var(--basewhite);
border-radius: 2%;
display: grid;
justify-content: center;
padding: 0.5em;
}

Loading…
Cancel
Save