2015-08-04 04:50:50 +00:00
|
|
|
#ifndef _OTA_TFTP_H
|
|
|
|
#define _OTA_TFTP_H
|
2016-03-23 06:33:08 +00:00
|
|
|
|
|
|
|
#include "lwip/err.h"
|
|
|
|
|
2016-05-25 07:07:13 +00:00
|
|
|
typedef void (*tftp_receive_cb)(size_t bytes_received);
|
|
|
|
|
2015-08-04 04:50:50 +00:00
|
|
|
/* TFTP Server OTA Support
|
|
|
|
*
|
|
|
|
* To use, call ota_tftp_init_server() which will start the TFTP server task
|
|
|
|
* and keep it running until a valid image is sent.
|
|
|
|
*
|
|
|
|
* The server expects to see a valid image sent with filename "filename.bin"
|
|
|
|
* and will switch "slots" and reboot if a valid image is received.
|
|
|
|
*
|
|
|
|
* Note that the server will allow you to flash an "OTA" update that doesn't
|
|
|
|
* support OTA itself, and possibly brick the esp requiring serial upload.
|
|
|
|
*
|
|
|
|
* Example client comment:
|
|
|
|
* tftp -m octet ESP_IP -c put firmware/myprogram.bin firmware.bin
|
|
|
|
*
|
|
|
|
* TFTP protocol implemented as per RFC1350:
|
|
|
|
* https://tools.ietf.org/html/rfc1350
|
|
|
|
*
|
|
|
|
* IMPORTANT: TFTP is not a secure protocol.
|
|
|
|
* Only allow TFTP OTA updates on trusted networks.
|
|
|
|
*
|
2016-02-08 05:58:31 +00:00
|
|
|
*
|
|
|
|
* For more details, see https://github.com/SuperHouse/esp-open-rtos/wiki/OTA-Update-Configuration
|
2015-08-04 04:50:50 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Start a FreeRTOS task to wait to receive an OTA update from a TFTP client.
|
|
|
|
*
|
|
|
|
* listen_port is the UDP port number to receive TFTP connections on (default TFTP port is 69)
|
|
|
|
*/
|
|
|
|
void ota_tftp_init_server(int listen_port);
|
|
|
|
|
2016-03-23 06:33:08 +00:00
|
|
|
/* Attempt to make a TFTP client connection and download the specified filename.
|
|
|
|
|
|
|
|
'timeout' is in milliseconds, and is timeout for any UDP exchange
|
|
|
|
_not_ the entire download.
|
|
|
|
|
|
|
|
Returns 0 on success, LWIP err.h values for errors.
|
|
|
|
|
|
|
|
Does not change the current firmware slot, or reboot.
|
2016-05-25 07:07:13 +00:00
|
|
|
|
|
|
|
receive_cb: called repeatedly after each successful packet that
|
|
|
|
has been written to flash and ACKed. Can pass NULL to omit.
|
2016-03-23 06:33:08 +00:00
|
|
|
*/
|
2016-05-25 07:07:13 +00:00
|
|
|
err_t ota_tftp_download(const char *server, int port, const char *filename,
|
|
|
|
int timeout, int ota_slot, tftp_receive_cb receive_cb);
|
2016-03-23 06:33:08 +00:00
|
|
|
|
2015-08-04 04:50:50 +00:00
|
|
|
#define TFTP_PORT 69
|
|
|
|
|
|
|
|
#endif
|