SafeDispatch/LibrarySDR/Responses/AcknowledgeResponse.cs

53 lines
1.6 KiB
C#
Raw Normal View History

2024-02-22 16:43:59 +00:00
using LibrarySDR.Enums;
using LibrarySDR.Requests;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static LibrarySDR.Helpers.BinaryHexHelper;
namespace LibrarySDR.Responses
{
public class AcknowledgeResponse
{
private static PDUType PduType = PDUType.ACK_RESP;
private static ProtocolIdentifier protocolIdentifier = ProtocolIdentifier.GPSUsingSDSTL;
private static int areaSelection = 0;
public static String GetInstance(Int64 sourceISSI, Int64 destinationISSI, int messageReference, DeliveredStatus deliveryStatus)
{
StringBuilder sb = new StringBuilder("");
// PDU Type (8 bits)
sb.Append(GetBits((int)PduType, 8));
// source ISSI (32 bits)
sb.Append(GetBits(sourceISSI, 32));
// destination ISSI (32 bits)
sb.Append(GetBits(destinationISSI, 32));
// protocol identifier (8 bits)
sb.Append(GetBits((int)protocolIdentifier, 8));
// message reference (8 bits)
sb.Append(GetBits(messageReference, 8));
// area selection (8 bits)
sb.Append(GetBits(areaSelection, 8));
// delivery status (8 bits)
sb.Append(GetBits((int)deliveryStatus, 8));
// get the header with the length
String header = Header.GetHeaderBinary(sb.ToString().Length / 8);
// add header in front of the request
return BinaryStringToHexString($"{header}{sb.ToString()}", Padding.RIGHT);
}
}
}