├── docs ├── logo.png └── wiring.png ├── ESP8266 ├── .gitignore ├── releases │ └── bierbot_brick_101_0.1.2.bin ├── dependencies │ ├── WiFiManager-2.0.4-beta.zip │ ├── WiFiManager@f5dd402ba2698be17e27d357b1ead5291c3d0eb1.zip │ └── README.MD ├── .vscode │ └── extensions.json ├── src │ ├── helper.h │ ├── helper.cpp │ └── main.cpp ├── test │ └── README ├── platformio.ini ├── lib │ └── README ├── include │ └── README └── patch │ └── strings_en.h ├── README.MD └── LICENSE /docs/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BernhardSchlegel/BierBot-Bricks/HEAD/docs/logo.png -------------------------------------------------------------------------------- /docs/wiring.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BernhardSchlegel/BierBot-Bricks/HEAD/docs/wiring.png -------------------------------------------------------------------------------- /ESP8266/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | .vscode/.browse.c_cpp.db* 3 | .vscode/c_cpp_properties.json 4 | .vscode/launch.json 5 | .vscode/ipch 6 | -------------------------------------------------------------------------------- /ESP8266/releases/bierbot_brick_101_0.1.2.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BernhardSchlegel/BierBot-Bricks/HEAD/ESP8266/releases/bierbot_brick_101_0.1.2.bin -------------------------------------------------------------------------------- /ESP8266/dependencies/WiFiManager-2.0.4-beta.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BernhardSchlegel/BierBot-Bricks/HEAD/ESP8266/dependencies/WiFiManager-2.0.4-beta.zip -------------------------------------------------------------------------------- /ESP8266/dependencies/WiFiManager@f5dd402ba2698be17e27d357b1ead5291c3d0eb1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BernhardSchlegel/BierBot-Bricks/HEAD/ESP8266/dependencies/WiFiManager@f5dd402ba2698be17e27d357b1ead5291c3d0eb1.zip -------------------------------------------------------------------------------- /ESP8266/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 3 | // for the documentation about the extensions.json format 4 | "recommendations": [ 5 | "platformio.platformio-ide" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /ESP8266/src/helper.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int32_t TimeDifference(uint32_t prev, uint32_t next); 4 | int32_t TimePassedSince(uint32_t timestamp); 5 | bool TimeReached(uint32_t timer); 6 | void SetNextTimeInterval(uint32_t& timer, const uint32_t step); 7 | int32_t TimePassedSinceUsec(uint32_t timestamp); 8 | bool TimeReachedUsec(uint32_t timer); -------------------------------------------------------------------------------- /ESP8266/dependencies/README.MD: -------------------------------------------------------------------------------- 1 | Note from Bernhard Schlegel: I was not able to get it working with any of the 2 | versions available in the platformIO package Repo (as of March 2021 0.16.0 and 0.15.0). 3 | 4 | Since WiFi manager is undergoing massive reworks, I decided to ship the version 5 | I was using (e.g. offering `saveParamCallback()`) as ZIP file. This is supposedly 6 | version `2.0.4-beta`. -------------------------------------------------------------------------------- /ESP8266/test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PlatformIO Unit Testing and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PlatformIO Unit Testing: 11 | - https://docs.platformio.org/page/plus/unit-testing.html 12 | -------------------------------------------------------------------------------- /ESP8266/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter 4 | ; Upload options: custom upload port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; Advanced options: extra scripting 7 | ; 8 | ; Please visit documentation for the other options and examples 9 | ; https://docs.platformio.org/page/projectconf.html 10 | 11 | [env:sonoff_th] 12 | platform = espressif8266 13 | board = sonoff_th 14 | framework = arduino 15 | lib_deps = 16 | paulstoffregen/OneWire@^2.3.5 17 | bblanchon/ArduinoJson@^6.17.2 18 | WiFiManager=https://github.com/tzapu/WiFiManager.git ; commit f5dd402ba2698be17e27d357b1ead5291c3d0eb1 as of 04/12/2021 worked fine, see backup next line 19 | ;./dependencies/WiFiManager@f5dd402ba2698be17e27d357b1ead5291c3d0eb1.zip 20 | monitor_speed = 115200 21 | 22 | [common] 23 | upload_port = /dev/ttyUSB0 24 | -------------------------------------------------------------------------------- /ESP8266/lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /ESP8266/src/helper.cpp: -------------------------------------------------------------------------------- 1 | #include "helper.h" 2 | 3 | inline int32_t TimeDifference(uint32_t prev, uint32_t next) 4 | { 5 | return ((int32_t) (next - prev)); 6 | } 7 | 8 | int32_t TimePassedSince(uint32_t timestamp) 9 | { 10 | // Compute the number of milliSeconds passed since timestamp given. 11 | // Note: value can be negative if the timestamp has not yet been reached. 12 | return TimeDifference(timestamp, millis()); 13 | } 14 | 15 | bool TimeReached(uint32_t timer) 16 | { 17 | // Check if a certain timeout has been reached. 18 | const int32_t passed = TimePassedSince(timer); 19 | return (passed >= 0); 20 | } 21 | 22 | void SetNextTimeInterval(uint32_t& timer, const uint32_t step) 23 | { 24 | timer += step; 25 | const int32_t passed = TimePassedSince(timer); 26 | if (passed < 0) { return; } // Event has not yet happened, which is fine. 27 | if (static_cast(passed) > step) { 28 | // No need to keep running behind, start again. 29 | timer = millis() + step; 30 | return; 31 | } 32 | // Try to get in sync again. 33 | timer = millis() + (step - passed); 34 | } 35 | 36 | int32_t TimePassedSinceUsec(uint32_t timestamp) 37 | { 38 | return TimeDifference(timestamp, micros()); 39 | } 40 | 41 | bool TimeReachedUsec(uint32_t timer) 42 | { 43 | // Check if a certain timeout has been reached. 44 | const int32_t passed = TimePassedSinceUsec(timer); 45 | return (passed >= 0); 46 | } -------------------------------------------------------------------------------- /ESP8266/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | ![Bricks](./docs/logo.png) 2 | 3 | # BierBot Bricks 4 | 5 | BierBot Bricks is a combination of brewing soft- and hardware that helps you to nail your temperatures (by controlling your heating and cooling equipment), monitor your gravity during fermentation, and much more. Everything is available on a beautiful website that works perfectly on all display sizes: [bricks.bierbot.com](https://bricks.bierbot.com). 6 | 7 | :information_source: The hardware for this repo (Sonoff TH16 based on an ESP8266) is end of production and harder to get. But: we've got you covered. Its official successor, the TH Origin (supporting up to 20Amps), is fully supported. The respective [software and repository is located here](https://github.com/BernhardSchlegel/Brick-32). 8 | 9 | If you get stuck along the way, please dont hesitate to [reach out](https://github.com/BernhardSchlegel/BierBot-Brick/discussions/new) - you're not alone and we're happy to help! If you 👍 it, please consider giving this repo a **star** 🌟 - THANKS! 10 | 11 | If you need more flexibility and have time to build your own RaspberryPi based solution, checkout the [BierBot Bricks software for RaspberryPi](https://github.com/BernhardSchlegel/BierBot-Bricks-RaspberryPi). 12 | 13 | ## Setup for easy use 14 | 15 | There is a [YouTube-Video](https://www.youtube.com/watch?v=ZJEo5KyGwx4) that shows you how to build your Brick step-by-step. There is also a [detailled howto guide including many pictures](https://docs.bierbot.com/hardware/hardware/brick-101#how-to-build-you-own-bierbot-brick) available on the official documentation. 16 | 17 | In the following, you'll find a description that is boiled down to the most important steps. 18 | 19 | First, we need to flash the firmware. 20 | 21 | 1. Order a Sonoff [TH16 + DS18B20 Temperature sensor](https://amzn.to/3uhLiXN). 22 | 2. In case you don't have one laying around, you'll also need: 23 | 1. [FT232RL USB to TTL](https://amzn.to/3ujiT3w) for flashing the BierBot Brick firmware onto your TH16. **Make sure the jumper is set to 3.3V**. 24 | 2. [the cheapest female rainbow cables you can find on the WWW](https://amzn.to/3udmdh2) to hook the TH16 and the FT232 up. 25 | 3. [a 4x1 pin header](https://amzn.to/3rXGrJT) to solder it onto your TH16. 26 | 3. Hook everything up as shown in the image below (left side). 27 | 4. Download the [NodeMCU Flasher](https://github.com/nodemcu/nodemcu-flasher). 28 | 6. Grab the (current) release from [here](https://github.com/BernhardSchlegel/BierBot-Brick/releases/latest). 29 | 7. Open the NodeMCU Flasher 30 | 1. Select tab "Config", and paste the filename of the binary you've just downloaded 31 | into the first line ("firmware.bin") or select one using the dots on the right. 32 | ESP8266Flasher.exe and the firmware.bin must be located in the same directory. 33 | 2. Press the button on your TH16 (and hold it), connect the FT232RL, release the button. 34 | 2. Select tab "Operation" and hit "Flash"! 35 | 36 | ![Image of AC connection](./docs/wiring.png) 37 | 38 | Second, read [the disclaimer](#disclaimer) and cut a extension cable into two pieces and connect as shown in the picture (right side). 39 | **ATTENTION** :warning: check if the labels on YOUR PCB match the colors of the cables: L = Brown, 40 | N = Blue, E / Ground symbol = Yellow / Green. L IN must go to your plug, L OUT to your socket. 41 | 42 | 43 | Your device is now ready to be used. 😃😤 44 | 45 | Go to [bricks.bierbot.com](https://bricks.bierbot.com/#/) > "Brewery" > "Bricks" and hit "Add device". Copy the API-Key 46 | into your clipboard. Power up your BierBot Brick. Scan for the "BierBot Brick 101" WiFi and connect. Enter 47 | the credentials to your home WiFi and paste the API-key from your clipboard. Hit "Save". 48 | 49 | **DONE**. The BierBot Brick should show up in your dashboard. 50 | 51 | ## Help 52 | 53 | For general questions please use [Github Discussions](https://github.com/BernhardSchlegel/BierBot-Brick/discussions). 54 | 55 | If you think you found a bug or want to request a feature: 56 | [Submit an issue](https://github.com/BernhardSchlegel/BierBot-Brick/issues/new/choose). 57 | 58 | In any case: Thanks for participating! 59 | 60 | ## Developer 61 | 62 | The information in this section is only relevant if you want to participate in development. 63 | 64 | ### Developer Setup 65 | 66 | 1. Install VSCode from [here](https://code.visualstudio.com/). 67 | 2. Install PlatformIO as described [here](https://platformio.org/). 68 | 3. Install driver for your Serial converter. E.g. from [here](https://ftdichip.com/drivers/vcp-drivers/). 69 | 4. connect your TTL Converter to the Sonoff TH 16. If all cables are in a row, you likely did something wrong. 70 | 5. Click the terminal Icon in the footer bar of VSCode saying "PlatformIO: new terminal" & type `pio lib install`. 71 | 6. Click the alien on the right side > "Project Tasks" > "sonoff_th" > "Build" and then "Upload". 72 | 73 | ### Notes for devs 74 | 75 | To decode stacktraces use `python3 ./decoder.py -e ./firmware.elf ./trace.txt -s` from [here](https://github.com/janLo/EspArduinoExceptionDecoder). 76 | 77 | If you get a bunch of WiFi Manager related compiling messages, unzip 78 | "./backup/2021_01_15_16_39_WiFiManager.zip" to ".pio/libdeps/sonoff_th". 79 | 80 | 81 | ### TODOs 82 | 83 | - [ ] Reduce programm size to 50% FLASH so that OTA update works. Blocked by 84 | [this](https://github.com/tzapu/WiFiManager/issues/1240). 85 | - [ ] set WiFiManager to a fixed version in Platform IO dependencies as soon as 86 | a stable version is released. 87 | - [ ] as soon as ESP8266 supports SSL without hardcoding fingerprints: Enable SSL. 88 | 89 | ## Disclaimer 90 | 91 | :warning: **DANGER OF ELECTROCUTION** :warning: 92 | 93 | If your device connects to mains electricity (AC power) there is danger of electrocution if not installed properly. If you don't know how to install it, please call an electrician (***Beware:*** certain countries prohibit installation without a licensed electrician present). Remember: _**SAFETY FIRST**_. It is not worth the risk to yourself, your family and your home if you don't know exactly what you are doing. Never tinker or try to flash a device using the serial programming interface while it is connected to MAINS ELECTRICITY (AC power). 94 | 95 | We don't take any responsibility nor liability for using this software nor for the installation or any tips, advice, videos, etc. given by any member of this site or any related site. 96 | 97 | [disclaimer source](https://github.com/arendst/Tasmota/edit/development/README.md) 98 | 99 | 100 | -------------------------------------------------------------------------------- /ESP8266/src/main.cpp: -------------------------------------------------------------------------------- 1 | #define WM_NODEBUG 2 | #define ARDUINO_ESP8266_RELEASE_2_3_0 3 | 4 | #include 5 | #include // https://github.com/tzapu/WiFiManager 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "helper.h" 13 | 14 | // Set web server port number to 80 15 | WiFiServer server(80); 16 | 17 | void handleRoot(); // function prototypes for HTTP handlers 18 | void handleNotFound(); 19 | 20 | OneWire ds(14); // on pin 14 SONOFF TH16 21 | 22 | #define EEPROM_ADDRESS_APIKEY 0 23 | #define GPIO_TRIGGER 0 24 | #define GPIO_RELAIS 12 25 | #define GPIO_LED 13 26 | #define HTTP_REQUEST_RESPONSE_BUF_LEN 255 27 | 28 | String apikey; 29 | WiFiManager wm; // global wm instance 30 | WiFiManagerParameter custom_field_apikey; // global param ( for non blocking w params ) 31 | HTTPClient http; //Declare an object of class HTTPClient 32 | WiFiClientSecure https; 33 | 34 | uint8_t global_error = 0; 35 | uint8_t global_warning = 0; 36 | String global_error_text = ""; 37 | String global_warning_text = ""; 38 | float celsius, fahrenheit; 39 | String sensor_id = ""; 40 | String chipid = ""; 41 | String ssid = ""; 42 | uint32_t main_interval_ms = 1000; // 1s default intervall for first iteration 43 | uint8_t global_relais_state = 0; 44 | String global_version = "0.9.5"; 45 | 46 | void writeStringToEEPROM(int addrOffset, const String &strToWrite) 47 | { 48 | byte len = strToWrite.length(); 49 | Serial.print("String has length "); 50 | Serial.println(len); 51 | EEPROM.write(addrOffset, len); 52 | for (int i = 0; i < len; i++) 53 | { 54 | // replace values in byte-array cache with modified data 55 | // no changes made to flash, all in local byte-array cache 56 | EEPROM.put(addrOffset + 1 + i, strToWrite[i]); 57 | } 58 | Serial.println("Data put to EEPROM."); 59 | 60 | // https://arduino.stackexchange.com/questions/25945/how-to-read-and-write-eeprom-in-esp8266 61 | // actually write the content of byte-array cache to 62 | // hardware flash. flash write occurs if and only if one or more byte 63 | // in byte-array cache has been changed, but if so, ALL 512 bytes are 64 | // written to flash 65 | EEPROM.commit(); 66 | Serial.println("EEPROM committed."); 67 | } 68 | 69 | String readStringFromEEPROM(int addrOffset) 70 | { 71 | int newStrLen = EEPROM.read(addrOffset); 72 | char data[newStrLen + 1]; 73 | for (int i = 0; i < newStrLen; i++) 74 | { 75 | data[i] = EEPROM.read(addrOffset + 1 + i); 76 | } 77 | data[newStrLen] = '\0'; // the character may appear in a weird way, you should read: 'only one backslash and 0' 78 | return String(data); 79 | } 80 | 81 | String getParam(String name) 82 | { 83 | //read parameter from server, for customhmtl input 84 | String value; 85 | if (wm.server->hasArg(name)) 86 | { 87 | value = wm.server->arg(name); 88 | } 89 | return value; 90 | } 91 | 92 | void saveParamCallback() 93 | { 94 | Serial.println("[CALLBACK] saveParamCallback fired"); 95 | apikey = getParam("apikey").substring(0, 20); 96 | Serial.println("PARAM apikey straight = " + apikey); 97 | //String apikey = getParam("apikey"); 98 | writeStringToEEPROM(EEPROM_ADDRESS_APIKEY, apikey); 99 | String apikey_restored = readStringFromEEPROM(EEPROM_ADDRESS_APIKEY); 100 | Serial.println("PARAM apikey from EEPROM = " + apikey_restored); 101 | } 102 | 103 | void checkButton() 104 | { 105 | // check for button press 106 | if (digitalRead(GPIO_TRIGGER) == LOW) 107 | { 108 | // poor mans debounce/press-hold, code not ideal for production 109 | delay(50); 110 | if (digitalRead(GPIO_TRIGGER) == LOW) 111 | { 112 | Serial.println("Button Pressed"); 113 | // still holding button for 3000 ms, reset settings, code not ideaa for production 114 | delay(3000); // reset delay hold 115 | if (digitalRead(GPIO_TRIGGER) == LOW) 116 | { 117 | Serial.println("Button Held"); 118 | Serial.println("Erasing Config, restarting"); 119 | wm.disconnect(); 120 | wm.resetSettings(); 121 | ESP.restart(); 122 | } 123 | else 124 | { 125 | server.stop(); // kill status server (to avoid conflicnt) 126 | 127 | // start portal w delay 128 | Serial.println("Starting config portal"); 129 | wm.setConfigPortalTimeout(120); 130 | 131 | if (!wm.startConfigPortal(ssid.c_str())) 132 | { 133 | Serial.println("failed to connect or hit timeout"); 134 | delay(3000); 135 | // ESP.restart(); 136 | } 137 | else 138 | { 139 | //if you get here you have connected to the WiFi 140 | Serial.println("connection re-established"); 141 | } 142 | 143 | server.begin(); // start status server again 144 | } 145 | } 146 | } 147 | } 148 | 149 | void short_flash_500ms(uint8_t count) 150 | { 151 | for (uint8_t i = 0; i < count; ++i) 152 | { 153 | digitalWrite(GPIO_LED, 1); 154 | delay(100); 155 | digitalWrite(GPIO_LED, 0); 156 | delay(400); 157 | } 158 | } 159 | 160 | void arrayToString(byte array[], unsigned int len, char buffer[]) 161 | { 162 | // source https://stackoverflow.com/questions/44748740/ 163 | for (unsigned int i = 0; i < len; i++) 164 | { 165 | byte nib1 = (array[i] >> 4) & 0x0F; 166 | byte nib2 = (array[i] >> 0) & 0x0F; 167 | buffer[i * 2 + 0] = nib1 < 0xA ? '0' + nib1 : 'A' + nib1 - 0xA; 168 | buffer[i * 2 + 1] = nib2 < 0xA ? '0' + nib2 : 'A' + nib2 - 0xA; 169 | } 170 | buffer[len * 2] = '\0'; 171 | } 172 | 173 | void readTemperature() 174 | { 175 | // put your main code here, to run repeatedly: 176 | byte i; 177 | byte present = 0; 178 | byte type_s; 179 | byte data[12]; 180 | byte addr[8]; 181 | 182 | if (!ds.search(addr)) 183 | { 184 | Serial.println("No more addresses."); 185 | Serial.println(); 186 | ds.reset_search(); 187 | delay(250); 188 | return; 189 | } 190 | 191 | Serial.print("ROM ="); 192 | for (i = 0; i < 8; i++) 193 | { 194 | Serial.write(' '); 195 | Serial.print(addr[i], HEX); 196 | } 197 | 198 | if (OneWire::crc8(addr, 7) != addr[7]) 199 | { 200 | Serial.println("CRC is not valid!"); 201 | return; 202 | } 203 | Serial.println(); 204 | 205 | // the first ROM byte indicates which chip 206 | switch (addr[0]) 207 | { 208 | case 0x10: 209 | Serial.println(" Chip = DS18S20"); // or old DS1820 210 | type_s = 1; 211 | break; 212 | case 0x28: 213 | Serial.println(" Chip = DS18B20"); 214 | type_s = 0; 215 | break; 216 | case 0x22: 217 | Serial.println(" Chip = DS1822"); 218 | type_s = 0; 219 | break; 220 | default: 221 | Serial.println("Device is not a DS18x20 family device."); 222 | return; 223 | } 224 | 225 | ds.reset(); 226 | ds.select(addr); 227 | ds.write(0x44, 1); // start conversion, with parasite power on at the end 228 | 229 | delay(1000); // maybe 750ms is enough, maybe not 230 | // we might do a ds.depower() here, but the reset will take care of it. 231 | 232 | present = ds.reset(); 233 | ds.select(addr); 234 | ds.write(0xBE); // Read Scratchpad 235 | 236 | // store sensor id => 8 bytes, one byte needs 2 char + Termination 237 | char buffer[17] = ""; 238 | arrayToString(addr, 8, buffer); 239 | sensor_id = String(buffer); 240 | 241 | Serial.print(" Data = "); 242 | Serial.print(present, HEX); 243 | Serial.print(" "); 244 | for (i = 0; i < 9; i++) 245 | { // we need 9 bytes 246 | data[i] = ds.read(); 247 | Serial.print(data[i], HEX); 248 | Serial.print(" "); 249 | } 250 | Serial.print(" CRC="); 251 | Serial.print(OneWire::crc8(data, 8), HEX); 252 | Serial.println(); 253 | 254 | // Convert the data to actual temperature 255 | // because the result is a 16 bit signed integer, it should 256 | // be stored to an "int16_t" type, which is always 16 bits 257 | // even when compiled on a 32 bit processor. 258 | int16_t raw = (data[1] << 8) | data[0]; 259 | if (type_s) 260 | { 261 | raw = raw << 3; // 9 bit resolution default 262 | if (data[7] == 0x10) 263 | { 264 | // "count remain" gives full 12 bit resolution 265 | raw = (raw & 0xFFF0) + 12 - data[6]; 266 | } 267 | } 268 | else 269 | { 270 | byte cfg = (data[4] & 0x60); 271 | // at lower res, the low bits are undefined, so let's zero them 272 | if (cfg == 0x00) 273 | raw = raw & ~7; // 9 bit resolution, 93.75 ms 274 | else if (cfg == 0x20) 275 | raw = raw & ~3; // 10 bit res, 187.5 ms 276 | else if (cfg == 0x40) 277 | raw = raw & ~1; // 11 bit res, 375 ms 278 | //// default is 12 bit resolution, 750 ms conversion time 279 | } 280 | celsius = (float)raw / 16.0; 281 | fahrenheit = celsius * 1.8 + 32.0; 282 | Serial.print(" Temperature = "); 283 | Serial.print(celsius); 284 | Serial.println(" Celsius."); 285 | //Serial.print(fahrenheit); 286 | //Serial.println(" Fahrenheit"); 287 | 288 | String apikey_restored = readStringFromEEPROM(EEPROM_ADDRESS_APIKEY); 289 | Serial.println("PARAM apikey from EEPROM = " + apikey_restored); 290 | } 291 | 292 | void setup() 293 | { 294 | Serial.println("BierBot Brick 101 starting"); 295 | chipid = String(ESP.getFlashChipId()) + "_" + String(WiFi.macAddress()); 296 | Serial.println("chipid: " + chipid); 297 | ssid = "BierBot Brick 101 " + String(ESP.getFlashChipId()); 298 | 299 | short_flash_500ms(10); 300 | 301 | //--------------------------------------------------------------------------------------- 302 | // GPIO 303 | //--------------------------------------------------------------------------------------- 304 | pinMode(GPIO_TRIGGER, INPUT); 305 | pinMode(GPIO_RELAIS, OUTPUT); 306 | pinMode(GPIO_LED, OUTPUT); 307 | 308 | //--------------------------------------------------------------------------------------- 309 | // EEPROM 310 | //--------------------------------------------------------------------------------------- 311 | // commit 512 bytes of ESP8266 flash (for "EEPROM" emulation) 312 | // this step actually loads the content (512 bytes) of flash into 313 | // a 512-byte-array cache in RAM 314 | EEPROM.begin(512); 315 | 316 | //--------------------------------------------------------------------------------------- 317 | // WIFI 318 | //--------------------------------------------------------------------------------------- 319 | WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP 320 | 321 | // put your setup code here, to run once: 322 | Serial.begin(115200); 323 | 324 | Serial.println("\n Starting"); 325 | 326 | // read temperature once 327 | readTemperature(); 328 | 329 | // guid, len 36 + terminator 330 | // e.g. 550e8400-e29b-11d4-a716-446655440000 331 | // test custom html(radio) 332 | //const char* custom_apikey_str = "

