bool CAPRSTransmit::run() { //First see if the packet is Icom supported... CAPRSPacket aprsPacket; if(!CAPRSParser::Parse(m_text, aprsPacket)){ wxLogWarning(wxT("Unsupported APRS Format, ignoring => ") + m_text.Trim(true)); return false; } wxString textWithCRC(aprsPacket.Raw()); wxLogMessage(wxT("Supported APRS Format => ") + textWithCRC.Trim(true)); //add nececessary stuff to text, but keep it the original textWithCRC.Replace(wxT("\n"), wxEmptyString); if(!textWithCRC.EndsWith(wxT("\r"))) textWithCRC.Append(wxT("\r")); wxString crc = wxString::Format(wxT("$$CRC%04X,"), calcCRC(textWithCRC)); textWithCRC.Prepend(crc); bool opened = m_socket.open(); if (!opened) return false; in_addr address = CUDPReaderWriter::lookup(wxT("127.0.0.1")); unsigned int id = CHeaderData::createId(); wxString callsignG = m_repeaterCallsign.Left(LONG_CALLSIGN_LENGTH - 1U); callsignG.Append(wxT("G")); CHeaderData header; header.setId(id); header.setMyCall1(m_APRSCallsign); header.setMyCall2(wxT("APRS")); header.setRptCall1(callsignG); header.setRptCall2(m_repeaterCallsign); header.setYourCall(wxT("CQCQCQ ")); header.setDestination(address, G2_DV_PORT); sendHeader(header); CSlowDataEncoder encoder; encoder.setHeaderData(header); encoder.setGPSData(textWithCRC); encoder.setTextData(wxT("APRS to DPRS")); CAMBEData data; data.setDestination(address, G2_DV_PORT); data.setId(id); wxStopWatch timer; timer.Start(); unsigned int out = 0U; unsigned int dataOut = 0U; unsigned int needed = (encoder.getInterleavedDataLength() / (DATA_FRAME_LENGTH_BYTES)) * 2U; while (dataOut < needed) { data.setSeq(out); unsigned char buffer[DV_FRAME_LENGTH_BYTES]; ::memcpy(buffer + 0U, NULL_AMBE_DATA_BYTES, VOICE_FRAME_LENGTH_BYTES); // Insert sync bytes when the sequence number is zero, slow data otherwise if (out == 0U) { ::memcpy(buffer + VOICE_FRAME_LENGTH_BYTES, DATA_SYNC_BYTES, DATA_FRAME_LENGTH_BYTES); } else { encoder.getInterleavedData(buffer + VOICE_FRAME_LENGTH_BYTES); dataOut++; } data.setData(buffer, DV_FRAME_LENGTH_BYTES); sendData(data); out++; if (out == 21U) out = 0U; } data.setData(END_PATTERN_BYTES, DV_FRAME_LENGTH_BYTES); data.setSeq(out >= 21U ? 0U : out); data.setEnd(true); sendData(data); m_socket.close(); return true; }