KISS monitoring

pull/8/head
Piotr Wilkon 2022-08-29 13:00:28 +02:00
rodzic 61acd3a890
commit 9f24211518
8 zmienionych plików z 96 dodań i 37 usunięć

Wyświetl plik

@ -31,6 +31,7 @@ const uint8_t *versionString; //version string
uint8_t autoReset;
uint32_t autoResetTimer;
uint8_t kissMonitor;
/**
* @brief Generate random number from min to max
@ -65,4 +66,11 @@ void common_toTNC2(uint8_t *from, uint16_t fromlen, uint8_t *to);
*/
uint32_t crc32(uint32_t crc0, uint8_t *s, uint64_t n);
/**
* @brief Send frame to available UARTs and USB in KISS format
* @param[in] *buf Frame buffer
* @param[in] len Frame buffer length
*/
void SendKiss(uint8_t *buf, uint16_t len);
#endif /* COMMON_H_ */

Wyświetl plik

@ -85,7 +85,8 @@ along with VP-Digi. If not, see <http://www.gnu.org/licenses/>.
#define CONFIG_DIGISSID6 1212
#define CONFIG_DIGISSID7 1214
#define CONFIG_PWM_FLAT 1216
#define CONFIG_XXX 1218 //next address (not used)
#define CONFIG_KISSMONITOR 1218
#define CONFIG_XXX 1220 //next address (not used)
/**
* @brief Store configuration from RAM to Flash

Wyświetl plik

@ -81,6 +81,9 @@ void Beacon_send(uint8_t no)
ax25.frameXmit[ax25.xmitIdx++] = buf[i]; //copy frame to main TX buffer
}
if(kissMonitor) //monitoring mode, send own frames to KISS ports
SendKiss(ax25.frameXmit, ax25.xmitIdx);
ax25.frameXmit[ax25.xmitIdx++] = 0xFF; //frame separator
Digi_storeDeDupeFromXmitBuf(frameStart); //store frame hash in duplicate protection buffer (to prevent from digipeating own packets)

Wyświetl plik

@ -19,16 +19,19 @@ along with VP-Digi. If not, see <http://www.gnu.org/licenses/>.
#include "ax25.h"
#include <math.h>
#include <stdlib.h>
#include "drivers/uart.h"
#include "usbd_cdc_if.h"
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
const uint8_t *versionString = (const uint8_t*)"VP-Digi v. 1.2.3\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.4\r\nThe open-source standalone APRS digipeater controller and KISS TNC\r\n";
uint8_t autoReset = 0;
uint32_t autoResetTimer = 0;
uint8_t kissMonitor = 0;
int64_t strToInt(uint8_t *str, uint8_t len)
@ -181,3 +184,39 @@ uint32_t crc32(uint32_t crc0, uint8_t *s, uint64_t n)
return ~crc;
}
void SendKiss(uint8_t *buf, uint16_t len)
{
Uart *u = &uart1;
for(uint8_t i = 0; i < 2; i++)
{
if(u->mode == MODE_KISS) //check if KISS mode
{
uart_sendByte(u, 0xc0); //send data in kiss format
uart_sendByte(u, 0x00);
for(uint16_t j = 0; j < len; j++)
{
uart_sendByte(u, buf[j]);
}
uart_sendByte(u, 0xc0);
uart_transmitStart(u);
}
u = &uart2;
}
if(USBmode == MODE_KISS) //check if USB in KISS mode
{
uint8_t t[2] = {0xc0, 0};
CDC_Transmit_FS(&t[0], 1);
CDC_Transmit_FS(&t[1], 1);
for(uint16_t i = 0; i < len; i++)
{
CDC_Transmit_FS(&buf[i], 1);
}
CDC_Transmit_FS(&t[0], 1);
}
}

Wyświetl plik

@ -189,6 +189,7 @@ void Config_write(void)
flash_writeString(CONFIG_DIGIFILLIST, digi.callFilter[0], 140);
flash_write(CONFIG_AUTORST, autoReset);
flash_write(CONFIG_PWM_FLAT, afskCfg.usePWM | (afskCfg.flatAudioIn << 1));
flash_write(CONFIG_KISSMONITOR, kissMonitor);
flash_write(CONFIG_FLAG, FLAG_CONFIG_WRITTEN);
@ -273,6 +274,7 @@ uint8_t Config_read(void)
t = (uint8_t)flash_read(CONFIG_PWM_FLAT);
afskCfg.usePWM = t & 1;
afskCfg.flatAudioIn = (t & 2) > 0;
kissMonitor = (flash_read(CONFIG_KISSMONITOR) == 1);
return 1;
}

Wyświetl plik

@ -84,6 +84,11 @@ void Digi_viscousRefresh(void)
ax25.frameXmit[ax25.xmitIdx] = 0xFF;
ax25.xmitIdx++;
if(kissMonitor) //monitoring mode, send own frames to KISS ports
{
SendKiss(ax25.frameXmit, ax25.xmitIdx - 1);
}
uint8_t buf[200];
common_toTNC2((uint8_t*)&ax25.frameXmit[begin], ax25.xmitIdx - begin - 1, buf);
@ -308,6 +313,11 @@ static void makeFrame(uint8_t *frame, uint16_t elStart, uint16_t len, uint32_t h
}
ax25.frameXmit[ax25.xmitIdx++] = 0xFF;
if(kissMonitor) //monitoring mode, send own frames to KISS ports
{
SendKiss(ax25.frameXmit, ax25.xmitIdx - 1);
}
common_toTNC2((uint8_t *)&ax25.frameXmit[begin], ax25.xmitIdx - begin - 1, buf);
term_sendMonitor((uint8_t*)"(AX.25) Digipeating frame: ", 0);
term_sendMonitor(buf, 0);

Wyświetl plik

@ -93,7 +93,7 @@ void handleFrame(void)
uint8_t modemReceived = ax25.frameReceived; //store states
ax25.frameReceived = 0; //clear flag
uint8_t bufto[FRAMELEN + 30], buf[FRAMELEN]; //bufory dla konwersji ramki z formatu APRS do TNC2
uint8_t bufto[FRAMELEN + 30], buf[FRAMELEN]; //buffer for raw frames to TNC2 frames conversion
uint16_t bufidx = 0;
uint16_t i = ax25.frameBufRd;
@ -119,38 +119,7 @@ void handleFrame(void)
}
Uart *u = &uart1;
for(uint8_t i = 0; i < 2; i++)
{
if(u->mode == MODE_KISS) //check if KISS mode
{
uart_sendByte(u, 0xc0); //send data in kiss format
uart_sendByte(u, 0x00);
for(uint16_t j = 0; j < (bufidx); j++)
{
uart_sendByte(u, buf[j]);
}
uart_sendByte(u, 0xc0);
uart_transmitStart(u);
}
u = &uart2;
}
if(USBmode == MODE_KISS) //check if USB in KISS mode
{
uint8_t t[2] = {0xc0, 0};
CDC_Transmit_FS(&t[0], 1);
CDC_Transmit_FS(&t[1], 1);
for(uint16_t i = 0; i < (bufidx); i++)
{
CDC_Transmit_FS(&buf[i], 1);
}
CDC_Transmit_FS(&t[0], 1);
}
SendKiss(buf, bufidx); //send KISS frames if ports available
if(((USBmode == MODE_MONITOR) || (uart1.mode == MODE_MONITOR) || (uart2.mode == MODE_MONITOR)))

Wyświetl plik

@ -487,6 +487,7 @@ void term_parse(uint8_t *cmd, uint16_t len, Terminal_stream src, Uart_data_type
term_sendBuf(src);
term_sendString((uint8_t*)"digi list <0-19> [set <call>/remove] - sets/clears specified callsign slot in filter list\r\n", 0);
term_sendString((uint8_t*)"autoreset <0-255> - sets auto-reset interval (h) - 0 to disable\r\n", 0);
term_sendString((uint8_t*)"kissmon [on/off] - send own and digipeated frames to KISS ports\r\n", 0);
term_sendBuf(src);
return;
}
@ -683,7 +684,11 @@ void term_parse(uint8_t *cmd, uint16_t len, Terminal_stream src, Uart_data_type
term_sendString((uint8_t*)"disabled\r\n", 0);
else
term_sendNumber(autoReset);
term_sendString((uint8_t*)"\r\n", 0);
term_sendString((uint8_t*)"\r\nKISS monitor: ", 0);
if(kissMonitor == 1)
term_sendString((uint8_t*)"On\r\n", 0);
else
term_sendString((uint8_t*)"Off\r\n", 0);
term_sendBuf(src);
return;
}
@ -1593,7 +1598,6 @@ void term_parse(uint8_t *cmd, uint16_t len, Terminal_stream src, Uart_data_type
term_sendBuf(src);
return;
}
else err = 1;
if(err == 1)
@ -1606,6 +1610,7 @@ void term_parse(uint8_t *cmd, uint16_t len, Terminal_stream src, Uart_data_type
return;
}
if(checkcmd(cmd, 10, (uint8_t*)"autoreset "))
{
uint8_t tmp[4] = {0};
@ -1693,6 +1698,28 @@ void term_parse(uint8_t *cmd, uint16_t len, Terminal_stream src, Uart_data_type
return;
}
if(checkcmd(cmd, 8, (uint8_t*)"kissmon "))
{
uint8_t err = 0;
if(checkcmd(&cmd[8], 2, (uint8_t*)"on"))
kissMonitor = 1;
else if(checkcmd(&cmd[8], 3, (uint8_t*)"off"))
kissMonitor = 0;
else
err = 1;
if(err)
{
term_sendString((uint8_t*)"Incorrect command!\r\n", 0);
}
else
{
term_sendString((uint8_t*)"OK\r\n", 0);
}
term_sendBuf(src);
return;
}
term_sendString((uint8_t*)"Unknown command. For command list type \"help\"\r\n", 0);
term_sendBuf(src);