diff --git a/Inc/common.h b/Inc/common.h
index 87dcc41..dec1af8 100644
--- a/Inc/common.h
+++ b/Inc/common.h
@@ -25,7 +25,7 @@ along with VP-Digi. If not, see .
uint8_t call[6]; //device callsign
uint8_t callSsid; //device ssid
-const uint8_t dest[7]; //constant destination field for own beacons. Should be APNV01-0 for VP-Digi
+uint8_t dest[7]; //destination address for own beacons. Should be APNV01-0 for VP-Digi, but can be changed. SSID MUST remain 0.
const uint8_t *versionString; //version string
diff --git a/Inc/config.h b/Inc/config.h
index 9c34d31..4312e2b 100644
--- a/Inc/config.h
+++ b/Inc/config.h
@@ -86,7 +86,8 @@ along with VP-Digi. If not, see .
#define CONFIG_DIGISSID7 1214
#define CONFIG_PWM_FLAT 1216
#define CONFIG_KISSMONITOR 1218
-#define CONFIG_XXX 1220 //next address (not used)
+#define CONFIG_DEST 1220
+#define CONFIG_XXX 1226 //next address (not used)
/**
* @brief Store configuration from RAM to Flash
diff --git a/Src/ax25.c b/Src/ax25.c
index 7463b03..d08bc75 100644
--- a/Src/ax25.c
+++ b/Src/ax25.c
@@ -358,7 +358,7 @@ uint8_t Ax25_getTxBit(void)
txState.txByte = 0x7E;
txState.txTailElapsed++;
}
- else //tail transmitted, stop transmissiob
+ else //tail transmitted, stop transmission
{
txState.txTailElapsed = 0;
txState.txStage = TX_STAGE_IDLE;
@@ -400,7 +400,7 @@ uint8_t Ax25_getTxBit(void)
txState.txBitIdx++;
}
}
- else //transmitting preambles or flags, don't calculate CRC, don't use bit stuffing
+ else //transmitting preamble or flags, don't calculate CRC, don't use bit stuffing
{
txBit = txState.txByte & 1;
txState.txByte >>= 1;
@@ -433,7 +433,7 @@ void Ax25_transmitBuffer(void)
/**
- * @brief Start transmissin immediately
+ * @brief Start transmission immediately
* @warning Transmission should be initialized using Ax25_transmitBuffer
*/
static void ax25_transmitStart(void)
@@ -476,7 +476,7 @@ void Ax25_transmitCheck(void)
}
else //channel is busy
{
- if(txState.txRetries == 8) //8th retry occured, transmit immediately
+ if(txState.txRetries == 8) //8th retry occurred, transmit immediately
{
txState.tx = TX_INIT_TRANSMITTING; //transmit right now
txState.txRetries = 0;
diff --git a/Src/common.c b/Src/common.c
index d1e444e..7b1f44f 100644
--- a/Src/common.c
+++ b/Src/common.c
@@ -25,9 +25,9 @@ along with VP-Digi. If not, see .
uint8_t call[6] = {'N' << 1, '0' << 1, 'C' << 1, 'A' << 1, 'L' << 1, 'L' << 1};
uint8_t callSsid = 0;
-const uint8_t dest[7] = {130, 160, 156, 172, 96, 98, 96}; //APNV01-0
+uint8_t dest[7] = {130, 160, 156, 172, 96, 98, 96}; //destination address: APNV01-0 by default. SSID MUST remain 0.
-const uint8_t *versionString = (const uint8_t*)"VP-Digi v. 1.2.4\r\nThe open-source standalone APRS digipeater controller and KISS TNC\r\n";
+const uint8_t *versionString = (const uint8_t*)"VP-Digi v. 1.2.5\r\nThe open-source standalone APRS digipeater controller and KISS TNC\r\n";
uint8_t autoReset = 0;
uint32_t autoResetTimer = 0;
diff --git a/Src/config.c b/Src/config.c
index 36310e3..8f13393 100644
--- a/Src/config.c
+++ b/Src/config.c
@@ -128,6 +128,7 @@ void Config_write(void)
flash_writeString(CONFIG_CALL, call, 6);
flash_write(CONFIG_SSID, callSsid);
+ flash_writeString(CONFIG_DEST, dest, 6);
flash_write(CONFIG_TXDELAY, ax25Cfg.txDelayLength);
flash_write(CONFIG_TXTAIL, ax25Cfg.txTailLength);
flash_write(CONFIG_TXQUIET, ax25Cfg.quietTime);
@@ -204,9 +205,14 @@ uint8_t Config_read(void)
{
return 0;
}
-
flash_readString(CONFIG_CALL, call, 6);
callSsid = (uint8_t)flash_read(CONFIG_SSID);
+ uint8_t temp[6];
+ flash_readString(CONFIG_DEST, temp, 6);
+ if((temp[0] >= ('A' << 1)) && (temp[0] <= ('Z' << 1)) && ((temp[0] & 1) == 0)) //check if stored destination address is correct (we just assume it by reading the first byte)
+ {
+ memcpy(dest, temp, sizeof(uint8_t) * 6);
+ }
ax25Cfg.txDelayLength = flash_read(CONFIG_TXDELAY);
ax25Cfg.txTailLength = flash_read(CONFIG_TXTAIL);
ax25Cfg.quietTime = flash_read(CONFIG_TXQUIET);
diff --git a/Src/drivers/modem.c b/Src/drivers/modem.c
index e4f97fd..e1f53c4 100644
--- a/Src/drivers/modem.c
+++ b/Src/drivers/modem.c
@@ -28,10 +28,10 @@ along with VP-Digi. If not, see .
* Configuration for PLL-based data carrier detection
* DCD_MAXPULSE is the maximum value of the DCD pulse counter
* DCD_THRES is the threshold value of the DCD pulse counter. When reached the input signal is assumed to be valid
- * DCD_MAXPULSE and DCD_THRES difference sets the DCD "intertia" so that the DCD state won't change rapidly when a valid signal is present
+ * DCD_MAXPULSE and DCD_THRES difference sets the DCD "inertia" so that the DCD state won't change rapidly when a valid signal is present
* DCD_DEC is the DCD pulse counter decrementation value when symbol changes too far from PLL counter zero
* DCD_INC is the DCD pulse counter incrementation value when symbol changes near the PLL counter zero
- * DCD_PLLTUNE is the DCD tining coefficient when symbol changes, pll_counter = pll_counter * DCD_PLLTUNE
+ * DCD_PLLTUNE is the DCD timing coefficient when symbol changes, pll_counter = pll_counter * DCD_PLLTUNE
* The DCD mechanism is described in afsk_demod().
* All values were selected by trial and error
*/
@@ -58,7 +58,7 @@ struct ModState
{
TxTestMode txTestState; //current TX test mode
uint16_t dacSine[DACSINELEN]; //sine samples for DAC
- uint8_t dacSineIdx; //current sine smaple index
+ uint8_t dacSineIdx; //current sine sample index
uint16_t samples_oversampling[4]; //very raw received samples, filled directly by DMA
uint8_t currentSymbol; //current symbol for NRZI encoding
uint16_t txDelay; //TXDelay length in number of bytes
@@ -370,7 +370,7 @@ static int32_t afsk_demod(int16_t sample, Demod *dem)
//PLL timer is counting up and eventually overflows to a minimal negative value
//so it crosses zero in the middle
//tone change should happen somewhere near this zero-crossing (in ideal case of exactly same TX and RX baudrates)
- //nothing is ideal, so we need to have some region around zero where the tone should change
+ //nothing is ideal, so we need to have some region around zero where tone change is expected
//if tone changed inside this region, then we add something to the DCD pulse counter (and adjust counter phase for the counter to be closer to 0)
//if tone changes outside this region, then we subtract something from the DCD pulse counter
//if some DCD pulse threshold is reached, then we claim that the incoming signal is correct and set DCD flag
@@ -383,7 +383,7 @@ static int32_t afsk_demod(int16_t sample, Demod *dem)
if(dcdSymbol != dem->dcdLastSymbol) //tone changed
{
- if(abs(dem->dcdPll) < PLLINC) //tone change occured near zero
+ if(abs(dem->dcdPll) < PLLINC) //tone change occurred near zero
dem->dcdCounter += DCD_INC; //increase DCD counter
else //tone change occurred far from zero
{
@@ -582,6 +582,8 @@ void Afsk_transmitStop(void)
NVIC_EnableIRQ(DMA1_Channel2_IRQn);
afsk_ptt(0);
+
+ TIM4->CCR1 = 44; //set around 50% duty cycle
}
/**
@@ -665,7 +667,7 @@ void Afsk_init(void)
DMA1_Channel2->CCR |= DMA_CCR_PSIZE_0;
DMA1_Channel2->CCR &= ~DMA_CCR_PSIZE_1;
- DMA1_Channel2->CCR |= DMA_CCR_MINC | DMA_CCR_CIRC| DMA_CCR_TCIE; //circural mode, memory increment and interrupt
+ DMA1_Channel2->CCR |= DMA_CCR_MINC | DMA_CCR_CIRC| DMA_CCR_TCIE; //circular mode, memory increment and interrupt
DMA1_Channel2->CNDTR = 4; //4 samples
DMA1_Channel2->CPAR = (uint32_t)&(ADC1->DR); //ADC data register address
DMA1_Channel2->CMAR = (uint32_t)modState.samples_oversampling; //sample buffer address
diff --git a/Src/terminal.c b/Src/terminal.c
index 8ad9305..4784be8 100644
--- a/Src/terminal.c
+++ b/Src/terminal.c
@@ -459,6 +459,7 @@ void term_parse(uint8_t *cmd, uint16_t len, Terminal_stream src, Uart_data_type
term_sendBuf(src);
term_sendString((uint8_t*)"call - sets callsign\r\n", 0);
term_sendString((uint8_t*)"ssid <0-15> - sets SSID\r\n", 0);
+ term_sendString((uint8_t*)"dest - sets destination address\r\n", 0);
term_sendString((uint8_t*)"txdelay <50-2550> - sets TXDelay time (ms)\r\n", 0);
term_sendString((uint8_t*)"txtail <10-2550> - sets TXTail time (ms)\r\n", 0);
term_sendString((uint8_t*)"quiet <100-2550> - sets quiet time (ms)\r\n", 0);
@@ -515,16 +516,24 @@ void term_parse(uint8_t *cmd, uint16_t len, Terminal_stream src, Uart_data_type
return;
}
- if(checkcmd(cmd, 5, (uint8_t*)"print")) //wyrzucamy cala konfiguracje
+ if(checkcmd(cmd, 5, (uint8_t*)"print"))
{
term_sendString((uint8_t*)"Callsign: ", 0);
for(uint8_t i = 0; i < 6; i++)
{
- if((call[i]) != 64) term_sendByte(call[i] >> 1);
+ if((call[i]) != 64)
+ term_sendByte(call[i] >> 1);
}
term_sendByte('-');
term_sendNumber(callSsid);
+ term_sendString((uint8_t*)"\r\nDestination: ", 0);
+ for(uint8_t i = 0; i < 6; i++)
+ {
+ if((dest[i]) != 64)
+ term_sendByte(dest[i] >> 1);
+ }
+
term_sendString((uint8_t*)"\r\nTXDelay (ms): ", 0);
term_sendNumber(ax25Cfg.txDelayLength);
term_sendString((uint8_t*)"\r\nTXTail (ms): ", 0);
@@ -768,7 +777,7 @@ void term_parse(uint8_t *cmd, uint16_t len, Terminal_stream src, Uart_data_type
err = 1;
break;
}
- if(!(((cmd[5 + i] > 47) && (cmd[5 + i] < 58)) || ((cmd[5 + i] > 64) && (cmd[5 + i] < 91)))) //only alphanumerical characters
+ if(!(((cmd[5 + i] > 47) && (cmd[5 + i] < 58)) || ((cmd[5 + i] > 64) && (cmd[5 + i] < 91)))) //only alphanumeric characters
{
err = 1;
break;
@@ -780,11 +789,13 @@ void term_parse(uint8_t *cmd, uint16_t len, Terminal_stream src, Uart_data_type
}
tmp[i] = cmd[5 + i] << 1;
}
- if(!err) for(uint8_t i = 0; i < 6; i++)
- {
- call[i] = 64; //fill with spaces
- if(tmp[i] != 0) call[i] = tmp[i];
- }
+ if(!err)
+ for(uint8_t i = 0; i < 6; i++)
+ {
+ call[i] = 64; //fill with spaces
+ if(tmp[i] != 0)
+ call[i] = tmp[i];
+ }
if(err)
{
term_sendString((uint8_t*)"Incorrect callsign!\r\n", 0);
@@ -797,6 +808,49 @@ void term_parse(uint8_t *cmd, uint16_t len, Terminal_stream src, Uart_data_type
return;
}
+ if(checkcmd(cmd, 4, (uint8_t*)"dest"))
+ {
+ uint8_t tmp[6] = {0};
+ uint8_t err = 0;
+ for(uint8_t i = 0; i < 7; i++)
+ {
+ if((cmd[5 + i] == '\r') || (cmd[5 + i] == '\n'))
+ {
+ if((i == 0))
+ err = 1;
+ break;
+ }
+ if(!(((cmd[5 + i] > 47) && (cmd[5 + i] < 58)) || ((cmd[5 + i] > 64) && (cmd[5 + i] < 91)))) //only alphanumeric characters
+ {
+ err = 1;
+ break;
+ }
+ if(i == 6) //address too long
+ {
+ err = 1;
+ break;
+ }
+ tmp[i] = cmd[5 + i] << 1;
+ }
+ if(!err)
+ for(uint8_t i = 0; i < 6; i++)
+ {
+ dest[i] = 64; //fill with spaces
+ if(tmp[i] != 0)
+ dest[i] = tmp[i];
+ }
+ if(err)
+ {
+ term_sendString((uint8_t*)"Incorrect address!\r\n", 0);
+ }
+ else
+ {
+ term_sendString((uint8_t*)"OK\r\n", 0);
+ }
+ term_sendBuf(src);
+ return;
+ }
+
if(checkcmd(cmd, 4, (uint8_t*)"ssid"))
{
uint8_t tmp[3] = {0};