- Remove hardcoded database credentials from all scripts - Remove hardcoded Legacy API tokens from backend scripts - Remove hardcoded MQTT credentials from mqtt-test.js - Update backend/.env.example with DB_HOST, DB_USER, DB_PASSWORD, DB_NAME - Update backend/.env.example with LEGACY_API_TOKEN and MQTT credentials - Add dotenv config to all scripts requiring credentials - Create comprehensive documentation: - scripts/README.md - Root scripts usage - backend/scripts/README.md - Backend scripts documentation - MQTT_TESTING.md - MQTT testing guide - SECURITY_CREDENTIALS_CLEANUP.md - Security changes summary All scripts now read credentials from backend/.env instead of hardcoded values. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
53 lines
1.8 KiB
Python
53 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Discover BLE services and characteristics of WP sensor"""
|
|
|
|
import asyncio
|
|
from bleak import BleakClient, BleakScanner
|
|
|
|
async def main():
|
|
print("Scanning for WP sensors...")
|
|
devices = await BleakScanner.discover(timeout=5.0)
|
|
|
|
wp_device = None
|
|
for d in devices:
|
|
if d.name and d.name.startswith("WP_"):
|
|
print(f"Found: {d.name} ({d.address})")
|
|
wp_device = d
|
|
break
|
|
|
|
if not wp_device:
|
|
print("No WP sensor found!")
|
|
return
|
|
|
|
print(f"\nConnecting to {wp_device.name}...")
|
|
async with BleakClient(wp_device.address) as client:
|
|
print("Connected!")
|
|
print(f"MTU: {client.mtu_size}")
|
|
|
|
print("\n=== Services and Characteristics ===\n")
|
|
for service in client.services:
|
|
print(f"Service: {service.uuid}")
|
|
print(f" Description: {service.description}")
|
|
|
|
for char in service.characteristics:
|
|
props = ", ".join(char.properties)
|
|
print(f" Characteristic: {char.uuid}")
|
|
print(f" Properties: {props}")
|
|
print(f" Handle: {char.handle}")
|
|
|
|
# Try to read if readable
|
|
if "read" in char.properties:
|
|
try:
|
|
value = await client.read_gatt_char(char.uuid)
|
|
try:
|
|
decoded = value.decode('utf-8', errors='replace')
|
|
print(f" Value: {decoded}")
|
|
except:
|
|
print(f" Value (hex): {value.hex()}")
|
|
except Exception as e:
|
|
print(f" (Could not read: {e})")
|
|
print()
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|