kopia lustrzana https://github.com/sh123/esp32_loraprs
Add experimental external PTT control
rodzic
96a6547710
commit
fc0ad84b4b
5
config.h
5
config.h
|
@ -47,3 +47,8 @@
|
||||||
#define CFG_IS_TO_RF false
|
#define CFG_IS_TO_RF false
|
||||||
#define CFG_BEACON false
|
#define CFG_BEACON false
|
||||||
#define CFG_KISS_EXTENSIONS false
|
#define CFG_KISS_EXTENSIONS false
|
||||||
|
|
||||||
|
#define CFG_PTT_ENABLE false
|
||||||
|
#define CFG_PTT_PIN 12
|
||||||
|
#define CFG_PTT_TX_DELAY_MS 50
|
||||||
|
#define CFG_PTT_TX_TAIL_MS 10
|
||||||
|
|
|
@ -64,6 +64,12 @@ void initializeConfig(LoraPrs::Config &cfg) {
|
||||||
cfg.EnableRepeater = CFG_DIGIREPEAT; // digirepeat incoming packets
|
cfg.EnableRepeater = CFG_DIGIREPEAT; // digirepeat incoming packets
|
||||||
cfg.EnableBeacon = CFG_BEACON; // enable periodic AprsRawBeacon beacon to rf and aprsis if rf to aprsis is enabled
|
cfg.EnableBeacon = CFG_BEACON; // enable periodic AprsRawBeacon beacon to rf and aprsis if rf to aprsis is enabled
|
||||||
cfg.EnableKissExtensions = CFG_KISS_EXTENSIONS; // radio control and signal reports
|
cfg.EnableKissExtensions = CFG_KISS_EXTENSIONS; // radio control and signal reports
|
||||||
|
|
||||||
|
// external ptt control
|
||||||
|
cfg.PttEnable = CFG_PTT_ENABLE;
|
||||||
|
cfg.PttPin = CFG_PTT_PIN;
|
||||||
|
cfg.PttTxDelayMs = CFG_PTT_TX_DELAY_MS;
|
||||||
|
cfg.PttTxTailMs = CFG_PTT_TX_TAIL_MS;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoraPrs::Service loraPrsService;
|
LoraPrs::Service loraPrsService;
|
||||||
|
|
|
@ -31,8 +31,10 @@ protected:
|
||||||
|
|
||||||
enum Cmd {
|
enum Cmd {
|
||||||
Data = 0x00,
|
Data = 0x00,
|
||||||
|
TxDelay = 0x01,
|
||||||
P = 0x02,
|
P = 0x02,
|
||||||
SlotTime = 0x03,
|
SlotTime = 0x03,
|
||||||
|
TxTail = 0x04,
|
||||||
SetHardware = 0x06,
|
SetHardware = 0x06,
|
||||||
SignalReport = 0x07,
|
SignalReport = 0x07,
|
||||||
NoCmd = 0x80
|
NoCmd = 0x80
|
||||||
|
|
|
@ -54,6 +54,12 @@ struct Config
|
||||||
bool EnableIsToRf; // true - enable APRS-IS to RF submission
|
bool EnableIsToRf; // true - enable APRS-IS to RF submission
|
||||||
bool EnableRepeater; // true - digirepeat incoming packets based on WIDEn-n paths
|
bool EnableRepeater; // true - digirepeat incoming packets based on WIDEn-n paths
|
||||||
bool EnableBeacon; // true - send AprsRawBeacon to RF and APRS-IS if EnableRfToIs is true
|
bool EnableBeacon; // true - send AprsRawBeacon to RF and APRS-IS if EnableRfToIs is true
|
||||||
|
|
||||||
|
// external ptt tx control
|
||||||
|
bool PttEnable; // true - enable external ptt control
|
||||||
|
int PttPin; // esp pin to set high on transmit
|
||||||
|
int PttTxDelayMs; // ptt tx delay
|
||||||
|
int PttTxTailMs; // ptt tx tail
|
||||||
};
|
};
|
||||||
|
|
||||||
} // LoraPrs
|
} // LoraPrs
|
||||||
|
|
|
@ -43,6 +43,11 @@ void Service::setup(const Config &conf)
|
||||||
if (needsAprsis() && config_.EnablePersistentAprsConnection) {
|
if (needsAprsis() && config_.EnablePersistentAprsConnection) {
|
||||||
reconnectAprsis();
|
reconnectAprsis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config_.PttEnable) {
|
||||||
|
Serial.println("External PTT is enabled");
|
||||||
|
pinMode(config_.PttPin, OUTPUT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Service::setupWifi(const String &wifiName, const String &wifiKey)
|
void Service::setupWifi(const String &wifiName, const String &wifiKey)
|
||||||
|
@ -357,7 +362,12 @@ void Service::processIncomingRawPacketAsServer(const byte *packet, int packetLen
|
||||||
|
|
||||||
bool Service::onRigTxBegin()
|
bool Service::onRigTxBegin()
|
||||||
{
|
{
|
||||||
delay(CfgPollDelayMs);
|
if (config_.PttEnable) {
|
||||||
|
digitalWrite(config_.PttPin, HIGH);
|
||||||
|
delay(config_.PttTxDelayMs);
|
||||||
|
} else {
|
||||||
|
delay(CfgPollDelayMs);
|
||||||
|
}
|
||||||
return (LoRa.beginPacket() == 1);
|
return (LoRa.beginPacket() == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,7 +378,13 @@ void Service::onRigTx(byte b)
|
||||||
|
|
||||||
void Service::onRigTxEnd()
|
void Service::onRigTxEnd()
|
||||||
{
|
{
|
||||||
LoRa.endPacket(true);
|
if (config_.PttEnable) {
|
||||||
|
LoRa.endPacket(false);
|
||||||
|
delay(config_.PttTxTailMs);
|
||||||
|
digitalWrite(config_.PttPin, LOW);
|
||||||
|
} else {
|
||||||
|
LoRa.endPacket(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Service::onSerialTx(byte b)
|
void Service::onSerialTx(byte b)
|
||||||
|
@ -402,6 +418,14 @@ void Service::onControlCommand(Cmd cmd, byte value)
|
||||||
Serial.print("CSMA SlotTime: "); Serial.println(value);
|
Serial.print("CSMA SlotTime: "); Serial.println(value);
|
||||||
csmaSlotTime_ = (long)value * 10;
|
csmaSlotTime_ = (long)value * 10;
|
||||||
break;
|
break;
|
||||||
|
case Cmd::TxDelay:
|
||||||
|
Serial.print("TX delay: "); Serial.println(value);
|
||||||
|
config_.PttTxDelayMs = (long)value * 10;
|
||||||
|
break;
|
||||||
|
case Cmd::TxTail:
|
||||||
|
Serial.print("TX tail: "); Serial.println(value);
|
||||||
|
config_.PttTxTailMs = (long)value * 10;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue