// lib/features/devices/data/models/route_plan_send_entity.dart import 'dart:typed_data'; // ✅ 必须添加 class RoutePlanSendEntity { final int commandType; final int pointCounts; final double targetLatitude; final double targetLongitude; final int speed; RoutePlanSendEntity({ required this.commandType, required this.pointCounts, required this.targetLatitude, required this.targetLongitude, required this.speed, }); List toBytes() { final bytes = []; bytes.add(commandType); bytes.addAll(_shortToBytes(pointCounts)); bytes.addAll(_doubleToBytes(targetLatitude)); bytes.addAll(_doubleToBytes(targetLongitude)); bytes.addAll(_shortToBytes(speed)); return bytes; } List _shortToBytes(int value) { return [(value >> 8) & 0xFF, value & 0xFF]; } List _doubleToBytes(double value) { final byteData = ByteData(8)..setFloat64(0, value); return byteData.buffer.asUint8List(); } }