"; 333 | //new (&custom_field_apikey) WiFiManagerParameter(custom_apikey_str); // custom html input 334 | new (&custom_field_apikey) WiFiManagerParameter("apikey", "BierBot Bricks API Key", "", 37, "placeholder=\"get your API key at bricks.bierbot.com\""); 335 | 336 | wm.addParameter(&custom_field_apikey); 337 | //wm.setConfigPortalBlocking(false); 338 | wm.setSaveConfigCallback(saveParamCallback); 339 | 340 | //reset settings - wipe credentials for testing 341 | //wm.resetSettings(); 342 | 343 | // Automatically connect using saved credentials, 344 | // if connection fails, it starts an access point with the specified name ( "AutoConnectAP"), 345 | // if empty will auto generate SSID, if password is blank it will be anonymous AP (wm.autoConnect()) 346 | // then goes into a blocking loop awaiting configuration and will return success result 347 | 348 | bool res; 349 | res = wm.autoConnect(ssid.c_str()); 350 | 351 | if (!res) 352 | { 353 | Serial.println("Failed to connect"); 354 | // ESP.restart(); 355 | } 356 | else 357 | { 358 | //if you get here you have connected to the WiFi 359 | Serial.println("connected...yeey :)"); 360 | } 361 | 362 | // eeprom for storing api key 363 | EEPROM.begin(512); 364 | 365 | server.begin(); 366 | } 367 | 368 | // Current time 369 | unsigned long currentTime = millis(); 370 | // Previous time 371 | unsigned long previousTime = 0; 372 | // Define timeout time in milliseconds (example: 2000ms = 2s) 373 | const long timeoutTime = 2000; 374 | 375 | void addDataRow(WiFiClient client, String key, String value) 376 | { 377 | client.println(""); 378 | client.println(""); 379 | client.println(key); 380 | client.println(""); 381 | client.println(""); 382 | client.println(value); 383 | client.println(""); 384 | client.println(""); 385 | } 386 | 387 | void checkRequest() 388 | { 389 | 390 | WiFiClient client = server.available(); // Listen for incoming clients 391 | 392 | if (client) 393 | { // If a new client connects, 394 | Serial.println("New Client."); // print a message out in the serial port 395 | String currentLine = ""; // make a String to hold incoming data from the client 396 | currentTime = millis(); 397 | previousTime = currentTime; 398 | while (client.connected() && currentTime - previousTime <= timeoutTime) 399 | { // loop while the client's connected 400 | currentTime = millis(); 401 | if (client.available()) 402 | { // if there's bytes to read from the client, 403 | char c = client.read(); // read a byte, then 404 | Serial.write(c); // print it out the serial monitor 405 | if (c == '\n') 406 | { // if the byte is a newline character 407 | // if the current line is blank, you got two newline characters in a row. 408 | // that's the end of the client HTTP request, so send a response: 409 | if (currentLine.length() == 0) 410 | { 411 | // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK) 412 | // and a content-type so the client knows what's coming, then a blank line: 413 | client.println("HTTP/1.1 200 OK"); 414 | client.println("Content-type:text/html"); 415 | client.println("Connection: close"); 416 | client.println(); 417 | 418 | // Display the HTML web page 419 | client.println(""); 420 | client.println(""); 421 | 422 | client.println(""); 423 | client.println(""); 424 | // CSS to style the on/off buttons 425 | // Feel free to change the background-color and font-size attributes to fit your preferences 426 | client.println(""); 430 | 431 | // Web Page Heading 432 | client.println("

