Esempio n. 1
0
ReturnStateContext SendMsgState::onRun(QKeyboard &kb) {
	StateBase *nextState = this;
	switch (InternalState) {
	case TYPE_MESSAGE: {
		gui_lable_multiline("Send Message: ", 0, 10, 128, 64, 0, 0);
		gui_lable_multiline(&MsgBuffer[0], 0, 20, 128, 64, 0, 0);
		//keyboard entry
		kb.updateContext(getKeyboardContext());
		uint8_t pin = kb.getLastKeyReleased();
		if (pin == 11) { //return has been pushed
			getKeyboardContext().finalize();
			InternalState = INTERNAL_STATE::CONFIRM_SEND;
		}
	}
		break;
	case CONFIRM_SEND: {
		gui_lable_multiline("Send by pressing return.", 0, 10, 128, 64, 0, 0);
		gui_lable_multiline("Cancel by pressing #.", 0, 30, 128, 64, 0, 0);
		//gui_lable_multiline(&MsgBuffer[0], 0, 30, 128, 64, 0, 0);
		uint8_t pin = kb.getLastKeyReleased();
		if (pin == 9) {
			InternalState = TYPE_MESSAGE;
		} else if (pin == 11) {
			InternalState = SENDING;
		}
	}
		break;
	case SENDING: {
		static char buf[32];
		sprintf(&buf[0], "Sending Message to: %s", AgentName);
		gui_lable_multiline(&buf[0], 0, 10, 128, 64, 0, 0);
#ifdef DONT_USE_ACK
		getRadio().send(RadioID, &MsgBuffer[0], strlen(&MsgBuffer[0]), false);
		nextState = StateFactory::getDisplayMessageState(StateFactory::getMenuState(), "Message Sent!", 5000);
#else
		//TODO get ack working
		if (getRadio().sendWithRetry(RadioID, &MsgBuffer[0], strlen(&MsgBuffer[0]), 1, 400)) {
			nextState = StateFactory::getDisplayMessageState(StateFactory::getMenuState(), "Message Sent Successfully!",
					5000);
		} else {
			static char ResultBuf[64];
			sprintf(&ResultBuf[0],"Failed to send: \nAddress: %d\n N: %s", RadioID,AgentName);
			nextState = StateFactory::getDisplayMessageState(StateFactory::getSendMessageState(),
					&ResultBuf[0], 8000);
			setState(DONT_RESET);
		}
#endif
	}
		break;
	}
	return ReturnStateContext(nextState);
}
Esempio n. 2
0
//------------------------------------------------------------------------------
// reset() -- Reset parameters
//------------------------------------------------------------------------------
void Datalink::reset()
{
   clearQueues();
   // ---
   // Do we need to find the track manager?
   // ---
   if (getTrackManager() == 0 && getTrackManagerName() != 0) {
        // We have a name of the track manager, but not the track manager itself
        const char* name = *getTrackManagerName();
        // Get the named track manager from the onboard computer
        Player* ownship = dynamic_cast<Player*>( findContainerByType(typeid(Player)) );
        if (ownship != 0) {
            OnboardComputer* obc = ownship->getOnboardComputer();
            if (obc != 0) {
               setTrackManager(obc->getTrackManagerByName(name));
            }
        }    
        if (getTrackManager() == 0) {
            // The assigned track manager was not found!
            //if (isMessageEnabled(MSG_ERROR)) {
            //std::cerr << "Datalink ERROR -- track manager, " << name << ", was not found!" << std::endl;
            //}
        }
   }
   // ---
   // Do we need to find the comm radio?
   // ---
   if (getRadio() == 0 && getRadioName() != 0) {
        // We have a name of the radio, but not the radio itself
        const char* name = *getRadioName();
        // Get the named radio from the component list of radios
        Player* ownship = dynamic_cast<Player*>( findContainerByType(typeid(Player)) );
        if (ownship != 0) {
            CommRadio* cr = dynamic_cast<CommRadio*>(ownship->getRadioByName(name));
            setRadio(cr);
        }
        CommRadio* rad = getRadio();
        if (rad == 0) {
            // The assigned radio was not found!
            if (isMessageEnabled(MSG_ERROR)) {
            std::cerr << "Datalink ERROR -- radio, " << name << ", was not found!" << std::endl;
        }
        }
        else {
            rad->setDatalink(this);
            rad->setReceiverEnabledFlag(true);
            rad->setTransmitterEnableFlag(true);
        }
   }
   BaseClass::reset();
}
Esempio n. 3
0
void testShell()
{
	int fd, i, byte ;
	const char *microKeyer = "/dev/cu.usbserial-M2Q5BDJC" ;
	unsigned char split[] = { 0x0, 0x0, 0x0, 0x1, 0x1 } ;
	unsigned char vfoData[] = { 0x0, 0x0, 0x0, 0x3, 0x10 } ;
	
	fd = openPort( microKeyer ) ;
	if ( fd < 0 ) {
		printf( "cannot open microKeyer %s\n", microKeyer ) ;
		return ;
	}
	
	setRadio1Params( fd, 4800, 2, 8 ) ;			//  set radio baud rate
	sleep( 1 ) ;
	writeRadioBuffer( fd, 0, split, 5 ) ;		//  set split mode
	sleep( 1 ) ;
	writeRadioBuffer( fd, 0, vfoData, 5 ) ;		//  get VFO A and B data (should get 32 bytes back)
	
	//  read from Radio 1 until timed out
	for ( i = 0; i < 64; i++ ) {
		byte = getRadio( fd, 0 ) ;
		if ( byte < 0 ) break ;
		printf( "read byte %2d: 0x%02x\n", i, byte ) ;
	}
	
	close( fd ) ;
}
Esempio n. 4
0
// Send the specified BitVector at the specified block time.
void PDCHL1Downlink::transmit(RLCBSN_t bsn, BitVector *mI, const int *qbits, int transceiverflags)
{
	parent()->debug_test();
	// Format the bits into the bursts.
	// GSM 05.03 4.1.5, 05.02 5.2.3
	// NO! Dont do a wait here.  The MAC serviceloop does this for all channels.
	// waitToSend();		// Don't get too far ahead of the clock.

	ARFCNManager *radio = getRadio();
	if (!radio) {
		// For some testing, we might not have a radio connected.
		// That's OK, as long as we know it.
		GLOG(INFO) << "XCCHL1Encoder with no radio, dumping frames";
		return;
	}

	int fn = bsn.FN();
	int tn = TN();

	for (int qi=0,B=0; B<4; B++) {
		Time nextWriteTime(fn,tn | transceiverflags);
		mchBurst.time(nextWriteTime);
		// Copy in the "encrypted" bits, GSM 05.03 4.1.5, 05.02 5.2.3.
		//OBJLOG(DEBUG) << "transmit mI["<<B<<"]=" << mI[B];
		mI[B].segment(0,57).copyToSegment(mchBurst,3);
		mI[B].segment(57,57).copyToSegment(mchBurst,88);
		mchBurst.Hl(qbits[qi++]);
		mchBurst.Hu(qbits[qi++]);
		// Send it to the radio.
		//OBJLOG(DEBUG) << "transmit mchBurst=" << mchBurst;
		if (gConfig.getBool("Control.GSMTAP.GPRS")) {
			// Send to GSMTAP.
			gWriteGSMTAP(ARFCN(),TN(),gBSNNext.FN(),
					TDMA_PDCH,
					false,	// not SACCH
					false,	// this is a downlink
					mchBurst,
					GSMTAP_TYPE_UM_BURST);
		}
#if FEC_DEBUG
		if (1) {
			// Try decoding the frame we just encoded to see if it is correct.
			devassert(mchBurst.size() == gSlotLen);
			RxBurst rxb(mchBurst);
			ChannelCodingType cc;
			decodeLowSide(rxb, B, debugDecoder, &cc);
		}
#endif
		radio->writeHighSideTx(mchBurst,"GPRS");
		fn++;	// This cannot overflow because it is within an RLC block.
	}
}
Esempio n. 5
0
void PDCHL1FEC::mchStart() {
	getRadio()->setSlot(TN(),Transceiver::IGPRS);
	// Load up the GPRS filler idle burst tables in the transceiver.
	// We could use any consecutive bsn, but lets use ones around the current time
	// just to make sure they get through in case someone is triaging somewhere.
	// Sending all 12 blocks is 2x overkill because the modulus in Transceiver::setModulus
	// for type IGPRS is set the same as type I which is only 26, not 52.
	RLCBSN_t bsn = FrameNumber2BSN(gBTS.time().FN()) + 1;
	for (int i = 0; i < 12; i++, bsn = bsn + 1) {
		GPRSLOG(1) <<"sendIdleFrame"<<LOGVAR2("TN",TN())<<LOGVAR(bsn)<<LOGVAR(i);
		mchDownlink->sendIdleFrame(bsn);
	}
	mchOldFec->setGPRS(true,this);
	debug_test();
}
void ShadowCover::step(float dt)
{
    for (int i = 0; i < DDConfig::BATTLE_NUM; i++) {
        for (int j = 0; j < DDConfig::BATTLE_NUM; j++) {
            float dir =  _cubeAniDir[i*DDConfig::BATTLE_NUM+j];
            if (dir == 0.f) continue;
            AgentPos pos = {j-DDConfig::BATTLE_NUM/2, i-DDConfig::BATTLE_NUM/2};
            float oldRadio = getRadio(pos);
            if (dir < 0 && oldRadio > 0.f){
                float newRadio = std::max(0.f, oldRadio - ANI_STEP_PER_SEC*dt);
                if (newRadio == 0.f) {
                    _cubeAniDir[i*DDConfig::BATTLE_NUM+j] = 0;
                }
                setRadio(pos, newRadio);
            } else if (dir >0 && oldRadio < 1.f) {
                float newRadio = std::min(1.f, oldRadio + ANI_STEP_PER_SEC*dt);
                if (newRadio == 1.f) {
                    _cubeAniDir[i*DDConfig::BATTLE_NUM+j] = 0;
                }
                setRadio(pos, newRadio);
            }
        }
    }
}
Esempio n. 7
0
void CAnalogueRepeaterApp::createThread()
{
	CAnalogueRepeaterThread* thread = new CAnalogueRepeaterThread;

	wxString openId, closeId, beacon1, beacon2;
	unsigned int speed, freq;
	wxFloat32 level1, level2;
	AUDIO_SOURCE openIdSource, closeIdSource, beacon1Source, beacon2Source;
	getCallsign(openIdSource, openId, closeIdSource, closeId, beacon1Source, beacon1, beacon2Source, beacon2, speed, freq, level1, level2);
	wxLogInfo(wxT("Open ID source: %d, value: \"%s\", close ID source: %d, value: \"%s\", beacon 1 source: %d, value: \"%s\", beacon 2 source: %d, value: \"%s\", speed: %u WPM, freq: %u Hz, level1: %.3f, level2: %.3f"), int(openIdSource), openId.c_str(), int(closeIdSource), closeId.c_str(), int(beacon1Source), beacon1.c_str(), int(beacon2Source), beacon2.c_str(), speed, freq, level1, level2);

	IFixedAudioSource* openIdAudio  = NULL;
	IFixedAudioSource* closeIdAudio = NULL;
	IFixedAudioSource* beacon1Audio = NULL;
	IFixedAudioSource* beacon2Audio = NULL;

	switch (openIdSource) {
		case AS_CW_KEYER:
			openIdAudio = new CCWKeyer(openId, speed, freq, ANALOGUE_RADIO_SAMPLE_RATE);
			break;
		case AS_WAV_FILE: {
				CWAVFileStore* audio = new CWAVFileStore;
				bool res = audio->load(openId, ANALOGUE_RADIO_SAMPLE_RATE);
				if (!res)
					delete audio;
				else
					openIdAudio = audio;
			}
			break;
	}

	switch (closeIdSource) {
		case AS_CW_KEYER:
			closeIdAudio = new CCWKeyer(closeId, speed, freq, ANALOGUE_RADIO_SAMPLE_RATE);
			break;
		case AS_WAV_FILE: {
				CWAVFileStore* audio = new CWAVFileStore;
				bool res = audio->load(closeId, ANALOGUE_RADIO_SAMPLE_RATE);
				if (!res)
					delete audio;
				else
					closeIdAudio = audio;
			}
			break;
	}

	switch (beacon1Source) {
		case AS_CW_KEYER:
			beacon1Audio = new CCWKeyer(beacon1, speed, freq, ANALOGUE_RADIO_SAMPLE_RATE);
			break;
		case AS_WAV_FILE: {
				CWAVFileStore* audio = new CWAVFileStore;
				bool res = audio->load(beacon1, ANALOGUE_RADIO_SAMPLE_RATE);
				if (!res)
					delete audio;
				else
					beacon1Audio = audio;
			}
			break;
	}

	switch (beacon2Source) {
		case AS_CW_KEYER:
			beacon2Audio = new CCWKeyer(beacon2, speed, freq, ANALOGUE_RADIO_SAMPLE_RATE);
			break;
		case AS_WAV_FILE: {
				CWAVFileStore* audio = new CWAVFileStore;
				bool res = audio->load(beacon2, ANALOGUE_RADIO_SAMPLE_RATE);
				if (!res)
					delete audio;
				else
					beacon2Audio = audio;
			}
			break;
	}

	thread->setCallsign(openIdAudio, closeIdAudio, beacon1Audio, beacon2Audio, level1, level2);

	wxString radioAck, extAck, batteryAck;
	unsigned int ack, minimum;
	wxFloat32 level;
	AUDIO_SOURCE radioAckSource, extAckSource, batteryAckSource;
	getAck(radioAckSource, radioAck, extAckSource, extAck, batteryAckSource, batteryAck, speed, freq, level, ack, minimum);
	wxLogInfo(wxT("Radio ack source: %d, radio ack: \"%s\", network ack source: %d, network ack: \"%s\", battery ack source: %d, battery ack: \"%s\", speed: %u WPM, freq: %u Hz, level: %.3f, ack: %u ms, minimum: %u ms"), int(radioAckSource), radioAck.c_str(), int(extAckSource), extAck.c_str(), int(batteryAckSource), batteryAck.c_str(), speed, freq, level, ack, minimum);

	IFixedAudioSource* radioAckAudio   = NULL;
	IFixedAudioSource* extAckAudio     = NULL;
	IFixedAudioSource* batteryAckAudio = NULL;

	switch (radioAckSource) {
		case AS_CW_KEYER:
			radioAckAudio = new CCWKeyer(radioAck, speed, freq, ANALOGUE_RADIO_SAMPLE_RATE);
			break;
		case AS_WAV_FILE: {
				CWAVFileStore* audio = new CWAVFileStore;
				bool res = audio->load(radioAck, ANALOGUE_RADIO_SAMPLE_RATE);
				if (!res)
					delete audio;
				else
					radioAckAudio = audio;
			}
			break;
	}

	switch (extAckSource) {
		case AS_CW_KEYER:
			extAckAudio = new CCWKeyer(extAck, speed, freq, ANALOGUE_RADIO_SAMPLE_RATE);
			break;
		case AS_WAV_FILE: {
				CWAVFileStore* audio = new CWAVFileStore;
				bool res = audio->load(extAck, ANALOGUE_RADIO_SAMPLE_RATE);
				if (!res)
					delete audio;
				else
					extAckAudio = audio;
			}
			break;
	}

	switch (batteryAckSource) {
		case AS_CW_KEYER:
			batteryAckAudio = new CCWKeyer(batteryAck, speed, freq, ANALOGUE_RADIO_SAMPLE_RATE);
			break;
		case AS_WAV_FILE: {
				CWAVFileStore* audio = new CWAVFileStore;
				bool res = audio->load(extAck, ANALOGUE_RADIO_SAMPLE_RATE);
				if (!res)
					delete audio;
				else
					batteryAckAudio = audio;
			}
			break;
	}

	thread->setAck(radioAckAudio, extAckAudio, batteryAckAudio, level, ack, minimum);

	unsigned int callsignTime, timeout, lockoutTime, hangTime, latchTime;
	getTimes(callsignTime, timeout, lockoutTime, hangTime, latchTime);
	thread->setTimes(callsignTime, timeout, lockoutTime, hangTime, latchTime);
	wxLogInfo(wxT("Times set to: callsign time: %u secs, timeout: %u secs, lockout time: %u secs, hang time: %u secs, latch time: %u secs"), callsignTime, timeout, lockoutTime, hangTime, latchTime);

	bool tbEnable, ctcssInternal;
	wxFloat32 tbThreshold, ctcssFreq, ctcssThresh, ctcssLevel;
	unsigned int ctcssHangTime;
	ANALOGUE_CTCSS_OUTPUT ctcssOutput;
	getTones(tbEnable, tbThreshold, ctcssFreq, ctcssInternal, ctcssThresh, ctcssLevel, ctcssHangTime, ctcssOutput);
	thread->setTones(tbEnable, tbThreshold, ctcssFreq, ctcssInternal, ctcssThresh, ctcssLevel, ctcssHangTime, ctcssOutput);
	wxLogInfo(wxT("Tones set to: toneburst enable: %u, threshold: %.3f, CTCSS freq: %.1f Hz, internal: %u, threshold: %.3f, level: %.3f, hang time: %u ms, output: %d"), tbEnable, tbThreshold, ctcssFreq, ctcssInternal, ctcssThresh, ctcssLevel, ctcssHangTime * 20U, ctcssOutput);

	ANALOGUE_CALLSIGN_START callsignAtStart;
	unsigned int callsignStartDelay;
	bool callsignAtEnd;
	ANALOGUE_TIMEOUT_TYPE timeoutType;
	ANALOGUE_CALLSIGN_HOLDOFF callsignHoldoff;
	getFeel(callsignAtStart, callsignStartDelay, callsignAtEnd, timeoutType, callsignHoldoff);
	thread->setFeel(callsignAtStart, callsignStartDelay, callsignAtEnd, timeoutType, callsignHoldoff);
	wxLogInfo(wxT("Feel set to: callsignAtStart: %d, callsignStartDelay: %u s, callsignAtEnd: %u, timeoutType: %d, callsignHoldoff: %d"), callsignAtStart, callsignStartDelay, callsignAtEnd, timeoutType, callsignHoldoff);

	wxString readDevice, writeDevice;
	unsigned int audioDelay;
	bool deEmphasis, preEmphasis, vogad;
	getRadio(readDevice, writeDevice, audioDelay, deEmphasis, preEmphasis, vogad);
	wxLogInfo(wxT("Radio soundcard set to %s:%s, delay: %u ms, de-emphasis: %d, pre-emphasis %d, vogad: %d"), readDevice.c_str(), writeDevice.c_str(), audioDelay * 20U, int(deEmphasis), int(preEmphasis), int(vogad));

	if (!readDevice.IsEmpty() && !writeDevice.IsEmpty()) {
		CSoundCardReaderWriter* soundcard = new CSoundCardReaderWriter(readDevice, writeDevice, ANALOGUE_RADIO_SAMPLE_RATE, ANALOGUE_RADIO_BLOCK_SIZE);
		soundcard->setCallback(thread, SOUNDCARD_RADIO);

		bool res = soundcard->open();
		if (!res)
			wxLogError(wxT("Cannot open the radio sound card"));
		else
			thread->setRadio(soundcard, audioDelay, deEmphasis, preEmphasis, vogad);
	}

	wxString type;
	unsigned int pttDelay, squelchDelay, cfg;
	bool pttInvert, squelchInvert;
	getController(type, cfg, pttDelay, squelchDelay, pttInvert, squelchInvert);
	wxLogInfo(wxT("Controller set to %s, config: %u, ptt delay: %u ms, squelch delay: %u ms, ptt invert: %d, squelch invert: %d"), type.c_str(), cfg, pttDelay * 20U, squelchInvert * 20U, pttInvert, squelchInvert);

	CExternalController* controller = NULL;

	wxString port;
	if (type.StartsWith(wxT("Velleman K8055 - "), &port)) {
		unsigned long num;
		port.ToULong(&num);
		controller = new CExternalController(new CK8055Controller(num), pttInvert, squelchInvert);
	} else if (type.StartsWith(wxT("Serial - "), &port)) {
		controller = new CExternalController(new CSerialLineController(port, cfg), pttInvert, squelchInvert);
	} else if (type.StartsWith(wxT("Arduino - "), &port)) {
		controller = new CExternalController(new CArduinoController(port), pttInvert, squelchInvert);
#if defined(GPIO)
	} else if (type.IsSameAs(wxT("GPIO"))) {
		controller = new CExternalController(new CGPIOController(cfg), pttInvert, squelchInvert);
#endif
	} else {
		controller = new CExternalController(new CDummyController, pttInvert, squelchInvert);
	}

	bool res = controller->open();
	if (!res)
		wxLogError(wxT("Cannot open the hardware interface - %s"), type.c_str());
	else
		thread->setController(controller, pttDelay, squelchDelay);

	ANALOGUE_EXTERNAL_MODE mode;
	wxString device;
	SERIALPIN txPin, rxPin;
	bool background;
	getExternal(mode, readDevice, writeDevice, audioDelay, deEmphasis, preEmphasis, vogad, device, txPin, rxPin, background);
	wxLogInfo(wxT("External mode: %d, soundcard set to %s:%s, delay: %u ms, de-emphasis: %d, pre-emphasis %d, vogad: %u, interface set to %s, tx %d, rx %d, background: %d"), mode, readDevice.c_str(), writeDevice.c_str(), audioDelay * 20U, int(deEmphasis), int(preEmphasis), int(vogad), device.c_str(), txPin, rxPin, int(background));

	if (mode != AEM_DISABLED) {
		CSoundCardReaderWriter* soundcard = new CSoundCardReaderWriter(readDevice, writeDevice, ANALOGUE_RADIO_SAMPLE_RATE, ANALOGUE_RADIO_BLOCK_SIZE);
		soundcard->setCallback(thread, SOUNDCARD_EXTERNAL);

		bool res = soundcard->open();
		if (!res) {
			wxLogError(wxT("Cannot open the external sound card"));
		} else {
			// This works even for an empty device name
			CNetworkController* controller = new CNetworkController(device, txPin, rxPin);

			res = controller->open();
			if (!res)
				wxLogError(wxT("Cannot open serial port - %s"), device.c_str());
			else
				thread->setExternal(mode, soundcard, audioDelay, deEmphasis, preEmphasis, vogad, controller, background);
		}
	}

	bool out1, out2, out3, out4;
	getOutputs(out1, out2, out3, out4);
	thread->setOutputs(out1, out2, out3, out4);
	m_frame->setOutputs(out1, out2, out3, out4);
	wxLogInfo(wxT("Output 1: %d, output 2: %d, output 3: %d, output 4: %d"), out1, out2, out3, out4);

	bool dtmfRadio, dtmfExternal;
	wxString dtmfShutdown, dtmfStartup, dtmfTimeout, dtmfTimeReset, dtmfOutput1, dtmfOutput2, dtmfOutput3, dtmfOutput4;
	wxString dtmfCommand1, dtmfCommand1Line, dtmfCommand2, dtmfCommand2Line;
	wxFloat32 dtmfThreshold;
	getDTMF(dtmfRadio, dtmfExternal, dtmfShutdown, dtmfStartup, dtmfTimeout, dtmfTimeReset, dtmfCommand1, dtmfCommand1Line, dtmfCommand2, dtmfCommand2Line, dtmfOutput1, dtmfOutput2, dtmfOutput3, dtmfOutput4, dtmfThreshold);
	thread->setDTMF(dtmfRadio, dtmfExternal, dtmfShutdown, dtmfStartup, dtmfTimeout, dtmfTimeReset, dtmfCommand1, dtmfCommand1Line, dtmfCommand2, dtmfCommand2Line, dtmfOutput1, dtmfOutput2, dtmfOutput3, dtmfOutput4, dtmfThreshold);
	wxLogInfo(wxT("DTMF: Radio: %d, External: %d, Shutdown: %s, Startup: %s, Timeout: %s, Time Reset: %s, Command1: %s = %s, Command2: %s = %s, Output1: %s, Output2: %s, Output3: %s, Output4: %s, Threshold: %f"), dtmfRadio, dtmfExternal, dtmfShutdown.c_str(), dtmfStartup.c_str(), dtmfTimeout.c_str(), dtmfTimeReset.c_str(), dtmfCommand1.c_str(), dtmfCommand1Line.c_str(), dtmfCommand2.c_str(), dtmfCommand2Line.c_str(), dtmfOutput1.c_str(), dtmfOutput2.c_str(), dtmfOutput3.c_str(), dtmfOutput4.c_str(), dtmfThreshold);

	unsigned int activeHangTime;
	getActiveHang(activeHangTime);
	thread->setActiveHang(activeHangTime);
	wxLogInfo(wxT("Active Hang: time: %u"), activeHangTime);

	// Convert the worker class into a thread
	m_thread = new CAnalogueRepeaterThreadHelper(thread);
	m_thread->start();
}
int MinionRadioHandler::send(BYTE id, BYTE msgType, word24 extraData) {
    return getRadio().send(id, msgType, extraData);
}
int MinionRadioHandler::send(BYTE id, BYTE msgType, BYTE ex0, BYTE ex1, BYTE ex2) {
    return getRadio().send(id, msgType, ex0, ex1, ex2);
}
void CSoundCardRepeaterApp::createThread()
{
	wxString callsign, gateway;
	DSTAR_MODE mode;
	ACK_TYPE ack;
	bool restriction, rpt1Validation;
	getCallsign(callsign, gateway, mode, ack, restriction, rpt1Validation);

	switch (mode) {
		case MODE_RXONLY:
			m_thread = new CSoundCardRepeaterRXThread;
			break;
		case MODE_TXONLY:
			m_thread = new CSoundCardRepeaterTXThread;
			break;
		case MODE_TXANDRX:
			m_thread = new CSoundCardRepeaterTXRXThread;
			break;
		default:
			m_thread = new CSoundCardRepeaterTRXThread;
			break;
	}

	m_thread->setCallsign(callsign, gateway, mode, ack, restriction, rpt1Validation);
	wxLogInfo(wxT("Callsign set to \"%s\", gateway set to \"%s\", mode: %d, ack: %d, restriction: %d, RPT1 validation: %d"), callsign.c_str(), gateway.c_str(), int(mode), int(ack), restriction, rpt1Validation);

	wxString gatewayAddress, localAddress;
	unsigned int gatewayPort, localPort;
	getNetwork(gatewayAddress, gatewayPort, localAddress, localPort);
	wxLogInfo(wxT("Gateway set to %s:%u, local set to %s:%u"), gatewayAddress.c_str(), gatewayPort, localAddress.c_str(), localPort);

	if (!gatewayAddress.IsEmpty()) {
		CRepeaterProtocolHandler* handler = new CRepeaterProtocolHandler(gatewayAddress, gatewayPort, localAddress, localPort);

		bool res = handler->open();
		if (!res)
			wxLogError(wxT("Cannot open the protocol handler"));
		else
			m_thread->setProtocolHandler(handler);
	}

	unsigned int timeout, ackTime, hangTime;
	getTimes(timeout, ackTime, hangTime);
	m_thread->setTimes(timeout, ackTime, hangTime);
	wxLogInfo(wxT("Timeout set to %u secs, Ack time set to %u ms, Hang time set to %u ms"), timeout, ackTime, hangTime);

	unsigned int beaconTime;
	wxString beaconText;
	bool beaconVoice;
	TEXT_LANG language;
	getBeacon(beaconTime, beaconText, beaconVoice, language);
	m_thread->setBeacon(beaconTime, beaconText, beaconVoice, language);
	wxLogInfo(wxT("Beacon set to %u mins, text set to \"%s\", voice set to %d, language set to %d"), beaconTime / 60U, beaconText.c_str(), int(beaconVoice), int(language));

	wxString readDevice, writeDevice;
	bool rxInvert, txInvert;
	wxFloat32 rxLevel, txLevel, squelchLevel;
	SQUELCH_MODE squelchMode;
	getRadio(readDevice, writeDevice, rxLevel, txLevel, squelchMode, squelchLevel, rxInvert, txInvert);
	wxLogInfo(wxT("Soundcard set to %s:%s, levels: %.2f:%.2f, GMSK Inversion set to %d:%d, squelch: mode: %d level: %.2f"), readDevice.c_str(), writeDevice.c_str(), rxLevel, txLevel, rxInvert, txInvert, int(squelchMode), squelchLevel);

	if (!readDevice.IsEmpty() && !writeDevice.IsEmpty()) {
#if defined(__WINDOWS__)
		CSoundCardReaderWriter* soundcard = new CSoundCardReaderWriter(readDevice, writeDevice, DSTAR_RADIO_SAMPLE_RATE, DSTAR_RADIO_BLOCK_SIZE);
#else
		CSoundCardReaderWriter* soundcard = new CSoundCardReaderWriter(readDevice, writeDevice, DSTAR_RADIO_SAMPLE_RATE, 64U);
#endif
		soundcard->setCallback(m_thread, 0U);

		bool res = soundcard->open();
		if (!res)
			wxLogError(wxT("Cannot open the sound card"));
		else
			m_thread->setSoundCard(soundcard, rxLevel, txLevel, squelchMode, squelchLevel, rxInvert, txInvert);
	}

	wxString type;
	unsigned int cfg;
	int pttDelay;
	bool pttInvert;
	getController(type, cfg, pttDelay, pttInvert);
	wxLogInfo(wxT("Controller set to %s, config: %u, ptt delay: %d ms, PTT Inversion set to %d"), type.c_str(), cfg, pttDelay * 20, pttInvert);

	CExternalController* controller = NULL;

	wxString port;
	if (type.StartsWith(wxT("Velleman K8055 - "), &port)) {
		unsigned long num;
		port.ToULong(&num);
		controller = new CExternalController(new CK8055Controller(num), pttInvert, false);
	} else if (type.StartsWith(wxT("URI USB - "), &port)) {
		unsigned long num;
		port.ToULong(&num);
		controller = new CExternalController(new CURIUSBController(num, false), pttInvert, false);
	} else if (type.StartsWith(wxT("Serial - "), &port)) {
		controller = new CExternalController(new CSerialController(port, cfg), pttInvert, false);
	} else {
		controller = new CExternalController(new CDummyController, pttInvert, false);
	}

	bool res = controller->open();
	if (!res)
		wxLogError(wxT("Cannot open the hardware interface - %s"), type.c_str());
	else
		m_thread->setController(controller, pttDelay);

	bool out1, out2, out3, out4;
	getOutputs(out1, out2, out3, out4);
	m_thread->setOutputs(out1, out2, out3, out4);
	m_frame->setOutputs(out1, out2, out3, out4);
	wxLogInfo(wxT("Output 1 = %d, output 2 = %d, output 3 = %d, output 4 = %d"), out1, out2, out3, out4);

	bool enabled;
	wxString rpt1Callsign, rpt2Callsign;
	wxString shutdown, startup;
	wxString status1, status2, status3, status4, status5;
	wxString command1, command1Line, command2, command2Line;
	wxString command3, command3Line, command4, command4Line;
	wxString output1, output2, output3, output4;
	getControl(enabled, rpt1Callsign, rpt2Callsign, shutdown, startup, status1, status2, status3, status4, status5, command1, command1Line, command2, command2Line, command3, command3Line, command4, command4Line, output1, output2, output3, output4);
	m_thread->setControl(enabled, rpt1Callsign, rpt2Callsign, shutdown, startup, status1, status2, status3, status4, status5, command1, command1Line, command2, command2Line, command3, command3Line, command4, command4Line, output1, output2, output3, output4);
	wxLogInfo(wxT("Control: enabled: %d, RPT1: %s, RPT2: %s, shutdown: %s, startup: %s, status1: %s, status2: %s, status3: %s, status4: %s, status5: %s, command1: %s = %s, command2: %s = %s, command3: %s = %s, command4: %s = %s, output1: %s, output2: %s, output3: %s, output4: %s"), enabled, rpt1Callsign.c_str(), rpt2Callsign.c_str(), shutdown.c_str(), startup.c_str(), status1.c_str(), status2.c_str(), status3.c_str(), status4.c_str(), status5.c_str(), command1.c_str(), command1Line.c_str(), command2.c_str(), command2Line.c_str(), command1.c_str(), command1Line.c_str(), command2.c_str(), command2Line.c_str(), command3.c_str(), command3Line.c_str(), command4.c_str(), command4Line.c_str(), output1.c_str(), output2.c_str(), output3.c_str(), output4.c_str());

	unsigned int activeHangTime;
	getActiveHang(activeHangTime);
	m_thread->setActiveHang(activeHangTime);
	wxLogInfo(wxT("Active Hang: time: %u"), activeHangTime);

	bool logging;
	getLogging(logging);
	m_thread->setLogging(logging, ::wxGetHomeDir());
	m_frame->setLogging(logging);
	wxLogInfo(wxT("Frame logging set to %d, in %s"), int(logging), ::wxGetHomeDir().c_str());

	wxFileName wlFilename(wxFileName::GetHomeDir(), WHITELIST_FILE_NAME);
	bool exists = wlFilename.FileExists();
	if (exists) {
		CCallsignList* list = new CCallsignList(wlFilename.GetFullPath());
		bool res = list->load();
		if (!res) {
			wxLogError(wxT("Unable to open white list file - %s"), wlFilename.GetFullPath().c_str());
			delete list;
		} else {
			wxLogInfo(wxT("%u callsigns loaded into the white list"), list->getCount());
			m_thread->setWhiteList(list);
		}
	}

	wxFileName blFilename(wxFileName::GetHomeDir(), BLACKLIST_FILE_NAME);
	exists = blFilename.FileExists();
	if (exists) {
		CCallsignList* list = new CCallsignList(blFilename.GetFullPath());
		bool res = list->load();
		if (!res) {
			wxLogError(wxT("Unable to open black list file - %s"), blFilename.GetFullPath().c_str());
			delete list;
		} else {
			wxLogInfo(wxT("%u callsigns loaded into the black list"), list->getCount());
			m_thread->setBlackList(list);
		}
	}

	m_thread->start();
}
Esempio n. 11
0
void PDCHL1FEC::mchStop() {
	getRadio()->setSlot(TN(),Transceiver::I);
	mchOldFec->setGPRS(false,NULL);
}