migrate
This commit is contained in:
+142
-8
@@ -13,12 +13,6 @@
|
||||
#define HEAD 0xFE
|
||||
#define END 0xFD
|
||||
|
||||
#define MSC_DATA_LENGTH (100 * 1024)
|
||||
#define MAX_SEGMENT_SIZE 8191
|
||||
#define MAX_IMAGE_SIZE 100 * 1024 // bytes, ETSI TS 101 499
|
||||
#define MAX_NAME_LENGTH 100
|
||||
#define EXPECTED_IMAGE_LENGTH 1000
|
||||
|
||||
// Set GPIO function
|
||||
#define DATA_IN 0
|
||||
#define DATA_OUT 1
|
||||
@@ -45,6 +39,41 @@
|
||||
|
||||
#define ANTENNA_RELAY_PIN 11
|
||||
|
||||
QString programTypeText[] =
|
||||
{
|
||||
"",
|
||||
"News",
|
||||
"Current Affairs",
|
||||
"Information",
|
||||
"Sport",
|
||||
"Education",
|
||||
"Drama",
|
||||
"Arts",
|
||||
"Science",
|
||||
"Talk",
|
||||
"Pop Music",
|
||||
"Rock Music",
|
||||
"Easy Listening",
|
||||
"Light Classical",
|
||||
"Classical Music",
|
||||
"Other Music",
|
||||
"Weather",
|
||||
"Finance",
|
||||
"Children",
|
||||
"Factual",
|
||||
"Religion",
|
||||
"Phone In",
|
||||
"Travel",
|
||||
"Leisure",
|
||||
"Jazz and Blues",
|
||||
"Country Music",
|
||||
"National Music",
|
||||
"Oldies Music",
|
||||
"Folk Music",
|
||||
"Documentary",
|
||||
"Undefined",
|
||||
"Undefined"
|
||||
};
|
||||
|
||||
cKeyStoneCOMM::cKeyStoneCOMM(const QString& commPort, QObject *parent) :
|
||||
QObject{parent},
|
||||
@@ -55,7 +84,10 @@ cKeyStoneCOMM::cKeyStoneCOMM(const QString& commPort, QObject *parent) :
|
||||
m_initialized{false},
|
||||
m_totalProgram{0},
|
||||
m_currentProgram{0},
|
||||
m_mutePrevVolume{0}
|
||||
m_mutePrevVolume{0},
|
||||
m_mainTransportID{0},
|
||||
m_MSCDataIndex{0},
|
||||
m_imageDataIndex{0}
|
||||
{
|
||||
}
|
||||
|
||||
@@ -467,6 +499,16 @@ QString cKeyStoneCOMM::programName()
|
||||
return(getProgramName(m_currentMode, m_currentProgram, 1));
|
||||
}
|
||||
|
||||
QString cKeyStoneCOMM::programType()
|
||||
{
|
||||
int8_t programType = getProgramType(m_currentMode, m_currentProgram);
|
||||
|
||||
if(programType < 0 || programType > 31)
|
||||
return("");
|
||||
|
||||
return(programTypeText[programType]);
|
||||
}
|
||||
|
||||
QString cKeyStoneCOMM::programText()
|
||||
{
|
||||
return(getProgramText());
|
||||
@@ -853,7 +895,7 @@ QString cKeyStoneCOMM::getProgramText()
|
||||
|
||||
programText = QString::fromWCharArray((wchar_t *)&tempBuffer[0], unicodesize-1).trimmed();
|
||||
#endif
|
||||
return(0);
|
||||
return(programText);
|
||||
|
||||
}
|
||||
else if((input[1] == 0x00) && (input[2] == 0x02))
|
||||
@@ -870,6 +912,48 @@ QString cKeyStoneCOMM::getProgramText()
|
||||
return(programText);
|
||||
}
|
||||
|
||||
int8_t cKeyStoneCOMM::getProgramType(char mode, long dabIndex)
|
||||
{
|
||||
uint16_t dwBytes;
|
||||
unsigned char input[9] = {0};
|
||||
unsigned char output[] = {HEAD,0x01,0x2C,0x01,0x00,0x04,0xFF,0xFF,0xFF,0xFF,END};
|
||||
unsigned char strChannel[4] = {0};
|
||||
|
||||
if((mode != STREAM_MODE_DAB) && (mode != STREAM_MODE_FM))
|
||||
return(-1);
|
||||
|
||||
if(mode == STREAM_MODE_DAB)
|
||||
{
|
||||
memcpy(&strChannel[0], &dabIndex, sizeof(long));
|
||||
output[6] = strChannel[3];
|
||||
output[7] = strChannel[2];
|
||||
output[8] = strChannel[1];
|
||||
output[9] = strChannel[0];
|
||||
}
|
||||
|
||||
if(!writeSerialBytes(output, 11, &dwBytes))
|
||||
return(-1);
|
||||
|
||||
if(dwBytes != 11)
|
||||
return(-1);
|
||||
|
||||
if(!readSerialBytes(input, &dwBytes))
|
||||
return(-1);
|
||||
|
||||
if(dwBytes != 8)
|
||||
return(-1);
|
||||
|
||||
if(goodHeader(input, dwBytes))
|
||||
{
|
||||
if((input[1] == 0x01) && (input[2] == 0x2C))
|
||||
return(input[6]);
|
||||
else
|
||||
return(-1);
|
||||
}
|
||||
else
|
||||
return(-1);
|
||||
}
|
||||
|
||||
QString cKeyStoneCOMM::getProgramName(char mode, long dabIndex, char namemode)
|
||||
{
|
||||
uint16_t dwBytes;
|
||||
@@ -981,3 +1065,53 @@ void cKeyStoneCOMM::serialReadError(QSerialPort::SerialPortError error)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool cKeyStoneCOMM::clearDatabase()
|
||||
{
|
||||
uint16_t dwBytes;
|
||||
unsigned char input[8] = {0};
|
||||
unsigned char output[] = {HEAD,0x00,0x01,0x01,0x00,0x01,0x01,END};
|
||||
|
||||
if(!writeSerialBytes(output, 8, &dwBytes))
|
||||
return(false);
|
||||
|
||||
// need to check the return
|
||||
if(!readSerialBytes(input, &dwBytes))
|
||||
return(false);
|
||||
else
|
||||
{
|
||||
if(goodHeader(input, dwBytes))
|
||||
{
|
||||
if(input[2] == 0x01)
|
||||
{
|
||||
QThread::msleep(1000);
|
||||
|
||||
// while(!isSysReady())
|
||||
// {
|
||||
// QThread::msleep(1000);
|
||||
// }
|
||||
|
||||
return(true);
|
||||
}
|
||||
else
|
||||
return(false);
|
||||
}
|
||||
else
|
||||
return(false);
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool cKeyStoneCOMM::clearFM()
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool cKeyStoneCOMM::clearDAB()
|
||||
{
|
||||
clearDatabase();
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
+80
-3
@@ -10,6 +10,12 @@
|
||||
|
||||
#define TEXT_BUFFER_LEN 300
|
||||
|
||||
#define MSC_DATA_LENGTH (100 * 1024)
|
||||
#define MAX_SEGMENT_SIZE 8191
|
||||
#define MAX_IMAGE_SIZE 100 * 1024 // bytes, ETSI TS 101 499
|
||||
#define MAX_NAME_LENGTH 100
|
||||
#define EXPECTED_IMAGE_LENGTH 1000
|
||||
|
||||
|
||||
class cKeyStoneCOMM : public QObject
|
||||
{
|
||||
@@ -44,7 +50,11 @@ public:
|
||||
int8_t volume();
|
||||
int8_t signalStrength();
|
||||
QString programName();
|
||||
QString programType();
|
||||
QString programText();
|
||||
|
||||
bool clearFM();
|
||||
bool clearDAB();
|
||||
signals:
|
||||
|
||||
private:
|
||||
@@ -65,13 +75,28 @@ private:
|
||||
int8_t m_currentVolume;
|
||||
int8_t m_mutePrevVolume;
|
||||
|
||||
uint16_t m_mainTransportID;
|
||||
bool m_startCollectData;
|
||||
uint8_t m_MSCData[100 * 1024];
|
||||
uint32_t m_MSCDataIndex;
|
||||
|
||||
unsigned char m_imageData[MAX_IMAGE_SIZE];
|
||||
uint32_t m_imageDataIndex;
|
||||
char m_imageFileName[MAX_NAME_LENGTH];
|
||||
|
||||
bool hardMute();
|
||||
bool hardUnmute();
|
||||
bool hardResetRadio();
|
||||
|
||||
int16_t getTotalProgram();
|
||||
int8_t getSignalStrength(int* biterror);
|
||||
|
||||
QString getProgramText();
|
||||
int8_t getProgramType(char mode, long dabIndex);
|
||||
QString getProgramName(char mode, long dabIndex, char namemode);
|
||||
|
||||
bool clearDatabase();
|
||||
|
||||
bool readSerialBytes (unsigned char* buffer, uint16_t* bytesreadreturn);
|
||||
bool writeSerialBytes(unsigned char* buffer, uint16_t nNumberOfBytesToWrite, uint16_t* lpNumberOfBytesWritten);
|
||||
bool goodHeader(unsigned char* input, uint16_t dwBytes);
|
||||
@@ -80,12 +105,64 @@ private:
|
||||
bool GPIO_SetLevel(char pin, char level);
|
||||
bool GPIO_GetLevel(char pin, char* level);
|
||||
bool GPIO_SetFunction(char pin, char pinfunction, char drive);
|
||||
|
||||
int16_t getTotalProgram();
|
||||
int8_t getSignalStrength(int* biterror);
|
||||
private slots:
|
||||
void serialReadReady();
|
||||
void serialReadError(QSerialPort::SerialPortError error);
|
||||
};
|
||||
|
||||
#endif // CKEYSTONECOMM_H
|
||||
|
||||
/*
|
||||
long commVersion(void);
|
||||
bool hardResetRadio();
|
||||
bool isSysReady();
|
||||
char getPlayStatus();
|
||||
long getPreset(char mode, char presetindex);
|
||||
bool setPreset(char mode, char presetindex, unsigned long channel);
|
||||
bool FMSearch(char direction);
|
||||
bool DABAutoSearch(unsigned char startindex, unsigned char endindex);
|
||||
bool DABAutoSearchNoClear(unsigned char startindex, unsigned char endindex);
|
||||
bool getEnsembleName(long dabIndex, char namemode, wchar_t * programName);
|
||||
int getDataRate();
|
||||
bool setStereoMode(char mode);
|
||||
char getFrequency();
|
||||
char getStereoMode();
|
||||
char getStereo();
|
||||
bool clearDatabase();
|
||||
bool setBBEEQ(char BBEOn, char EQMode, char BBELo, char BBEHi, char BBECFreq, char BBEMachFreq, char BBEMachGain, char BBEMachQ, char BBESurr, char BBEMp, char BBEHpF, char BBEHiMode );
|
||||
bool getBBEEQ(char *BBEOn, char *EQMode, char *BBELo, char *BBEHi, char *BBECFreq, char *BBEMachFreq, char *BBEMachGain, char *BBEMachQ, char *BBESurr, char *BBEMp, char *BBEHpF, char *BBEHiMode);
|
||||
bool setHeadroom(char headroom);
|
||||
char getHeadroom();
|
||||
int16 getApplicationType(long dabIndex);
|
||||
bool getApplicationData();
|
||||
int16 setApplicationType(uint16 appType1);
|
||||
bool getProgramInfo(long dabIndex, unsigned char * ServiceComponentID, uint32 * ServiceID, uint16 * EnsembleID);
|
||||
//BOOL MotQuery(void);
|
||||
void getImage(wchar_t *ImageFileName);
|
||||
//void MotReset(MotMode enMode);
|
||||
char getDABSignalQuality();
|
||||
char getServCompType(long dabIndex);
|
||||
|
||||
// RTC Clock Date
|
||||
bool syncRTC(bool sync);
|
||||
bool getRTC(unsigned char *sec, unsigned char *min, unsigned char *hour, unsigned char *day, unsigned char *month, unsigned char* year);
|
||||
bool enableSyncClock();
|
||||
bool disableSyncClock();
|
||||
bool getClockStatus();
|
||||
|
||||
int getSamplingRate();
|
||||
|
||||
bool enableI2S(bool enable);
|
||||
bool GPIO_SetFunction(char pin, char pinfunction, char drive);
|
||||
bool GPIO_SetLevel(char pin, char level);
|
||||
bool GPIO_GetLevel(char pin, char* level);
|
||||
|
||||
// Local functions
|
||||
void hardMute();
|
||||
void hardUnMute();
|
||||
bool readSerialBytes (HANDLE serialhandle, unsigned char *buffer, uint16 noofbytestoread, uint16 *bytesreadreturn, uint16 exitFD);
|
||||
bool writeSerialBytes(HANDLE serialhandle, LPCVOID lpBuffer, uint16 nNumberOfBytesToWrite, uint16* lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped);
|
||||
bool goodHeader(unsigned char* input, uint16 dwBytes);
|
||||
|
||||
bool parseMSCData();
|
||||
*/
|
||||
|
||||
+10
-1
@@ -2,6 +2,9 @@
|
||||
#include "ui_cmainwindow.h"
|
||||
|
||||
|
||||
#define REFRESH_RATE 1000
|
||||
|
||||
|
||||
cMainWindow::cMainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::cMainWindow),
|
||||
@@ -14,9 +17,10 @@ cMainWindow::cMainWindow(QWidget *parent) :
|
||||
|
||||
m_timerSignalStrength = new QTimer(this);
|
||||
connect(m_timerSignalStrength, &QTimer::timeout, this, &cMainWindow::updateSignalStrength);
|
||||
m_timerSignalStrength->start(1000);
|
||||
m_timerSignalStrength->start(REFRESH_RATE);
|
||||
|
||||
m_keystoneCOMM->open();
|
||||
|
||||
m_keystoneCOMM->startStream(cKeyStoneCOMM::STREAM_MODE_DAB, 2);
|
||||
}
|
||||
|
||||
@@ -36,6 +40,7 @@ void cMainWindow::updateSignalStrength()
|
||||
int8_t signalStrength = m_keystoneCOMM->signalStrength();
|
||||
ui->m_signalStrength->setText(QString("%1").arg(signalStrength));
|
||||
ui->m_sender->setText(m_keystoneCOMM->programName());
|
||||
ui->m_type->setText(m_keystoneCOMM->programType());
|
||||
ui->m_text->setText(m_keystoneCOMM->programText());
|
||||
int16_t channel = m_keystoneCOMM->channel();
|
||||
ui->m_channel->setText(QString("%1").arg(channel));
|
||||
@@ -65,3 +70,7 @@ void cMainWindow::on_m_volumeUp_clicked()
|
||||
m_keystoneCOMM->volumePlus();
|
||||
}
|
||||
|
||||
void cMainWindow::on_m_clearDAB_clicked()
|
||||
{
|
||||
m_keystoneCOMM->clearDAB();
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ private slots:
|
||||
void on_m_channelUp_clicked();
|
||||
void on_m_volumeDown_clicked();
|
||||
void on_m_volumeUp_clicked();
|
||||
void on_m_clearDAB_clicked();
|
||||
};
|
||||
|
||||
#endif // CMAINWINDOW_H
|
||||
|
||||
+89
-68
@@ -16,8 +16,56 @@
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<layout class="QGridLayout" name="gridLayout" columnstretch="0,0,100">
|
||||
<item row="9" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QPushButton" name="m_channelUp">
|
||||
<property name="text">
|
||||
<string>channel +</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Channel:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QLabel" name="m_type">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QPushButton" name="m_channelDown">
|
||||
<property name="text">
|
||||
<string>channel -</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Text:</string>
|
||||
@@ -31,6 +79,34 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QLabel" name="m_signalStrength">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QPushButton" name="m_volumeUp">
|
||||
<property name="text">
|
||||
<string>volume +</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="2">
|
||||
<widget class="QLabel" name="m_channel">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Volume:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
@@ -38,93 +114,38 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Colume:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="6" column="1" colspan="2">
|
||||
<widget class="QLabel" name="m_volume">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Channel:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QPushButton" name="m_channelDown">
|
||||
<property name="text">
|
||||
<string>channel -</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="m_channel">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QLabel" name="m_text">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="m_sender">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="m_signalStrength">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QPushButton" name="m_channelUp">
|
||||
<property name="text">
|
||||
<string>channel +</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QPushButton" name="m_volumeDown">
|
||||
<property name="text">
|
||||
<string>volume -</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QPushButton" name="m_volumeUp">
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QLabel" name="m_sender">
|
||||
<property name="text">
|
||||
<string>volume +</string>
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QPushButton" name="m_clearDAB">
|
||||
<property name="text">
|
||||
<string>clear DAB</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user