BierBot Brick 101

"); 433 | client.println(""); 434 | String temp = String(celsius); 435 | addDataRow(client, "Temperature", temp); 436 | String api_key = readStringFromEEPROM(EEPROM_ADDRESS_APIKEY); 437 | addDataRow(client, "API key", api_key); 438 | 439 | if (global_warning) 440 | { 441 | addDataRow(client, "Warning", global_warning_text); 442 | } 443 | if (global_error) 444 | { 445 | addDataRow(client, "Warning", global_error_text); 446 | } 447 | 448 | client.println(""); 449 | client.println("
"); 450 | 451 | // The HTTP response ends with another blank line 452 | client.println(); 453 | // Break out of the while loop 454 | break; 455 | } 456 | else 457 | { // if you got a newline, then clear currentLine 458 | currentLine = ""; 459 | } 460 | } 461 | else if (c != '\r') 462 | { // if you got anything else but a carriage return character, 463 | currentLine += c; // add it to the end of the currentLine 464 | } 465 | } 466 | } 467 | // Close the connection 468 | client.stop(); 469 | Serial.println("Client disconnected."); 470 | } 471 | } 472 | 473 | void contactBackend() 474 | { 475 | if (1 == 1) 476 | { // WiFi.status() == WL_CONNECTED) { //Check WiFi connection status 477 | String apikey_restored = readStringFromEEPROM(EEPROM_ADDRESS_APIKEY); 478 | String temp = String(celsius); 479 | String relais = String(global_relais_state); 480 | String url = "https://bricks.bierbot.com/api/iot/v1?apikey=" + apikey_restored + "&type=" + "sonoff_th16" + "&brand=" + "bierbot" + "&version=" + global_version + "&s_number_temp_0=" + temp + "&a_bool_epower_0=" + relais + "&chipid=" + chipid + "&s_number_temp_id_0=" + sensor_id; 481 | 482 | Serial.print("s_number_temp_0=" + temp); 483 | Serial.println(", a_bool_epower_0=" + relais); 484 | 485 | WiFiClientSecure client; 486 | client.setInsecure(); // unfortunately necessary, ESP8266 does not support SSL without hard coding certificates 487 | client.connect(url, 443); 488 | 489 | http.begin(client, url); 490 | 491 | // String payload = "{\"s_number_temp_0\":\"" + temp + "\",\"a_bool_epower_0\":\"" + relais + "\",\"type\":\"" + "sonoff_th16" + "\",\"brand\":\"" + "bierbot" + "\",\"version\":\"" + global_version + "\",\"chipid\":\"" + chipid + "\"}"; 492 | // Serial.println("payload " + payload); 493 | 494 | Serial.println("submitting POST to " + url); 495 | int httpCode = http.GET(); // GET has issues with 301 forwards 496 | Serial.print("httpCode: "); 497 | Serial.println(httpCode); 498 | 499 | if (httpCode > 0) 500 | { //Check the returning code 501 | 502 | for (int i = 0; i < http.headers(); i++) 503 | { 504 | Serial.println(http.header(i)); 505 | } 506 | 507 | String payload = http.getString(); //Get the request response payload 508 | Serial.print(F("received payload: ")); 509 | Serial.println(payload); //Print the response payload 510 | 511 | if (payload.length() == 0) 512 | { 513 | Serial.println(F("payload empty, skipping.")); 514 | Serial.println(F("setting next request to 60s.")); 515 | main_interval_ms = 60000; 516 | global_relais_state = 0; 517 | } 518 | else if (payload.indexOf("{") == -1) 519 | { 520 | Serial.println("no JSON - skippping."); 521 | Serial.println(F("setting next request to 60s.")); 522 | main_interval_ms = 60000; 523 | global_relais_state = 0; 524 | } 525 | else 526 | { 527 | StaticJsonDocument doc; 528 | 529 | // Deserialize the JSON document 530 | // doc should look like "{\"target_state\":0, \"next_request_ms\":10000,\"error\":1,\"error_text\":\"Your device will need an upgrade\",\"warning\":1,\"warning_text\":\"Your device will need an upgrade\"}"; 531 | DeserializationError error = deserializeJson(doc, payload); 532 | // Test if parsing succeeds. 533 | if (error) 534 | { 535 | Serial.print(F("deserializeJson() failed: ")); 536 | Serial.println(error.f_str()); 537 | global_error = 1; 538 | global_error_text = String("JSON error: ") + String(error.f_str()); 539 | global_relais_state = 0; 540 | } 541 | else 542 | { 543 | Serial.println("deserializeJson success"); 544 | if (doc["error"]) 545 | { 546 | // an error is critical, do not proceed with logik 547 | const char *error_text = doc["error_text"]; 548 | global_error_text = String(error_text); 549 | global_error = 1; 550 | global_relais_state = 0; 551 | } 552 | else 553 | { 554 | global_error = 0; 555 | if (doc["warning"]) 556 | { 557 | // proceed with logik, if there is a warning 558 | const char *warning_text = doc["warning_text"]; 559 | global_warning_text = String(warning_text); 560 | global_warning = 1; 561 | global_relais_state = 0; 562 | } 563 | else 564 | { 565 | global_warning = 0; 566 | } 567 | 568 | // main logic here 569 | if (doc.containsKey("next_request_ms")) 570 | { 571 | main_interval_ms = doc["next_request_ms"].as(); 572 | } 573 | else 574 | { 575 | // try again in 30s 576 | main_interval_ms = 30000; 577 | } 578 | if (doc.containsKey("epower_0_state")) 579 | { 580 | global_relais_state = doc["epower_0_state"]; 581 | } 582 | else 583 | { 584 | global_relais_state = 0; 585 | } 586 | } 587 | } 588 | } 589 | } 590 | else 591 | { 592 | Serial.print(F("setting next request to 60s.")); 593 | main_interval_ms = 60000; 594 | global_relais_state = 0; 595 | } 596 | http.end(); //Close connection 597 | } 598 | }; 599 | 600 | void setRelais() 601 | { 602 | digitalWrite(GPIO_RELAIS, global_relais_state); 603 | digitalWrite(GPIO_LED, global_relais_state); 604 | }; 605 | 606 | void loop() 607 | { 608 | checkRequest(); 609 | checkButton(); 610 | 611 | static uint32_t state_main_interval = 0; 612 | if (TimeReached(state_main_interval)) 613 | { 614 | // one interval delay in case server wants to set new interval 615 | SetNextTimeInterval(state_main_interval, main_interval_ms); 616 | 617 | Serial.println("##### MAIN: reading temperature"); 618 | readTemperature(); 619 | 620 | Serial.println("##### MAIN: contacting backend"); 621 | contactBackend(); 622 | 623 | Serial.println("##### MAIN: setting relais"); 624 | setRelais(); 625 | } 626 | } 627 | -------------------------------------------------------------------------------- /ESP8266/patch/strings_en.h: -------------------------------------------------------------------------------- 1 | /** 2 | * strings_en.h 3 | * engligh strings for 4 | * WiFiManager, a library for the ESP8266/Arduino platform 5 | * for configuration of WiFi credentials using a Captive Portal 6 | * 7 | * @author Creator tzapu 8 | * @author tablatronix 9 | * @version 0.0.0 10 | * @license MIT 11 | */ 12 | 13 | #ifndef _WM_STRINGS_H_ 14 | #define _WM_STRINGS_H_ 15 | 16 | #ifndef WIFI_MANAGER_OVERRIDE_STRINGS 17 | // !!! ABOVE WILL NOT WORK if you define in your sketch, must be build flag, if anyone one knows how to order includes to be able to do this it would be neat.. I have seen it done.. 18 | 19 | const char HTTP_HEAD_START[] PROGMEM = "" 20 | "" 21 | "" 22 | "" 23 | "" 24 | "{v}"; 25 | 26 | const char HTTP_SCRIPT[] PROGMEM = ""; // @todo add button states, disable on click , show ack , spinner etc 31 | 32 | const char HTTP_HEAD_END[] PROGMEM = "
"; // {c} = _bodyclass 33 | // example of embedded logo, base64 encoded inline, No styling here 34 | // const char HTTP_ROOT_MAIN[] PROGMEM = "

