void tx(repeater* myrpt) { if (myrpt->state > IDLE && !myrpt->transmitter.tx) { serial_writer(&myrpt->serial, "REPEATER: TX ON"); myrpt->transmitter.tx = true; digitalWrite(PTT,LOW); delay(100); myrpt->timer.tx_start = millis(); return; } if (myrpt->state < KEYCHUNK && myrpt->transmitter.tx) { serial_writer(&myrpt->serial, "REPEATER: TX OFF"); myrpt->transmitter.tx = false; myrpt->stats.tx_time += millis() - myrpt->timer.tx_start; digitalWrite(PTT,HIGH); } } void rx(repeater* myrpt) { myrpt->receiver.rx = digitalRead(COS); myrpt->gateway.receiver.rx = 1; //digitalRead(GW_COS); if (!myrpt->receiver.rx && !myrpt->gateway.transmitter.tx) { serial_writer(&myrpt->serial, "REPEATER: COS"); digitalWrite(GWPTT, true); myrpt->gateway.transmitter.tx = true; myrpt->timer.rx_start = millis(); return; } if (myrpt->receiver.rx && myrpt->gateway.transmitter.tx) { digitalWrite(GWPTT, false); myrpt->gateway.transmitter.tx = false; myrpt->stats.rx_time += millis() - myrpt->timer.rx_start; } } bool busy(repeater* myrpt) { rx(myrpt); return (!myrpt->receiver.rx || !myrpt->gateway.receiver.rx); } void courtesyTone(repeater* myrpt) { switch(myrpt->params.courtesy) { case TONE: myrpt->last == TT ? tone(PIP, myrpt->params.pip_pitch, myrpt->params.pip_length) : tone(PIP, myrpt->params.pip_gw_pitch, myrpt->params.pip_gw_length); break; case CW: myrpt->last == TT ? sendChar(myrpt, myrpt->params.pip_letter) : sendChar(myrpt, myrpt->params.pip_gw_letter); break; default: break; } if (TAILPIPS) delay(myrpt->params.pip_length); } void serial_command(serial* s, repeater* myrpt) { char cmd[5]; if (Serial.available() > 0) { Serial.readBytes(cmd, 5); switch (cmd[0]) { case '0': serial_writer(s, "SEND STATS"); break; case '1': tone(PIP, 1000, 100); break; case '2': serial_writer(s, "CONFIG: Set tone | (0) OFF | (1) CW | (2) TONE |"); serial_writer(s, "Entered"); switch (cmd[1]) { case '0': serial_writer(s, "Courtesy OFF"); myrpt->params.courtesy = NONE; break; case '1': serial_writer(s, "Courtesy CW"); myrpt->params.courtesy = CW; break; case '2': serial_writer(s, "Courtesy TONE"); myrpt->params.courtesy = TONE; break; default: break; } break; case '3': Serial.print("RX: "); Serial.println((myrpt->stats.rx_time /1000)); Serial.print("TX: "); Serial.println((myrpt->stats.tx_time /1000)); Serial.print("GW: "); Serial.println((myrpt->stats.gw_time /1000)); Serial.print("RX Status: "); Serial.println(!myrpt->receiver.rx); Serial.print("TX Status: "); Serial.println(myrpt->transmitter.tx); Serial.print("GW Status: "); Serial.println(!myrpt->gateway.receiver.rx); break; case '4': info inf; inf.type = 254; inf.stats = &myrpt->stats; inf.receiver = !myrpt->receiver.rx; inf.transmitter = myrpt->transmitter.tx; inf.gateway = !myrpt->gateway.receiver.rx; Serial.write((byte*)&inf, sizeof(info) + sizeof(stats) - 4); default: break; } } } void serial_writer(serial* s, char* buff) { if (!s->enable) return; Serial.write(buff); Serial.write('\n'); }