-
Notifications
You must be signed in to change notification settings - Fork 11
/
rboot-ota.h
50 lines (39 loc) · 1.23 KB
/
rboot-ota.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef __RBOOT_OTA_H__
#define __RBOOT_OTA_H__
//////////////////////////////////////////////////
// rBoot OTA sample code for ESP8266.
// Copyright 2015 Richard A Burton
// See license.txt for license terms.
// OTA code based on SDK sample from Espressif.
//////////////////////////////////////////////////
#include "rboot-api.h"
#ifdef __cplusplus
extern "C" {
#endif
// ota server details
#define OTA_HOST "192.168.7.5"
#define OTA_PORT 80
#define OTA_ROM0 "rom0.bin"
#define OTA_ROM1 "rom1.bin"
// OTA_FILE is not required, but is part of the example
// code for writing arbitrary files to flash
#define OTA_FILE "file.bin"
// general http header
#define HTTP_HEADER "Connection: keep-alive\r\n\
Cache-Control: no-cache\r\n\
User-Agent: rBoot-Sample/1.0\r\n\
Accept: */*\r\n\r\n"
/* this comment to keep notepad++ happy */
// timeout for the initial connect and each recv (in ms)
#define OTA_NETWORK_TIMEOUT 10000
// used to indicate a non-rom flash
#define FLASH_BY_ADDR 0xff
// callback method should take this format
typedef void (*ota_callback)(bool result, uint8_t rom_slot);
// function to perform the ota update
bool ICACHE_FLASH_ATTR rboot_ota_start(ota_callback callback);
#ifdef __cplusplus
}
#endif
#endif