DAPNETGateway/POCSAGMessage.cpp

49 lines
1.3 KiB
C++
Raw Permalink Normal View History

2018-06-06 20:33:31 +01:00
/*
2025-03-18 13:52:17 +00:00
* Copyright (C) 2018,2025 by Jonathan Naylor G4KLX
2018-06-06 20:33:31 +01:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "POCSAGMessage.h"
#include <cstdio>
#include <cassert>
2018-06-06 21:38:43 +01:00
#include <cstring>
2018-06-06 20:33:31 +01:00
2018-06-07 07:17:55 +01:00
CPOCSAGMessage::CPOCSAGMessage(unsigned char type, unsigned int ric, unsigned char functional, unsigned char* message, unsigned int length) :
2018-06-06 20:33:31 +01:00
m_type(type),
m_ric(ric),
m_functional(functional),
2025-03-18 13:52:17 +00:00
m_message(nullptr),
2018-06-25 19:11:33 +01:00
m_length(length),
m_timeQueued()
2018-06-06 20:33:31 +01:00
{
assert(functional < 4U);
2025-03-18 13:52:17 +00:00
assert(message != nullptr);
2018-06-06 20:33:31 +01:00
assert(length > 0U);
m_message = new unsigned char[length + 1];
2018-06-06 20:33:31 +01:00
::memcpy(m_message, message, length);
m_message[length] = '\0';
2018-06-25 19:11:33 +01:00
m_timeQueued.start();
2018-06-06 20:33:31 +01:00
}
CPOCSAGMessage::~CPOCSAGMessage()
{
delete[] m_message;
}