diff --git a/GB3TX/GB3TX.ino b/GB3TX/GB3TX.ino index 05565d4..06f60a5 100644 --- a/GB3TX/GB3TX.ino +++ b/GB3TX/GB3TX.ino @@ -54,7 +54,7 @@ void loop() { kc = millis(); } - if (myrpt->state == KEYCHUNK && millis() - kc > KEYCHUNK_TIME) { + if (myrpt->state == KEYCHUNK && compareStamp(&myrpt->receiver.timestamp, KEYCHUNK_TIME)) { if (!myrpt->receiver.rx) { myrpt->state = TT; serial_writer(&myrpt->serial, "RX: RF"); @@ -74,13 +74,12 @@ void loop() { if ((myrpt->receiver.rx && myrpt->gateway.receiver.rx) && myrpt->state > HANG) { serial_writer(&myrpt->serial, "HANG"); - if (myrpt->state == GW) delay(500); myrpt->last = myrpt->state; myrpt->state = HANG; ht = millis(); myrpt->tail = ht; - if (ht - tot < PIP_KEYCHUNK || busy(myrpt)) + if (!compareStamp(&myrpt->receiver.timestamp, PIP_KEYCHUNK) || busy(myrpt)) continue; courtesyTone(myrpt); } diff --git a/GB3TX/cw.ino b/GB3TX/cw.ino index 6cb9e69..f525305 100644 --- a/GB3TX/cw.ino +++ b/GB3TX/cw.ino @@ -50,8 +50,6 @@ void sendID(repeater* myrpt) { return; } - delay(500); - for (int i=0; i < sizeof ID/sizeof ID[0]; i++) { sendChar(myrpt, myrpt->callsign[i]); delay(myrpt->params.cw_speed * 3); diff --git a/GB3TX/repeater.h b/GB3TX/repeater.h index e1e3a39..557c1c4 100644 --- a/GB3TX/repeater.h +++ b/GB3TX/repeater.h @@ -32,6 +32,11 @@ typedef struct { int start_up; }params; +typedef struct { + unsigned long start; + unsigned long end; +}t_stamp; + typedef struct { bool tx; }transmitter; @@ -39,6 +44,7 @@ typedef struct { typedef struct { int id; bool rx; + t_stamp timestamp; }receiver; typedef struct { @@ -47,7 +53,6 @@ typedef struct { }serial; typedef struct { - bool enable; receiver receiver; transmitter transmitter; }gateway; diff --git a/GB3TX/repeater.ino b/GB3TX/repeater.ino index 2f1e5f1..224d747 100644 --- a/GB3TX/repeater.ino +++ b/GB3TX/repeater.ino @@ -20,14 +20,18 @@ void rx(repeater* myrpt) { if (!myrpt->receiver.rx && !myrpt->gateway.transmitter.tx) { serial_writer(&myrpt->serial, "REPEATER: COS"); + myrpt->receiver.timestamp.start = millis(); digitalWrite(GWPTT, true); myrpt->gateway.transmitter.tx = true; return; } - if (myrpt->receiver.rx && myrpt->gateway.transmitter.tx) { + if (myrpt->receiver.rx) { + myrpt->receiver.timestamp.end = millis(); + if (myrpt->gateway.transmitter.tx) { digitalWrite(GWPTT, false); myrpt->gateway.transmitter.tx = false; + } } } @@ -36,6 +40,10 @@ bool busy(repeater* myrpt) { return (!myrpt->receiver.rx || !myrpt->gateway.receiver.rx); } +bool compareStamp(t_stamp* ts, unsigned long cmp) { + return ts->end - ts->start > cmp; +} + void courtesyTone(repeater* myrpt) { switch(myrpt->params.courtesy) { case TONE: