Support for two device types

This commit is contained in:
2025-12-24 18:40:07 -06:00
parent 3215702893
commit 1f49116d6f
4 changed files with 80 additions and 12 deletions

View File

@@ -123,8 +123,11 @@ class _AddDeviceState extends State<AddDevice> {
}
Widget _buildScanResultTiles() {
// final res = _scanResults.where((r) => r.advertisementData.advName == "BlindMaster Device" && r.rssi > -55);
final res = _scanResults.where((r) => r.advertisementData.advName == "BlindMaster-C6");
// Filter for both BlindMaster-C6 and BlindMaster Device
final res = _scanResults.where((r) =>
r.advertisementData.advName == "BlindMaster-C6" ||
r.advertisementData.advName == "BlindMaster Device"
);
return (res.isNotEmpty)
? ListView(
children: [

View File

@@ -46,6 +46,7 @@ class DeviceSetup extends StatefulWidget {
class _DeviceSetupState extends State<DeviceSetup> {
bool refreshing = false;
List<BluetoothService> _services = [];
int maxPorts = 4; // Default to multi-port
List<Map<String, dynamic>> networks = [];
@@ -60,6 +61,13 @@ class _DeviceSetupState extends State<DeviceSetup> {
@override void initState() {
super.initState();
// Detect device type from platform name
final deviceName = widget.device.platformName;
if (deviceName == "BlindMaster-C6") {
maxPorts = 1;
} else if (deviceName == "BlindMaster Device") {
maxPorts = 4;
}
initSetup();
}
@@ -308,7 +316,12 @@ class _DeviceSetupState extends State<DeviceSetup> {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SetDeviceName(tokenEntryChar: tokenEntryChar, authConfirmChar: authConfirmChar, device: widget.device),
builder: (context) => SetDeviceName(
tokenEntryChar: tokenEntryChar,
authConfirmChar: authConfirmChar,
device: widget.device,
maxPorts: maxPorts,
),
)
).then((_) {
if (widget.device.isConnected) {

View File

@@ -11,10 +11,17 @@ import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:google_fonts/google_fonts.dart';
class SetDeviceName extends StatefulWidget {
const SetDeviceName({super.key, required this.tokenEntryChar, required this.authConfirmChar, required this.device});
const SetDeviceName({
super.key,
required this.tokenEntryChar,
required this.authConfirmChar,
required this.device,
required this.maxPorts,
});
final BluetoothCharacteristic tokenEntryChar;
final BluetoothCharacteristic authConfirmChar;
final BluetoothDevice device;
final int maxPorts;
@override
State<SetDeviceName> createState() => _SetDeviceNameState();
@@ -57,7 +64,10 @@ class _SetDeviceNameState extends State<SetDeviceName> {
}
Future addDevice(String name) async {
final payload = {'deviceName': name};
final payload = {
'deviceName': name,
'maxPorts': widget.maxPorts,
};
String? token;
try {
final tokenResponse = await securePost(payload, 'add_device');