{v}

WiFiManager

"; 35 | const char HTTP_ROOT_MAIN[] PROGMEM = "

{t}

{v}

"; 36 | const char * const HTTP_PORTAL_MENU[] PROGMEM = { 37 | "

\n", // MENU_WIFI 38 | "

\n", // MENU_WIFINOSCAN 39 | "

\n", // MENU_INFO 40 | "

\n",//MENU_PARAM 41 | "

\n", // MENU_CLOSE 42 | "

\n",// MENU_RESTART 43 | "

\n", // MENU_EXIT 44 | "

\n", // MENU_ERASE 45 | "

\n",// MENU_UPDATE 46 | "

" // MENU_SEP 47 | }; 48 | 49 | // const char HTTP_PORTAL_OPTIONS[] PROGMEM = strcat(HTTP_PORTAL_MENU[0] , HTTP_PORTAL_MENU[3] , HTTP_PORTAL_MENU[7]); 50 | const char HTTP_PORTAL_OPTIONS[] PROGMEM = ""; 51 | const char HTTP_ITEM_QI[] PROGMEM = ""; // rssi icons 52 | const char HTTP_ITEM_QP[] PROGMEM = "
{r}%
"; // rssi percentage {h} = hidden showperc pref 53 | const char HTTP_ITEM[] PROGMEM = "
{v}{qi}{qp}
"; // {q} = HTTP_ITEM_QI, {r} = HTTP_ITEM_QP 54 | // const char HTTP_ITEM[] PROGMEM = "
{v} {R} {r}% {q} {e}
"; // test all tokens 55 | 56 | const char HTTP_FORM_START[] PROGMEM = "
"; 57 | const char HTTP_FORM_WIFI[] PROGMEM = "
"; 58 | const char HTTP_FORM_WIFI_END[] PROGMEM = ""; 59 | const char HTTP_FORM_STATIC_HEAD[] PROGMEM = "

