Ymodem ESP32 1.0.0
Loading...
Searching...
No Matches
YmodemReceive.h File Reference

Ymodem Packet reception functions. More...

#include "YmodemUtils.h"
+ Include dependency graph for YmodemReceive.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int processDataPacket (uint8_t *packet_data, int packet_length, fs::File &ffd, unsigned int file_size, unsigned int *errors)
 Processes a data packet received via Ymodem protocol.
 
void handleEOFPacket (unsigned int *file_done, unsigned int *errors)
 Handles the End Of File (EOF) packet in the Ymodem protocol.
 
void extractFileInfo (uint8_t *packet_data, char *getname, int *size)
 Extracts file information from a Ymodem packet.
 
int processHeaderPacket (uint8_t *packet_data, int packet_length, unsigned int maxsize, char *getname, int *size, unsigned int *errors)
 Processes the header packet of a Ymodem transfer.
 
int processPacket (uint8_t *packet_data, int packet_length, fs::File &ffd, unsigned int maxsize, char *getname, unsigned int packets_received, int *size, unsigned int *file_done, unsigned int *errors)
 Processes a received Ymodem packet.
 
int handleFileSession (fs::File &ffd, unsigned int maxsize, char *getname, unsigned int *session_done, unsigned int *errors)
 Handles a file session for receiving data.
 

Detailed Description

Ymodem Packet reception functions.

Author
Miguel Ferrer (mferr.nosp@m.er@i.nosp@m.nbiot.nosp@m..es)
Version
0.1
Date
2025-01-24

This file contains the functions to receive files using the Ymodem protocol. It processes the incoming packets, extracts the file information, and writes the data to the filesystem.

Definition in file YmodemReceive.h.

Function Documentation

◆ extractFileInfo()

void extractFileInfo ( uint8_t * packet_data,
char * getname,
int * size )

Extracts file information from a Ymodem packet.

This function parses the given packet data to extract the file name and size.

Parameters
packet_dataPointer to the packet data containing the file information.
getnamePointer to a character array where the extracted file name will be stored.
sizePointer to an integer where the extracted file size will be stored.

Definition at line 54 of file YmodemReceive.cpp.

◆ handleEOFPacket()

void handleEOFPacket ( unsigned int * file_done,
unsigned int * errors )

Handles the End Of File (EOF) packet in the Ymodem protocol.

This function processes the EOF packet received during a Ymodem file transfer. It updates the status of the file transfer and tracks any errors encountered.

Parameters
file_donePointer to an unsigned int that indicates whether the file transfer is complete. A non-zero value indicates completion.
errorsPointer to an unsigned int that tracks the number of errors encountered during the transfer.

Definition at line 40 of file YmodemReceive.cpp.

◆ handleFileSession()

int handleFileSession ( fs::File & ffd,
unsigned int maxsize,
char * getname,
unsigned int * session_done,
unsigned int * errors )

Handles a file session for receiving data.

Parameters
ffdReference to the file object where the received data will be stored.
maxsizeMaximum size of the file to be received.
getnamePointer to a character array where the name of the received file will be stored.
session_donePointer to an unsigned int that will be set to 1 if the session is completed successfully, 0 otherwise.
errorsPointer to an unsigned int that will be incremented if any errors occur during the session.
Returns
int Status code indicating the result of the file session handling.

Definition at line 144 of file YmodemReceive.cpp.

◆ processDataPacket()

int processDataPacket ( uint8_t * packet_data,
int packet_length,
fs::File & ffd,
unsigned int file_size,
unsigned int * errors )

Processes a data packet received via Ymodem protocol.

This function handles the data packet, writing its contents to the specified file, and updating the error count if any issues are encountered.

Parameters
packet_dataPointer to the data packet to be processed.
packet_lengthLength of the data packet.
ffdReference to the file object where the data will be written.
file_sizeTotal size of the file being received.
errorsPointer to an unsigned int where the error count will be updated.
Returns
int Status code indicating success or failure of the packet processing.

Definition at line 17 of file YmodemReceive.cpp.

◆ processHeaderPacket()

int processHeaderPacket ( uint8_t * packet_data,
int packet_length,
unsigned int maxsize,
char * getname,
int * size,
unsigned int * errors )

Processes the header packet of a Ymodem transfer.

This function extracts information from the header packet, such as the file name and size, and performs validation checks.

Parameters
packet_dataPointer to the packet data.
packet_lengthLength of the packet data.
maxsizeMaximum allowed size for the file.
getnamePointer to a buffer where the file name will be stored.
sizePointer to an integer where the file size will be stored.
errorsPointer to an unsigned integer where the error count will be stored.
Returns
int Returns 0 on success, or a negative error code on failure.

Definition at line 92 of file YmodemReceive.cpp.

◆ processPacket()

int processPacket ( uint8_t * packet_data,
int packet_length,
fs::File & ffd,
unsigned int maxsize,
char * getname,
unsigned int packets_received,
int * size,
unsigned int * file_done,
unsigned int * errors )

Processes a received Ymodem packet.

This function handles the processing of a Ymodem packet, including writing data to a file, managing packet counts, and handling errors.

Parameters
packet_dataPointer to the data of the received packet.
packet_lengthLength of the received packet.
ffdReference to the file object where data will be written.
maxsizeMaximum allowed size of the file.
getnamePointer to a buffer where the filename will be stored.
packets_receivedNumber of packets received so far.
sizePointer to an integer where the size of the file will be stored.
file_donePointer to an unsigned integer that indicates if the file transfer is complete.
errorsPointer to an unsigned integer that counts the number of errors encountered.
Returns
An integer indicating the status of the packet processing. 0 indicates success, while non-zero values indicate different error conditions.

Definition at line 114 of file YmodemReceive.cpp.