Ymodem ESP32 1.0.0
Loading...
Searching...
No Matches
TransmitExample.cpp File Reference

Example code to transmit a file using Ymodem protocol. More...

#include "YmodemCore.h"
#include <Arduino.h>
#include <HardwareSerial.h>
#include <SPIFFS.h>
+ Include dependency graph for TransmitExample.cpp:

Go to the source code of this file.

Macros

#define CONFIG_SPIFFS_SIZE   (2 * 1024 * 1024)
 
#define MAX_FILE_SIZE   (CONFIG_SPIFFS_SIZE - 0x2000)
 

Functions

void setup ()
 Initial system configuration.
 
void loop ()
 Main loop function that handles the transmission of a firmware file using Ymodem protocol.
 

Variables

Ymodem ymodem
 

Detailed Description

Example code to transmit a file using Ymodem protocol.

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

This code is an example of how to use the Ymodem library to transmit a file using the Ymodem protocol. The file is read from the SPIFFS filesystem and sent through the Serial1 port.

Definition in file TransmitExample.cpp.

Macro Definition Documentation

◆ CONFIG_SPIFFS_SIZE

#define CONFIG_SPIFFS_SIZE   (2 * 1024 * 1024)

SPIFFS size in bytes

Definition at line 20 of file TransmitExample.cpp.

◆ MAX_FILE_SIZE

#define MAX_FILE_SIZE   (CONFIG_SPIFFS_SIZE - 0x2000)

Maximum file size

Definition at line 21 of file TransmitExample.cpp.

Function Documentation

◆ loop()

void loop ( )

Main loop function that handles the transmission of a firmware file using Ymodem protocol.

This function performs the following steps:

  1. Opens a file named "firmware-1.bin" from SPIFFS (SPI Flash File System).
  2. Checks if the file was successfully opened. If not, logs an error message and returns.
  3. Transmits the file to the receiver using the Ymodem protocol.
  4. Closes the file after transmission.
  5. Logs a success message if the transmission was successful, otherwise logs an error message with the error code.
  6. Introduces a short delay of 10 milliseconds before the next iteration of the loop.

Definition at line 75 of file TransmitExample.cpp.

◆ setup()

void setup ( )

Initial system configuration.

This function performs the following tasks:

  • Initializes the Serial communication for debugging at 115200 baud.
  • Waits until the Serial communication is ready.
  • Mounts the SPIFFS filesystem and checks if it was mounted correctly.
  • Configures the YModem activity LED pin.
  • Initializes the UART (Serial1) with a speed of 115200 baud and configures the RX and TX pins.
  • Prints a message indicating that the setup is complete and the system is ready to send files.

Definition at line 36 of file TransmitExample.cpp.

Variable Documentation

◆ ymodem

Ymodem ymodem

Ymodem instance

Definition at line 23 of file TransmitExample.cpp.