"; 60 | const char HTTP_FORM_END[] PROGMEM = "

"; 61 | const char HTTP_FORM_LABEL[] PROGMEM = ""; 62 | const char HTTP_FORM_PARAM_HEAD[] PROGMEM = "

"; 63 | const char HTTP_FORM_PARAM[] PROGMEM = "
"; 64 | 65 | const char HTTP_SCAN_LINK[] PROGMEM = "
"; 66 | const char HTTP_SAVED[] PROGMEM = "
Saving Credentials
Trying to connect ESP to network.
If it fails reconnect to AP to try again
"; 67 | const char HTTP_PARAMSAVED[] PROGMEM = "
Saved
"; 68 | const char HTTP_END[] PROGMEM = "
"; 69 | const char HTTP_ERASEBTN[] PROGMEM = "
"; 70 | const char HTTP_UPDATEBTN[] PROGMEM = "
"; 71 | const char HTTP_BACKBTN[] PROGMEM = "

"; 72 | 73 | const char HTTP_STATUS_ON[] PROGMEM = "
Connected to {v}
with IP {i}
"; 74 | const char HTTP_STATUS_OFF[] PROGMEM = "
Not Connected to {v}{r}
"; // {c=class} {v=ssid} {r=status_off} 75 | const char HTTP_STATUS_OFFPW[] PROGMEM = "
Authentication Failure"; // STATION_WRONG_PASSWORD, no eps32 76 | const char HTTP_STATUS_OFFNOAP[] PROGMEM = "
AP not found"; // WL_NO_SSID_AVAIL 77 | const char HTTP_STATUS_OFFFAIL[] PROGMEM = "
Could not Connect"; // WL_CONNECT_FAILED 78 | const char HTTP_STATUS_NONE[] PROGMEM = "
No AP set
"; 79 | const char HTTP_BR[] PROGMEM = "
"; 80 | 81 | const char HTTP_STYLE[] PROGMEM = ""; 109 | 110 | #ifndef WM_NOHELP 111 | const char HTTP_HELP[] PROGMEM = 112 | "

