Skip to content

Commit

Permalink
Merge pull request #25 from sq8vps/dev
Browse files Browse the repository at this point in the history
v. 1.3.0
  • Loading branch information
sq8vps authored Aug 30, 2023
2 parents 7ea31b5 + 70f2805 commit b27fde7
Show file tree
Hide file tree
Showing 29 changed files with 2,337 additions and 3,137 deletions.
30 changes: 21 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# 1.3.0 (2023-08-30)
## New features
* Callsign is now set together with SSID using ```call <call-SSID>```
* ```time``` command to show uptime
## Removed features
* ```ssid``` command is removed
* Auto-reset functionality and ```autoreset``` command is removed
## Bug fixes
* When beacon *n* delay hadn't passed yet, beacon *n+1*, *n+2*, ... were not sent regardless of their delay
* Bugs with line ending parsing
## Other
* Major code refactoring and rewrite
* Got rid of *uart_transmitStart()* routine
* USB sending is handled the same way as UART
* New way of TX and RX frame handling to improve non-APRS compatibility
* Much bigger frame buffer
* Minimized number of temporary buffers
* All *malloc()*s removed
* Added copyright notice as required by GNU GPL
## Known bugs
* none
# 1.2.6 (2023-07-29)
## New features
* Added ```nonaprs [on/off]``` command that enables reception of non-APRS frames, e.g. for full Packet Radio use
Expand Down Expand Up @@ -43,15 +64,6 @@
* none
## Known bugs
* USB in KISS mode has problem with TX frames
# 1.2.2 (2022-06-11)
## New features
* none
## Bug fixes
* Default de-dupe time was 0, backspace was sometimes stored in config, frame length was not checked in viscous delay mode
## Other
* none
## Known bugs
* USB in KISS mode has problem with TX frames
# 1.2.1 (2021-10-13)
## New features
* none
Expand Down
74 changes: 47 additions & 27 deletions Inc/ax25.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
Copyright 2020-2023 Piotr Wilkon
This file is part of VP-Digi.
VP-Digi is free software: you can redistribute it and/or modify
Expand All @@ -18,54 +20,72 @@ along with VP-Digi. If not, see <http://www.gnu.org/licenses/>.
#ifndef AX25_H_
#define AX25_H_

#define FRAMELEN (150) //single frame max length
#define FRAMEBUFLEN (600) //circural frame buffer (multiple frames) length

#include <stdint.h>
#include <stdbool.h>


#include <stdint.h>


typedef enum
enum Ax25RxStage
{
RX_STAGE_IDLE,
RX_STAGE_IDLE = 0,
RX_STAGE_FLAG,
RX_STAGE_FRAME,
} RxStage;
};

typedef struct
struct Ax25ProtoConfig
{
uint16_t txDelayLength; //TXDelay length in ms
uint16_t txTailLength; //TXTail length in ms
uint16_t quietTime; //Quiet time in ms
uint8_t allowNonAprs; //allow non-APRS packets
};

} Ax25_config;
extern struct Ax25ProtoConfig Ax25Config;

Ax25_config ax25Cfg;
/**
* @brief Transmit one or more frames encoded in KISS format
* @param *buf Inout buffer
* @param len Buffer size
*/
void Ax25TxKiss(uint8_t *buf, uint16_t len);

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

typedef struct
{
uint8_t frameBuf[FRAMEBUFLEN]; //cirucal buffer for received frames, frames are separated with 0xFF
uint16_t frameBufWr; //cirucal RX buffer write index
uint16_t frameBufRd; //circural TX buffer read index
uint8_t frameXmit[FRAMEBUFLEN]; //TX frame buffer
uint16_t xmitIdx; //TX frame buffer index
uint16_t sLvl; //RMS of the frame
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
/**
* @brief Get bitmap of "frame received" flags for each decoder. A non-zero value means that a frame was received
* @return Bitmap of decoder that received the frame
*/
uint8_t Ax25GetReceivedFrameBitmap(void);

} Ax25;
/**
* @brief Clear bitmap of "frame received" flags
*/
void Ax25ClearReceivedFrameBitmap(void);

Ax25 ax25;
/**
* @brief Get next received frame (if available)
* @param **dst Pointer to internal buffer
* @param *size Actual frame size
* @param *signalLevel Frame signal level (RMS)
* @return True if frame was read, false if no more frames to read
*/
bool Ax25ReadNextRxFrame(uint8_t **dst, uint16_t *size, uint16_t *signalLevel);

/**
* @brief Get current RX stage
* @param[in] modemNo Modem/decoder number (0 or 1)
* @return RX_STATE_IDLE, RX_STATE_FLAG or RX_STATE_FRAME
* @warning Only for internal use
*/
RxStage Ax25_getRxStage(uint8_t modemNo);
enum Ax25RxStage Ax25GetRxStage(uint8_t modemNo);

/**
* @brief Parse incoming bit (not symbol!)
Expand All @@ -74,29 +94,29 @@ RxStage Ax25_getRxStage(uint8_t modemNo);
* @param[in] *dem Modem state pointer
* @warning Only for internal use
*/
void Ax25_bitParse(uint8_t bit, uint8_t modemNo);
void Ax25BitParse(uint8_t bit, uint8_t modemNo);

/**
* @brief Get next bit to be transmitted
* @return Bit to be transmitted
* @warning Only for internal use
*/
uint8_t Ax25_getTxBit(void);
uint8_t Ax25GetTxBit(void);

/**
* @brief Initialize transmission and start when possible
*/
void Ax25_transmitBuffer(void);
void Ax25TransmitBuffer(void);

/**
* @brief Start transmitting when possible
* @attention Must be continuously polled in main loop
*/
void Ax25_transmitCheck(void);
void Ax25TransmitCheck(void);

