Skip to content

Commit b27fde7

Browse files
authored
Merge pull request #25 from sq8vps/dev
v. 1.3.0
2 parents 7ea31b5 + 70f2805 commit b27fde7

29 files changed

+2337
-3137
lines changed

CHANGELOG.md

+21-9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
# 1.3.0 (2023-08-30)
2+
## New features
3+
* Callsign is now set together with SSID using ```call <call-SSID>```
4+
* ```time``` command to show uptime
5+
## Removed features
6+
* ```ssid``` command is removed
7+
* Auto-reset functionality and ```autoreset``` command is removed
8+
## Bug fixes
9+
* When beacon *n* delay hadn't passed yet, beacon *n+1*, *n+2*, ... were not sent regardless of their delay
10+
* Bugs with line ending parsing
11+
## Other
12+
* Major code refactoring and rewrite
13+
* Got rid of *uart_transmitStart()* routine
14+
* USB sending is handled the same way as UART
15+
* New way of TX and RX frame handling to improve non-APRS compatibility
16+
* Much bigger frame buffer
17+
* Minimized number of temporary buffers
18+
* All *malloc()*s removed
19+
* Added copyright notice as required by GNU GPL
20+
## Known bugs
21+
* none
122
# 1.2.6 (2023-07-29)
223
## New features
324
* Added ```nonaprs [on/off]``` command that enables reception of non-APRS frames, e.g. for full Packet Radio use
@@ -43,15 +64,6 @@
4364
* none
4465
## Known bugs
4566
* USB in KISS mode has problem with TX frames
46-
# 1.2.2 (2022-06-11)
47-
## New features
48-
* none
49-
## Bug fixes
50-
* Default de-dupe time was 0, backspace was sometimes stored in config, frame length was not checked in viscous delay mode
51-
## Other
52-
* none
53-
## Known bugs
54-
* USB in KISS mode has problem with TX frames
5567
# 1.2.1 (2021-10-13)
5668
## New features
5769
* none

Inc/ax25.h

+47-27
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/*
2+
Copyright 2020-2023 Piotr Wilkon
3+
24
This file is part of VP-Digi.
35
46
VP-Digi is free software: you can redistribute it and/or modify
@@ -18,54 +20,72 @@ along with VP-Digi. If not, see <http://www.gnu.org/licenses/>.
1820
#ifndef AX25_H_
1921
#define AX25_H_
2022

21-
#define FRAMELEN (150) //single frame max length
22-
#define FRAMEBUFLEN (600) //circural frame buffer (multiple frames) length
23-
23+
#include <stdint.h>
24+
#include <stdbool.h>
2425

2526

26-
#include <stdint.h>
2727

2828

29-
typedef enum
29+
enum Ax25RxStage
3030
{
31-
RX_STAGE_IDLE,
31+
RX_STAGE_IDLE = 0,
3232
RX_STAGE_FLAG,
3333
RX_STAGE_FRAME,
34-
} RxStage;
34+
};
3535

36-
typedef struct
36+
struct Ax25ProtoConfig
3737
{
3838
uint16_t txDelayLength; //TXDelay length in ms
3939
uint16_t txTailLength; //TXTail length in ms
4040
uint16_t quietTime; //Quiet time in ms
4141
uint8_t allowNonAprs; //allow non-APRS packets
42+
};
4243

43-
} Ax25_config;
44+
extern struct Ax25ProtoConfig Ax25Config;
4445

45-
Ax25_config ax25Cfg;
46+
/**
47+
* @brief Transmit one or more frames encoded in KISS format
48+
* @param *buf Inout buffer
49+
* @param len Buffer size
50+
*/
51+
void Ax25TxKiss(uint8_t *buf, uint16_t len);
4652

53+
/**
54+
* @brief Write frame to transmit buffer
55+
* @param *data Data to transmit
56+
* @param size Data size
57+
* @return Pointer to internal frame handle or NULL on failure
58+
* @attention This function will block if transmission is already in progress
59+
*/
60+
void *Ax25WriteTxFrame(uint8_t *data, uint16_t size);
4761

48-
typedef struct
49-
{
50-
uint8_t frameBuf[FRAMEBUFLEN]; //cirucal buffer for received frames, frames are separated with 0xFF
51-
uint16_t frameBufWr; //cirucal RX buffer write index
52-
uint16_t frameBufRd; //circural TX buffer read index
53-
uint8_t frameXmit[FRAMEBUFLEN]; //TX frame buffer
54-
uint16_t xmitIdx; //TX frame buffer index
55-
uint16_t sLvl; //RMS of the frame
56-
uint8_t frameReceived; //frame received flag, must be polled in main loop for >0. Bit 0 for frame received on decoder 1, bit 1 for decoder 2
62+
/**
63+
* @brief Get bitmap of "frame received" flags for each decoder. A non-zero value means that a frame was received
64+
* @return Bitmap of decoder that received the frame
65+
*/
66+
uint8_t Ax25GetReceivedFrameBitmap(void);
5767

58-
} Ax25;
68+
/**
69+
* @brief Clear bitmap of "frame received" flags
70+
*/
71+
void Ax25ClearReceivedFrameBitmap(void);
5972

