├── README.md ├── Circuit ├── BOM │ ├── 元件摆放位置.jpg │ └── HomeKitSwitchBom.xlsx └── 8266HomeKitSwitch │ ├── 8266HomeKitSwitch.PrjPcbStructure │ ├── MyLib.PcbLib │ ├── MyLib.SchLib │ ├── 8266HomeKitSwitch.PcbDoc │ └── 8266HomeKitSwitch.SchDoc ├── Code └── 8266HomeKitSwitch │ ├── lib │ ├── Arduino-HomeKit-ESP8266 │ │ ├── .gitattributes │ │ ├── src │ │ │ ├── constants.h │ │ │ ├── watchdog.h │ │ │ ├── pairing.h │ │ │ ├── base64.h │ │ │ ├── query_params.h │ │ │ ├── json.h │ │ │ ├── homekit_debug.c │ │ │ ├── storage.h │ │ │ ├── homekit │ │ │ │ ├── tlv.h │ │ │ │ └── homekit.h │ │ │ ├── esp_xpgm.h │ │ │ ├── wolfssl │ │ │ │ └── wolfcrypt │ │ │ │ │ ├── compress.h │ │ │ │ │ ├── md4.h │ │ │ │ │ ├── arc4.h │ │ │ │ │ ├── fips_test.h │ │ │ │ │ ├── md2.h │ │ │ │ │ ├── rabbit.h │ │ │ │ │ ├── ripemd.h │ │ │ │ │ ├── hc128.h │ │ │ │ │ ├── pkcs12.h │ │ │ │ │ ├── cpuid.h │ │ │ │ │ ├── signature.h │ │ │ │ │ ├── chacha.h │ │ │ │ │ ├── blake2.h │ │ │ │ │ ├── cmac.h │ │ │ │ │ ├── wolfmath.h │ │ │ │ │ ├── wc_encrypt.h │ │ │ │ │ ├── idea.h │ │ │ │ │ ├── visibility.h │ │ │ │ │ ├── coding.h │ │ │ │ │ ├── dsa.h │ │ │ │ │ ├── pwdbased.h │ │ │ │ │ ├── misc.h │ │ │ │ │ ├── chacha20_poly1305.h │ │ │ │ │ ├── dh.h │ │ │ │ │ ├── mpi_superclass.h │ │ │ │ │ ├── poly1305.h │ │ │ │ │ └── md5.h │ │ │ ├── watchdog.c │ │ │ ├── port.h │ │ │ ├── query_params.c │ │ │ ├── homekit_debug.h │ │ │ ├── user_settings.h │ │ │ ├── base64.c │ │ │ └── types.c │ │ ├── extras │ │ │ ├── preview.jpg │ │ │ ├── qq_group_qrcode.png │ │ │ └── ESP8266WiFi_nossl_noleak │ │ │ │ └── src │ │ │ │ ├── include │ │ │ │ ├── WiFiState.h │ │ │ │ ├── slist.h │ │ │ │ └── wl_definitions.h │ │ │ │ ├── ESP8266WiFiMulti.h │ │ │ │ ├── ESP8266WiFiAP.h │ │ │ │ ├── WiFiServer.h │ │ │ │ ├── ESP8266WiFiScan.h │ │ │ │ ├── ESP8266WiFi.h │ │ │ │ └── ESP8266WiFi.cpp │ │ ├── library.properties │ │ ├── .gitignore │ │ ├── library.json │ │ ├── examples │ │ │ ├── Example02_Switch │ │ │ │ ├── wifi_info.h │ │ │ │ ├── my_accessory.c │ │ │ │ └── Example02_Switch.ino │ │ │ ├── Example06_makesmart_lock │ │ │ │ ├── wifi_info.h │ │ │ │ ├── my_accessory.c │ │ │ │ └── Example06_makesmart_lock.ino │ │ │ ├── Example05_WS2812_Neopixel │ │ │ │ ├── wifi_info.h │ │ │ │ └── my_accessory.c │ │ │ ├── Example01_TemperatureSensor │ │ │ │ └── wifi_info.h │ │ │ ├── Example04_MultipleAccessories │ │ │ │ └── wifi_info.h │ │ │ ├── Example03_StatelessProgrammableSwitch │ │ │ │ ├── wifi_info.h │ │ │ │ └── my_accessory.c │ │ │ └── legacy │ │ │ │ ├── simplest_led │ │ │ │ ├── simplest_led.ino │ │ │ │ └── simplest_led_accessory.c │ │ │ │ └── simple_led │ │ │ │ └── ButtonDebounce.h │ │ ├── translations │ │ │ └── README_cn.md │ │ └── LICENSE │ ├── WiFiManager-master │ │ ├── extras │ │ │ ├── png_signal_strength_master.png │ │ │ ├── parse.js │ │ │ └── template.h │ │ ├── library.properties │ │ ├── .github │ │ │ ├── CONTRIBUTING.md │ │ │ ├── workflows │ │ │ │ ├── cpp_lint.yml │ │ │ │ └── compile_library.yml │ │ │ └── ISSUE_TEMPLATE.md │ │ ├── library.json │ │ ├── examples │ │ │ ├── Unique │ │ │ │ └── cb │ │ │ │ │ └── AnonymousCB.ino │ │ │ ├── NonBlocking │ │ │ │ ├── AutoConnectNonBlocking │ │ │ │ │ └── AutoConnectNonBlocking.ino │ │ │ │ ├── AutoConnectNonBlockingwParams │ │ │ │ │ └── AutoConnectNonBlockingwParams.ino │ │ │ │ └── OnDemandNonBlocking │ │ │ │ │ └── onDemandNonBlocking.ino │ │ │ ├── Old_examples │ │ │ │ ├── AutoConnectWithTimeout │ │ │ │ │ └── AutoConnectWithTimeout.ino │ │ │ │ ├── AutoConnectWithReset │ │ │ │ │ └── AutoConnectWithReset.ino │ │ │ │ ├── AutoConnectWithFeedback │ │ │ │ │ └── AutoConnectWithFeedback.ino │ │ │ │ └── AutoConnectWithStaticIP │ │ │ │ │ └── AutoConnectWithStaticIP.ino │ │ │ ├── OnDemand │ │ │ │ ├── OnDemandWebPortal │ │ │ │ │ └── onDemandWebPortal.ino │ │ │ │ └── OnDemandConfigPortal │ │ │ │ │ └── OnDemandConfigPortal.ino │ │ │ └── Basic │ │ │ │ └── Basic.ino │ │ ├── keywords.txt │ │ ├── LICENSE │ │ ├── .travis.yml │ │ └── travis │ │ │ └── common.sh │ ├── ESP_DoubleResetDetector │ │ ├── library.properties │ │ ├── keywords.txt │ │ ├── library.json │ │ ├── LICENSE │ │ ├── CONTRIBUTING.md │ │ ├── examples │ │ │ ├── ConfigOnDRD_ESP32_minimal │ │ │ │ └── ConfigOnDRD_ESP32_minimal.ino │ │ │ ├── ConfigOnDRD_ESP8266_minimal │ │ │ │ └── ConfigOnDRD_ESP8266_minimal.ino │ │ │ └── minimal │ │ │ │ └── minimal.ino │ │ └── platformio │ │ │ └── platformio.ini │ └── README │ ├── .gitignore │ ├── src │ ├── config.h │ ├── my_accessory.c │ └── main.cpp │ ├── .vscode │ ├── extensions.json │ └── launch.json │ ├── platformio.ini │ ├── test │ └── README │ └── include │ └── README └── LICENSE /README.md: -------------------------------------------------------------------------------- 1 | # HomeKitSwitch -------------------------------------------------------------------------------- /Circuit/BOM/元件摆放位置.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Homeless-Xu/HomeKitSwitch/main/Circuit/BOM/元件摆放位置.jpg -------------------------------------------------------------------------------- /Circuit/BOM/HomeKitSwitchBom.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Homeless-Xu/HomeKitSwitch/main/Circuit/BOM/HomeKitSwitchBom.xlsx -------------------------------------------------------------------------------- /Circuit/8266HomeKitSwitch/8266HomeKitSwitch.PrjPcbStructure: -------------------------------------------------------------------------------- 1 | Record=TopLevelDocument|FileName=8266HomeKitSwitch.SchDoc|SheetNumber=1 2 | -------------------------------------------------------------------------------- /Circuit/8266HomeKitSwitch/MyLib.PcbLib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Homeless-Xu/HomeKitSwitch/main/Circuit/8266HomeKitSwitch/MyLib.PcbLib -------------------------------------------------------------------------------- /Circuit/8266HomeKitSwitch/MyLib.SchLib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Homeless-Xu/HomeKitSwitch/main/Circuit/8266HomeKitSwitch/MyLib.SchLib -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | .vscode/.browse.c_cpp.db* 3 | .vscode/c_cpp_properties.json 4 | .vscode/launch.json 5 | .vscode/ipch 6 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/src/constants.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define DEVICE_ID_SIZE 36 4 | #define ACCESSORY_ID_SIZE 17 5 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/src/config.h: -------------------------------------------------------------------------------- 1 | #define AP_SSID "ESP HOMEKIT" 2 | #define AP_PASSWORD "88888888" 3 | #define AUTH_ID "111-11-111" 4 | -------------------------------------------------------------------------------- /Circuit/8266HomeKitSwitch/8266HomeKitSwitch.PcbDoc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Homeless-Xu/HomeKitSwitch/main/Circuit/8266HomeKitSwitch/8266HomeKitSwitch.PcbDoc -------------------------------------------------------------------------------- /Circuit/8266HomeKitSwitch/8266HomeKitSwitch.SchDoc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Homeless-Xu/HomeKitSwitch/main/Circuit/8266HomeKitSwitch/8266HomeKitSwitch.SchDoc -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/extras/preview.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Homeless-Xu/HomeKitSwitch/main/Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/extras/preview.jpg -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/extras/qq_group_qrcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Homeless-Xu/HomeKitSwitch/main/Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/extras/qq_group_qrcode.png -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/WiFiManager-master/extras/png_signal_strength_master.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Homeless-Xu/HomeKitSwitch/main/Code/8266HomeKitSwitch/lib/WiFiManager-master/extras/png_signal_strength_master.png -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/.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 | "unwantedRecommendations": [ 8 | "ms-vscode.cpptools-extension-pack" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/src/watchdog.h: -------------------------------------------------------------------------------- 1 | #ifndef WATCHDOG_H_ 2 | #define WATCHDOG_H_ 3 | 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | void watchdog_disable_all(); 10 | 11 | void watchdog_enable_all(); 12 | 13 | void watchdog_check_begin(); 14 | 15 | void watchdog_check_end(const char* message); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | 22 | #endif /* WATCHDOG_H_ */ 23 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/library.properties: -------------------------------------------------------------------------------- 1 | name=HomeKit-ESP8266 2 | version=1.2.0 3 | author=Mixiaoxiao 4 | maintainer=Mixiaoxiao 5 | sentence=Native Apple HomeKit accessory implementation for the ESP8266 Arduino core. 6 | paragraph=Native Apple HomeKit Accessory Implementation for the ESP8266 Arduino core. 7 | category=Communication 8 | url=https://github.com/Mixiaoxiao/Arduino-HomeKit-ESP8266.git 9 | architectures=esp8266 10 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/src/pairing.h: -------------------------------------------------------------------------------- 1 | #ifndef __PAIRING_H__ 2 | #define __PAIRING_H__ 3 | 4 | #include "constants.h" 5 | #include "crypto.h" 6 | 7 | 8 | typedef enum { 9 | pairing_permissions_admin = (1 << 0), 10 | } pairing_permissions_t; 11 | 12 | typedef struct { 13 | int id; 14 | char device_id[DEVICE_ID_SIZE + 1]; 15 | ed25519_key device_key; 16 | pairing_permissions_t permissions; 17 | } pairing_t; 18 | 19 | #endif // __PAIRING_H__ 20 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/WiFiManager-master/library.properties: -------------------------------------------------------------------------------- 1 | name=WiFiManager 2 | version=2.0.11-beta 3 | author=tzapu 4 | maintainer=tablatronix 5 | sentence=WiFi Configuration manager with web configuration portal for Espressif ESPx boards, by tzapu 6 | paragraph=Library for configuring ESP8266/ESP32 modules WiFi credentials and custom parameters at runtime with captive portal. 7 | category=Communication 8 | url=https://github.com/tzapu/WiFiManager.git 9 | architectures=esp8266,esp32 10 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | # Others 35 | .DS_STORE 36 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/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:esp12e] 12 | platform = espressif8266 13 | board = esp12e 14 | framework = arduino 15 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/extras/ESP8266WiFi_nossl_noleak/src/include/WiFiState.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef WIFISTATE_H_ 3 | #define WIFISTATE_H_ 4 | 5 | #include 6 | #include 7 | 8 | struct WiFiState 9 | { 10 | uint32_t crc; 11 | struct 12 | { 13 | station_config fwconfig; 14 | ip_info ip; 15 | ip_addr_t dns[2]; 16 | ip_addr_t ntp[2]; 17 | WiFiMode_t mode; 18 | uint8_t channel; 19 | bool persistent; 20 | } state; 21 | }; 22 | 23 | #endif // WIFISTATE_H_ 24 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PlatformIO Test Runner 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/en/latest/advanced/unit-testing/index.html 12 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/src/base64.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | #include 8 | 9 | 10 | size_t base64_encoded_size(const unsigned char* data, size_t size); 11 | size_t base64_decoded_size(const unsigned char* encoded_data, size_t encoded_size); 12 | //multiple definition of `base64_decode'; 13 | int base64_encode_(const unsigned char* data, size_t data_size, unsigned char *encoded_data); 14 | int base64_decode_(const unsigned char* encoded_data, size_t encoded_size, unsigned char *data); 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/src/query_params.h: -------------------------------------------------------------------------------- 1 | #ifndef __HOMEKIT_QUERY_PARAMS__ 2 | #define __HOMEKIT_QUERY_PARAMS__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | typedef struct _query_param { 9 | char *name; 10 | char *value; 11 | 12 | struct _query_param *next; 13 | } query_param_t; 14 | 15 | query_param_t *query_params_parse(const char *s); 16 | query_param_t *query_params_find(query_param_t *params, const char *name); 17 | void query_params_free(query_param_t *params); 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | 23 | #endif // __HOMEKIT_QUERY_PARAMS__ 24 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/WiFiManager-master/.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing PRs and ISSUES 2 | 3 | The development branch is the active branch, no features or bugs will be fixed against master ( hotfixes may be considered ). 4 | 5 | Please test against development branch before submitting issues, issues against master will be closed, 6 | 7 | PRs against master may be kept open if provides something useful to other members. 8 | 9 | Please open issues before sumbitting PRs against development, as commits might be occuring very frequently. 10 | 11 | ### Documentation is in progress 12 | https://github.com/tzapu/WiFiManager/issues/500 13 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name":"HomeKit-ESP8266", 3 | "description":"Apple HomeKit accessory server library for the ESP8266 Arduino core.", 4 | "keywords":"homekit,esp8266,esp32,apple homekit", 5 | "authors": 6 | { 7 | "name": "Mixiaoxiao (Wang Bin)", 8 | "maintainer": true 9 | }, 10 | "repository": 11 | { 12 | "type": "git", 13 | "url": "https://github.com/Mixiaoxiao/Arduino-HomeKit-ESP8266.git" 14 | }, 15 | "version": "1.2.0", 16 | "license": "MIT", 17 | "frameworks": "arduino", 18 | "platforms": "espressif8266", 19 | "build": { 20 | "libCompatMode": 2 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/ESP_DoubleResetDetector/library.properties: -------------------------------------------------------------------------------- 1 | name=ESP_DoubleResetDetector 2 | version=1.1.1 3 | author=Khoi Hoang 4 | maintainer=Khoi Hoang 5 | license=MIT 6 | sentence=Library to detect a double reset within a predetermined time, using RTC Memory, EEPROM, LittleFS or SPIFFS for ESP8266 and ESP32 7 | paragraph=An alternative start-up mode can be used. One example use is to allow re-configuration of device's WiFi credentials. 8 | category=Device,Control 9 | url=https://github.com/khoih-prog/ESP_DoubleResetDetector 10 | architectures=esp8266,esp32 11 | includes=ESP_DoubleResetDetector.h 12 | depends=LittleFS_esp32 13 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/ESP_DoubleResetDetector/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | DoubleResetDetector 9 | 10 | ####################################### 11 | # Methods and Functions (KEYWORD2) 12 | ####################################### 13 | detectDoubleReset KEYWORD2 14 | loop KEYWORD2 15 | stop KEYWORD2 16 | ####################################### 17 | # Instances (KEYWORD2) 18 | ####################################### 19 | 20 | ####################################### 21 | # Constants (LITERAL1) 22 | ####################################### 23 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/WiFiManager-master/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "WiFiManager", 3 | "version": "2.0.11-beta", 4 | "keywords": "wifi,wi-fi,esp,esp8266,esp32,espressif8266,espressif32,nodemcu,wemos,arduino", 5 | "description": "WiFi Configuration manager with web configuration portal for ESP boards", 6 | "authors": 7 | [ 8 | { 9 | "name": "tzapu", 10 | "url": "https://github.com/tzapu" 11 | }, 12 | { 13 | "name": "tablatronix", 14 | "url": "https://github.com/tablatronix", 15 | "maintainer": true 16 | } 17 | ], 18 | "repository": 19 | { 20 | "type": "git", 21 | "url": "https://github.com/tzapu/WiFiManager.git" 22 | }, 23 | "frameworks": "arduino", 24 | "platforms": 25 | [ 26 | "espressif8266", 27 | "espressif32" 28 | ] 29 | } -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/extras/ESP8266WiFi_nossl_noleak/src/include/slist.h: -------------------------------------------------------------------------------- 1 | #ifndef SLIST_H 2 | #define SLIST_H 3 | 4 | template 5 | class SList { 6 | public: 7 | SList() : _next(0) { } 8 | 9 | protected: 10 | 11 | static void _add(T* self) { 12 | T* tmp = _s_first; 13 | _s_first = self; 14 | self->_next = tmp; 15 | } 16 | 17 | static void _remove(T* self) { 18 | if (_s_first == self) { 19 | _s_first = self->_next; 20 | self->_next = 0; 21 | return; 22 | } 23 | 24 | for (T* prev = _s_first; prev->_next; prev = prev->_next) { 25 | if (prev->_next == self) { 26 | prev->_next = self->_next; 27 | self->_next = 0; 28 | return; 29 | } 30 | } 31 | } 32 | 33 | static T* _s_first; 34 | T* _next; 35 | }; 36 | 37 | 38 | #endif //SLIST_H 39 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/WiFiManager-master/examples/Unique/cb/AnonymousCB.ino: -------------------------------------------------------------------------------- 1 | #include // https://github.com/tzapu/WiFiManager 2 | 3 | bool _enteredConfigMode = false; 4 | 5 | void setup(){ 6 | Serial.begin(115200); 7 | WiFiManager wifiManager; 8 | 9 | // wifiManager.setAPCallback([this](WiFiManager* wifiManager) { 10 | wifiManager.setAPCallback([&](WiFiManager* wifiManager) { 11 | Serial.printf("Entered config mode:ip=%s, ssid='%s'\n", 12 | WiFi.softAPIP().toString().c_str(), 13 | wifiManager->getConfigPortalSSID().c_str()); 14 | _enteredConfigMode = true; 15 | }); 16 | wifiManager.resetSettings(); 17 | if (!wifiManager.autoConnect()) { 18 | Serial.printf("*** Failed to connect and hit timeout\n"); 19 | ESP.restart(); 20 | delay(1000); 21 | } 22 | } 23 | 24 | void loop(){ 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/examples/Example02_Switch/wifi_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * wifi_info.h 3 | * 4 | * Created on: 2020-05-15 5 | * Author: Mixiaoxiao (Wang Bin) 6 | */ 7 | 8 | #ifndef WIFI_INFO_H_ 9 | #define WIFI_INFO_H_ 10 | 11 | #if defined(ESP8266) 12 | #include 13 | #elif defined(ESP32) 14 | #include 15 | #endif 16 | 17 | const char *ssid = "your-ssid"; 18 | const char *password = "your-password"; 19 | 20 | void wifi_connect() { 21 | WiFi.persistent(false); 22 | WiFi.mode(WIFI_STA); 23 | WiFi.setAutoReconnect(true); 24 | WiFi.begin(ssid, password); 25 | Serial.println("WiFi connecting..."); 26 | while (!WiFi.isConnected()) { 27 | delay(100); 28 | Serial.print("."); 29 | } 30 | Serial.print("\n"); 31 | Serial.printf("WiFi connected, IP: %s\n", WiFi.localIP().toString().c_str()); 32 | } 33 | 34 | #endif /* WIFI_INFO_H_ */ 35 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/examples/Example06_makesmart_lock/wifi_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * wifi_info.h 3 | * 4 | * Created on: 2020-05-15 5 | * Author: Mixiaoxiao (Wang Bin) 6 | */ 7 | 8 | #ifndef WIFI_INFO_H_ 9 | #define WIFI_INFO_H_ 10 | 11 | #if defined(ESP8266) 12 | #include 13 | #elif defined(ESP32) 14 | #include 15 | #endif 16 | 17 | const char *ssid = "your-ssid"; 18 | const char *password = "your-password"; 19 | 20 | void wifi_connect() { 21 | WiFi.persistent(false); 22 | WiFi.mode(WIFI_STA); 23 | WiFi.setAutoReconnect(true); 24 | WiFi.begin(ssid, password); 25 | Serial.println("WiFi connecting..."); 26 | while (!WiFi.isConnected()) { 27 | delay(100); 28 | Serial.print("."); 29 | } 30 | Serial.print("\n"); 31 | Serial.printf("WiFi connected, IP: %s\n", WiFi.localIP().toString().c_str()); 32 | } 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/examples/Example05_WS2812_Neopixel/wifi_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * wifi_info.h 3 | * 4 | * Created on: 2020-05-15 5 | * Author: Mixiaoxiao (Wang Bin) 6 | */ 7 | 8 | #ifndef WIFI_INFO_H_ 9 | #define WIFI_INFO_H_ 10 | 11 | #if defined(ESP8266) 12 | #include 13 | #elif defined(ESP32) 14 | #include 15 | #endif 16 | 17 | const char *ssid = "your-ssid"; 18 | const char *password = "your-password"; 19 | 20 | void wifi_connect() { 21 | WiFi.persistent(false); 22 | WiFi.mode(WIFI_STA); 23 | WiFi.setAutoReconnect(true); 24 | WiFi.begin(ssid, password); 25 | Serial.println("WiFi connecting..."); 26 | while (!WiFi.isConnected()) { 27 | delay(100); 28 | Serial.print("."); 29 | } 30 | Serial.print("\n"); 31 | Serial.printf("WiFi connected, IP: %s\n", WiFi.localIP().toString().c_str()); 32 | } 33 | 34 | #endif /* WIFI_INFO_H_ */ 35 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/examples/Example01_TemperatureSensor/wifi_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * wifi_info.h 3 | * 4 | * Created on: 2020-05-15 5 | * Author: Mixiaoxiao (Wang Bin) 6 | */ 7 | 8 | #ifndef WIFI_INFO_H_ 9 | #define WIFI_INFO_H_ 10 | 11 | #if defined(ESP8266) 12 | #include 13 | #elif defined(ESP32) 14 | #include 15 | #endif 16 | 17 | const char *ssid = "your-ssid"; 18 | const char *password = "your-password"; 19 | 20 | void wifi_connect() { 21 | WiFi.persistent(false); 22 | WiFi.mode(WIFI_STA); 23 | WiFi.setAutoReconnect(true); 24 | WiFi.begin(ssid, password); 25 | Serial.println("WiFi connecting..."); 26 | while (!WiFi.isConnected()) { 27 | delay(100); 28 | Serial.print("."); 29 | } 30 | Serial.print("\n"); 31 | Serial.printf("WiFi connected, IP: %s\n", WiFi.localIP().toString().c_str()); 32 | } 33 | 34 | #endif /* WIFI_INFO_H_ */ 35 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/examples/Example04_MultipleAccessories/wifi_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * wifi_info.h 3 | * 4 | * Created on: 2020-05-15 5 | * Author: Mixiaoxiao (Wang Bin) 6 | */ 7 | 8 | #ifndef WIFI_INFO_H_ 9 | #define WIFI_INFO_H_ 10 | 11 | #if defined(ESP8266) 12 | #include 13 | #elif defined(ESP32) 14 | #include 15 | #endif 16 | 17 | const char *ssid = "your-ssid"; 18 | const char *password = "your-password"; 19 | 20 | void wifi_connect() { 21 | WiFi.persistent(false); 22 | WiFi.mode(WIFI_STA); 23 | WiFi.setAutoReconnect(true); 24 | WiFi.begin(ssid, password); 25 | Serial.println("WiFi connecting..."); 26 | while (!WiFi.isConnected()) { 27 | delay(100); 28 | Serial.print("."); 29 | } 30 | Serial.print("\n"); 31 | Serial.printf("WiFi connected, IP: %s\n", WiFi.localIP().toString().c_str()); 32 | } 33 | 34 | #endif /* WIFI_INFO_H_ */ 35 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/examples/Example03_StatelessProgrammableSwitch/wifi_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * wifi_info.h 3 | * 4 | * Created on: 2020-05-15 5 | * Author: Mixiaoxiao (Wang Bin) 6 | */ 7 | 8 | #ifndef WIFI_INFO_H_ 9 | #define WIFI_INFO_H_ 10 | 11 | #if defined(ESP8266) 12 | #include 13 | #elif defined(ESP32) 14 | #include 15 | #endif 16 | 17 | const char *ssid = "your-ssid"; 18 | const char *password = "your-password"; 19 | 20 | void wifi_connect() { 21 | WiFi.persistent(false); 22 | WiFi.mode(WIFI_STA); 23 | WiFi.setAutoReconnect(true); 24 | WiFi.begin(ssid, password); 25 | Serial.println("WiFi connecting..."); 26 | while (!WiFi.isConnected()) { 27 | delay(100); 28 | Serial.print("."); 29 | } 30 | Serial.print("\n"); 31 | Serial.printf("WiFi connected, IP: %s\n", WiFi.localIP().toString().c_str()); 32 | } 33 | 34 | #endif /* WIFI_INFO_H_ */ 35 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/WiFiManager-master/.github/workflows/cpp_lint.yml: -------------------------------------------------------------------------------- 1 | name: cpplint 2 | 3 | on: 4 | push: 5 | paths-ignore: 6 | - '.github/workflows/compile_*.yml' 7 | pull_request: 8 | paths-ignore: 9 | - '.github/workflows/compile_*.yml' 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v2 15 | - name: cpplint 16 | uses: reviewdog/action-cpplint@master 17 | with: 18 | github_token: ${{ secrets.GITHUB_TOKEN }} 19 | reporter: github-pr-check 20 | flags: --linelength=100 21 | target: . 22 | filter: "-whitespace/tab\ 23 | ,-readability/braces\ 24 | ,-whitespace/braces\ 25 | ,-whitespace/comments\ 26 | ,-whitespace/indent\ 27 | ,-whitespace/newline\ 28 | ,-whitespace/operators\ 29 | ,-whitespace/parens\ 30 | " 31 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/translations/README_cn.md: -------------------------------------------------------------------------------- 1 | # Arduino HomeKit ESP8266 2 | 3 | 4 | ## Apple HomeKit accessory server library for ESP8266 Arduino 5 | 6 | 本库是适用于[ESP8266 Arduino core](https://github.com/esp8266/Arduino) 的原生 Apple HomeKit 协议实现,无需额外的homeassistant、homebridge等服务器配置。可制作使用ESP8266芯片的独立运行的非商用的HomeKit配件。 7 | 8 | 本库的开发主要来自适用于[ESP-OPEN-RTOS](https://github.com/SuperHouse/esp-open-rtos) 的 [esp-homekit](https://github.com/maximkulkin/esp-homekit) 库,进行修改适配后适用于Arduino环境,大大降低上手难度与开发成本。另外,强烈推荐使用sloeber(for Eclipse), PlatformIO等较为现代化的IDE来敲代码。 9 | 10 | 适用于ESP32 Arduino的版本请移步[Arduino-HomeKit-ESP32](https://github.com/Mixiaoxiao/Arduino-HomeKit-ESP32). 运行在ESP32上的HomeKit性能是ESP8266的近10倍。 11 | 12 | 其他技术相关说明含有大量专用名词,不适合翻译,请参见原始的English版本。 13 | 14 | 15 | ## QQ群:686409089 16 | 17 | 更多对于ESP8266/ESP32开发以及HomeKit库的使用和交流,欢迎大家加群讨论: 18 | 19 | ![QQGroup](https://raw.github.com/Mixiaoxiao/Arduino-HomeKit-ESP8266/master/extras/qq_group_qrcode.png) 20 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/WiFiManager-master/examples/NonBlocking/AutoConnectNonBlocking/AutoConnectNonBlocking.ino: -------------------------------------------------------------------------------- 1 | #include // https://github.com/tzapu/WiFiManager 2 | WiFiManager wm; 3 | 4 | void setup() { 5 | WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP 6 | // put your setup code here, to run once: 7 | Serial.begin(115200); 8 | 9 | //reset settings - wipe credentials for testing 10 | //wm.resetSettings(); 11 | 12 | wm.setConfigPortalBlocking(false); 13 | wm.setConfigPortalTimeout(60); 14 | //automatically connect using saved credentials if they exist 15 | //If connection fails it starts an access point with the specified name 16 | if(wm.autoConnect("AutoConnectAP")){ 17 | Serial.println("connected...yeey :)"); 18 | } 19 | else { 20 | Serial.println("Configportal running"); 21 | } 22 | } 23 | 24 | void loop() { 25 | wm.process(); 26 | // put your main code here, to run repeatedly: 27 | } 28 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/WiFiManager-master/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For WifiManager 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | WiFiManager KEYWORD1 10 | WiFiManagerParameter KEYWORD1 11 | 12 | 13 | ####################################### 14 | # Methods and Functions (KEYWORD2) 15 | ####################################### 16 | autoConnect KEYWORD2 17 | getSSID KEYWORD2 18 | getPassword KEYWORD2 19 | getConfigPortalSSID KEYWORD2 20 | resetSettings KEYWORD2 21 | setConfigPortalTimeout KEYWORD2 22 | setConnectTimeout KEYWORD2 23 | setDebugOutput KEYWORD2 24 | setMinimumSignalQuality KEYWORD2 25 | setAPStaticIPConfig KEYWORD2 26 | setSTAStaticIPConfig KEYWORD2 27 | setAPCallback KEYWORD2 28 | setSaveConfigCallback KEYWORD2 29 | addParameter KEYWORD2 30 | getID KEYWORD2 31 | getValue KEYWORD2 32 | getPlaceholder KEYWORD2 33 | getValueLength KEYWORD2 34 | 35 | ####################################### 36 | # Constants (LITERAL1) 37 | ####################################### 38 | 39 | # LITERAL1 40 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/ESP_DoubleResetDetector/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ESP_DoubleResetDetector", 3 | "version": "1.1.1", 4 | "keywords": "rtc,eeprom,littlefs,spiffs,reset,data,esp32,esp8266,double-reset,detector", 5 | "description": "Library to detect a double reset within a predetermined time, using RTC Memory, EEPROM, LittleFS or SPIFFS for ESP8266 and ESP32", 6 | "authors": 7 | { 8 | "name": "Khoi Hoang", 9 | "url": "https://github.com/khoih-prog", 10 | "maintainer": true 11 | }, 12 | "repository": 13 | { 14 | "type": "git", 15 | "url": "https://github.com/khoih-prog/ESP_DoubleResetDetector" 16 | }, 17 | "homepage": "https://github.com/khoih-prog/ESP_DoubleResetDetector", 18 | "export": { 19 | "exclude": [ 20 | "linux", 21 | "extras", 22 | "tests" 23 | ] 24 | }, 25 | "dependencies": 26 | [ 27 | { 28 | "owner": "lorol", 29 | "name": "LittleFS_esp32", 30 | "version": "^1.0.5", 31 | "platforms": ["espressif32"] 32 | } 33 | ], 34 | "frameworks": "arduino", 35 | "platforms": [ "espressif32", "espressif8266" ], 36 | "examples": "examples/*/*/*.ino" 37 | } 38 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/ESP_DoubleResetDetector/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Khoi Hoang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Mixiaoxiao(谜小小) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/WiFiManager-master/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 tzapu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/src/json.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | #include 8 | 9 | struct json_stream; 10 | typedef struct json_stream json_stream; 11 | 12 | typedef void (*json_flush_callback)(uint8_t *buffer, size_t size, void *context); 13 | 14 | json_stream *json_new(size_t buffer_size, json_flush_callback on_flush, void *context); 15 | void json_free(json_stream *json); 16 | 17 | void json_flush(json_stream *json); 18 | 19 | void json_object_start(json_stream *json); 20 | void json_object_end(json_stream *json); 21 | 22 | void json_array_start(json_stream *json); 23 | void json_array_end(json_stream *json); 24 | 25 | void json_integer(json_stream *json, int x); 26 | void json_uint8(json_stream *json, uint8_t x); 27 | void json_uint16(json_stream *json, uint16_t x); 28 | void json_uint32(json_stream *json, uint32_t x); 29 | void json_uint64(json_stream *json, uint64_t x); 30 | void json_float(json_stream *json, float x); 31 | void json_string(json_stream *json, const char *x); 32 | void json_boolean(json_stream *json, bool x); 33 | void json_null(json_stream *json); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/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 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/WiFiManager-master/.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## PLEASE TRY DEVELOPMENT BRANCH before submitting bugs on release or master, in case they were already fixed. ## 2 | 3 | Issues without basic info will be ignored or closed! 4 | 5 | Please fill the info fields, it helps to get you faster support ;) 6 | 7 | if you have a stack dump decode it: 8 | https://github.com/esp8266/Arduino/blob/master/doc/Troubleshooting/stack_dump.rst 9 | 10 | for better debug messages: 11 | https://github.com/esp8266/Arduino/blob/master/doc/Troubleshooting/debugging.rst 12 | 13 | ----------------------------- Remove above ----------------------------- 14 | 15 | ### Basic Infos 16 | 17 | #### Hardware 18 | WiFimanager Branch/Release: Master 19 | 20 | Esp8266/Esp32: 21 | 22 | Hardware: ESP-12e, esp01, esp25 23 | 24 | Core Version: 2.4.0, staging 25 | 26 | ### Description 27 | 28 | Problem description 29 | 30 | ### Settings in IDE 31 | 32 | Module: NodeMcu, Wemos D1 33 | 34 | Additional libraries: 35 | 36 | ### Sketch 37 | 38 | ```cpp 39 | #BEGIN 40 | #include 41 | 42 | void setup() { 43 | 44 | } 45 | 46 | void loop() { 47 | 48 | } 49 | #END 50 | ``` 51 | 52 | ### Debug Messages 53 | 54 | ``` 55 | messages here 56 | ``` 57 | 58 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/src/homekit_debug.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "homekit_debug.h" 5 | 6 | 7 | char *binary_to_string(const byte *data, size_t size) { 8 | int i; 9 | 10 | size_t buffer_size = 1; // 1 char for eos 11 | for (i=0; i= 32 && data[i] < 128) ? 1 : 4); 13 | 14 | char *buffer = malloc(buffer_size); 15 | 16 | int pos = 0; 17 | for (i=0; i= 128) { 22 | size_t printed = snprintf(&buffer[pos], buffer_size - pos, "\\x%02X", data[i]); 23 | if (printed > 0) { 24 | pos += printed; 25 | } 26 | } else { 27 | buffer[pos++] = data[i]; 28 | } 29 | } 30 | buffer[pos] = 0; 31 | 32 | return buffer; 33 | } 34 | 35 | 36 | void print_binary(const char *prompt, const byte *data, size_t size) { 37 | #ifdef HOMEKIT_DEBUG 38 | char *buffer = binary_to_string(data, size); 39 | printf("%s (%d bytes): \"%s\"\n", prompt, (int)size, buffer); 40 | free(buffer); 41 | #endif 42 | } 43 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/src/storage.h: -------------------------------------------------------------------------------- 1 | #ifndef __STORAGE_H__ 2 | #define __STORAGE_H__ 3 | 4 | //#include "EEPROM.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #include "pairing.h" 11 | 12 | int homekit_storage_reset(); 13 | 14 | int homekit_storage_init(); 15 | 16 | void homekit_storage_save_accessory_id(const char *accessory_id); 17 | int homekit_storage_load_accessory_id(char *data); 18 | 19 | void homekit_storage_save_accessory_key(const ed25519_key *key); 20 | int homekit_storage_load_accessory_key(ed25519_key *key); 21 | 22 | bool homekit_storage_can_add_pairing(); 23 | int homekit_storage_add_pairing(const char *device_id, const ed25519_key *device_key, byte permissions); 24 | int homekit_storage_update_pairing(const char *device_id, byte permissions); 25 | int homekit_storage_remove_pairing(const char *device_id); 26 | int homekit_storage_find_pairing(const char *device_id, pairing_t *pairing); 27 | 28 | typedef struct { 29 | int idx; 30 | } pairing_iterator_t; 31 | 32 | 33 | void homekit_storage_pairing_iterator_init(pairing_iterator_t *it); 34 | int homekit_storage_next_pairing(pairing_iterator_t *it, pairing_t *pairing); 35 | void homekit_storage_pairing_iterator_done(pairing_iterator_t *iterator); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | #endif // __STORAGE_H__ 41 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/WiFiManager-master/examples/NonBlocking/AutoConnectNonBlockingwParams/AutoConnectNonBlockingwParams.ino: -------------------------------------------------------------------------------- 1 | #include // https://github.com/tzapu/WiFiManager 2 | WiFiManager wm; 3 | WiFiManagerParameter custom_mqtt_server("server", "mqtt server", "", 40); 4 | 5 | void setup() { 6 | WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP 7 | // put your setup code here, to run once: 8 | Serial.begin(115200); 9 | 10 | //reset settings - wipe credentials for testing 11 | //wm.resetSettings(); 12 | wm.addParameter(&custom_mqtt_server); 13 | wm.setConfigPortalBlocking(false); 14 | wm.setSaveParamsCallback(saveParamsCallback); 15 | 16 | //automatically connect using saved credentials if they exist 17 | //If connection fails it starts an access point with the specified name 18 | if(wm.autoConnect("AutoConnectAP")){ 19 | Serial.println("connected...yeey :)"); 20 | } 21 | else { 22 | Serial.println("Configportal running"); 23 | } 24 | } 25 | 26 | void loop() { 27 | wm.process(); 28 | // put your main code here, to run repeatedly: 29 | } 30 | 31 | void saveParamsCallback () { 32 | Serial.println("Get Params:"); 33 | Serial.print(custom_mqtt_server.getID()); 34 | Serial.print(" : "); 35 | Serial.println(custom_mqtt_server.getValue()); 36 | } 37 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/WiFiManager-master/examples/Old_examples/AutoConnectWithTimeout/AutoConnectWithTimeout.ino: -------------------------------------------------------------------------------- 1 | #include // https://github.com/tzapu/WiFiManager 2 | 3 | void setup() { 4 | // put your setup code here, to run once: 5 | Serial.begin(115200); 6 | 7 | //WiFiManager 8 | //Local intialization. Once its business is done, there is no need to keep it around 9 | WiFiManager wifiManager; 10 | //reset settings - for testing 11 | //wifiManager.resetSettings(); 12 | 13 | //sets timeout until configuration portal gets turned off 14 | //useful to make it all retry or go to sleep 15 | //in seconds 16 | wifiManager.setConfigPortalTimeout(180); 17 | 18 | //fetches ssid and pass and tries to connect 19 | //if it does not connect it starts an access point with the specified name 20 | //here "AutoConnectAP" 21 | //and goes into a blocking loop awaiting configuration 22 | if(!wifiManager.autoConnect("AutoConnectAP")) { 23 | Serial.println("failed to connect and hit timeout"); 24 | delay(3000); 25 | //reset and try again, or maybe put it to deep sleep 26 | ESP.restart(); 27 | delay(5000); 28 | } 29 | 30 | //if you get here you have connected to the WiFi 31 | Serial.println("connected...yeey :)"); 32 | 33 | } 34 | 35 | void loop() { 36 | // put your main code here, to run repeatedly: 37 | 38 | } 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2022, Yin Baiyuan 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/src/homekit/tlv.h: -------------------------------------------------------------------------------- 1 | #ifndef __TLV_H__ 2 | #define __TLV_H__ 3 | 4 | #define __need_size_t 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | typedef unsigned char byte; 15 | 16 | typedef struct _tlv { 17 | struct _tlv *next; 18 | byte type; 19 | byte *value; 20 | size_t size; 21 | } tlv_t; 22 | 23 | 24 | typedef struct { 25 | tlv_t *head; 26 | } tlv_values_t; 27 | 28 | 29 | tlv_values_t *tlv_new(); 30 | 31 | void tlv_free(tlv_values_t *values); 32 | 33 | int tlv_add_value(tlv_values_t *values, byte type, const byte *value, size_t size); 34 | int tlv_add_string_value(tlv_values_t *values, byte type, const char *value); 35 | int tlv_add_integer_value(tlv_values_t *values, byte type, size_t size, int value); 36 | int tlv_add_tlv_value(tlv_values_t *values, byte type, tlv_values_t *value); 37 | 38 | tlv_t *tlv_get_value(const tlv_values_t *values, byte type); 39 | int tlv_get_integer_value(const tlv_values_t *values, byte type, int def); 40 | tlv_values_t *tlv_get_tlv_value(const tlv_values_t *values, byte type); 41 | 42 | int tlv_format(const tlv_values_t *values, byte *buffer, size_t *size); 43 | 44 | int tlv_parse(const byte *buffer, size_t length, tlv_values_t *values); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif // __TLV_H__ 51 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/WiFiManager-master/examples/OnDemand/OnDemandWebPortal/onDemandWebPortal.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * OnDemandWebPortal.ino 3 | * example of running the webportal (always NON blocking) 4 | */ 5 | #include // https://github.com/tzapu/WiFiManager 6 | 7 | // select which pin will trigger the configuration portal when set to LOW 8 | #define TRIGGER_PIN 0 9 | 10 | WiFiManager wm; 11 | 12 | bool portalRunning = false; 13 | 14 | void setup() { 15 | WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP 16 | // put your setup code here, to run once 17 | Serial.begin(115200); 18 | Serial.println("\n Starting"); 19 | pinMode(TRIGGER_PIN, INPUT_PULLUP); 20 | } 21 | 22 | void loop() { 23 | checkButton(); 24 | // put your main code here, to run repeatedly: 25 | } 26 | 27 | void checkButton(){ 28 | // is auto timeout portal running 29 | if(portalRunning){ 30 | wm.process(); 31 | } 32 | 33 | // is configuration portal requested? 34 | if(digitalRead(TRIGGER_PIN) == LOW) { 35 | delay(50); 36 | if(digitalRead(TRIGGER_PIN) == LOW) { 37 | if(!portalRunning){ 38 | Serial.println("Button Pressed, Starting Portal"); 39 | wm.startWebPortal(); 40 | portalRunning = true; 41 | } 42 | else{ 43 | Serial.println("Button Pressed, Stopping Portal"); 44 | wm.stopWebPortal(); 45 | portalRunning = false; 46 | } 47 | } 48 | } 49 | } 50 | 51 | 52 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/WiFiManager-master/examples/Old_examples/AutoConnectWithReset/AutoConnectWithReset.ino: -------------------------------------------------------------------------------- 1 | #include // this needs to be first, or it all crashes and burns... 2 | #include // https://github.com/tzapu/WiFiManager 3 | 4 | void setup() { 5 | // put your setup code here, to run once: 6 | Serial.begin(115200); 7 | Serial.println(); 8 | 9 | //WiFiManager 10 | //Local intialization. Once its business is done, there is no need to keep it around 11 | WiFiManager wifiManager; 12 | 13 | //exit after config instead of connecting 14 | wifiManager.setBreakAfterConfig(true); 15 | 16 | //reset settings - for testing 17 | //wifiManager.resetSettings(); 18 | 19 | 20 | //tries to connect to last known settings 21 | //if it does not connect it starts an access point with the specified name 22 | //here "AutoConnectAP" with password "password" 23 | //and goes into a blocking loop awaiting configuration 24 | if (!wifiManager.autoConnect("AutoConnectAP", "password")) { 25 | Serial.println("failed to connect, we should reset as see if it connects"); 26 | delay(3000); 27 | ESP.restart(); 28 | delay(5000); 29 | } 30 | 31 | //if you get here you have connected to the WiFi 32 | Serial.println("connected...yeey :)"); 33 | 34 | 35 | Serial.println("local ip"); 36 | Serial.println(WiFi.localIP()); 37 | } 38 | 39 | void loop() { 40 | // put your main code here, to run repeatedly: 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/src/esp_xpgm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * xpgm.h 3 | * 4 | * Created on: 2020-03-08 5 | * Author: Wang Bin 6 | */ 7 | 8 | #ifndef ESP_XPGM_H_ 9 | #define ESP_XPGM_H_ 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | //see "osapi.h" 20 | /* 21 | This function works only after Serial.setDebugOutput(true); ? 22 | otherwise Serial prints nothing. 23 | #define esp_printf(fmt, ...) do { \ 24 | static const char flash_str[] ICACHE_RODATA_ATTR STORE_ATTR = fmt; \ 25 | os_printf_plus(flash_str, ##__VA_ARGS__); \ 26 | } while(0)*/ 27 | 28 | #define XPGM_PRINTF(fmt, ...) printf_P(PSTR(fmt) , ##__VA_ARGS__); 29 | 30 | #define XPGM_VAR(v0, v1) v0##v1 31 | 32 | // pgm_ptr --> ram_ptr 33 | #define XPGM_CPY(ram_ptr, pgm_ptr, size) memcpy_P(ram_ptr, pgm_ptr, size) 34 | 35 | #define XPGM_BUFFCPY(buff_type, buff_name, pgm_ptr, size) size_t XPGM_VAR(buff_name, _size) = size; \ 36 | buff_type buff_name[XPGM_VAR(buff_name, _size)]; \ 37 | XPGM_CPY(buff_name, pgm_ptr, XPGM_VAR(buff_name, _size)); 38 | 39 | #define XPGM_BUFFCPY_ARRAY(buff_type, buff_name, pgm_array) XPGM_BUFFCPY(buff_type, buff_name, pgm_array, sizeof(pgm_array)) 40 | 41 | #define XPGM_BUFFCPY_STRING(buff_type, buff_name, pgm_string) XPGM_BUFFCPY(buff_type, buff_name, pgm_string, strlen_P(pgm_string) + 1) 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif /* ESP_XPGM_H_ */ 48 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/src/wolfssl/wolfcrypt/compress.h: -------------------------------------------------------------------------------- 1 | /* compress.h 2 | * 3 | * Copyright (C) 2006-2017 wolfSSL Inc. 4 | * 5 | * This file is part of wolfSSL. 6 | * 7 | * wolfSSL is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * wolfSSL is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA 20 | */ 21 | 22 | 23 | #ifndef WOLF_CRYPT_COMPRESS_H 24 | #define WOLF_CRYPT_COMPRESS_H 25 | 26 | #include 27 | 28 | #ifdef HAVE_LIBZ 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | 35 | #define COMPRESS_FIXED 1 36 | 37 | 38 | WOLFSSL_API int wc_Compress(byte*, word32, const byte*, word32, word32); 39 | WOLFSSL_API int wc_DeCompress(byte*, word32, const byte*, word32); 40 | 41 | 42 | #ifdef __cplusplus 43 | } /* extern "C" */ 44 | #endif 45 | 46 | 47 | #endif /* HAVE_LIBZ */ 48 | #endif /* WOLF_CRYPT_COMPRESS_H */ 49 | 50 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/src/watchdog.c: -------------------------------------------------------------------------------- 1 | // Base on esp_hw_wdt in github 2 | /* 3 | * Copyright (c) 2014-2017 Cesanta Software Limited 4 | * All rights reserved 5 | * Changed: 6 | * 2017 Alexander Epstine (a@epstine.com) 7 | */ 8 | 9 | #include "watchdog.h" 10 | #include "Arduino.h" 11 | #include "stdint.h" 12 | #include "user_interface.h" 13 | #include "homekit_debug.h" 14 | 15 | #define REG_WDT_BASE 0x60000900 16 | 17 | #define WDT_CTL (REG_WDT_BASE + 0x0) 18 | #define WDT_CTL_ENABLE (BIT(0)) 19 | #define WDT_RESET (REG_WDT_BASE + 0x14) 20 | #define WDT_RESET_VALUE 0x73 21 | 22 | void esp_hw_wdt_enable() { 23 | SET_PERI_REG_MASK(WDT_CTL, WDT_CTL_ENABLE); 24 | } 25 | 26 | void esp_hw_wdt_disable() { 27 | CLEAR_PERI_REG_MASK(WDT_CTL, WDT_CTL_ENABLE); 28 | } 29 | 30 | void esp_hw_wdt_feed() { 31 | WRITE_PERI_REG(WDT_RESET, WDT_RESET_VALUE); 32 | } 33 | 34 | void watchdog_disable_all() { 35 | system_soft_wdt_stop(); 36 | esp_hw_wdt_disable(); 37 | } 38 | 39 | void watchdog_enable_all() { 40 | esp_hw_wdt_enable(); 41 | system_soft_wdt_restart(); 42 | } 43 | 44 | #ifdef HOMEKIT_DEBUG 45 | 46 | static uint32_t wdt_checkpoint; 47 | 48 | void watchdog_check_begin() { 49 | wdt_checkpoint = millis(); 50 | } 51 | 52 | void watchdog_check_end(const char *message) { 53 | uint32_t d = millis() - wdt_checkpoint; 54 | printf("[WatchDog] Function %s took: %dms\n", message, d); 55 | } 56 | 57 | #else 58 | 59 | void watchdog_check_begin() { 60 | } 61 | void watchdog_check_end(const char *message) { 62 | } 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/src/port.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | #include 8 | 9 | uint32_t homekit_random(); 10 | void homekit_random_fill(uint8_t *data, size_t size); 11 | 12 | void homekit_system_restart(); 13 | void homekit_overclock_start(); 14 | void homekit_overclock_end(); 15 | 16 | #ifdef ESP_OPEN_RTOS 17 | #include 18 | #define ESP_OK 0 19 | #endif 20 | 21 | //#ifdef ESP_IDF 22 | //#include 23 | //#include 24 | 25 | #ifdef ARDUINO_ARCH_ESP8266 26 | #include "Arduino.h" 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | 33 | #define ESP_OK SPI_FLASH_RESULT_OK //0 34 | 35 | #define SPI_FLASH_SECTOR_SIZE SPI_FLASH_SEC_SIZE 36 | #define spiflash_read(addr, buffer, size) (spi_flash_read((addr), (buffer), (size)) == ESP_OK) 37 | #define spiflash_write(addr, data, size) (spi_flash_write((addr), (data), (size)) == ESP_OK) 38 | #define spiflash_erase_sector(addr) (spi_flash_erase_sector((addr) / SPI_FLASH_SECTOR_SIZE) == ESP_OK) 39 | #endif 40 | 41 | 42 | #ifdef ESP_IDF 43 | #define SERVER_TASK_STACK 12288 44 | #else 45 | #define SERVER_TASK_STACK 2048 46 | #endif 47 | 48 | 49 | //void homekit_mdns_init(); 50 | //void homekit_mdns_configure_init(const char *instance_name, int port); 51 | //void homekit_mdns_add_txt(const char *key, const char *format, ...); 52 | //void homekit_mdns_configure_finalize(); 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/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 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/WiFiManager-master/examples/OnDemand/OnDemandConfigPortal/OnDemandConfigPortal.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * OnDemandConfigPortal.ino 3 | * example of running the configPortal AP manually, independantly from the captiveportal 4 | * trigger pin will start a configPortal AP for 120 seconds then turn it off. 5 | * 6 | */ 7 | #include // https://github.com/tzapu/WiFiManager 8 | 9 | // select which pin will trigger the configuration portal when set to LOW 10 | #define TRIGGER_PIN 0 11 | 12 | int timeout = 120; // seconds to run for 13 | 14 | void setup() { 15 | WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP 16 | // put your setup code here, to run once: 17 | Serial.begin(115200); 18 | Serial.println("\n Starting"); 19 | pinMode(TRIGGER_PIN, INPUT_PULLUP); 20 | } 21 | 22 | void loop() { 23 | // is configuration portal requested? 24 | if ( digitalRead(TRIGGER_PIN) == LOW) { 25 | WiFiManager wm; 26 | 27 | //reset settings - for testing 28 | //wm.resetSettings(); 29 | 30 | // set configportal timeout 31 | wm.setConfigPortalTimeout(timeout); 32 | 33 | if (!wm.startConfigPortal("OnDemandAP")) { 34 | Serial.println("failed to connect and hit timeout"); 35 | delay(3000); 36 | //reset and try again, or maybe put it to deep sleep 37 | ESP.restart(); 38 | delay(5000); 39 | } 40 | 41 | //if you get here you have connected to the WiFi 42 | Serial.println("connected...yeey :)"); 43 | 44 | } 45 | 46 | // put your main code here, to run repeatedly: 47 | } 48 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/WiFiManager-master/examples/Old_examples/AutoConnectWithFeedback/AutoConnectWithFeedback.ino: -------------------------------------------------------------------------------- 1 | #include // https://github.com/tzapu/WiFiManager 2 | 3 | void configModeCallback (WiFiManager *myWiFiManager) { 4 | Serial.println("Entered config mode"); 5 | Serial.println(WiFi.softAPIP()); 6 | //if you used auto generated SSID, print it 7 | Serial.println(myWiFiManager->getConfigPortalSSID()); 8 | } 9 | 10 | void setup() { 11 | // put your setup code here, to run once: 12 | Serial.begin(115200); 13 | 14 | //WiFiManager 15 | //Local intialization. Once its business is done, there is no need to keep it around 16 | WiFiManager wifiManager; 17 | //reset settings - for testing 18 | //wifiManager.resetSettings(); 19 | 20 | //set callback that gets called when connecting to previous WiFi fails, and enters Access Point mode 21 | wifiManager.setAPCallback(configModeCallback); 22 | 23 | //fetches ssid and pass and tries to connect 24 | //if it does not connect it starts an access point with the specified name 25 | //here "AutoConnectAP" 26 | //and goes into a blocking loop awaiting configuration 27 | if(!wifiManager.autoConnect()) { 28 | Serial.println("failed to connect and hit timeout"); 29 | //reset and try again, or maybe put it to deep sleep 30 | ESP.restart(); 31 | delay(1000); 32 | } 33 | 34 | //if you get here you have connected to the WiFi 35 | Serial.println("connected...yeey :)"); 36 | 37 | } 38 | 39 | void loop() { 40 | // put your main code here, to run repeatedly: 41 | 42 | } 43 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/WiFiManager-master/.github/workflows/compile_library.yml: -------------------------------------------------------------------------------- 1 | name: Compile Library 2 | 3 | on: 4 | push: 5 | paths-ignore: 6 | - '.github/workflows/cpp_lint.yml' 7 | - '.github/workflows/compile_examples.yml' 8 | - 'examples/**' 9 | pull_request: 10 | paths-ignore: 11 | - '.github/workflows/cpp_lint.yml' 12 | - '.github/workflows/compile_examples.yml' 13 | - 'examples/**' 14 | 15 | jobs: 16 | build: 17 | 18 | runs-on: ubuntu-latest 19 | strategy: 20 | fail-fast: false 21 | matrix: 22 | board: 23 | - "nodemcuv2" 24 | - "lolin32" 25 | 26 | steps: 27 | - uses: actions/checkout@v2 28 | - name: Cache pip 29 | uses: actions/cache@v2 30 | with: 31 | path: ~/.cache/pip 32 | key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} 33 | restore-keys: ${{ runner.os }}-pip- 34 | - name: Cache PlatformIO 35 | uses: actions/cache@v2 36 | with: 37 | path: ~/.platformio 38 | key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} 39 | - name: Set up Python 40 | uses: actions/setup-python@v2 41 | - name: Install PlatformIO 42 | run: | 43 | python -m pip install --upgrade pip 44 | pip install --upgrade platformio 45 | 46 | - name: Create main file 47 | run: | 48 | echo "#include " >> main.ino 49 | echo "void setup() {}" >> main.ino 50 | echo "void loop() {}" >> main.ino 51 | 52 | - name: Run PlatformIO 53 | run: pio ci --board=${{ matrix.board }} . 54 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/src/my_accessory.c: -------------------------------------------------------------------------------- 1 | /* 2 | * my_accessory.c 3 | * Define the accessory in C language using the Macro in characteristics.h 4 | * 5 | * Created on: 2020-05-15 6 | * Author: Mixiaoxiao (Wang Bin) 7 | */ 8 | 9 | #include 10 | #include 11 | #include "config.h" 12 | 13 | 14 | void my_accessory_identify(homekit_value_t _value) { 15 | printf("accessory identify\n"); 16 | } 17 | 18 | homekit_characteristic_t cha_switch_on = HOMEKIT_CHARACTERISTIC_(ON, false); 19 | 20 | homekit_characteristic_t cha_name = HOMEKIT_CHARACTERISTIC_(NAME, "Switch"); 21 | 22 | homekit_accessory_t *accessories[] = { 23 | HOMEKIT_ACCESSORY(.id=1, .category=homekit_accessory_category_switch, .services=(homekit_service_t*[]) { 24 | HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]) { 25 | HOMEKIT_CHARACTERISTIC(NAME, "Switch"), 26 | HOMEKIT_CHARACTERISTIC(MANUFACTURER, "ESP HomeKit"), 27 | HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "ESP123456"), 28 | HOMEKIT_CHARACTERISTIC(MODEL, "ESP8266"), 29 | HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "0.1"), 30 | HOMEKIT_CHARACTERISTIC(IDENTIFY, my_accessory_identify), 31 | NULL 32 | }), 33 | HOMEKIT_SERVICE(SWITCH, .primary=true, .characteristics=(homekit_characteristic_t*[]){ 34 | &cha_switch_on, 35 | &cha_name, 36 | NULL 37 | }), 38 | NULL 39 | }), 40 | NULL 41 | }; 42 | 43 | homekit_server_config_t config = { 44 | .accessories = accessories, 45 | .password = AUTH_ID 46 | }; 47 | 48 | 49 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/WiFiManager-master/examples/Basic/Basic.ino: -------------------------------------------------------------------------------- 1 | #include // https://github.com/tzapu/WiFiManager 2 | 3 | 4 | void setup() { 5 | WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP 6 | // it is a good practice to make sure your code sets wifi mode how you want it. 7 | 8 | // put your setup code here, to run once: 9 | Serial.begin(115200); 10 | 11 | //WiFiManager, Local intialization. Once its business is done, there is no need to keep it around 12 | WiFiManager wm; 13 | 14 | // reset settings - wipe stored credentials for testing 15 | // these are stored by the esp library 16 | wm.resetSettings(); 17 | 18 | // Automatically connect using saved credentials, 19 | // if connection fails, it starts an access point with the specified name ( "AutoConnectAP"), 20 | // if empty will auto generate SSID, if password is blank it will be anonymous AP (wm.autoConnect()) 21 | // then goes into a blocking loop awaiting configuration and will return success result 22 | 23 | bool res; 24 | // res = wm.autoConnect(); // auto generated AP name from chipid 25 | // res = wm.autoConnect("AutoConnectAP"); // anonymous ap 26 | res = wm.autoConnect("AutoConnectAP","password"); // password protected ap 27 | 28 | if(!res) { 29 | Serial.println("Failed to connect"); 30 | // ESP.restart(); 31 | } 32 | else { 33 | //if you get here you have connected to the WiFi 34 | Serial.println("connected...yeey :)"); 35 | } 36 | 37 | } 38 | 39 | void loop() { 40 | // put your main code here, to run repeatedly: 41 | } 42 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/src/query_params.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "query_params.h" 4 | 5 | 6 | query_param_t *query_params_parse(const char *s) { 7 | query_param_t *params = NULL; 8 | 9 | int i = 0; 10 | while (1) { 11 | int pos = i; 12 | while (s[i] && s[i] != '=' && s[i] != '&' && s[i] != '#') i++; 13 | if (i == pos) { 14 | i++; 15 | continue; 16 | } 17 | 18 | query_param_t *param = malloc(sizeof(query_param_t)); 19 | param->name = strndup(s+pos, i-pos); 20 | param->value = NULL; 21 | param->next = params; 22 | params = param; 23 | 24 | if (s[i] == '=') { 25 | i++; 26 | pos = i; 27 | while (s[i] && s[i] != '&' && s[i] != '#') i++; 28 | if (i != pos) { 29 | param->value = strndup(s+pos, i-pos); 30 | } 31 | } 32 | 33 | if (!s[i] || s[i] == '#') 34 | break; 35 | } 36 | 37 | return params; 38 | } 39 | 40 | 41 | query_param_t *query_params_find(query_param_t *params, const char *name) { 42 | while (params) { 43 | if (!strcmp(params->name, name)) 44 | return params; 45 | params = params->next; 46 | } 47 | 48 | return NULL; 49 | } 50 | 51 | 52 | void query_params_free(query_param_t *params) { 53 | while (params) { 54 | query_param_t *next = params->next; 55 | if (params->name) 56 | free(params->name); 57 | if (params->value) 58 | free(params->value); 59 | free(params); 60 | 61 | params = next; 62 | } 63 | } 64 | 65 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/WiFiManager-master/.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | sudo: false 3 | 4 | before_install: 5 | - "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16" 6 | - sleep 3 7 | - export DISPLAY=:1.0 8 | - wget http://downloads.arduino.cc/arduino-1.8.10-linux64.tar.xz 9 | - tar xf arduino-1.8.10-linux64.tar.xz 10 | - sudo mv arduino-1.8.10 /usr/local/share/arduino 11 | - sudo ln -s /usr/local/share/arduino/arduino /usr/local/bin/arduino 12 | 13 | install: 14 | - ln -s $PWD /usr/local/share/arduino/libraries/WiFiManager 15 | - arduino --pref "boardsmanager.additional.urls=http://arduino.esp8266.com/stable/package_esp8266com_index.json,http://dl.espressif.com/dl/package_esp32_index.json" --save-prefs 16 | - arduino --install-library "ArduinoJson:6.18.0" 17 | - arduino --install-boards esp8266:esp8266 18 | - arduino --pref "compiler.warning_level=all" --save-prefs 19 | # install esp32 20 | - arduino --install-boards esp32:esp32 21 | 22 | script: 23 | - "echo $PWD" 24 | - "echo $HOME" 25 | - "ls $PWD" 26 | - source $TRAVIS_BUILD_DIR/travis/common.sh 27 | - arduino --board esp8266:esp8266:generic:xtal=80,eesz=4M1M,FlashMode=qio,FlashFreq=80,dbg=Serial,lvl=CORE --save-prefs 28 | - build_examples 29 | - arduino --board esp32:esp32:esp32:FlashFreq=80,FlashSize=4M,DebugLevel=info --save-prefs 30 | # some examples fail (SPIFFS defines differ esp32 vs esp8266) so we exclude them 31 | - build_examples 32 | # - arduino -v --verbose-build --verify $PWD/examples/AutoConnect/AutoConnect.ino 33 | 34 | # no coverage generated, no need to run 35 | # 36 | #after_success: 37 | # - bash <(curl -s https://codecov.io/bash) 38 | 39 | notifications: 40 | email: 41 | on_success: change 42 | on_failure: change 43 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/examples/Example02_Switch/my_accessory.c: -------------------------------------------------------------------------------- 1 | /* 2 | * my_accessory.c 3 | * Define the accessory in C language using the Macro in characteristics.h 4 | * 5 | * Created on: 2020-05-15 6 | * Author: Mixiaoxiao (Wang Bin) 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | void my_accessory_identify(homekit_value_t _value) { 13 | printf("accessory identify\n"); 14 | } 15 | 16 | // Switch (HAP section 8.38) 17 | // required: ON 18 | // optional: NAME 19 | 20 | // format: bool; HAP section 9.70; write the .setter function to get the switch-event sent from iOS Home APP. 21 | homekit_characteristic_t cha_switch_on = HOMEKIT_CHARACTERISTIC_(ON, false); 22 | 23 | // format: string; HAP section 9.62; max length 64 24 | homekit_characteristic_t cha_name = HOMEKIT_CHARACTERISTIC_(NAME, "Switch"); 25 | 26 | homekit_accessory_t *accessories[] = { 27 | HOMEKIT_ACCESSORY(.id=1, .category=homekit_accessory_category_switch, .services=(homekit_service_t*[]) { 28 | HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]) { 29 | HOMEKIT_CHARACTERISTIC(NAME, "Switch"), 30 | HOMEKIT_CHARACTERISTIC(MANUFACTURER, "Arduino HomeKit"), 31 | HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "0123456"), 32 | HOMEKIT_CHARACTERISTIC(MODEL, "ESP8266/ESP32"), 33 | HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "1.0"), 34 | HOMEKIT_CHARACTERISTIC(IDENTIFY, my_accessory_identify), 35 | NULL 36 | }), 37 | HOMEKIT_SERVICE(SWITCH, .primary=true, .characteristics=(homekit_characteristic_t*[]){ 38 | &cha_switch_on, 39 | &cha_name, 40 | NULL 41 | }), 42 | NULL 43 | }), 44 | NULL 45 | }; 46 | 47 | homekit_server_config_t config = { 48 | .accessories = accessories, 49 | .password = "111-11-111" 50 | }; 51 | 52 | 53 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/src/wolfssl/wolfcrypt/md4.h: -------------------------------------------------------------------------------- 1 | /* md4.h 2 | * 3 | * Copyright (C) 2006-2017 wolfSSL Inc. 4 | * 5 | * This file is part of wolfSSL. 6 | * 7 | * wolfSSL is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * wolfSSL is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA 20 | */ 21 | 22 | 23 | #ifndef WOLF_CRYPT_MD4_H 24 | #define WOLF_CRYPT_MD4_H 25 | 26 | #include 27 | 28 | #ifndef NO_MD4 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /* in bytes */ 35 | enum { 36 | MD4_BLOCK_SIZE = 64, 37 | MD4_DIGEST_SIZE = 16, 38 | MD4_PAD_SIZE = 56 39 | }; 40 | 41 | 42 | /* MD4 digest */ 43 | typedef struct Md4 { 44 | word32 buffLen; /* in bytes */ 45 | word32 loLen; /* length in bytes */ 46 | word32 hiLen; /* length in bytes */ 47 | word32 digest[MD4_DIGEST_SIZE / sizeof(word32)]; 48 | word32 buffer[MD4_BLOCK_SIZE / sizeof(word32)]; 49 | } Md4; 50 | 51 | 52 | WOLFSSL_API void wc_InitMd4(Md4*); 53 | WOLFSSL_API void wc_Md4Update(Md4*, const byte*, word32); 54 | WOLFSSL_API void wc_Md4Final(Md4*, byte*); 55 | 56 | 57 | #ifdef __cplusplus 58 | } /* extern "C" */ 59 | #endif 60 | 61 | #endif /* NO_MD4 */ 62 | #endif /* WOLF_CRYPT_MD4_H */ 63 | 64 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/src/wolfssl/wolfcrypt/arc4.h: -------------------------------------------------------------------------------- 1 | /* arc4.h 2 | * 3 | * Copyright (C) 2006-2017 wolfSSL Inc. 4 | * 5 | * This file is part of wolfSSL. 6 | * 7 | * wolfSSL is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * wolfSSL is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA 20 | */ 21 | 22 | 23 | 24 | #ifndef WOLF_CRYPT_ARC4_H 25 | #define WOLF_CRYPT_ARC4_H 26 | 27 | #include 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | #ifdef WOLFSSL_ASYNC_CRYPT 34 | #include 35 | #endif 36 | 37 | enum { 38 | ARC4_ENC_TYPE = 4, /* cipher unique type */ 39 | ARC4_STATE_SIZE = 256 40 | }; 41 | 42 | /* ARC4 encryption and decryption */ 43 | typedef struct Arc4 { 44 | byte x; 45 | byte y; 46 | byte state[ARC4_STATE_SIZE]; 47 | #ifdef WOLFSSL_ASYNC_CRYPT 48 | WC_ASYNC_DEV asyncDev; 49 | #endif 50 | void* heap; 51 | } Arc4; 52 | 53 | WOLFSSL_API int wc_Arc4Process(Arc4*, byte*, const byte*, word32); 54 | WOLFSSL_API int wc_Arc4SetKey(Arc4*, const byte*, word32); 55 | 56 | WOLFSSL_API int wc_Arc4Init(Arc4*, void*, int); 57 | WOLFSSL_API void wc_Arc4Free(Arc4*); 58 | 59 | #ifdef __cplusplus 60 | } /* extern "C" */ 61 | #endif 62 | 63 | 64 | #endif /* WOLF_CRYPT_ARC4_H */ 65 | 66 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/src/wolfssl/wolfcrypt/fips_test.h: -------------------------------------------------------------------------------- 1 | /* fips_test.h 2 | * 3 | * Copyright (C) 2006-2017 wolfSSL Inc. 4 | * 5 | * This file is part of wolfSSL. 6 | * 7 | * wolfSSL is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * wolfSSL is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA 20 | */ 21 | 22 | 23 | 24 | #ifndef WOLF_CRYPT_FIPS_TEST_H 25 | #define WOLF_CRYPT_FIPS_TEST_H 26 | 27 | #include 28 | 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /* Known Answer Test string inputs are hex, internal */ 35 | CYASSL_LOCAL int DoKnownAnswerTests(char*, int); 36 | 37 | 38 | /* FIPS failure callback */ 39 | typedef void(*wolfCrypt_fips_cb)(int ok, int err, const char* hash); 40 | 41 | /* Public set function */ 42 | CYASSL_API int wolfCrypt_SetCb_fips(wolfCrypt_fips_cb cbf); 43 | 44 | /* Public get status functions */ 45 | CYASSL_API int wolfCrypt_GetStatus_fips(void); 46 | CYASSL_API const char* wolfCrypt_GetCoreHash_fips(void); 47 | 48 | #ifdef HAVE_FORCE_FIPS_FAILURE 49 | /* Public function to force failure mode for operational testing */ 50 | CYASSL_API int wolfCrypt_SetStatus_fips(int); 51 | #endif 52 | 53 | 54 | #ifdef __cplusplus 55 | } /* extern "C" */ 56 | #endif 57 | 58 | #endif /* WOLF_CRYPT_FIPS_TEST_H */ 59 | 60 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/src/wolfssl/wolfcrypt/md2.h: -------------------------------------------------------------------------------- 1 | /* md2.h 2 | * 3 | * Copyright (C) 2006-2017 wolfSSL Inc. 4 | * 5 | * This file is part of wolfSSL. 6 | * 7 | * wolfSSL is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * wolfSSL is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA 20 | */ 21 | 22 | 23 | #ifndef WOLF_CRYPT_MD2_H 24 | #define WOLF_CRYPT_MD2_H 25 | 26 | #include 27 | 28 | #ifdef WOLFSSL_MD2 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /* in bytes */ 35 | enum { 36 | MD2 = 6, /* hash type unique */ 37 | MD2_BLOCK_SIZE = 16, 38 | MD2_DIGEST_SIZE = 16, 39 | MD2_PAD_SIZE = 16, 40 | MD2_X_SIZE = 48 41 | }; 42 | 43 | 44 | /* Md2 digest */ 45 | typedef struct Md2 { 46 | word32 count; /* bytes % PAD_SIZE */ 47 | byte X[MD2_X_SIZE]; 48 | byte C[MD2_BLOCK_SIZE]; 49 | byte buffer[MD2_BLOCK_SIZE]; 50 | } Md2; 51 | 52 | 53 | WOLFSSL_API void wc_InitMd2(Md2*); 54 | WOLFSSL_API void wc_Md2Update(Md2*, const byte*, word32); 55 | WOLFSSL_API void wc_Md2Final(Md2*, byte*); 56 | WOLFSSL_API int wc_Md2Hash(const byte*, word32, byte*); 57 | 58 | 59 | #ifdef __cplusplus 60 | } /* extern "C" */ 61 | #endif 62 | 63 | #endif /* WOLFSSL_MD2 */ 64 | #endif /* WOLF_CRYPT_MD2_H */ 65 | 66 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/ESP_DoubleResetDetector/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing to ESP_DoubleResetDetector 2 | 3 | ### Reporting Bugs 4 | 5 | Please report bugs in ESP_DoubleResetDetector if you find them. 6 | 7 | However, before reporting a bug please check through the following: 8 | 9 | * [Existing Open Issues](https://github.com/khoih-prog/ESP_DoubleResetDetector/issues) - someone might have already encountered this. 10 | 11 | If you don't find anything, please [open a new issue](https://github.com/khoih-prog/ESP_DoubleResetDetector/issues/new). 12 | 13 | ### How to submit a bug report 14 | 15 | Please ensure to specify the following: 16 | 17 | * Arduino IDE version (e.g. 1.8.13) or Platform.io version 18 | * `ESP8266` or `ESP32` Core Version (e.g. ESP8266 core v2.7.4 or ESP32 v1.0.4) 19 | * Contextual information (e.g. what you were trying to achieve) 20 | * Simplest possible steps to reproduce 21 | * Anything that might be relevant in your opinion, such as: 22 | * Operating system (Windows, Ubuntu, etc.) and the output of `uname -a` 23 | * Network configuration 24 | 25 | 26 | ### Example 27 | 28 | ``` 29 | Arduino IDE version: 1.8.13 30 | ESP8266 Core Version 2.7.4 31 | OS: Ubuntu 20.04 LTS 32 | Linux Inspiron 5.4.0-54-generic #60-Ubuntu SMP Fri Nov 6 10:37:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux 33 | 34 | Context: 35 | I encountered a non-response while trying to press the reset button twice. 36 | 37 | Steps to reproduce: 38 | 1. ... 39 | 2. ... 40 | 3. ... 41 | 4. ... 42 | ``` 43 | ### Sending Feature Requests 44 | 45 | Feel free to post feature requests. It's helpful if you can explain exactly why the feature would be useful. 46 | 47 | There are usually some outstanding feature requests in the [existing issues list](https://github.com/khoih-prog/ESP_DoubleResetDetector/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them. 48 | 49 | ### Sending Pull Requests 50 | 51 | Pull Requests with changes and fixes are also welcome! 52 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/examples/Example03_StatelessProgrammableSwitch/my_accessory.c: -------------------------------------------------------------------------------- 1 | /* 2 | * my_accessory.c 3 | * Define the accessory in C language using the Macro in characteristics.h 4 | * 5 | * Created on: 2020-05-16 6 | * Author: Mixiaoxiao (Wang Bin) 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | void my_accessory_identify(homekit_value_t _value) { 13 | printf("accessory identify\n"); 14 | } 15 | 16 | // Stateless Programmable Switch (HAP section 8.37) 17 | // required: PROGRAMMABLE_SWITCH_EVENT 18 | // optional: NAME, SERVICE_LABEL_INDEX 19 | 20 | // format: uint8; HAP section 9.75; write the .getter function and always return "null" for reading 21 | homekit_characteristic_t cha_programmable_switch_event = HOMEKIT_CHARACTERISTIC_(PROGRAMMABLE_SWITCH_EVENT, 0); 22 | 23 | homekit_accessory_t *accessories[] = { 24 | HOMEKIT_ACCESSORY(.id=1, .category=homekit_accessory_category_switch, .services=(homekit_service_t*[]) { 25 | HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]) { 26 | HOMEKIT_CHARACTERISTIC(NAME, "Stateless Programmable Switch"), 27 | HOMEKIT_CHARACTERISTIC(MANUFACTURER, "Arduino HomeKit"), 28 | HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "0123456"), 29 | HOMEKIT_CHARACTERISTIC(MODEL, "ESP8266/ESP32"), 30 | HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "1.0"), 31 | HOMEKIT_CHARACTERISTIC(IDENTIFY, my_accessory_identify), 32 | NULL 33 | }), 34 | HOMEKIT_SERVICE(STATELESS_PROGRAMMABLE_SWITCH, .primary=true, .characteristics=(homekit_characteristic_t*[]){ 35 | HOMEKIT_CHARACTERISTIC(NAME, "Stateless Programmable Switch"), 36 | &cha_programmable_switch_event, 37 | NULL 38 | }), 39 | NULL 40 | }), 41 | NULL 42 | }; 43 | 44 | homekit_server_config_t config = { 45 | .accessories = accessories, 46 | .password = "111-11-111" 47 | }; 48 | 49 | 50 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/examples/Example06_makesmart_lock/my_accessory.c: -------------------------------------------------------------------------------- 1 | /* 2 | * my_accessory.c 3 | * Define the accessory in C language using the Macro in characteristics.h 4 | * 5 | * Created on: 2021-02-05 6 | * Author: cooper @ makesmart.net 7 | * Thank you for this great library! 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | void my_accessory_identify(homekit_value_t _value) { 15 | printf("accessory identify\n"); 16 | } 17 | 18 | 19 | // characteristics of the lock-mechanism 20 | // format: uint8_t // 0 is unsecured // 1 is secured 21 | homekit_characteristic_t cha_lock_current_state = HOMEKIT_CHARACTERISTIC_(LOCK_CURRENT_STATE, 1); 22 | homekit_characteristic_t cha_lock_target_state = HOMEKIT_CHARACTERISTIC_(LOCK_TARGET_STATE, 1); 23 | 24 | homekit_characteristic_t cha_name = HOMEKIT_CHARACTERISTIC_(NAME, "Lock"); 25 | 26 | homekit_accessory_t *accessories[] = { 27 | HOMEKIT_ACCESSORY(.id=1, .category=homekit_accessory_category_door_lock, .services=(homekit_service_t*[]) { 28 | HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]) { 29 | HOMEKIT_CHARACTERISTIC(NAME, "Lock"), 30 | HOMEKIT_CHARACTERISTIC(MANUFACTURER, "makesmart Community"), 31 | HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "1111111"), 32 | HOMEKIT_CHARACTERISTIC(MODEL, "makesmart Lock"), 33 | HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "1.0"), 34 | HOMEKIT_CHARACTERISTIC(IDENTIFY, my_accessory_identify), 35 | NULL 36 | }), 37 | HOMEKIT_SERVICE(LOCK_MECHANISM, .primary=true, .characteristics=(homekit_characteristic_t*[]){ 38 | &cha_lock_current_state, 39 | &cha_lock_target_state, 40 | &cha_name, 41 | NULL 42 | }), 43 | NULL 44 | }), 45 | NULL 46 | }; 47 | 48 | homekit_server_config_t config = { 49 | .accessories = accessories, 50 | .password = "123-45-678" 51 | }; 52 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/Arduino-HomeKit-ESP8266/src/homekit_debug.h: -------------------------------------------------------------------------------- 1 | #ifndef __HOMEKIT_DEBUG_H__ 2 | #define __HOMEKIT_DEBUG_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | #include "Arduino.h" 11 | #include 12 | #include 13 | 14 | typedef unsigned char byte; 15 | 16 | #define HOMEKIT_NO_LOG 0 17 | #define HOMEKIT_LOG_ERROR 1 18 | #define HOMEKIT_LOG_INFO 2 19 | #define HOMEKIT_LOG_DEBUG 3 20 | 21 | #ifndef HOMEKIT_LOG_LEVEL 22 | #define HOMEKIT_LOG_LEVEL HOMEKIT_LOG_INFO 23 | #endif 24 | 25 | #define HOMEKIT_PRINTF XPGM_PRINTF 26 | 27 | #if HOMEKIT_LOG_LEVEL >= HOMEKIT_LOG_DEBUG 28 | 29 | #define DEBUG(message, ...) HOMEKIT_PRINTF(">>> %s: " message "\n", __func__, ##__VA_ARGS__) 30 | static uint32_t start_time = 0; 31 | #define DEBUG_TIME_BEGIN() start_time=millis(); 32 | #define DEBUG_TIME_END(func_name) HOMEKIT_PRINTF("### [%7d] %s took %6dms\n", millis(), func_name, (millis() - start_time)); 33 | #define DEBUG_HEAP() DEBUG("Free heap: %d", system_get_free_heap_size()); 34 | 35 | #else 36 | 37 | #define DEBUG(message, ...) 38 | #define DEBUG_TIME_BEGIN() 39 | #define DEBUG_TIME_END(func_name) 40 | #define DEBUG_HEAP() 41 | 42 | #endif 43 | 44 | #if HOMEKIT_LOG_LEVEL >= HOMEKIT_LOG_ERROR 45 | 46 | #define ERROR(message, ...) HOMEKIT_PRINTF("!!! [%7d] HomeKit: " message "\n", millis(), ##__VA_ARGS__) 47 | 48 | #else 49 | 50 | #define ERROR(message, ...) 51 | 52 | #endif 53 | 54 | #if HOMEKIT_LOG_LEVEL >= HOMEKIT_LOG_INFO 55 | 56 | #define INFO(message, ...) HOMEKIT_PRINTF(">>> [%7d] HomeKit: " message "\n", millis(), ##__VA_ARGS__) 57 | #define INFO_HEAP() INFO("Free heap: %d", system_get_free_heap_size()); 58 | 59 | #else 60 | 61 | #define INFO(message, ...) 62 | #define INFO_HEAP() 63 | 64 | #endif 65 | 66 | char *binary_to_string(const byte *data, size_t size); 67 | void print_binary(const char *prompt, const byte *data, size_t size); 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | 73 | #endif // __HOMEKIT_DEBUG_H__ 74 | -------------------------------------------------------------------------------- /Code/8266HomeKitSwitch/lib/WiFiManager-master/extras/parse.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | 5 | console.log('starting'); 6 | 7 | const inFile = 'WiFiManager.template.html'; 8 | const outFile = 'template.h'; 9 | 10 | const defineRegEx = //gm; 11 | console.log('parsing', inFile); 12 | 13 | fs.readFile(inFile, 'utf8', function (err,data) { 14 | if (err) { 15 | return console.log(err); 16 | } 17 | //console.log(data); 18 | 19 | let defines = data.match(defineRegEx); 20 | 21 | //console.log(defines); 22 | var stream = fs.createWriteStream(outFile); 23 | stream.once('open', function(fd) { 24 | for (const i in defines) { 25 | 26 | const start = defines[i]; 27 | const end = start.replace('