/**
* @brief Initialize AX25 module
*/
void Ax25_init(void);
void Ax25Init(void);

#endif /* AX25_H_ */
22 changes: 12 additions & 10 deletions Inc/beacon.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
Copyright 2020-2023 Piotr Wilkon
This file is part of VP-Digi.
VP-Digi is free software: you can redistribute it and/or modify
Expand All @@ -21,35 +23,35 @@ along with VP-Digi. If not, see <http://www.gnu.org/licenses/>.

#include <stdint.h>

#define BEACON_MAX_PAYLOAD_SIZE 100


typedef struct
struct Beacon
{
uint8_t enable; //enable beacon
uint32_t interval; //interval in seconds
uint32_t delay; //delay in seconds
uint8_t data[101]; //information field
uint8_t data[BEACON_MAX_PAYLOAD_SIZE + 1]; //information field
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
uint32_t next; //next beacon timestamp
} Beacon;
};

Beacon beacon[8];
extern struct Beacon beacon[8];

/**
* @brief Send specified beacon
* @param[in] no Beacon number (0-7)
* @param number Beacon number (0-7)
*/
void Beacon_send(uint8_t no);
void BeaconSend(uint8_t number);


/**
* @brief Check if any beacon should be transmitted and transmit if neccessary
* @brief Check if any beacon should be transmitted and transmit if necessary
*/
void Beacon_check(void);
void BeaconCheck(void);

/**
* @brief Initialize beacon module
*/
void Beacon_init(void);
void BeaconInit(void);

#endif /* BEACON_H_ */
75 changes: 56 additions & 19 deletions Inc/common.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
Copyright 2020-2023 Piotr Wilkon
This file is part of VP-Digi.
VP-Digi is free software: you can redistribute it and/or modify
Expand All @@ -14,48 +16,62 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with VP-Digi. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef COMMON_H_
#define COMMON_H_

#include <stdint.h>
#include "drivers/uart.h"

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

#define CRC32_INIT 0xFFFFFFFF

uint8_t call[6]; //device callsign
uint8_t callSsid; //device ssid
struct _GeneralConfig
{
uint8_t call[6]; //device callsign
uint8_t callSsid; //device ssid
uint8_t dest[7]; //destination address for own beacons. Should be APNV01-0 for VP-Digi, but can be changed. SSID MUST remain 0.
uint8_t kissMonitor;
};

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

const uint8_t *versionString; //version string
extern const char versionString[]; //version string

uint8_t autoReset;
uint32_t autoResetTimer;
uint8_t kissMonitor;

/**
* @brief Generate random number from min to max
* @param[in] min Lower boundary
* @param[in] max Higher boundary
* @return Generated number
*/
int16_t rando(int16_t min, int16_t max);
int16_t Random(int16_t min, int16_t max);

/**
* @brief Convert string to int
* @param[in] *str Input string
* @param[in] len String length or 0 to detect by strlen()
* @return Converted int
*/
int64_t strToInt(uint8_t *str, uint8_t len);
int64_t StrToInt(const char *str, uint16_t len);

///**
// * @brief Convert AX25 frame to TNC2 (readable) format
// * @param *from Input AX25 frame
// * @param len Input frame length
// * @param *to Destination buffer, will be NULL terminated
// * @param limit Destination buffer size limit
// */
//void ConvertToTNC2(uint8_t *from, uint16_t fromlen, uint8_t *to, uint16_t limit);

/**
* @brief Convert AX25 frame to TNC2 (readable) format
* @param[in] *from Input AX25 frame
* @param[in] len Input frame length
* @param[out] *to Destination buffer, will be NULL terminated
* @brief Convert AX25 frame to TNC2 (readable) format and send it through available ports
* @param *from Input AX25 frame
* @param len Input frame length
*/
void common_toTNC2(uint8_t *from, uint16_t fromlen, uint8_t *to);
void SendTNC2(uint8_t *from, uint16_t len);

/**
* @brief Calculate CRC32
Expand All @@ -64,13 +80,34 @@ void common_toTNC2(uint8_t *from, uint16_t fromlen, uint8_t *to);
* @param[in] n Input data length
* @return Calculated CRC32
*/
uint32_t crc32(uint32_t crc0, uint8_t *s, uint64_t n);
uint32_t Crc32(uint32_t crc0, uint8_t *s, uint64_t n);

/**
* @brief Check if callsign is correct and convert it to AX.25 format
* @param *in Input ASCII callsign
* @param size Input size, not bigger than 6
* @param *out Output buffer, exactly 6 bytes
* @return True if callsign is valid
*/
bool ParseCallsign(const char *in, uint16_t size, uint8_t *out);

/**
* @brief Check if callsign with SSID is correct and convert it to AX.25 format
* @param *in Input ASCII callsign with SSID
* @param size Input size
* @param *out Output buffer, exactly 6 bytes
* @param *ssid Output SSID, exactly 1 byte
* @return True if callsign is valid
*/
bool ParseCallsignWithSsid(const char *in, uint16_t size, uint8_t *out, uint8_t *ssid);

/**
* @brief Send frame to available UARTs and USB in KISS format
* @param[in] *buf Frame buffer
* @param[in] len Frame buffer length
* @brief Check if SSID is correct and convert it to uint8_t
* @param *in Input ASCII SSID
* @param size Input size
* @param *out Output buffer, exactly 1 byte
* @return True if SSID is valid
*/
void SendKiss(uint8_t *buf, uint16_t len);
bool ParseSsid(const char *in, uint16_t size, uint8_t *out);

#endif /* COMMON_H_ */
Loading

0 comments on commit b27fde7

Please sign in to comment.