Skip to content

Latest commit

 

History

History
71 lines (48 loc) · 2 KB

File metadata and controls

71 lines (48 loc) · 2 KB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Build Commands

# Build and publish for release
dotnet publish --configuration Release

# Build for development
dotnet build

# Run the application directly
dotnet run

Application Usage

The application scans for SwitchBot temperature/humidity meters and displays their readings:

# Single reading (default)
SwitchBotMeter

# With custom timeout (seconds)
SwitchBotMeter --timeout 10

# Continuous reading with limit
SwitchBotMeter --timeout 60 --limit 0

# Infinite continuous reading
SwitchBotMeter --timeout 0 --limit 0

# List all Bluetooth LE devices
SwitchBotMeter --list

# Show help
SwitchBotMeter --help

Architecture

This is a .NET 6.0 Windows console application that uses Windows Bluetooth LE APIs to scan for SwitchBot devices.

Core Components

  • Program.cs: Main application entry point containing command-line parsing, device scanning logic, and output formatting
  • SwitchBotUtil.cs: Utility classes defining SwitchBot device constants and UUIDs

Device Support

The application supports multiple SwitchBot device types:

  • Original Meter (uses service UUID scanning)
  • MeterPlus, MeterPro, OutdoorMeter (uses manufacturer data and service data)

Data Flow

  1. Parses command-line arguments for timeout, limit, and operation mode
  2. Creates BluetoothLEAdvertisementWatcher to scan for BLE advertisements
  3. Filters advertisements by SwitchBot service UUIDs or manufacturer data
  4. Decodes temperature, humidity, and battery data from advertisement payloads
  5. Outputs formatted readings: ADDRESS TEMP HUMIDITY BATTERY DEVICE_TYPE

Key Technical Details

  • Uses Windows Runtime APIs (Windows.Devices.Bluetooth)
  • Requires .NET 6.0 with Windows 10 Build 19041+ target
  • Single-file publish configuration for standalone deployment
  • Active scanning mode for better device detection
  • Two-stage detection for newer devices (service data then manufacturer data)