using LibrarySDR.Enums; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using static LibrarySDR.Helpers.BinaryHexHelper; namespace LibrarySDR.Requests { public class StatusRequest { private static PDUType PduType = PDUType.STATUS_REQ_RESP; public static String GetInstance(Int64 sourceISSI, Int64 destinationISSI, Int16 status) { 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)); // status value sb.Append(GetBits(status, 16)); // 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); } public static byte[] GetBytes(Int64 sourceISSI, Int64 destinationISSI, Int16 status) { String res = GetInstance(sourceISSI, destinationISSI, status); byte[] response = new byte[res.Length / 2]; for (int i = 0; i < res.Length / 2; i++) response[i] = (byte)Convert.ToInt16(res.Substring(i * 2, 2), 16); return response; } } }