605 lines
9.7 KiB
C++
605 lines
9.7 KiB
C++
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include <set>
|
|
#include <map>
|
|
#include <memory>
|
|
#include <vector>
|
|
#include <QByteArray>
|
|
#include <CoPrtCnv/coprtcnv_export.h>
|
|
#include "tetra_telegram_ids.h"
|
|
|
|
namespace NGL
|
|
{
|
|
class INGLLogger;
|
|
}
|
|
|
|
namespace N_CoPrtCnv
|
|
{
|
|
|
|
|
|
enum class E_LicensingKind
|
|
{
|
|
|
|
|
|
Success = 0,
|
|
|
|
|
|
Rejected = 1,
|
|
|
|
|
|
Unlicense = 2
|
|
};
|
|
|
|
|
|
|
|
enum class E_LicensingErrorCode
|
|
{
|
|
Ok = 0,
|
|
Selftest = 1,
|
|
Battery = 2,
|
|
Configuration = 3,
|
|
Unlicense = 4,
|
|
IdentityDenied = 5
|
|
};
|
|
|
|
|
|
|
|
class COPRTCNV_EXPORT CoPrtCnvRadioTelegram
|
|
{
|
|
public:
|
|
|
|
|
|
|
|
enum E_Flags
|
|
{
|
|
e_FlagsNone = 0x00,
|
|
e_StorageAllowed = 0x10,
|
|
e_GroupServiceOrOnlyStandardReportAllowed = 0x20,
|
|
e_ReceivedConfirmationRequested = 0x40,
|
|
e_ConsumedConfirmationRequested = 0x80
|
|
};
|
|
|
|
|
|
|
|
enum E_ProtocolIdentifier
|
|
{
|
|
e_SimpleTextMessagingWithoutSDS_TL = 0x02,
|
|
e_SimpleGPS_WithoutSDS_TL = 0x03,
|
|
e_TDSMessageWithoutSDS_TL = 0x50,
|
|
e_UsingSDS_TL = 0x80,
|
|
e_SimpleTextMessagingUsingSDS_TL = 0x82,
|
|
e_SimpleGPS_UsingSDS_TL = 0x83,
|
|
e_LoginTest = 0x1D
|
|
};
|
|
|
|
|
|
|
|
enum E_FragmentStatus
|
|
{
|
|
e_NotFragmented = 0x00,
|
|
e_FirstFragment = 0x40,
|
|
e_MiddleFragment = 0xC0,
|
|
e_LastFragment = 0x80,
|
|
e_FragmentStatusMask = 0xC0,
|
|
e_Checksum = 0x20,
|
|
e_CounterMask = 0x0F,
|
|
e_NormalTelegram = 0x00,
|
|
e_LoginTelegram = 0x02,
|
|
e_DgpsTelegram = 0x03
|
|
};
|
|
|
|
|
|
|
|
struct PrtCnvRadioGwHeader
|
|
{
|
|
|
|
|
|
uint8_t m_MagicNumber;
|
|
|
|
|
|
uint8_t m_Counter;
|
|
|
|
|
|
uint16_t m_Length;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum E_PDU_Type
|
|
{
|
|
e_RegisterInd = 0,
|
|
e_RegisterRsp = 1,
|
|
e_DataIndReq = 2,
|
|
e_ReportIndReq = 3,
|
|
e_StatusIndReq = 4,
|
|
e_GroupMonitorReq = 6,
|
|
e_AirInterfaceLoadReq = 8,
|
|
e_AirLoadHyterra = 19
|
|
};
|
|
|
|
|
|
|
|
enum E_RegistrationStatus
|
|
{
|
|
e_IssiSuccessfulRegistered = 0,
|
|
e_DuplicateISSI = 1,
|
|
e_InvalidISSI = 2,
|
|
e_InvalidIpAddress = 3
|
|
};
|
|
|
|
|
|
|
|
enum E_DeliveryStatusForTL_Report
|
|
{
|
|
e_SDS_ReceiptAcknowledgedByDestination = 0x00,
|
|
e_SDS_ConsumedByDestination = 0x02,
|
|
e_SourceIsNotAuthorizedForSDS = 0x43,
|
|
e_DestinationIsNotAuthorizedForSDS = 0x44,
|
|
e_UnknownDestinationAddress = 0x45,
|
|
e_DeliveryFailed = 0x4A,
|
|
e_DestinationNotRegisteredOnSystem = 0x4B,
|
|
e_DestinationQueueFull = 0x4C,
|
|
e_MessageTooLong = 0x4D,
|
|
e_DestinationHostPC_NotConnected = 0x4F,
|
|
e_ProtocolNotSupported = 0x50,
|
|
e_DataCodingSchemeNotSupported = 0x51,
|
|
e_DestinationNotReachable = 0x5A
|
|
};
|
|
|
|
|
|
|
|
enum E_LoginStatus
|
|
{
|
|
e_LoginRequest = 0x40,
|
|
e_LoginAccept = 0x80,
|
|
e_LoginReject = 0xC0,
|
|
e_LoginStatusMask = 0xC0,
|
|
e_LoginMastering = 0x20,
|
|
|
|
|
|
e_LoginNoExerciseAssignment = 0x00,
|
|
e_LoginOtherEqId = 0x02,
|
|
e_LoginOtherISSI = 0x04,
|
|
e_LoginOtherExercise = 0x06,
|
|
};
|
|
|
|
|
|
|
|
static constexpr uint8_t MAGIC_NUMBER = 0xA5;
|
|
|
|
|
|
static constexpr uint16_t DATA_IND_REQ_WITH_TL_HEADER_LENGTH = 22;
|
|
|
|
|
|
static constexpr uint16_t DATA_IND_REQ_HEADER_LENGTH = 27;
|
|
|
|
|
|
static constexpr uint16_t DATA_IND_REQ_HEADER_LENGTH_WITHOUT_PAYLOAD_HEADER = DATA_IND_REQ_HEADER_LENGTH -1;
|
|
|
|
|
|
static constexpr uint16_t DATA_IND_REQ_NO_TL_HEADER_LENGTH = 14;
|
|
|
|
|
|
static constexpr uint16_t MAX_RADIO_TELEGRAM_PAYLOAD_LENGTH = 249;
|
|
|
|
|
|
static constexpr uint16_t PAYLOAD_STATUS_LENGTH = 1;
|
|
|
|
|
|
static constexpr uint8_t MAX_NBR_OF_FRAGMENTS = 16;
|
|
|
|
|
|
|
|
|
|
explicit CoPrtCnvRadioTelegram(const uint32_t a_sourceISSI);
|
|
|
|
|
|
|
|
explicit CoPrtCnvRadioTelegram(const uint32_t a_sourceISSI, const std::set<uint32_t> &groups);
|
|
|
|
|
|
|
|
explicit CoPrtCnvRadioTelegram(const uint32_t a_sourceISSI, const E_DeliveryStatusForTL_Report a_delivery);
|
|
|
|
|
|
|
|
explicit CoPrtCnvRadioTelegram(const QByteArray &a_data);
|
|
|
|
|
|
|
|
explicit CoPrtCnvRadioTelegram(const gef_telegramm_id_et a_telegramId, const uint16_t a_payloadSize, const uint16_t a_identity);
|
|
|
|
|
|
|
|
explicit CoPrtCnvRadioTelegram(const E_LoginStatus a_loginTelegramStatus, const uint16_t a_identity, uint32_t a_issi);
|
|
|
|
void setLoginIssis(int hostIssi, int groupIssi1, int groupIssi2);
|
|
|
|
|
|
|
|
explicit CoPrtCnvRadioTelegram(const std::shared_ptr<CoPrtCnvRadioTelegram> &a_bigTelegram,
|
|
const uint8_t a_fragmentIndex, bool &a_error);
|
|
|
|
|
|
virtual ~CoPrtCnvRadioTelegram();
|
|
|
|
|
|
|
|
void fixupTelegramIdForEts(bool convertToEtsId);
|
|
static void setEtsMode(bool bIsEtsMode);
|
|
|
|
|
|
|
|
void setPayload1Byte(uint8_t a_value);
|
|
void setPayload2Byte(uint16_t a_value);
|
|
void setPayload3Byte(uint32_t a_value);
|
|
void setPayload4Byte(uint32_t a_value);
|
|
void setPayloadData(uint32_t a_value, const uint8_t a_size);
|
|
|
|
|
|
|
|
void setPayloadData(const uint8_t a_value) { return setPayload1Byte(a_value); }
|
|
|
|
|
|
|
|
void setPayloadData(const uint8_t *a_data, const uint16_t a_size);
|
|
|
|
|
|
|
|
const char *getData() const { return m_data.data(); }
|
|
char *getData() { return m_data.data(); }
|
|
QByteArray data() const { return m_data; }
|
|
|
|
|
|
|
|
int getSize() const { return m_data.size(); }
|
|
|
|
|
|
|
|
gef_telegramm_id_et getTelID() const;
|
|
|
|
|
|
|
|
uint8_t zaehler() const;
|
|
|
|
|
|
|
|
void setZaehler(const uint8_t a_counter);
|
|
|
|
|
|
|
|
uint32_t getPayloadDataUInt32(size_t a_offset, uint16_t a_size) const;
|
|
|
|
|
|
|
|
uint8_t getPayloadDataUInt8(size_t a_offset) const;
|
|
|
|
|
|
|
|
uint32_t getDestISSI() const;
|
|
|
|
|
|
|
|
uint16_t getIdentity() const;
|
|
|
|
|
|
|
|
void setSrcISSI(const uint32_t a_ISSI);
|
|
|
|
|
|
|
|
bool mustBroadcastBeSet() const;
|
|
|
|
|
|
|
|
void setBroadcastIndex(const uint16_t a_broadcastIndex);
|
|
|
|
|
|
|
|
void setDestISSI(const uint32_t a_ISSI);
|
|
|
|
|
|
|
|
CoPrtCnvRadioTelegram::E_PDU_Type getPDU_Type() const;
|
|
|
|
|
|
|
|
CoPrtCnvRadioTelegram::E_FragmentStatus getFragmentStatus() const;
|
|
|
|
|
|
|
|
uint8_t getFragmentCounter() const;
|
|
|
|
|
|
|
|
bool isCrcOk() const;
|
|
|
|
|
|
|
|
uint32_t getSrcISSI() const;
|
|
|
|
|
|
|
|
bool isLoginTelegram() const;
|
|
|
|
|
|
|
|
bool mustBeFragmented() const;
|
|
|
|
|
|
|
|
const uint8_t *getPayloadDataPtr(uint16_t a_offset) const;
|
|
uint8_t *getPayloadDataPtr(uint16_t a_offset);
|
|
|
|
|
|
|
|
virtual uint16_t getPayloadSize() const;
|
|
|
|
|
|
|
|
static QByteArray getUnfragmentedData(const std::multimap<uint16_t, CoPrtCnvRadioTelegram *> &a_fragTelegramList);
|
|
|
|
|
|
|
|
static bool isTelegramLengthOk(const uint16_t a_lengthWithoutFrame);
|
|
|
|
|
|
|
|
bool isNormalTelegram() const;
|
|
|
|
|
|
|
|
uint8_t getPriority() const;
|
|
|
|
|
|
|
|
uint16_t getBroadcastIndex() const;
|
|
|
|
|
|
|
|
void setPayloadDataWithIndex(const uint16_t a_index, const uint32_t a_value, const uint16_t a_size);
|
|
|
|
|
|
|
|
void setPayloadDataComplete(const QByteArray &payload);
|
|
|
|
|
|
|
|
void resetPayloadSize(const uint16_t a_newPayloadSize);
|
|
|
|
|
|
|
|
void setIdentity(const uint16_t a_identity);
|
|
|
|
|
|
|
|
void setProtocolIdentifier(const E_ProtocolIdentifier a_ProtocolIdentifier);
|
|
|
|
|
|
|
|
void setMessageReference(const uint8_t a_MessageReference);
|
|
|
|
|
|
|
|
bool isSDSTL() const;
|
|
|
|
|
|
|
|
CoPrtCnvRadioTelegram::E_RegistrationStatus getRegistrationStatus() const;
|
|
|
|
|
|
|
|
std::string getRegistrationStatusAsText() const;
|
|
|
|
|
|
|
|
CoPrtCnvRadioTelegram::E_ProtocolIdentifier getProtocolIdentifier() const;
|
|
|
|
|
|
|
|
std::string getProtocolIdentifierAsText() const;
|
|
|
|
|
|
|
|
uint8_t getMessageReference() const;
|
|
|
|
|
|
|
|
uint8_t getAreaSelection() const;
|
|
|
|
|
|
|
|
uint8_t getValidityPeriod() const;
|
|
|
|
|
|
|
|
uint32_t getForwardAddress() const;
|
|
|
|
|
|
|
|
CoPrtCnvRadioTelegram::E_Flags getFlags() const;
|
|
|
|
|
|
|
|
std::string getFlagsAsText() const;
|
|
|
|
|
|
|
|
uint16_t getLengthInBits() const;
|
|
|
|
|
|
|
|
uint16_t getLengthInBytes() const;
|
|
|
|
|
|
|
|
bool getWithCrc() const;
|
|
|
|
|
|
|
|
CoPrtCnvRadioTelegram::E_DeliveryStatusForTL_Report getDelivery() const;
|
|
|
|
|
|
|
|
std::string getDeliveryAsText() const;
|
|
|
|
|
|
|
|
int32_t getPayloadDataSInt24(uint16_t a_offset) const;
|
|
|
|
|
|
|
|
bool needsLicensing() const;
|
|
|
|
|
|
|
|
bool hasExpired() const;
|
|
|
|
|
|
|
|
uint32_t getExpireTime() const;
|
|
|
|
|
|
|
|
bool isContentValid();
|
|
|
|
|
|
|
|
bool mustBeSentAsBroadcast(time_t a_currentTime, bool &a_wasLastBroadcast, const bool a_updateBroadcastCounter = true);
|
|
|
|
|
|
|
|
static void setBroadcastDelayTimes(int a_2ndDelay, int a_3rdDelay);
|
|
|
|
|
|
|
|
static void setMaxBroadcastSendCnt(int a_maxSendCnt);
|
|
|
|
|
|
|
|
bool isMovedToBroadcastList() const;
|
|
|
|
|
|
|
|
void setBroadcastOnly(const bool a_doSet = true);
|
|
|
|
|
|
|
|
bool isBroadcastOnly() const;
|
|
|
|
|
|
|
|
void setBroadcastonlyTelegram(const std::shared_ptr<N_CoPrtCnv::CoPrtCnvRadioTelegram> &a_radioTelegram);
|
|
|
|
|
|
|
|
std::shared_ptr<N_CoPrtCnv::CoPrtCnvRadioTelegram> getBroadcastonlyTelegram() const;
|
|
|
|
|
|
|
|
uint16_t getBroadcastCounter() const;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
QByteArray m_data;
|
|
|
|
|
|
|
|
uint16_t m_PayloadIndex;
|
|
|
|
|
|
uint16_t m_BroadcastCounter;
|
|
|
|
|
|
time_t m_NextSendTime;
|
|
|
|
|
|
static int s_2ndDelay;
|
|
|
|
|
|
static int s_3rdDelay;
|
|
|
|
|
|
static int s_maxBroadcastSendCnt;
|
|
|
|
|
|
bool m_IsBroadcastOnly;
|
|
|
|
|
|
std::shared_ptr<N_CoPrtCnv::CoPrtCnvRadioTelegram> m_BroadcastOnlyTelegram;
|
|
|
|
|
|
|
|
static bool s_etsMode;
|
|
|
|
|
|
|
|
bool isPayloadLengthOk(uint16_t a_minLength,
|
|
const uint16_t a_dataAmountOffset,
|
|
const uint8_t a_variableDataElementSize) const;
|
|
bool isPayloadLengthOk(uint16_t a_minLength,
|
|
uint16_t a_maxLength) const;
|
|
bool isPayloadLengthOk(uint16_t a_length) const;
|
|
bool isPayloadLengthOk(const std::vector<uint16_t> &a_lengths) const;
|
|
|
|
|
|
|
|
static void set1Byte(QByteArray &a_data, uint16_t a_offset, uint8_t a_value);
|
|
|
|
|
|
|
|
static void set2Byte(QByteArray &a_data, uint16_t a_offset, uint16_t a_value);
|
|
|
|
|
|
|
|
static void set4Byte(QByteArray &a_data, uint16_t a_offset, uint32_t a_value);
|
|
|
|
|
|
uint8_t getUInt8(const uint16_t a_offset) const { return static_cast<uint8_t>(m_data.at(a_offset)); }
|
|
uint16_t getUInt16(const uint16_t a_offset) const;
|
|
uint32_t getUInt32(const uint16_t a_offset) const;
|
|
|
|
|
|
|
|
static void setHeader(QByteArray &data, E_PDU_Type pduType);
|
|
|
|
|
|
|
|
static void fillDataIndReqHeader(QByteArray &a_data);
|
|
|
|
|
|
|
|
static void setSrcISSI_Internal(QByteArray &data, const uint32_t issi);
|
|
|
|
|
|
|
|
static void setDestISSI_Internal(QByteArray &data, const uint32_t issi);
|
|
|
|
private:
|
|
|
|
|
|
NGL::INGLLogger &m_logger;
|
|
|
|
};
|
|
|
|
}
|