Hello Enzo,
there is an example in the github repo of the TCI Interface definition written in C++ for Qt. The following method shows what you have to do when you receive a binary message via the websocket connection:
github.com/maksimus1210/TCI/blob/0b22692ad6fdcea3f05aab89fb369ec555edf51a/projects_example/TciClient/libs/TciClient/tciclient.cpp#L150
How you get to the point where you know that you received a binary message highly depends on the language and the websocket library you are using. But this part is not TCI specific and should be documented in your websocket library.
When you have the binary message at your fingertips, do the following steps in order to handle the TX chrono message:
- Unmarshal the binary data into a data structure that you can handle in your language. The data comes in binary form in little endian byte order, the meaning of the bytes is perfectly described in the "typedef struct DataStream" that you posted.
- Check the field "type" (bytes 0x18-0x1B). If it has the value 3, you received a TX chrono message.
- The field "length" (bytes 0x14-0x17) contains the number of samples that is expected by ExpertSDR. You need to send a binary message through the websocket connect as a reply that uses the same data structure (typedef struct DataStream) and contains the requested number of samples. (see also github.com/maksimus1210/TCI/blob/0b22692ad6fdcea3f05aab89fb369ec555edf51a/projects_example/TciClient/libs/TciClient/tciclient.cpp#L112)
I hope this helps. Below I marked the relevant parts with comments to give some orientation in the example code.
73! Florian
void TciClient::onBinaryReceived(const QByteArray &data)
{
t_iqData = data;
// STEP 1: unmarshal - this is rather simple in C++, as the data structure was defined in this language
DataStream *pStream = reinterpret_cast<DataStream*>(t_iqData.data());
if (pStream->receiver != 0u)
return;
if (pStream->type == IqStream) {
m_signalIQ.resize(pStream->length/2u);
for (quint32 i = 0u, j = 0u; i < pStream->length; ++j) {
m_signalIQ[j].re = pStream->data[i++];
m_signalIQ[j].im = pStream->data[i++];
}
emit readyReadIq();
}
else if (pStream->type == RxAudioStream) {
m_signalAudio.resize(pStream->length/2u);
for (quint32 i = 0u, j = 0u; i < pStream->length; ++j) {
m_signalAudio[j].re = pStream->data[i++];
m_signalAudio[j].im = pStream->data[i++];
}
emit readyReadAudio();
}
// STEP 2: check the message type for TxChrono (3)
else if (pStream->type == TxChrono) {
qDebug() << Q_FUNC_INFO << __LINE__ << m_txTimer.elapsed();
m_txTimer.start();
// STEP 3: reply with the required number of samples, see also https://github.com/maksimus1210/TCI/blob/0b22692ad6fdcea3f05aab89fb369ec555edf51a/projects_example/TciClient/libs/TciClient/tciclient.cpp#L112
emit chronoTxSignal(pStream->length);
}
}