Available Pages


" 113 | "
" 114 | "" 115 | "" 116 | "" 117 | "" 118 | "" 119 | "" 120 | "" 121 | "" 122 | "" 123 | "" 124 | "" 125 | "" 126 | "" 127 | "" 128 | "" 129 | "" 130 | "" 131 | "" 132 | "" 133 | "" 134 | "" 135 | "
PageFunction
/Menu page.
/wifiShow WiFi scan results and enter WiFi configuration.(/0wifi noscan)
/wifisaveSave WiFi configuration information and configure device. Needs variables supplied.
/paramParameter page
/infoInformation page
/uOTA Update
/closeClose the captiveportal popup,configportal will remain active
/exitExit Config Portal, configportal will close
/restartReboot the device
/eraseErase WiFi configuration and reboot Device. Device will not reconnect to a network until new WiFi configuration data is entered.
" 136 | "

More information about WiFiManager at https://github.com/tzapu/WiFiManager."; 137 | #else 138 | const char HTTP_HELP[] PROGMEM = ""; 139 | #endif 140 | 141 | const char HTTP_UPDATE[] PROGMEM = "Upload New Firmware

* May not function inside captive portal, Open in browser http://192.168.4.1"; 142 | const char HTTP_UPDATE_FAIL[] PROGMEM = "
Update Failed!
Reboot device and try again
"; 143 | const char HTTP_UPDATE_SUCCESS[] PROGMEM = "
Update Successful.
Device Rebooting now...
"; 144 | 145 | #ifdef WM_JSTEST 146 | const char HTTP_JS[] PROGMEM = 147 | ""; 163 | #endif 164 | 165 | // Info html 166 | #ifdef ESP32 167 | const char HTTP_INFO_esphead[] PROGMEM = "

esp32


"; 168 | const char HTTP_INFO_chiprev[] PROGMEM = "
Chip Rev
{1}
"; 169 | const char HTTP_INFO_lastreset[] PROGMEM = "
Last reset reason
CPU0: {1}
CPU1: {2}
"; 170 | const char HTTP_INFO_aphost[] PROGMEM = "
Acccess Point Hostname
{1}
"; 171 | const char HTTP_INFO_psrsize[] PROGMEM = "
PSRAM Size
{1} bytes
"; 172 | const char HTTP_INFO_temp[] PROGMEM = "
Temperature
{1} C° / {2} F°
Hall
{3}
"; 173 | #else 174 | const char HTTP_INFO_esphead[] PROGMEM = "

esp8266


"; 175 | const char HTTP_INFO_fchipid[] PROGMEM = "
Flash Chip ID
{1}
"; 176 | const char HTTP_INFO_corever[] PROGMEM = "
Core Version
{1}
"; 177 | const char HTTP_INFO_bootver[] PROGMEM = "
Boot Version
{1}
"; 178 | const char HTTP_INFO_lastreset[] PROGMEM = "
Last reset reason
{1}
"; 179 | const char HTTP_INFO_flashsize[] PROGMEM = "
Real Flash Size
{1} bytes
"; 180 | #endif 181 | 182 | const char HTTP_INFO_memsmeter[] PROGMEM = "
"; 183 | const char HTTP_INFO_memsketch[] PROGMEM = "
Memory - Sketch Size
Used / Total bytes
{1} / {2}"; 184 | const char HTTP_INFO_freeheap[] PROGMEM = "
Memory - Free Heap
{1} bytes available
"; 185 | const char HTTP_INFO_wifihead[] PROGMEM = "

WiFi


