From 7c1ea015a8e312b1f5a8fb8a037e34585886a2f0 Mon Sep 17 00:00:00 2001 From: Jim Colderwood Date: Thu, 4 Apr 2024 11:30:37 +0100 Subject: [PATCH] start of serial --- GB3TX/GB3TX.ino | 17 ++++++++++++++++- GB3TX/config.h | 14 +++++++++----- GB3TX/repeater.h | 6 ++++++ GB3TX/repeater.ino | 8 ++++++++ 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/GB3TX/GB3TX.ino b/GB3TX/GB3TX.ino index 071fba5..d9b794f 100644 --- a/GB3TX/GB3TX.ino +++ b/GB3TX/GB3TX.ino @@ -17,6 +17,10 @@ void loop() { myrpt = &rpt; myrpt->callsign = ID; myrpt->params.cw_pitch = CW_PITCH; + myrpt->serial.enable = SERIAL; + myrpt->serial.speed = 115200; + if (myrpt->serial.enable) + Serial.begin(myrpt->serial.speed); /* Setup params */ myrpt->params.cw_speed = 1200 / CW_SPEED; @@ -31,7 +35,7 @@ void loop() { delay(1000); myrpt->transmitter.tx = true; - sendID(myrpt); + //sendID(myrpt); myrpt->state = SLEEP; unsigned long ht = millis(); @@ -43,23 +47,28 @@ void loop() { if (((!myrpt->receiver.rx || !myrpt->gateway.receiver.rx)) && myrpt->state < 2) { myrpt->state = KEYCHUNK; + serial_writer(&myrpt->serial, "KEYCHUNK"); kc = millis(); } if (myrpt->state == KEYCHUNK && millis() - kc > KEYCHUNK_TIME) { if (!myrpt->receiver.rx) { myrpt->state = TT; + serial_writer(&myrpt->serial, "RX: RF"); } else { myrpt->state = GW; + serial_writer(&myrpt->serial, "RX: GATEWAY"); } tot = millis(); } if ((myrpt->receiver.rx && myrpt->gateway.receiver.rx) && myrpt->state == KEYCHUNK) { + serial_writer(&myrpt->serial, "SHORT SIGNAL"); myrpt->state = IDLE; } if ((myrpt->receiver.rx && myrpt->gateway.receiver.rx) && myrpt->state > HANG) { + serial_writer(&myrpt->serial, "HANG"); delay(350); myrpt->last = myrpt->state; myrpt->state = HANG; @@ -78,20 +87,24 @@ void loop() { } if (!myrpt->receiver.rx && myrpt->state == HANG) { + serial_writer(&myrpt->serial, "RX: RF"); myrpt->state = TT; tot = millis(); } if (!myrpt->gateway.receiver.rx && myrpt->state == HANG) { + serial_writer(&myrpt->serial, "RX: GATEWAY"); myrpt->state = GW; tot = millis(); } if (myrpt->state == HANG && millis() - ht > HANGTIME) { + serial_writer(&myrpt->serial, "REPEATER: IDLE"); myrpt->state = IDLE; } if (millis() - tot >= TIMEOUT && (myrpt->state == TT || myrpt->state == GW)) { + serial_writer(&myrpt->serial, "REPEATER: TIMEOUT"); myrpt->state = TIMEOUT; tone(3, 440, 1000); delay(1000); @@ -105,12 +118,14 @@ void loop() { if (myrpt->receiver.rx && myrpt->gateway.receiver.rx) break; } + serial_writer(&myrpt->serial, "REPEATER: TIMEOUT RESET"); } tx(myrpt); if (myrpt->state > SLEEP && millis() - id >= IDTIME) { /* Repeater is IDLE, bring the transmitter up */ + serial_writer(&myrpt->serial, "REPEATER: ID"); if (!myrpt->transmitter.tx) { myrpt->state = HANG; tx(myrpt); diff --git a/GB3TX/config.h b/GB3TX/config.h index eb33b51..6f3f873 100644 --- a/GB3TX/config.h +++ b/GB3TX/config.h @@ -15,21 +15,25 @@ /* PARAMS */ #define COURTESY CW -#define GWPIP 875 +#define GWPIP 1200 #define GWPIPLEN 120 #define PIP_LETTER 'R' -#define PIP_GW_LETTER 'I' -#define PIP_SPEED 18 +#define PIP_GW_LETTER 'E' +#define PIP_SPEED 20 #define RFPIP 1200 #define RFPIPLEN 80 #define TAILPIPS true #define TAILPIP_PITCH 500 +/* SERIAL */ +#define SERIAL false +#define SERIAL_SPEED 115200 + /* TIMERS */ -#define HANGTIME 3000 +#define HANGTIME 5000 #define KEYCHUNK_TIME 1000 #define TIMEOUT 300000 #define IDTIME 300000 -#define PIP_KEYCHUNK 1500 +#define PIP_KEYCHUNK 1500 #endif \ No newline at end of file diff --git a/GB3TX/repeater.h b/GB3TX/repeater.h index a41f60d..91e5bd7 100644 --- a/GB3TX/repeater.h +++ b/GB3TX/repeater.h @@ -40,6 +40,11 @@ typedef struct { unsigned long long rx_time; }receiver; +typedef struct { + bool enable; + unsigned long speed; +}serial; + typedef struct { bool enable; receiver receiver; @@ -55,6 +60,7 @@ typedef struct { state last; params params; receiver receiver; + serial serial; state state; transmitter transmitter; }repeater; diff --git a/GB3TX/repeater.ino b/GB3TX/repeater.ino index be642cb..1ab3b0f 100644 --- a/GB3TX/repeater.ino +++ b/GB3TX/repeater.ino @@ -1,5 +1,6 @@ void tx(repeater* myrpt) { if (myrpt->state > 1 && !myrpt->transmitter.tx) { + serial_writer(&myrpt->serial, "REPEATER: TX ON"); myrpt->transmitter.tx = true; digitalWrite(PTT,LOW); delay(100); @@ -9,6 +10,7 @@ void tx(repeater* myrpt) { if (!myrpt->transmitter.tx) return; + serial_writer(&myrpt->serial, "REPEATER: TX OFF"); myrpt->transmitter.tx = false; digitalWrite(PTT,HIGH); } @@ -18,6 +20,7 @@ void rx(repeater* myrpt) { myrpt->gateway.receiver.rx = 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; return; @@ -45,4 +48,9 @@ void courtesyTone(repeater* myrpt) { myrpt->last == TT ? sendChar(myrpt->params.pip_speed,myrpt->params.pip_pitch,myrpt->params.pip_letter) : sendChar(myrpt->params.pip_speed,myrpt->params.pip_gw_pitch, myrpt->params.pip_gw_letter); break; } +} + +void serial_writer(serial* s, char* buff) { + Serial.write(buff); + Serial.write('\n'); } \ No newline at end of file