60-
Ax25 ax25;
73+
/**
74+
* @brief Get next received frame (if available)
75+
* @param **dst Pointer to internal buffer
76+
* @param *size Actual frame size
77+
* @param *signalLevel Frame signal level (RMS)
78+
* @return True if frame was read, false if no more frames to read
79+
*/
80+
bool Ax25ReadNextRxFrame(uint8_t **dst, uint16_t *size, uint16_t *signalLevel);
6181

6282
/**
6383
* @brief Get current RX stage
6484
* @param[in] modemNo Modem/decoder number (0 or 1)
6585
* @return RX_STATE_IDLE, RX_STATE_FLAG or RX_STATE_FRAME
6686
* @warning Only for internal use
6787
*/
68-
RxStage Ax25_getRxStage(uint8_t modemNo);
88+
enum Ax25RxStage Ax25GetRxStage(uint8_t modemNo);
6989

7090
/**
7191
* @brief Parse incoming bit (not symbol!)
@@ -74,29 +94,29 @@ RxStage Ax25_getRxStage(uint8_t modemNo);
7494
* @param[in] *dem Modem state pointer
7595
* @warning Only for internal use
7696
*/
77-
void Ax25_bitParse(uint8_t bit, uint8_t modemNo);
97+
void Ax25BitParse(uint8_t bit, uint8_t modemNo);
7898

7999
/**
80100
* @brief Get next bit to be transmitted
81101
* @return Bit to be transmitted
82102
* @warning Only for internal use
83103
*/
84-
uint8_t Ax25_getTxBit(void);
104+
uint8_t Ax25GetTxBit(void);
85105

86106
/**
87107
* @brief Initialize transmission and start when possible
88108
*/
89-
void Ax25_transmitBuffer(void);
109+
void Ax25TransmitBuffer(void);
90110

91111
/**
92112
* @brief Start transmitting when possible
93113
* @attention Must be continuously polled in main loop
94114
*/
95-
void Ax25_transmitCheck(void);
115+
void Ax25TransmitCheck(void);
96116

97117
/**
98118
* @brief Initialize AX25 module
99119
*/
100-
void Ax25_init(void);
120+
void Ax25Init(void);
101121

102122
#endif /* AX25_H_ */

Inc/beacon.h

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/*
2+
Copyright 2020-2023 Piotr Wilkon
3+
24
This file is part of VP-Digi.
35
46
VP-Digi is free software: you can redistribute it and/or modify
@@ -21,35 +23,35 @@ along with VP-Digi. If not, see <http://www.gnu.org/licenses/>.
2123

2224
#include <stdint.h>
2325

26+
#define BEACON_MAX_PAYLOAD_SIZE 100
2427

25-
26-
typedef struct
28+
struct Beacon
2729
{
2830
uint8_t enable; //enable beacon
2931
uint32_t interval; //interval in seconds
3032
uint32_t delay; //delay in seconds
31-
uint8_t data[101]; //information field
33+
uint8_t data[BEACON_MAX_PAYLOAD_SIZE + 1]; //information field
3234
uint8_t path[15]; //path, 2 parts max, e.g. WIDE1<sp>1SP2<sp><sp><sp>2<NUL>, <NUL> can be at byte 0, 7 and 14
3335
uint32_t next; //next beacon timestamp
34-
} Beacon;
36+
};
3537

36-
Beacon beacon[8];
38+
extern struct Beacon beacon[8];
3739

3840
/**
3941
* @brief Send specified beacon
40-
* @param[in] no Beacon number (0-7)
42+
* @param number Beacon number (0-7)
4143
*/
42-
void Beacon_send(uint8_t no);
44+
void BeaconSend(uint8_t number);
4345

4446

4547
/**
46-
* @brief Check if any beacon should be transmitted and transmit if neccessary
48+
* @brief Check if any beacon should be transmitted and transmit if necessary
4749
*/
48-
void Beacon_check(void);
50+
void BeaconCheck(void);
4951

5052
/**
5153
* @brief Initialize beacon module
5254
*/
53-
void Beacon_init(void);
55+
void BeaconInit(void);
5456

5557
#endif /* BEACON_H_ */

Inc/common.h

+56-19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/*
2+
Copyright 2020-2023 Piotr Wilkon
3+
24
This file is part of VP-Digi.
35
46
VP-Digi is free software: you can redistribute it and/or modify
@@ -14,48 +16,62 @@ GNU General Public License for more details.
1416
You should have received a copy of the GNU General Public License
1517
along with VP-Digi. If not, see <http://www.gnu.org/licenses/>.
1618
*/
19+
1720
#ifndef COMMON_H_
1821
#define COMMON_H_
1922

2023
#include <stdint.h>
24+
#include "drivers/uart.h"
2125

