├── .cproject ├── .gitignore ├── .project ├── .settings ├── language.settings.xml └── org.eclipse.cdt.core.prefs ├── .travis.yml ├── lib └── readme.txt ├── platformio.ini ├── server └── firmware.php └── src └── main.cpp /.cproject: -------------------------------------------------------------------------------- 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 | 67 | 77 | 78 | 79 | 80 | 122 | 132 | 133 | 134 | 135 | 177 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | platformio 216 | -f -c eclipse 217 | run -t program 218 | true 219 | true 220 | false 221 | 222 | 223 | platformio 224 | -f -c eclipse 225 | run -t uploadfs 226 | true 227 | true 228 | false 229 | 230 | 231 | platformio 232 | -f -c eclipse 233 | run 234 | true 235 | true 236 | false 237 | 238 | 239 | platformio 240 | -f -c eclipse 241 | run -t upload 242 | true 243 | true 244 | false 245 | 246 | 247 | platformio 248 | -f -c eclipse 249 | run -t clean 250 | true 251 | true 252 | false 253 | 254 | 255 | platformio 256 | -f -c eclipse 257 | update 258 | true 259 | true 260 | false 261 | 262 | 263 | 264 | 265 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .pioenvs 2 | .clang_complete 3 | .gcc-flags.json 4 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | esp8266-ci-ota 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.core.ccnature 24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /.settings/org.eclipse.cdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | environment/project/0.910961921/PATH/delimiter=\: 3 | environment/project/0.910961921/PATH/operation=replace 4 | environment/project/0.910961921/PATH/value=/opt/local/bin\:/opt/local/sbin\:/usr/local/sbin\:/usr/local/bin\:/usr/local/sbin\:/opt/local/bin\:/opt/local/sbin\:/Applications/KindleGen_Mac_i386_v2_9/\:/usr/local/share/npm/bin\:/usr/local/bin\:/usr/bin\:/bin\:/usr/sbin\:/sbin\:/opt/X11/bin 5 | environment/project/0.910961921/append=true 6 | environment/project/0.910961921/appendContributed=true -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - '2.7' 4 | sudo: false 5 | cache: 6 | directories: 7 | - ~/.platformio 8 | env: 9 | - PLATFORMIO_CI_SRC=src/ 10 | 11 | install: 12 | - pip install -U platformio 13 | - platformio lib install 567 562 14 | script: 15 | - platformio run -e nodemcuv2_deploy 16 | 17 | deploy: 18 | on: 19 | repo: squix78/esp8266-ci-ota 20 | all_branches: true 21 | condition: $TRAVIS_TAG =~ ^[0-9]+\.[0-9]+\.[0-9]+$ 22 | skip_cleanup: true 23 | provider: releases 24 | overwrite: true 25 | api_key: 26 | secure: DeLq8sczTsEAo3qi2ztSYgvaeidenvJherPCrceoknNuBs8SEsb8czGxBDPKt7lzK155Kcsfq/zo1VtUpVQ8HsalMQJABv9Li6t1uBc0m+mSLGggxw9woGzHv8FfnJdqeBD3YXgX8Qrmlnqp5QdIDZuyRfOxeF4NFwWZ89aOxMO8Kk363ykvQg5mq8mbqzHJOtCQCkHOEjklhcMTaHZgW/mlt7jBbuX/RM5jGTTAEOIKU/gmVvLo1LQMgsvJ2BCSLMrkEZmfxPncI1xTf26X7aSu01krn6oaROgJtFpTWEmSWHDHOJwngPC36SuaVtyd5WHE8u6+ZkDlfZsvDShq7Iap6vzqZwrTM3NvNyAnLWbE4YLLBDkuHMojyhy5MkvFLjVfEd4wkvy4JOnCL7IhJjcM4OWEXykZv80X/XBqT3XcZYYaorXs1x7rVUCsMYIxythVRaBzsP61NMFIEbLxV0maTYbuLMWX2HmForumMkk6SD7NdbaONZUaKRaG5G/QGWGHrOfVwBWCL/0KEZl6mKqkfadAQI4GWD77MOWn5JNmbM6bVE2hD/oVkSoao1XdY2N0flDEQQuVu3GHIweN3f5kudJ/bS04US1iyWw3t3PYtNOaQrUFtoUMd88/Q6hzzbdYuVVvjBH4Lsni4i/svMu//7URWXGgmcjm14Fr8xU= 27 | file: ".pioenvs/nodemcuv2_deploy/firmware.bin" 28 | -------------------------------------------------------------------------------- /lib/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for the project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link to executable file. 4 | 5 | The source code of each library should be placed in separate directory, like 6 | "lib/private_lib/[here are source files]". 7 | 8 | For example, see how can be organized `Foo` and `Bar` libraries: 9 | 10 | |--lib 11 | | |--Bar 12 | | | |--docs 13 | | | |--examples 14 | | | |--src 15 | | | |- Bar.c 16 | | | |- Bar.h 17 | | |--Foo 18 | | | |- Foo.c 19 | | | |- Foo.h 20 | | |- readme.txt --> THIS FILE 21 | |- platformio.ini 22 | |--src 23 | |- main.c 24 | 25 | Then in `src/main.c` you should use: 26 | 27 | #include 28 | #include 29 | 30 | // rest H/C/CPP code 31 | 32 | PlatformIO will find your libraries automatically, configure preprocessor's 33 | include paths and build them. 34 | 35 | See additional options for PlatformIO Library Dependency Finder `lib_*`: 36 | 37 | http://docs.platformio.org/en/latest/projectconf.html#lib-install 38 | 39 | -------------------------------------------------------------------------------- /platformio.ini: -------------------------------------------------------------------------------- 1 | # 2 | # Project Configuration File 3 | # 4 | # A detailed documentation with the EXAMPLES is located here: 5 | # http://docs.platformio.org/en/latest/projectconf.html 6 | # 7 | 8 | # A sign `#` at the beginning of the line indicates a comment 9 | # Comment lines are ignored. 10 | 11 | # Simple and base environment 12 | # [env:mybaseenv] 13 | # platform = %INSTALLED_PLATFORM_NAME_HERE% 14 | # framework = 15 | # board = 16 | # 17 | # Automatic targets - enable auto-uploading 18 | # targets = upload 19 | 20 | [env:nodemcuv2] 21 | platform = espressif 22 | framework = arduino 23 | board = nodemcuv2 24 | upload_speed = 921600 25 | lib_install = 567, 562 26 | build_flags = -DBUILD_TAG=0.0.0 27 | 28 | [env:nodemcuv2_deploy] 29 | platform = espressif 30 | framework = arduino 31 | board = nodemcuv2 32 | lib_install = 567, 562 33 | build_flags = !echo '-DBUILD_TAG='${TRAVIS_TAG:-"0.0.0"} 34 | -------------------------------------------------------------------------------- /server/firmware.php: -------------------------------------------------------------------------------- 1 | tag_name; 14 | $currentTag = $_GET["tag"]; 15 | if ($latestTag != $currentTag) { 16 | $binPath = $json->assets[0]->browser_download_url; 17 | // the file you want to send 18 | $ch = curl_init(); 19 | curl_setopt($ch, CURLOPT_URL, $binPath); 20 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 21 | curl_setopt($ch, CURLOPT_HEADER, 0); 22 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 23 | $out = curl_exec($ch); 24 | curl_close($ch); 25 | 26 | // Set header for binary 27 | header('Content-type: application/octet-stream'); 28 | header('Content-disposition: attachment; filename="firmware.bin"'); 29 | header('Content-Transfer-Encoding: binary'); 30 | header("Content-Length: ".strlen($out)); 31 | 32 | echo $out; 33 | } else { 34 | header($_SERVER["SERVER_PROTOCOL"].' 304 Not Modified', true, 304); 35 | } 36 | 37 | exit(); 38 | ?> 39 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | #define CHECK_INTERVAL 60 13 | // Stringifying the BUILD_TAG parameter 14 | #define TEXTIFY(A) #A 15 | #define ESCAPEQUOTE(A) TEXTIFY(A) 16 | 17 | String buildTag = ESCAPEQUOTE(BUILD_TAG); 18 | ESP8266WiFiMulti WiFiMulti; 19 | Ticker updateCheck; 20 | boolean doUpdateCheck = true; 21 | 22 | void enableUpdateCheck() { 23 | doUpdateCheck = true; 24 | } 25 | 26 | void setup() { 27 | 28 | // put your setup code here, to run once: 29 | Serial.begin(115200); 30 | Serial.println("Now starting..."); 31 | //WiFiManager 32 | //Local intialization. Once its business is done, there is no need to keep it around 33 | WiFiManager wifiManager; 34 | //reset saved settings 35 | //wifiManager.resetSettings(); 36 | 37 | wifiManager.autoConnect("AutoConnectAP"); 38 | //or use this for auto generated name ESP + ChipID 39 | //wifiManager.autoConnect(); 40 | Serial.println("Started.."); 41 | Serial.println("BUILD_TAG: "+ buildTag); 42 | 43 | // don't wanna miss a thing... Check every 60 seconds 44 | updateCheck.attach(CHECK_INTERVAL, enableUpdateCheck); 45 | } 46 | 47 | void loop() { 48 | // press nodemcu's flash button 49 | int flashButtonState = digitalRead(0); 50 | if (flashButtonState == LOW || doUpdateCheck) { 51 | Serial.println("Going to update firmware..."); 52 | if((WiFiMulti.run() == WL_CONNECTED)) { 53 | 54 | Serial.println("Checking for Update. Current version: " + buildTag); 55 | t_httpUpdate_return ret = ESPhttpUpdate.update("http://www.squix.org/blog/firmware.php?tag=" + buildTag); 56 | 57 | switch(ret) { 58 | case HTTP_UPDATE_FAILED: 59 | Serial.printf("HTTP_UPDATE_FAILD Error (%d): %s", ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str()); 60 | break; 61 | 62 | case HTTP_UPDATE_NO_UPDATES: 63 | Serial.println("HTTP_UPDATE_NO_UPDATES"); 64 | break; 65 | 66 | case HTTP_UPDATE_OK: 67 | Serial.println("HTTP_UPDATE_OK"); 68 | break; 69 | } 70 | } 71 | doUpdateCheck = false; 72 | } 73 | 74 | 75 | } 76 | --------------------------------------------------------------------------------