├── .gitattributes ├── BMP-LCD.zip ├── ESP+kit+Specification.pdf ├── ESP32-DrawLogo └── ESP32-DrawLogo.ino ├── ESP32-DrawLogo2 └── ESP32-DrawLogo2.ino ├── ESP32-examples-Inet-heltec.zip ├── ESP32-examples-Inet-heltec ├── Kconfig ├── Makefile.projbuild ├── README.md ├── appveyor.yml ├── boards.txt ├── component.mk ├── cores │ └── esp32 │ │ ├── Arduino.h │ │ ├── Client.h │ │ ├── Esp.cpp │ │ ├── Esp.h │ │ ├── HardwareSerial.cpp │ │ ├── HardwareSerial.h │ │ ├── IPAddress.cpp │ │ ├── IPAddress.h │ │ ├── IPv6Address.cpp │ │ ├── IPv6Address.h │ │ ├── MD5Builder.cpp │ │ ├── MD5Builder.h │ │ ├── Print.cpp │ │ ├── Print.h │ │ ├── Printable.h │ │ ├── Server.h │ │ ├── Stream.cpp │ │ ├── Stream.h │ │ ├── StreamString.cpp │ │ ├── StreamString.h │ │ ├── Udp.h │ │ ├── WCharacter.h │ │ ├── WMath.cpp │ │ ├── WString.cpp │ │ ├── WString.h │ │ ├── base64.cpp │ │ ├── base64.h │ │ ├── binary.h │ │ ├── cbuf.cpp │ │ ├── cbuf.h │ │ ├── esp32-hal-adc.c │ │ ├── esp32-hal-adc.h │ │ ├── esp32-hal-dac.c │ │ ├── esp32-hal-dac.h │ │ ├── esp32-hal-gpio.c │ │ ├── esp32-hal-gpio.h │ │ ├── esp32-hal-i2c.c │ │ ├── esp32-hal-i2c.h │ │ ├── esp32-hal-ledc.c │ │ ├── esp32-hal-ledc.h │ │ ├── esp32-hal-log.h │ │ ├── esp32-hal-matrix.c │ │ ├── esp32-hal-matrix.h │ │ ├── esp32-hal-misc.c │ │ ├── esp32-hal-sigmadelta.c │ │ ├── esp32-hal-sigmadelta.h │ │ ├── esp32-hal-spi.c │ │ ├── esp32-hal-spi.h │ │ ├── esp32-hal-time.c │ │ ├── esp32-hal-timer.c │ │ ├── esp32-hal-timer.h │ │ ├── esp32-hal-touch.c │ │ ├── esp32-hal-touch.h │ │ ├── esp32-hal-uart.c │ │ ├── esp32-hal-uart.h │ │ ├── esp32-hal.h │ │ ├── libb64 │ │ ├── AUTHORS │ │ ├── LICENSE │ │ ├── cdecode.c │ │ ├── cdecode.h │ │ ├── cencode.c │ │ └── cencode.h │ │ ├── main.cpp │ │ ├── pgmspace.h │ │ ├── stdlib_noniso.c │ │ ├── stdlib_noniso.h │ │ ├── wiring_private.h │ │ ├── wiring_pulse.c │ │ └── wiring_shift.c ├── doc │ ├── arduino-ide.png │ ├── esp32_pinmap.png │ ├── win-gui-1.png │ ├── win-gui-2.png │ ├── win-gui-3.png │ ├── win-gui-4.png │ ├── win-gui-5.png │ ├── win-gui-update-1.png │ ├── win-gui-update-2.png │ └── windows.md ├── libraries │ ├── ESP32 │ │ ├── examples │ │ │ ├── AnalogOut │ │ │ │ ├── LEDCSoftwareFade │ │ │ │ │ └── LEDCSoftwareFade.ino │ │ │ │ └── SigmaDelta │ │ │ │ │ └── SigmaDelta.ino │ │ │ ├── Timer │ │ │ │ └── RepeatTimer │ │ │ │ │ └── RepeatTimer.ino │ │ │ └── Touch │ │ │ │ ├── TouchInterrupt │ │ │ │ └── TouchInterrupt.ino │ │ │ │ └── TouchRead │ │ │ │ └── TouchRead.ino │ │ ├── library.properties │ │ └── src │ │ │ └── dummy.h │ ├── LoRa │ │ ├── .travis.yml │ │ ├── API.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── examples │ │ │ ├── LoRaReceiver │ │ │ │ └── LoRaReceiver.ino │ │ │ ├── LoRaReceiverCallback │ │ │ │ └── LoRaReceiverCallback.ino │ │ │ └── LoRaSender │ │ │ │ └── LoRaSender.ino │ │ ├── keywords.txt │ │ ├── library.properties │ │ └── src │ │ │ ├── LoRa.cpp │ │ │ └── LoRa.h │ ├── OLED │ │ ├── .travis.yml │ │ ├── OLEDDisplay.cpp │ │ ├── OLEDDisplay.h │ │ ├── OLEDDisplayFonts.h │ │ ├── OLEDDisplayUi.cpp │ │ ├── OLEDDisplayUi.h │ │ ├── README.md │ │ ├── SSD1306.h │ │ ├── SSD1306Brzo.h │ │ ├── SSD1306Spi.h │ │ ├── SSD1306Wire.h │ │ ├── UPGRADE-3.0.md │ │ ├── examples │ │ │ ├── SSD1306DrawingDemo │ │ │ │ └── SSD1306DrawingDemo.ino │ │ │ ├── SSD1306SimpleDemo │ │ │ │ ├── SSD1306SimpleDemo.ino │ │ │ │ └── images.h │ │ │ └── SSD1306UiDemo │ │ │ │ ├── SSD1306UiDemo.ino │ │ │ │ └── images.h │ │ ├── library.json │ │ ├── library.properties │ │ └── license │ ├── Preferences │ │ ├── examples │ │ │ └── StartCounter │ │ │ │ └── StartCounter.ino │ │ ├── keywords.txt │ │ ├── library.properties │ │ └── src │ │ │ ├── Preferences.cpp │ │ │ └── Preferences.h │ ├── SPI │ │ ├── keywords.txt │ │ ├── library.properties │ │ └── src │ │ │ ├── SPI.cpp │ │ │ └── SPI.h │ ├── WiFi │ │ ├── examples │ │ │ ├── SimpleWiFiServer │ │ │ │ └── SimpleWiFiServer.ino │ │ │ ├── WiFiClient │ │ │ │ └── WiFiClient.ino │ │ │ ├── WiFiClientBasic │ │ │ │ └── WiFiClientBasic.ino │ │ │ ├── WiFiClientEvents │ │ │ │ └── WiFiClientEvents.ino │ │ │ ├── WiFiIPv6 │ │ │ │ └── WiFiIPv6.ino │ │ │ ├── WiFiMulti │ │ │ │ └── WiFiMulti.ino │ │ │ ├── WiFiScan │ │ │ │ ├── WiFiScan.ino │ │ │ │ └── images.h │ │ │ ├── WiFiSmartConfig │ │ │ │ └── WiFiSmartConfig.ino │ │ │ └── WiFiUDPClient │ │ │ │ ├── WiFiUDPClient.ino │ │ │ │ ├── udp_server.py │ │ │ │ └── udp_server.rb │ │ ├── keywords.txt │ │ ├── library.properties │ │ └── src │ │ │ ├── WiFi.cpp │ │ │ ├── WiFi.h │ │ │ ├── WiFiAP.cpp │ │ │ ├── WiFiAP.h │ │ │ ├── WiFiClient.cpp │ │ │ ├── WiFiClient.h │ │ │ ├── WiFiGeneric.cpp │ │ │ ├── WiFiGeneric.h │ │ │ ├── WiFiMulti.cpp │ │ │ ├── WiFiMulti.h │ │ │ ├── WiFiSTA.cpp │ │ │ ├── WiFiSTA.h │ │ │ ├── WiFiScan.cpp │ │ │ ├── WiFiScan.h │ │ │ ├── WiFiServer.cpp │ │ │ ├── WiFiServer.h │ │ │ ├── WiFiType.h │ │ │ ├── WiFiUdp.cpp │ │ │ └── WiFiUdp.h │ ├── WiFiClientSecure │ │ ├── examples │ │ │ └── WiFiClientSecure │ │ │ │ └── WiFiClientSecure.ino │ │ ├── keywords.txt │ │ ├── library.properties │ │ └── src │ │ │ ├── WiFiClientSecure.cpp │ │ │ ├── WiFiClientSecure.h │ │ │ ├── ssl_client.cpp │ │ │ └── ssl_client.h │ └── Wire │ │ ├── keywords.txt │ │ ├── library.properties │ │ └── src │ │ ├── Wire.cpp │ │ └── Wire.h ├── package.json ├── package │ └── package_esp32_index.template.json ├── platform.txt ├── programmers.txt └── variants │ ├── WIFI_Kit_32 │ └── pins_arduino.h │ └── WIFI_LoRa_32 │ └── pins_arduino.h ├── Heltec_WIFI-LoRa-32_DiagramPinout.jpg ├── IMG_20170827_145742.jpg ├── README.md ├── esp32-ble-test └── esp32-ble-test.ino ├── esp32_datasheet_en.pdf ├── esp32_pcap_serial-edited └── esp32_pcap_serial-edited.ino ├── hackaday.png └── house.bmp /.gitattributes: -------------------------------------------------------------------------------- 1 | *.zip filter=lfs diff=lfs merge=lfs -text 2 | -------------------------------------------------------------------------------- /BMP-LCD.zip: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6cb082947d7ce4bbb19a8b8e22f696cfe6a8921cdd9cb50c8eb5c5797ced4ccb 3 | size 97434 4 | -------------------------------------------------------------------------------- /ESP+kit+Specification.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/darthm0e/esp32-101/9227a2fe3d7cef382d10f0a8f5112a412e416f01/ESP+kit+Specification.pdf -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec.zip: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:41c71b379b26640a0c6192cf9d52736f3b993ed66e40f680bb5dbd9aee42a64b 3 | size 62554695 4 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/Kconfig: -------------------------------------------------------------------------------- 1 | menu "Arduino Configuration" 2 | 3 | config ENABLE_ARDUINO_DEPENDS 4 | bool 5 | select LWIP_SO_RCVBUF 6 | default "y" 7 | 8 | config AUTOSTART_ARDUINO 9 | bool "Autostart Arduino setup and loop on boot" 10 | default "n" 11 | help 12 | Enabling this option will implement app_main and start Arduino. 13 | All you need to implement in your main.cpp is setup() and loop() 14 | and include Arduino.h 15 | If disabled, you can call initArduino() to run any preparations 16 | required by the framework 17 | 18 | config DISABLE_HAL_LOCKS 19 | bool "Disable mutex locks for HAL" 20 | default "n" 21 | help 22 | Enabling this option will run all hardware abstraction without locks. 23 | While communication with external hardware will be faster, you need to 24 | make sure that there is no option to use the same bus from another thread 25 | or interrupt at the same time. Option is best used with Arduino enabled 26 | and code implemented only in setup/loop and Arduino callbacks 27 | 28 | menu "Debug Log Configuration" 29 | choice ARDUHAL_LOG_DEFAULT_LEVEL 30 | bool "Default log level" 31 | default ARDUHAL_LOG_DEFAULT_LEVEL_ERROR 32 | help 33 | Specify how much output to see in logs by default. 34 | 35 | config ARDUHAL_LOG_DEFAULT_LEVEL_NONE 36 | bool "No output" 37 | config ARDUHAL_LOG_DEFAULT_LEVEL_ERROR 38 | bool "Error" 39 | config ARDUHAL_LOG_DEFAULT_LEVEL_WARN 40 | bool "Warning" 41 | config ARDUHAL_LOG_DEFAULT_LEVEL_INFO 42 | bool "Info" 43 | config ARDUHAL_LOG_DEFAULT_LEVEL_DEBUG 44 | bool "Debug" 45 | config ARDUHAL_LOG_DEFAULT_LEVEL_VERBOSE 46 | bool "Verbose" 47 | endchoice 48 | 49 | config ARDUHAL_LOG_DEFAULT_LEVEL 50 | int 51 | default 0 if ARDUHAL_LOG_DEFAULT_LEVEL_NONE 52 | default 1 if ARDUHAL_LOG_DEFAULT_LEVEL_ERROR 53 | default 2 if ARDUHAL_LOG_DEFAULT_LEVEL_WARN 54 | default 3 if ARDUHAL_LOG_DEFAULT_LEVEL_INFO 55 | default 4 if ARDUHAL_LOG_DEFAULT_LEVEL_DEBUG 56 | default 5 if ARDUHAL_LOG_DEFAULT_LEVEL_VERBOSE 57 | 58 | config ARDUHAL_LOG_COLORS 59 | bool "Use ANSI terminal colors in log output" 60 | default "n" 61 | help 62 | Enable ANSI terminal color codes in bootloader output. 63 | In order to view these, your terminal program must support ANSI color codes. 64 | 65 | endmenu 66 | 67 | config AUTOCONNECT_WIFI 68 | bool "Autoconnect WiFi on boot" 69 | default "n" 70 | depends on AUTOSTART_ARDUINO 71 | help 72 | If enabled, WiFi will connect to the last used SSID (if station was enabled), 73 | else connection will be started only after calling WiFi.begin(ssid, password) 74 | 75 | endmenu 76 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/Makefile.projbuild: -------------------------------------------------------------------------------- 1 | BOOT_APP_BIN_OFFSET := 0xe000 2 | BOOT_APP_BIN_ROOT := $(call dequote,$(COMPONENT_PATH)) 3 | BOOT_APP_BIN_PATH := $(call dequote,$(abspath $(BOOT_APP_BIN_ROOT)/$(subst $(quote),,tools/partitions/boot_app0.bin))) 4 | 5 | ifndef CONFIG_PARTITION_TABLE_CUSTOM 6 | PARTITION_TABLE_CSV_PATH = $(call dequote,$(abspath $(BOOT_APP_BIN_ROOT)/$(subst $(quote),,tools/partitions/default.csv))) 7 | endif 8 | 9 | BOOT_APP_BIN_FLASH_CMD = $(ESPTOOLPY_SERIAL) write_flash $(BOOT_APP_BIN_OFFSET) $(BOOT_APP_BIN_PATH) 10 | ESPTOOL_ALL_FLASH_ARGS += $(BOOT_APP_BIN_OFFSET) $(BOOT_APP_BIN_PATH) 11 | 12 | CPPFLAGS += -DARDUINO=180 -DESP32=1 -DARDUINO_ARCH_ESP32=1 13 | 14 | boot-app0: 15 | @echo "Rebooting to APP0" 16 | $(BOOT_APP_BIN_FLASH_CMD) 17 | 18 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/appveyor.yml: -------------------------------------------------------------------------------- 1 | build: off 2 | environment: 3 | 4 | matrix: 5 | - PLATFORMIO_CI_SRC: "libraries/WiFi/examples/WiFiClient" 6 | - PLATFORMIO_CI_SRC: "libraries/WiFi/examples/WiFiClientBasic" 7 | - PLATFORMIO_CI_SRC: "libraries/WiFi/examples/WiFiClientEvents" 8 | - PLATFORMIO_CI_SRC: "libraries/WiFi/examples/WiFiIPv6" 9 | - PLATFORMIO_CI_SRC: "libraries/WiFi/examples/WiFiScan" 10 | - PLATFORMIO_CI_SRC: "libraries/WiFi/examples/WiFiSmartConfig" 11 | 12 | install: 13 | - cmd: git submodule update --init --recursive 14 | - cmd: SET PATH=%PATH%;C:\Python27\Scripts 15 | - cmd: pip install -U https://github.com/platformio/platformio/archive/develop.zip 16 | - cmd: platformio platform install https://github.com/platformio/platform-espressif32.git#feature/stage 17 | 18 | test_script: 19 | - cmd: platformio ci -b esp32dev -b nano32 -b node32s 20 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/boards.txt: -------------------------------------------------------------------------------- 1 | menu.UploadSpeed=Upload Speed 2 | menu.FlashFreq=Flash Frequency 3 | menu.DebugLevel=Core Debug Level 4 | 5 | ############################################################## 6 | 7 | WIFI_Kit_32.name=WIFI_Kit_32 8 | 9 | WIFI_Kit_32.upload.tool=esptool 10 | WIFI_Kit_32.upload.maximum_size=1044464 11 | WIFI_Kit_32.upload.maximum_data_size=294912 12 | WIFI_Kit_32.upload.wait_for_upload_port=true 13 | 14 | WIFI_Kit_32.serial.disableDTR=true 15 | WIFI_Kit_32.serial.disableRTS=true 16 | 17 | WIFI_Kit_32.build.mcu=esp32 18 | WIFI_Kit_32.build.core=esp32 19 | WIFI_Kit_32.build.variant=WIFI_Kit_32 20 | WIFI_Kit_32.build.board=WIFI_Kit_32 21 | 22 | WIFI_Kit_32.build.f_cpu=240000000L 23 | WIFI_Kit_32.build.flash_mode=dio 24 | WIFI_Kit_32.build.flash_size=4MB 25 | 26 | WIFI_Kit_32.menu.FlashFreq.80=80MHz 27 | WIFI_Kit_32.menu.FlashFreq.80.build.flash_freq=80m 28 | WIFI_Kit_32.menu.FlashFreq.40=40MHz 29 | WIFI_Kit_32.menu.FlashFreq.40.build.flash_freq=40m 30 | 31 | WIFI_Kit_32.menu.UploadSpeed.921600=921600 32 | WIFI_Kit_32.menu.UploadSpeed.921600.upload.speed=921600 33 | WIFI_Kit_32.menu.UploadSpeed.115200=115200 34 | WIFI_Kit_32.menu.UploadSpeed.115200.upload.speed=115200 35 | WIFI_Kit_32.menu.UploadSpeed.256000.windows=256000 36 | WIFI_Kit_32.menu.UploadSpeed.256000.upload.speed=256000 37 | WIFI_Kit_32.menu.UploadSpeed.230400.windows.upload.speed=256000 38 | WIFI_Kit_32.menu.UploadSpeed.230400=230400 39 | WIFI_Kit_32.menu.UploadSpeed.230400.upload.speed=230400 40 | WIFI_Kit_32.menu.UploadSpeed.460800.linux=460800 41 | WIFI_Kit_32.menu.UploadSpeed.460800.macosx=460800 42 | WIFI_Kit_32.menu.UploadSpeed.460800.upload.speed=460800 43 | WIFI_Kit_32.menu.UploadSpeed.512000.windows=512000 44 | WIFI_Kit_32.menu.UploadSpeed.512000.upload.speed=512000 45 | 46 | ############################################################## 47 | 48 | WIFI_LoRa_32.name=WIFI_LoRa_32 49 | 50 | WIFI_LoRa_32.upload.tool=esptool 51 | WIFI_LoRa_32.upload.maximum_size=1044464 52 | WIFI_LoRa_32.upload.maximum_data_size=294912 53 | WIFI_LoRa_32.upload.wait_for_upload_port=true 54 | 55 | WIFI_LoRa_32.serial.disableDTR=true 56 | WIFI_LoRa_32.serial.disableRTS=true 57 | 58 | WIFI_LoRa_32.build.mcu=esp32 59 | WIFI_LoRa_32.build.core=esp32 60 | WIFI_LoRa_32.build.variant=WIFI_LoRa_32 61 | WIFI_LoRa_32.build.board=WIFI_LoRa_32 62 | 63 | WIFI_LoRa_32.build.f_cpu=240000000L 64 | WIFI_LoRa_32.build.flash_mode=dio 65 | WIFI_LoRa_32.build.flash_size=4MB 66 | 67 | WIFI_LoRa_32.menu.FlashFreq.80=80MHz 68 | WIFI_LoRa_32.menu.FlashFreq.80.build.flash_freq=80m 69 | WIFI_LoRa_32.menu.FlashFreq.40=40MHz 70 | WIFI_LoRa_32.menu.FlashFreq.40.build.flash_freq=40m 71 | 72 | WIFI_LoRa_32.menu.UploadSpeed.921600=921600 73 | WIFI_LoRa_32.menu.UploadSpeed.921600.upload.speed=921600 74 | WIFI_LoRa_32.menu.UploadSpeed.115200=115200 75 | WIFI_LoRa_32.menu.UploadSpeed.115200.upload.speed=115200 76 | WIFI_LoRa_32.menu.UploadSpeed.256000.windows=256000 77 | WIFI_LoRa_32.menu.UploadSpeed.256000.upload.speed=256000 78 | WIFI_LoRa_32.menu.UploadSpeed.230400.windows.upload.speed=256000 79 | WIFI_LoRa_32.menu.UploadSpeed.230400=230400 80 | WIFI_LoRa_32.menu.UploadSpeed.230400.upload.speed=230400 81 | WIFI_LoRa_32.menu.UploadSpeed.460800.linux=460800 82 | WIFI_LoRa_32.menu.UploadSpeed.460800.macosx=460800 83 | WIFI_LoRa_32.menu.UploadSpeed.460800.upload.speed=460800 84 | WIFI_LoRa_32.menu.UploadSpeed.512000.windows=512000 85 | WIFI_LoRa_32.menu.UploadSpeed.512000.upload.speed=512000 86 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/component.mk: -------------------------------------------------------------------------------- 1 | ARDUINO_LIB_DIRS := libraries/WiFi/src libraries/SPI/src libraries/Wire/src libraries/Preferences/src 2 | 3 | COMPONENT_ADD_INCLUDEDIRS := cores/esp32 variants/esp32 $(ARDUINO_LIB_DIRS) 4 | COMPONENT_PRIV_INCLUDEDIRS := cores/esp32/libb64 5 | COMPONENT_SRCDIRS := cores/esp32/libb64 cores/esp32 variants/esp32 $(ARDUINO_LIB_DIRS) 6 | CXXFLAGS += -fno-rtti 7 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/Client.h: -------------------------------------------------------------------------------- 1 | /* 2 | Client.h - Base class that provides Client 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef client_h 21 | #define client_h 22 | #include "Print.h" 23 | #include "Stream.h" 24 | #include "IPAddress.h" 25 | 26 | class Client: public Stream 27 | { 28 | public: 29 | virtual int connect(IPAddress ip, uint16_t port) =0; 30 | virtual int connect(const char *host, uint16_t port) =0; 31 | virtual size_t write(uint8_t) =0; 32 | virtual size_t write(const uint8_t *buf, size_t size) =0; 33 | virtual int available() = 0; 34 | virtual int read() = 0; 35 | virtual int read(uint8_t *buf, size_t size) = 0; 36 | virtual int peek() = 0; 37 | virtual void flush() = 0; 38 | virtual void stop() = 0; 39 | virtual uint8_t connected() = 0; 40 | virtual operator bool() = 0; 41 | protected: 42 | uint8_t* rawIPAddress(IPAddress& addr) 43 | { 44 | return addr.raw_address(); 45 | } 46 | }; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/Esp.h: -------------------------------------------------------------------------------- 1 | /* 2 | Esp.h - ESP31B-specific APIs 3 | Copyright (c) 2015 Ivan Grokhotkov. All rights reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef ESP_H 21 | #define ESP_H 22 | 23 | #include 24 | 25 | /** 26 | * AVR macros for WDT managment 27 | */ 28 | typedef enum { 29 | WDTO_0MS = 0, //!< WDTO_0MS 30 | WDTO_15MS = 15, //!< WDTO_15MS 31 | WDTO_30MS = 30, //!< WDTO_30MS 32 | WDTO_60MS = 60, //!< WDTO_60MS 33 | WDTO_120MS = 120, //!< WDTO_120MS 34 | WDTO_250MS = 250, //!< WDTO_250MS 35 | WDTO_500MS = 500, //!< WDTO_500MS 36 | WDTO_1S = 1000,//!< WDTO_1S 37 | WDTO_2S = 2000,//!< WDTO_2S 38 | WDTO_4S = 4000,//!< WDTO_4S 39 | WDTO_8S = 8000 //!< WDTO_8S 40 | } WDTO_t; 41 | 42 | 43 | typedef enum { 44 | FM_QIO = 0x00, 45 | FM_QOUT = 0x01, 46 | FM_DIO = 0x02, 47 | FM_DOUT = 0x03, 48 | FM_UNKNOWN = 0xff 49 | } FlashMode_t; 50 | 51 | class EspClass 52 | { 53 | public: 54 | EspClass() {} 55 | ~EspClass() {} 56 | void restart(); 57 | uint32_t getFreeHeap(); 58 | uint8_t getCpuFreqMHz(){ return CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ; } 59 | uint32_t getCycleCount(); 60 | const char * getSdkVersion(); 61 | 62 | void deepSleep(uint32_t time_us); 63 | 64 | uint32_t getFlashChipSize(); 65 | uint32_t getFlashChipSpeed(); 66 | FlashMode_t getFlashChipMode(); 67 | 68 | uint32_t magicFlashChipSize(uint8_t byte); 69 | uint32_t magicFlashChipSpeed(uint8_t byte); 70 | FlashMode_t magicFlashChipMode(uint8_t byte); 71 | 72 | bool flashEraseSector(uint32_t sector); 73 | bool flashWrite(uint32_t offset, uint32_t *data, size_t size); 74 | bool flashRead(uint32_t offset, uint32_t *data, size_t size); 75 | 76 | }; 77 | 78 | extern EspClass ESP; 79 | 80 | #endif //ESP_H 81 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/HardwareSerial.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "HardwareSerial.h" 7 | 8 | HardwareSerial Serial(0); 9 | 10 | HardwareSerial::HardwareSerial(int uart_nr) : _uart_nr(uart_nr), _uart(NULL) {} 11 | 12 | void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin) 13 | { 14 | if(_uart_nr == 0 && rxPin < 0 && txPin < 0) { 15 | rxPin = 3; 16 | txPin = 1; 17 | } 18 | if(_uart_nr == 1 && rxPin < 0 && txPin < 0) { 19 | rxPin = 9; 20 | txPin = 10; 21 | } 22 | if(_uart_nr == 2 && rxPin < 0 && txPin < 0) { 23 | rxPin = 16; 24 | txPin = 17; 25 | } 26 | _uart = uartBegin(_uart_nr, baud, config, rxPin, txPin, 256, false); 27 | } 28 | 29 | void HardwareSerial::end() 30 | { 31 | if(uartGetDebug() == _uart_nr) { 32 | uartSetDebug(0); 33 | } 34 | uartEnd(_uart); 35 | _uart = 0; 36 | } 37 | 38 | void HardwareSerial::setDebugOutput(bool en) 39 | { 40 | if(_uart == 0) { 41 | return; 42 | } 43 | if(en) { 44 | uartSetDebug(_uart); 45 | } else { 46 | if(uartGetDebug() == _uart_nr) { 47 | uartSetDebug(0); 48 | } 49 | } 50 | } 51 | 52 | int HardwareSerial::available(void) 53 | { 54 | return uartAvailable(_uart); 55 | } 56 | 57 | int HardwareSerial::peek(void) 58 | { 59 | if (available()) { 60 | return uartPeek(_uart); 61 | } 62 | return -1; 63 | } 64 | 65 | int HardwareSerial::read(void) 66 | { 67 | if(available()) { 68 | return uartRead(_uart); 69 | } 70 | return -1; 71 | } 72 | 73 | void HardwareSerial::flush() 74 | { 75 | uartFlush(_uart); 76 | } 77 | 78 | size_t HardwareSerial::write(uint8_t c) 79 | { 80 | uartWrite(_uart, c); 81 | return 1; 82 | } 83 | 84 | size_t HardwareSerial::write(const uint8_t *buffer, size_t size) 85 | { 86 | uartWriteBuf(_uart, buffer, size); 87 | return size; 88 | } 89 | 90 | HardwareSerial::operator bool() const 91 | { 92 | return _uart != 0; 93 | } 94 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/HardwareSerial.h: -------------------------------------------------------------------------------- 1 | /* 2 | HardwareSerial.h - Hardware serial library for Wiring 3 | Copyright (c) 2006 Nicholas Zambetti. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Modified 28 September 2010 by Mark Sproul 20 | Modified 14 August 2012 by Alarus 21 | Modified 3 December 2013 by Matthijs Kooijman 22 | Modified 18 December 2014 by Ivan Grokhotkov (esp8266 platform support) 23 | Modified 31 March 2015 by Markus Sattler (rewrite the code for UART0 + UART1 support in ESP8266) 24 | Modified 25 April 2015 by Thomas Flayols (add configuration different from 8N1 in ESP8266) 25 | */ 26 | 27 | #ifndef HardwareSerial_h 28 | #define HardwareSerial_h 29 | 30 | #include 31 | 32 | #include "Stream.h" 33 | #include "esp32-hal.h" 34 | 35 | class HardwareSerial: public Stream 36 | { 37 | public: 38 | HardwareSerial(int uart_nr); 39 | 40 | void begin(unsigned long baud, uint32_t config=SERIAL_8N1, int8_t rxPin=-1, int8_t txPin=-1); 41 | void end(); 42 | int available(void); 43 | int peek(void); 44 | int read(void); 45 | void flush(void); 46 | size_t write(uint8_t); 47 | size_t write(const uint8_t *buffer, size_t size); 48 | 49 | inline size_t write(const char * s) 50 | { 51 | return write((uint8_t*) s, strlen(s)); 52 | } 53 | inline size_t write(unsigned long n) 54 | { 55 | return write((uint8_t) n); 56 | } 57 | inline size_t write(long n) 58 | { 59 | return write((uint8_t) n); 60 | } 61 | inline size_t write(unsigned int n) 62 | { 63 | return write((uint8_t) n); 64 | } 65 | inline size_t write(int n) 66 | { 67 | return write((uint8_t) n); 68 | } 69 | operator bool() const; 70 | 71 | void setDebugOutput(bool); 72 | 73 | protected: 74 | int _uart_nr; 75 | uart_t* _uart; 76 | }; 77 | 78 | extern HardwareSerial Serial; 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/IPAddress.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | IPAddress.cpp - Base class that provides IPAddress 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | IPAddress::IPAddress() 25 | { 26 | _address.dword = 0; 27 | } 28 | 29 | IPAddress::IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet) 30 | { 31 | _address.bytes[0] = first_octet; 32 | _address.bytes[1] = second_octet; 33 | _address.bytes[2] = third_octet; 34 | _address.bytes[3] = fourth_octet; 35 | } 36 | 37 | IPAddress::IPAddress(uint32_t address) 38 | { 39 | _address.dword = address; 40 | } 41 | 42 | IPAddress::IPAddress(const uint8_t *address) 43 | { 44 | memcpy(_address.bytes, address, sizeof(_address.bytes)); 45 | } 46 | 47 | IPAddress& IPAddress::operator=(const uint8_t *address) 48 | { 49 | memcpy(_address.bytes, address, sizeof(_address.bytes)); 50 | return *this; 51 | } 52 | 53 | IPAddress& IPAddress::operator=(uint32_t address) 54 | { 55 | _address.dword = address; 56 | return *this; 57 | } 58 | 59 | bool IPAddress::operator==(const uint8_t* addr) const 60 | { 61 | return memcmp(addr, _address.bytes, sizeof(_address.bytes)) == 0; 62 | } 63 | 64 | size_t IPAddress::printTo(Print& p) const 65 | { 66 | size_t n = 0; 67 | for(int i = 0; i < 3; i++) { 68 | n += p.print(_address.bytes[i], DEC); 69 | n += p.print('.'); 70 | } 71 | n += p.print(_address.bytes[3], DEC); 72 | return n; 73 | } 74 | 75 | String IPAddress::toString() const 76 | { 77 | char szRet[16]; 78 | sprintf(szRet,"%u.%u.%u.%u", _address.bytes[0], _address.bytes[1], _address.bytes[2], _address.bytes[3]); 79 | return String(szRet); 80 | } 81 | 82 | bool IPAddress::fromString(const char *address) 83 | { 84 | // TODO: add support for "a", "a.b", "a.b.c" formats 85 | 86 | uint16_t acc = 0; // Accumulator 87 | uint8_t dots = 0; 88 | 89 | while (*address) 90 | { 91 | char c = *address++; 92 | if (c >= '0' && c <= '9') 93 | { 94 | acc = acc * 10 + (c - '0'); 95 | if (acc > 255) { 96 | // Value out of [0..255] range 97 | return false; 98 | } 99 | } 100 | else if (c == '.') 101 | { 102 | if (dots == 3) { 103 | // Too much dots (there must be 3 dots) 104 | return false; 105 | } 106 | _address.bytes[dots++] = acc; 107 | acc = 0; 108 | } 109 | else 110 | { 111 | // Invalid char 112 | return false; 113 | } 114 | } 115 | 116 | if (dots != 3) { 117 | // Too few dots (there must be 3 dots) 118 | return false; 119 | } 120 | _address.bytes[3] = acc; 121 | return true; 122 | } 123 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/IPAddress.h: -------------------------------------------------------------------------------- 1 | /* 2 | IPAddress.h - Base class that provides IPAddress 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef IPAddress_h 21 | #define IPAddress_h 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | // A class to make it easier to handle and pass around IP addresses 28 | 29 | class IPAddress: public Printable 30 | { 31 | private: 32 | union { 33 | uint8_t bytes[4]; // IPv4 address 34 | uint32_t dword; 35 | } _address; 36 | 37 | // Access the raw byte array containing the address. Because this returns a pointer 38 | // to the internal structure rather than a copy of the address this function should only 39 | // be used when you know that the usage of the returned uint8_t* will be transient and not 40 | // stored. 41 | uint8_t* raw_address() 42 | { 43 | return _address.bytes; 44 | } 45 | 46 | public: 47 | // Constructors 48 | IPAddress(); 49 | IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet); 50 | IPAddress(uint32_t address); 51 | IPAddress(const uint8_t *address); 52 | virtual ~IPAddress() {} 53 | 54 | bool fromString(const char *address); 55 | bool fromString(const String &address) { return fromString(address.c_str()); } 56 | 57 | // Overloaded cast operator to allow IPAddress objects to be used where a pointer 58 | // to a four-byte uint8_t array is expected 59 | operator uint32_t() const 60 | { 61 | return _address.dword; 62 | } 63 | bool operator==(const IPAddress& addr) const 64 | { 65 | return _address.dword == addr._address.dword; 66 | } 67 | bool operator==(const uint8_t* addr) const; 68 | 69 | // Overloaded index operator to allow getting and setting individual octets of the address 70 | uint8_t operator[](int index) const 71 | { 72 | return _address.bytes[index]; 73 | } 74 | uint8_t& operator[](int index) 75 | { 76 | return _address.bytes[index]; 77 | } 78 | 79 | // Overloaded copy operators to allow initialisation of IPAddress objects from other types 80 | IPAddress& operator=(const uint8_t *address); 81 | IPAddress& operator=(uint32_t address); 82 | 83 | virtual size_t printTo(Print& p) const; 84 | String toString() const; 85 | 86 | friend class EthernetClass; 87 | friend class UDP; 88 | friend class Client; 89 | friend class Server; 90 | friend class DhcpClass; 91 | friend class DNSClient; 92 | }; 93 | 94 | const IPAddress INADDR_NONE(0, 0, 0, 0); 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/IPv6Address.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | IPv6Address.cpp - Base class that provides IPv6Address 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | IPv6Address::IPv6Address() 25 | { 26 | memset(_address.bytes, 0, sizeof(_address.bytes)); 27 | } 28 | 29 | IPv6Address::IPv6Address(const uint8_t *address) 30 | { 31 | memcpy(_address.bytes, address, sizeof(_address.bytes)); 32 | } 33 | 34 | IPv6Address::IPv6Address(const uint32_t *address) 35 | { 36 | memcpy(_address.bytes, (const uint8_t *)address, sizeof(_address.bytes)); 37 | } 38 | 39 | IPv6Address& IPv6Address::operator=(const uint8_t *address) 40 | { 41 | memcpy(_address.bytes, address, sizeof(_address.bytes)); 42 | return *this; 43 | } 44 | 45 | bool IPv6Address::operator==(const uint8_t* addr) const 46 | { 47 | return memcmp(addr, _address.bytes, sizeof(_address.bytes)) == 0; 48 | } 49 | 50 | size_t IPv6Address::printTo(Print& p) const 51 | { 52 | size_t n = 0; 53 | for(int i = 0; i < 16; i+=2) { 54 | if(i){ 55 | n += p.print(':'); 56 | } 57 | n += p.printf("%02x", _address.bytes[i]); 58 | n += p.printf("%02x", _address.bytes[i+1]); 59 | 60 | } 61 | return n; 62 | } 63 | 64 | String IPv6Address::toString() const 65 | { 66 | char szRet[40]; 67 | sprintf(szRet,"%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x", 68 | _address.bytes[0], _address.bytes[1], _address.bytes[2], _address.bytes[3], 69 | _address.bytes[4], _address.bytes[5], _address.bytes[6], _address.bytes[7], 70 | _address.bytes[8], _address.bytes[9], _address.bytes[10], _address.bytes[11], 71 | _address.bytes[12], _address.bytes[13], _address.bytes[14], _address.bytes[15]); 72 | return String(szRet); 73 | } 74 | 75 | bool IPv6Address::fromString(const char *address) 76 | { 77 | //format 0011:2233:4455:6677:8899:aabb:ccdd:eeff 78 | if(strlen(address) != 39){ 79 | return false; 80 | } 81 | char * pos = (char *)address; 82 | size_t i = 0; 83 | for(i = 0; i < 16; i+=2) { 84 | if(!sscanf(pos, "%2hhx", &_address.bytes[i]) || !sscanf(pos+2, "%2hhx", &_address.bytes[i+1])){ 85 | return false; 86 | } 87 | pos += 5; 88 | } 89 | return true; 90 | } 91 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/IPv6Address.h: -------------------------------------------------------------------------------- 1 | /* 2 | IPv6Address.h - Base class that provides IPv6Address 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef IPv6Address_h 21 | #define IPv6Address_h 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | // A class to make it easier to handle and pass around IP addresses 28 | 29 | class IPv6Address: public Printable 30 | { 31 | private: 32 | union { 33 | uint8_t bytes[16]; // IPv4 address 34 | uint32_t dword[4]; 35 | } _address; 36 | 37 | // Access the raw byte array containing the address. Because this returns a pointer 38 | // to the internal structure rather than a copy of the address this function should only 39 | // be used when you know that the usage of the returned uint8_t* will be transient and not 40 | // stored. 41 | uint8_t* raw_address() 42 | { 43 | return _address.bytes; 44 | } 45 | 46 | public: 47 | // Constructors 48 | IPv6Address(); 49 | IPv6Address(const uint8_t *address); 50 | IPv6Address(const uint32_t *address); 51 | virtual ~IPv6Address() {} 52 | 53 | bool fromString(const char *address); 54 | bool fromString(const String &address) { return fromString(address.c_str()); } 55 | 56 | operator const uint8_t*() const 57 | { 58 | return _address.bytes; 59 | } 60 | operator const uint32_t*() const 61 | { 62 | return _address.dword; 63 | } 64 | bool operator==(const IPv6Address& addr) const 65 | { 66 | return (_address.dword[0] == addr._address.dword[0]) 67 | && (_address.dword[1] == addr._address.dword[1]) 68 | && (_address.dword[2] == addr._address.dword[2]) 69 | && (_address.dword[3] == addr._address.dword[3]); 70 | } 71 | bool operator==(const uint8_t* addr) const; 72 | 73 | // Overloaded index operator to allow getting and setting individual octets of the address 74 | uint8_t operator[](int index) const 75 | { 76 | return _address.bytes[index]; 77 | } 78 | uint8_t& operator[](int index) 79 | { 80 | return _address.bytes[index]; 81 | } 82 | 83 | // Overloaded copy operators to allow initialisation of IPv6Address objects from other types 84 | IPv6Address& operator=(const uint8_t *address); 85 | 86 | virtual size_t printTo(Print& p) const; 87 | String toString() const; 88 | 89 | friend class UDP; 90 | friend class Client; 91 | friend class Server; 92 | }; 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/MD5Builder.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Hristo Gochkov. All rights reserved. 3 | This file is part of the esp8266 core for Arduino environment. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | #include 20 | #include 21 | 22 | uint8_t hex_char_to_byte(uint8_t c) 23 | { 24 | return (c >= 'a' && c <= 'f') ? (c - ((uint8_t)'a' - 0xa)) : 25 | (c >= 'A' && c <= 'F') ? (c - ((uint8_t)'A' - 0xA)) : 26 | (c >= '0' && c<= '9') ? (c - (uint8_t)'0') : 0; 27 | } 28 | 29 | void MD5Builder::begin(void) 30 | { 31 | memset(_buf, 0x00, 16); 32 | MD5Init(&_ctx); 33 | } 34 | 35 | void MD5Builder::add(uint8_t * data, uint16_t len) 36 | { 37 | MD5Update(&_ctx, data, len); 38 | } 39 | 40 | void MD5Builder::addHexString(const char * data) 41 | { 42 | uint16_t i, len = strlen(data); 43 | uint8_t * tmp = (uint8_t*)malloc(len/2); 44 | if(tmp == NULL) { 45 | return; 46 | } 47 | for(i=0; i 0) && (maxLengthLeft > 0)) { 68 | 69 | // determine number of bytes to read 70 | int readBytes = bytesAvailable; 71 | if(readBytes > maxLengthLeft) { 72 | readBytes = maxLengthLeft ; // read only until max_len 73 | } 74 | if(readBytes > buf_size) { 75 | readBytes = buf_size; // not read more the buffer can handle 76 | } 77 | 78 | // read data and check if we got something 79 | int numBytesRead = stream.readBytes(buf, readBytes); 80 | if(numBytesRead< 1) { 81 | return false; 82 | } 83 | 84 | // Update MD5 with buffer payload 85 | MD5Update(&_ctx, buf, numBytesRead); 86 | 87 | // update available number of bytes 88 | maxLengthLeft -= numBytesRead; 89 | bytesAvailable = stream.available(); 90 | } 91 | free(buf); 92 | return true; 93 | } 94 | 95 | void MD5Builder::calculate(void) 96 | { 97 | MD5Final(_buf, &_ctx); 98 | } 99 | 100 | void MD5Builder::getBytes(uint8_t * output) 101 | { 102 | memcpy(output, _buf, 16); 103 | } 104 | 105 | void MD5Builder::getChars(char * output) 106 | { 107 | for(uint8_t i = 0; i < 16; i++) { 108 | sprintf(output + (i * 2), "%02x", _buf[i]); 109 | } 110 | } 111 | 112 | String MD5Builder::toString(void) 113 | { 114 | char out[33]; 115 | getChars(out); 116 | return String(out); 117 | } 118 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/MD5Builder.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Hristo Gochkov. All rights reserved. 3 | This file is part of the esp8266 core for Arduino environment. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | #ifndef __ESP8266_MD5_BUILDER__ 20 | #define __ESP8266_MD5_BUILDER__ 21 | 22 | #include 23 | #include 24 | #include "rom/md5_hash.h" 25 | 26 | class MD5Builder 27 | { 28 | private: 29 | struct MD5Context _ctx; 30 | uint8_t _buf[16]; 31 | public: 32 | void begin(void); 33 | void add(uint8_t * data, uint16_t len); 34 | void add(const char * data) 35 | { 36 | add((uint8_t*)data, strlen(data)); 37 | } 38 | void add(char * data) 39 | { 40 | add((const char*)data); 41 | } 42 | void add(String data) 43 | { 44 | add(data.c_str()); 45 | } 46 | void addHexString(const char * data); 47 | void addHexString(char * data) 48 | { 49 | addHexString((const char*)data); 50 | } 51 | void addHexString(String data) 52 | { 53 | addHexString(data.c_str()); 54 | } 55 | bool addStream(Stream & stream, const size_t maxLen); 56 | void calculate(void); 57 | void getBytes(uint8_t * output); 58 | void getChars(char * output); 59 | String toString(void); 60 | }; 61 | 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/Print.h: -------------------------------------------------------------------------------- 1 | /* 2 | Print.h - Base class that provides print() and println() 3 | Copyright (c) 2008 David A. Mellis. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef Print_h 21 | #define Print_h 22 | 23 | #include 24 | #include 25 | 26 | #include "WString.h" 27 | #include "Printable.h" 28 | 29 | #define DEC 10 30 | #define HEX 16 31 | #define OCT 8 32 | #define BIN 2 33 | 34 | class Print 35 | { 36 | private: 37 | int write_error; 38 | size_t printNumber(unsigned long, uint8_t); 39 | size_t printFloat(double, uint8_t); 40 | protected: 41 | void setWriteError(int err = 1) 42 | { 43 | write_error = err; 44 | } 45 | public: 46 | Print() : 47 | write_error(0) 48 | { 49 | } 50 | virtual ~Print() {} 51 | int getWriteError() 52 | { 53 | return write_error; 54 | } 55 | void clearWriteError() 56 | { 57 | setWriteError(0); 58 | } 59 | 60 | virtual size_t write(uint8_t) = 0; 61 | size_t write(const char *str) 62 | { 63 | if(str == NULL) { 64 | return 0; 65 | } 66 | return write((const uint8_t *) str, strlen(str)); 67 | } 68 | virtual size_t write(const uint8_t *buffer, size_t size); 69 | size_t write(const char *buffer, size_t size) 70 | { 71 | return write((const uint8_t *) buffer, size); 72 | } 73 | 74 | size_t printf(const char * format, ...) __attribute__ ((format (printf, 2, 3))); 75 | size_t print(const __FlashStringHelper *); 76 | size_t print(const String &); 77 | size_t print(const char[]); 78 | size_t print(char); 79 | size_t print(unsigned char, int = DEC); 80 | size_t print(int, int = DEC); 81 | size_t print(unsigned int, int = DEC); 82 | size_t print(long, int = DEC); 83 | size_t print(unsigned long, int = DEC); 84 | size_t print(double, int = 2); 85 | size_t print(const Printable&); 86 | size_t print(struct tm * timeinfo, const char * format = NULL); 87 | 88 | size_t println(const __FlashStringHelper *); 89 | size_t println(const String &s); 90 | size_t println(const char[]); 91 | size_t println(char); 92 | size_t println(unsigned char, int = DEC); 93 | size_t println(int, int = DEC); 94 | size_t println(unsigned int, int = DEC); 95 | size_t println(long, int = DEC); 96 | size_t println(unsigned long, int = DEC); 97 | size_t println(double, int = 2); 98 | size_t println(const Printable&); 99 | size_t println(struct tm * timeinfo, const char * format = NULL); 100 | size_t println(void); 101 | }; 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/Printable.h: -------------------------------------------------------------------------------- 1 | /* 2 | Printable.h - Interface class that allows printing of complex types 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef Printable_h 21 | #define Printable_h 22 | 23 | #include 24 | 25 | class Print; 26 | 27 | /** The Printable class provides a way for new classes to allow themselves to be printed. 28 | By deriving from Printable and implementing the printTo method, it will then be possible 29 | for users to print out instances of this class by passing them into the usual 30 | Print::print and Print::println methods. 31 | */ 32 | 33 | class Printable 34 | { 35 | public: 36 | virtual ~Printable() {} 37 | virtual size_t printTo(Print& p) const = 0; 38 | }; 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/Server.h: -------------------------------------------------------------------------------- 1 | /* 2 | Server.h - Base class that provides Server 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef server_h 21 | #define server_h 22 | 23 | #include "Print.h" 24 | 25 | class Server: public Print 26 | { 27 | public: 28 | virtual void begin() =0; 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/StreamString.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | StreamString.cpp 3 | 4 | Copyright (c) 2015 Markus Sattler. All rights reserved. 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | 20 | */ 21 | 22 | #include 23 | #include "StreamString.h" 24 | 25 | size_t StreamString::write(const uint8_t *data, size_t size) 26 | { 27 | if(size && data) { 28 | if(reserve(length() + size + 1)) { 29 | memcpy((void *) (buffer + len), (const void *) data, size); 30 | len += size; 31 | *(buffer + len) = 0x00; // add null for string end 32 | return size; 33 | } 34 | } 35 | return 0; 36 | } 37 | 38 | size_t StreamString::write(uint8_t data) 39 | { 40 | return concat((char) data); 41 | } 42 | 43 | int StreamString::available() 44 | { 45 | return length(); 46 | } 47 | 48 | int StreamString::read() 49 | { 50 | if(length()) { 51 | char c = charAt(0); 52 | remove(0, 1); 53 | return c; 54 | 55 | } 56 | return -1; 57 | } 58 | 59 | int StreamString::peek() 60 | { 61 | if(length()) { 62 | char c = charAt(0); 63 | return c; 64 | } 65 | return -1; 66 | } 67 | 68 | void StreamString::flush() 69 | { 70 | } 71 | 72 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/StreamString.h: -------------------------------------------------------------------------------- 1 | /** 2 | StreamString.h 3 | 4 | Copyright (c) 2015 Markus Sattler. All rights reserved. 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | 20 | */ 21 | 22 | #ifndef STREAMSTRING_H_ 23 | #define STREAMSTRING_H_ 24 | 25 | 26 | class StreamString: public Stream, public String 27 | { 28 | public: 29 | size_t write(const uint8_t *buffer, size_t size) override; 30 | size_t write(uint8_t data) override; 31 | 32 | int available() override; 33 | int read() override; 34 | int peek() override; 35 | void flush() override; 36 | }; 37 | 38 | 39 | #endif /* STREAMSTRING_H_ */ 40 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/WMath.cpp: -------------------------------------------------------------------------------- 1 | /* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ 2 | 3 | /* 4 | Part of the Wiring project - http://wiring.org.co 5 | Copyright (c) 2004-06 Hernando Barragan 6 | Modified 13 August 2006, David A. Mellis for Arduino - http://www.arduino.cc/ 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General 19 | Public License along with this library; if not, write to the 20 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, 21 | Boston, MA 02111-1307 USA 22 | 23 | $Id$ 24 | */ 25 | 26 | extern "C" { 27 | #include 28 | #include "esp_system.h" 29 | } 30 | 31 | void randomSeed(unsigned long seed) 32 | { 33 | if(seed != 0) { 34 | srand(seed); 35 | } 36 | } 37 | 38 | long random(long howbig) 39 | { 40 | if(howbig == 0) { 41 | return 0; 42 | } 43 | return esp_random() % howbig; 44 | } 45 | 46 | long random(long howsmall, long howbig) 47 | { 48 | if(howsmall >= howbig) { 49 | return howsmall; 50 | } 51 | long diff = howbig - howsmall; 52 | return random(diff) + howsmall; 53 | } 54 | 55 | long map(long x, long in_min, long in_max, long out_min, long out_max) 56 | { 57 | return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; 58 | } 59 | 60 | unsigned int makeWord(unsigned int w) 61 | { 62 | return w; 63 | } 64 | 65 | unsigned int makeWord(unsigned char h, unsigned char l) 66 | { 67 | return (h << 8) | l; 68 | } 69 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/base64.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * base64.cpp 3 | * 4 | * Created on: 09.12.2015 5 | * 6 | * Copyright (c) 2015 Markus Sattler. All rights reserved. 7 | * This file is part of the ESP31B core for Arduino. 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 | * 23 | */ 24 | 25 | #include "Arduino.h" 26 | extern "C" { 27 | #include "libb64/cdecode.h" 28 | #include "libb64/cencode.h" 29 | } 30 | #include "base64.h" 31 | 32 | /** 33 | * convert input data to base64 34 | * @param data uint8_t * 35 | * @param length size_t 36 | * @return String 37 | */ 38 | String base64::encode(uint8_t * data, size_t length) 39 | { 40 | // base64 needs more size then the source data 41 | size_t size = ((length * 1.6f) + 1); 42 | char * buffer = (char *) malloc(size); 43 | if(buffer) { 44 | base64_encodestate _state; 45 | base64_init_encodestate(&_state); 46 | int len = base64_encode_block((const char *) &data[0], length, &buffer[0], &_state); 47 | len = base64_encode_blockend((buffer + len), &_state); 48 | 49 | String base64 = String(buffer); 50 | free(buffer); 51 | return base64; 52 | } 53 | return String("-FAIL-"); 54 | } 55 | 56 | /** 57 | * convert input data to base64 58 | * @param text String 59 | * @return String 60 | */ 61 | String base64::encode(String text) 62 | { 63 | return base64::encode((uint8_t *) text.c_str(), text.length()); 64 | } 65 | 66 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/base64.h: -------------------------------------------------------------------------------- 1 | #ifndef CORE_BASE64_H_ 2 | #define CORE_BASE64_H_ 3 | 4 | class base64 5 | { 6 | public: 7 | static String encode(uint8_t * data, size_t length); 8 | static String encode(String text); 9 | private: 10 | }; 11 | 12 | 13 | #endif /* CORE_BASE64_H_ */ 14 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/cbuf.h: -------------------------------------------------------------------------------- 1 | /* 2 | cbuf.h - Circular buffer implementation 3 | Copyright (c) 2014 Ivan Grokhotkov. All rights reserved. 4 | This file is part of the esp8266 core for Arduino environment. 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef __cbuf_h 22 | #define __cbuf_h 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | class cbuf 29 | { 30 | public: 31 | cbuf(size_t size); 32 | ~cbuf(); 33 | 34 | size_t resizeAdd(size_t addSize); 35 | size_t resize(size_t newSize); 36 | size_t available() const; 37 | size_t size(); 38 | 39 | size_t room() const; 40 | 41 | inline bool empty() const 42 | { 43 | return _begin == _end; 44 | } 45 | 46 | inline bool full() const 47 | { 48 | return wrap_if_bufend(_end + 1) == _begin; 49 | } 50 | 51 | int peek(); 52 | size_t peek(char *dst, size_t size); 53 | 54 | int read(); 55 | size_t read(char* dst, size_t size); 56 | 57 | size_t write(char c); 58 | size_t write(const char* src, size_t size); 59 | 60 | void flush(); 61 | size_t remove(size_t size); 62 | 63 | cbuf *next; 64 | 65 | private: 66 | inline char* wrap_if_bufend(char* ptr) const 67 | { 68 | return (ptr == _bufend) ? _buf : ptr; 69 | } 70 | 71 | size_t _size; 72 | char* _buf; 73 | const char* _bufend; 74 | char* _begin; 75 | char* _end; 76 | 77 | }; 78 | 79 | #endif//__cbuf_h 80 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/esp32-hal-adc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Arduino.h - Main include file for the Arduino SDK 3 | Copyright (c) 2005-2013 Arduino Team. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef MAIN_ESP32_HAL_ADC_H_ 21 | #define MAIN_ESP32_HAL_ADC_H_ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include "esp32-hal.h" 28 | 29 | typedef enum { 30 | ADC_0db, 31 | ADC_2_5db, 32 | ADC_6db, 33 | ADC_11db 34 | } adc_attenuation_t; 35 | 36 | /* 37 | * Get ADC value for pin 38 | * */ 39 | uint16_t analogRead(uint8_t pin); 40 | 41 | /* 42 | * Sets the sample bits 43 | * Default is 12bit (0 - 4095) 44 | * Range is 9 - 12 45 | * */ 46 | void analogSetWidth(uint8_t bits); 47 | 48 | /* 49 | * Set number of cycles per sample 50 | * Default is 8 and seems to do well 51 | * Range is 1 - 255 52 | * */ 53 | void analogSetCycles(uint8_t cycles); 54 | 55 | /* 56 | * Set number of samples in the range. 57 | * Default is 1 58 | * Range is 1 - 255 59 | * This setting splits the range into 60 | * "samples" pieces, which could look 61 | * like the sensitivity has been multiplied 62 | * that many times 63 | * */ 64 | void analogSetSamples(uint8_t samples); 65 | 66 | /* 67 | * Set the divider for the ADC clock. 68 | * Default is 1 69 | * Range is 1 - 255 70 | * */ 71 | void analogSetClockDiv(uint8_t clockDiv); 72 | 73 | /* 74 | * Set the attenuation for all channels 75 | * Default is 11db 76 | * */ 77 | void analogSetAttenuation(adc_attenuation_t attenuation); 78 | 79 | /* 80 | * Set the attenuation for particular pin 81 | * Default is 11db 82 | * */ 83 | void analogSetPinAttenuation(uint8_t pin, adc_attenuation_t attenuation); 84 | 85 | /* 86 | * Get value for HALL sensor (without LNA) 87 | * connected to pins 36(SVP) and 39(SVN) 88 | * */ 89 | int hallRead(); 90 | 91 | #ifdef __cplusplus 92 | } 93 | #endif 94 | 95 | #endif /* MAIN_ESP32_HAL_ADC_H_ */ 96 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/esp32-hal-dac.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "esp32-hal-dac.h" 16 | #include "freertos/FreeRTOS.h" 17 | #include "freertos/task.h" 18 | #include "rom/ets_sys.h" 19 | #include "esp_attr.h" 20 | #include "esp_intr.h" 21 | #include "soc/rtc_io_reg.h" 22 | #include "soc/rtc_cntl_reg.h" 23 | #include "soc/sens_reg.h" 24 | 25 | void IRAM_ATTR __dacWrite(uint8_t pin, uint8_t value) 26 | { 27 | if(pin < 25 || pin > 26){ 28 | return;//not dac pin 29 | } 30 | pinMode(pin, ANALOG); 31 | uint8_t channel = pin - 25; 32 | 33 | 34 | //Disable Tone 35 | CLEAR_PERI_REG_MASK(SENS_SAR_DAC_CTRL1_REG, SENS_SW_TONE_EN); 36 | 37 | if (channel) { 38 | //Disable Channel Tone 39 | CLEAR_PERI_REG_MASK(SENS_SAR_DAC_CTRL2_REG, SENS_DAC_CW_EN2_M); 40 | //Set the Dac value 41 | SET_PERI_REG_BITS(RTC_IO_PAD_DAC2_REG, RTC_IO_PDAC2_DAC, value, RTC_IO_PDAC2_DAC_S); //dac_output 42 | //Channel output enable 43 | SET_PERI_REG_MASK(RTC_IO_PAD_DAC2_REG, RTC_IO_PDAC2_XPD_DAC | RTC_IO_PDAC2_DAC_XPD_FORCE); 44 | } else { 45 | //Disable Channel Tone 46 | CLEAR_PERI_REG_MASK(SENS_SAR_DAC_CTRL2_REG, SENS_DAC_CW_EN1_M); 47 | //Set the Dac value 48 | SET_PERI_REG_BITS(RTC_IO_PAD_DAC1_REG, RTC_IO_PDAC1_DAC, value, RTC_IO_PDAC1_DAC_S); //dac_output 49 | //Channel output enable 50 | SET_PERI_REG_MASK(RTC_IO_PAD_DAC1_REG, RTC_IO_PDAC1_XPD_DAC | RTC_IO_PDAC1_DAC_XPD_FORCE); 51 | } 52 | } 53 | 54 | extern void dacWrite(uint8_t pin, uint8_t value) __attribute__ ((weak, alias("__dacWrite"))); 55 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/esp32-hal-dac.h: -------------------------------------------------------------------------------- 1 | /* 2 | Arduino.h - Main include file for the Arduino SDK 3 | Copyright (c) 2005-2013 Arduino Team. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef MAIN_ESP32_HAL_DAC_H_ 21 | #define MAIN_ESP32_HAL_DAC_H_ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include "esp32-hal.h" 28 | 29 | void dacWrite(uint8_t pin, uint8_t value); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif /* MAIN_ESP32_HAL_DAC_H_ */ 36 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/esp32-hal-gpio.h: -------------------------------------------------------------------------------- 1 | /* 2 | Arduino.h - Main include file for the Arduino SDK 3 | Copyright (c) 2005-2013 Arduino Team. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef MAIN_ESP32_HAL_GPIO_H_ 21 | #define MAIN_ESP32_HAL_GPIO_H_ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include "esp32-hal.h" 28 | 29 | #define LOW 0x0 30 | #define HIGH 0x1 31 | 32 | //GPIO FUNCTIONS 33 | #define INPUT 0x01 34 | #define OUTPUT 0x02 35 | #define PULLUP 0x04 36 | #define INPUT_PULLUP 0x05 37 | #define PULLDOWN 0x08 38 | #define INPUT_PULLDOWN 0x09 39 | #define OPEN_DRAIN 0x10 40 | #define OUTPUT_OPEN_DRAIN 0x12 41 | #define SPECIAL 0xF0 42 | #define FUNCTION_1 0x00 43 | #define FUNCTION_2 0x20 44 | #define FUNCTION_3 0x40 45 | #define FUNCTION_4 0x60 46 | #define FUNCTION_5 0x80 47 | #define FUNCTION_6 0xA0 48 | #define ANALOG 0xC0 49 | 50 | //Interrupt Modes 51 | #define DISABLED 0x00 52 | #define RISING 0x01 53 | #define FALLING 0x02 54 | #define CHANGE 0x03 55 | #define ONLOW 0x04 56 | #define ONHIGH 0x05 57 | #define ONLOW_WE 0x0C 58 | #define ONHIGH_WE 0x0D 59 | 60 | typedef struct { 61 | uint8_t reg; /*!< GPIO register offset from DR_REG_IO_MUX_BASE */ 62 | int8_t rtc; /*!< RTC GPIO number (-1 if not RTC GPIO pin) */ 63 | int8_t adc; /*!< ADC Channel number (-1 if not ADC pin) */ 64 | int8_t touch; /*!< Touch Channel number (-1 if not Touch pin) */ 65 | } esp32_gpioMux_t; 66 | 67 | extern const esp32_gpioMux_t esp32_gpioMux[40]; 68 | extern const int8_t esp32_adc2gpio[20]; 69 | 70 | #define digitalPinIsValid(pin) ((pin) < 40 && esp32_gpioMux[(pin)].reg) 71 | #define digitalPinCanOutput(pin) ((pin) < 34 && esp32_gpioMux[(pin)].reg) 72 | #define digitalPinToRtcPin(pin) (((pin) < 40)?esp32_gpioMux[(pin)].rtc:-1) 73 | #define digitalPinToAnalogChannel(pin) (((pin) < 40)?esp32_gpioMux[(pin)].adc:-1) 74 | #define digitalPinToTouchChannel(pin) (((pin) < 40)?esp32_gpioMux[(pin)].touch:-1) 75 | #define digitalPinToDacChannel(pin) (((pin) == 25)?0:((pin) == 26)?1:-1) 76 | 77 | void pinMode(uint8_t pin, uint8_t mode); 78 | void digitalWrite(uint8_t pin, uint8_t val); 79 | int digitalRead(uint8_t pin); 80 | 81 | void attachInterrupt(uint8_t pin, void (*)(void), int mode); 82 | void detachInterrupt(uint8_t pin); 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | #endif /* MAIN_ESP32_HAL_GPIO_H_ */ 89 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/esp32-hal-i2c.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _ESP32_HAL_I2C_H_ 16 | #define _ESP32_HAL_I2C_H_ 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | #include 23 | #include 24 | 25 | typedef enum { 26 | I2C_ERROR_OK, 27 | I2C_ERROR_DEV, 28 | I2C_ERROR_ACK, 29 | I2C_ERROR_TIMEOUT, 30 | I2C_ERROR_BUS 31 | } i2c_err_t; 32 | 33 | struct i2c_struct_t; 34 | typedef struct i2c_struct_t i2c_t; 35 | 36 | i2c_t * i2cInit(uint8_t i2c_num, uint16_t slave_addr, bool addr_10bit_en); 37 | 38 | //call this after you setup the bus and pins to send empty packet 39 | //required because when pins are attached, they emit pulses that lock the bus 40 | void i2cInitFix(i2c_t * i2c); 41 | 42 | i2c_err_t i2cSetFrequency(i2c_t * i2c, uint32_t clk_speed); 43 | uint32_t i2cGetFrequency(i2c_t * i2c); 44 | 45 | i2c_err_t i2cAttachSCL(i2c_t * i2c, int8_t scl); 46 | i2c_err_t i2cDetachSCL(i2c_t * i2c, int8_t scl); 47 | i2c_err_t i2cAttachSDA(i2c_t * i2c, int8_t sda); 48 | i2c_err_t i2cDetachSDA(i2c_t * i2c, int8_t sda); 49 | 50 | i2c_err_t i2cWrite(i2c_t * i2c, uint16_t address, bool addr_10bit, uint8_t * data, uint8_t len, bool sendStop); 51 | i2c_err_t i2cRead(i2c_t * i2c, uint16_t address, bool addr_10bit, uint8_t * data, uint8_t len, bool sendStop); 52 | 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | 58 | #endif /* _ESP32_HAL_I2C_H_ */ 59 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/esp32-hal-ledc.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _ESP32_HAL_LEDC_H_ 16 | #define _ESP32_HAL_LEDC_H_ 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | #include 23 | #include 24 | 25 | typedef enum { 26 | NOTE_C, NOTE_Cs, NOTE_D, NOTE_Eb, NOTE_E, NOTE_F, NOTE_Fs, NOTE_G, NOTE_Gs, NOTE_A, NOTE_Bb, NOTE_B, NOTE_MAX 27 | } note_t; 28 | 29 | //channel 0-15 resolution 1-16bits freq limits depend on resolution 30 | double ledcSetup(uint8_t channel, double freq, uint8_t resolution_bits); 31 | void ledcWrite(uint8_t channel, uint32_t duty); 32 | double ledcWriteTone(uint8_t channel, double freq); 33 | double ledcWriteNote(uint8_t channel, note_t note, uint8_t octave); 34 | uint32_t ledcRead(uint8_t channel); 35 | double ledcReadFreq(uint8_t channel); 36 | void ledcAttachPin(uint8_t pin, uint8_t channel); 37 | void ledcDetachPin(uint8_t pin); 38 | 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | #endif /* _ESP32_HAL_LEDC_H_ */ 45 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/esp32-hal-matrix.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "esp32-hal-matrix.h" 16 | #include "esp_attr.h" 17 | #include "rom/gpio.h" 18 | 19 | #define MATRIX_DETACH_OUT_SIG 0x100 20 | #define MATRIX_DETACH_IN_LOW_PIN 0x30 21 | #define MATRIX_DETACH_IN_LOW_HIGH 0x38 22 | 23 | void IRAM_ATTR pinMatrixOutAttach(uint8_t pin, uint8_t function, bool invertOut, bool invertEnable) 24 | { 25 | gpio_matrix_out(pin, function, invertOut, invertEnable); 26 | } 27 | 28 | void IRAM_ATTR pinMatrixOutDetach(uint8_t pin, bool invertOut, bool invertEnable) 29 | { 30 | gpio_matrix_out(pin, MATRIX_DETACH_OUT_SIG, invertOut, invertEnable); 31 | } 32 | 33 | void IRAM_ATTR pinMatrixInAttach(uint8_t pin, uint8_t signal, bool inverted) 34 | { 35 | gpio_matrix_in(pin, signal, inverted); 36 | } 37 | 38 | void IRAM_ATTR pinMatrixInDetach(uint8_t signal, bool high, bool inverted) 39 | { 40 | gpio_matrix_in(high?MATRIX_DETACH_IN_LOW_HIGH:MATRIX_DETACH_IN_LOW_PIN, signal, inverted); 41 | } 42 | /* 43 | void IRAM_ATTR intrMatrixAttach(uint32_t source, uint32_t inum){ 44 | intr_matrix_set(PRO_CPU_NUM, source, inum); 45 | } 46 | */ 47 | 48 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/esp32-hal-matrix.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _ESP32_HAL_MATRIX_H_ 16 | #define _ESP32_HAL_MATRIX_H_ 17 | 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | #include "esp32-hal.h" 24 | #include "soc/gpio_sig_map.h" 25 | 26 | void pinMatrixOutAttach(uint8_t pin, uint8_t function, bool invertOut, bool invertEnable); 27 | void pinMatrixOutDetach(uint8_t pin, bool invertOut, bool invertEnable); 28 | void pinMatrixInAttach(uint8_t pin, uint8_t signal, bool inverted); 29 | void pinMatrixInDetach(uint8_t signal, bool high, bool inverted); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif /* COMPONENTS_ARDUHAL_INCLUDE_ESP32_HAL_MATRIX_H_ */ 36 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/esp32-hal-sigmadelta.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "esp32-hal.h" 16 | #include "freertos/FreeRTOS.h" 17 | #include "freertos/task.h" 18 | #include "freertos/semphr.h" 19 | #include "rom/ets_sys.h" 20 | #include "esp32-hal-matrix.h" 21 | #include "soc/gpio_sd_reg.h" 22 | #include "soc/gpio_sd_struct.h" 23 | 24 | 25 | #if CONFIG_DISABLE_HAL_LOCKS 26 | #define SD_MUTEX_LOCK() 27 | #define SD_MUTEX_UNLOCK() 28 | #else 29 | #define SD_MUTEX_LOCK() do {} while (xSemaphoreTake(_sd_sys_lock, portMAX_DELAY) != pdPASS) 30 | #define SD_MUTEX_UNLOCK() xSemaphoreGive(_sd_sys_lock) 31 | xSemaphoreHandle _sd_sys_lock; 32 | #endif 33 | 34 | uint32_t sigmaDeltaSetup(uint8_t channel, uint32_t freq) //chan 0-7 freq 1220-312500 35 | { 36 | if(channel > 7) { 37 | return 0; 38 | } 39 | #if !CONFIG_DISABLE_HAL_LOCKS 40 | static bool tHasStarted = false; 41 | if(!tHasStarted) { 42 | tHasStarted = true; 43 | _sd_sys_lock = xSemaphoreCreateMutex(); 44 | } 45 | #endif 46 | uint32_t prescale = (10000000/(freq*32)) - 1; 47 | if(prescale > 0xFF) { 48 | prescale = 0xFF; 49 | } 50 | SD_MUTEX_LOCK(); 51 | SIGMADELTA.channel[channel].prescale = prescale; 52 | SIGMADELTA.cg.clk_en = 0; 53 | SIGMADELTA.cg.clk_en = 1; 54 | SD_MUTEX_UNLOCK(); 55 | return 10000000/((prescale + 1) * 32); 56 | } 57 | 58 | void sigmaDeltaWrite(uint8_t channel, uint8_t duty) //chan 0-7 duty 8 bit 59 | { 60 | if(channel > 7) { 61 | return; 62 | } 63 | duty += 128; 64 | SD_MUTEX_LOCK(); 65 | SIGMADELTA.channel[channel].duty = duty; 66 | SD_MUTEX_UNLOCK(); 67 | } 68 | 69 | uint8_t sigmaDeltaRead(uint8_t channel) //chan 0-7 70 | { 71 | if(channel > 7) { 72 | return 0; 73 | } 74 | SD_MUTEX_LOCK(); 75 | uint8_t duty = SIGMADELTA.channel[channel].duty - 128; 76 | SD_MUTEX_UNLOCK(); 77 | return duty; 78 | } 79 | 80 | void sigmaDeltaAttachPin(uint8_t pin, uint8_t channel) //channel 0-7 81 | { 82 | if(channel > 7) { 83 | return; 84 | } 85 | pinMode(pin, OUTPUT); 86 | pinMatrixOutAttach(pin, GPIO_SD0_OUT_IDX + channel, false, false); 87 | } 88 | 89 | void sigmaDeltaDetachPin(uint8_t pin) 90 | { 91 | pinMatrixOutDetach(pin, false, false); 92 | } 93 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/esp32-hal-sigmadelta.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _ESP32_HAL_SD_H_ 16 | #define _ESP32_HAL_SD_H_ 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | #include 23 | #include 24 | 25 | //channel 0-7 freq 1220-312500 duty 0-255 26 | uint32_t sigmaDeltaSetup(uint8_t channel, uint32_t freq); 27 | void sigmaDeltaWrite(uint8_t channel, uint8_t duty); 28 | uint8_t sigmaDeltaRead(uint8_t channel); 29 | void sigmaDeltaAttachPin(uint8_t pin, uint8_t channel); 30 | void sigmaDeltaDetachPin(uint8_t pin); 31 | 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif /* _ESP32_HAL_SD_H_ */ 38 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/esp32-hal-time.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "esp32-hal.h" 16 | #include "apps/sntp/sntp.h" 17 | 18 | static void setTimeZone(long offset, int daylight) 19 | { 20 | char cst[16] = {0}; 21 | char cdt[16] = "CDT"; 22 | char tz[32] = {0}; 23 | 24 | if(offset % 3600){ 25 | sprintf(cst, "CST%ld:%02u:%02u", offset / 3600, abs((offset % 3600) / 60), abs(offset % 60)); 26 | } else { 27 | sprintf(cst, "CST%ld", offset / 3600); 28 | } 29 | if(daylight != 3600){ 30 | long tz_dst = offset - daylight; 31 | if(tz_dst % 3600){ 32 | sprintf(cdt, "CDT%ld:%02u:%02u", tz_dst / 3600, abs((tz_dst % 3600) / 60), abs(tz_dst % 60)); 33 | } else { 34 | sprintf(cdt, "CDT%ld", tz_dst / 3600); 35 | } 36 | } 37 | sprintf(tz, "%s%s", cst, cdt); 38 | setenv("TZ", tz, 1); 39 | tzset(); 40 | } 41 | 42 | /* 43 | * configTime 44 | * Source: https://github.com/esp8266/Arduino/blob/master/cores/esp8266/time.c 45 | * */ 46 | void configTime(long gmtOffset_sec, int daylightOffset_sec, const char* server1, const char* server2, const char* server3) 47 | { 48 | 49 | if(sntp_enabled()){ 50 | sntp_stop(); 51 | } 52 | sntp_setoperatingmode(SNTP_OPMODE_POLL); 53 | sntp_setservername(0, (char*)server1); 54 | sntp_setservername(1, (char*)server2); 55 | sntp_setservername(2, (char*)server3); 56 | sntp_init(); 57 | setTimeZone(gmtOffset_sec, daylightOffset_sec); 58 | } 59 | 60 | bool getLocalTime(struct tm * info, uint32_t ms) 61 | { 62 | uint32_t count = ms / 10; 63 | time_t now; 64 | 65 | time(&now); 66 | localtime_r(&now, info); 67 | 68 | if(info->tm_year > (2016 - 1900)){ 69 | return true; 70 | } 71 | 72 | while(count--) { 73 | delay(10); 74 | time(&now); 75 | localtime_r(&now, info); 76 | if(info->tm_year > (2016 - 1900)){ 77 | return true; 78 | } 79 | } 80 | return false; 81 | } 82 | 83 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/esp32-hal-timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Arduino.h - Main include file for the Arduino SDK 3 | Copyright (c) 2005-2013 Arduino Team. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef MAIN_ESP32_HAL_TIMER_H_ 21 | #define MAIN_ESP32_HAL_TIMER_H_ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include "esp32-hal.h" 28 | #include "freertos/FreeRTOS.h" 29 | 30 | struct hw_timer_s; 31 | typedef struct hw_timer_s hw_timer_t; 32 | 33 | hw_timer_t * timerBegin(uint8_t timer, uint16_t divider, bool countUp); 34 | void timerEnd(hw_timer_t *timer); 35 | 36 | void timerSetConfig(hw_timer_t *timer, uint32_t config); 37 | uint32_t timerGetConfig(hw_timer_t *timer); 38 | 39 | void timerAttachInterrupt(hw_timer_t *timer, void (*fn)(void), bool edge); 40 | void timerDetachInterrupt(hw_timer_t *timer); 41 | 42 | void timerStart(hw_timer_t *timer); 43 | void timerStop(hw_timer_t *timer); 44 | void timerRestart(hw_timer_t *timer); 45 | void timerWrite(hw_timer_t *timer, uint64_t val); 46 | void timerSetDivider(hw_timer_t *timer, uint16_t divider); 47 | void timerSetCountUp(hw_timer_t *timer, bool countUp); 48 | void timerSetAutoReload(hw_timer_t *timer, bool autoreload); 49 | 50 | bool timerStarted(hw_timer_t *timer); 51 | uint64_t timerRead(hw_timer_t *timer); 52 | uint64_t timerReadMicros(hw_timer_t *timer); 53 | double timerReadSeconds(hw_timer_t *timer); 54 | uint16_t timerGetDivider(hw_timer_t *timer); 55 | bool timerGetCountUp(hw_timer_t *timer); 56 | bool timerGetAutoReload(hw_timer_t *timer); 57 | 58 | void timerAlarmEnable(hw_timer_t *timer); 59 | void timerAlarmDisable(hw_timer_t *timer); 60 | void timerAlarmWrite(hw_timer_t *timer, uint64_t interruptAt, bool autoreload); 61 | 62 | bool timerAlarmEnabled(hw_timer_t *timer); 63 | uint64_t timerAlarmRead(hw_timer_t *timer); 64 | uint64_t timerAlarmReadMicros(hw_timer_t *timer); 65 | double timerAlarmReadSeconds(hw_timer_t *timer); 66 | 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* MAIN_ESP32_HAL_TIMER_H_ */ 73 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/esp32-hal-touch.h: -------------------------------------------------------------------------------- 1 | /* 2 | Arduino.h - Main include file for the Arduino SDK 3 | Copyright (c) 2005-2013 Arduino Team. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef MAIN_ESP32_HAL_TOUCH_H_ 21 | #define MAIN_ESP32_HAL_TOUCH_H_ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include "esp32-hal.h" 28 | 29 | /* 30 | * Set cycles that measurement operation takes 31 | * The result from touchRead, threshold and detection 32 | * accuracy depend on these values. Defaults are 33 | * 0x1000 for measure and 0x1000 for sleep. 34 | * With default values touchRead takes 0.5ms 35 | * */ 36 | void touchSetCycles(uint16_t measure, uint16_t sleep); 37 | 38 | /* 39 | * Read touch pad (values close to 0 mean touch detected) 40 | * You can use this method to chose a good threshold value 41 | * to use as value for touchAttachInterrupt 42 | * */ 43 | uint16_t touchRead(uint8_t pin); 44 | 45 | /* 46 | * Set function to be called if touch pad value falls 47 | * below the given threshold. Use touchRead to determine 48 | * a proper threshold between touched and untouched state 49 | * */ 50 | void touchAttachInterrupt(uint8_t pin, void (*userFunc)(void), uint16_t threshold); 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | 56 | #endif /* MAIN_ESP32_HAL_TOUCH_H_ */ 57 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/esp32-hal-uart.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef MAIN_ESP32_HAL_UART_H_ 16 | #define MAIN_ESP32_HAL_UART_H_ 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #define SERIAL_5N1 0x8000010 27 | #define SERIAL_6N1 0x8000014 28 | #define SERIAL_7N1 0x8000018 29 | #define SERIAL_8N1 0x800001c 30 | #define SERIAL_5N2 0x8000030 31 | #define SERIAL_6N2 0x8000034 32 | #define SERIAL_7N2 0x8000038 33 | #define SERIAL_8N2 0x800003c 34 | #define SERIAL_5E1 0x8000012 35 | #define SERIAL_6E1 0x8000016 36 | #define SERIAL_7E1 0x800001a 37 | #define SERIAL_8E1 0x800001e 38 | #define SERIAL_5E2 0x8000032 39 | #define SERIAL_6E2 0x8000036 40 | #define SERIAL_7E2 0x800003a 41 | #define SERIAL_8E2 0x800003e 42 | #define SERIAL_5O1 0x8000013 43 | #define SERIAL_6O1 0x8000017 44 | #define SERIAL_7O1 0x800001b 45 | #define SERIAL_8O1 0x800001f 46 | #define SERIAL_5O2 0x8000033 47 | #define SERIAL_6O2 0x8000037 48 | #define SERIAL_7O2 0x800003b 49 | #define SERIAL_8O2 0x800003f 50 | 51 | struct uart_struct_t; 52 | typedef struct uart_struct_t uart_t; 53 | 54 | uart_t* uartBegin(uint8_t uart_nr, uint32_t baudrate, uint32_t config, int8_t rxPin, int8_t txPin, uint16_t queueLen, bool inverted); 55 | void uartEnd(uart_t* uart); 56 | 57 | uint32_t uartAvailable(uart_t* uart); 58 | uint8_t uartRead(uart_t* uart); 59 | uint8_t uartPeek(uart_t* uart); 60 | 61 | void uartWrite(uart_t* uart, uint8_t c); 62 | void uartWriteBuf(uart_t* uart, const uint8_t * data, size_t len); 63 | 64 | void uartFlush(uart_t* uart); 65 | 66 | void uartSetBaudRate(uart_t* uart, uint32_t baud_rate); 67 | uint32_t uartGetBaudRate(uart_t* uart); 68 | 69 | void uartSetDebug(uart_t* uart); 70 | int uartGetDebug(); 71 | 72 | #ifdef __cplusplus 73 | } 74 | #endif 75 | 76 | #endif /* MAIN_ESP32_HAL_UART_H_ */ 77 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/esp32-hal.h: -------------------------------------------------------------------------------- 1 | /* 2 | Arduino.h - Main include file for the Arduino SDK 3 | Copyright (c) 2005-2013 Arduino Team. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef HAL_ESP32_HAL_H_ 21 | #define HAL_ESP32_HAL_H_ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include "sdkconfig.h" 36 | 37 | #ifndef F_CPU 38 | #define F_CPU (CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ * 1000000U) 39 | #endif 40 | 41 | //forward declaration from freertos/portmacro.h 42 | void vPortYield(void); 43 | void yield(void); 44 | #define optimistic_yield(u) 45 | 46 | #define ESP_REG(addr) *((volatile uint32_t *)(addr)) 47 | #define NOP() asm volatile ("nop") 48 | 49 | #include "esp32-hal-log.h" 50 | #include "esp32-hal-matrix.h" 51 | #include "esp32-hal-uart.h" 52 | #include "esp32-hal-gpio.h" 53 | #include "esp32-hal-touch.h" 54 | #include "esp32-hal-dac.h" 55 | #include "esp32-hal-adc.h" 56 | #include "esp32-hal-spi.h" 57 | #include "esp32-hal-i2c.h" 58 | #include "esp32-hal-ledc.h" 59 | #include "esp32-hal-sigmadelta.h" 60 | #include "esp32-hal-timer.h" 61 | #include "esp_system.h" 62 | 63 | uint32_t micros(); 64 | uint32_t millis(); 65 | void delay(uint32_t); 66 | void delayMicroseconds(uint32_t us); 67 | 68 | #if !CONFIG_ESP32_PHY_AUTO_INIT 69 | void arduino_phy_init(); 70 | #endif 71 | 72 | #if !CONFIG_AUTOSTART_ARDUINO 73 | void initArduino(); 74 | #endif 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif /* HAL_ESP32_HAL_H_ */ 81 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/libb64/AUTHORS: -------------------------------------------------------------------------------- 1 | libb64: Base64 Encoding/Decoding Routines 2 | ====================================== 3 | 4 | Authors: 5 | ------- 6 | 7 | Chris Venter chris.venter@gmail.com http://rocketpod.blogspot.com 8 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/libb64/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright-Only Dedication (based on United States law) 2 | or Public Domain Certification 3 | 4 | The person or persons who have associated work with this document (the 5 | "Dedicator" or "Certifier") hereby either (a) certifies that, to the best of 6 | his knowledge, the work of authorship identified is in the public domain of the 7 | country from which the work is published, or (b) hereby dedicates whatever 8 | copyright the dedicators holds in the work of authorship identified below (the 9 | "Work") to the public domain. A certifier, moreover, dedicates any copyright 10 | interest he may have in the associated work, and for these purposes, is 11 | described as a "dedicator" below. 12 | 13 | A certifier has taken reasonable steps to verify the copyright status of this 14 | work. Certifier recognizes that his good faith efforts may not shield him from 15 | liability if in fact the work certified is not in the public domain. 16 | 17 | Dedicator makes this dedication for the benefit of the public at large and to 18 | the detriment of the Dedicator's heirs and successors. Dedicator intends this 19 | dedication to be an overt act of relinquishment in perpetuity of all present 20 | and future rights under copyright law, whether vested or contingent, in the 21 | Work. Dedicator understands that such relinquishment of all rights includes 22 | the relinquishment of all rights to enforce (by lawsuit or otherwise) those 23 | copyrights in the Work. 24 | 25 | Dedicator recognizes that, once placed in the public domain, the Work may be 26 | freely reproduced, distributed, transmitted, used, modified, built upon, or 27 | otherwise exploited by anyone for any purpose, commercial or non-commercial, 28 | and in any way, including by methods that have not yet been invented or 29 | conceived. -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/libb64/cdecode.c: -------------------------------------------------------------------------------- 1 | /* 2 | cdecoder.c - c source to a base64 decoding algorithm implementation 3 | 4 | This is part of the libb64 project, and has been placed in the public domain. 5 | For details, see http://sourceforge.net/projects/libb64 6 | */ 7 | 8 | #include "cdecode.h" 9 | 10 | int base64_decode_value(char value_in) 11 | { 12 | static const char decoding[] = {62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-2,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51}; 13 | static const char decoding_size = sizeof(decoding); 14 | value_in -= 43; 15 | if (value_in < 0 || value_in > decoding_size) { 16 | return -1; 17 | } 18 | return decoding[(int)value_in]; 19 | } 20 | 21 | void base64_init_decodestate(base64_decodestate* state_in) 22 | { 23 | state_in->step = step_a; 24 | state_in->plainchar = 0; 25 | } 26 | 27 | int base64_decode_block(const char* code_in, const int length_in, char* plaintext_out, base64_decodestate* state_in) 28 | { 29 | const char* codechar = code_in; 30 | char* plainchar = plaintext_out; 31 | char fragment; 32 | 33 | *plainchar = state_in->plainchar; 34 | 35 | switch (state_in->step) { 36 | while (1) { 37 | case step_a: 38 | do { 39 | if (codechar == code_in+length_in) { 40 | state_in->step = step_a; 41 | state_in->plainchar = *plainchar; 42 | return plainchar - plaintext_out; 43 | } 44 | fragment = (char)base64_decode_value(*codechar++); 45 | } while (fragment < 0); 46 | *plainchar = (fragment & 0x03f) << 2; 47 | case step_b: 48 | do { 49 | if (codechar == code_in+length_in) { 50 | state_in->step = step_b; 51 | state_in->plainchar = *plainchar; 52 | return plainchar - plaintext_out; 53 | } 54 | fragment = (char)base64_decode_value(*codechar++); 55 | } while (fragment < 0); 56 | *plainchar++ |= (fragment & 0x030) >> 4; 57 | *plainchar = (fragment & 0x00f) << 4; 58 | case step_c: 59 | do { 60 | if (codechar == code_in+length_in) { 61 | state_in->step = step_c; 62 | state_in->plainchar = *plainchar; 63 | return plainchar - plaintext_out; 64 | } 65 | fragment = (char)base64_decode_value(*codechar++); 66 | } while (fragment < 0); 67 | *plainchar++ |= (fragment & 0x03c) >> 2; 68 | *plainchar = (fragment & 0x003) << 6; 69 | case step_d: 70 | do { 71 | if (codechar == code_in+length_in) { 72 | state_in->step = step_d; 73 | state_in->plainchar = *plainchar; 74 | return plainchar - plaintext_out; 75 | } 76 | fragment = (char)base64_decode_value(*codechar++); 77 | } while (fragment < 0); 78 | *plainchar++ |= (fragment & 0x03f); 79 | } 80 | } 81 | /* control should not reach here */ 82 | return plainchar - plaintext_out; 83 | } 84 | 85 | int base64_decode_chars(const char* code_in, const int length_in, char* plaintext_out) 86 | { 87 | base64_decodestate _state; 88 | base64_init_decodestate(&_state); 89 | int len = base64_decode_block(code_in, length_in, plaintext_out, &_state); 90 | if(len > 0) { 91 | plaintext_out[len] = 0; 92 | } 93 | return len; 94 | } 95 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/libb64/cdecode.h: -------------------------------------------------------------------------------- 1 | /* 2 | cdecode.h - c header for a base64 decoding algorithm 3 | 4 | This is part of the libb64 project, and has been placed in the public domain. 5 | For details, see http://sourceforge.net/projects/libb64 6 | */ 7 | 8 | #ifndef BASE64_CDECODE_H 9 | #define BASE64_CDECODE_H 10 | 11 | #define base64_decode_expected_len(n) ((n * 3) / 4) 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | typedef enum { 18 | step_a, step_b, step_c, step_d 19 | } base64_decodestep; 20 | 21 | typedef struct { 22 | base64_decodestep step; 23 | char plainchar; 24 | } base64_decodestate; 25 | 26 | void base64_init_decodestate(base64_decodestate* state_in); 27 | 28 | int base64_decode_value(char value_in); 29 | 30 | int base64_decode_block(const char* code_in, const int length_in, char* plaintext_out, base64_decodestate* state_in); 31 | 32 | int base64_decode_chars(const char* code_in, const int length_in, char* plaintext_out); 33 | 34 | #ifdef __cplusplus 35 | } // extern "C" 36 | #endif 37 | 38 | #endif /* BASE64_CDECODE_H */ 39 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/libb64/cencode.h: -------------------------------------------------------------------------------- 1 | /* 2 | cencode.h - c header for a base64 encoding algorithm 3 | 4 | This is part of the libb64 project, and has been placed in the public domain. 5 | For details, see http://sourceforge.net/projects/libb64 6 | */ 7 | 8 | #ifndef BASE64_CENCODE_H 9 | #define BASE64_CENCODE_H 10 | 11 | #define base64_encode_expected_len(n) ((((4 * n) / 3) + 3) & ~3) 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | typedef enum { 18 | step_A, step_B, step_C 19 | } base64_encodestep; 20 | 21 | typedef struct { 22 | base64_encodestep step; 23 | char result; 24 | int stepcount; 25 | } base64_encodestate; 26 | 27 | void base64_init_encodestate(base64_encodestate* state_in); 28 | 29 | char base64_encode_value(char value_in); 30 | 31 | int base64_encode_block(const char* plaintext_in, int length_in, char* code_out, base64_encodestate* state_in); 32 | 33 | int base64_encode_blockend(char* code_out, base64_encodestate* state_in); 34 | 35 | int base64_encode_chars(const char* plaintext_in, int length_in, char* code_out); 36 | 37 | #ifdef __cplusplus 38 | } // extern "C" 39 | #endif 40 | 41 | #endif /* BASE64_CENCODE_H */ 42 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/main.cpp: -------------------------------------------------------------------------------- 1 | #include "freertos/FreeRTOS.h" 2 | #include "freertos/task.h" 3 | #include "Arduino.h" 4 | 5 | #if CONFIG_AUTOSTART_ARDUINO 6 | 7 | void loopTask(void *pvParameters) 8 | { 9 | setup(); 10 | for(;;) { 11 | loop(); 12 | } 13 | } 14 | 15 | extern "C" void app_main() 16 | { 17 | initArduino(); 18 | xTaskCreatePinnedToCore(loopTask, "loopTask", 4096, NULL, 1, NULL, 1); 19 | } 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/pgmspace.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Hristo Gochkov. All rights reserved. 3 | This file is part of the RaspberryPi core for Arduino environment. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | #ifndef PGMSPACE_INCLUDE 20 | #define PGMSPACE_INCLUDE 21 | 22 | typedef void prog_void; 23 | typedef char prog_char; 24 | typedef unsigned char prog_uchar; 25 | typedef char prog_int8_t; 26 | typedef unsigned char prog_uint8_t; 27 | typedef short prog_int16_t; 28 | typedef unsigned short prog_uint16_t; 29 | typedef long prog_int32_t; 30 | typedef unsigned long prog_uint32_t; 31 | 32 | #define SIZE_IRRELEVANT 0x7fffffff 33 | 34 | #define PROGMEM 35 | #define PGM_P const char * 36 | #define PGM_VOID_P const void * 37 | #define FPSTR(p) ((const char *)(p)) 38 | #define PSTR(s) (s) 39 | #define _SFR_BYTE(n) (n) 40 | 41 | #define pgm_read_byte(addr) (*(const unsigned char *)(addr)) 42 | #define pgm_read_word(addr) (*(const unsigned short *)(addr)) 43 | #define pgm_read_dword(addr) (*(const unsigned long *)(addr)) 44 | #define pgm_read_float(addr) (*(const float *)(addr)) 45 | 46 | #define pgm_read_byte_near(addr) pgm_read_byte(addr) 47 | #define pgm_read_word_near(addr) pgm_read_word(addr) 48 | #define pgm_read_dword_near(addr) pgm_read_dword(addr) 49 | #define pgm_read_float_near(addr) pgm_read_float(addr) 50 | #define pgm_read_byte_far(addr) pgm_read_byte(addr) 51 | #define pgm_read_word_far(addr) pgm_read_word(addr) 52 | #define pgm_read_dword_far(addr) pgm_read_dword(addr) 53 | #define pgm_read_float_far(addr) pgm_read_float(addr) 54 | 55 | #define memcmp_P memcmp 56 | #define memccpy_P memccpy 57 | #define memmem_P memmem 58 | #define memcpy_P memcpy 59 | #define strncpy_P strncpy 60 | #define strncat_P strncat 61 | #define strncmp_P strncmp 62 | #define strncasecmp_P strncasecmp 63 | #define strnlen_P strnlen 64 | #define strstr_P strstr 65 | #define printf_P printf 66 | #define sprintf_P sprintf 67 | #define snprintf_P snprintf 68 | #define vsnprintf_P vsnprintf 69 | 70 | #define strlen_P(strP) strnlen_P((strP), SIZE_IRRELEVANT) 71 | #define strcasecmp_P(str1, str2P) strncasecmp_P((str1), (str2P), SIZE_IRRELEVANT) 72 | #define strcmp_P(str1, str2P) strncmp_P((str1), (str2P), SIZE_IRRELEVANT) 73 | #define strcat_P(dest, src) strncat_P((dest), (src), SIZE_IRRELEVANT) 74 | #define strcpy_P(dest, src) strncpy_P((dest), (src), SIZE_IRRELEVANT) 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/stdlib_noniso.h: -------------------------------------------------------------------------------- 1 | /* 2 | stdlib_noniso.h - nonstandard (but usefull) conversion functions 3 | 4 | Copyright (c) 2014 Ivan Grokhotkov. All rights reserved. 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef STDLIB_NONISO_H 22 | #define STDLIB_NONISO_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | int atoi(const char *s); 29 | 30 | long atol(const char* s); 31 | 32 | double atof(const char* s); 33 | 34 | char* itoa (int val, char *s, int radix); 35 | 36 | char* ltoa (long val, char *s, int radix); 37 | 38 | char* utoa (unsigned int val, char *s, int radix); 39 | 40 | char* ultoa (unsigned long val, char *s, int radix); 41 | 42 | char* dtostrf (double val, signed char width, unsigned char prec, char *s); 43 | 44 | #ifdef __cplusplus 45 | } // extern "C" 46 | #endif 47 | 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/wiring_private.h: -------------------------------------------------------------------------------- 1 | /* 2 | wiring_private.h - Internal header file. 3 | Part of Arduino - http://www.arduino.cc/ 4 | 5 | Copyright (c) 2005-2006 David A. Mellis 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | This library 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 GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General 18 | Public License along with this library; if not, write to the 19 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, 20 | Boston, MA 02111-1307 USA 21 | 22 | $Id: wiring.h 239 2007-01-12 17:58:39Z mellis $ 23 | */ 24 | 25 | #ifndef WiringPrivate_h 26 | #define WiringPrivate_h 27 | 28 | #include 29 | #include 30 | 31 | #include "Arduino.h" 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | typedef void (*voidFuncPtr)(void); 38 | 39 | void initPins(); 40 | 41 | #ifdef __cplusplus 42 | } // extern "C" 43 | #endif 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/wiring_pulse.c: -------------------------------------------------------------------------------- 1 | /* 2 | pulse.c - wiring pulseIn implementation for esp8266 3 | Copyright (c) 2015 Hristo Gochkov. All rights reserved. 4 | This file is part of the esp8266 core for Arduino environment. 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | You should have received a copy of the GNU Lesser General Public 14 | License along with this library; if not, write to the Free Software 15 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16 | */ 17 | //#include 18 | #include "wiring_private.h" 19 | #include "pins_arduino.h" 20 | 21 | 22 | extern uint32_t xthal_get_ccount(); 23 | 24 | #define WAIT_FOR_PIN_STATE(state) \ 25 | while (digitalRead(pin) != (state)) { \ 26 | if (xthal_get_ccount() - start_cycle_count > timeout_cycles) { \ 27 | return 0; \ 28 | } \ 29 | } 30 | 31 | // max timeout is 27 seconds at 160MHz clock and 54 seconds at 80MHz clock 32 | unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout) 33 | { 34 | const uint32_t max_timeout_us = clockCyclesToMicroseconds(UINT_MAX); 35 | if (timeout > max_timeout_us) { 36 | timeout = max_timeout_us; 37 | } 38 | const uint32_t timeout_cycles = microsecondsToClockCycles(timeout); 39 | const uint32_t start_cycle_count = xthal_get_ccount(); 40 | WAIT_FOR_PIN_STATE(!state); 41 | WAIT_FOR_PIN_STATE(state); 42 | const uint32_t pulse_start_cycle_count = xthal_get_ccount(); 43 | WAIT_FOR_PIN_STATE(!state); 44 | return clockCyclesToMicroseconds(xthal_get_ccount() - pulse_start_cycle_count); 45 | } 46 | 47 | unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout) 48 | { 49 | return pulseIn(pin, state, timeout); 50 | } 51 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/cores/esp32/wiring_shift.c: -------------------------------------------------------------------------------- 1 | /* 2 | wiring_shift.c - shiftOut() function 3 | Part of Arduino - http://www.arduino.cc/ 4 | Copyright (c) 2005-2006 David A. Mellis 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | You should have received a copy of the GNU Lesser General 14 | Public License along with this library; if not, write to the 15 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, 16 | Boston, MA 02111-1307 USA 17 | $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $ 18 | */ 19 | 20 | #include "esp32-hal.h" 21 | #include "wiring_private.h" 22 | 23 | uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) { 24 | uint8_t value = 0; 25 | uint8_t i; 26 | 27 | for(i = 0; i < 8; ++i) { 28 | digitalWrite(clockPin, HIGH); 29 | if(bitOrder == LSBFIRST) 30 | value |= digitalRead(dataPin) << i; 31 | else 32 | value |= digitalRead(dataPin) << (7 - i); 33 | digitalWrite(clockPin, LOW); 34 | } 35 | return value; 36 | } 37 | 38 | void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val) { 39 | uint8_t i; 40 | 41 | for(i = 0; i < 8; i++) { 42 | if(bitOrder == LSBFIRST) 43 | digitalWrite(dataPin, !!(val & (1 << i))); 44 | else 45 | digitalWrite(dataPin, !!(val & (1 << (7 - i)))); 46 | 47 | digitalWrite(clockPin, HIGH); 48 | digitalWrite(clockPin, LOW); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/doc/arduino-ide.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/darthm0e/esp32-101/9227a2fe3d7cef382d10f0a8f5112a412e416f01/ESP32-examples-Inet-heltec/doc/arduino-ide.png -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/doc/esp32_pinmap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/darthm0e/esp32-101/9227a2fe3d7cef382d10f0a8f5112a412e416f01/ESP32-examples-Inet-heltec/doc/esp32_pinmap.png -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/doc/win-gui-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/darthm0e/esp32-101/9227a2fe3d7cef382d10f0a8f5112a412e416f01/ESP32-examples-Inet-heltec/doc/win-gui-1.png -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/doc/win-gui-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/darthm0e/esp32-101/9227a2fe3d7cef382d10f0a8f5112a412e416f01/ESP32-examples-Inet-heltec/doc/win-gui-2.png -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/doc/win-gui-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/darthm0e/esp32-101/9227a2fe3d7cef382d10f0a8f5112a412e416f01/ESP32-examples-Inet-heltec/doc/win-gui-3.png -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/doc/win-gui-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/darthm0e/esp32-101/9227a2fe3d7cef382d10f0a8f5112a412e416f01/ESP32-examples-Inet-heltec/doc/win-gui-4.png -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/doc/win-gui-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/darthm0e/esp32-101/9227a2fe3d7cef382d10f0a8f5112a412e416f01/ESP32-examples-Inet-heltec/doc/win-gui-5.png -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/doc/win-gui-update-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/darthm0e/esp32-101/9227a2fe3d7cef382d10f0a8f5112a412e416f01/ESP32-examples-Inet-heltec/doc/win-gui-update-1.png -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/doc/win-gui-update-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/darthm0e/esp32-101/9227a2fe3d7cef382d10f0a8f5112a412e416f01/ESP32-examples-Inet-heltec/doc/win-gui-update-2.png -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/doc/windows.md: -------------------------------------------------------------------------------- 1 | ## Steps to install Arduino ESP32 support on Windows 2 | ### Tested on 32 and 64 bit Windows 10 machines 3 | 4 | 1. Download and install the latest Arduino IDE ```Windows Installer``` from [arduino.cc](https://www.arduino.cc/en/Main/Software) 5 | 2. Download and install Git from [git-scm.com](https://git-scm.com/download/win) 6 | 3. Start ```Git GUI``` and run through the following steps: 7 | - Select ```Clone Existing Repository``` 8 | 9 | ![Step 1](win-gui-1.png) 10 | 11 | - Select source and destination 12 | - Source Location: ```https://github.com/espressif/arduino-esp32.git``` 13 | - Target Directory: ```C:/Users/[YOUR_USER_NAME]/Documents/Arduino/hardware/espressif/esp32``` 14 | - Click ```Clone``` to start cloning the repository 15 | 16 | ![Step 2](win-gui-2.png) 17 | ![Step 3](win-gui-3.png) 18 | 19 | - Open ```C:/Users/[YOUR_USER_NAME]/Documents/Arduino/hardware/espressif/esp32/tools``` and double-click ```get.exe``` 20 | 21 | ![Step 4](win-gui-4.png) 22 | 23 | - When ```get.exe``` finishes, you should see the following files in the directory 24 | 25 | ![Step 5](win-gui-5.png) 26 | 27 | 4. Plug your ESP32 board and wait for the drivers to install (or install manually any that might be required) 28 | 5. Start Arduino IDE 29 | 6. Select your board in ```Tools > Board``` menu 30 | 7. Select the COM port that the board is attached to 31 | 8. Compile and upload (You might need to hold the boot button while uploading) 32 | 33 | ![Arduino IDE Example](arduino-ide.png) 34 | 35 | ### How to update to the latest code 36 | 37 | 1. Start ```Git GUI``` and you should see the repository under ```Open Recent Repository```. Click on it! 38 | 39 | ![Update Step 1](win-gui-update-1.png) 40 | 41 | 2. From menu ```Remote``` select ```Fetch from``` > ```origin``` 42 | 43 | ![Update Step 2](win-gui-update-2.png) 44 | 45 | 3. Wait for git to pull any changes and close ```Git GUI``` 46 | 4. Open ```C:/Users/[YOUR_USER_NAME]/Documents/Arduino/hardware/espressif/esp32/tools``` and double-click ```get.exe``` 47 | 48 | ![Step 4](win-gui-4.png) 49 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/ESP32/examples/AnalogOut/LEDCSoftwareFade/LEDCSoftwareFade.ino: -------------------------------------------------------------------------------- 1 | /* 2 | LEDC Software Fade 3 | 4 | This example shows how to software fade LED 5 | using the ledcWrite function. 6 | 7 | Code adapted from original Arduino Fade example: 8 | https://www.arduino.cc/en/Tutorial/Fade 9 | 10 | This example code is in the public domain. 11 | */ 12 | 13 | // use first channel of 16 channels (started from zero) 14 | #define LEDC_CHANNEL_0 0 15 | 16 | // use 13 bit precission for LEDC timer 17 | #define LEDC_TIMER_13_BIT 13 18 | 19 | // use 5000 Hz as a LEDC base frequency 20 | #define LEDC_BASE_FREQ 5000 21 | 22 | // fade LED PIN (replace with LED_BUILTIN constant for built-in LED) 23 | #define LED_PIN 5 24 | 25 | int brightness = 0; // how bright the LED is 26 | int fadeAmount = 5; // how many points to fade the LED by 27 | 28 | // Arduino like analogWrite 29 | // value has to be between 0 and valueMax 30 | void ledcAnalogWrite(uint8_t channel, uint32_t value, uint32_t valueMax = 255) { 31 | // calculate duty 32 | uint32_t duty = (LEDC_BASE_FREQ / valueMax) * min(value, valueMax); 33 | 34 | // write duty to LEDC 35 | ledcWrite(channel, duty); 36 | } 37 | 38 | void setup() { 39 | // Setup timer and attach timer to a led pin 40 | ledcSetup(LEDC_CHANNEL_0, LEDC_BASE_FREQ, LEDC_TIMER_13_BIT); 41 | ledcAttachPin(LED_PIN, LEDC_CHANNEL_0); 42 | } 43 | 44 | void loop() { 45 | // set the brightness on LEDC channel 0 46 | ledcAnalogWrite(LEDC_CHANNEL_0, brightness); 47 | 48 | // change the brightness for next time through the loop: 49 | brightness = brightness + fadeAmount; 50 | 51 | // reverse the direction of the fading at the ends of the fade: 52 | if (brightness <= 0 || brightness >= 255) { 53 | fadeAmount = -fadeAmount; 54 | } 55 | // wait for 30 milliseconds to see the dimming effect 56 | delay(30); 57 | } 58 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/ESP32/examples/AnalogOut/SigmaDelta/SigmaDelta.ino: -------------------------------------------------------------------------------- 1 | void setup() 2 | { 3 | //setup channel 0 with frequency 312500 Hz 4 | sigmaDeltaSetup(0, 312500); 5 | //attach pin 18 to channel 0 6 | sigmaDeltaAttachPin(18,0); 7 | //initialize channel 0 to off 8 | sigmaDeltaWrite(0, 0); 9 | } 10 | 11 | void loop() 12 | { 13 | //slowly ramp-up the value 14 | //will overflow at 256 15 | static uint8_t i = 0; 16 | sigmaDeltaWrite(0, i++); 17 | delay(100); 18 | } 19 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/ESP32/examples/Timer/RepeatTimer/RepeatTimer.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Repeat timer example 3 | 4 | This example shows how to use hardware timer in ESP32. The timer calls onTimer 5 | function every second. The timer can be stopped with button attached to PIN 0 6 | (IO0). 7 | 8 | This example code is in the public domain. 9 | */ 10 | 11 | // Stop button is attached to PIN 0 (IO0) 12 | #define BTN_STOP_ALARM 0 13 | 14 | hw_timer_t * timer = NULL; 15 | 16 | void onTimer(){ 17 | static unsigned int counter = 1; 18 | 19 | Serial.print("onTimer no. "); 20 | Serial.print(counter); 21 | Serial.print(" at "); 22 | Serial.print(millis()); 23 | Serial.println(" ms"); 24 | 25 | counter++; 26 | } 27 | 28 | void setup() { 29 | Serial.begin(115200); 30 | 31 | // Set BTN_STOP_ALARM to input mode 32 | pinMode(BTN_STOP_ALARM, INPUT); 33 | 34 | // Use 1st timer of 4 (counted from zero). 35 | // Set 80 divider for prescaler (see ESP32 Technical Reference Manual for more 36 | // info). 37 | timer = timerBegin(0, 80, true); 38 | 39 | // Attach onTimer function to our timer. 40 | timerAttachInterrupt(timer, &onTimer, true); 41 | 42 | // Set alarm to call onTimer function every second (value in microseconds). 43 | // Repeat the alarm (third parameter) 44 | timerAlarmWrite(timer, 1000000, true); 45 | 46 | // Start an alarm 47 | timerAlarmEnable(timer); 48 | } 49 | 50 | void loop() { 51 | // If button is pressed 52 | if (digitalRead(BTN_STOP_ALARM) == LOW) { 53 | // If timer is still running 54 | if (timer) { 55 | // Stop and free timer 56 | timerEnd(timer); 57 | timer = NULL; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/ESP32/examples/Touch/TouchInterrupt/TouchInterrupt.ino: -------------------------------------------------------------------------------- 1 | /* 2 | This is un example howto use Touch Intrrerupts 3 | The bigger the threshold, the more sensible is the touch 4 | */ 5 | 6 | int threshold = 40; 7 | bool touch1detected = false; 8 | bool touch2detected = false; 9 | 10 | void gotTouch1(){ 11 | touch1detected = true; 12 | } 13 | 14 | void gotTouch2(){ 15 | touch2detected = true; 16 | } 17 | 18 | void setup() { 19 | Serial.begin(115200); 20 | delay(1000); // give me time to bring up serial monitor 21 | Serial.println("ESP32 Touch Interrupt Test"); 22 | touchAttachInterrupt(T2, gotTouch1, threshold); 23 | touchAttachInterrupt(T3, gotTouch2, threshold); 24 | } 25 | 26 | void loop(){ 27 | if(touch1detected){ 28 | touch1detected = false; 29 | Serial.println("Touch 1 detected"); 30 | } 31 | if(touch2detected){ 32 | touch2detected = false; 33 | Serial.println("Touch 2 detected"); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/ESP32/examples/Touch/TouchRead/TouchRead.ino: -------------------------------------------------------------------------------- 1 | // ESP32 Touch Test 2 | // Just test touch pin - Touch0 is T0 which is on GPIO 4. 3 | 4 | void setup() 5 | { 6 | Serial.begin(115200); 7 | delay(1000); // give me time to bring up serial monitor 8 | Serial.println("ESP32 Touch Test"); 9 | } 10 | 11 | void loop() 12 | { 13 | Serial.println(touchRead(T0)); // get value using T0 14 | delay(1000); 15 | } 16 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/ESP32/library.properties: -------------------------------------------------------------------------------- 1 | name=ESP32 2 | version=1.0 3 | author=Hristo Gochkov, Ivan Grokhtkov 4 | maintainer=Hristo Gochkov 5 | sentence=ESP32 sketches examples 6 | paragraph= 7 | category=Other 8 | url= 9 | architectures=esp32 10 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/ESP32/src/dummy.h: -------------------------------------------------------------------------------- 1 | // This file is here only to silence warnings from Arduino IDE 2 | // Currently IDE doesn't support no-code libraries, like this collection of example sketches. 3 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/LoRa/.travis.yml: -------------------------------------------------------------------------------- 1 | language: generic 2 | env: 3 | global: 4 | - IDE_VERSION=1.6.12 5 | matrix: 6 | - BOARD="arduino:avr:uno" 7 | - BOARD="arduino:avr:micro" 8 | - BOARD="arduino:avr:mega:cpu=atmega2560" 9 | - BOARD="arduino:samd:arduino_zero_edbg" 10 | - BOARD="arduino:samd:mkr1000" 11 | before_install: 12 | - /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16 13 | - sleep 3 14 | - export DISPLAY=:1.0 15 | - wget http://downloads.arduino.cc/arduino-$IDE_VERSION-linux64.tar.xz 16 | - tar xf arduino-$IDE_VERSION-linux64.tar.xz 17 | - mv arduino-$IDE_VERSION $HOME/arduino-ide 18 | - export PATH=$PATH:$HOME/arduino-ide 19 | - if [[ "$BOARD" =~ "arduino:samd:" ]]; then 20 | arduino --install-boards arduino:samd &> /dev/null; 21 | fi 22 | - buildExampleSketch() { arduino --verbose-build --verify --board $BOARD $PWD/examples/$1/$1.ino; } 23 | install: 24 | - mkdir -p $HOME/Arduino/libraries 25 | - ln -s $PWD $HOME/Arduino/libraries/LoRa 26 | script: 27 | - buildExampleSketch LoRaReceiver 28 | - buildExampleSketch LoRaReceiverCallback 29 | - buildExampleSketch LoRaSender 30 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/LoRa/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Sandeep Mistry 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 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/LoRa/README.md: -------------------------------------------------------------------------------- 1 | # Arduino LoRa 2 | 3 | [![Build Status](https://travis-ci.org/sandeepmistry/arduino-LoRa.svg?branch=master)](https://travis-ci.org/sandeepmistry/arduino-LoRa) 4 | 5 | An [Arduino](http://arduino.cc/) library for sending and receiving data using [LoRa](https://www.lora-alliance.org/) radios. 6 | 7 | ## Compatible Hardware 8 | 9 | * [Semtech SX1276/77/78/79](http://www.semtech.com/apps/product.php?pn=SX1276) based boards including: 10 | * [Dragino Lora Shield](http://www.dragino.com/products/module/item/102-lora-shield.html) 11 | * [HopeRF](http://www.hoperf.com/rf_transceiver/lora/) [RFM95W](http://www.hoperf.com/rf_transceiver/lora/RFM95W.html), [RFM96W](http://www.hoperf.com/rf_transceiver/lora/RFM96W.html), and [RFM98W](http://www.hoperf.com/rf_transceiver/lora/RFM98W.html) 12 | * [Modtronix](http://modtronix.com/) [inAir4](http://modtronix.com/inair4.html), [inAir9](http://modtronix.com/inair9.html), and [inAir9B](http://modtronix.com/inair9b.html) 13 | 14 | ### Semtech SX1276/77/78/79 wiring 15 | 16 | | Semtech SX1276/77/78/79 | Arduino | 17 | | :---------------------: | :------:| 18 | | VCC | 3.3V | 19 | | GND | GND | 20 | | SCK | SCK | 21 | | MISO | MISO | 22 | | MOSI | MOSI | 23 | | NSS | 10 | 24 | | NRESET | 9 | 25 | | DIO0 | 2 | 26 | 27 | 28 | `NSS`, `NRESET`, and `DIO0` pins can be changed by using `LoRa.setPins(ss, reset, dio0)`. `DIO0` pin is optional, it is only needed for receive callback mode. 29 | 30 | ## Installation 31 | 32 | ### Using the Arduino IDE Library Manager 33 | 34 | 1. Choose `Sketch` -> `Include Library` -> `Manage Libraries...` 35 | 2. Type `LoRa` into the search box. 36 | 3. Click the row to select the library. 37 | 4. Click the `Install` button to install the library. 38 | 39 | ### Using Git 40 | 41 | ```sh 42 | cd ~/Documents/Arduino/libraries/ 43 | git clone https://github.com/sandeepmistry/arduino-LoRa LoRa 44 | ``` 45 | 46 | ## API 47 | 48 | See [API.md](API.md). 49 | 50 | ## Examples 51 | 52 | See [examples](examples) folder. 53 | 54 | ## License 55 | 56 | This libary is [licensed](LICENSE) under the [MIT Licence](http://en.wikipedia.org/wiki/MIT_License). 57 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/LoRa/examples/LoRaReceiver/LoRaReceiver.ino: -------------------------------------------------------------------------------- 1 | // This example just provide basic LoRa function test; 2 | // Not the LoRa's farthest distance or strongest interference immunity. 3 | // For more informations, please vist www.heltec.cn or mail to support@heltec.cn 4 | 5 | #include 6 | #include 7 | 8 | // WIFI_LoRa_32 ports 9 | 10 | // GPIO5 -- SX1278's SCK 11 | // GPIO19 -- SX1278's MISO 12 | // GPIO27 -- SX1278's MOSI 13 | // GPIO18 -- SX1278's CS 14 | // GPIO14 -- SX1278's RESET 15 | // GPIO26 -- SX1278's IRQ(Interrupt Request) 16 | 17 | #define SS 18 18 | #define RST 14 19 | #define DI0 26 20 | #define BAND 433E6 21 | 22 | void setup() { 23 | Serial.begin(115200); 24 | while (!Serial); //if just the the basic function, must connect to a computer 25 | delay(1000); 26 | 27 | Serial.println("LoRa Receiver"); 28 | 29 | SPI.begin(5,19,27,18); 30 | LoRa.setPins(SS,RST,DI0); 31 | 32 | if (!LoRa.begin(BAND)) { 33 | Serial.println("Starting LoRa failed!"); 34 | while (1); 35 | } 36 | } 37 | 38 | void loop() { 39 | // try to parse packet 40 | int packetSize = LoRa.parsePacket(); 41 | if (packetSize) { 42 | // received a packet 43 | Serial.print("Received packet '"); 44 | 45 | // read packet 46 | while (LoRa.available()) { 47 | Serial.print((char)LoRa.read()); 48 | } 49 | 50 | // print RSSI of packet 51 | Serial.print("' with RSSI "); 52 | Serial.println(LoRa.packetRssi()); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/LoRa/examples/LoRaReceiverCallback/LoRaReceiverCallback.ino: -------------------------------------------------------------------------------- 1 | // This example just provide basic LoRa function test; 2 | // Not the LoRa's farthest distance or strongest interference immunity. 3 | // For more informations, please vist www.heltec.cn or mail to support@heltec.cn 4 | 5 | #include 6 | #include 7 | 8 | // WIFI_LoRa_32 ports 9 | 10 | // GPIO5 -- SX1278's SCK 11 | // GPIO19 -- SX1278's MISO 12 | // GPIO27 -- SX1278's MOSI 13 | // GPIO18 -- SX1278's CS 14 | // GPIO14 -- SX1278's RESET 15 | // GPIO26 -- SX1278's IRQ(Interrupt Request) 16 | 17 | #define SS 18 18 | #define RST 14 19 | #define DI0 26 20 | #define BAND 433E6 21 | 22 | void setup() { 23 | Serial.begin(115200); 24 | while (!Serial); //if just the the basic function, must connect to a computer 25 | 26 | SPI.begin(5,19,27,18); 27 | LoRa.setPins(SS,RST,DI0); 28 | 29 | Serial.println("LoRa Receiver Callback"); 30 | 31 | if (!LoRa.begin(BAND)) { 32 | Serial.println("Starting LoRa failed!"); 33 | while (1); 34 | } 35 | 36 | // register the receive callback 37 | LoRa.onReceive(onReceive); 38 | 39 | // put the radio into receive mode 40 | LoRa.receive(); 41 | } 42 | 43 | void loop() { 44 | // do nothing 45 | } 46 | 47 | void onReceive(int packetSize) { 48 | // received a packet 49 | Serial.print("Received packet '"); 50 | 51 | // read packet 52 | for (int i = 0; i < packetSize; i++) { 53 | Serial.print((char)LoRa.read()); 54 | } 55 | 56 | // print RSSI of packet 57 | Serial.print("' with RSSI "); 58 | Serial.println(LoRa.packetRssi()); 59 | } 60 | 61 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/LoRa/examples/LoRaSender/LoRaSender.ino: -------------------------------------------------------------------------------- 1 | // This example just provide basic LoRa function test; 2 | // Not the LoRa's farthest distance or strongest interference immunity. 3 | // For more informations, please vist www.heltec.cn or mail to support@heltec.cn 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | // WIFI_LoRa_32 ports 10 | 11 | // GPIO5 -- SX1278's SCK 12 | // GPIO19 -- SX1278's MISO 13 | // GPIO27 -- SX1278's MOSI 14 | // GPIO18 -- SX1278's CS 15 | // GPIO14 -- SX1278's RESET 16 | // GPIO26 -- SX1278's IRQ(Interrupt Request) 17 | 18 | #define SS 18 19 | #define RST 14 20 | #define DI0 26 21 | #define BAND 433E6 //915E6 -- 这里的模式选择中,检查一下是否可在中国实用915这个频段 22 | 23 | int counter = 0; 24 | 25 | void setup() { 26 | pinMode(25,OUTPUT); //Send success, LED will bright 1 second 27 | 28 | Serial.begin(115200); 29 | while (!Serial); //If just the the basic function, must connect to a computer 30 | 31 | SPI.begin(5,19,27,18); 32 | LoRa.setPins(SS,RST,DI0); 33 | // Serial.println("LoRa Sender"); 34 | 35 | if (!LoRa.begin(BAND)) { 36 | Serial.println("Starting LoRa failed!"); 37 | while (1); 38 | } 39 | Serial.println("LoRa Initial OK!"); 40 | } 41 | 42 | void loop() { 43 | Serial.print("Sending packet: "); 44 | Serial.println(counter); 45 | 46 | // send packet 47 | LoRa.beginPacket(); 48 | LoRa.print("hello "); 49 | LoRa.print(counter); 50 | LoRa.endPacket(); 51 | 52 | counter++; 53 | digitalWrite(25, HIGH); // turn the LED on (HIGH is the voltage level) 54 | delay(1000); // wait for a second 55 | digitalWrite(25, LOW); // turn the LED off by making the voltage LOW 56 | delay(1000); // wait for a second 57 | 58 | delay(3000); 59 | } 60 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/LoRa/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For LoRa 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | LoRa KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | 15 | begin KEYWORD2 16 | end KEYWORD2 17 | 18 | beginPacket KEYWORD2 19 | endPacket KEYWORD2 20 | 21 | parsePacket KEYWORD2 22 | packetRssi KEYWORD2 23 | packetSnr KEYWORD2 24 | 25 | write KEYWORD2 26 | 27 | available KEYWORD2 28 | read KEYWORD2 29 | peek KEYWORD2 30 | flush KEYWORD2 31 | 32 | onReceive KEYWORD2 33 | receive KEYWORD2 34 | idle KEYWORD2 35 | sleep KEYWORD2 36 | 37 | setTxPower KEYWORD2 38 | setFrequency KEYWORD2 39 | setSpreadingFactor KEYWORD2 40 | setSignalBandwidth KEYWORD2 41 | setCodingRate4 KEYWORD2 42 | setPreambleLength KEYWORD2 43 | setSyncWord KEYWORD2 44 | crc KEYWORD2 45 | noCrc KEYWORD2 46 | 47 | random KEYWORD2 48 | setPins KEYWORD2 49 | setSPIFrequency KEYWORD2 50 | dumpRegisters KEYWORD2 51 | 52 | ####################################### 53 | # Constants (LITERAL1) 54 | ####################################### 55 | 56 | PA_OUTPUT_RFO_PIN LITERAL1 57 | PA_OUTPUT_PA_BOOST_PIN LITERAL1 58 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/LoRa/library.properties: -------------------------------------------------------------------------------- 1 | name=LoRa function basic test 2 | version=0.0.2 3 | author=Aaron.Lee 4 | maintainer=Aaron.Lee 5 | sentence=An Arduino library for sending and receiving data using LoRa radios. 6 | paragraph=Supports Semtech SX1276/77/78/79 based boards/shields. 7 | category=Communication 8 | url=https://heltec.cn 9 | architectures=* 10 | includes=LoRa.h 11 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/LoRa/src/LoRa.h: -------------------------------------------------------------------------------- 1 | #ifndef LORA_H 2 | #define LORA_H 3 | 4 | #include 5 | #include 6 | 7 | #define LORA_DEFAULT_SS_PIN 18 8 | #define LORA_DEFAULT_RESET_PIN 14 9 | #define LORA_DEFAULT_DIO0_PIN 26 10 | 11 | #define PA_OUTPUT_RFO_PIN 0 12 | #define PA_OUTPUT_PA_BOOST_PIN 1 13 | 14 | class LoRaClass : public Stream { 15 | public: 16 | LoRaClass(); 17 | 18 | int begin(long frequency); 19 | void end(); 20 | 21 | int beginPacket(int implicitHeader = false); 22 | int endPacket(); 23 | 24 | int parsePacket(int size = 0); 25 | int packetRssi(); 26 | float packetSnr(); 27 | 28 | // from Print 29 | virtual size_t write(uint8_t byte); 30 | virtual size_t write(const uint8_t *buffer, size_t size); 31 | 32 | // from Stream 33 | virtual int available(); 34 | virtual int read(); 35 | virtual int peek(); 36 | virtual void flush(); 37 | 38 | void onReceive(void(*callback)(int)); 39 | 40 | void receive(int size = 0); 41 | void idle(); 42 | void sleep(); 43 | 44 | void setTxPower(int level, int outputPin = PA_OUTPUT_PA_BOOST_PIN); 45 | void setFrequency(long frequency); 46 | void setSpreadingFactor(int sf); 47 | void setSignalBandwidth(long sbw); 48 | void setCodingRate4(int denominator); 49 | void setPreambleLength(long length); 50 | void setSyncWord(int sw); 51 | void crc(); 52 | void noCrc(); 53 | 54 | byte random(); 55 | 56 | void setPins(int ss = LORA_DEFAULT_SS_PIN, int reset = LORA_DEFAULT_RESET_PIN, int dio0 = LORA_DEFAULT_DIO0_PIN); 57 | void setSPIFrequency(uint32_t frequency); 58 | 59 | void dumpRegisters(Stream& out); 60 | 61 | //private: 62 | void explicitHeaderMode(); 63 | void implicitHeaderMode(); 64 | 65 | void handleDio0Rise(); 66 | 67 | uint8_t readRegister(uint8_t address); 68 | void writeRegister(uint8_t address, uint8_t value); 69 | uint8_t singleTransfer(uint8_t address, uint8_t value); 70 | 71 | static void onDio0Rise(); 72 | 73 | private: 74 | SPISettings _spiSettings; 75 | int _ss; 76 | int _reset; 77 | int _dio0; 78 | int _frequency; 79 | int _packetIndex; 80 | int _implicitHeaderMode; 81 | void (*_onReceive)(int); 82 | }; 83 | 84 | extern LoRaClass LoRa; 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/OLED/.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "2.7" 4 | 5 | # Cache PlatformIO packages using Travis CI container-based infrastructure 6 | sudo: false 7 | cache: 8 | directories: 9 | - "~/.platformio" 10 | 11 | env: 12 | - PLATFORMIO_CI_SRC=examples/SSD1306UiDemo 13 | - PLATFORMIO_CI_SRC=examples/SSD1306SimpleDemo 14 | - PLATFORMIO_CI_SRC=examples/SSD1306DrawingDemo 15 | - PLATFORMIO_CI_SRC=examples/SSD1306OTADemo 16 | - PLATFORMIO_CI_SRC=examples/SSD1306ClockDemo 17 | 18 | 19 | install: 20 | - pip install -U platformio 21 | - platformio lib install 44 22 | 23 | script: 24 | - platformio ci --lib="." --board=nodemcuv2 25 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/OLED/SSD1306.h: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2016 by Daniel Eichhorn 5 | * Copyright (c) 2016 by Fabrice Weinberg 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | * 25 | * Credits for parts of this code go to Mike Rankin. Thank you so much for sharing! 26 | */ 27 | 28 | #ifndef SSD1306_h 29 | #define SSD1306_h 30 | #include "SSD1306Wire.h" 31 | 32 | // For legacy support make SSD1306 an alias for SSD1306 33 | typedef SSD1306Wire SSD1306; 34 | 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/OLED/examples/SSD1306SimpleDemo/images.h: -------------------------------------------------------------------------------- 1 | #define WiFi_Logo_width 60 2 | #define WiFi_Logo_height 36 3 | const char WiFi_Logo_bits[] PROGMEM = { 4 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 6 | 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 7 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 8 | 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 9 | 0xFF, 0x03, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 10 | 0x00, 0xFF, 0xFF, 0xFF, 0x07, 0xC0, 0x83, 0x01, 0x80, 0xFF, 0xFF, 0xFF, 11 | 0x01, 0x00, 0x07, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x0C, 0x00, 12 | 0xC0, 0xFF, 0xFF, 0x7C, 0x00, 0x60, 0x0C, 0x00, 0xC0, 0x31, 0x46, 0x7C, 13 | 0xFC, 0x77, 0x08, 0x00, 0xE0, 0x23, 0xC6, 0x3C, 0xFC, 0x67, 0x18, 0x00, 14 | 0xE0, 0x23, 0xE4, 0x3F, 0x1C, 0x00, 0x18, 0x00, 0xE0, 0x23, 0x60, 0x3C, 15 | 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x03, 0x60, 0x3C, 0x1C, 0x70, 0x18, 0x00, 16 | 0xE0, 0x07, 0x60, 0x3C, 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 17 | 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 18 | 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x8F, 0x71, 0x3C, 19 | 0x1C, 0x70, 0x18, 0x00, 0xC0, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x08, 0x00, 20 | 0xC0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x0C, 0x00, 0x80, 0xFF, 0xFF, 0x1F, 21 | 0x00, 0x00, 0x06, 0x00, 0x80, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x07, 0x00, 22 | 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 23 | 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 24 | 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 25 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 26 | 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 28 | }; 29 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/OLED/examples/SSD1306UiDemo/images.h: -------------------------------------------------------------------------------- 1 | #define WiFi_Logo_width 60 2 | #define WiFi_Logo_height 36 3 | const char WiFi_Logo_bits[] PROGMEM = { 4 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 6 | 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 7 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 8 | 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 9 | 0xFF, 0x03, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 10 | 0x00, 0xFF, 0xFF, 0xFF, 0x07, 0xC0, 0x83, 0x01, 0x80, 0xFF, 0xFF, 0xFF, 11 | 0x01, 0x00, 0x07, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x0C, 0x00, 12 | 0xC0, 0xFF, 0xFF, 0x7C, 0x00, 0x60, 0x0C, 0x00, 0xC0, 0x31, 0x46, 0x7C, 13 | 0xFC, 0x77, 0x08, 0x00, 0xE0, 0x23, 0xC6, 0x3C, 0xFC, 0x67, 0x18, 0x00, 14 | 0xE0, 0x23, 0xE4, 0x3F, 0x1C, 0x00, 0x18, 0x00, 0xE0, 0x23, 0x60, 0x3C, 15 | 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x03, 0x60, 0x3C, 0x1C, 0x70, 0x18, 0x00, 16 | 0xE0, 0x07, 0x60, 0x3C, 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 17 | 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 18 | 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x8F, 0x71, 0x3C, 19 | 0x1C, 0x70, 0x18, 0x00, 0xC0, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x08, 0x00, 20 | 0xC0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x0C, 0x00, 0x80, 0xFF, 0xFF, 0x1F, 21 | 0x00, 0x00, 0x06, 0x00, 0x80, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x07, 0x00, 22 | 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 23 | 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 24 | 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 25 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 26 | 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 28 | }; 29 | 30 | const char activeSymbol[] PROGMEM = { 31 | B00000000, 32 | B00000000, 33 | B00011000, 34 | B00100100, 35 | B01000010, 36 | B01000010, 37 | B00100100, 38 | B00011000 39 | }; 40 | 41 | const char inactiveSymbol[] PROGMEM = { 42 | B00000000, 43 | B00000000, 44 | B00000000, 45 | B00000000, 46 | B00011000, 47 | B00011000, 48 | B00000000, 49 | B00000000 50 | }; 51 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/OLED/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ESP8266_SSD1306", 3 | "version": "3.2.7", 4 | "keywords": "ssd1306, oled, display, i2c", 5 | "description": "A I2C display driver for SSD1306 oled displays connected to an ESP8266 or ESP32", 6 | "repository": 7 | { 8 | "type": "git", 9 | "url": "https://github.com/squix78/esp8266-oled-ssd1306.git" 10 | }, 11 | "authors": 12 | [ 13 | { 14 | "name": "Daniel Eichhorn", 15 | "email": "squix78@gmail.com", 16 | "url": "http://blog.squix.ch" 17 | }, 18 | { 19 | "name": "Fabrice Weinberg", 20 | "email": "fabrice@weinberg.me" 21 | } 22 | ], 23 | "frameworks": "arduino", 24 | "platforms": [ 25 | "espressif8266", 26 | "espressif32" 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/OLED/library.properties: -------------------------------------------------------------------------------- 1 | name=0.96 OLED DisPlay 2 | version=0.0.2 3 | author=Aaron.Lee 4 | maintainer=Aaron.Lee 5 | sentence=A I2C display driver for SSD1306 oled displays connected to an ESP8266 or ESP32 6 | paragraph=A I2C display driver for SSD1306 oled displays connected to an ESP8266 or ESP32 7 | category=Display 8 | url=https://heltec.cn 9 | architectures=esp8266,esp32 10 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/OLED/license: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 by Daniel Eichhorn 4 | Copyright (c) 2016 by Fabrice Weinberg 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | 24 | See more at http://blog.squix.ch 25 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/Preferences/examples/StartCounter/StartCounter.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ESP32 start counter example with Preferences library 3 | 4 | This simple example demonstrate using Preferences library to store how many times 5 | was ESP32 module started. Preferences library is wrapper around Non-volatile 6 | storage on ESP32 processor. 7 | 8 | created for arduino-esp32 09 Feb 2017 9 | by Martin Sloup (Arcao) 10 | */ 11 | 12 | #include 13 | 14 | Preferences preferences; 15 | 16 | void setup() { 17 | Serial.begin(115200); 18 | Serial.println(); 19 | 20 | // Open Preferences with my-app namespace. Each application module, library, etc. 21 | // has to use namespace name to prevent key name collisions. We will open storage in 22 | // RW-mode (second parameter has to be false). 23 | // Note: Namespace name is limited to 15 chars 24 | preferences.begin("my-app", false); 25 | 26 | // Remove all preferences under opened namespace 27 | //preferences.clear(); 28 | 29 | // Or remove the counter key only 30 | //preferences.remove("counter"); 31 | 32 | // Get a counter value, if key is not exist return default value 0 33 | // Note: Key name is limited to 15 chars too 34 | unsigned int counter = preferences.getUInt("counter", 0); 35 | 36 | // Increase counter 37 | counter++; 38 | 39 | // Print counter to a Serial 40 | Serial.printf("Current counter value: %u\n", counter); 41 | 42 | // Store counter to the Preferences 43 | preferences.putUInt("counter", counter); 44 | 45 | // Close the Preferences 46 | preferences.end(); 47 | 48 | // Wait 10 seconds 49 | Serial.println("Restarting in 10 seconds..."); 50 | delay(10000); 51 | 52 | // Restart ESP 53 | ESP.restart(); 54 | } 55 | 56 | void loop() {} -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/Preferences/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map NVS 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | Preferences KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | begin KEYWORD2 15 | end KEYWORD2 16 | 17 | clear KEYWORD2 18 | delete KEYWORD2 19 | 20 | putChar KEYWORD2 21 | putUChar KEYWORD2 22 | putShort KEYWORD2 23 | putUShort KEYWORD2 24 | putInt KEYWORD2 25 | putUInt KEYWORD2 26 | putLong KEYWORD2 27 | putULong KEYWORD2 28 | putLong64 KEYWORD2 29 | putULong64 KEYWORD2 30 | putFloat KEYWORD2 31 | putDouble KEYWORD2 32 | putBool KEYWORD2 33 | putString KEYWORD2 34 | putBytes KEYWORD2 35 | 36 | getChar KEYWORD2 37 | getUChar KEYWORD2 38 | getShort KEYWORD2 39 | getUShort KEYWORD2 40 | getInt KEYWORD2 41 | getUInt KEYWORD2 42 | getLong KEYWORD2 43 | getULong KEYWORD2 44 | getLong64 KEYWORD2 45 | getULong64 KEYWORD2 46 | getFloat KEYWORD2 47 | getDouble KEYWORD2 48 | getBool KEYWORD2 49 | getString KEYWORD2 50 | getBytes KEYWORD2 51 | 52 | ####################################### 53 | # Constants (LITERAL1) 54 | ####################################### 55 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/Preferences/library.properties: -------------------------------------------------------------------------------- 1 | name=Preferences 2 | version=1.0 3 | author=Hristo Gochkov 4 | maintainer=Hristo Gochkov 5 | sentence=Provides friendly access to ESP32's Non-Volatile Storage 6 | paragraph= 7 | category=Data Storage 8 | url= 9 | architectures=esp32 10 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/Preferences/src/Preferences.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | #ifndef _PREFERENCES_H_ 15 | #define _PREFERENCES_H_ 16 | 17 | #include "Arduino.h" 18 | 19 | class Preferences { 20 | protected: 21 | uint32_t _handle; 22 | bool _started; 23 | bool _readOnly; 24 | public: 25 | Preferences(); 26 | ~Preferences(); 27 | 28 | bool begin(const char * name, bool readOnly=false); 29 | void end(); 30 | 31 | bool clear(); 32 | bool remove(const char * key); 33 | 34 | size_t putChar(const char* key, int8_t value); 35 | size_t putUChar(const char* key, uint8_t value); 36 | size_t putShort(const char* key, int16_t value); 37 | size_t putUShort(const char* key, uint16_t value); 38 | size_t putInt(const char* key, int32_t value); 39 | size_t putUInt(const char* key, uint32_t value); 40 | size_t putLong(const char* key, int32_t value); 41 | size_t putULong(const char* key, uint32_t value); 42 | size_t putLong64(const char* key, int64_t value); 43 | size_t putULong64(const char* key, uint64_t value); 44 | size_t putFloat(const char* key, float_t value); 45 | size_t putDouble(const char* key, double_t value); 46 | size_t putBool(const char* key, bool value); 47 | size_t putString(const char* key, const char* value); 48 | size_t putString(const char* key, String value); 49 | size_t putBytes(const char* key, const void* value, size_t len); 50 | 51 | int8_t getChar(const char* key, int8_t defaultValue = 0); 52 | uint8_t getUChar(const char* key, uint8_t defaultValue = 0); 53 | int16_t getShort(const char* key, int16_t defaultValue = 0); 54 | uint16_t getUShort(const char* key, uint16_t defaultValue = 0); 55 | int32_t getInt(const char* key, int32_t defaultValue = 0); 56 | uint32_t getUInt(const char* key, uint32_t defaultValue = 0); 57 | int32_t getLong(const char* key, int32_t defaultValue = 0); 58 | uint32_t getULong(const char* key, uint32_t defaultValue = 0); 59 | int64_t getLong64(const char* key, int64_t defaultValue = 0); 60 | uint64_t getULong64(const char* key, uint64_t defaultValue = 0); 61 | float_t getFloat(const char* key, float_t defaultValue = NAN); 62 | double_t getDouble(const char* key, double_t defaultValue = NAN); 63 | bool getBool(const char* key, bool defaultValue = false); 64 | size_t getString(const char* key, char* value, size_t maxLen); 65 | String getString(const char* key, String defaultValue = String()); 66 | size_t getBytes(const char* key, void * buf, size_t maxLen); 67 | }; 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/SPI/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map SPI 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | SPI KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | begin KEYWORD2 15 | end KEYWORD2 16 | transfer KEYWORD2 17 | setBitOrder KEYWORD2 18 | setDataMode KEYWORD2 19 | setClockDivider KEYWORD2 20 | 21 | 22 | ####################################### 23 | # Constants (LITERAL1) 24 | ####################################### 25 | SPI_CLOCK_DIV4 LITERAL1 26 | SPI_CLOCK_DIV16 LITERAL1 27 | SPI_CLOCK_DIV64 LITERAL1 28 | SPI_CLOCK_DIV128 LITERAL1 29 | SPI_CLOCK_DIV2 LITERAL1 30 | SPI_CLOCK_DIV8 LITERAL1 31 | SPI_CLOCK_DIV32 LITERAL1 32 | SPI_CLOCK_DIV64 LITERAL1 33 | SPI_MODE0 LITERAL1 34 | SPI_MODE1 LITERAL1 35 | SPI_MODE2 LITERAL1 36 | SPI_MODE3 LITERAL1 -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/SPI/library.properties: -------------------------------------------------------------------------------- 1 | name=SPI 2 | version=1.0 3 | author=Hristo Gochkov 4 | maintainer=Hristo Gochkov 5 | sentence=Enables the communication with devices that use the Serial Peripheral Interface (SPI) Bus. For all Arduino boards, BUT Arduino DUE. 6 | paragraph= 7 | category=Signal Input/Output 8 | url=http://arduino.cc/en/Reference/SPI 9 | architectures=esp32 10 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/SPI/src/SPI.h: -------------------------------------------------------------------------------- 1 | /* 2 | SPI.h - SPI library for esp8266 3 | 4 | Copyright (c) 2015 Hristo Gochkov. All rights reserved. 5 | This file is part of the esp8266 core for Arduino environment. 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | This library 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 GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | #ifndef _SPI_H_INCLUDED 22 | #define _SPI_H_INCLUDED 23 | 24 | #include 25 | #include "esp32-hal-spi.h" 26 | 27 | class SPISettings 28 | { 29 | public: 30 | SPISettings() :_clock(1000000), _bitOrder(SPI_MSBFIRST), _dataMode(SPI_MODE0) {} 31 | SPISettings(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) :_clock(clock), _bitOrder(bitOrder), _dataMode(dataMode) {} 32 | uint32_t _clock; 33 | uint8_t _bitOrder; 34 | uint8_t _dataMode; 35 | }; 36 | 37 | class SPIClass 38 | { 39 | private: 40 | int8_t _spi_num; 41 | spi_t * _spi; 42 | bool _use_hw_ss; 43 | int8_t _sck; 44 | int8_t _miso; 45 | int8_t _mosi; 46 | int8_t _ss; 47 | uint32_t _div; 48 | uint32_t _freq; 49 | bool _inTransaction; 50 | void writePattern_(uint8_t * data, uint8_t size, uint8_t repeat); 51 | 52 | public: 53 | SPIClass(uint8_t spi_bus=HSPI); 54 | void begin(int8_t sck=-1, int8_t miso=-1, int8_t mosi=-1, int8_t ss=-1); 55 | void end(); 56 | 57 | void setHwCs(bool use); 58 | void setBitOrder(uint8_t bitOrder); 59 | void setDataMode(uint8_t dataMode); 60 | void setFrequency(uint32_t freq); 61 | void setClockDivider(uint32_t clockDiv); 62 | 63 | void beginTransaction(SPISettings settings); 64 | void endTransaction(void); 65 | 66 | uint8_t transfer(uint8_t data); 67 | uint16_t transfer16(uint16_t data); 68 | uint32_t transfer32(uint32_t data); 69 | void transferBytes(uint8_t * data, uint8_t * out, uint32_t size); 70 | void transferBits(uint32_t data, uint32_t * out, uint8_t bits); 71 | 72 | void write(uint8_t data); 73 | void write16(uint16_t data); 74 | void write32(uint32_t data); 75 | void writeBytes(uint8_t * data, uint32_t size); 76 | void writePixels(const void * data, uint32_t size);//ili9341 compatible 77 | void writePattern(uint8_t * data, uint8_t size, uint32_t repeat); 78 | 79 | spi_t * bus(){ return _spi; } 80 | }; 81 | 82 | extern SPIClass SPI; 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFi/examples/WiFiClient/WiFiClient.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * This sketch sends data via HTTP GET requests to data.sparkfun.com service. 3 | * 4 | * You need to get streamId and privateKey at data.sparkfun.com and paste them 5 | * below. Or just customize this script to talk to other HTTP servers. 6 | * 7 | */ 8 | 9 | #include 10 | 11 | const char* ssid = "your-ssid"; 12 | const char* password = "your-password"; 13 | 14 | const char* host = "data.sparkfun.com"; 15 | const char* streamId = "...................."; 16 | const char* privateKey = "...................."; 17 | 18 | void setup() 19 | { 20 | Serial.begin(115200); 21 | delay(10); 22 | 23 | // We start by connecting to a WiFi network 24 | 25 | Serial.println(); 26 | Serial.println(); 27 | Serial.print("Connecting to "); 28 | Serial.println(ssid); 29 | 30 | WiFi.begin(ssid, password); 31 | 32 | while (WiFi.status() != WL_CONNECTED) { 33 | delay(500); 34 | Serial.print("."); 35 | } 36 | 37 | Serial.println(""); 38 | Serial.println("WiFi connected"); 39 | Serial.println("IP address: "); 40 | Serial.println(WiFi.localIP()); 41 | } 42 | 43 | int value = 0; 44 | 45 | void loop() 46 | { 47 | delay(5000); 48 | ++value; 49 | 50 | Serial.print("connecting to "); 51 | Serial.println(host); 52 | 53 | // Use WiFiClient class to create TCP connections 54 | WiFiClient client; 55 | const int httpPort = 80; 56 | if (!client.connect(host, httpPort)) { 57 | Serial.println("connection failed"); 58 | return; 59 | } 60 | 61 | // We now create a URI for the request 62 | String url = "/input/"; 63 | url += streamId; 64 | url += "?private_key="; 65 | url += privateKey; 66 | url += "&value="; 67 | url += value; 68 | 69 | Serial.print("Requesting URL: "); 70 | Serial.println(url); 71 | 72 | // This will send the request to the server 73 | client.print(String("GET ") + url + " HTTP/1.1\r\n" + 74 | "Host: " + host + "\r\n" + 75 | "Connection: close\r\n\r\n"); 76 | unsigned long timeout = millis(); 77 | while (client.available() == 0) { 78 | if (millis() - timeout > 5000) { 79 | Serial.println(">>> Client Timeout !"); 80 | client.stop(); 81 | return; 82 | } 83 | } 84 | 85 | // Read all the lines of the reply from server and print them to Serial 86 | while(client.available()) { 87 | String line = client.readStringUntil('\r'); 88 | Serial.print(line); 89 | } 90 | 91 | Serial.println(); 92 | Serial.println("closing connection"); 93 | } 94 | 95 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFi/examples/WiFiClientBasic/WiFiClientBasic.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * This sketch sends a message to a TCP server 3 | * 4 | */ 5 | 6 | #include 7 | #include 8 | 9 | WiFiMulti WiFiMulti; 10 | 11 | void setup() 12 | { 13 | Serial.begin(115200); 14 | delay(10); 15 | 16 | // We start by connecting to a WiFi network 17 | WiFiMulti.addAP("SSID", "passpasspass"); 18 | 19 | Serial.println(); 20 | Serial.println(); 21 | Serial.print("Wait for WiFi... "); 22 | 23 | while(WiFiMulti.run() != WL_CONNECTED) { 24 | Serial.print("."); 25 | delay(500); 26 | } 27 | 28 | Serial.println(""); 29 | Serial.println("WiFi connected"); 30 | Serial.println("IP address: "); 31 | Serial.println(WiFi.localIP()); 32 | 33 | delay(500); 34 | } 35 | 36 | 37 | void loop() 38 | { 39 | const uint16_t port = 80; 40 | const char * host = "192.168.1.1"; // ip or dns 41 | 42 | 43 | 44 | Serial.print("connecting to "); 45 | Serial.println(host); 46 | 47 | // Use WiFiClient class to create TCP connections 48 | WiFiClient client; 49 | 50 | if (!client.connect(host, port)) { 51 | Serial.println("connection failed"); 52 | Serial.println("wait 5 sec..."); 53 | delay(5000); 54 | return; 55 | } 56 | 57 | // This will send the request to the server 58 | client.print("Send this data to server"); 59 | 60 | //read back one line from server 61 | String line = client.readStringUntil('\r'); 62 | client.println(line); 63 | 64 | Serial.println("closing connection"); 65 | client.stop(); 66 | 67 | Serial.println("wait 5 sec..."); 68 | delay(5000); 69 | } 70 | 71 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFi/examples/WiFiClientEvents/WiFiClientEvents.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * This sketch shows the WiFi event usage 3 | * 4 | */ 5 | 6 | #include 7 | 8 | const char* ssid = "your-ssid"; 9 | const char* password = "your-password"; 10 | 11 | 12 | void WiFiEvent(WiFiEvent_t event) 13 | { 14 | Serial.printf("[WiFi-event] event: %d\n", event); 15 | 16 | switch(event) { 17 | case SYSTEM_EVENT_STA_GOT_IP: 18 | Serial.println("WiFi connected"); 19 | Serial.println("IP address: "); 20 | Serial.println(WiFi.localIP()); 21 | break; 22 | case SYSTEM_EVENT_STA_DISCONNECTED: 23 | Serial.println("WiFi lost connection"); 24 | break; 25 | } 26 | } 27 | 28 | void setup() 29 | { 30 | Serial.begin(115200); 31 | 32 | // delete old config 33 | WiFi.disconnect(true); 34 | 35 | delay(1000); 36 | 37 | WiFi.onEvent(WiFiEvent); 38 | 39 | WiFi.begin(ssid, password); 40 | 41 | Serial.println(); 42 | Serial.println(); 43 | Serial.println("Wait for WiFi... "); 44 | } 45 | 46 | 47 | void loop() 48 | { 49 | delay(1000); 50 | } 51 | 52 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFi/examples/WiFiMulti/WiFiMulti.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * This sketch trys to Connect to the best AP based on a given list 3 | * 4 | */ 5 | 6 | #include 7 | #include 8 | 9 | WiFiMulti wifiMulti; 10 | 11 | void setup() 12 | { 13 | Serial.begin(115200); 14 | delay(10); 15 | 16 | wifiMulti.addAP("ssid_from_AP_1", "your_password_for_AP_1"); 17 | wifiMulti.addAP("ssid_from_AP_2", "your_password_for_AP_2"); 18 | wifiMulti.addAP("ssid_from_AP_3", "your_password_for_AP_3"); 19 | 20 | Serial.println("Connecting Wifi..."); 21 | if(wifiMulti.run() == WL_CONNECTED) { 22 | Serial.println(""); 23 | Serial.println("WiFi connected"); 24 | Serial.println("IP address: "); 25 | Serial.println(WiFi.localIP()); 26 | } 27 | } 28 | 29 | void loop() 30 | { 31 | if(wifiMulti.run() != WL_CONNECTED) { 32 | Serial.println("WiFi not connected!"); 33 | delay(1000); 34 | } 35 | } -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFi/examples/WiFiScan/WiFiScan.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * This sketch demonstrates how to scan WiFi networks. 3 | * The API is almost the same as with the WiFi Shield library, 4 | * the most obvious difference being the different file you need to include: 5 | */ 6 | #include "WiFi.h" 7 | 8 | void setup() 9 | { 10 | Serial.begin(115200); 11 | 12 | // Set WiFi to station mode and disconnect from an AP if it was previously connected 13 | WiFi.mode(WIFI_STA); 14 | WiFi.disconnect(); 15 | delay(100); 16 | 17 | Serial.println("Setup done"); 18 | } 19 | 20 | void loop() 21 | { 22 | Serial.println("scan start"); 23 | 24 | // WiFi.scanNetworks will return the number of networks found 25 | int n = WiFi.scanNetworks(); 26 | Serial.println("scan done"); 27 | if (n == 0) { 28 | Serial.println("no networks found"); 29 | } else { 30 | Serial.print(n); 31 | Serial.println(" networks found"); 32 | for (int i = 0; i < n; ++i) { 33 | // Print SSID and RSSI for each network found 34 | Serial.print(i + 1); 35 | Serial.print(": "); 36 | Serial.print(WiFi.SSID(i)); 37 | Serial.print(" ("); 38 | Serial.print(WiFi.RSSI(i)); 39 | Serial.print(")"); 40 | Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*"); 41 | delay(10); 42 | } 43 | } 44 | Serial.println(""); 45 | 46 | // Wait a bit before scanning again 47 | delay(5000); 48 | } 49 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFi/examples/WiFiScan/images.h: -------------------------------------------------------------------------------- 1 | #define WiFi_Logo_width 60 2 | #define WiFi_Logo_height 36 3 | const char WiFi_Logo_bits[] PROGMEM = { 4 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 6 | 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 7 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 8 | 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 9 | 0xFF, 0x03, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 10 | 0x00, 0xFF, 0xFF, 0xFF, 0x07, 0xC0, 0x83, 0x01, 0x80, 0xFF, 0xFF, 0xFF, 11 | 0x01, 0x00, 0x07, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x0C, 0x00, 12 | 0xC0, 0xFF, 0xFF, 0x7C, 0x00, 0x60, 0x0C, 0x00, 0xC0, 0x31, 0x46, 0x7C, 13 | 0xFC, 0x77, 0x08, 0x00, 0xE0, 0x23, 0xC6, 0x3C, 0xFC, 0x67, 0x18, 0x00, 14 | 0xE0, 0x23, 0xE4, 0x3F, 0x1C, 0x00, 0x18, 0x00, 0xE0, 0x23, 0x60, 0x3C, 15 | 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x03, 0x60, 0x3C, 0x1C, 0x70, 0x18, 0x00, 16 | 0xE0, 0x07, 0x60, 0x3C, 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 17 | 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 18 | 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x8F, 0x71, 0x3C, 19 | 0x1C, 0x70, 0x18, 0x00, 0xC0, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x08, 0x00, 20 | 0xC0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x0C, 0x00, 0x80, 0xFF, 0xFF, 0x1F, 21 | 0x00, 0x00, 0x06, 0x00, 0x80, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x07, 0x00, 22 | 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 23 | 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 24 | 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 25 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 26 | 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 28 | }; 29 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFi/examples/WiFiSmartConfig/WiFiSmartConfig.ino: -------------------------------------------------------------------------------- 1 | #include "WiFi.h" 2 | 3 | void setup() { 4 | Serial.begin(115200); 5 | 6 | //Init WiFi as Station, start SmartConfig 7 | WiFi.mode(WIFI_AP_STA); 8 | WiFi.beginSmartConfig(); 9 | 10 | //Wait for SmartConfig packet from mobile 11 | Serial.println("Waiting for SmartConfig."); 12 | while (!WiFi.smartConfigDone()) { 13 | delay(500); 14 | Serial.print("."); 15 | } 16 | 17 | Serial.println(""); 18 | Serial.println("SmartConfig received."); 19 | 20 | //Wait for WiFi to connect to AP 21 | Serial.println("Waiting for WiFi"); 22 | while (WiFi.status() != WL_CONNECTED) { 23 | delay(500); 24 | Serial.print("."); 25 | } 26 | 27 | Serial.println("WiFi Connected."); 28 | 29 | Serial.print("IP Address: "); 30 | Serial.println(WiFi.localIP()); 31 | } 32 | 33 | void loop() { 34 | // put your main code here, to run repeatedly: 35 | 36 | } 37 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFi/examples/WiFiUDPClient/WiFiUDPClient.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * This sketch sends random data over UDP on a ESP32 device 3 | * 4 | */ 5 | #include 6 | #include 7 | 8 | // WiFi network name and password: 9 | const char * networkName = "your-ssid"; 10 | const char * networkPswd = "your-password"; 11 | 12 | //IP address to send UDP data to: 13 | // either use the ip address of the server or 14 | // a network broadcast address 15 | const char * udpAddress = "192.168.0.255"; 16 | const int udpPort = 3333; 17 | 18 | //Are we currently connected? 19 | boolean connected = false; 20 | 21 | //The udp library class 22 | WiFiUDP udp; 23 | 24 | void setup(){ 25 | // Initilize hardware serial: 26 | Serial.begin(115200); 27 | 28 | //Connect to the WiFi network 29 | connectToWiFi(networkName, networkPswd); 30 | } 31 | 32 | void loop(){ 33 | //only send data when connected 34 | if(connected){ 35 | //Send a packet 36 | udp.beginPacket(udpAddress,udpPort); 37 | udp.printf("Seconds since boot: %u", millis()/1000); 38 | udp.endPacket(); 39 | } 40 | //Wait for 1 second 41 | delay(1000); 42 | } 43 | 44 | void connectToWiFi(const char * ssid, const char * pwd){ 45 | Serial.println("Connecting to WiFi network: " + String(ssid)); 46 | 47 | // delete old config 48 | WiFi.disconnect(true); 49 | //register event handler 50 | WiFi.onEvent(WiFiEvent); 51 | 52 | //Initiate connection 53 | WiFi.begin(ssid, pwd); 54 | 55 | Serial.println("Waiting for WIFI connection..."); 56 | } 57 | 58 | //wifi event handler 59 | void WiFiEvent(WiFiEvent_t event){ 60 | switch(event) { 61 | case SYSTEM_EVENT_STA_GOT_IP: 62 | //When connected set 63 | Serial.print("WiFi connected! IP address: "); 64 | Serial.println(WiFi.localIP()); 65 | //initializes the UDP state 66 | //This initializes the transfer buffer 67 | udp.begin(WiFi.localIP(),udpPort); 68 | connected = true; 69 | break; 70 | case SYSTEM_EVENT_STA_DISCONNECTED: 71 | Serial.println("WiFi lost connection"); 72 | connected = false; 73 | break; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFi/examples/WiFiUDPClient/udp_server.py: -------------------------------------------------------------------------------- 1 | # This python script listens on UDP port 3333 2 | # for messages from the ESP32 board and prints them 3 | import socket 4 | import sys 5 | 6 | try : 7 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 8 | s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) 9 | except socket.error, msg : 10 | print 'Failed to create socket. Error Code : ' + str(msg[0]) + ' Message ' + msg[1] 11 | sys.exit() 12 | 13 | try: 14 | s.bind(('', 3333)) 15 | except socket.error , msg: 16 | print 'Bind failed. Error: ' + str(msg[0]) + ': ' + msg[1] 17 | sys.exit() 18 | 19 | print 'Server listening' 20 | 21 | while 1: 22 | d = s.recvfrom(1024) 23 | data = d[0] 24 | 25 | if not data: 26 | break 27 | 28 | print data.strip() 29 | 30 | s.close() -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFi/examples/WiFiUDPClient/udp_server.rb: -------------------------------------------------------------------------------- 1 | # This ruby script listens on UDP port 3333 2 | # for messages from the ESP32 board and prints them 3 | 4 | require 'socket' 5 | include Socket::Constants 6 | 7 | udp_socket = UDPSocket.new(AF_INET) 8 | 9 | #bind 10 | udp_socket.bind("", 3333) 11 | puts 'Server listening' 12 | 13 | while true do 14 | message, sender = udp_socket.recvfrom(1024) 15 | puts message 16 | end -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFi/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For WiFi 3 | ####################################### 4 | 5 | ####################################### 6 | # Library (KEYWORD3) 7 | ####################################### 8 | 9 | WiFi KEYWORD3 10 | 11 | ####################################### 12 | # Datatypes (KEYWORD1) 13 | ####################################### 14 | 15 | WiFi KEYWORD1 16 | WiFiClient KEYWORD1 17 | WiFiServer KEYWORD1 18 | WiFiUDP KEYWORD1 19 | WiFiClientSecure KEYWORD1 20 | 21 | ####################################### 22 | # Methods and Functions (KEYWORD2) 23 | ####################################### 24 | 25 | status KEYWORD2 26 | mode KEYWORD2 27 | connect KEYWORD2 28 | write KEYWORD2 29 | available KEYWORD2 30 | config KEYWORD2 31 | setDNS KEYWORD2 32 | read KEYWORD2 33 | flush KEYWORD2 34 | stop KEYWORD2 35 | connected KEYWORD2 36 | begin KEYWORD2 37 | beginMulticast KEYWORD2 38 | disconnect KEYWORD2 39 | macAddress KEYWORD2 40 | localIP KEYWORD2 41 | subnetMask KEYWORD2 42 | gatewayIP KEYWORD2 43 | SSID KEYWORD2 44 | psk KEYWORD2 45 | BSSID KEYWORD2 46 | RSSI KEYWORD2 47 | encryptionType KEYWORD2 48 | beginPacket KEYWORD2 49 | beginPacketMulticast KEYWORD2 50 | endPacket KEYWORD2 51 | parsePacket KEYWORD2 52 | destinationIP KEYWORD2 53 | remoteIP KEYWORD2 54 | remotePort KEYWORD2 55 | softAP KEYWORD2 56 | softAPIP KEYWORD2 57 | softAPmacAddress KEYWORD2 58 | softAPConfig KEYWORD2 59 | printDiag KEYWORD2 60 | hostByName KEYWORD2 61 | scanNetworks KEYWORD2 62 | 63 | ####################################### 64 | # Constants (LITERAL1) 65 | ####################################### 66 | WIFI_AP LITERAL1 67 | WIFI_STA LITERAL1 68 | WIFI_AP_STA LITERAL1 69 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFi/library.properties: -------------------------------------------------------------------------------- 1 | name=WiFi 2 | version=1.0 3 | author=Hristo Gochkov 4 | maintainer=Hristo Gochkov 5 | sentence=Enables network connection (local and Internet) using the ESP32 built-in WiFi. 6 | paragraph=With this library you can instantiate Servers, Clients and send/receive UDP packets through WiFi. The shield can connect either to open or encrypted networks (WEP, WPA). The IP address can be assigned statically or through a DHCP. The library can also manage DNS. 7 | category=Communication 8 | url= 9 | architectures=esp32 10 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFi/src/WiFi.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ESP8266WiFi.cpp - WiFi library for esp8266 3 | 4 | Copyright (c) 2014 Ivan Grokhotkov. All rights reserved. 5 | This file is part of the esp8266 core for Arduino environment. 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | This library 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 GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | 21 | Reworked on 28 Dec 2015 by Markus Sattler 22 | 23 | */ 24 | #include "WiFi.h" 25 | 26 | extern "C" { 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | } 37 | 38 | 39 | // ----------------------------------------------------------------------------------------------------------------------- 40 | // ---------------------------------------------------------- Debug ------------------------------------------------------ 41 | // ----------------------------------------------------------------------------------------------------------------------- 42 | 43 | 44 | /** 45 | * Output WiFi settings to an object derived from Print interface (like Serial). 46 | * @param p Print interface 47 | */ 48 | void WiFiClass::printDiag(Print& p) 49 | { 50 | const char* modes[] = { "NULL", "STA", "AP", "STA+AP" }; 51 | 52 | wifi_mode_t mode; 53 | esp_wifi_get_mode(&mode); 54 | 55 | uint8_t primaryChan; 56 | wifi_second_chan_t secondChan; 57 | esp_wifi_get_channel(&primaryChan, &secondChan); 58 | 59 | bool autoConnect; 60 | esp_wifi_get_auto_connect(&autoConnect); 61 | 62 | p.print("Mode: "); 63 | p.println(modes[mode]); 64 | 65 | p.print("Channel: "); 66 | p.println(primaryChan); 67 | /* 68 | p.print("AP id: "); 69 | p.println(wifi_station_get_current_ap_id()); 70 | 71 | p.print("Status: "); 72 | p.println(wifi_station_get_connect_status()); 73 | */ 74 | p.print("Auto connect: "); 75 | p.println(autoConnect); 76 | 77 | wifi_config_t conf; 78 | esp_wifi_get_config(WIFI_IF_STA, &conf); 79 | 80 | const char* ssid = reinterpret_cast(conf.sta.ssid); 81 | p.print("SSID ("); 82 | p.print(strlen(ssid)); 83 | p.print("): "); 84 | p.println(ssid); 85 | 86 | const char* passphrase = reinterpret_cast(conf.sta.password); 87 | p.print("Passphrase ("); 88 | p.print(strlen(passphrase)); 89 | p.print("): "); 90 | p.println(passphrase); 91 | 92 | p.print("BSSID set: "); 93 | p.println(conf.sta.bssid_set); 94 | } 95 | 96 | WiFiClass WiFi; 97 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFi/src/WiFi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ESP8266WiFi.h - esp8266 Wifi support. 3 | Based on WiFi.h from Arduino WiFi shield library. 4 | Copyright (c) 2011-2014 Arduino. All right reserved. 5 | Modified by Ivan Grokhotkov, December 2014 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | This library 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 GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef WiFi_h 23 | #define WiFi_h 24 | 25 | #include 26 | 27 | #include "Print.h" 28 | #include "IPAddress.h" 29 | #include "IPv6Address.h" 30 | 31 | #include "WiFiType.h" 32 | #include "WiFiSTA.h" 33 | #include "WiFiAP.h" 34 | #include "WiFiScan.h" 35 | #include "WiFiGeneric.h" 36 | 37 | #include "WiFiClient.h" 38 | #include "WiFiServer.h" 39 | #include "WiFiUdp.h" 40 | 41 | class WiFiClass : public WiFiGenericClass, public WiFiSTAClass, public WiFiScanClass, public WiFiAPClass 42 | { 43 | public: 44 | using WiFiGenericClass::channel; 45 | 46 | using WiFiSTAClass::SSID; 47 | using WiFiSTAClass::RSSI; 48 | using WiFiSTAClass::BSSID; 49 | using WiFiSTAClass::BSSIDstr; 50 | 51 | using WiFiScanClass::SSID; 52 | using WiFiScanClass::encryptionType; 53 | using WiFiScanClass::RSSI; 54 | using WiFiScanClass::BSSID; 55 | using WiFiScanClass::BSSIDstr; 56 | using WiFiScanClass::channel; 57 | 58 | public: 59 | void printDiag(Print& dest); 60 | friend class WiFiClient; 61 | friend class WiFiServer; 62 | friend class WiFiUDP; 63 | }; 64 | 65 | extern WiFiClass WiFi; 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFi/src/WiFiAP.h: -------------------------------------------------------------------------------- 1 | /* 2 | ESP8266WiFiAP.h - esp8266 Wifi support. 3 | Based on WiFi.h from Arduino WiFi shield library. 4 | Copyright (c) 2011-2014 Arduino. All right reserved. 5 | Modified by Ivan Grokhotkov, December 2014 6 | Reworked by Markus Sattler, December 2015 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef ESP32WIFIAP_H_ 24 | #define ESP32WIFIAP_H_ 25 | 26 | 27 | #include "WiFiType.h" 28 | #include "WiFiGeneric.h" 29 | 30 | 31 | class WiFiAPClass 32 | { 33 | 34 | // ---------------------------------------------------------------------------------------------- 35 | // ----------------------------------------- AP function ---------------------------------------- 36 | // ---------------------------------------------------------------------------------------------- 37 | 38 | public: 39 | 40 | bool softAP(const char* ssid, const char* passphrase = NULL, int channel = 1, int ssid_hidden = 0); 41 | bool softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress subnet); 42 | bool softAPdisconnect(bool wifioff = false); 43 | 44 | uint8_t softAPgetStationNum(); 45 | 46 | IPAddress softAPIP(); 47 | 48 | bool softAPenableIpV6(); 49 | IPv6Address softAPIPv6(); 50 | 51 | const char * softAPgetHostname(); 52 | bool softAPsetHostname(const char * hostname); 53 | 54 | uint8_t* softAPmacAddress(uint8_t* mac); 55 | String softAPmacAddress(void); 56 | 57 | protected: 58 | 59 | }; 60 | 61 | #endif /* ESP32WIFIAP_H_*/ 62 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFi/src/WiFiClient.h: -------------------------------------------------------------------------------- 1 | /* 2 | Client.h - Base class that provides Client 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef _WIFICLIENT_H_ 21 | #define _WIFICLIENT_H_ 22 | 23 | 24 | #include "Arduino.h" 25 | #include "Client.h" 26 | 27 | class WiFiClient : public Client 28 | { 29 | protected: 30 | int sockfd; 31 | bool _connected; 32 | 33 | public: 34 | WiFiClient *next; 35 | WiFiClient(); 36 | WiFiClient(int fd); 37 | ~WiFiClient(); 38 | int connect(IPAddress ip, uint16_t port); 39 | int connect(const char *host, uint16_t port); 40 | size_t write(uint8_t data); 41 | size_t write(const uint8_t *buf, size_t size); 42 | int available(); 43 | int read(); 44 | int read(uint8_t *buf, size_t size); 45 | int peek() 46 | { 47 | return 0; 48 | } 49 | void flush() {} 50 | void stop(); 51 | uint8_t connected(); 52 | 53 | operator bool() 54 | { 55 | return connected(); 56 | } 57 | WiFiClient & operator=(const WiFiClient &other); 58 | bool operator==(const bool value) 59 | { 60 | return bool() == value; 61 | } 62 | bool operator!=(const bool value) 63 | { 64 | return bool() != value; 65 | } 66 | bool operator==(const WiFiClient&); 67 | bool operator!=(const WiFiClient& rhs) 68 | { 69 | return !this->operator==(rhs); 70 | }; 71 | 72 | int fd() 73 | { 74 | return sockfd; 75 | } 76 | IPAddress remoteIP(); 77 | uint16_t remotePort(); 78 | int setSocketOption(int option, char* value, size_t len); 79 | int setOption(int option, int *value); 80 | int getOption(int option, int *value); 81 | int setTimeout(uint32_t seconds); 82 | int setNoDelay(bool nodelay); 83 | bool getNoDelay(); 84 | 85 | IPAddress remoteIP(int fd); 86 | uint16_t remotePort(int fd); 87 | 88 | //friend class WiFiServer; 89 | using Print::write; 90 | }; 91 | 92 | #endif /* _WIFICLIENT_H_ */ 93 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFi/src/WiFiGeneric.h: -------------------------------------------------------------------------------- 1 | /* 2 | ESP8266WiFiGeneric.h - esp8266 Wifi support. 3 | Based on WiFi.h from Ardiono WiFi shield library. 4 | Copyright (c) 2011-2014 Arduino. All right reserved. 5 | Modified by Ivan Grokhotkov, December 2014 6 | Reworked by Markus Sattler, December 2015 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef ESP32WIFIGENERIC_H_ 24 | #define ESP32WIFIGENERIC_H_ 25 | 26 | #include "WiFiType.h" 27 | #include 28 | #include 29 | 30 | typedef void (*WiFiEventCb)(system_event_id_t event); 31 | 32 | typedef struct { 33 | WiFiEventCb cb; 34 | system_event_id_t event; 35 | } WiFiEventCbList_t; 36 | 37 | class WiFiGenericClass 38 | { 39 | public: 40 | 41 | WiFiGenericClass(); 42 | 43 | void onEvent(WiFiEventCb cbEvent, system_event_id_t event = SYSTEM_EVENT_MAX); 44 | void removeEvent(WiFiEventCb cbEvent, system_event_id_t event = SYSTEM_EVENT_MAX); 45 | 46 | int32_t channel(void); 47 | 48 | void persistent(bool persistent); 49 | 50 | static bool mode(wifi_mode_t); 51 | static wifi_mode_t getMode(); 52 | 53 | bool enableSTA(bool enable); 54 | bool enableAP(bool enable); 55 | 56 | static esp_err_t _eventCallback(void *arg, system_event_t *event); 57 | 58 | protected: 59 | static bool _persistent; 60 | static wifi_mode_t _forceSleepLastMode; 61 | 62 | public: 63 | 64 | int hostByName(const char* aHostname, IPAddress& aResult); 65 | 66 | protected: 67 | 68 | friend class WiFiSTAClass; 69 | friend class WiFiScanClass; 70 | friend class WiFiAPClass; 71 | }; 72 | 73 | #endif /* ESP32WIFIGENERIC_H_ */ 74 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFi/src/WiFiMulti.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @file ESP8266WiFiMulti.h 4 | * @date 16.05.2015 5 | * @author Markus Sattler 6 | * 7 | * Copyright (c) 2015 Markus Sattler. All rights reserved. 8 | * This file is part of the esp8266 core for Arduino environment. 9 | * 10 | * This library is free software; you can redistribute it and/or 11 | * modify it under the terms of the GNU Lesser General Public 12 | * License as published by the Free Software Foundation; either 13 | * version 2.1 of the License, or (at your option) any later version. 14 | * 15 | * This library is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | * Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; if not, write to the Free Software 22 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | * 24 | */ 25 | 26 | #ifndef WIFICLIENTMULTI_H_ 27 | #define WIFICLIENTMULTI_H_ 28 | 29 | #include "WiFi.h" 30 | #undef min 31 | #undef max 32 | #include 33 | 34 | #ifdef DEBUG_ESP_WIFI 35 | #ifdef DEBUG_ESP_PORT 36 | #define DEBUG_WIFI_MULTI(...) DEBUG_ESP_PORT.printf( __VA_ARGS__ ) 37 | #endif 38 | #endif 39 | 40 | #ifndef DEBUG_WIFI_MULTI 41 | #define DEBUG_WIFI_MULTI(...) 42 | #endif 43 | 44 | typedef struct { 45 | char * ssid; 46 | char * passphrase; 47 | } WifiAPlist_t; 48 | 49 | class WiFiMulti 50 | { 51 | public: 52 | WiFiMulti(); 53 | ~WiFiMulti(); 54 | 55 | bool addAP(const char* ssid, const char *passphrase = NULL); 56 | 57 | uint8_t run(void); 58 | 59 | private: 60 | std::vector APlist; 61 | bool APlistAdd(const char* ssid, const char *passphrase = NULL); 62 | void APlistClean(void); 63 | 64 | }; 65 | 66 | #endif /* WIFICLIENTMULTI_H_ */ 67 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFi/src/WiFiSTA.h: -------------------------------------------------------------------------------- 1 | /* 2 | ESP8266WiFiSTA.h - esp8266 Wifi support. 3 | Based on WiFi.h from Ardiono WiFi shield library. 4 | Copyright (c) 2011-2014 Arduino. All right reserved. 5 | Modified by Ivan Grokhotkov, December 2014 6 | Reworked by Markus Sattler, December 2015 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef ESP32WIFISTA_H_ 24 | #define ESP32WIFISTA_H_ 25 | 26 | 27 | #include "WiFiType.h" 28 | #include "WiFiGeneric.h" 29 | 30 | 31 | class WiFiSTAClass 32 | { 33 | // ---------------------------------------------------------------------------------------------- 34 | // ---------------------------------------- STA function ---------------------------------------- 35 | // ---------------------------------------------------------------------------------------------- 36 | 37 | public: 38 | 39 | wl_status_t begin(const char* ssid, const char *passphrase = NULL, int32_t channel = 0, const uint8_t* bssid = NULL, bool connect = true); 40 | wl_status_t begin(char* ssid, char *passphrase = NULL, int32_t channel = 0, const uint8_t* bssid = NULL, bool connect = true); 41 | wl_status_t begin(); 42 | 43 | bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = (uint32_t)0x00000000, IPAddress dns2 = (uint32_t)0x00000000); 44 | 45 | bool reconnect(); 46 | bool disconnect(bool wifioff = false); 47 | 48 | bool isConnected(); 49 | 50 | bool setAutoConnect(bool autoConnect); 51 | bool getAutoConnect(); 52 | 53 | bool setAutoReconnect(bool autoReconnect); 54 | 55 | uint8_t waitForConnectResult(); 56 | 57 | // STA network info 58 | IPAddress localIP(); 59 | 60 | uint8_t * macAddress(uint8_t* mac); 61 | String macAddress(); 62 | 63 | IPAddress subnetMask(); 64 | IPAddress gatewayIP(); 65 | IPAddress dnsIP(uint8_t dns_no = 0); 66 | 67 | bool enableIpV6(); 68 | IPv6Address localIPv6(); 69 | 70 | const char * getHostname(); 71 | bool setHostname(const char * hostname); 72 | 73 | // STA WiFi info 74 | wl_status_t status(); 75 | String SSID() const; 76 | String psk() const; 77 | 78 | uint8_t * BSSID(); 79 | String BSSIDstr(); 80 | 81 | int8_t RSSI(); 82 | 83 | static void _setStatus(wl_status_t status); 84 | protected: 85 | static wl_status_t _status; 86 | static bool _useStaticIp; 87 | 88 | public: 89 | bool beginSmartConfig(); 90 | bool stopSmartConfig(); 91 | bool smartConfigDone(); 92 | 93 | protected: 94 | static bool _smartConfigStarted; 95 | static bool _smartConfigDone; 96 | static void _smartConfigCallback(uint32_t status, void* result); 97 | 98 | }; 99 | 100 | 101 | #endif /* ESP32WIFISTA_H_ */ 102 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFi/src/WiFiScan.h: -------------------------------------------------------------------------------- 1 | /* 2 | ESP8266WiFiScan.h - esp8266 Wifi support. 3 | Based on WiFi.h from Ardiono WiFi shield library. 4 | Copyright (c) 2011-2014 Arduino. All right reserved. 5 | Modified by Ivan Grokhotkov, December 2014 6 | Reworked by Markus Sattler, December 2015 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef ESP32WIFISCAN_H_ 24 | #define ESP32WIFISCAN_H_ 25 | 26 | #include "WiFiType.h" 27 | #include "WiFiGeneric.h" 28 | 29 | class WiFiScanClass 30 | { 31 | 32 | public: 33 | 34 | int8_t scanNetworks(bool async = false, bool show_hidden = false); 35 | 36 | int8_t scanComplete(); 37 | void scanDelete(); 38 | 39 | // scan result 40 | bool getNetworkInfo(uint8_t networkItem, String &ssid, uint8_t &encryptionType, int32_t &RSSI, uint8_t* &BSSID, int32_t &channel); 41 | 42 | String SSID(uint8_t networkItem); 43 | wifi_auth_mode_t encryptionType(uint8_t networkItem); 44 | int32_t RSSI(uint8_t networkItem); 45 | uint8_t * BSSID(uint8_t networkItem); 46 | String BSSIDstr(uint8_t networkItem); 47 | int32_t channel(uint8_t networkItem); 48 | 49 | static void _scanDone(); 50 | protected: 51 | 52 | static bool _scanAsync; 53 | static bool _scanStarted; 54 | static bool _scanComplete; 55 | 56 | static uint16_t _scanCount; 57 | static void* _scanResult; 58 | 59 | static void * _getScanInfoByIndex(int i); 60 | 61 | }; 62 | 63 | 64 | #endif /* ESP32WIFISCAN_H_ */ 65 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFi/src/WiFiServer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Server.cpp - Server class for Raspberry Pi 3 | Copyright (c) 2016 Hristo Gochkov All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | #include "WiFiServer.h" 20 | #include 21 | #include 22 | 23 | #undef write 24 | 25 | int WiFiServer::setTimeout(uint32_t seconds){ 26 | struct timeval tv; 27 | tv.tv_sec = seconds; 28 | tv.tv_usec = 0; 29 | if(setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct timeval)) < 0) 30 | return -1; 31 | return setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, sizeof(struct timeval)); 32 | } 33 | 34 | size_t WiFiServer::write(const uint8_t *data, size_t len){ 35 | return 0; 36 | } 37 | 38 | void WiFiServer::stopAll(){} 39 | 40 | WiFiClient WiFiServer::available(){ 41 | if(!_listening) 42 | return WiFiClient(); 43 | struct sockaddr_in _client; 44 | int cs = sizeof(struct sockaddr_in); 45 | int client_sock = accept(sockfd, (struct sockaddr *)&_client, (socklen_t*)&cs); 46 | if(client_sock >= 0){ 47 | int val = 1; 48 | if(setsockopt(client_sock, SOL_SOCKET, SO_KEEPALIVE, (char*)&val, sizeof(int)) == ESP_OK) 49 | return WiFiClient(client_sock); 50 | } 51 | return WiFiClient(); 52 | } 53 | 54 | void WiFiServer::begin(){ 55 | if(_listening) 56 | return; 57 | struct sockaddr_in server; 58 | sockfd = socket(AF_INET , SOCK_STREAM, 0); 59 | if (sockfd < 0) 60 | return; 61 | server.sin_family = AF_INET; 62 | server.sin_addr.s_addr = INADDR_ANY; 63 | server.sin_port = htons(_port); 64 | if(bind(sockfd, (struct sockaddr *)&server, sizeof(server)) < 0) 65 | return; 66 | if(listen(sockfd , _max_clients) < 0) 67 | return; 68 | fcntl(sockfd, F_SETFL, O_NONBLOCK); 69 | _listening = true; 70 | } 71 | 72 | void WiFiServer::end(){ 73 | close(sockfd); 74 | sockfd = -1; 75 | _listening = false; 76 | } 77 | 78 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFi/src/WiFiServer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Server.h - Server class for Raspberry Pi 3 | Copyright (c) 2016 Hristo Gochkov All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | #ifndef _WIFISERVER_H_ 20 | #define _WIFISERVER_H_ 21 | 22 | #include "Arduino.h" 23 | #include "Server.h" 24 | #include "WiFiClient.h" 25 | 26 | class WiFiServer : public Server { 27 | private: 28 | int sockfd; 29 | uint16_t _port; 30 | uint8_t _max_clients; 31 | bool _listening; 32 | 33 | public: 34 | void listenOnLocalhost(){} 35 | 36 | WiFiServer(uint16_t port=80, uint8_t max_clients=4):sockfd(-1),_port(port),_max_clients(max_clients),_listening(false){} 37 | ~WiFiServer(){ end();} 38 | WiFiClient available(); 39 | WiFiClient accept(){return available();} 40 | void begin(); 41 | size_t write(const uint8_t *data, size_t len); 42 | size_t write(uint8_t data){ 43 | return write(&data, 1); 44 | } 45 | using Print::write; 46 | 47 | void end(); 48 | operator bool(){return _listening;} 49 | int setTimeout(uint32_t seconds); 50 | void stopAll(); 51 | }; 52 | 53 | #endif /* _WIFISERVER_H_ */ 54 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFi/src/WiFiType.h: -------------------------------------------------------------------------------- 1 | /* 2 | ESP8266WiFiType.h - esp8266 Wifi support. 3 | Copyright (c) 2011-2014 Arduino. All right reserved. 4 | Modified by Ivan Grokhotkov, December 2014 5 | Reworked by Markus Sattler, December 2015 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | This library 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 GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | 23 | #ifndef ESP32WIFITYPE_H_ 24 | #define ESP32WIFITYPE_H_ 25 | 26 | #define WIFI_SCAN_RUNNING (-1) 27 | #define WIFI_SCAN_FAILED (-2) 28 | 29 | #define WiFiMode_t wifi_mode_t 30 | #define WIFI_OFF WIFI_MODE_NULL 31 | #define WIFI_STA WIFI_MODE_STA 32 | #define WIFI_AP WIFI_MODE_AP 33 | #define WIFI_AP_STA WIFI_MODE_APSTA 34 | 35 | #define WiFiEvent_t system_event_id_t 36 | 37 | typedef enum { 38 | WL_NO_SHIELD = 255, // for compatibility with WiFi Shield library 39 | WL_IDLE_STATUS = 0, 40 | WL_NO_SSID_AVAIL = 1, 41 | WL_SCAN_COMPLETED = 2, 42 | WL_CONNECTED = 3, 43 | WL_CONNECT_FAILED = 4, 44 | WL_CONNECTION_LOST = 5, 45 | WL_DISCONNECTED = 6 46 | } wl_status_t; 47 | 48 | #endif /* ESP32WIFITYPE_H_ */ 49 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFi/src/WiFiUdp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Udp.cpp: Library to send/receive UDP packets. 3 | * 4 | * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these) 5 | * 1) UDP does not guarantee the order in which assembled UDP packets are received. This 6 | * might not happen often in practice, but in larger network topologies, a UDP 7 | * packet can be received out of sequence. 8 | * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being 9 | * aware of it. Again, this may not be a concern in practice on small local networks. 10 | * For more information, see http://www.cafeaulait.org/course/week12/35.html 11 | * 12 | * MIT License: 13 | * Copyright (c) 2008 Bjoern Hartmann 14 | * Permission is hereby granted, free of charge, to any person obtaining a copy 15 | * of this software and associated documentation files (the "Software"), to deal 16 | * in the Software without restriction, including without limitation the rights 17 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18 | * copies of the Software, and to permit persons to whom the Software is 19 | * furnished to do so, subject to the following conditions: 20 | * 21 | * The above copyright notice and this permission notice shall be included in 22 | * all copies or substantial portions of the Software. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 30 | * THE SOFTWARE. 31 | * 32 | * bjoern@cs.stanford.edu 12/30/2008 33 | */ 34 | 35 | #ifndef _WIFIUDP_H_ 36 | #define _WIFIUDP_H_ 37 | 38 | #include 39 | #include 40 | #include 41 | 42 | class WiFiUDP : public UDP { 43 | private: 44 | int udp_server; 45 | IPAddress multicast_ip; 46 | IPAddress remote_ip; 47 | uint16_t server_port; 48 | uint16_t remote_port; 49 | char * tx_buffer; 50 | size_t tx_buffer_len; 51 | cbuf * rx_buffer; 52 | public: 53 | WiFiUDP(); 54 | ~WiFiUDP(); 55 | uint8_t begin(IPAddress a, uint16_t p); 56 | uint8_t begin(uint16_t p); 57 | uint8_t beginMulticast(IPAddress a, uint16_t p); 58 | void stop(); 59 | int beginMulticastPacket(); 60 | int beginPacket(); 61 | int beginPacket(IPAddress ip, uint16_t port); 62 | int beginPacket(const char *host, uint16_t port); 63 | int endPacket(); 64 | size_t write(uint8_t); 65 | size_t write(const uint8_t *buffer, size_t size); 66 | int parsePacket(); 67 | int available(); 68 | int read(); 69 | int read(unsigned char* buffer, size_t len); 70 | int read(char* buffer, size_t len); 71 | int peek(); 72 | void flush(); 73 | IPAddress remoteIP(); 74 | uint16_t remotePort(); 75 | }; 76 | 77 | #endif /* _WIFIUDP_H_ */ 78 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFiClientSecure/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For WiFi 3 | ####################################### 4 | 5 | ####################################### 6 | # Library (KEYWORD3) 7 | ####################################### 8 | 9 | WiFiClientSecure KEYWORD3 10 | 11 | ####################################### 12 | # Datatypes (KEYWORD1) 13 | ####################################### 14 | 15 | WiFiClientSecure KEYWORD1 16 | 17 | ####################################### 18 | # Methods and Functions (KEYWORD2) 19 | ####################################### 20 | 21 | connect KEYWORD2 22 | write KEYWORD2 23 | available KEYWORD2 24 | config KEYWORD2 25 | read KEYWORD2 26 | flush KEYWORD2 27 | stop KEYWORD2 28 | connected KEYWORD2 29 | setCACert KEYWORD2 30 | setCertificate KEYWORD2 31 | setPrivateKey KEYWORD2 32 | 33 | ####################################### 34 | # Constants (LITERAL1) 35 | ####################################### 36 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFiClientSecure/library.properties: -------------------------------------------------------------------------------- 1 | name=WiFiClientSecure 2 | version=1.0 3 | author=Evandro Luis Copercini 4 | maintainer=Github Community 5 | sentence=Enables secure network connection (local and Internet) using the ESP32 built-in WiFi. 6 | paragraph=With this library you can make a TLS or SSL connection to a remote server. 7 | category=Communication 8 | url= 9 | architectures=esp32 10 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFiClientSecure/src/WiFiClientSecure.h: -------------------------------------------------------------------------------- 1 | /* 2 | WiFiClientSecure.h - Base class that provides Client SSL to ESP32 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | Additions Copyright (C) 2017 Evandro Luis Copercini. 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef WiFiClientSecure_h 22 | #define WiFiClientSecure_h 23 | #include "Arduino.h" 24 | #include "IPAddress.h" 25 | #include 26 | #include "ssl_client.h" 27 | 28 | class WiFiClientSecure : public Client 29 | { 30 | protected: 31 | bool _connected; 32 | sslclient_context *sslclient; 33 | 34 | unsigned char *_CA_cert; 35 | unsigned char *_cert; 36 | unsigned char *_private_key; 37 | 38 | public: 39 | WiFiClientSecure *next; 40 | WiFiClientSecure(); 41 | WiFiClientSecure(int socket); 42 | ~WiFiClientSecure(); 43 | int connect(IPAddress ip, uint16_t port); 44 | int connect(const char *host, uint16_t port); 45 | int connect(IPAddress ip, uint16_t port, unsigned char *rootCABuff, unsigned char *cli_cert, unsigned char *cli_key); 46 | int connect(const char *host, uint16_t port, unsigned char *rootCABuff, unsigned char *cli_cert, unsigned char *cli_key); 47 | size_t write(uint8_t data); 48 | size_t write(const uint8_t *buf, size_t size); 49 | int available(); 50 | int read(); 51 | int read(uint8_t *buf, size_t size); 52 | int peek() 53 | { 54 | return 0; 55 | } 56 | void flush() {} 57 | void stop(); 58 | uint8_t connected(); 59 | 60 | void setCACert(unsigned char *rootCA); 61 | void setCertificate(unsigned char *client_ca); 62 | void setPrivateKey (unsigned char *private_key); 63 | 64 | operator bool() 65 | { 66 | return connected(); 67 | } 68 | WiFiClientSecure &operator=(const WiFiClientSecure &other); 69 | bool operator==(const bool value) 70 | { 71 | return bool() == value; 72 | } 73 | bool operator!=(const bool value) 74 | { 75 | return bool() != value; 76 | } 77 | bool operator==(const WiFiClientSecure &); 78 | bool operator!=(const WiFiClientSecure &rhs) 79 | { 80 | return !this->operator==(rhs); 81 | }; 82 | 83 | int socket() 84 | { 85 | return sslclient->socket = -1; 86 | } 87 | 88 | //friend class WiFiServer; 89 | using Print::write; 90 | }; 91 | 92 | #endif /* _WIFICLIENT_H_ */ 93 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/WiFiClientSecure/src/ssl_client.h: -------------------------------------------------------------------------------- 1 | /* Provide SSL/TLS functions to ESP32 with Arduino IDE 2 | * by Evandro Copercini - 2017 - Apache 2.0 License 3 | */ 4 | 5 | #ifndef ARD_SSL_H 6 | #define ARD_SSL_H 7 | #include "mbedtls/platform.h" 8 | #include "mbedtls/net.h" 9 | #include "mbedtls/debug.h" 10 | #include "mbedtls/ssl.h" 11 | #include "mbedtls/entropy.h" 12 | #include "mbedtls/ctr_drbg.h" 13 | #include "mbedtls/error.h" 14 | 15 | typedef struct sslclient_context { 16 | int socket; 17 | mbedtls_net_context net_ctx; 18 | mbedtls_ssl_context ssl_ctx; 19 | mbedtls_ssl_config ssl_conf; 20 | 21 | mbedtls_ctr_drbg_context drbg_ctx; 22 | mbedtls_entropy_context entropy_ctx; 23 | 24 | mbedtls_x509_crt ca_cert; 25 | mbedtls_x509_crt client_cert; 26 | mbedtls_pk_context client_key; 27 | } sslclient_context; 28 | 29 | 30 | void ssl_init(sslclient_context *ssl_client); 31 | int start_ssl_client(sslclient_context *ssl_client, uint32_t ipAddress, uint32_t port, unsigned char *rootCABuff, unsigned char *cli_cert, unsigned char *cli_key); 32 | void stop_ssl_socket(sslclient_context *ssl_client, unsigned char *rootCABuff, unsigned char *cli_cert, unsigned char *cli_key); 33 | int data_to_read(sslclient_context *ssl_client); 34 | int send_ssl_data(sslclient_context *ssl_client, const uint8_t *data, uint16_t len); 35 | int get_ssl_receive(sslclient_context *ssl_client, uint8_t *data, int length); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/Wire/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Wire 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | ####################################### 10 | # Methods and Functions (KEYWORD2) 11 | ####################################### 12 | 13 | begin KEYWORD2 14 | setClock KEYWORD2 15 | setClockStretchLimit KEYWORD2 16 | beginTransmission KEYWORD2 17 | endTransmission KEYWORD2 18 | requestFrom KEYWORD2 19 | send KEYWORD2 20 | receive KEYWORD2 21 | onReceive KEYWORD2 22 | onRequest KEYWORD2 23 | 24 | ####################################### 25 | # Instances (KEYWORD2) 26 | ####################################### 27 | 28 | Wire KEYWORD2 29 | 30 | ####################################### 31 | # Constants (LITERAL1) 32 | ####################################### 33 | 34 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/Wire/library.properties: -------------------------------------------------------------------------------- 1 | name=Wire 2 | version=1.0 3 | author=Hristo Gochkov 4 | maintainer=Hristo Gochkov 5 | sentence=Allows the communication between devices or sensors connected via Two Wire Interface Bus. For esp8266 boards. 6 | paragraph= 7 | category=Signal Input/Output 8 | url=http://arduino.cc/en/Reference/Wire 9 | architectures=esp32 10 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/libraries/Wire/src/Wire.h: -------------------------------------------------------------------------------- 1 | /* 2 | TwoWire.h - TWI/I2C library for Arduino & Wiring 3 | Copyright (c) 2006 Nicholas Zambetti. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Modified 2012 by Todd Krein (todd@krein.org) to implement repeated starts 20 | Modified December 2014 by Ivan Grokhotkov (ivan@esp8266.com) - esp8266 support 21 | Modified April 2015 by Hrsto Gochkov (ficeto@ficeto.com) - alternative esp8266 support 22 | */ 23 | 24 | #ifndef TwoWire_h 25 | #define TwoWire_h 26 | 27 | #include 28 | #include "freertos/FreeRTOS.h" 29 | #include "freertos/queue.h" 30 | #include "Stream.h" 31 | 32 | #define I2C_BUFFER_LENGTH 128 33 | 34 | class TwoWire: public Stream 35 | { 36 | protected: 37 | uint8_t num; 38 | int8_t sda; 39 | int8_t scl; 40 | i2c_t * i2c; 41 | 42 | uint8_t rxBuffer[I2C_BUFFER_LENGTH]; 43 | uint16_t rxIndex; 44 | uint16_t rxLength; 45 | 46 | uint8_t txBuffer[I2C_BUFFER_LENGTH]; 47 | uint16_t txIndex; 48 | uint16_t txLength; 49 | uint8_t txAddress; 50 | 51 | uint8_t transmitting; 52 | 53 | public: 54 | TwoWire(uint8_t bus_num); 55 | void begin(int sda=-1, int scl=-1, uint32_t frequency=100000); 56 | void setClock(uint32_t); 57 | void beginTransmission(uint8_t); 58 | void beginTransmission(int); 59 | uint8_t endTransmission(void); 60 | uint8_t endTransmission(uint8_t); 61 | size_t requestFrom(uint8_t address, size_t size, bool sendStop); 62 | 63 | uint8_t requestFrom(uint8_t, uint8_t); 64 | uint8_t requestFrom(uint8_t, uint8_t, uint8_t); 65 | uint8_t requestFrom(int, int); 66 | uint8_t requestFrom(int, int, int); 67 | 68 | size_t write(uint8_t); 69 | size_t write(const uint8_t *, size_t); 70 | int available(void); 71 | int read(void); 72 | int peek(void); 73 | void flush(void); 74 | 75 | inline size_t write(const char * s) 76 | { 77 | return write((uint8_t*) s, strlen(s)); 78 | } 79 | inline size_t write(unsigned long n) 80 | { 81 | return write((uint8_t)n); 82 | } 83 | inline size_t write(long n) 84 | { 85 | return write((uint8_t)n); 86 | } 87 | inline size_t write(unsigned int n) 88 | { 89 | return write((uint8_t)n); 90 | } 91 | inline size_t write(int n) 92 | { 93 | return write((uint8_t)n); 94 | } 95 | }; 96 | 97 | extern TwoWire Wire; 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "framework-arduinoespressif32", 3 | "description": "Arduino Wiring-based Framework (ESP32 Core)", 4 | "version": "0.0.0", 5 | "url": "https://github.com/espressif/arduino-esp32" 6 | } -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/programmers.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/darthm0e/esp32-101/9227a2fe3d7cef382d10f0a8f5112a412e416f01/ESP32-examples-Inet-heltec/programmers.txt -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/variants/WIFI_Kit_32/pins_arduino.h: -------------------------------------------------------------------------------- 1 | #ifndef Pins_Arduino_h 2 | #define Pins_Arduino_h 3 | 4 | #define EXTERNAL_NUM_INTERRUPTS 16 5 | #define NUM_DIGITAL_PINS 40 6 | #define NUM_ANALOG_INPUTS 16 7 | 8 | #define analogInputToDigitalPin(p) (((p)<20)?(esp32_adc2gpio[(p)]):-1) 9 | #define digitalPinToInterrupt(p) (((p)<40)?(p):-1) 10 | #define digitalPinHasPWM(p) (p < 34) 11 | 12 | static const uint8_t LED_BUILTIN = 2; 13 | #define BUILTIN_LED LED_BUILTIN // backward compatibility 14 | 15 | static const uint8_t KEY_BUILTIN = 0; 16 | 17 | static const uint8_t TX = 1; 18 | static const uint8_t RX = 3; 19 | 20 | static const uint8_t SDA = 21; 21 | static const uint8_t SCL = 22; 22 | 23 | static const uint8_t SS = 18; 24 | static const uint8_t MOSI = 27; 25 | static const uint8_t MISO = 19; 26 | static const uint8_t SCK = 5; 27 | 28 | static const uint8_t A0 = 36; 29 | static const uint8_t A3 = 39; 30 | static const uint8_t A4 = 32; 31 | static const uint8_t A5 = 33; 32 | static const uint8_t A6 = 34; 33 | static const uint8_t A7 = 35; 34 | static const uint8_t A10 = 4; 35 | static const uint8_t A11 = 0; 36 | static const uint8_t A12 = 2; 37 | static const uint8_t A13 = 15; 38 | static const uint8_t A14 = 13; 39 | static const uint8_t A15 = 12; 40 | static const uint8_t A16 = 14; 41 | static const uint8_t A17 = 27; 42 | static const uint8_t A18 = 25; 43 | static const uint8_t A19 = 26; 44 | 45 | static const uint8_t T0 = 4; 46 | static const uint8_t T1 = 0; 47 | static const uint8_t T2 = 2; 48 | static const uint8_t T3 = 15; 49 | static const uint8_t T4 = 13; 50 | static const uint8_t T5 = 12; 51 | static const uint8_t T6 = 14; 52 | static const uint8_t T7 = 27; 53 | static const uint8_t T8 = 33; 54 | static const uint8_t T9 = 32; 55 | 56 | static const uint8_t DAC1 = 25; 57 | static const uint8_t DAC2 = 26; 58 | 59 | #endif /* Pins_Arduino_h */ 60 | -------------------------------------------------------------------------------- /ESP32-examples-Inet-heltec/variants/WIFI_LoRa_32/pins_arduino.h: -------------------------------------------------------------------------------- 1 | #ifndef Pins_Arduino_h 2 | #define Pins_Arduino_h 3 | 4 | #define EXTERNAL_NUM_INTERRUPTS 16 5 | #define NUM_DIGITAL_PINS 40 6 | #define NUM_ANALOG_INPUTS 16 7 | 8 | #define analogInputToDigitalPin(p) (((p)<20)?(esp32_adc2gpio[(p)]):-1) 9 | #define digitalPinToInterrupt(p) (((p)<40)?(p):-1) 10 | #define digitalPinHasPWM(p) (p < 34) 11 | 12 | static const uint8_t LED_BUILTIN = 2; 13 | #define BUILTIN_LED LED_BUILTIN // backward compatibility 14 | 15 | static const uint8_t KEY_BUILTIN = 0; 16 | 17 | static const uint8_t TX = 1; 18 | static const uint8_t RX = 3; 19 | 20 | static const uint8_t SDA = 21; 21 | static const uint8_t SCL = 22; 22 | 23 | static const uint8_t SS = 18; 24 | static const uint8_t MOSI = 27; 25 | static const uint8_t MISO = 19; 26 | static const uint8_t SCK = 5; 27 | 28 | static const uint8_t A0 = 36; 29 | static const uint8_t A3 = 39; 30 | static const uint8_t A4 = 32; 31 | static const uint8_t A5 = 33; 32 | static const uint8_t A6 = 34; 33 | static const uint8_t A7 = 35; 34 | static const uint8_t A10 = 4; 35 | static const uint8_t A11 = 0; 36 | static const uint8_t A12 = 2; 37 | static const uint8_t A13 = 15; 38 | static const uint8_t A14 = 13; 39 | static const uint8_t A15 = 12; 40 | static const uint8_t A16 = 14; 41 | static const uint8_t A17 = 27; 42 | static const uint8_t A18 = 25; 43 | static const uint8_t A19 = 26; 44 | 45 | static const uint8_t T0 = 4; 46 | static const uint8_t T1 = 0; 47 | static const uint8_t T2 = 2; 48 | static const uint8_t T3 = 15; 49 | static const uint8_t T4 = 13; 50 | static const uint8_t T5 = 12; 51 | static const uint8_t T6 = 14; 52 | static const uint8_t T7 = 27; 53 | static const uint8_t T8 = 33; 54 | static const uint8_t T9 = 32; 55 | 56 | static const uint8_t DAC1 = 25; 57 | static const uint8_t DAC2 = 26; 58 | 59 | #endif /* Pins_Arduino_h */ 60 | -------------------------------------------------------------------------------- /Heltec_WIFI-LoRa-32_DiagramPinout.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/darthm0e/esp32-101/9227a2fe3d7cef382d10f0a8f5112a412e416f01/Heltec_WIFI-LoRa-32_DiagramPinout.jpg -------------------------------------------------------------------------------- /IMG_20170827_145742.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/darthm0e/esp32-101/9227a2fe3d7cef382d10f0a8f5112a412e416f01/IMG_20170827_145742.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## ESP32 101 ## 2 | Stuff i collected around for getting started with the HelTec WiFi LoRa 32 Board 3 | ##### Infos @ https://hackaday.io/project/26991-esp32-board-wifi-lora-32 ##### 4 | -------------------------------------------------------------------------------- /esp32-ble-test/esp32-ble-test.ino: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Sketch shows how to use SimpleBLE to advertise the name of the device and change it on the press of a button 16 | // Useful if you want to advertise some sort of message 17 | // Button is attached between GPIO 0 and GND, and the device name changes each time the button is pressed 18 | 19 | #include 20 | #include "SSD1306.h" 21 | 22 | #include "SimpleBLE.h" 23 | SimpleBLE ble; 24 | SSD1306 display(0x3c, 4, 15); 25 | 26 | void onButton(){ 27 | String out = "BLE32 name: "; 28 | out += String(millis() / 1000); 29 | Serial.println(out); 30 | ble.begin(out); 31 | display.clear(); 32 | display.setFont(ArialMT_Plain_16); 33 | display.drawString(5, 20, String(out)); 34 | display.display(); 35 | } 36 | 37 | void setup() { 38 | pinMode(16,OUTPUT); 39 | digitalWrite(16, LOW); // set GPIO16 low to reset OLED 40 | delay(50); 41 | digitalWrite(16, HIGH); // while OLED is running, must set GPIO16 to high 42 | 43 | Serial.begin(115200); 44 | Serial.setDebugOutput(true); 45 | pinMode(0, INPUT_PULLUP); 46 | Serial.print("ESP32 SDK: "); 47 | Serial.println(ESP.getSdkVersion()); 48 | ble.begin("ESP32 SimpleBLE"); 49 | Serial.println("Press the button to change the device's name"); 50 | display.init(); 51 | display.flipScreenVertically(); 52 | display.setTextAlignment(TEXT_ALIGN_LEFT); 53 | display.setFont(ArialMT_Plain_10); 54 | display.drawStringMaxWidth(0, 0, 128, 55 | "Press PRG Button to Change BLE Name" ); 56 | display.display(); 57 | delay(2000); 58 | } 59 | 60 | void loop() { 61 | static uint8_t lastPinState = 1; 62 | uint8_t pinState = digitalRead(0); 63 | if(!pinState && lastPinState){ 64 | onButton(); 65 | } 66 | lastPinState = pinState; 67 | while(Serial.available()) Serial.write(Serial.read()); 68 | 69 | } 70 | -------------------------------------------------------------------------------- /esp32_datasheet_en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/darthm0e/esp32-101/9227a2fe3d7cef382d10f0a8f5112a412e416f01/esp32_datasheet_en.pdf -------------------------------------------------------------------------------- /esp32_pcap_serial-edited/esp32_pcap_serial-edited.ino: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================== 3 | Copyright (c) 2017 Stefan Kremser 4 | github.com/spacehuhn 5 | =========================================== 6 | */ 7 | 8 | 9 | /* include all necessary libraries */ 10 | #include "freertos/FreeRTOS.h" 11 | #include "esp_wifi.h" 12 | #include "esp_wifi_internal.h" 13 | #include "lwip/err.h" 14 | #include "esp_system.h" 15 | #include "esp_event.h" 16 | #include "esp_event_loop.h" 17 | #include "nvs_flash.h" 18 | #include "driver/gpio.h" 19 | 20 | #include 21 | #include 22 | #include "FS.h" 23 | #include "SD.h" 24 | #include 25 | #include 26 | 27 | 28 | //===== SETTINGS =====// 29 | #define CHANNEL 1 30 | #define BAUD_RATE 921600 31 | #define CHANNEL_HOPPING true //if true it will scan on all channels 32 | #define MAX_CHANNEL 11 //(only necessary if channelHopping is true) 33 | #define HOP_INTERVAL 214 //in ms (only necessary if channelHopping is true) 34 | 35 | //===== Run-Time variables =====// 36 | PCAP pcap = PCAP(); 37 | int ch = CHANNEL; 38 | unsigned long lastChannelChange = 0; 39 | 40 | //===== FUNCTIONS =====// 41 | 42 | /* will be executed on every packet the ESP32 gets while beeing in promiscuous mode */ 43 | void sniffer(void *buf, wifi_promiscuous_pkt_type_t type){ 44 | wifi_promiscuous_pkt_t* pkt = (wifi_promiscuous_pkt_t*)buf; 45 | wifi_pkt_rx_ctrl_t ctrl = (wifi_pkt_rx_ctrl_t)pkt->rx_ctrl; 46 | 47 | uint32_t timestamp = now(); //current timestamp 48 | uint32_t microseconds = (unsigned int)(micros() - millis() * 1000); //micro seconds offset (0 - 999) 49 | 50 | pcap.newPacketSerial(timestamp, microseconds, ctrl.sig_len, pkt->payload); //send packet via Serial 51 | } 52 | 53 | esp_err_t event_handler(void *ctx, system_event_t *event){ return ESP_OK; } 54 | 55 | 56 | //===== SETUP =====// 57 | void setup() { 58 | 59 | /* start Serial */ 60 | Serial.begin(BAUD_RATE); 61 | delay(2000); 62 | Serial.println(); 63 | 64 | Serial.println("<>"); 65 | pcap.startSerial(); 66 | 67 | /* setup wifi */ 68 | nvs_flash_init(); 69 | tcpip_adapter_init(); 70 | ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) ); 71 | wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); 72 | ESP_ERROR_CHECK( esp_wifi_init(&cfg) ); 73 | ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) ); 74 | ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_AP) ); 75 | ESP_ERROR_CHECK( esp_wifi_start() ); 76 | esp_wifi_set_promiscuous(true); 77 | esp_wifi_set_promiscuous_rx_cb(sniffer); 78 | wifi_second_chan_t secondCh = (wifi_second_chan_t)NULL; 79 | esp_wifi_set_channel(ch,secondCh); 80 | } 81 | 82 | //===== LOOP =====// 83 | void loop() { 84 | 85 | /* Channel Hopping */ 86 | if(CHANNEL_HOPPING){ 87 | unsigned long currentTime = millis(); 88 | if(currentTime - lastChannelChange >= HOP_INTERVAL){ 89 | lastChannelChange = currentTime; 90 | ch++; //increase channel 91 | if(ch > MAX_CHANNEL) ch = 1; 92 | wifi_second_chan_t secondCh = (wifi_second_chan_t)NULL; 93 | esp_wifi_set_channel(ch,secondCh); 94 | } 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /hackaday.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/darthm0e/esp32-101/9227a2fe3d7cef382d10f0a8f5112a412e416f01/hackaday.png -------------------------------------------------------------------------------- /house.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/darthm0e/esp32-101/9227a2fe3d7cef382d10f0a8f5112a412e416f01/house.bmp --------------------------------------------------------------------------------