26+
#define IS_UPPERCASE_ALPHANUMERIC(x) ((((x) >= '0') && ((x) <= '9')) || (((x) >= 'A') && ((x) <= 'Z')))
27+
#define IS_NUMBER(x) (((x) >= '0') && ((x) <= '9'))
2228

2329
#define CRC32_INIT 0xFFFFFFFF
2430

25-
uint8_t call[6]; //device callsign
26-
uint8_t callSsid; //device ssid
31+
struct _GeneralConfig
32+
{
33+
uint8_t call[6]; //device callsign
34+
uint8_t callSsid; //device ssid
35+
uint8_t dest[7]; //destination address for own beacons. Should be APNV01-0 for VP-Digi, but can be changed. SSID MUST remain 0.
36+
uint8_t kissMonitor;
37+
};
2738

28-
uint8_t dest[7]; //destination address for own beacons. Should be APNV01-0 for VP-Digi, but can be changed. SSID MUST remain 0.
39+
extern struct _GeneralConfig GeneralConfig;
2940

30-
const uint8_t *versionString; //version string
41+
extern const char versionString[]; //version string
3142

32-
uint8_t autoReset;
33-
uint32_t autoResetTimer;
34-
uint8_t kissMonitor;
3543

3644
/**
3745
* @brief Generate random number from min to max
3846
* @param[in] min Lower boundary
3947
* @param[in] max Higher boundary
4048
* @return Generated number
4149
*/
42-
int16_t rando(int16_t min, int16_t max);
50+
int16_t Random(int16_t min, int16_t max);
4351

4452
/**
4553
* @brief Convert string to int
4654
* @param[in] *str Input string
4755
* @param[in] len String length or 0 to detect by strlen()
4856
* @return Converted int
4957
*/
50-
int64_t strToInt(uint8_t *str, uint8_t len);
58+
int64_t StrToInt(const char *str, uint16_t len);
59+
60+
///**
61+
// * @brief Convert AX25 frame to TNC2 (readable) format
62+
// * @param *from Input AX25 frame
63+
// * @param len Input frame length
64+
// * @param *to Destination buffer, will be NULL terminated
65+
// * @param limit Destination buffer size limit
66+
// */
67+
//void ConvertToTNC2(uint8_t *from, uint16_t fromlen, uint8_t *to, uint16_t limit);
5168

5269
/**
53-
* @brief Convert AX25 frame to TNC2 (readable) format
54-
* @param[in] *from Input AX25 frame
55-
* @param[in] len Input frame length
56-
* @param[out] *to Destination buffer, will be NULL terminated
70+
* @brief Convert AX25 frame to TNC2 (readable) format and send it through available ports
71+
* @param *from Input AX25 frame
72+
* @param len Input frame length
5773
*/
58-
void common_toTNC2(uint8_t *from, uint16_t fromlen, uint8_t *to);
74+
void SendTNC2(uint8_t *from, uint16_t len);
5975

6076
/**
6177
* @brief Calculate CRC32
@@ -64,13 +80,34 @@ void common_toTNC2(uint8_t *from, uint16_t fromlen, uint8_t *to);
6480
* @param[in] n Input data length
6581
* @return Calculated CRC32
6682
*/
67-
uint32_t crc32(uint32_t crc0, uint8_t *s, uint64_t n);
83+
uint32_t Crc32(uint32_t crc0, uint8_t *s, uint64_t n);
84+
85+
/**
86+
* @brief Check if callsign is correct and convert it to AX.25 format
87+
* @param *in Input ASCII callsign
88+
* @param size Input size, not bigger than 6
89+
* @param *out Output buffer, exactly 6 bytes
90+
* @return True if callsign is valid
91+
*/
92+
bool ParseCallsign(const char *in, uint16_t size, uint8_t *out);
93+
94+
/**
95+
* @brief Check if callsign with SSID is correct and convert it to AX.25 format
96+
* @param *in Input ASCII callsign with SSID
97+
* @param size Input size
98+
* @param *out Output buffer, exactly 6 bytes
99+
* @param *ssid Output SSID, exactly 1 byte
100+
* @return True if callsign is valid
101+
*/
102+
bool ParseCallsignWithSsid(const char *in, uint16_t size, uint8_t *out, uint8_t *ssid);
68103

69104
/**
70-
* @brief Send frame to available UARTs and USB in KISS format
71-
* @param[in] *buf Frame buffer
72-
* @param[in] len Frame buffer length
105+
* @brief Check if SSID is correct and convert it to uint8_t
106+
* @param *in Input ASCII SSID
107+
* @param size Input size
108+
* @param *out Output buffer, exactly 1 byte
109+
* @return True if SSID is valid
73110
*/
74-
void SendKiss(uint8_t *buf, uint16_t len);
111+
bool ParseSsid(const char *in, uint16_t size, uint8_t *out);
75112

76113
#endif /* COMMON_H_ */

0 commit comments

Comments
 (0)