Changed handling of meta data. Changed USRP_HOST default entry.

This commit is contained in:
Adi Bier / DL1HRC 2021-05-31 13:00:05 +02:00
parent 9714a208e9
commit 98e8b6206d
3 changed files with 40 additions and 42 deletions

View File

@ -396,6 +396,11 @@ void UsrpLogic::sendEncodedAudio(const void *buf, int count)
while (stored_samples >= USRP_AUDIO_FRAME_LEN)
{
/*for (int i=0;i<USRP_AUDIO_FRAME_LEN; i++)
{
cout << r_buf[i] << ",";
}
cout << endl;*/
usrp.setAudioData(r_buf);
sendMsg(usrp);
memmove(r_buf, r_buf + USRP_AUDIO_FRAME_LEN,
@ -462,7 +467,11 @@ void UsrpLogic::udpDatagramReceived(const IpAddress& addr, uint16_t port,
}
handleTextMsg(usrpmeta);
}
else
else if (usrp.type() == USRP_TYPE_TLV)
{
cout << "USRP_TYPE_TLV!" << endl;
}
else
{
cout << "*** unknown type of message:" << usrp.type() << endl;
}
@ -500,40 +509,28 @@ void UsrpLogic::handleTextMsg(UsrpMetaMsg usrp)
stringstream ss;
m_last_tg = usrp.getTg();
std::string metadata = usrp.getMetaInfo();
if (usrp.getTlv() == TLV_TAG_SET_INFO)
if (metadata.substr(0,1) == "{" && usrp.getTlv() == TLV_TAG_SET_INFO)
{
Json::Reader reader;
Json::Value value;
//Read data from the string
if (reader.parse(metadata,value))
{
m_last_call = value["call"].asString();
}
}
else
{
m_last_call = usrp.getCallsign();
ss << "usrp_stationdata_received " << m_last_call << " "
}
if (usrp.getTlv() == TLV_TAG_SET_INFO)
{
ss << "usrp_stationdata_received " << m_last_call << " "
<< usrp.getTg() << " " << usrp.getDmrId();
processEvent(ss.str());
}
else
{
if (metadata.substr(0,6) == "INFO:{")
{
handleMetaData(metadata.erase(0,5));
}
else if (metadata.substr(0,9) == "INFO:MSG:")
{
handleInfoMsg(metadata.substr(0,9));
}
else if (metadata.substr(0,5) == "INFO:")
{
// sendInfoJson();
}
else if (metadata.substr(0,1) == "{")
{
size_t fa = metadata.find("{");
size_t fe = metadata.find("}");
if (fe != std::string::npos && fa != std::string::npos && fa<fe)
{
ss << "usrp_jsondata_received \"" << metadata.substr(fa, fe-fa)
<< "\"";
processEvent(ss.str());
}
}
}
} /* UsrpLogic::handleTextMsg */

View File

@ -148,9 +148,9 @@ class UsrpMsg : public Async::Msg
uint32_t reserved(void) const { return ntohl(m_reserved); }
uint32_t talkgroup(void) const { return ntohl(m_talkgroup); }
void setTg(uint32_t tg) { m_talkgroup = htonl(tg);}
void setType(uint32_t type) { m_type = htonl(type);}
void setSeq(uint32_t seq) { m_seq = htonl(seq); }
void setTg(uint32_t tg) { m_talkgroup = htole32(tg);}
void setType(uint32_t type) { m_type = htole32(type);}
void setSeq(uint32_t seq) { m_seq = htole32(seq); }
void setKeyup(bool keyup) { (keyup ? m_keyup=1 : m_keyup=0); }
void setAudioData(int16_t in[USRP_AUDIO_FRAME_LEN*2])
@ -325,32 +325,33 @@ class UsrpMetaMsg : public Async::Msg
{
(ts > 4 ? m_ts = 4 : m_ts = ts);
}
void setTlv(uint8_t tlv)
{
m_tlv = tlv;
}
void setTlvLen(uint8_t tlvlen)
{
m_tlvlen = tlvlen;
}
// returns the callsing of the talker
std::string getCallsign(void)
{
uint8_t i;
uint8_t i = 0;
uint8_t call[9];
if (m_tlv == TLV_TAG_SET_INFO && m_tlvlen < 0x14)
if (m_tlv == TLV_TAG_SET_INFO && m_tlvlen < 0x16)
{
for(i=0;i<(m_tlvlen-13);i++)
for(i=0;i<(m_tlvlen-14);i++)
{
if (m_meta[i] == 0x00) break;
call[i] = m_meta[i];
}
}
return std::string(call, call+(m_tlvlen-13));
return std::string(call, call+i);
}
// returns the info (as json in a string)
std::string getMetaInfo(void)
{

View File

@ -105,7 +105,7 @@ QSY_PENDING_TIMEOUT=15
[UsrpLogic]
TYPE=Usrp
USRP_HOST=usrp.server.org
USRP_HOST=127.0.0.1
USRP_TX_PORT=41234
USRP_RX_PORT=41233
CALL=N0CALL