181 lines
5.1 KiB
C++
181 lines
5.1 KiB
C++
#ifndef MSG_H
|
|
#define MSG_H
|
|
#include <cstdint>
|
|
#include <vector>
|
|
#include <string>
|
|
#include <QByteArray>
|
|
|
|
#define FRAME_SLIP_C0 0xC0
|
|
#define FRAME_SLIP_DB 0xDB
|
|
#define FRAME_SLIP_DC 0xDC
|
|
#define FRAME_SLIP_DD 0xDD
|
|
#define COMMAND_TYPE_INDEX 2
|
|
#define SUB_COMMAND_TYPE_INDEX 3
|
|
#define COMMAND_DATA_BEGIN_INDEX 4
|
|
#define FRAME_MIN_LEN 5 //不含帧头帧尾
|
|
#define FRAME_LEN_STATUSREPORT (FRAME_MIN_LEN + 81)
|
|
#define FRAME_LEN_ZHUANTAISTATUSREPORT (FRAME_MIN_LEN + 6)
|
|
|
|
enum class CommandType : uint8_t{
|
|
kTianTongVoice = 0xA0,
|
|
kUhfVoice = 0xA1,
|
|
kTianTongShortMessage = 0xB0,
|
|
kUhfShortMessage = 0xB1,
|
|
kBeiDouShortMessage = 0xB2,
|
|
kStatusReport = 0x80,
|
|
kSearchSatelliteStatusReport = 0x90,
|
|
kSearchZhuanTaiStatusReport = 0x91,
|
|
kConfigCmdDefaultChannel = 0xD0,
|
|
kConfigCmdUDataChannelKeepTime = 0xD1,
|
|
kConfigCmdDefaultNumber = 0xD2,
|
|
kConfigCmdSoftVersion = 0xD3,
|
|
kConfigCmdSoftReset = 0xD4,
|
|
kConfigCmdSDataSwitch = 0xD5,
|
|
kDebugCmd = 0xE0,
|
|
};
|
|
enum class TianTongVoiceSubCommandType: uint8_t{
|
|
kDial = 0x01, //拨号
|
|
kHangUp = 0x02,//挂机
|
|
kAnswer = 0x03,//接听
|
|
kSendKeysWhenOnLine = 0x04, //通话时发送按键值
|
|
};
|
|
|
|
enum class UhfVoiceSubCommandType: uint8_t{
|
|
kDial = 0x01, //拨号
|
|
kHangUp = 0x02,//挂机
|
|
kAnswer = 0x03,//接听
|
|
};
|
|
|
|
enum class ShortMessageSubCommandType: uint8_t{
|
|
kSendMessage = 0x01, //发送短消息
|
|
kRecvMessage = 0x02, //接收短消息
|
|
};
|
|
|
|
enum class SearchSatelliteStatusReportSubCommandType: uint8_t{
|
|
kRnss = 0x01, //RNSS卫星状态
|
|
kRdss = 0x02, //RDSS卫星状态
|
|
};
|
|
|
|
enum class VoiceAndShortMessageReponse{
|
|
kSucess = 0x00,
|
|
kFailure = 0x01,
|
|
};
|
|
|
|
enum class ModuleStatus: uint8_t{
|
|
kChecking = 0x00,//检测中
|
|
kNormal = 0x01, //正常
|
|
kFault = 0x02, //故障
|
|
kUpgrading = 0x03, //升级中
|
|
};
|
|
|
|
enum class NetworkAccessStatus: uint8_t{
|
|
kNotConnected = 0x00, //未入网
|
|
kConnecting = 0x01, //正在入网
|
|
kConnectedDataIsNotActivated = 0x02, //已入网, 数据未激活
|
|
kConnectedDataIsActivated = 0x03, //已入网, 数据已激活
|
|
};
|
|
|
|
enum class SimCardStatus: uint8_t{
|
|
kChecking = 0x00,//正在检测
|
|
kExist = 0x01,//存在
|
|
kNotExist = 0x02,//不存在
|
|
};
|
|
|
|
enum class MCardStatus: uint8_t{
|
|
kChecking = 0x00,//正在检测
|
|
kExistNotEncryted = 0x01,//存在未注密
|
|
kExistEncryted = 0x02,//存在已注密
|
|
kNotExist = 0x03,//不存在
|
|
};
|
|
|
|
enum class CallStatus: uint8_t{
|
|
kIdle = 0x00, //空闲
|
|
kDialing = 0x01,//拨号中
|
|
kPeerRingTheBell = 0x02,//对方振铃
|
|
kOnLine = 0x03,//通话中
|
|
kCallIsComing = 0x04,//来电中
|
|
};
|
|
|
|
enum class PhaseLockedLoopStatus{
|
|
kUnlocked = 0x00,//失锁
|
|
kLocked = 0x01, //锁定
|
|
};
|
|
|
|
enum class DebugCommandType: uint8_t{
|
|
kUCattierType = 0x00,
|
|
kURate = 0x01,
|
|
kSFreq = 0x02,
|
|
kSRate = 0x03,
|
|
kPASwitch = 0x04,
|
|
kZTCtrl = 0x05,
|
|
kCmdCtrl = 0x06,
|
|
};
|
|
|
|
enum class ConfigCommandType: uint8_t{
|
|
kGetType = 0x00,
|
|
kSetType = 0x01,
|
|
};
|
|
|
|
enum class RDSSType: uint8_t{
|
|
RDSS_S1 = 0x00,
|
|
RDSS_S2 = 0x01,
|
|
};
|
|
|
|
enum class ChannelType: uint8_t{
|
|
ChannelS = 0x00,
|
|
ChannelUHF = 0x01,
|
|
ChannelAuto = 0x02,
|
|
};
|
|
|
|
struct SatelliteStatus{
|
|
uint8_t number;
|
|
uint8_t locate_flag;
|
|
uint8_t snr;
|
|
uint16_t azimuth;
|
|
uint8_t pitch;
|
|
};
|
|
|
|
struct RDSSSatelliteStatus{
|
|
uint8_t number;
|
|
uint8_t snr1;
|
|
uint8_t snr2;
|
|
};
|
|
|
|
void calc_checksum(QByteArray&cmd);
|
|
QByteArray pack_tiantong_dial_cmd(const std::string& number);
|
|
QByteArray pack_tiantong_hang_up_cmd();
|
|
QByteArray pack_tiantong_answer();
|
|
QByteArray pack_tiantong_send_keys_when_on_line_cmd(const std::string& keys);
|
|
|
|
QByteArray pack_uhf_dial_cmd(const std::string& number);
|
|
QByteArray pack_uhf_hang_up_cmd();
|
|
QByteArray pack_uhf_answer();
|
|
|
|
QByteArray pack_debug_cmd_UCattierType(uint8_t type);
|
|
QByteArray pack_debug_cmd_URate(uint8_t type);
|
|
QByteArray pack_debug_cmd_SFreq(uint16_t freq);
|
|
QByteArray pack_debug_cmd_SRate(uint8_t type);
|
|
QByteArray pack_debug_cmd_PASwitch(uint8_t s_switch, uint8_t u_switch, uint8_t bd_switch);
|
|
QByteArray pack_debug_cmd_ZTCtrl(uint8_t type);
|
|
QByteArray pack_debug_cmd_CmdCtrl(uint8_t type, const std::string& cmd_content);
|
|
|
|
QByteArray pack_config_cmd_DefaultChannelGet();
|
|
QByteArray pack_config_cmd_DefaultChannelSet(uint8_t type);
|
|
QByteArray pack_config_cmd_UDataChannelKeepTimeGet();
|
|
QByteArray pack_config_cmd_UDataChannelKeepTimeSet(uint16_t time);
|
|
QByteArray pack_config_cmd_DefaultNumberGet();
|
|
QByteArray pack_config_cmd_DefaultNumberSet(const std::string& u_number, const std::string& s_number);
|
|
QByteArray pack_config_cmd_SoftVersionGet();
|
|
QByteArray pack_config_cmd_SoftResetSet();
|
|
QByteArray pack_config_cmd_SDataSwitchSet(uint8_t onoff);
|
|
QByteArray pack_short_message_cmd(CommandType cmd_type,const std::string& number, const std::u16string& message);
|
|
|
|
QByteArray pack_slip(QByteArray &message);
|
|
int pack_deslip(QByteArray &message);
|
|
QByteArray pack_tiantong_short_message_cmd(const std::string& number,const std::u16string& message);
|
|
QByteArray pack_uhf_short_message_cmd(const std::string& number, const std::u16string& message);
|
|
QByteArray pack_beidou_short_message_cmd(const std::string& number, const std::u16string& message);
|
|
|
|
|
|
#endif // MSG_H
|