"; 186 | const char HTTP_INFO_uptime[] PROGMEM = "
Uptime
{1} Mins {2} Secs
"; 187 | const char HTTP_INFO_chipid[] PROGMEM = "
Chip ID
{1}
"; 188 | const char HTTP_INFO_idesize[] PROGMEM = "
Flash Size
{1} bytes
"; 189 | const char HTTP_INFO_sdkver[] PROGMEM = "
SDK Version
{1}
"; 190 | const char HTTP_INFO_cpufreq[] PROGMEM = "
CPU Frequency
{1}MHz
"; 191 | const char HTTP_INFO_apip[] PROGMEM = "
Access Point IP
{1}
"; 192 | const char HTTP_INFO_apmac[] PROGMEM = "
Access Point MAC
{1}
"; 193 | const char HTTP_INFO_apssid[] PROGMEM = "
Access Point SSID
{1}
"; 194 | const char HTTP_INFO_apbssid[] PROGMEM = "
BSSID
{1}
"; 195 | const char HTTP_INFO_stassid[] PROGMEM = "
Station SSID
{1}
"; 196 | const char HTTP_INFO_staip[] PROGMEM = "
Station IP
{1}
"; 197 | const char HTTP_INFO_stagw[] PROGMEM = "
Station Gateway
{1}
"; 198 | const char HTTP_INFO_stasub[] PROGMEM = "
Station Subnet
{1}
"; 199 | const char HTTP_INFO_dnss[] PROGMEM = "
DNS Server
{1}
"; 200 | const char HTTP_INFO_host[] PROGMEM = "
Hostname
{1}
"; 201 | const char HTTP_INFO_stamac[] PROGMEM = "
Station MAC
{1}
"; 202 | const char HTTP_INFO_conx[] PROGMEM = "
Connected
{1}
"; 203 | const char HTTP_INFO_autoconx[] PROGMEM = "
Autoconnect
{1}
"; 204 | 205 | 206 | const char S_brand[] PROGMEM = "WiFiManager"; 207 | const char S_debugPrefix[] PROGMEM = "*wm:"; 208 | const char S_y[] PROGMEM = "Yes"; 209 | const char S_n[] PROGMEM = "No"; 210 | const char S_enable[] PROGMEM = "Enabled"; 211 | const char S_disable[] PROGMEM = "Disabled"; 212 | const char S_GET[] PROGMEM = "GET"; 213 | const char S_POST[] PROGMEM = "POST"; 214 | const char S_NA[] PROGMEM = "Unknown"; 215 | const char S_passph[] PROGMEM = "********"; 216 | const char S_titlewifisaved[] PROGMEM = "Credentials Saved"; 217 | const char S_titlewifisettings[] PROGMEM = "Settings Saved"; 218 | const char S_titlewifi[] PROGMEM = "Config ESP"; 219 | const char S_titleinfo[] PROGMEM = "Info"; 220 | const char S_titleparam[] PROGMEM = "Setup"; 221 | const char S_titleparamsaved[] PROGMEM = "Setup Saved"; 222 | const char S_titleexit[] PROGMEM = "Exit"; 223 | const char S_titlereset[] PROGMEM = "Reset"; 224 | const char S_titleerase[] PROGMEM = "Erase"; 225 | const char S_titleclose[] PROGMEM = "Close"; 226 | const char S_options[] PROGMEM = "options"; 227 | const char S_nonetworks[] PROGMEM = "No networks found. Refresh to scan again."; 228 | const char S_staticip[] PROGMEM = "Static IP"; 229 | const char S_staticgw[] PROGMEM = "Static Gateway"; 230 | const char S_staticdns[] PROGMEM = "Static DNS"; 231 | const char S_subnet[] PROGMEM = "Subnet"; 232 | const char S_exiting[] PROGMEM = "Exiting"; 233 | const char S_resetting[] PROGMEM = "Module will reset in a few seconds."; 234 | const char S_closing[] PROGMEM = "You can close the page, portal will continue to run"; 235 | const char S_error[] PROGMEM = "An Error Occured"; 236 | const char S_notfound[] PROGMEM = "File Not Found\n\n"; 237 | const char S_uri[] PROGMEM = "URI: "; 238 | const char S_method[] PROGMEM = "\nMethod: "; 239 | const char S_args[] PROGMEM = "\nArguments: "; 240 | const char S_parampre[] PROGMEM = "param_"; 241 | 242 | // debug strings 243 | const char D_HR[] PROGMEM = "--------------------"; 244 | 245 | // END WIFI_MANAGER_OVERRIDE_STRINGS 246 | #endif 247 | 248 | // ----------------------------------------------------------------------------------------------- 249 | // DO NOT EDIT BELOW THIS LINE 250 | 251 | const uint8_t _nummenutokens = 10; 252 | const char * const _menutokens[10] PROGMEM = { 253 | "wifi", 254 | "wifinoscan", 255 | "info", 256 | "param", 257 | "close", 258 | "restart", 259 | "exit", 260 | "erase", 261 | "update", 262 | "sep" 263 | }; 264 | 265 | const char R_root[] PROGMEM = "/"; 266 | const char R_wifi[] PROGMEM = "/wifi"; 267 | const char R_wifinoscan[] PROGMEM = "/0wifi"; 268 | const char R_wifisave[] PROGMEM = "/wifisave"; 269 | const char R_info[] PROGMEM = "/info"; 270 | const char R_param[] PROGMEM = "/param"; 271 | const char R_paramsave[] PROGMEM = "/paramsave"; 272 | const char R_restart[] PROGMEM = "/restart"; 273 | const char R_exit[] PROGMEM = "/exit"; 274 | const char R_close[] PROGMEM = "/close"; 275 | const char R_erase[] PROGMEM = "/erase"; 276 | const char R_status[] PROGMEM = "/status"; 277 | const char R_update[] PROGMEM = "/update"; 278 | const char R_updatedone[] PROGMEM = "/u"; 279 | 280 | 281 | //Strings 282 | const char S_ip[] PROGMEM = "ip"; 283 | const char S_gw[] PROGMEM = "gw"; 284 | const char S_sn[] PROGMEM = "sn"; 285 | const char S_dns[] PROGMEM = "dns"; 286 | 287 | // softap ssid default prefix 288 | #ifdef ESP8266 289 | const char S_ssidpre[] PROGMEM = "ESP"; 290 | #elif defined(ESP32) 291 | const char S_ssidpre[] PROGMEM = "ESP32"; 292 | #else 293 | const char S_ssidpre[] PROGMEM = "WM"; 294 | #endif 295 | 296 | //Tokens 297 | //@todo consolidate and reduce 298 | const char T_ss[] PROGMEM = "{"; // token start sentinel 299 | const char T_es[] PROGMEM = "}"; // token end sentinel 300 | const char T_1[] PROGMEM = "{1}"; // @token 1 301 | const char T_2[] PROGMEM = "{2}"; // @token 2 302 | const char T_3[] PROGMEM = "{3}"; // @token 2 303 | const char T_v[] PROGMEM = "{v}"; // @token v 304 | const char T_I[] PROGMEM = "{I}"; // @token I 305 | const char T_i[] PROGMEM = "{i}"; // @token i 306 | const char T_n[] PROGMEM = "{n}"; // @token n 307 | const char T_p[] PROGMEM = "{p}"; // @token p 308 | const char T_t[] PROGMEM = "{t}"; // @token t 309 | const char T_l[] PROGMEM = "{l}"; // @token l 310 | const char T_c[] PROGMEM = "{c}"; // @token c 311 | const char T_e[] PROGMEM = "{e}"; // @token e 312 | const char T_q[] PROGMEM = "{q}"; // @token q 313 | const char T_r[] PROGMEM = "{r}"; // @token r 314 | const char T_R[] PROGMEM = "{R}"; // @token R 315 | const char T_h[] PROGMEM = "{h}"; // @token h 316 | 317 | // http 318 | const char HTTP_HEAD_CL[] PROGMEM = "Content-Length"; 319 | const char HTTP_HEAD_CT[] PROGMEM = "text/html"; 320 | const char HTTP_HEAD_CT2[] PROGMEM = "text/plain"; 321 | const char HTTP_HEAD_CORS[] PROGMEM = "Access-Control-Allow-Origin"; 322 | const char HTTP_HEAD_CORS_ALLOW_ALL[] PROGMEM = "*"; 323 | 324 | const char * const WIFI_STA_STATUS[] PROGMEM 325 | { 326 | "WL_IDLE_STATUS", // 0 STATION_IDLE 327 | "WL_NO_SSID_AVAIL", // 1 STATION_NO_AP_FOUND 328 | "WL_SCAN_COMPLETED", // 2 329 | "WL_CONNECTED", // 3 STATION_GOT_IP 330 | "WL_CONNECT_FAILED", // 4 STATION_CONNECT_FAIL, STATION_WRONG_PASSWORD(NI) 331 | "WL_CONNECTION_LOST", // 5 332 | "WL_DISCONNECTED", // 6 333 | "WL_STATION_WRONG_PASSWORD" // 7 KLUDGE 334 | }; 335 | 336 | #ifdef ESP32 337 | const char * const AUTH_MODE_NAMES[] PROGMEM 338 | { 339 | "OPEN", 340 | "WEP", 341 | "WPA_PSK", 342 | "WPA2_PSK", 343 | "WPA_WPA2_PSK", 344 | "WPA2_ENTERPRISE", 345 | "MAX" 346 | }; 347 | #elif defined(ESP8266) 348 | const char * const AUTH_MODE_NAMES[] PROGMEM 349 | { 350 | "", 351 | "", 352 | "WPA_PSK", // 2 ENC_TYPE_TKIP 353 | "", 354 | "WPA2_PSK", // 4 ENC_TYPE_CCMP 355 | "WEP", // 5 ENC_TYPE_WEP 356 | "", 357 | "OPEN", //7 ENC_TYPE_NONE 358 | "WPA_WPA2_PSK", // 8 ENC_TYPE_AUTO 359 | }; 360 | #endif 361 | 362 | const char* const WIFI_MODES[] PROGMEM = { "NULL", "STA", "AP", "STA+AP" }; 363 | 364 | 365 | #ifdef ESP32 366 | // as 2.5.2 367 | // typedef struct { 368 | // char cc[3]; /**< country code string */ 369 | // uint8_t schan; /**< start channel */ 370 | // uint8_t nchan; /**< total channel number */ 371 | // int8_t max_tx_power; /**< This field is used for getting WiFi maximum transmitting power, call esp_wifi_set_max_tx_power to set the maximum transmitting power. */ 372 | // wifi_country_policy_t policy; /**< country policy */ 373 | // } wifi_country_t; 374 | const wifi_country_t WM_COUNTRY_US{"US",1,11,CONFIG_ESP32_PHY_MAX_TX_POWER,WIFI_COUNTRY_POLICY_AUTO}; 375 | const wifi_country_t WM_COUNTRY_CN{"CN",1,13,CONFIG_ESP32_PHY_MAX_TX_POWER,WIFI_COUNTRY_POLICY_AUTO}; 376 | const wifi_country_t WM_COUNTRY_JP{"JP",1,14,CONFIG_ESP32_PHY_MAX_TX_POWER,WIFI_COUNTRY_POLICY_AUTO}; 377 | #elif defined(ESP8266) && !defined(WM_NOCOUNTRY) 378 | // typedef struct { 379 | // char cc[3]; /**< country code string */ 380 | // uint8_t schan; /**< start channel */ 381 | // uint8_t nchan; /**< total channel number */ 382 | // uint8_t policy; /**< country policy */ 383 | // } wifi_country_t; 384 | const wifi_country_t WM_COUNTRY_US{"US",1,11,WIFI_COUNTRY_POLICY_AUTO}; 385 | const wifi_country_t WM_COUNTRY_CN{"CN",1,13,WIFI_COUNTRY_POLICY_AUTO}; 386 | const wifi_country_t WM_COUNTRY_JP{"JP",1,14,WIFI_COUNTRY_POLICY_AUTO}; 387 | #endif 388 | 389 | 390 | /* 391 | * ESP32 WiFi Events 392 | 393 | 0 SYSTEM_EVENT_WIFI_READY < ESP32 WiFi ready 394 | 1 SYSTEM_EVENT_SCAN_DONE < ESP32 finish scanning AP 395 | 2 SYSTEM_EVENT_STA_START < ESP32 station start 396 | 3 SYSTEM_EVENT_STA_STOP < ESP32 station stop 397 | 4 SYSTEM_EVENT_STA_CONNECTED < ESP32 station connected to AP 398 | 5 SYSTEM_EVENT_STA_DISCONNECTED < ESP32 station disconnected from AP 399 | 6 SYSTEM_EVENT_STA_AUTHMODE_CHANGE < the auth mode of AP connected by ESP32 station changed 400 | 7 SYSTEM_EVENT_STA_GOT_IP < ESP32 station got IP from connected AP 401 | 8 SYSTEM_EVENT_STA_LOST_IP < ESP32 station lost IP and the IP is reset to 0 402 | 9 SYSTEM_EVENT_STA_WPS_ER_SUCCESS < ESP32 station wps succeeds in enrollee mode 403 | 10 SYSTEM_EVENT_STA_WPS_ER_FAILED < ESP32 station wps fails in enrollee mode 404 | 11 SYSTEM_EVENT_STA_WPS_ER_TIMEOUT < ESP32 station wps timeout in enrollee mode 405 | 12 SYSTEM_EVENT_STA_WPS_ER_PIN < ESP32 station wps pin code in enrollee mode 406 | 13 SYSTEM_EVENT_AP_START < ESP32 soft-AP start 407 | 14 SYSTEM_EVENT_AP_STOP < ESP32 soft-AP stop 408 | 15 SYSTEM_EVENT_AP_STACONNECTED < a station connected to ESP32 soft-AP 409 | 16 SYSTEM_EVENT_AP_STADISCONNECTED < a station disconnected from ESP32 soft-AP 410 | 17 SYSTEM_EVENT_AP_STAIPASSIGNED < ESP32 soft-AP assign an IP to a connected station 411 | 18 SYSTEM_EVENT_AP_PROBEREQRECVED < Receive probe request packet in soft-AP interface 412 | 19 SYSTEM_EVENT_GOT_IP6 < ESP32 station or ap or ethernet interface v6IP addr is preferred 413 | 20 SYSTEM_EVENT_ETH_START < ESP32 ethernet start 414 | 21 SYSTEM_EVENT_ETH_STOP < ESP32 ethernet stop 415 | 22 SYSTEM_EVENT_ETH_CONNECTED < ESP32 ethernet phy link up 416 | 23 SYSTEM_EVENT_ETH_DISCONNECTED < ESP32 ethernet phy link down 417 | 24 SYSTEM_EVENT_ETH_GOT_IP < ESP32 ethernet got IP from connected AP 418 | 25 SYSTEM_EVENT_MAX 419 | */ 420 | 421 | #endif -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . --------------------------------------------------------------------------------