40 lines
995 B
Dart
Executable File
40 lines
995 B
Dart
Executable File
|
||
import 'dart:convert';
|
||
|
||
import '../../blue/io_tool/io_tool.dart';
|
||
import 'io_udpType.dart';
|
||
|
||
abstract class IOData {
|
||
List<int> messageDetail();
|
||
}
|
||
|
||
abstract class UDPSenderProtocol extends IOData {
|
||
// var uint8View1 = Uint8List(300);
|
||
|
||
CommandUDPType? commandType; //指令类型
|
||
// final List<int> header = [0XEF, 0X01, 0XEE, 0X02]; //帧头 固定取值 0XEF01EE02,长度 4 字节
|
||
// final int ask = 0X01 ; // 包类型:0X01 表示请求包,0X11 表示应答包,长度 1 字节
|
||
|
||
List<int>? commandData = []; //数据块
|
||
|
||
UDPSenderProtocol(this.commandType) {
|
||
|
||
}
|
||
|
||
// 拼装数据
|
||
List<int> packageData() {
|
||
commandData = messageDetail();
|
||
List<int> commandList = [];
|
||
|
||
var cID = "XXXCID";
|
||
commandList.addAll(utf8.encode(cID));
|
||
commandList = getFixedLengthList(commandList, 6 - utf8.encode(cID).length);
|
||
|
||
// 数据块
|
||
commandList.addAll(commandData!); //数据块
|
||
// AppLog.log("commandList:$commandList");
|
||
return commandList;
|
||
}
|
||
|
||
|
||
} |