This commit is contained in:
2025-11-27 18:23:48 +09:00
parent 7f6e35db6b
commit 47f8c4fc59
3 changed files with 53 additions and 16 deletions

View File

@@ -7,6 +7,8 @@ class BLEManager: NSObject, ObservableObject {
@Published var isScanning = false
@Published var bluetoothState: CBManagerState = .unknown
@Published var discoveredDevices: Set<String> = []
@Published var allowedUUIDs: Set<String> = []
@Published var discoveryMode = false
private var centralManager: CBCentralManager!
private var seenNonces: Set<String> = []
@@ -14,13 +16,6 @@ class BLEManager: NSObject, ObservableObject {
// Configuration
private let companyID: UInt16 = 0xFFFF
// Optional: Set specific UUIDs to filter. Empty = accept all devices with correct company ID
// Example: ["12345678-1234-1234-1234-123456789ABC"]
var allowedUUIDs: Set<String> = []
// Set to true to show all devices regardless of company ID (for discovery)
var discoveryMode = false
override init() {
super.init()
centralManager = CBCentralManager(delegate: self, queue: nil)

View File

@@ -48,6 +48,8 @@ struct ContentView: View {
SensorReadingRow(reading: reading)
}
.listStyle(.plain)
.background(Color(.systemGroupedBackground))
.scrollContentBackground(.hidden)
}
// Start/Stop button
@@ -63,6 +65,7 @@ struct ContentView: View {
.padding()
.disabled(bleManager.bluetoothState != .poweredOn)
}
.background(Color(.systemGroupedBackground))
.navigationTitle("EnvSensor Reader")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
@@ -234,7 +237,21 @@ struct SensorReadingRow: View {
.font(.system(.body, design: .monospaced))
}
}
.padding(.vertical, 8)
.padding()
.background(
RoundedRectangle(cornerRadius: 12)
.fill(Color(.secondarySystemGroupedBackground))
)
.overlay(
RoundedRectangle(cornerRadius: 12)
.strokeBorder(Color.blue.opacity(0.4), lineWidth: 2.5)
)
.shadow(color: Color.black.opacity(0.15), radius: 5, x: 0, y: 3)
.padding(.vertical, 6)
.padding(.horizontal, 12)
.listRowInsets(EdgeInsets())
.listRowSeparator(.hidden)
.listRowBackground(Color.clear)
}
private func rssiColor(_ rssi: Int) -> Color {