Skip to main content

netget/server/bluetooth_ble_running/
mod.rs

1//! BLE Running Speed and Cadence Service (0x1814)
2pub mod actions;
3use anyhow::Result;
4use std::sync::Arc;
5use tokio::sync::mpsc;
6
7pub struct BluetoothBleRunning;
8impl BluetoothBleRunning {
9    #[cfg(all(unix, feature = "bluetooth"))]
10    pub async fn spawn_with_llm_actions(
11        device_name: String,
12        llm: crate::llm::ollama_client::OllamaClient,
13        state: Arc<crate::state::app_state::AppState>,
14        tx: mpsc::UnboundedSender<String>,
15        id: crate::state::ServerId,
16        inst: String,
17    ) -> Result<std::net::SocketAddr> {
18        crate::server::bluetooth_ble::BluetoothBle::spawn_with_llm_actions(
19            device_name,
20            llm,
21            state,
22            tx,
23            id,
24            {
25                // The user's instruction leads and the profile sentence is appended to it; an
26                // empty instruction gets the sentence alone. This was
27                // `format!("{}. Configure as ...", inst)`, which put a stray leading period in
28                // front of the sentence when the instruction was empty and a doubled one after
29                // it when the instruction already ended in a full stop — in the prompt the
30                // model actually reads.
31                let inst = inst.trim().trim_end_matches('.').trim();
32                if inst.is_empty() {
33                    "Configure as a BLE Running Speed and Cadence Service (0x1814).".to_string()
34                } else {
35                    format!(
36                        "{inst}. Configure as a BLE Running Speed and Cadence Service (0x1814)."
37                    )
38                }
39            },
40        )
41        .await
42    }
43}
44#[cfg(any(all(unix, not(feature = "bluetooth")), not(unix)))]
45impl BluetoothBleRunning {
46    pub async fn spawn_with_llm_actions(
47        _: String,
48        _: crate::llm::ollama_client::OllamaClient,
49        _: Arc<crate::state::app_state::AppState>,
50        _: mpsc::UnboundedSender<String>,
51        _: crate::state::ServerId,
52        _: String,
53    ) -> Result<std::net::SocketAddr> {
54        anyhow::bail!("BLE running not enabled")
55    }
56}
57
58pub const RUNNING_SERVICE: u16 = 0x1814;
59pub const RSC_MEASUREMENT: u16 = 0x2A53;