1#if !defined(RADIOLIB_SSDV_H)
4#include "../../TypeDef.h"
6#if !RADIOLIB_EXCLUDE_SSDV
8#include "../PhysicalLayer/PhysicalLayer.h"
29#ifndef RADIOLIB_SSDV_MAX_PACKETS
30#define RADIOLIB_SSDV_MAX_PACKETS (512)
34#define RADIOLIB_SSDV_PACKET_LEN (256)
35#define RADIOLIB_SSDV_HEADER_LEN (15)
36#define RADIOLIB_SSDV_CRC_LEN (4)
37#define RADIOLIB_SSDV_RS_LEN (32)
38#define RADIOLIB_SSDV_PAYLOAD_LEN_FEC (RADIOLIB_SSDV_PACKET_LEN - RADIOLIB_SSDV_HEADER_LEN - RADIOLIB_SSDV_CRC_LEN - RADIOLIB_SSDV_RS_LEN)
39#define RADIOLIB_SSDV_PAYLOAD_LEN_NOFEC (RADIOLIB_SSDV_PACKET_LEN - RADIOLIB_SSDV_HEADER_LEN - RADIOLIB_SSDV_CRC_LEN)
42#define RADIOLIB_SSDV_SYNC_WORD (0x55)
43#define RADIOLIB_SSDV_TYPE_OFFSET (0x66)
44#define RADIOLIB_SSDV_TYPE_NORMAL (0x00)
45#define RADIOLIB_SSDV_TYPE_NOFEC (0x01)
46#define RADIOLIB_SSDV_TYPE_INVALID (0xFF)
47#define RADIOLIB_SSDV_MCU_NONE (0xFFFF)
50#define RADIOLIB_SSDV_CALLSIGN_MAX_LEN (6)
53#define RADIOLIB_SSDV_QUALITY_MAX (7)
58#define RADIOLIB_SSDV_EOI (1)
72 char callsign[RADIOLIB_SSDV_CALLSIGN_MAX_LEN + 1];
107#define RADIOLIB_SSDV_TBL_LEN (546)
108#define RADIOLIB_SSDV_HBUFF_LEN (16)
126 uint16_t packetMcuId;
127 uint8_t packetMcuOffset;
151 uint16_t markerDataLen;
163 uint32_t nextResetMcu;
167 uint8_t srcTbls[RADIOLIB_SSDV_TBL_LEN + RADIOLIB_SSDV_HBUFF_LEN];
168 uint8_t* srcDht[2][2];
171 uint8_t dstTbls[RADIOLIB_SSDV_TBL_LEN];
172 uint8_t* dstDht[2][2];
204 int16_t
begin(
const char* callsign);
220 int16_t
setImage(
const uint8_t* jpegData,
size_t jpegLen, uint8_t quality = 4, int16_t imageId = -1);
245 int16_t
transmit(uint16_t* packetId = NULL);
267 int16_t
read(uint8_t* packet);
276 static int16_t
isValidPacket(uint8_t* packet, int16_t* errors = NULL);
292 int16_t
beginDecoder(uint8_t* jpegBuf,
size_t jpegBufLen);
308 int16_t
getJpeg(uint8_t** jpegPtr,
size_t* jpegLen);
327 char callsign[RADIOLIB_SSDV_CALLSIGN_MAX_LEN + 1];
333 uint16_t packetCount;
334 uint16_t packetIndex;
346 int32_t encode(
const uint8_t* jpegData,
size_t jpegLen, uint8_t quality, uint8_t* dst, uint16_t maxPackets);
347 int16_t transmitPacket(uint8_t offset, uint16_t* packetId);
Provides common interface for protocols that run on LoRa/FSK modules, such as RTTY or LoRaWAN....
Definition PhysicalLayer.h:390
int16_t transmit(uint16_t *packetId=NULL)
Transmit the next packet, all 256 bytes including sync word. Intended for RTTY/FSK.
Definition SSDV.cpp:1200
int16_t begin(const char *callsign)
Initialization method.
Definition SSDV.cpp:1069
int16_t beginDecoder(uint8_t *jpegBuf, size_t jpegBufLen)
Initialize the JPEG decoder. A safe output buffer size is (number of packets) * (payload length) + 20...
Definition SSDV.cpp:1325
void endDecoder()
Detach the decoder from its output buffer. The buffer is owned by the caller and is not released.
Definition SSDV.cpp:1335
int16_t getJpeg(uint8_t **jpegPtr, size_t *jpegLen)
Get the reconstructed JPEG after feedPacket() returned RADIOLIB_SSDV_EOI.
Definition SSDV.cpp:1357
uint16_t currentPacketIndex()
Get the index of the next packet to be transmitted.
Definition SSDV.cpp:1196
static void parseHeader(const uint8_t *packet, SSDVPacketInfo_t *info)
Parse the header of a validated packet.
Definition SSDV.cpp:1302
int16_t feedPacket(const uint8_t *packet)
Feed a validated packet to the decoder. Packets must arrive in ascending order; missing packets are r...
Definition SSDV.cpp:1341
uint16_t numPackets()
Get the number of packets of the current image.
Definition SSDV.cpp:1188
void clearImage()
Discard the current image and release the packet buffer.
Definition SSDV.cpp:1230
~SSDVClient()
Destructor, releases the packet buffer and decoder state.
Definition SSDV.cpp:1065
static int16_t isValidPacket(uint8_t *packet, int16_t *errors=NULL)
Validate a packet by its CRC. If that fails, Reed-Solomon correction is attempted (up to 16 symbol er...
Definition SSDV.cpp:1261
int16_t read(uint8_t *packet)
Read a received packet from the radio. The packet is not validated, call isValidPacket() on it.
Definition SSDV.cpp:1244
int16_t resetDecoder()
Reset the decoder to receive a new image into the same output buffer.
Definition SSDV.cpp:1388
int16_t transmitLoRa(uint16_t *packetId=NULL)
Transmit the next packet without the sync word (255 bytes), to fit the LoRa payload limit.
Definition SSDV.cpp:1204
int16_t setImage(const uint8_t *jpegData, size_t jpegLen, uint8_t quality=4, int16_t imageId=-1)
Encode a JPEG image into SSDV packets. Any previously loaded image is discarded. The packets are stor...
Definition SSDV.cpp:1142
bool isDone()
Check whether all packets of the current image have been sent.
Definition SSDV.cpp:1192
SSDVClient(PhysicalLayer *phy, bool fec=true)
Default constructor.
Definition SSDV.cpp:1055
Header fields of an SSDV packet, filled by SSDVClient::parseHeader.
Definition SSDV.h:64
uint16_t width
Image width in pixels.
Definition SSDV.h:81
uint8_t mcuOffset
Offset of the first MCU in the payload.
Definition SSDV.h:96
uint8_t type
Packet type, RADIOLIB_SSDV_TYPE_NORMAL or RADIOLIB_SSDV_TYPE_NOFEC.
Definition SSDV.h:66
uint32_t callsignCode
Base-40 encoded callsign.
Definition SSDV.h:69
uint16_t mcuCount
Total number of MCU blocks in the image.
Definition SSDV.h:102
char callsign[RADIOLIB_SSDV_CALLSIGN_MAX_LEN+1]
Decoded, null-terminated callsign.
Definition SSDV.h:72
uint16_t height
Image height in pixels.
Definition SSDV.h:84
uint16_t mcuId
Index of the first MCU in this packet, RADIOLIB_SSDV_MCU_NONE if no MCU starts here.
Definition SSDV.h:99
uint16_t packetId
Packet ID, starting from 0.
Definition SSDV.h:78
uint8_t imageId
Image ID.
Definition SSDV.h:75
uint8_t quality
Quality level, 0 - 7.
Definition SSDV.h:90
uint8_t mcuMode
Chroma subsampling mode: 0 = 2x2, 1 = 1x2, 2 = 2x1, 3 = 1x1.
Definition SSDV.h:93
bool eoi
Whether this is the last packet of the image.
Definition SSDV.h:87