├── .gitignore ├── .vscode ├── extensions.json └── settings.json ├── LICENSE ├── README.md ├── blue.svg ├── doc ├── LILYGO_TWRPlus_Harmonics.png ├── README.md ├── TWRPlus_AudioOut_signal.png ├── TWR_audio_mic2esp.jpg ├── sigmadelta_sample_48k.jpg └── sigmadelta_sample_9k6.jpg ├── flash_16MB.csv ├── image ├── ESP32APRS_Display_Logo.png ├── ESP32APRS_Display_MenuIcon.png ├── ESP32APRS_Display_filter.png ├── ESP32APRS_Display_gpscompass.png ├── ESP32APRS_Display_gpsinfo.png ├── ESP32APRS_Display_igate.png ├── ESP32APRS_Display_infomation.png ├── ESP32APRS_Display_mnuigate.png ├── ESP32APRS_Display_position.png ├── ESP32APRS_Display_qrcode.png ├── ESP32APRS_Display_save.png ├── ESP32APRS_Display_smartbeacon.png ├── ESP32APRS_Display_station.png ├── ESP32APRS_Display_statistic.png ├── ESP32APRS_Display_systeminfo.png ├── ESP32APRS_Display_telemetry.png ├── ESP32APRS_Display_tnc2raw.png ├── ESP32APRS_Display_tracker.png ├── ESP32APRS_Display_tracker2.png ├── ESP32APRS_Display_txtracker.png ├── ESP32APRS_Mainmenu.gif ├── ESP32APRS_ScreenShort_About.png ├── ESP32APRS_ScreenShort_Digi.png ├── ESP32APRS_ScreenShort_File.png ├── ESP32APRS_ScreenShort_Igate.png ├── ESP32APRS_ScreenShort_Radio.png ├── ESP32APRS_ScreenShort_System.png ├── ESP32APRS_ScreenShort_Tracker.png ├── ESP32APRS_ScreenShort_VPN.png ├── ESP32APRS_ScreenShort_dashboard.png ├── ESP32APRS_ScreenShort_wireless.png ├── ESP32APRS_TWR_usage.png ├── ESP32S3_download_selector.png ├── ESP32S3_download_tool.png ├── TWR_harmonic_2nd.bmp └── TWR_harmonic_3nd.bmp ├── include ├── Adafruit_SSD1306.h ├── README ├── config.h ├── digirepeater.h ├── gui_lcd.h ├── igate.h ├── jquery_min_js.h ├── main.h ├── parse_aprs.h ├── pbuf.h ├── rl78.h ├── sa868.h ├── sensor.h ├── weather.h ├── webservice.h └── wireguard_vpn.h ├── lib ├── Adafruit_GFX │ ├── .gitignore │ ├── .travis.yml │ ├── Adafruit_GFX.cpp │ ├── Adafruit_GFX.h │ ├── Adafruit_SPITFT.cpp │ ├── Adafruit_SPITFT.h │ ├── Adafruit_SPITFT_Macros.h │ ├── Fonts │ │ ├── FreeMono12pt7b.h │ │ ├── FreeMono18pt7b.h │ │ ├── FreeMono24pt7b.h │ │ ├── FreeMono9pt7b.h │ │ ├── FreeMonoBold12pt7b.h │ │ ├── FreeMonoBold18pt7b.h │ │ ├── FreeMonoBold24pt7b.h │ │ ├── FreeMonoBold9pt7b.h │ │ ├── FreeMonoBoldOblique12pt7b.h │ │ ├── FreeMonoBoldOblique18pt7b.h │ │ ├── FreeMonoBoldOblique24pt7b.h │ │ ├── FreeMonoBoldOblique9pt7b.h │ │ ├── FreeMonoOblique12pt7b.h │ │ ├── FreeMonoOblique18pt7b.h │ │ ├── FreeMonoOblique24pt7b.h │ │ ├── FreeMonoOblique9pt7b.h │ │ ├── FreeSans12pt7b.h │ │ ├── FreeSans18pt7b.h │ │ ├── FreeSans24pt7b.h │ │ ├── FreeSans9pt7b.h │ │ ├── FreeSansBold12pt7b.h │ │ ├── FreeSansBold18pt7b.h │ │ ├── FreeSansBold24pt7b.h │ │ ├── FreeSansBold9pt7b.h │ │ ├── FreeSansBoldOblique12pt7b.h │ │ ├── FreeSansBoldOblique18pt7b.h │ │ ├── FreeSansBoldOblique24pt7b.h │ │ ├── FreeSansBoldOblique9pt7b.h │ │ ├── FreeSansOblique12pt7b.h │ │ ├── FreeSansOblique18pt7b.h │ │ ├── FreeSansOblique24pt7b.h │ │ ├── FreeSansOblique9pt7b.h │ │ ├── FreeSerif12pt7b.h │ │ ├── FreeSerif18pt7b.h │ │ ├── FreeSerif24pt7b.h │ │ ├── FreeSerif9pt7b.h │ │ ├── FreeSerifBold12pt7b.h │ │ ├── FreeSerifBold18pt7b.h │ │ ├── FreeSerifBold24pt7b.h │ │ ├── FreeSerifBold9pt7b.h │ │ ├── FreeSerifBoldItalic12pt7b.h │ │ ├── FreeSerifBoldItalic18pt7b.h │ │ ├── FreeSerifBoldItalic24pt7b.h │ │ ├── FreeSerifBoldItalic9pt7b.h │ │ ├── FreeSerifItalic12pt7b.h │ │ ├── FreeSerifItalic18pt7b.h │ │ ├── FreeSerifItalic24pt7b.h │ │ ├── FreeSerifItalic9pt7b.h │ │ ├── Org_01.h │ │ ├── Picopixel.h │ │ ├── Seven_Segment24pt7b.h │ │ ├── Seven_Segment28pt7b.h │ │ ├── Seven_Segment32pt7b.h │ │ ├── Seven_Segment34pt7b.h │ │ ├── Taviraj_Bold8pt7b.h │ │ ├── Tiny3x3a2pt7b.h │ │ ├── TomThumb.h │ │ └── font_taviraj_bold8.c │ ├── README.md │ ├── examples │ │ └── mock_ili9341 │ │ │ └── mock_ili9341.ino │ ├── fontconvert │ │ ├── Font Converter.url │ │ ├── Makefile │ │ ├── fontconvert.c │ │ ├── fontconvert_win.md │ │ └── makefonts.sh │ ├── gfxfont.h │ ├── glcdfont.c │ ├── library.properties │ └── license.txt ├── ESP32Ping │ ├── library.properties │ └── src │ │ ├── ESP32Ping.cpp │ │ ├── ESP32Ping.h │ │ ├── ping.cpp │ │ └── ping.h ├── ESPAsyncWebServer-esphome │ ├── .github │ │ ├── release-drafter.yml │ │ ├── scripts │ │ │ ├── install-arduino-core-esp32.sh │ │ │ ├── install-arduino-core-esp8266.sh │ │ │ ├── install-arduino-ide.sh │ │ │ ├── install-platformio.sh │ │ │ └── on-push.sh │ │ ├── stale.yml │ │ └── workflows │ │ │ ├── publish.yml │ │ │ ├── push.yml │ │ │ └── release-drafter.yml │ ├── .gitignore │ ├── .piopm │ ├── .travis.yml │ ├── CMakeLists.txt │ ├── README.md │ ├── _config.yml │ ├── component.mk │ ├── examples │ │ ├── CaptivePortal │ │ │ └── CaptivePortal.ino │ │ ├── regex_patterns │ │ │ ├── .test.build_flags │ │ │ └── regex_patterns.ino │ │ └── simple_server │ │ │ └── simple_server.ino │ ├── keywords.txt │ ├── library.json │ └── src │ │ ├── AsyncEventSource.cpp │ │ ├── AsyncEventSource.h │ │ ├── AsyncJson.h │ │ ├── AsyncWebSocket.cpp │ │ ├── AsyncWebSocket.h │ │ ├── AsyncWebSynchronization.h │ │ ├── ESPAsyncWebServer.h │ │ ├── StringArray.h │ │ ├── WebAuthentication.cpp │ │ ├── WebAuthentication.h │ │ ├── WebHandlerImpl.h │ │ ├── WebHandlers.cpp │ │ ├── WebRequest.cpp │ │ ├── WebResponseImpl.h │ │ ├── WebResponses.cpp │ │ └── WebServer.cpp ├── LibAPRS_ESP32S3 │ ├── AFSK.cpp │ ├── AFSK.h │ ├── AX25.cpp │ ├── AX25.h │ ├── CRC-CCIT.c │ ├── CRC-CCIT.h │ ├── HDLC.h │ ├── KISS.cpp │ ├── KISS.h │ ├── LibAPRS.cpp │ ├── LibAPRSesp.h │ ├── fx25.cpp │ ├── fx25.h │ ├── gpio.h │ ├── modem.cpp │ └── modem.h ├── LittleFS_esp32 │ ├── .piopm │ ├── LICENSE │ ├── README.md │ ├── examples │ │ ├── LITTLEFS_PlatformIO │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── data │ │ │ │ ├── file1.txt │ │ │ │ └── testfolder │ │ │ │ │ └── test2.txt │ │ │ ├── include │ │ │ │ └── .placeholder.txt │ │ │ ├── lib │ │ │ │ └── .placeholder.txt │ │ │ ├── littlefsbuilder.py │ │ │ ├── partitions_custom.csv │ │ │ ├── platformio.ini │ │ │ └── src │ │ │ │ └── main.cpp │ │ ├── LITTLEFS_test │ │ │ ├── LittleFS_test.ino │ │ │ └── partitions.csv │ │ └── LITTLEFS_time │ │ │ └── LITTLEFS_time.ino │ ├── library.json │ ├── library.properties │ └── src │ │ ├── LICENSE │ │ ├── LICENSE.md │ │ ├── LITTLEFS.cpp │ │ ├── LITTLEFS.h │ │ ├── esp_littlefs.c │ │ ├── esp_littlefs.h │ │ ├── lfs.c │ │ ├── lfs.h │ │ ├── lfs_util.c │ │ ├── lfs_util.h │ │ ├── littlefs_api.c │ │ └── littlefs_api.h ├── MenuSystem │ ├── .gitignore │ ├── LICENSE │ ├── MenuSystem.cpp │ ├── MenuSystem.h │ ├── README.md │ ├── examples │ │ ├── current_item │ │ │ ├── Makefile │ │ │ └── current_item.ino │ │ ├── current_menu │ │ │ ├── Makefile │ │ │ └── current_menu.ino │ │ ├── lcd_nav │ │ │ ├── Makefile │ │ │ └── lcd_nav.ino │ │ ├── led_matrix │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ └── led_matrix.ino │ │ ├── led_matrix_animated │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ └── led_matrix_animated.ino │ │ ├── pcd8544_nav │ │ │ ├── Makefile │ │ │ └── pcd8544_nav.ino │ │ └── serial_nav │ │ │ ├── CustomNumericMenuItem.cpp │ │ │ ├── CustomNumericMenuItem.h │ │ │ ├── Makefile │ │ │ ├── MyRenderer.cpp │ │ │ ├── MyRenderer.h │ │ │ └── serial_nav.ino │ ├── keywords.txt │ └── library.json ├── OneWire │ ├── .piopm │ ├── OneWire.cpp │ ├── OneWire.h │ ├── examples │ │ ├── DS18x20_Temperature │ │ │ └── DS18x20_Temperature.ino │ │ ├── DS2408_Switch │ │ │ └── DS2408_Switch.ino │ │ └── DS250x_PROM │ │ │ └── DS250x_PROM.ino │ ├── keywords.txt │ ├── library.json │ ├── library.properties │ └── util │ │ ├── OneWire_direct_gpio.h │ │ └── OneWire_direct_regtype.h ├── Queue │ ├── library.properties │ └── src │ │ ├── cppQueue.cpp │ │ └── cppQueue.h ├── README ├── TimeLib.cpp ├── TimeLib.h ├── TimeLib │ ├── TimeLib.cpp │ └── TimeLib.h └── lwfec │ ├── LICENSE │ ├── README.md │ ├── gf.cpp │ ├── gf.h │ ├── rs.cpp │ └── rs.h ├── lilygo-t-twr.json ├── partitions.csv ├── platformio.ini └── src ├── Adafruit_SSD1306.cpp ├── config.cpp ├── digirepeater.cpp ├── gui_lcd.cpp ├── igate.cpp ├── main.cpp ├── parse_aprs.cpp ├── rl78.cpp ├── sa868.cpp ├── sensor.cpp ├── weather.cpp ├── webservice.cpp └── wireguard_vpn.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | .vscode/.browse.c_cpp.db* 3 | .vscode/c_cpp_properties.json 4 | .vscode/launch.json 5 | .vscode/ipch 6 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 3 | // for the documentation about the extensions.json format 4 | "recommendations": [ 5 | "platformio.platformio-ide" 6 | ], 7 | "unwantedRecommendations": [ 8 | "ms-vscode.cpptools-extension-pack" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "*.tpp": "cpp", 4 | "functional": "cpp", 5 | "tuple": "cpp", 6 | "string_view": "cpp", 7 | "regex": "cpp", 8 | "format": "cpp", 9 | "array": "cpp", 10 | "atomic": "cpp", 11 | "bit": "cpp", 12 | "*.tcc": "cpp", 13 | "bitset": "cpp", 14 | "cctype": "cpp", 15 | "charconv": "cpp", 16 | "chrono": "cpp", 17 | "clocale": "cpp", 18 | "cmath": "cpp", 19 | "compare": "cpp", 20 | "concepts": "cpp", 21 | "condition_variable": "cpp", 22 | "cstdarg": "cpp", 23 | "cstddef": "cpp", 24 | "cstdint": "cpp", 25 | "cstdio": "cpp", 26 | "cstdlib": "cpp", 27 | "cstring": "cpp", 28 | "ctime": "cpp", 29 | "cwchar": "cpp", 30 | "cwctype": "cpp", 31 | "deque": "cpp", 32 | "list": "cpp", 33 | "map": "cpp", 34 | "set": "cpp", 35 | "string": "cpp", 36 | "unordered_map": "cpp", 37 | "unordered_set": "cpp", 38 | "vector": "cpp", 39 | "exception": "cpp", 40 | "algorithm": "cpp", 41 | "iterator": "cpp", 42 | "memory": "cpp", 43 | "memory_resource": "cpp", 44 | "netfwd": "cpp", 45 | "numeric": "cpp", 46 | "optional": "cpp", 47 | "random": "cpp", 48 | "ratio": "cpp", 49 | "system_error": "cpp", 50 | "type_traits": "cpp", 51 | "utility": "cpp", 52 | "initializer_list": "cpp", 53 | "iomanip": "cpp", 54 | "iosfwd": "cpp", 55 | "iostream": "cpp", 56 | "istream": "cpp", 57 | "limits": "cpp", 58 | "mutex": "cpp", 59 | "new": "cpp", 60 | "numbers": "cpp", 61 | "ostream": "cpp", 62 | "semaphore": "cpp", 63 | "span": "cpp", 64 | "sstream": "cpp", 65 | "stdexcept": "cpp", 66 | "stop_token": "cpp", 67 | "streambuf": "cpp", 68 | "thread": "cpp", 69 | "cinttypes": "cpp", 70 | "typeinfo": "cpp", 71 | "variant": "cpp", 72 | "config.h": "c" 73 | }, 74 | "C_Cpp.errorSquiggles": "disabled" 75 | } -------------------------------------------------------------------------------- /doc/LILYGO_TWRPlus_Harmonics.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/doc/LILYGO_TWRPlus_Harmonics.png -------------------------------------------------------------------------------- /doc/README.md: -------------------------------------------------------------------------------- 1 | # ESP32-S3 howto ADC and DAC 2 | 3 | The ESP32-S3 version has no DAC and no internal I2S.Therefore, another method must be used. 4 | 5 | **ADC** Can use the operating mode of adc continue to DMA. \ 6 | The SA868 Module provides output signals at voltage levels <2Vp-p,it can use adc attention 11db no modifications hardware required. 7 | 8 | ## From the example in the picture 9 | ![TWR_AUDIO2ESP](TWRPlus_AudioOut_signal.png) 10 | 11 | **DAC** Can use the operating mode of sigmadelta. \ 12 | Use the pulse width to determine the voltage level through the LPF generate signals, similar to PWM. 13 | 14 | ## Example AFSK signal sample 9600Hz in the picture 15 | ![sigmadelta_9600sample](sigmadelta_sample_9k6.jpg) 16 | 17 | ## Example AFSK signal sample 48,000Hz in the picture 18 | ![sigmadelta_48ksample](sigmadelta_sample_48k.jpg) 19 | 20 | ## Measuring point of signal 21 | ![TWR_MIC2ESP](TWR_audio_mic2esp.jpg) 22 | 23 | # LILYGO T-TWR Plus most harmonic on RF 24 | 25 | If you want to use it at a large station for igate/digi mode,Should be connected through a band pass filter(BPF). 26 | 27 | ![TWR_Harmonic](LILYGO_TWRPlus_Harmonics.png) -------------------------------------------------------------------------------- /doc/TWRPlus_AudioOut_signal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/doc/TWRPlus_AudioOut_signal.png -------------------------------------------------------------------------------- /doc/TWR_audio_mic2esp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/doc/TWR_audio_mic2esp.jpg -------------------------------------------------------------------------------- /doc/sigmadelta_sample_48k.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/doc/sigmadelta_sample_48k.jpg -------------------------------------------------------------------------------- /doc/sigmadelta_sample_9k6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/doc/sigmadelta_sample_9k6.jpg -------------------------------------------------------------------------------- /flash_16MB.csv: -------------------------------------------------------------------------------- 1 | # Name, Type, SubType, Offset, Size, Flags 2 | nvs, data, nvs, 0x9000, 0x5000, 3 | otadata, data, ota, 0xe000, 0x2000, 4 | app0, app, ota_0, 0x10000, 0x1E0000, 5 | app1, app, ota_1, 0x1F0000,0x1E0000, 6 | spiffs, data, spiffs, 0x3D0000,0xC20000, 7 | coredump, data, coredump,0xFF0000,0x10000, -------------------------------------------------------------------------------- /image/ESP32APRS_Display_Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_Display_Logo.png -------------------------------------------------------------------------------- /image/ESP32APRS_Display_MenuIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_Display_MenuIcon.png -------------------------------------------------------------------------------- /image/ESP32APRS_Display_filter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_Display_filter.png -------------------------------------------------------------------------------- /image/ESP32APRS_Display_gpscompass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_Display_gpscompass.png -------------------------------------------------------------------------------- /image/ESP32APRS_Display_gpsinfo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_Display_gpsinfo.png -------------------------------------------------------------------------------- /image/ESP32APRS_Display_igate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_Display_igate.png -------------------------------------------------------------------------------- /image/ESP32APRS_Display_infomation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_Display_infomation.png -------------------------------------------------------------------------------- /image/ESP32APRS_Display_mnuigate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_Display_mnuigate.png -------------------------------------------------------------------------------- /image/ESP32APRS_Display_position.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_Display_position.png -------------------------------------------------------------------------------- /image/ESP32APRS_Display_qrcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_Display_qrcode.png -------------------------------------------------------------------------------- /image/ESP32APRS_Display_save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_Display_save.png -------------------------------------------------------------------------------- /image/ESP32APRS_Display_smartbeacon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_Display_smartbeacon.png -------------------------------------------------------------------------------- /image/ESP32APRS_Display_station.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_Display_station.png -------------------------------------------------------------------------------- /image/ESP32APRS_Display_statistic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_Display_statistic.png -------------------------------------------------------------------------------- /image/ESP32APRS_Display_systeminfo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_Display_systeminfo.png -------------------------------------------------------------------------------- /image/ESP32APRS_Display_telemetry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_Display_telemetry.png -------------------------------------------------------------------------------- /image/ESP32APRS_Display_tnc2raw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_Display_tnc2raw.png -------------------------------------------------------------------------------- /image/ESP32APRS_Display_tracker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_Display_tracker.png -------------------------------------------------------------------------------- /image/ESP32APRS_Display_tracker2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_Display_tracker2.png -------------------------------------------------------------------------------- /image/ESP32APRS_Display_txtracker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_Display_txtracker.png -------------------------------------------------------------------------------- /image/ESP32APRS_Mainmenu.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_Mainmenu.gif -------------------------------------------------------------------------------- /image/ESP32APRS_ScreenShort_About.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_ScreenShort_About.png -------------------------------------------------------------------------------- /image/ESP32APRS_ScreenShort_Digi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_ScreenShort_Digi.png -------------------------------------------------------------------------------- /image/ESP32APRS_ScreenShort_File.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_ScreenShort_File.png -------------------------------------------------------------------------------- /image/ESP32APRS_ScreenShort_Igate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_ScreenShort_Igate.png -------------------------------------------------------------------------------- /image/ESP32APRS_ScreenShort_Radio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_ScreenShort_Radio.png -------------------------------------------------------------------------------- /image/ESP32APRS_ScreenShort_System.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_ScreenShort_System.png -------------------------------------------------------------------------------- /image/ESP32APRS_ScreenShort_Tracker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_ScreenShort_Tracker.png -------------------------------------------------------------------------------- /image/ESP32APRS_ScreenShort_VPN.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_ScreenShort_VPN.png -------------------------------------------------------------------------------- /image/ESP32APRS_ScreenShort_dashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_ScreenShort_dashboard.png -------------------------------------------------------------------------------- /image/ESP32APRS_ScreenShort_wireless.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_ScreenShort_wireless.png -------------------------------------------------------------------------------- /image/ESP32APRS_TWR_usage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32APRS_TWR_usage.png -------------------------------------------------------------------------------- /image/ESP32S3_download_selector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32S3_download_selector.png -------------------------------------------------------------------------------- /image/ESP32S3_download_tool.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/ESP32S3_download_tool.png -------------------------------------------------------------------------------- /image/TWR_harmonic_2nd.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/TWR_harmonic_2nd.bmp -------------------------------------------------------------------------------- /image/TWR_harmonic_3nd.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/image/TWR_harmonic_3nd.bmp -------------------------------------------------------------------------------- /include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /include/digirepeater.h: -------------------------------------------------------------------------------- 1 | #ifndef DIGIREPEATER_H 2 | #define DIGIREPEATER_H 3 | 4 | #include 5 | 6 | int digiProcess(AX25Msg &Packet); 7 | 8 | #endif -------------------------------------------------------------------------------- /include/igate.h: -------------------------------------------------------------------------------- 1 | #ifndef IGATE_H 2 | #define IGATE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "main.h" 8 | 9 | int igateProcess(AX25Msg &Packet); 10 | 11 | #endif -------------------------------------------------------------------------------- /include/sa868.h: -------------------------------------------------------------------------------- 1 | #ifndef SA_868_H 2 | #define SA_868_H 3 | 4 | #include 5 | 6 | enum class SA868_Mode: uint8_t 7 | { 8 | OFF = 0, 9 | RX, 10 | TX 11 | }; 12 | 13 | typedef struct SA868_Config_Struct 14 | { 15 | uint32_t freq_rx; 16 | uint32_t freq_tx; 17 | int tone_rx; 18 | int tone_tx; 19 | uint8_t band; 20 | uint8_t sql_level; 21 | bool rf_power; 22 | uint8_t volume; 23 | uint8_t mic; 24 | SA868_Mode mode; 25 | } SA868_Configuration; 26 | 27 | typedef struct SA868_Version_Struct 28 | { 29 | uint8_t major; 30 | uint8_t minor; 31 | uint8_t patch; 32 | uint8_t revision; 33 | } SA868_Version; 34 | 35 | bool SA868_WaitResponse(HardwareSerial * SerialRF, const char * cmd, String * result); 36 | 37 | class SA868 38 | { 39 | public: 40 | SA868(HardwareSerial * SerialRF, uint8_t RX_PIN, uint8_t TX_PIN); 41 | bool init(); 42 | SA868_Version Version(); 43 | int16_t getRSSI(); 44 | void RxOn(); 45 | void TxOn(); 46 | void TxOff(); 47 | void setAudio(bool value); 48 | void setTxFrequency(uint32_t freq); 49 | void setRxFrequency(uint32_t freq); 50 | void setTxTone(uint32_t tone); 51 | void setRxTone(uint32_t tone); 52 | void setVolume(uint8_t value); 53 | void setBandwidth(uint8_t value); 54 | void setSqlThresh(uint8_t value); 55 | SA868_Configuration settings(); 56 | bool isHighPower(); 57 | void setHighPower(); 58 | void setLowPower(); 59 | private: 60 | HardwareSerial * _SerialRF; 61 | SA868_Configuration _config; 62 | uint8_t _RX_PIN; 63 | uint8_t _TX_PIN; 64 | void setFrequency(uint32_t freq); 65 | void updateBandwidth(); 66 | void setSqlThresh(); 67 | void setPower(); 68 | }; 69 | #endif 70 | -------------------------------------------------------------------------------- /include/sensor.h: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | #ifndef SENSOR_H 4 | #define SENSOR_H 5 | 6 | #define SENSOR_NUMBER 10 7 | #define SENSOR_NONE 0 8 | //Module 9 | // #define SENSOR_BAT 1 10 | // #define SENSOR_NTC 2 11 | // #define SENSOR_DS18B20 3 12 | // #define SENSOR_BME280 4 13 | // #define SENSOR_M701 5 14 | // #define SENSOR_M702 6 15 | //Node 16 | #define SENSOR_CO2 1 17 | #define SENSOR_CH2O 2 18 | #define SENSOR_TVOC 3 19 | #define SENSOR_PM25 4 20 | #define SENSOR_PM100 5 21 | #define SENSOR_TEMPERATURE 6 22 | #define SENSOR_HUMIDITY 7 23 | #define SENSOR_PRESSURE 8 24 | #define SENSOR_WIND_SPD 9 25 | #define SENSOR_WIND_DIR 10 26 | #define SENSOR_RAIN 11 27 | #define SENSOR_LUMINOSITY 12 28 | #define SENSOR_SOIL_TEMPERATURE 13 29 | #define SENSOR_SOIL_MOISTURE 14 30 | #define SENSOR_WATER_TEMPERATURE 15 31 | #define SENSOR_WATER_TDS 16 32 | #define SENSOR_WATER_LEVEL 17 33 | #define SENSOR_WATER_FLOW 18 34 | #define SENSOR_VOLTAGE 19 35 | #define SENSOR_CURRENT 20 36 | #define SENSOR_POWER 21 37 | #define SENSOR_ENERGY 22 38 | #define SENSOR_FREQ 23 39 | #define SENSOR_PF 24 40 | #define SENSOR_SAT_NUM 25 41 | #define SENSOR_SAT_HDOP 26 42 | #define SENSOR_BAT_VOLTAGE 27 43 | #define SENSOR_BAT_PERCENT 28 44 | 45 | 46 | #define PORT_UART0 0 47 | #define PORT_UART1 1 48 | #define PORT_ADC 2 49 | #define PORT_I2C0 3 50 | #define PORT_I2C1 4 51 | #define PORT_CNT_0 5 52 | #define PORT_CNT_1 6 53 | #define PORT_LOGIC 7 54 | #define PORT_M701 8 55 | #define PORT_M702 9 56 | #define PORT_BME280_I2C0 10 57 | #define PORT_BME280_I2C1 11 58 | #define PORT_BMP280_I2C0 12 59 | #define PORT_BMP280_I2C1 13 60 | #define PORT_SI7021_I2C0 14 61 | #define PORT_SI7021_I2C1 15 62 | #define PORT_CCS811_I2C0 16 63 | #define PORT_CCS811_I2C1 17 64 | #define PORT_SAT_NUM 18 65 | #define PORT_SAT_HDOP 19 66 | #define PORT_SHT_I2C0 20 67 | #define PORT_SHT_I2C1 21 68 | #define PORT_BATTERY 22 69 | #define PORT_PZEM 23 70 | #define PORT_MODBUS_16 24 71 | #define PORT_MODBUS_32 25 72 | #define PORT_DS1820 26 73 | 74 | #define SENSOR_PORT_NUM 27 75 | const char SENSOR_PORT[SENSOR_PORT_NUM][15] = {"UART0_CSV", "UART1_CSV", "ADC", "I2C_0","I2C_1","COUNTER_0","COUNTER_1","LOGIC","M701_Modbus","M702_Modbus","BME280_I2C0","BME280_I2C1","BMP280_I2C0","BMP280_I2C1","SI7021_I2C0","SI7021_I2C1","CCS811_I2C0","CCS811_I2C1","GNSS_NUM","GNSS_HDOP","SHTxx_I2C0","SHTxx_I2C1","SYS_BAT","PZEM","MODBUS_16Bit","MODBUS_32Bit","DS1820_1Wire"}; 76 | 77 | #define SENSOR_NAME_NUM 29 78 | const char SENSOR_NAME[29][20] = {"NONE", "CO2", "CH2O", "TVOC","PM2.5","PM10","TEMPERATURE","HUMIDITY","PRESSURE","WIND_SPD","WIND_DIR","RAIN","LUMINOSITY","SOIL_TEMP","SOIL_HUM","WATER_TEMP","WATER_TDS","WATER_LEVEL","WATER_FLOW","VOLTAGE","CURRENT","POWER","ENERGY","FREQ","PF","SAT_NUM","SAT_HDOP","BATTERY_VOLT","BATTERY_PERCENT"}; 79 | 80 | 81 | typedef struct SensorInfo_Struct 82 | { 83 | bool enable; 84 | uint16_t type; // Type of sensor 85 | uint8_t port; // Port or Channel of Sensor 86 | uint16_t address; // Address registor 87 | uint16_t samplerate; // Sample rate Sec. 88 | uint16_t averagerate; // Average rate Sec. 89 | float eqns[3]; // Equation av^2+bv+c 90 | char unit[10]; // Unit text of sensor 91 | char parm[15]; // Parameter/name text of sensor 92 | } SensorInfo; 93 | 94 | typedef struct SensorData_Struct 95 | { 96 | bool visable; 97 | double sample; //Value of sample 98 | double average; //Value of average 99 | double sum; 100 | uint16_t counter; 101 | unsigned long int timeSample; 102 | unsigned long int timeAvg; 103 | unsigned long int timeTick; 104 | } SensorData; 105 | 106 | void dispSensor(); 107 | void dispSensor(int i); 108 | void taskSensor(void *pvParameters); 109 | void sensorInit(bool resetAll); 110 | #endif -------------------------------------------------------------------------------- /include/weather.h: -------------------------------------------------------------------------------- 1 | /* 2 | Name: ESP32APRS T-TWR Plus 3 | Created: 13-10-2023 14:27:23 4 | Author: HS5TQA/Atten 5 | Github: https://github.com/nakhonthai 6 | Facebook: https://www.facebook.com/atten 7 | Support IS: host:aprs.dprns.com port:14580 or aprs.hs5tqa.ampr.org:14580 8 | Support IS monitor: http://aprs.dprns.com:14501 or http://aprs.hs5tqa.ampr.org:14501 9 | */ 10 | 11 | #ifndef WEATHER_H 12 | #define WEATHER_H 13 | 14 | #include "main.h" 15 | #include "sensor.h" 16 | //#include 17 | 18 | //Format: c...s...g...t...r...p...P...h..b.....L...S...m...M...w...W....v...d...D...x....F....T....u..n... 19 | //#define WX_SENSOR_NUM 23 20 | 21 | #define WX_NONE 0 22 | #define WX_WIND_DIR (1 << 0) // c Wind Direction (in degrees) 23 | #define WX_WIND_SPD (1 << 1) // s Wind Speed (mhp) 24 | #define WX_WIND_GUST (1 << 2) // g Wind Gust (peak wind speed in mph in the last 5 minutes) 25 | #define WX_TEMP (1 << 3) // t Temperature (Fahenheit) 26 | #define WX_RAIN (1 << 4) // r Rain collector (in hundredths of an inch) last hour 27 | #define WX_RAIN24HR (1 << 5) // p Rain collector (in hundredths of an inch) Last 24 Hr 28 | #define WX_RAIN_GMT (1 << 6) // P Rain collector (in hundredths of an inch) Sine Midnight (GMT+0) 29 | #define WX_HUMIDITY (1 << 7) // h Humidity 30 | #define WX_BARO (1 << 8) // b Barometric Pressure (in thenths of millibars/tenths of hPascal) 31 | #define WX_LUMINOSITY (1 << 9) // L,l Luminosity (in watts per square meter) L=0-999,l=1000-1999 32 | #define WX_SNOW (1 << 10) // S Snowfall (in inches) in the last 24 hours 33 | #define WX_SOIL_TEMP (1 << 11) // m Soil temperature (Fahenheit) 34 | #define WX_SOIL_MOISTURE (1 << 12) // M Soil Moisture (0-40%VWC) 35 | #define WX_WATER_TEMP (1 << 13) // w Water (Fahenheit) 36 | #define WX_WATER_TDS (1 << 14) // W Water TDS(Total Dissolved Solids) 0-1000ppm 37 | #define WX_WATER_LEVEL (1 << 15) // v Water Level (in hundredths of an inch) 38 | #define WX_PM25 (1 << 16) // d Dust PM 2.5 0~1000μg/m³ 39 | #define WX_PM100 (1 << 17) // D Dust PM 10 ,0~1000μg/m³ 40 | #define WX_CO2 (1 << 18) // X,x Co2 (PPM) x=0-9999,X=10-99990(x10) 41 | #define WX_CH2O (1<<19) //F,f Formaldehyde(CH2O) F=0-9999,f,1000-2000 μg/m³ 42 | #define WX_TVOC (1<<20) // T 43 | #define WX_UV (1<<21) //UV Index 44 | #define WX_SOUND (1<<22) //n noise of sound Level dB 45 | 46 | typedef struct Weather_Struct 47 | { 48 | unsigned long int timeStamp; 49 | uint16_t winddirection; // Wind Direction (in degrees) 50 | uint32_t visable; 51 | float windspeed; // Wind Speed (kph) 52 | float windgust; // Wind Gust (peak wind speed in kph in the last 5 minutes) 53 | float temperature; // Temperature (Celsius) 54 | float rain; // Rain collector (in mm.) last hour 55 | float rain24hr; // Rain collector (in mm.) Last 24 Hr 56 | float rainmidnight; // Rain collector (in mm.) Sine Midnight (GMT+0) 57 | float humidity; // Humidity 0-100%RH 58 | float barometric; // Barometric Pressure (in thenths of millibars/tenths of hPascal) 59 | uint16_t solar; // Solar radiation/Luminosity (in watts per square meter) L=0-999,l=1000-9999 60 | uint16_t snow; // Snowfall (in mm.) in the last 24 hours 61 | float soil_temp; // Soil Temperature (Celsius) 62 | float soil_moisture; // Soil Moisture (0-40%VWC) 63 | float water_temp; // Water Temperature (Celsius) 64 | uint16_t water_tds; // Water TDS(Total Dissolved Solids) 0-1000ppm 65 | uint16_t water_level; // Water Level (in mm.) 66 | uint16_t pm25; // Ordure PM 2.5 (0~1000μg/m³) 67 | uint16_t pm100; // Ordure PM 10 (0~1000μg/m³) 68 | uint32_t co2; // Co2 (ppm) 69 | uint16_t ch2o; // F,f Formaldehyde(CH2O) F=0-9999,f,1000-2000 μg/m³ 70 | uint16_t tvoc; // (0~2000μg/m³) 71 | uint8_t uv; // UV index 1-11 72 | float sound; // Sound Level dB 73 | float vbat; // Battery Voltage (V) 74 | float vsolar; // Solar cell Voltage (V) 75 | float ibat; // Battery Current (A) 76 | uint8_t pbat; // Battery Percent (0-100%) 77 | } WeatherData; 78 | 79 | extern WeatherData weather; 80 | extern float mslAltitude; 81 | 82 | int getRawWx(char *strData); 83 | bool getCSV2Wx(String stream); 84 | void getSensor(uint32_t type, float *val, int i); 85 | void getSensor(uint32_t type, uint16_t *val, int i); 86 | void getSensor(uint32_t type, uint32_t *val, int i); 87 | // bool getM70xModbus(ModbusMaster &node); 88 | // bool getM70xModbus(ModbusMaster &node, uint32_t sensor); 89 | 90 | #endif -------------------------------------------------------------------------------- /include/webservice.h: -------------------------------------------------------------------------------- 1 | /* 2 | Name: ESP32APRS T-TWR Plus 3 | Created: 13-10-2023 14:27:23 4 | Author: HS5TQA/Atten 5 | Github: https://github.com/nakhonthai 6 | Facebook: https://www.facebook.com/atten 7 | Support IS: host:aprs.dprns.com port:14580 or aprs.hs5tqa.ampr.org:14580 8 | Support IS monitor: http://aprs.dprns.com:14501 or http://aprs.hs5tqa.ampr.org:14501 9 | */ 10 | 11 | #include "main.h" 12 | #ifndef WEBSERVICE_H 13 | #define WEBSERVICE_H 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include "LITTLEFS.h" 24 | 25 | typedef struct timeZoneName 26 | { 27 | float tz; 28 | const char *name; 29 | }timeZoneName; 30 | 31 | const timeZoneName tzList[40] PROGMEM= { 32 | {-12.00, "(GMT -12:00) Eniwetok, Kwajalein"}, 33 | {-11.00, "(GMT -11:00) Midway Island, Samoa"}, 34 | {-10.00, "(GMT -10:00) Hawaii"}, 35 | {-09.50, "(GMT -9:30) Taiohae"}, 36 | {-09.00, "(GMT -9:00) Alaska"}, 37 | {-08.00, "(GMT -8:00) Pacific Time (US & Canada)"}, 38 | {-07.00, "(GMT -7:00) Mountain Time (US & Canada)"}, 39 | {-06.00, "(GMT -6:00) Central Time (US & Canada), Mexico City"}, 40 | {-05.00, "(GMT -5:00) Eastern Time (US & Canada), Bogota, Lima"}, 41 | {-04.50, "(GMT -4:30) Caracas"}, 42 | {-04.00, "(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz"}, 43 | {-03.50, "(GMT -3:30) Newfoundland"}, 44 | {-03.00, "(GMT -3:00) Brazil, Buenos Aires, Georgetown"}, 45 | {-02.00, "(GMT -2:00) Mid-Atlantic"}, 46 | {-01.00, "(GMT -1:00) Azores, Cape Verde Islands"}, 47 | {+00.00, "(GMT) Western Europe Time, London, Lisbon, Casablanca"}, 48 | {+01.00, "(GMT +1:00) Brussels, Copenhagen, Madrid, Paris"}, 49 | {+02.00, "(GMT +2:00) Kaliningrad, South Africa"}, 50 | {+03.00, "(GMT +3:00) Baghdad, Riyadh, Moscow, St. Petersburg"}, 51 | {+03.50, "(GMT +3:30) Tehran"}, 52 | {+04.00, "(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi"}, 53 | {+04.50, "(GMT +4:30) Kabul"}, 54 | {+05.00, "(GMT +5:00) Ekaterinburg, Islamabad, Karachi, Tashkent"}, 55 | {+05.50, "(GMT +5:30) Bombay, Calcutta, Madras, New Delhi"}, 56 | {+05.75, "(GMT +5:45) Kathmandu, Pokhara"}, 57 | {+06.00, "(GMT +6:00) Almaty, Dhaka, Colombo"}, 58 | {+06.50, "(GMT +6:30) Yangon, Mandalay"}, 59 | {+07.00, "(GMT +7:00) Bangkok, Hanoi, Jakarta"}, 60 | {+08.00, "(GMT +8:00) Beijing, Perth, Singapore, Hong Kong"}, 61 | {+08.75, "(GMT +8:45) Eucla"}, 62 | {+09.00, "(GMT +9:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk"}, 63 | {+09.50, "(GMT +9:30) Adelaide, Darwin"}, 64 | {+10.00, "(GMT +10:00) Eastern Australia, Guam, Vladivostok"}, 65 | {+10.50, "(GMT +10:30) Lord Howe Island"}, 66 | {+11.00, "(GMT +11:00) Magadan, Solomon Islands, New Caledonia"}, 67 | {+11.50, "(GMT +11:30) Norfolk Island"}, 68 | {+12.00, "(GMT +12:00) Auckland, Wellington, Fiji, Kamchatka"}, 69 | {+12.75, "(GMT +12:45) Chatham Islands"}, 70 | {+13.00, "(GMT +13:00) Apia, Nukualofa"}, 71 | {+14.00, "(GMT +14:00) Line Islands, Tokelau"}, 72 | }; 73 | 74 | const char ADC_ATTEN[5][19] = {"0dB (100-950mV)", "2.5dB (100-1250mV)", "6dB (150-1750mV)", "11dB (150-2450mV)", "12dB (150-3300mV)"}; 75 | 76 | #define SYSTEM_LEN 6 77 | #define SYSTEM_BIT_LEN 9 78 | #define PATH_LEN 17 79 | const char SYSTEM_NAME[SYSTEM_LEN][20] = {"NONE", "All Count", "RF2INET", "INET2RF","DIGI","All Drop"}; 80 | const char SYSTEM_BITS_NAME[9][20] = {"NONE", "IGATE Mode", "DIGI Mode", "WEATHER Mode","SAT Status","INET Status","VPN Status","GSM Status","FX.25"}; 81 | const char PATH_NAME[PATH_LEN][15] = {"OFF", "DST-TRACE 1", "DST-TRACE 2", "DST-TRACE 3", "DST-TRACE 4", "TRACE1-1", "TRACE2-2", "TRACE3-3", "WIDE1-1","RFONLY","RELAY","GATE","ECHO","UserDefine 1","UserDefine 2","UserDefine 3","UserDefine 4"}; 82 | 83 | 84 | // ใช้ตัวแปรโกลบอลในไฟล์ main.cpp 85 | extern statusType status; 86 | extern digiTLMType digiTLM; 87 | extern Configuration config; 88 | extern TaskHandle_t taskNetworkHandle; 89 | extern TaskHandle_t taskAPRSHandle; 90 | extern TaskHandle_t taskAPRSPollHandle; 91 | extern TaskHandle_t taskSerialHandle; 92 | extern TaskHandle_t taskGPSHandle; 93 | extern TaskHandle_t taskSensorHandle; 94 | extern time_t systemUptime; 95 | extern String RF_VERSION; 96 | extern pkgListType *pkgList; 97 | extern TinyGPSPlus gps; 98 | extern float vbat; 99 | extern WiFiClient aprsClient; 100 | extern bool initInterval; 101 | extern bool webServiceBegin; 102 | extern fs::LITTLEFSFS LITTLEFS; 103 | extern double VBat; 104 | extern double TempNTC; 105 | extern bool lastHeard_Flag; 106 | extern SensorData sen[SENSOR_NUMBER]; 107 | extern uint16_t TLM_SEQ; 108 | extern uint16_t IGATE_TLM_SEQ; 109 | extern uint16_t DIGI_TLM_SEQ; 110 | extern unsigned int StandByTick; 111 | 112 | #ifdef __cplusplus 113 | extern "C" 114 | { 115 | #endif 116 | uint8_t temprature_sens_read(); 117 | #ifdef __cplusplus 118 | } 119 | #endif 120 | uint8_t temprature_sens_read(); 121 | 122 | void serviceHandle(); 123 | void setHTML(byte page); 124 | void handle_root(); 125 | void handle_setting(); 126 | void handle_service(); 127 | void handle_system(); 128 | void handle_firmware(); 129 | void handle_default(); 130 | void webService(); 131 | void handle_radio(); 132 | extern void RF_MODULE(bool boot); 133 | void handle_ws(String Raw,uint16_t mVrms); 134 | void handle_ws_gnss(char *nmea); 135 | void handle_ws_gnss(char *nmea, size_t size); 136 | void event_lastHeard(); 137 | 138 | #endif 139 | -------------------------------------------------------------------------------- /include/wireguard_vpn.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Multi-include guard 3 | //============================================================================== 4 | #ifndef INC_WIREGUARD_VPN_H 5 | #define INC_WIREGUARD_VPN_H 6 | 7 | //============================================================================== 8 | // Wireguard VPN Client demo for LwIP/ESP32 9 | //============================================================================== 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif // __cplusplus 13 | 14 | #include "lwip/tcpip.h" 15 | 16 | #ifdef CONFIG_LWIP_TCPIP_CORE_LOCKING 17 | #define TCP_MUTEX_LOCK() \ 18 | if (!sys_thread_tcpip(LWIP_CORE_LOCK_QUERY_HOLDER)) { \ 19 | LOCK_TCPIP_CORE(); \ 20 | } 21 | 22 | #define TCP_MUTEX_UNLOCK() \ 23 | if (sys_thread_tcpip(LWIP_CORE_LOCK_QUERY_HOLDER)) { \ 24 | UNLOCK_TCPIP_CORE(); \ 25 | } 26 | #else // CONFIG_LWIP_TCPIP_CORE_LOCKING 27 | #define TCP_MUTEX_LOCK() 28 | #define TCP_MUTEX_UNLOCK() 29 | #endif // CONFIG_LWIP_TCPIP_CORE_LOCKING 30 | 31 | //============================================================================== 32 | // Includes 33 | //============================================================================== 34 | 35 | //============================================================================== 36 | // Defines 37 | //============================================================================== 38 | 39 | // #define WG_LOCAL_ADDRESS IPADDR4_INIT_BYTES(192, 168, 44, 202) 40 | // #define WG_LOCAL_NETMASK IPADDR4_INIT_BYTES(255, 255, 255, 255) 41 | // #define WG_GATEWAY_ADDRESS IPADDR4_INIT_BYTES(192, 168, 44, 195) 42 | // #define WG_CLIENT_PRIVATE_KEY "gH2YqDa+St6x5eFhomVQDwtV1F0YMQd3HtOElPkZgVY=" 43 | // #define WG_CLIENT_PORT 51821 44 | 45 | // #define WG_PEER_PUBLIC_KEY "ZEFr+/B/T5+k0DhVG/GOTvAOjeOiuFKmwtu/cy23xVs=" 46 | // #define WG_PEER_PORT 51820 47 | // #define WG_PEER_ADDRESS IPADDR4_INIT_BYTES(203, 150, 19, 23) 48 | 49 | //============================================================================== 50 | // Exported types 51 | //============================================================================== 52 | 53 | //============================================================================== 54 | // Exported data 55 | //============================================================================== 56 | 57 | //============================================================================== 58 | // Exported functions 59 | //============================================================================== 60 | bool wireguard_active(); 61 | void wireguard_remove(); 62 | void wireguard_setup(); 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif // __cplusplus 67 | 68 | #endif // INC_WIREGUARD_VPN_H 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /lib/Adafruit_GFX/.gitignore: -------------------------------------------------------------------------------- 1 | default.vim 2 | fontconvert/fontconvert 3 | # Our handy .gitignore for automation ease 4 | Doxyfile* 5 | doxygen_sqlite3.db 6 | html -------------------------------------------------------------------------------- /lib/Adafruit_GFX/.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | sudo: false 3 | cache: 4 | directories: 5 | - ~/arduino_ide 6 | - ~/.arduino15/packages/ 7 | git: 8 | depth: false 9 | quiet: true 10 | env: 11 | global: 12 | - PRETTYNAME="Adafruit GFX Library" 13 | 14 | before_install: 15 | - source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/install.sh) 16 | 17 | install: 18 | - arduino --install-library "Adafruit ILI9341" 19 | 20 | script: 21 | - build_main_platforms 22 | 23 | # Generate and deploy documentation 24 | after_success: 25 | - source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/library_check.sh) 26 | - source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/doxy_gen_and_deploy.sh) 27 | -------------------------------------------------------------------------------- /lib/Adafruit_GFX/Adafruit_SPITFT_Macros.h: -------------------------------------------------------------------------------- 1 | // THIS FILE INTENTIONALLY LEFT BLANK. 2 | 3 | // Macros previously #defined here have been made into (mostly) inline 4 | // functions in the Adafruit_SPITFT class. Other libraries might still 5 | // contain code trying to #include this header file, so until everything's 6 | // updated this file still exists (but doing nothing) to avoid trouble. 7 | -------------------------------------------------------------------------------- /lib/Adafruit_GFX/README.md: -------------------------------------------------------------------------------- 1 | # Adafruit GFX Library [![Build Status](https://travis-ci.com/adafruit/Adafruit-GFX-Library.svg?branch=master)](https://travis-ci.com/adafruit/Adafruit-GFX-Library) 2 | 3 | This is the core graphics library for all our displays, providing a common set of graphics primitives (points, lines, circles, etc.). It needs to be paired with a hardware-specific library for each display device we carry (to handle the lower-level functions). 4 | 5 | Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! 6 | 7 | Written by Limor Fried/Ladyada for Adafruit Industries. 8 | BSD license, check license.txt for more information. 9 | All text above must be included in any redistribution. 10 | 11 | Recent Arduino IDE releases include the Library Manager for easy installation. Otherwise, to download, click the DOWNLOAD ZIP button, uncompress and rename the uncompressed folder Adafruit_GFX. Confirm that the Adafruit_GFX folder contains Adafruit_GFX.cpp and Adafruit_GFX.h. Place the Adafruit_GFX library folder your ArduinoSketchFolder/Libraries/ folder. You may need to create the Libraries subfolder if its your first library. Restart the IDE. 12 | 13 | # Useful Resources 14 | 15 | - Image2Code: This is a handy Java GUI utility to convert a BMP file into the array code necessary to display the image with the drawBitmap function. Check out the code at ehubin's GitHub repository: https://github.com/ehubin/Adafruit-GFX-Library/tree/master/Img2Code 16 | 17 | - drawXBitmap function: You can use the GIMP photo editor to save a .xbm file and use the array saved in the file to draw a bitmap with the drawXBitmap function. See the pull request here for more details: https://github.com/adafruit/Adafruit-GFX-Library/pull/31 18 | 19 | - 'Fonts' folder contains bitmap fonts for use with recent (1.1 and later) Adafruit_GFX. To use a font in your Arduino sketch, \#include the corresponding .h file and pass address of GFXfont struct to setFont(). Pass NULL to revert to 'classic' fixed-space bitmap font. 20 | 21 | - 'fontconvert' folder contains a command-line tool for converting TTF fonts to Adafruit_GFX header format. 22 | 23 | --- 24 | 25 | ### Roadmap 26 | 27 | The PRIME DIRECTIVE is to maintain backward compatibility with existing Arduino sketches -- many are hosted elsewhere and don't track changes here, some are in print and can never be changed! This "little" library has grown organically over time and sometimes we paint ourselves into a design corner and just have to live with it or add ungainly workarounds. 28 | 29 | Highly unlikely to merge any changes for additional or incompatible font formats (see Prime Directive above). There are already two formats and the code is quite bloaty there as it is (this also creates liabilities for tools and documentation). If you *must* have a more sophisticated font format, consider creating a fork with the features required for your project. For similar reasons, also unlikely to add any more bitmap formats, it's getting messy. 30 | 31 | Please don't reformat code for the sake of reformatting code. The resulting large "visual diff" makes it impossible to untangle actual bug fixes from merely rearranged lines. 32 | -------------------------------------------------------------------------------- /lib/Adafruit_GFX/fontconvert/Font Converter.url: -------------------------------------------------------------------------------- 1 | [InternetShortcut] 2 | URL=http://oleddisplay.squix.ch/#/home 3 | -------------------------------------------------------------------------------- /lib/Adafruit_GFX/fontconvert/Makefile: -------------------------------------------------------------------------------- 1 | all: fontconvert 2 | 3 | CC = gcc 4 | CFLAGS = -Wall -I/usr/local/include/freetype2 -I/usr/include/freetype2 -I/usr/include 5 | LIBS = -lfreetype 6 | 7 | fontconvert: fontconvert.c 8 | $(CC) $(CFLAGS) $< $(LIBS) -o $@ 9 | strip $@ 10 | 11 | clean: 12 | rm -f fontconvert 13 | -------------------------------------------------------------------------------- /lib/Adafruit_GFX/fontconvert/fontconvert_win.md: -------------------------------------------------------------------------------- 1 | ### A short guide to use fontconvert.c to create your own fonts using MinGW. 2 | 3 | #### STEP 1: INSTALL MinGW 4 | 5 | Install MinGW (Minimalist GNU for Windows) from [MinGW.org](http://www.mingw.org/). 6 | Please read carefully the instructions found on [Getting started page](http://www.mingw.org/wiki/Getting_Started). 7 | I suggest installing with the "Graphical User Interface Installer". 8 | To complete your initial installation you should further install some "packages". 9 | For our purpose you should only install the "Basic Setup" packages. 10 | To do that: 11 | 12 | 1. Open the MinGW Installation Manager 13 | 2. From the left panel click "Basic Setup". 14 | 3. On the right panel choose "mingw32-base", "mingw-gcc-g++", "mingw-gcc-objc" and "msys-base" 15 | and click "Mark for installation" 16 | 4. From the Menu click "Installation" and then "Apply changes". In the pop-up window select "Apply". 17 | 18 | 19 | #### STEP 2: INSTALL Freetype Library 20 | 21 | To read about the freetype project visit [freetype.org](https://www.freetype.org/). 22 | To Download the latest version of freetype go to [download page](http://download.savannah.gnu.org/releases/freetype/) 23 | and choose "freetype-2.7.tar.gz" file (or a newer version if available). 24 | To avoid long cd commands later in the command prompt, I suggest you unzip the file in the C:\ directory. 25 | (I also renamed the folder to "ft27") 26 | Before you build the library it's good to read these articles: 27 | * [Using MSYS with MinGW](http://www.mingw.org/wiki/MSYS) 28 | * [Installation and Use of Supplementary Libraries with MinGW](http://www.mingw.org/wiki/LibraryPathHOWTO) 29 | * [Include Path](http://www.mingw.org/wiki/IncludePathHOWTO) 30 | 31 | Inside the unzipped folder there is another folder named "docs". Open it and read the INSTALL.UNIX (using notepad). 32 | Pay attention to paragraph 3 (Build and Install the Library). So, let's begin the installation. 33 | To give the appropriate commands we will use the MSYS command prompt (not cmd.exe of windows) which is UNIX like. 34 | Follow the path C:\MinGW\msys\1.0 and double click "msys.bat". The command prompt environment appears. 35 | Enter "ft27" directory using the cd commands: 36 | ``` 37 | cd /c 38 | cd ft27 39 | ``` 40 | 41 | and then type one by one the commands: 42 | ``` 43 | ./configure --prefix=/mingw 44 | make 45 | make install 46 | ``` 47 | Once you're finished, go inside "C:\MinGW\include" and there should be a new folder named "freetype2". 48 | That, hopefully, means that you have installed the library correctly !! 49 | 50 | #### STEP 3: Build fontconvert.c 51 | 52 | Before proceeding I suggest you make a copy of Adafruit_GFX_library folder in C:\ directory. 53 | Then, inside "fontconvert" folder open the "makefile" with an editor ( I used notepad++). 54 | Change the commands so in the end the program looks like : 55 | ``` 56 | all: fontconvert 57 | 58 | CC = gcc 59 | CFLAGS = -Wall -I c:/mingw/include/freetype2 60 | LIBS = -lfreetype 61 | 62 | fontconvert: fontconvert.c 63 | $(CC) $(CFLAGS) $< $(LIBS) -o $@ 64 | 65 | clean: 66 | rm -f fontconvert 67 | ``` 68 | Go back in the command prompt and with a cd command enter the fontconvert directory. 69 | ``` 70 | cd /c/adafruit_gfx_library\fontconvert 71 | ``` 72 | Give the command: 73 | ``` 74 | make 75 | ``` 76 | This command will, eventually, create a "fontconvert.exe" file inside fontconvert directory. 77 | 78 | #### STEP 4: Create your own font header files 79 | 80 | Now that you have an executable file, you can use it to create your own fonts to work with Adafruit GFX lib. 81 | So, if we suppose that you already have a .ttf file with your favorite fonts, jump to the command prompt and type: 82 | ``` 83 | ./fontconvert yourfonts.ttf 9 > yourfonts9pt7b.h 84 | ``` 85 | You can read more details at: [learn.adafruit](https://learn.adafruit.com/adafruit-gfx-graphics-library/using-fonts). 86 | 87 | Taraaaaaammm !! you've just created your new font header file. Put it inside the "Fonts" folder, grab a cup of coffee 88 | and start playing with your Arduino (or whatever else ....)+ display module project. 89 | -------------------------------------------------------------------------------- /lib/Adafruit_GFX/fontconvert/makefonts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Ugly little Bash script, generates a set of .h files for GFX using 4 | # GNU FreeFont sources. There are three fonts: 'Mono' (Courier-like), 5 | # 'Sans' (Helvetica-like) and 'Serif' (Times-like); four styles: regular, 6 | # bold, oblique or italic, and bold+oblique or bold+italic; and four 7 | # sizes: 9, 12, 18 and 24 point. No real error checking or anything, 8 | # this just powers through all the combinations, calling the fontconvert 9 | # utility and redirecting the output to a .h file for each combo. 10 | 11 | # Adafruit_GFX repository does not include the source outline fonts 12 | # (huge zipfile, different license) but they're easily acquired: 13 | # http://savannah.gnu.org/projects/freefont/ 14 | 15 | convert=./fontconvert 16 | inpath=~/Desktop/freefont/ 17 | outpath=../Fonts/ 18 | fonts=(FreeMono FreeSans FreeSerif) 19 | styles=("" Bold Italic BoldItalic Oblique BoldOblique) 20 | sizes=(9 12 18 24) 21 | 22 | for f in ${fonts[*]} 23 | do 24 | for index in ${!styles[*]} 25 | do 26 | st=${styles[$index]} 27 | for si in ${sizes[*]} 28 | do 29 | infile=$inpath$f$st".ttf" 30 | if [ -f $infile ] # Does source combination exist? 31 | then 32 | outfile=$outpath$f$st$si"pt7b.h" 33 | # printf "%s %s %s > %s\n" $convert $infile $si $outfile 34 | $convert $infile $si > $outfile 35 | fi 36 | done 37 | done 38 | done 39 | -------------------------------------------------------------------------------- /lib/Adafruit_GFX/gfxfont.h: -------------------------------------------------------------------------------- 1 | // Font structures for newer Adafruit_GFX (1.1 and later). 2 | // Example fonts are included in 'Fonts' directory. 3 | // To use a font in your Arduino sketch, #include the corresponding .h 4 | // file and pass address of GFXfont struct to setFont(). Pass NULL to 5 | // revert to 'classic' fixed-space bitmap font. 6 | 7 | #ifndef _GFXFONT_H_ 8 | #define _GFXFONT_H_ 9 | 10 | /// Font data stored PER GLYPH 11 | typedef struct { 12 | uint16_t bitmapOffset; ///< Pointer into GFXfont->bitmap 13 | uint8_t width; ///< Bitmap dimensions in pixels 14 | uint8_t height; ///< Bitmap dimensions in pixels 15 | uint8_t xAdvance; ///< Distance to advance cursor (x axis) 16 | int8_t xOffset; ///< X dist from cursor pos to UL corner 17 | int8_t yOffset; ///< Y dist from cursor pos to UL corner 18 | } GFXglyph; 19 | 20 | /// Data stored for FONT AS A WHOLE 21 | typedef struct { 22 | uint8_t *bitmap; ///< Glyph bitmaps, concatenated 23 | GFXglyph *glyph; ///< Glyph array 24 | uint8_t first; ///< ASCII extents (first char) 25 | uint8_t last; ///< ASCII extents (last char) 26 | uint8_t yAdvance; ///< Newline distance (y axis) 27 | } GFXfont; 28 | 29 | #endif // _GFXFONT_H_ 30 | -------------------------------------------------------------------------------- /lib/Adafruit_GFX/library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit GFX Library 2 | version=1.5.6 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Adafruit GFX graphics core library, this is the 'core' class that all our other graphics libraries derive from. 6 | paragraph=Install this library in addition to the display library for your hardware. 7 | category=Display 8 | url=https://github.com/adafruit/Adafruit-GFX-Library 9 | architectures=* 10 | -------------------------------------------------------------------------------- /lib/Adafruit_GFX/license.txt: -------------------------------------------------------------------------------- 1 | Software License Agreement (BSD License) 2 | 3 | Copyright (c) 2012 Adafruit Industries. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | - Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | - Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /lib/ESP32Ping/library.properties: -------------------------------------------------------------------------------- 1 | name=ESP32Ping 2 | version=1.2 3 | author=Daniele Colanardi,Marian Craciunescu 4 | maintainer=marian4us2007@gmail.com 5 | sentence=Let the ESP32 ping a remote machine. 6 | paragraph=With this library an ESP32 can ping a remote machine and know if it's reachable. It provide some basic measurements on ping messages (avg response time). 7 | category=Communication 8 | url=https://github.com/marian-craciunescu/ESP32Ping 9 | architectures=esp32 10 | -------------------------------------------------------------------------------- /lib/ESP32Ping/src/ESP32Ping.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ESP32Ping - Ping library for ESP32 3 | Copyright (c) 2018 Marian Craciunescu. 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 | #include "ESP32Ping.h" 20 | 21 | 22 | extern "C" void esp_schedule(void) {}; 23 | extern "C" void esp_yield(void) {}; 24 | 25 | PingClass::PingClass() {} 26 | 27 | bool PingClass::ping(IPAddress dest, byte count) { 28 | _expected_count = count; 29 | _errors = 0; 30 | _success = 0; 31 | 32 | _avg_time = 0; 33 | 34 | memset(&_options, 0, sizeof(struct ping_option)); 35 | 36 | // Repeat count (how many time send a ping message to destination) 37 | _options.count = count; 38 | // Time interval between two ping (seconds??) 39 | _options.coarse_time = 1; 40 | // Destination machine 41 | _options.ip = dest; 42 | 43 | // Callbacks 44 | _options.recv_function = reinterpret_cast(&PingClass::_ping_recv_cb); 45 | _options.sent_function = NULL; //reinterpret_cast(&_ping_sent_cb); 46 | 47 | // Let's go! 48 | if (ping_start(&_options)) { 49 | // Suspend till the process end 50 | esp_yield(); 51 | } 52 | 53 | return (_success > 0); 54 | } 55 | 56 | bool PingClass::ping(const char *host, byte count) { 57 | IPAddress remote_addr; 58 | 59 | if (WiFi.hostByName(host, remote_addr)) 60 | return ping(remote_addr, count); 61 | 62 | return false; 63 | } 64 | 65 | int PingClass::averageTime() { 66 | return _avg_time; 67 | } 68 | 69 | void PingClass::_ping_recv_cb(void *opt, void *resp) { 70 | // Cast the parameters to get some usable info 71 | ping_resp *ping_resp = reinterpret_cast(resp); 72 | //ping_option* ping_opt = reinterpret_cast(opt); 73 | 74 | // Error or success? 75 | if (ping_resp->ping_err == -1) 76 | _errors++; 77 | else { 78 | _success++; 79 | _avg_time += ping_resp->resp_time; 80 | } 81 | 82 | // Some debug info 83 | DEBUG_PING( 84 | "DEBUG: ping reply\n" 85 | "\ttotal_count = %d \n" 86 | "\tresp_time = %d \n" 87 | "\tseqno = %d \n" 88 | "\ttimeout_count = %d \n" 89 | "\tbytes = %d \n" 90 | "\ttotal_bytes = %d \n" 91 | "\ttotal_time = %d \n" 92 | "\tping_err = %d \n", 93 | ping_resp->total_count, ping_resp->resp_time, ping_resp->seqno, 94 | ping_resp->timeout_count, ping_resp->bytes, ping_resp->total_bytes, 95 | ping_resp->total_time, ping_resp->ping_err 96 | ); 97 | 98 | // Is it time to end? 99 | // Don't using seqno because it does not increase on error 100 | if (_success + _errors == _expected_count) { 101 | _avg_time = _avg_time / _expected_count; 102 | 103 | DEBUG_PING("Avg resp time %d ms\n", _avg_time); 104 | 105 | // Done, return to main functiom 106 | esp_schedule(); 107 | } 108 | } 109 | 110 | byte PingClass::_expected_count = 0; 111 | byte PingClass::_errors = 0; 112 | byte PingClass::_success = 0; 113 | int PingClass::_avg_time = 0; 114 | 115 | PingClass Ping; -------------------------------------------------------------------------------- /lib/ESP32Ping/src/ESP32Ping.h: -------------------------------------------------------------------------------- 1 | /* 2 | ESP32Ping - Ping library for ESP32 3 | Copyright (c) 2018 Marian Craciunescu. 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 ESP32PING_H 21 | #define ESP32PING_H 22 | 23 | #include 24 | #include 25 | 26 | // extern "C" { 27 | #include 28 | //} 29 | 30 | #ifdef ENABLE_DEBUG_PING 31 | #define DEBUG_PING(...) Serial.printf(__VA_ARGS__) 32 | #else 33 | #define DEBUG_PING(...) 34 | #endif 35 | 36 | #ifdef __cplusplus 37 | extern "C" 38 | { 39 | #endif 40 | 41 | void esp_schedule(void); 42 | void esp_yield(void); 43 | 44 | #ifdef __cplusplus 45 | } // extern "C" 46 | #endif 47 | 48 | class PingClass 49 | { 50 | public: 51 | PingClass(); 52 | 53 | bool ping(IPAddress dest, byte count = 5); 54 | 55 | bool ping(const char *host, byte count = 5); 56 | 57 | int averageTime(); 58 | 59 | protected: 60 | static void _ping_sent_cb(void *opt, void *pdata); 61 | 62 | static void _ping_recv_cb(void *opt, void *pdata); 63 | 64 | IPAddress _dest; 65 | ping_option _options; 66 | 67 | static byte _expected_count, _errors, _success; 68 | static int _avg_time; 69 | }; 70 | 71 | extern PingClass Ping; 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /lib/ESP32Ping/src/ping.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef PING_H 4 | #define PING_H 5 | #include 6 | 7 | typedef void(*ping_recv_function)(void* arg, void *pdata); 8 | typedef void(*ping_sent_function)(void* arg, void *pdata); 9 | 10 | struct ping_option { 11 | uint32_t count; 12 | uint32_t ip; 13 | uint32_t coarse_time; 14 | ping_recv_function recv_function; 15 | ping_sent_function sent_function; 16 | void* reverse; 17 | }; 18 | 19 | struct ping_resp { 20 | uint32_t total_count; 21 | uint32_t resp_time; 22 | uint32_t seqno; 23 | uint32_t timeout_count; 24 | uint32_t bytes; 25 | uint32_t total_bytes; 26 | uint32_t total_time; 27 | int8_t ping_err; 28 | }; 29 | 30 | bool ping_start(struct ping_option *ping_opt); 31 | void ping(const char *name, int count, int interval, int size, int timeout); 32 | bool ping_start(IPAddress adr, int count, int interval, int size, int timeout); 33 | 34 | #endif // PING_H 35 | -------------------------------------------------------------------------------- /lib/ESPAsyncWebServer-esphome/.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name-template: "v$RESOLVED_VERSION" 2 | tag-template: "v$RESOLVED_VERSION" 3 | categories: 4 | - title: "Breaking Changes" 5 | label: "breaking-change" 6 | - title: "Dependencies" 7 | collapse-after: 1 8 | labels: 9 | - "dependencies" 10 | 11 | version-resolver: 12 | major: 13 | labels: 14 | - "major" 15 | - "breaking-change" 16 | minor: 17 | labels: 18 | - "minor" 19 | - "new-feature" 20 | patch: 21 | labels: 22 | - "bugfix" 23 | - "dependencies" 24 | - "documentation" 25 | - "enhancement" 26 | default: patch 27 | 28 | template: | 29 | ## What's Changed 30 | 31 | $CHANGES 32 | 33 | **Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION 34 | -------------------------------------------------------------------------------- /lib/ESPAsyncWebServer-esphome/.github/scripts/install-arduino-core-esp32.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export ARDUINO_ESP32_PATH="$ARDUINO_USR_PATH/hardware/espressif/esp32" 4 | if [ ! -d "$ARDUINO_ESP32_PATH" ]; then 5 | echo "Installing ESP32 Arduino Core ..." 6 | script_init_path="$PWD" 7 | mkdir -p "$ARDUINO_USR_PATH/hardware/espressif" 8 | cd "$ARDUINO_USR_PATH/hardware/espressif" 9 | 10 | echo "Installing Python Serial ..." 11 | pip3 install pyserial > /dev/null 12 | 13 | if [ "$OS_IS_WINDOWS" == "1" ]; then 14 | echo "Installing Python Requests ..." 15 | pip3 install requests > /dev/null 16 | fi 17 | 18 | if [ "$GITHUB_REPOSITORY" == "espressif/arduino-esp32" ]; then 19 | echo "Linking Core..." 20 | ln -s $GITHUB_WORKSPACE esp32 21 | else 22 | echo "Cloning Core Repository..." 23 | git clone https://github.com/espressif/arduino-esp32.git esp32 > /dev/null 2>&1 24 | fi 25 | 26 | echo "Updating Submodules ..." 27 | cd esp32 28 | git submodule update --init --recursive > /dev/null 2>&1 29 | 30 | echo "Installing Platform Tools ..." 31 | cd tools && python3 get.py 32 | cd $script_init_path 33 | 34 | echo "ESP32 Arduino has been installed in '$ARDUINO_ESP32_PATH'" 35 | echo "" 36 | fi 37 | -------------------------------------------------------------------------------- /lib/ESPAsyncWebServer-esphome/.github/scripts/install-arduino-core-esp8266.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Installing ESP8266 Arduino Core ..." 4 | script_init_path="$PWD" 5 | mkdir -p "$ARDUINO_USR_PATH/hardware/esp8266com" 6 | cd "$ARDUINO_USR_PATH/hardware/esp8266com" 7 | 8 | echo "Installing Python Serial ..." 9 | pip3 install pyserial > /dev/null 10 | 11 | if [ "$OS_IS_WINDOWS" == "1" ]; then 12 | echo "Installing Python Requests ..." 13 | pip3 install requests > /dev/null 14 | fi 15 | 16 | echo "Cloning Core Repository ..." 17 | git clone https://github.com/esp8266/Arduino.git esp8266 > /dev/null 2>&1 18 | 19 | echo "Updating submodules ..." 20 | cd esp8266 21 | git submodule update --init --recursive > /dev/null 2>&1 22 | 23 | echo "Installing Platform Tools ..." 24 | cd tools 25 | python3 get.py > /dev/null 26 | cd $script_init_path 27 | 28 | echo "ESP8266 Arduino has been installed in '$ARDUINO_USR_PATH/hardware/esp8266com'" 29 | echo "" 30 | -------------------------------------------------------------------------------- /lib/ESPAsyncWebServer-esphome/.github/scripts/install-platformio.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Installing Python Wheel ..." 4 | pip3 install wheel > /dev/null 2>&1 5 | 6 | echo "Installing PlatformIO ..." 7 | pip3 install -U platformio > /dev/null 2>&1 8 | 9 | echo "PlatformIO has been installed" 10 | echo "" 11 | 12 | 13 | function build_pio_sketch(){ # build_pio_sketch 14 | if [ "$#" -lt 3 ]; then 15 | echo "ERROR: Illegal number of parameters" 16 | echo "USAGE: build_pio_sketch " 17 | return 1 18 | fi 19 | 20 | local board="$1" 21 | local sketch="$2" 22 | local buildFlags="$3" 23 | local sketch_dir=$(dirname "$sketch") 24 | echo "" 25 | echo "Compiling '"$(basename "$sketch")"' ..." 26 | python3 -m platformio ci -l '.' --board "$board" "$sketch_dir" --project-option="board_build.partitions = huge_app.csv" --project-option="build_flags=$buildFlags" 27 | } 28 | 29 | function count_sketches() # count_sketches 30 | { 31 | local examples="$1" 32 | rm -rf sketches.txt 33 | if [ ! -d "$examples" ]; then 34 | touch sketches.txt 35 | return 0 36 | fi 37 | local sketches=$(find $examples -name *.ino) 38 | local sketchnum=0 39 | for sketch in $sketches; do 40 | local sketchdir=$(dirname $sketch) 41 | local sketchdirname=$(basename $sketchdir) 42 | local sketchname=$(basename $sketch) 43 | if [[ "${sketchdirname}.ino" != "$sketchname" ]]; then 44 | continue 45 | fi; 46 | if [[ -f "$sketchdir/.test.skip" ]]; then 47 | continue 48 | fi 49 | echo $sketch >> sketches.txt 50 | sketchnum=$(($sketchnum + 1)) 51 | done 52 | return $sketchnum 53 | } 54 | 55 | function build_pio_sketches() # build_pio_sketches 56 | { 57 | if [ "$#" -lt 2 ]; then 58 | echo "ERROR: Illegal number of parameters" 59 | echo "USAGE: build_pio_sketches [ ]" 60 | return 1 61 | fi 62 | 63 | local board=$1 64 | local examples=$2 65 | local chunk_idex=$3 66 | local chunks_num=$4 67 | 68 | if [ "$#" -lt 4 ]; then 69 | chunk_idex="0" 70 | chunks_num="1" 71 | fi 72 | 73 | if [ "$chunks_num" -le 0 ]; then 74 | echo "ERROR: Chunks count must be positive number" 75 | return 1 76 | fi 77 | if [ "$chunk_idex" -ge "$chunks_num" ]; then 78 | echo "ERROR: Chunk index must be less than chunks count" 79 | return 1 80 | fi 81 | 82 | set +e 83 | count_sketches "$examples" 84 | local sketchcount=$? 85 | set -e 86 | local sketches=$(cat sketches.txt) 87 | rm -rf sketches.txt 88 | 89 | local chunk_size=$(( $sketchcount / $chunks_num )) 90 | local all_chunks=$(( $chunks_num * $chunk_size )) 91 | if [ "$all_chunks" -lt "$sketchcount" ]; then 92 | chunk_size=$(( $chunk_size + 1 )) 93 | fi 94 | 95 | local start_index=$(( $chunk_idex * $chunk_size )) 96 | if [ "$sketchcount" -le "$start_index" ]; then 97 | echo "Skipping job" 98 | return 0 99 | fi 100 | 101 | local end_index=$(( $(( $chunk_idex + 1 )) * $chunk_size )) 102 | if [ "$end_index" -gt "$sketchcount" ]; then 103 | end_index=$sketchcount 104 | fi 105 | 106 | local start_num=$(( $start_index + 1 )) 107 | echo "Found $sketchcount Sketches"; 108 | echo "Chunk Count : $chunks_num" 109 | echo "Chunk Size : $chunk_size" 110 | echo "Start Sketch: $start_num" 111 | echo "End Sketch : $end_index" 112 | 113 | local sketchnum=0 114 | for sketch in $sketches; do 115 | local sketchdir=$(dirname $sketch) 116 | local sketchdirname=$(basename $sketchdir) 117 | local sketchname=$(basename $sketch) 118 | if [ "${sketchdirname}.ino" != "$sketchname" ] \ 119 | || [ -f "$sketchdir/.test.skip" ]; then 120 | continue 121 | fi 122 | local sketchBuildFlags="" 123 | if [ -f "$sketchdir/.test.build_flags" ]; then 124 | while read line; do 125 | sketchBuildFlags="$sketchBuildFlags $line" 126 | done < "$sketchdir/.test.build_flags" 127 | fi 128 | sketchnum=$(($sketchnum + 1)) 129 | if [ "$sketchnum" -le "$start_index" ] \ 130 | || [ "$sketchnum" -gt "$end_index" ]; then 131 | continue 132 | fi 133 | build_pio_sketch "$board" "$sketch" "$sketchBuildFlags" 134 | local result=$? 135 | if [ $result -ne 0 ]; then 136 | return $result 137 | fi 138 | done 139 | return 0 140 | } 141 | -------------------------------------------------------------------------------- /lib/ESPAsyncWebServer-esphome/.github/scripts/on-push.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | if [ ! -z "$TRAVIS_BUILD_DIR" ]; then 6 | export GITHUB_WORKSPACE="$TRAVIS_BUILD_DIR" 7 | export GITHUB_REPOSITORY="$TRAVIS_REPO_SLUG" 8 | elif [ -z "$GITHUB_WORKSPACE" ]; then 9 | export GITHUB_WORKSPACE="$PWD" 10 | export GITHUB_REPOSITORY="me-no-dev/ESPAsyncWebServer" 11 | fi 12 | 13 | TARGET_PLATFORM="$1" 14 | CHUNK_INDEX=$2 15 | CHUNKS_CNT=$3 16 | BUILD_PIO=0 17 | if [ "$#" -lt 1 ]; then 18 | TARGET_PLATFORM="esp32" 19 | fi 20 | if [ "$#" -lt 3 ] || [ "$CHUNKS_CNT" -le 0 ]; then 21 | CHUNK_INDEX=0 22 | CHUNKS_CNT=1 23 | elif [ "$CHUNK_INDEX" -gt "$CHUNKS_CNT" ]; then 24 | CHUNK_INDEX=$CHUNKS_CNT 25 | elif [ "$CHUNK_INDEX" -eq "$CHUNKS_CNT" ]; then 26 | BUILD_PIO=1 27 | fi 28 | 29 | if [ "$BUILD_PIO" -eq 0 ]; then 30 | # ArduinoIDE Test 31 | source ./.github/scripts/install-arduino-ide.sh 32 | 33 | echo "Installing ESPAsyncWebServer ..." 34 | cp -af "$GITHUB_WORKSPACE/src" "$ARDUINO_USR_PATH/libraries/ESPAsyncWebServer" 35 | echo "Installing ArduinoJson ..." 36 | git clone https://github.com/bblanchon/ArduinoJson "$ARDUINO_USR_PATH/libraries/ArduinoJson" > /dev/null 2>&1 37 | 38 | if [[ "$TARGET_PLATFORM" == "esp32" ]]; then 39 | echo "Installing AsyncTCP ..." 40 | git clone https://github.com/me-no-dev/AsyncTCP "$ARDUINO_USR_PATH/libraries/AsyncTCP" > /dev/null 2>&1 41 | FQBN="espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app" 42 | source ./.github/scripts/install-arduino-core-esp32.sh 43 | echo "BUILDING ESP32 EXAMPLES" 44 | else 45 | echo "Installing ESPAsyncTCP ..." 46 | git clone https://github.com/me-no-dev/ESPAsyncTCP "$ARDUINO_USR_PATH/libraries/ESPAsyncTCP" > /dev/null 2>&1 47 | FQBN="esp8266com:esp8266:generic:eesz=4M1M,ip=lm2f" 48 | source ./.github/scripts/install-arduino-core-esp8266.sh 49 | echo "BUILDING ESP8266 EXAMPLES" 50 | fi 51 | build_sketches "$FQBN" "$GITHUB_WORKSPACE/examples" "$CHUNK_INDEX" "$CHUNKS_CNT" 52 | else 53 | # PlatformIO Test 54 | source ./.github/scripts/install-platformio.sh 55 | 56 | python3 -m platformio lib --storage-dir "$GITHUB_WORKSPACE" install 57 | echo "Installing ArduinoJson ..." 58 | python3 -m platformio lib -g install https://github.com/bblanchon/ArduinoJson.git > /dev/null 2>&1 59 | if [[ "$TARGET_PLATFORM" == "esp32" ]]; then 60 | BOARD="esp32dev" 61 | echo "Installing AsyncTCP ..." 62 | python3 -m platformio lib -g install https://github.com/me-no-dev/AsyncTCP.git > /dev/null 2>&1 63 | echo "BUILDING ESP32 EXAMPLES" 64 | else 65 | BOARD="esp12e" 66 | echo "Installing ESPAsyncTCP ..." 67 | python3 -m platformio lib -g install https://github.com/me-no-dev/ESPAsyncTCP.git > /dev/null 2>&1 68 | echo "BUILDING ESP8266 EXAMPLES" 69 | fi 70 | build_pio_sketches "$BOARD" "$GITHUB_WORKSPACE/examples" 71 | fi 72 | -------------------------------------------------------------------------------- /lib/ESPAsyncWebServer-esphome/.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Configuration for probot-stale - https://github.com/probot/stale 2 | 3 | daysUntilStale: 60 4 | daysUntilClose: 14 5 | limitPerRun: 30 6 | staleLabel: stale 7 | exemptLabels: 8 | - pinned 9 | - security 10 | - "to be implemented" 11 | - "for reference" 12 | - "move to PR" 13 | - "enhancement" 14 | 15 | only: issues 16 | onlyLabels: [] 17 | exemptProjects: false 18 | exemptMilestones: false 19 | exemptAssignees: false 20 | 21 | markComment: > 22 | [STALE_SET] This issue has been automatically marked as stale because it has not had 23 | recent activity. It will be closed in 14 days if no further activity occurs. Thank you 24 | for your contributions. 25 | 26 | unmarkComment: > 27 | [STALE_CLR] This issue has been removed from the stale queue. Please ensure activity to keep it openin the future. 28 | 29 | closeComment: > 30 | [STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions. 31 | 32 | -------------------------------------------------------------------------------- /lib/ESPAsyncWebServer-esphome/.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | 3 | on: 4 | release: 5 | types: [published] 6 | 7 | jobs: 8 | publish: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v4.2.1 12 | - name: Set up Python 13 | uses: actions/setup-python@v5.2.0 14 | with: 15 | python-version: '3.x' 16 | - name: Install platformio 17 | run: pip install --upgrade platformio 18 | - name: Publish package 19 | env: 20 | PLATFORMIO_AUTH_TOKEN: ${{ secrets.PLATFORMIO_AUTH_TOKEN }} 21 | run: pio package publish --owner esphome --non-interactive 22 | -------------------------------------------------------------------------------- /lib/ESPAsyncWebServer-esphome/.github/workflows/push.yml: -------------------------------------------------------------------------------- 1 | name: ESP Async Web Server CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - release/* 8 | pull_request: 9 | 10 | jobs: 11 | 12 | build-arduino: 13 | name: Arduino for ${{ matrix.board }} on ${{ matrix.os }} 14 | runs-on: ${{ matrix.os }} 15 | strategy: 16 | fail-fast: false 17 | matrix: 18 | os: [ubuntu-latest, windows-latest, macOS-latest] 19 | board: [esp32, esp8266] 20 | steps: 21 | - uses: actions/checkout@v3.0.2 22 | - name: Build Tests 23 | run: bash ./.github/scripts/on-push.sh ${{ matrix.board }} 0 1 24 | 25 | build-pio: 26 | name: PlatformIO for ${{ matrix.board }} on ${{ matrix.os }} 27 | runs-on: ${{ matrix.os }} 28 | strategy: 29 | fail-fast: false 30 | matrix: 31 | os: [ubuntu-latest, windows-latest, macOS-latest] 32 | board: [esp32, esp8266] 33 | steps: 34 | - uses: actions/checkout@v3.0.2 35 | - name: Build Tests 36 | run: bash ./.github/scripts/on-push.sh ${{ matrix.board }} 1 1 37 | -------------------------------------------------------------------------------- /lib/ESPAsyncWebServer-esphome/.github/workflows/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name: Release Drafter 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | permissions: 9 | contents: write 10 | pull-requests: read 11 | 12 | jobs: 13 | release-drafter: 14 | name: Release Drafter 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: release-drafter/release-drafter@v6 18 | id: drafter 19 | env: 20 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 21 | 22 | - uses: actions/checkout@v4 23 | 24 | - name: Set library.json version 25 | run: | 26 | sed -i "s/\"version\": .*/\"version\": \"${{ steps.drafter.outputs.resolved_version }}\",/g" library.json 27 | 28 | - name: Commit changes 29 | run: | 30 | if ! git diff --quiet; then 31 | git config --global user.name "esphomebot" 32 | git config --global user.email "68923041+esphomebot@users.noreply.github.com" 33 | git commit -am "Bump version to ${{ steps.drafter.outputs.resolved_version }}" 34 | git push 35 | fi 36 | -------------------------------------------------------------------------------- /lib/ESPAsyncWebServer-esphome/.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | .DS_Store 3 | /dist/ 4 | 5 | -------------------------------------------------------------------------------- /lib/ESPAsyncWebServer-esphome/.piopm: -------------------------------------------------------------------------------- 1 | {"type": "library", "name": "ESPAsyncWebServer-esphome", "version": "3.3.0", "spec": {"owner": "ottowinter", "id": 6758, "name": "ESPAsyncWebServer-esphome", "requirements": null, "uri": null}} -------------------------------------------------------------------------------- /lib/ESPAsyncWebServer-esphome/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | 3 | language: python 4 | 5 | os: 6 | - linux 7 | 8 | git: 9 | depth: false 10 | 11 | stages: 12 | - build 13 | 14 | jobs: 15 | include: 16 | 17 | - name: "Build Arduino ESP32" 18 | if: tag IS blank AND (type = pull_request OR (type = push AND branch = master)) 19 | stage: build 20 | script: bash $TRAVIS_BUILD_DIR/.github/scripts/on-push.sh esp32 21 | 22 | - name: "Build Arduino ESP8266" 23 | if: tag IS blank AND (type = pull_request OR (type = push AND branch = master)) 24 | stage: build 25 | script: bash $TRAVIS_BUILD_DIR/.github/scripts/on-push.sh esp8266 26 | 27 | - name: "Build Platformio ESP32" 28 | if: tag IS blank AND (type = pull_request OR (type = push AND branch = master)) 29 | stage: build 30 | script: bash $TRAVIS_BUILD_DIR/.github/scripts/on-push.sh esp32 1 1 31 | 32 | - name: "Build Platformio ESP8266" 33 | if: tag IS blank AND (type = pull_request OR (type = push AND branch = master)) 34 | stage: build 35 | script: bash $TRAVIS_BUILD_DIR/.github/scripts/on-push.sh esp8266 1 1 36 | 37 | notifications: 38 | email: 39 | on_success: change 40 | on_failure: change 41 | webhooks: 42 | urls: 43 | - https://webhooks.gitter.im/e/60e65d0c78ea0a920347 44 | on_success: change # options: [always|never|change] default: always 45 | on_failure: always # options: [always|never|change] default: always 46 | on_start: never # options: [always|never|change] default: always 47 | -------------------------------------------------------------------------------- /lib/ESPAsyncWebServer-esphome/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_SRCDIRS 2 | "src" 3 | ) 4 | 5 | set(COMPONENT_ADD_INCLUDEDIRS 6 | "src" 7 | ) 8 | 9 | set(COMPONENT_REQUIRES 10 | "arduino-esp32" 11 | "AsyncTCP" 12 | ) 13 | 14 | register_component() 15 | 16 | target_compile_definitions(${COMPONENT_TARGET} PUBLIC -DESP32) 17 | target_compile_options(${COMPONENT_TARGET} PRIVATE -fno-rtti) 18 | -------------------------------------------------------------------------------- /lib/ESPAsyncWebServer-esphome/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /lib/ESPAsyncWebServer-esphome/component.mk: -------------------------------------------------------------------------------- 1 | COMPONENT_ADD_INCLUDEDIRS := src 2 | COMPONENT_SRCDIRS := src 3 | CXXFLAGS += -fno-rtti 4 | -------------------------------------------------------------------------------- /lib/ESPAsyncWebServer-esphome/examples/CaptivePortal/CaptivePortal.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #ifdef ESP32 3 | #include 4 | #include 5 | #elif defined(ESP8266) 6 | #include 7 | #include 8 | #endif 9 | #include "ESPAsyncWebServer.h" 10 | 11 | DNSServer dnsServer; 12 | AsyncWebServer server(80); 13 | 14 | class CaptiveRequestHandler : public AsyncWebHandler { 15 | public: 16 | CaptiveRequestHandler() {} 17 | virtual ~CaptiveRequestHandler() {} 18 | 19 | bool canHandle(AsyncWebServerRequest *request){ 20 | //request->addInterestingHeader("ANY"); 21 | return true; 22 | } 23 | 24 | void handleRequest(AsyncWebServerRequest *request) { 25 | AsyncResponseStream *response = request->beginResponseStream("text/html"); 26 | response->print("Captive Portal"); 27 | response->print("

This is out captive portal front page.

"); 28 | response->printf("

You were trying to reach: http://%s%s

", request->host().c_str(), request->url().c_str()); 29 | response->printf("

Try opening this link instead

", WiFi.softAPIP().toString().c_str()); 30 | response->print(""); 31 | request->send(response); 32 | } 33 | }; 34 | 35 | 36 | void setup(){ 37 | //your other setup stuff... 38 | WiFi.softAP("esp-captive"); 39 | dnsServer.start(53, "*", WiFi.softAPIP()); 40 | server.addHandler(new CaptiveRequestHandler()).setFilter(ON_AP_FILTER);//only when requested from AP 41 | //more handlers... 42 | server.begin(); 43 | } 44 | 45 | void loop(){ 46 | dnsServer.processNextRequest(); 47 | } 48 | -------------------------------------------------------------------------------- /lib/ESPAsyncWebServer-esphome/examples/regex_patterns/.test.build_flags: -------------------------------------------------------------------------------- 1 | -DASYNCWEBSERVER_REGEX=1 2 | -------------------------------------------------------------------------------- /lib/ESPAsyncWebServer-esphome/examples/regex_patterns/regex_patterns.ino: -------------------------------------------------------------------------------- 1 | // 2 | // A simple server implementation with regex routes: 3 | // * serve static messages 4 | // * read GET and POST parameters 5 | // * handle missing pages / 404s 6 | // 7 | 8 | // Add buildflag ASYNCWEBSERVER_REGEX to enable the regex support 9 | 10 | // For platformio: platformio.ini: 11 | // build_flags = 12 | // -DASYNCWEBSERVER_REGEX 13 | 14 | // For arduino IDE: create/update platform.local.txt 15 | // Windows: C:\Users\(username)\AppData\Local\Arduino15\packages\espxxxx\hardware\espxxxx\{version}\platform.local.txt 16 | // Linux: ~/.arduino15/packages/espxxxx/hardware/espxxxx/{version}/platform.local.txt 17 | // 18 | // compiler.cpp.extra_flags=-DASYNCWEBSERVER_REGEX=1 19 | 20 | #include 21 | #ifdef ESP32 22 | #include 23 | #include 24 | #elif defined(ESP8266) 25 | #include 26 | #include 27 | #endif 28 | #include 29 | 30 | AsyncWebServer server(80); 31 | 32 | const char* ssid = "YOUR_SSID"; 33 | const char* password = "YOUR_PASSWORD"; 34 | 35 | const char* PARAM_MESSAGE = "message"; 36 | 37 | void notFound(AsyncWebServerRequest *request) { 38 | request->send(404, "text/plain", "Not found"); 39 | } 40 | 41 | void setup() { 42 | 43 | Serial.begin(115200); 44 | WiFi.mode(WIFI_STA); 45 | WiFi.begin(ssid, password); 46 | if (WiFi.waitForConnectResult() != WL_CONNECTED) { 47 | Serial.printf("WiFi Failed!\n"); 48 | return; 49 | } 50 | 51 | Serial.print("IP Address: "); 52 | Serial.println(WiFi.localIP()); 53 | 54 | server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){ 55 | request->send(200, "text/plain", "Hello, world"); 56 | }); 57 | 58 | // Send a GET request to /sensor/ 59 | server.on("^\\/sensor\\/([0-9]+)$", HTTP_GET, [] (AsyncWebServerRequest *request) { 60 | String sensorNumber = request->pathArg(0); 61 | request->send(200, "text/plain", "Hello, sensor: " + sensorNumber); 62 | }); 63 | 64 | // Send a GET request to /sensor//action/ 65 | server.on("^\\/sensor\\/([0-9]+)\\/action\\/([a-zA-Z0-9]+)$", HTTP_GET, [] (AsyncWebServerRequest *request) { 66 | String sensorNumber = request->pathArg(0); 67 | String action = request->pathArg(1); 68 | request->send(200, "text/plain", "Hello, sensor: " + sensorNumber + ", with action: " + action); 69 | }); 70 | 71 | server.onNotFound(notFound); 72 | 73 | server.begin(); 74 | } 75 | 76 | void loop() { 77 | } 78 | -------------------------------------------------------------------------------- /lib/ESPAsyncWebServer-esphome/examples/simple_server/simple_server.ino: -------------------------------------------------------------------------------- 1 | // 2 | // A simple server implementation showing how to: 3 | // * serve static messages 4 | // * read GET and POST parameters 5 | // * handle missing pages / 404s 6 | // 7 | 8 | #include 9 | #ifdef ESP32 10 | #include 11 | #include 12 | #elif defined(ESP8266) 13 | #include 14 | #include 15 | #endif 16 | #include 17 | 18 | AsyncWebServer server(80); 19 | 20 | const char* ssid = "YOUR_SSID"; 21 | const char* password = "YOUR_PASSWORD"; 22 | 23 | const char* PARAM_MESSAGE = "message"; 24 | 25 | void notFound(AsyncWebServerRequest *request) { 26 | request->send(404, "text/plain", "Not found"); 27 | } 28 | 29 | void setup() { 30 | 31 | Serial.begin(115200); 32 | WiFi.mode(WIFI_STA); 33 | WiFi.begin(ssid, password); 34 | if (WiFi.waitForConnectResult() != WL_CONNECTED) { 35 | Serial.printf("WiFi Failed!\n"); 36 | return; 37 | } 38 | 39 | Serial.print("IP Address: "); 40 | Serial.println(WiFi.localIP()); 41 | 42 | server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){ 43 | request->send(200, "text/plain", "Hello, world"); 44 | }); 45 | 46 | // Send a GET request to /get?message= 47 | server.on("/get", HTTP_GET, [] (AsyncWebServerRequest *request) { 48 | String message; 49 | if (request->hasParam(PARAM_MESSAGE)) { 50 | message = request->getParam(PARAM_MESSAGE)->value(); 51 | } else { 52 | message = "No message sent"; 53 | } 54 | request->send(200, "text/plain", "Hello, GET: " + message); 55 | }); 56 | 57 | // Send a POST request to /post with a form field message set to 58 | server.on("/post", HTTP_POST, [](AsyncWebServerRequest *request){ 59 | String message; 60 | if (request->hasParam(PARAM_MESSAGE, true)) { 61 | message = request->getParam(PARAM_MESSAGE, true)->value(); 62 | } else { 63 | message = "No message sent"; 64 | } 65 | request->send(200, "text/plain", "Hello, POST: " + message); 66 | }); 67 | 68 | server.onNotFound(notFound); 69 | 70 | server.begin(); 71 | } 72 | 73 | void loop() { 74 | } -------------------------------------------------------------------------------- /lib/ESPAsyncWebServer-esphome/keywords.txt: -------------------------------------------------------------------------------- 1 | JsonArray KEYWORD1 2 | add KEYWORD2 3 | createArray KEYWORD3 4 | -------------------------------------------------------------------------------- /lib/ESPAsyncWebServer-esphome/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name":"ESPAsyncWebServer-esphome", 3 | "description":"Asynchronous HTTP and WebSocket Server Library for ESP8266 and ESP32", 4 | "keywords":"http,async,websocket,webserver", 5 | "authors": 6 | { 7 | "name": "ESPHome Team", 8 | "maintainer": true 9 | }, 10 | "repository": 11 | { 12 | "type": "git", 13 | "url": "https://github.com/esphome/ESPAsyncWebServer.git" 14 | }, 15 | "version": "3.3.0", 16 | "license": "LGPL-3.0", 17 | "frameworks": "arduino", 18 | "platforms": ["espressif8266", "espressif32", "libretiny"], 19 | "dependencies": [ 20 | { 21 | "owner": "esphome", 22 | "name": "ESPAsyncTCP-esphome", 23 | "platforms": "espressif8266" 24 | }, 25 | { 26 | "owner": "mathieucarbou", 27 | "name": "AsyncTCP", 28 | "platforms": ["espressif32", "libretiny"] 29 | }, 30 | { 31 | "name": "Hash", 32 | "platforms": "espressif8266" 33 | }, 34 | { 35 | "name": "ESP8266WiFi", 36 | "platforms": "espressif8266" 37 | } 38 | ] 39 | } 40 | -------------------------------------------------------------------------------- /lib/ESPAsyncWebServer-esphome/src/AsyncWebSynchronization.h: -------------------------------------------------------------------------------- 1 | #ifndef ASYNCWEBSYNCHRONIZATION_H_ 2 | #define ASYNCWEBSYNCHRONIZATION_H_ 3 | 4 | // Synchronisation is only available on ESP32, as the ESP8266 isn't using FreeRTOS by default 5 | 6 | #include 7 | 8 | #if defined(ESP32) || (defined(LIBRETINY) && LT_HAS_FREERTOS) 9 | //#include "esp_private/freertos_debug.h" 10 | 11 | // This is the ESP32 version of the Sync Lock, using the FreeRTOS Semaphore 12 | class AsyncWebLock 13 | { 14 | private: 15 | SemaphoreHandle_t _lock; 16 | mutable void *_lockedBy; 17 | 18 | public: 19 | AsyncWebLock() { 20 | _lock = xSemaphoreCreateBinary(); 21 | _lockedBy = NULL; 22 | xSemaphoreGive(_lock); 23 | } 24 | 25 | ~AsyncWebLock() { 26 | vSemaphoreDelete(_lock); 27 | } 28 | #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0) 29 | bool lock() const { 30 | TaskHandle_t currentTask = xTaskGetCurrentTaskHandle(); 31 | if (_lockedBy != currentTask) { 32 | xSemaphoreTake(_lock, portMAX_DELAY); 33 | _lockedBy = currentTask; 34 | return true; 35 | } 36 | return false; 37 | } 38 | #else 39 | bool lock() const { 40 | extern void *pxCurrentTCB; 41 | if (_lockedBy != pxCurrentTCB) { 42 | xSemaphoreTake(_lock, portMAX_DELAY); 43 | _lockedBy = pxCurrentTCB; 44 | return true; 45 | } 46 | return false; 47 | } 48 | #endif 49 | 50 | void unlock() const { 51 | _lockedBy = NULL; 52 | xSemaphoreGive(_lock); 53 | } 54 | }; 55 | 56 | #else 57 | 58 | // This is the 8266 version of the Sync Lock which is currently unimplemented 59 | class AsyncWebLock 60 | { 61 | 62 | public: 63 | AsyncWebLock() { 64 | } 65 | 66 | ~AsyncWebLock() { 67 | } 68 | 69 | bool lock() const { 70 | return false; 71 | } 72 | 73 | void unlock() const { 74 | } 75 | }; 76 | #endif 77 | 78 | class AsyncWebLockGuard 79 | { 80 | private: 81 | const AsyncWebLock *_lock; 82 | 83 | public: 84 | AsyncWebLockGuard(const AsyncWebLock &l) { 85 | if (l.lock()) { 86 | _lock = &l; 87 | } else { 88 | _lock = NULL; 89 | } 90 | } 91 | 92 | ~AsyncWebLockGuard() { 93 | if (_lock) { 94 | _lock->unlock(); 95 | } 96 | } 97 | }; 98 | 99 | #endif // ASYNCWEBSYNCHRONIZATION_H_ 100 | -------------------------------------------------------------------------------- /lib/ESPAsyncWebServer-esphome/src/WebAuthentication.h: -------------------------------------------------------------------------------- 1 | /* 2 | Asynchronous WebServer library for Espressif MCUs 3 | 4 | Copyright (c) 2016 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 | 22 | #ifndef WEB_AUTHENTICATION_H_ 23 | #define WEB_AUTHENTICATION_H_ 24 | 25 | #include "Arduino.h" 26 | 27 | bool checkBasicAuthentication(const char * header, const char * username, const char * password); 28 | String requestDigestAuthentication(const char * realm); 29 | bool checkDigestAuthentication(const char * header, const char * method, const char * username, const char * password, const char * realm, bool passwordIsHash, const char * nonce, const char * opaque, const char * uri); 30 | 31 | //for storing hashed versions on the device that can be authenticated against 32 | String generateDigestHash(const char * username, const char * password, const char * realm); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /lib/LibAPRS_ESP32S3/CRC-CCIT.c: -------------------------------------------------------------------------------- 1 | #include "CRC-CCIT.h" 2 | 3 | const uint16_t crc_ccit_table[256] = { 4 | 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, 5 | 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, 6 | 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, 7 | 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, 8 | 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, 9 | 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, 10 | 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, 11 | 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, 12 | 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb, 13 | 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, 14 | 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, 15 | 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, 16 | 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, 17 | 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, 18 | 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, 19 | 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, 20 | 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, 21 | 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff, 22 | 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, 23 | 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, 24 | 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, 25 | 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, 26 | 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, 27 | 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, 28 | 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, 29 | 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, 30 | 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, 31 | 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, 32 | 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, 33 | 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, 34 | 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 35 | 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78, 36 | }; -------------------------------------------------------------------------------- /lib/LibAPRS_ESP32S3/CRC-CCIT.h: -------------------------------------------------------------------------------- 1 | // CRC-CCIT Implementation based on work by Francesco Sacchi 2 | 3 | #ifndef CRC_CCIT_H 4 | #define CRC_CCIT_H 5 | 6 | #include 7 | #include 8 | 9 | #define CRC_CCIT_INIT_VAL ((uint16_t)0xFFFF) 10 | 11 | extern const uint16_t crc_ccit_table[256]; 12 | 13 | inline uint16_t update_crc_ccit(uint8_t c, uint16_t prev_crc) { 14 | return (prev_crc >> 8) ^ pgm_read_word(&crc_ccit_table[(prev_crc ^ c) & 0xff]); 15 | } 16 | 17 | 18 | #endif -------------------------------------------------------------------------------- /lib/LibAPRS_ESP32S3/HDLC.h: -------------------------------------------------------------------------------- 1 | #ifndef PROTOCOL_HDLC_H 2 | #define PROTOCOL_HDLC_H 3 | 4 | #define HDLC_FLAG 0x7E 5 | #define HDLC_RESET 0x7F 6 | #define AX25_ESC 0x1B 7 | 8 | #endif -------------------------------------------------------------------------------- /lib/LibAPRS_ESP32S3/KISS.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "KISS.h" 6 | #include "ax25.h" 7 | 8 | size_t ctxbufflen; 9 | size_t frame_len = 0; 10 | uint8_t *ctxbuffer; 11 | 12 | static uint8_t serialBuffer[AX25_MAX_FRAME_LEN]; // Buffer for holding incoming serial data 13 | AX25Ctx testkiss; 14 | 15 | bool IN_FRAME; 16 | bool ESCAPE; 17 | 18 | uint8_t command = CMD_UNKNOWN; 19 | 20 | extern struct Ax25ProtoConfig Ax25Config; 21 | 22 | uint8_t p = 63; 23 | 24 | int kiss_wrapper(uint8_t *pkg, uint8_t *buf, size_t len) 25 | { 26 | uint8_t *ptr = pkg; 27 | int size = 0; 28 | *ptr++ = FEND; 29 | *ptr++ = 0x00; 30 | for (unsigned i = 0; i < len; i++) 31 | { 32 | uint8_t b = buf[i]; 33 | if (b == FEND) 34 | { 35 | *ptr++ = FESC; 36 | *ptr++ = TFEND; 37 | } 38 | else if (b == FESC) 39 | { 40 | *ptr++ = FESC; 41 | *ptr++ = TFESC; 42 | } 43 | else 44 | { 45 | *ptr++ = b; 46 | } 47 | } 48 | *ptr++ = FEND; 49 | size = ptr - pkg; 50 | return size; 51 | } 52 | 53 | void kiss_serial(uint8_t sbyte) 54 | { 55 | 56 | if (IN_FRAME && sbyte == FEND && command == CMD_DATA) 57 | { 58 | IN_FRAME = false; 59 | Ax25WriteTxFrame(serialBuffer, frame_len); 60 | } 61 | else if (sbyte == FEND) 62 | { 63 | IN_FRAME = true; 64 | command = CMD_UNKNOWN; 65 | frame_len = 0; 66 | } 67 | else if (IN_FRAME && frame_len < AX25_MAX_FRAME_LEN) 68 | { 69 | // Have a look at the command byte first 70 | if (frame_len == 0 && command == CMD_UNKNOWN) 71 | { 72 | // MicroModem supports only one HDLC port, so we 73 | // strip off the port nibble of the command byte 74 | sbyte = sbyte & 0x0F; 75 | command = sbyte; 76 | } 77 | else if (command == CMD_DATA) 78 | { 79 | if (sbyte == FESC) 80 | { 81 | ESCAPE = true; 82 | } 83 | else 84 | { 85 | if (ESCAPE) 86 | { 87 | if (sbyte == TFEND) 88 | sbyte = FEND; 89 | if (sbyte == TFESC) 90 | sbyte = FESC; 91 | ESCAPE = false; 92 | } 93 | serialBuffer[frame_len++] = sbyte; 94 | } 95 | } 96 | else if (command == CMD_TXDELAY) 97 | { 98 | Ax25Config.txDelayLength = sbyte * 10UL; 99 | } 100 | else if (command == CMD_TXTAIL) 101 | { 102 | Ax25Config.txTailLength = sbyte * 10; 103 | } 104 | else if (command == CMD_SLOTTIME) 105 | { 106 | Ax25Config.quietTime = sbyte * 10; 107 | } 108 | else if (command == CMD_P) 109 | { 110 | p = sbyte; 111 | } 112 | } 113 | } 114 | 115 | size_t kiss_parse(uint8_t *buf, uint8_t *raw, size_t len) 116 | { 117 | uint8_t sbyte = 0; 118 | size_t frame_len = 0; 119 | IN_FRAME = false; 120 | for (int i = 0; i < len; i++) 121 | { 122 | sbyte = raw[i]; 123 | if (IN_FRAME && sbyte == FEND && command == CMD_DATA) 124 | { 125 | IN_FRAME = false; 126 | return frame_len; 127 | } 128 | else if (sbyte == FEND) 129 | { 130 | IN_FRAME = true; 131 | command = CMD_UNKNOWN; 132 | frame_len = 0; 133 | } 134 | else if (IN_FRAME && frame_len < AX25_MAX_FRAME_LEN) 135 | { 136 | // Have a look at the command byte first 137 | if (frame_len == 0 && command == CMD_UNKNOWN) 138 | { 139 | // MicroModem supports only one HDLC port, so we 140 | // strip off the port nibble of the command byte 141 | sbyte = sbyte & 0x0F; 142 | command = sbyte; 143 | } 144 | else if (command == CMD_DATA) 145 | { 146 | if (sbyte == FESC) 147 | { 148 | ESCAPE = true; 149 | } 150 | else 151 | { 152 | if (ESCAPE) 153 | { 154 | if (sbyte == TFEND) 155 | sbyte = FEND; 156 | if (sbyte == TFESC) 157 | sbyte = FESC; 158 | ESCAPE = false; 159 | } 160 | serialBuffer[frame_len++] = sbyte; 161 | } 162 | } 163 | else if (command == CMD_TXDELAY) 164 | { 165 | Ax25Config.txDelayLength = sbyte * 10UL; 166 | } 167 | else if (command == CMD_TXTAIL) 168 | { 169 | Ax25Config.txTailLength = sbyte * 10; 170 | } 171 | else if (command == CMD_SLOTTIME) 172 | { 173 | Ax25Config.quietTime = sbyte * 10; 174 | } 175 | else if (command == CMD_P) 176 | { 177 | p = sbyte; 178 | } 179 | } 180 | } 181 | return frame_len; 182 | } -------------------------------------------------------------------------------- /lib/LibAPRS_ESP32S3/KISS.h: -------------------------------------------------------------------------------- 1 | #ifndef _PROTOCOL_KISS 2 | #define _PROTOCOL_KISS 0x02 3 | 4 | #include "AX25.h" 5 | #include "AFSK.h" 6 | 7 | #define FEND 0xC0 8 | #define FESC 0xDB 9 | #define TFEND 0xDC 10 | #define TFESC 0xDD 11 | 12 | #define CMD_UNKNOWN 0xFE 13 | #define CMD_DATA 0x00 14 | #define CMD_TXDELAY 0x01 15 | #define CMD_P 0x02 16 | #define CMD_SLOTTIME 0x03 17 | #define CMD_TXTAIL 0x04 18 | #define CMD_FULLDUPLEX 0x05 19 | #define CMD_SETHARDWARE 0x06 20 | #define CMD_RETURN 0xFF 21 | 22 | #define AX25_MAX_FRAME_LEN 329 23 | 24 | //void kiss_csma(AX25Ctx *ctx, uint8_t *buf, size_t len); 25 | int kiss_wrapper(uint8_t *pkg,uint8_t *buf,size_t len); 26 | void kiss_serial(uint8_t sbyte); 27 | size_t kiss_parse(uint8_t *buf,uint8_t *raw,size_t len); 28 | 29 | #endif -------------------------------------------------------------------------------- /lib/LibAPRS_ESP32S3/LibAPRSesp.h: -------------------------------------------------------------------------------- 1 | #ifndef _LIBAPRSESP_H 2 | #define _LIBAPRSESP_H 3 | #include "Arduino.h" 4 | #include 5 | #include 6 | 7 | #include "CRC-CCIT.h" 8 | #include "HDLC.h" 9 | #include "AFSK.h" 10 | #include "AX25.h" 11 | 12 | void APRS_init(); 13 | void APRS_poll(void); 14 | 15 | void APRS_setCallsign(char *call, int ssid); 16 | void APRS_setDestination(char *call, int ssid); 17 | void APRS_setMessageDestination(char *call, int ssid); 18 | void APRS_setPath1(char *call, int ssid); 19 | void APRS_setPath2(char *call, int ssid); 20 | 21 | void APRS_setPreamble(unsigned long pre); 22 | void APRS_setTail(unsigned long tail); 23 | void APRS_useAlternateSymbolTable(bool use); 24 | void APRS_setSymbol(char sym); 25 | 26 | void APRS_setLat(char *lat); 27 | void APRS_setLon(char *lon); 28 | void APRS_setPower(int s); 29 | void APRS_setHeight(int s); 30 | void APRS_setGain(int s); 31 | void APRS_setDirectivity(int s); 32 | 33 | void APRS_sendPkt(void *_buffer, size_t length); 34 | void APRS_sendLoc(void *_buffer, size_t length); 35 | void APRS_sendMsg(void *_buffer, size_t length); 36 | void APRS_msgRetry(); 37 | void APRS_sendRawPkt(uint8_t *raw, size_t length); 38 | 39 | void APRS_printSettings(); 40 | void APRS_sendTNC2Pkt(const uint8_t *raw, size_t length); 41 | 42 | void base91encode(long ltemp,char *s); 43 | long semicircles(char *degstr, char hemi); 44 | void telemetry_base91(char *cdata, char *output, size_t outputsize); 45 | 46 | int freeMemory(); 47 | #endif 48 | -------------------------------------------------------------------------------- /lib/LibAPRS_ESP32S3/fx25.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2023 Piotr Wilkon 3 | 4 | This file is part of VP-Digi. 5 | 6 | VP-Digi is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | VP-Digi 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 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with VP-Digi. If not, see . 18 | */ 19 | 20 | #ifdef ENABLE_FX25 21 | #include 22 | #include "fx25.h" 23 | #include 24 | #include "rs.h" 25 | 26 | #define FX25_RS_FCR 1 27 | 28 | #define FX25_PREGENERATE_POLYS 29 | #define FX25_MAX_DISTANCE 10 //maximum Hamming distance when comparing tags 30 | 31 | const struct Fx25Mode Fx25ModeList[11] = 32 | { 33 | {.tag = 0xB74DB7DF8A532F3E, .K = 239, .T = 16}, 34 | {.tag = 0x26FF60A600CC8FDE, .K = 128, .T = 16}, 35 | {.tag = 0xC7DC0508F3D9B09E, .K = 64, .T = 16}, 36 | {.tag = 0x8F056EB4369660EE, .K = 32, .T = 16}, 37 | {.tag = 0x6E260B1AC5835FAE, .K = 223, .T = 32}, 38 | {.tag = 0xFF94DC634F1CFF4E, .K = 128, .T = 32}, 39 | {.tag = 0x1EB7B9CDBC09C00E, .K = 64, .T = 32}, 40 | {.tag = 0xDBF869BD2DBB1776, .K = 32, .T = 32}, 41 | {.tag = 0x3ADB0C13DEAE2836, .K = 191, .T = 64}, 42 | {.tag = 0xAB69DB6A543188D6, .K = 128, .T = 64}, 43 | {.tag = 0x4A4ABEC4A724B796, .K = 64, .T = 64} 44 | }; 45 | 46 | 47 | 48 | const struct Fx25Mode* Fx25GetModeForTag(uint64_t tag) 49 | { 50 | for(uint8_t i = 0; i < sizeof(Fx25ModeList) / sizeof(*Fx25ModeList); i++) 51 | { 52 | if(__builtin_popcountll(tag ^ Fx25ModeList[i].tag) <= FX25_MAX_DISTANCE) 53 | return &Fx25ModeList[i]; 54 | } 55 | return NULL; 56 | } 57 | 58 | const struct Fx25Mode* Fx25GetModeForSize(uint16_t size) 59 | { 60 | //use "UZ7HO Soundmodem standard" for choosing FX.25 mode 61 | if(size <= 32) 62 | return &Fx25ModeList[3]; 63 | else if(size <= 64) 64 | return &Fx25ModeList[2]; 65 | else if(size <= 128) 66 | return &Fx25ModeList[5]; 67 | else if(size <= 191) 68 | return &Fx25ModeList[8]; 69 | else if(size <= 223) 70 | return &Fx25ModeList[4]; 71 | else if(size <= 239) 72 | return &Fx25ModeList[0]; 73 | else 74 | return NULL; //frame too big, do not use FX.25 75 | } 76 | 77 | #ifdef FX25_PREGENERATE_POLYS 78 | static struct LwFecRS rs16, rs32, rs64; 79 | #else 80 | static struct LwFecRS rs; 81 | #endif 82 | 83 | void Fx25Encode(uint8_t *buffer, const struct Fx25Mode *mode) 84 | { 85 | #ifdef FX25_PREGENERATE_POLYS 86 | struct LwFecRS *rs = NULL; 87 | switch(mode->T) 88 | { 89 | case 16: 90 | rs = &rs16; 91 | break; 92 | case 32: 93 | rs = &rs32; 94 | break; 95 | case 64: 96 | rs = &rs64; 97 | break; 98 | default: 99 | rs = &rs16; 100 | break; 101 | } 102 | RsEncode(rs, buffer, mode->K); 103 | #else 104 | RsInit(&rs, mode->T, FX25_RS_FCR); 105 | RsEncode(&rs, buffer, mode->K); 106 | #endif 107 | 108 | } 109 | 110 | bool Fx25Decode(uint8_t *buffer, const struct Fx25Mode *mode, uint8_t *fixed) 111 | { 112 | #ifdef FX25_PREGENERATE_POLYS 113 | struct LwFecRS *rs = NULL; 114 | switch(mode->T) 115 | { 116 | case 16: 117 | rs = &rs16; 118 | break; 119 | case 32: 120 | rs = &rs32; 121 | break; 122 | case 64: 123 | rs = &rs64; 124 | break; 125 | default: 126 | rs = &rs16; 127 | break; 128 | } 129 | return RsDecode(rs, buffer, mode->K, fixed); 130 | #else 131 | RsInit(&rs, mode->T, FX25_RS_FCR); 132 | return RsDecode(&rs, buffer, mode->K, fixed); 133 | #endif 134 | 135 | } 136 | 137 | void Fx25Init(void) 138 | { 139 | #ifdef FX25_PREGENERATE_POLYS 140 | RsInit(&rs16, 16, FX25_RS_FCR); 141 | RsInit(&rs32, 32, FX25_RS_FCR); 142 | RsInit(&rs64, 64, FX25_RS_FCR); 143 | #else 144 | #endif 145 | } 146 | 147 | #endif -------------------------------------------------------------------------------- /lib/LibAPRS_ESP32S3/fx25.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2023 Piotr Wilkon 3 | 4 | This file is part of VP-Digi. 5 | 6 | VP-Digi is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | VP-Digi 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 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with VP-Digi. If not, see . 18 | */ 19 | 20 | #ifndef FX25_H_ 21 | #define FX25_H_ 22 | 23 | #ifdef ENABLE_FX25 24 | 25 | #include 26 | #include 27 | 28 | #define FX25_MAX_BLOCK_SIZE 255 29 | 30 | struct Fx25Mode 31 | { 32 | uint64_t tag; //correlation tag 33 | uint16_t K; //data size 34 | uint8_t T; //parity check size 35 | }; 36 | 37 | extern const struct Fx25Mode Fx25ModeList[11]; 38 | 39 | /** 40 | * @brief Get FX.25 mode for given correlation tag 41 | * @param tag FX.25 correlation tag 42 | * @return FX.25 mode structure pointer or NULL if not a FX.25 tag 43 | */ 44 | const struct Fx25Mode* Fx25GetModeForTag(uint64_t tag); 45 | 46 | /** 47 | * @brief Get FX.25 mode for given payload size 48 | * @param size Payload size including flags and CRC 49 | * @return FX.25 mode structure pointer or NULL if standard AX.25 must be used 50 | */ 51 | const struct Fx25Mode* Fx25GetModeForSize(uint16_t size); 52 | 53 | /** 54 | * @brief Encode AX.25 message in FX.25 55 | * @param *buffer AX.25 message (bit-stuffed, with CRC and padding) 56 | * @param *mode FX.25 mode 57 | */ 58 | void Fx25Encode(uint8_t *buffer, const struct Fx25Mode *mode); 59 | 60 | /** 61 | * @brief Decode/fix FX.25 packet 62 | * @param *buffer Input buffer 63 | * @param *mode FX.25 mode 64 | * @param *fixed Number of bytes fixed 65 | * @return True if message is valid, false if uncorrectable 66 | */ 67 | bool Fx25Decode(uint8_t *buffer, const struct Fx25Mode *mode, uint8_t *fixed); 68 | 69 | /** 70 | * @brief Initialize FX.25 module 71 | */ 72 | void Fx25Init(void); 73 | 74 | #endif 75 | 76 | #endif /* FX25_H_ */ -------------------------------------------------------------------------------- /lib/LibAPRS_ESP32S3/gpio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * copyright (c) Espressif System 2010 3 | * 4 | */ 5 | 6 | #ifndef _GPIO_H_ 7 | #define _GPIO_H_ 8 | 9 | #define GPIO_PIN_ADDR(i) (GPIO_PIN0_ADDRESS + i*4) 10 | 11 | #define GPIO_ID_IS_PIN_REGISTER(reg_id) \ 12 | ((reg_id >= GPIO_ID_PIN0) && (reg_id <= GPIO_ID_PIN(GPIO_PIN_COUNT-1))) 13 | 14 | #define GPIO_REGID_TO_PINIDX(reg_id) ((reg_id) - GPIO_ID_PIN0) 15 | 16 | typedef enum { 17 | GPIO_PIN_INTR_DISABLE = 0, 18 | GPIO_PIN_INTR_POSEDGE = 1, 19 | GPIO_PIN_INTR_NEGEDGE = 2, 20 | GPIO_PIN_INTR_ANYEDGE = 3, 21 | GPIO_PIN_INTR_LOLEVEL = 4, 22 | GPIO_PIN_INTR_HILEVEL = 5 23 | } GPIO_INT_TYPE; 24 | 25 | #define GPIO_OUTPUT_SET(gpio_no, bit_value) \ 26 | gpio_output_set((bit_value)<>gpio_no)&BIT0) 29 | 30 | /* GPIO interrupt handler, registered through gpio_intr_handler_register */ 31 | typedef void (* gpio_intr_handler_fn_t)(uint32 intr_mask, void *arg); 32 | 33 | 34 | /* 35 | * Initialize GPIO. This includes reading the GPIO Configuration DataSet 36 | * to initialize "output enables" and pin configurations for each gpio pin. 37 | * Must be called once during startup. 38 | */ 39 | void gpio_init(void); 40 | 41 | /* 42 | * Change GPIO pin output by setting, clearing, or disabling pins. 43 | * In general, it is expected that a bit will be set in at most one 44 | * of these masks. If a bit is clear in all masks, the output state 45 | * remains unchanged. 46 | * 47 | * There is no particular ordering guaranteed; so if the order of 48 | * writes is significant, calling code should divide a single call 49 | * into multiple calls. 50 | */ 51 | void gpio_output_set(uint32 set_mask, 52 | uint32 clear_mask, 53 | uint32 enable_mask, 54 | uint32 disable_mask); 55 | 56 | /* 57 | * Sample the value of GPIO input pins and returns a bitmask. 58 | */ 59 | uint32 gpio_input_get(void); 60 | 61 | /* 62 | * Set the specified GPIO register to the specified value. 63 | * This is a very general and powerful interface that is not 64 | * expected to be used during normal operation. It is intended 65 | * mainly for debug, or for unusual requirements. 66 | */ 67 | void gpio_register_set(uint32 reg_id, uint32 value); 68 | 69 | /* Get the current value of the specified GPIO register. */ 70 | uint32 gpio_register_get(uint32 reg_id); 71 | 72 | /* 73 | * Register an application-specific interrupt handler for GPIO pin 74 | * interrupts. Once the interrupt handler is called, it will not 75 | * be called again until after a call to gpio_intr_ack. Any GPIO 76 | * interrupts that occur during the interim are masked. 77 | * 78 | * The application-specific handler is called with a mask of 79 | * pending GPIO interrupts. After processing pin interrupts, the 80 | * application-specific handler may wish to use gpio_intr_pending 81 | * to check for any additional pending interrupts before it returns. 82 | */ 83 | void gpio_intr_handler_register(gpio_intr_handler_fn_t fn, void *arg); 84 | 85 | /* Determine which GPIO interrupts are pending. */ 86 | uint32 gpio_intr_pending(void); 87 | 88 | /* 89 | * Acknowledge GPIO interrupts. 90 | * Intended to be called from the gpio_intr_handler_fn. 91 | */ 92 | void gpio_intr_ack(uint32 ack_mask); 93 | 94 | void gpio_pin_wakeup_enable(uint32 i, GPIO_INT_TYPE intr_state); 95 | 96 | void gpio_pin_wakeup_disable(); 97 | 98 | void gpio_pin_intr_state_set(uint32 i, GPIO_INT_TYPE intr_state); 99 | 100 | #endif // _GPIO_H_ 101 | -------------------------------------------------------------------------------- /lib/LibAPRS_ESP32S3/modem.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2023 Piotr Wilkon 3 | 4 | This file is part of VP-Digi. 5 | 6 | VP-Digi is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | VP-Digi 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 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with VP-Digi. If not, see . 18 | */ 19 | 20 | #ifndef DRIVERS_MODEM_H_ 21 | #define DRIVERS_MODEM_H_ 22 | 23 | #include 24 | 25 | //number of maximum parallel demodulators 26 | //each demodulator must be explicitly configured in code 27 | //currently used only for 1200 Bd modem 28 | #define MODEM_MAX_DEMODULATOR_COUNT 2 29 | 30 | enum ModemType 31 | { 32 | MODEM_1200 = 0, 33 | MODEM_1200_V23, 34 | MODEM_300, 35 | MODEM_9600, 36 | }; 37 | 38 | enum ModemTxTestMode 39 | { 40 | TEST_DISABLED, 41 | TEST_MARK, 42 | TEST_SPACE, 43 | TEST_ALTERNATING, 44 | }; 45 | 46 | 47 | struct ModemDemodConfig 48 | { 49 | enum ModemType modem; 50 | uint8_t usePWM : 1; //0 - use R2R, 1 - use PWM 51 | uint8_t flatAudioIn : 1; //0 - normal (deemphasized) audio input, 1 - flat audio (unfiltered) input 52 | }; 53 | 54 | extern struct ModemDemodConfig ModemConfig; 55 | 56 | enum ModemPrefilter 57 | { 58 | PREFILTER_NONE = 0, 59 | PREFILTER_PREEMPHASIS, 60 | PREFILTER_DEEMPHASIS, 61 | PREFILTER_FLAT, 62 | }; 63 | 64 | /** 65 | * @brief Get measured signal level 66 | * @param modem Modem number 67 | * @param *peak Output signal positive peak in % 68 | * @param *valley Output signal negative peak in % 69 | * @param *level Output signal level in % 70 | */ 71 | void ModemGetSignalLevel(uint8_t modem, int8_t *peak, int8_t *valley, uint8_t *level); 72 | 73 | /** 74 | * @brief Get current modem baudrate 75 | * @return Baudrate 76 | */ 77 | float ModemGetBaudrate(void); 78 | 79 | /** 80 | * @brief Get count of demodulators running in parallel 81 | * @return Count of demodulators 82 | */ 83 | uint8_t ModemGetDemodulatorCount(void); 84 | 85 | /** 86 | * @brief Get prefilter type (preemphasis, deemphasis etc.) for given modem 87 | * @param modem Modem number 88 | * @return Filter type 89 | */ 90 | enum ModemPrefilter ModemGetFilterType(uint8_t modem); 91 | 92 | /** 93 | * @brief Get current DCD state 94 | * @return 1 if channel busy, 0 if free 95 | */ 96 | uint8_t ModemDcdState(void); 97 | 98 | /** 99 | * @brief Check if there is a TX test mode enabled 100 | * @return 1 if in TX test mode, 0 otherwise 101 | */ 102 | uint8_t ModemIsTxTestOngoing(void); 103 | 104 | /** 105 | * @brief Clear modem RMS counter 106 | * @param number Modem number 107 | */ 108 | void ModemClearRMS(uint8_t number); 109 | 110 | /** 111 | * @brief Get RMS value for modem 112 | * @param number Modem number 113 | * @return RMS value 114 | */ 115 | uint16_t ModemGetRMS(uint8_t number); 116 | 117 | /** 118 | * @brief Start or restart TX test mode 119 | * @param type TX test type: TEST_MARK, TEST_SPACE or TEST_ALTERNATING 120 | */ 121 | void ModemTxTestStart(enum ModemTxTestMode type); 122 | 123 | 124 | /** 125 | * @brief Stop TX test mode 126 | */ 127 | void ModemTxTestStop(void); 128 | 129 | /** 130 | * @brief Configure and start TX 131 | * @info This function is used internally by protocol module. 132 | * @warning Use Ax25TransmitStart() to initialize transmission 133 | */ 134 | void ModemTransmitStart(void); 135 | 136 | 137 | /** 138 | * @brief Stop TX and go back to RX 139 | */ 140 | void ModemTransmitStop(void); 141 | 142 | 143 | /** 144 | * @brief Initialize modem module 145 | */ 146 | void ModemInit(void); 147 | 148 | void MODEM_DECODE(int16_t sample,uint16_t mVrms); 149 | uint8_t MODEM_BAUDRATE_TIMER_HANDLER(void); 150 | bool getDCD(void); 151 | 152 | #endif -------------------------------------------------------------------------------- /lib/LittleFS_esp32/.piopm: -------------------------------------------------------------------------------- 1 | {"type": "library", "name": "LittleFS_esp32", "version": "1.0.6", "spec": {"owner": "lorol", "id": 11164, "name": "LittleFS_esp32", "requirements": null, "uri": null}} -------------------------------------------------------------------------------- /lib/LittleFS_esp32/examples/LITTLEFS_PlatformIO/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | .vscode 3 | mklittlefs.exe 4 | mklittlefs -------------------------------------------------------------------------------- /lib/LittleFS_esp32/examples/LITTLEFS_PlatformIO/README.md: -------------------------------------------------------------------------------- 1 | # How to run on PlatformIO IDE 2 | 3 | - Download and extract to this project root a **mklittlefs** executable for your OS [from a zipped binary here](https://github.com/earlephilhower/mklittlefs/releases) 4 | - Open **LITTLEFS_PlatformIO** folder 5 | - Run PlatformIO project task: **Upload Filesystem Image** 6 | - Run PlatformIO project task: **Upload and Monitor** 7 | - You will see a Serial output like: 8 | ``` 9 | --- Miniterm on COM5 115200,8,N,1 --- 10 | --- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H --- 11 | ets Jun 8 2016 00:22:57 12 | 13 | rst:0x1 (POWERON_RESET),boot:0x13 (Snfigsip: 0, SPIWP:0xee 14 | clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 15 | mode:DIO, clock div:2 16 | load:0x3fff0018,len:4 17 | load:0x3fff001c,len:1044 18 | load:0x40078000,len:10044 19 | load:0x40080400,len:5872 20 | entry 0x400806ac 21 | Listing directory: / 22 | FILE: /file1.txt SIZE: 3 LAST WRITE: 2020-10-06 15:10:33 23 | DIR : /testfolder LAST WRITE: 2020-10-06 15:10:33 24 | Creating Dir: /mydir 25 | Dir created 26 | Writing file: /mydir/hello2.txt 27 | - file written 28 | Listing directory: / 29 | FILE: /file1.txt SIZE: 3 LAST WRITE: 2020-10-06 15:10:33 30 | DIR : /mydir LAST WRITE: 1970-01-01 00:00:00 31 | Listing directory: /mydir 32 | FILE: /mydir/hello2.txt SIZE: 6 LAST WRITE: 1970-01-01 00:00:00 33 | DIR : /testfolder LAST WRITE: 2020-10-06 15:10:33 34 | Listing directory: /testfolder 35 | FILE: /testfolder/test2.txt SIZE: 3 LAST WRITE: 2020-10-06 15:10:33 36 | Deleting file: /mydir/hello2.txt 37 | - file deleted 38 | Removing Dir: /mydir 39 | Dir removed 40 | Listing directory: / 41 | FILE: /file1.txt SIZE: 3 LAST WRITE: 2020-10-06 15:10:33 42 | DIR : /testfolder LAST WRITE: 2020-10-06 15:10:33 43 | Listing directory: /testfolder 44 | FILE: /testfolder/test2.txt SIZE: 3 LAST WRITE: 2020-10-06 15:10:33 45 | Writing file: /hello.txt 46 | - file written 47 | Appending to file: /hello.txt 48 | - message appended 49 | Reading file: /hello.txt 50 | - read from file: 51 | Hello World! 52 | Renaming file /hello.txt to /foo.txt 53 | - file renamed 54 | Reading file: /foo.txt 55 | - read from file: 56 | Hello World! 57 | Deleting file: /foo.txt 58 | - file deleted 59 | Testing file I/O with /test.txt 60 | - writing................................................................ 61 | - 1048576 bytes written in 12006 ms 62 | - reading................................................................ 63 | - 1048576 bytes read in 547 ms 64 | Deleting file: /test.txt 65 | - file deleted 66 | Test complete 67 | ``` 68 | - If you have a module with more than 4MB flash, you can uncomment **partitions_custom.csv** in **platformio.ini** and modify the csv file accordingly -------------------------------------------------------------------------------- /lib/LittleFS_esp32/examples/LITTLEFS_PlatformIO/data/file1.txt: -------------------------------------------------------------------------------- 1 | aaa -------------------------------------------------------------------------------- /lib/LittleFS_esp32/examples/LITTLEFS_PlatformIO/data/testfolder/test2.txt: -------------------------------------------------------------------------------- 1 | bbb -------------------------------------------------------------------------------- /lib/LittleFS_esp32/examples/LITTLEFS_PlatformIO/include/.placeholder.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/lib/LittleFS_esp32/examples/LITTLEFS_PlatformIO/include/.placeholder.txt -------------------------------------------------------------------------------- /lib/LittleFS_esp32/examples/LITTLEFS_PlatformIO/lib/.placeholder.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nakhonthai/ESP32APRS_T-TWR/605d0f3e7d09e79ad5a851683d02ee5de8017b28/lib/LittleFS_esp32/examples/LITTLEFS_PlatformIO/lib/.placeholder.txt -------------------------------------------------------------------------------- /lib/LittleFS_esp32/examples/LITTLEFS_PlatformIO/littlefsbuilder.py: -------------------------------------------------------------------------------- 1 | Import("env") 2 | env.Replace( MKSPIFFSTOOL=env.get("PROJECT_DIR") + '/mklittlefs' ) -------------------------------------------------------------------------------- /lib/LittleFS_esp32/examples/LITTLEFS_PlatformIO/partitions_custom.csv: -------------------------------------------------------------------------------- 1 | # Name, Type, SubType, Offset, Size, Flags 2 | ota_0, app, ota_0, 0x10000, 0x1A0000, 3 | ota_1, app, ota_1, , 0x1A0000, 4 | otadata, data, ota, 0x350000, 0x2000, 5 | nvs, data, nvs, , 0x6000, 6 | data, data, spiffs, , 0xA8000, 7 | -------------------------------------------------------------------------------- /lib/LittleFS_esp32/examples/LITTLEFS_PlatformIO/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter 4 | ; Upload options: custom upload port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; Advanced options: extra scripting 7 | ; 8 | ; Please visit documentation for the other options and examples 9 | ; https://docs.platformio.org/page/projectconf.html 10 | 11 | [platformio] 12 | default_envs = esp32 13 | 14 | [env] 15 | framework = arduino 16 | 17 | [env:esp32] 18 | platform = espressif32 19 | ;platform = https://github.com/platformio/platform-espressif32.git 20 | ;board_build.mcu = esp32 21 | platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git 22 | 23 | build_flags = 24 | ${env.build_flags} 25 | -D=${PIOENV} 26 | ;-D CONFIG_LITTLEFS_FOR_IDF_3_2 27 | 28 | lib_deps = https://github.com/lorol/LITTLEFS.git 29 | 30 | board = esp32dev 31 | ;board_build.partitions = partitions_custom.csv 32 | monitor_filters = esp32_exception_decoder 33 | monitor_speed = 115200 34 | 35 | extra_scripts = ./littlefsbuilder.py 36 | -------------------------------------------------------------------------------- /lib/LittleFS_esp32/examples/LITTLEFS_test/partitions.csv: -------------------------------------------------------------------------------- 1 | # Name, Type, SubType, Offset, Size, Flags 2 | nvs, data, nvs, 0x9000, 0x5000, 3 | otadata, data, ota, 0xe000, 0x2000, 4 | app0, app, ota_0, 0x10000, 0x100000, 5 | app1, app, ota_1, ,0x100000, 6 | spiffs, data, spiffs, ,0x1D0000, 7 | part2, data, spiffs, ,0x20000, 8 | #1048576 -------------------------------------------------------------------------------- /lib/LittleFS_esp32/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name":"LittleFS_esp32", 3 | "description":"LittleFS for esp32", 4 | "keywords":"littlefs, spiffs", 5 | "authors": 6 | { 7 | "name": "lorol", 8 | "maintainer": true 9 | }, 10 | "repository": 11 | { 12 | "type": "git", 13 | "url": "https://github.com/lorol/LITTLEFS.git" 14 | }, 15 | "version": "1.0.6", 16 | "license": "LGPL-2.0", 17 | "frameworks": "arduino", 18 | "platforms": "espressif32", 19 | "build": { 20 | "libCompatMode": 2 21 | } 22 | } -------------------------------------------------------------------------------- /lib/LittleFS_esp32/library.properties: -------------------------------------------------------------------------------- 1 | name=LittleFS_esp32 2 | version=1.0.6 3 | author=lorol 4 | maintainer=lorol 5 | sentence=LittleFS for esp32 based on esp_littlefs IDF component. Use esp32 core-provided LITTLEFS library instead of this one when available in future core releases. 6 | paragraph= For esp32 core 1.0.4 release, use #define CONFIG_LITTLEFS_FOR_IDF_3_2 and for more SPIFFS compatibility, set #define CONFIG_LITTLEFS_SPIFFS_COMPAT 1 7 | category=Data Storage 8 | url=https://github.com/lorol/LITTLEFS 9 | architectures=esp32 -------------------------------------------------------------------------------- /lib/LittleFS_esp32/src/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 Brian Pugh 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /lib/LittleFS_esp32/src/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017, Arm Limited. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without modification, 4 | are permitted provided that the following conditions are met: 5 | 6 | - Redistributions of source code must retain the above copyright notice, this 7 | list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright notice, this 9 | list of conditions and the following disclaimer in the documentation and/or 10 | other materials provided with the distribution. 11 | - Neither the name of ARM nor the names of its contributors may be used to 12 | endorse or promote products derived from this software without specific prior 13 | written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 19 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 22 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /lib/LittleFS_esp32/src/LITTLEFS.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2020 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 | 16 | 17 | #include "vfs_api.h" 18 | 19 | extern "C" { 20 | #include 21 | #include 22 | #include 23 | #include "esp_littlefs.h" 24 | } 25 | 26 | #include "LITTLEFS.h" 27 | 28 | using namespace fs; 29 | 30 | class LITTLEFSImpl : public VFSImpl 31 | { 32 | public: 33 | LITTLEFSImpl(); 34 | virtual ~LITTLEFSImpl() { } 35 | virtual bool exists(const char* path); 36 | }; 37 | 38 | LITTLEFSImpl::LITTLEFSImpl() 39 | { 40 | } 41 | 42 | bool LITTLEFSImpl::exists(const char* path) 43 | { 44 | File f = open(path, "r",false); 45 | return (f == true); 46 | } 47 | 48 | LITTLEFSFS::LITTLEFSFS() : FS(FSImplPtr(new LITTLEFSImpl())), partitionLabel_(NULL) 49 | { 50 | } 51 | 52 | LITTLEFSFS::~LITTLEFSFS() 53 | { 54 | if (partitionLabel_){ 55 | free(partitionLabel_); 56 | partitionLabel_ = NULL; 57 | } 58 | } 59 | 60 | bool LITTLEFSFS::begin(bool formatOnFail, const char * basePath, uint8_t maxOpenFiles, const char * partitionLabel) 61 | { 62 | 63 | if (partitionLabel_){ 64 | free(partitionLabel_); 65 | partitionLabel_ = NULL; 66 | } 67 | 68 | if (partitionLabel){ 69 | partitionLabel_ = strdup(partitionLabel); 70 | } 71 | 72 | if(esp_littlefs_mounted(partitionLabel_)){ 73 | log_w("LITTLEFS Already Mounted!"); 74 | return true; 75 | } 76 | 77 | esp_vfs_littlefs_conf_t conf = { 78 | .base_path = basePath, 79 | .partition_label = partitionLabel_, 80 | .format_if_mount_failed = false 81 | }; 82 | 83 | esp_err_t err = esp_vfs_littlefs_register(&conf); 84 | if(err == ESP_FAIL && formatOnFail){ 85 | if(format()){ 86 | err = esp_vfs_littlefs_register(&conf); 87 | } 88 | } 89 | if(err != ESP_OK){ 90 | log_e("Mounting LITTLEFS failed! Error: %d", err); 91 | return false; 92 | } 93 | _impl->mountpoint(basePath); 94 | return true; 95 | } 96 | 97 | void LITTLEFSFS::end() 98 | { 99 | if(esp_littlefs_mounted(partitionLabel_)){ 100 | esp_err_t err = esp_vfs_littlefs_unregister(partitionLabel_); 101 | if(err){ 102 | log_e("Unmounting LITTLEFS failed! Error: %d", err); 103 | return; 104 | } 105 | _impl->mountpoint(NULL); 106 | } 107 | } 108 | 109 | bool LITTLEFSFS::format() 110 | { 111 | disableCore0WDT(); 112 | esp_err_t err = esp_littlefs_format(partitionLabel_); 113 | enableCore0WDT(); 114 | if(err){ 115 | log_e("Formatting LITTLEFS failed! Error: %d", err); 116 | return false; 117 | } 118 | return true; 119 | } 120 | 121 | size_t LITTLEFSFS::totalBytes() 122 | { 123 | size_t total,used; 124 | if(esp_littlefs_info(partitionLabel_, &total, &used)){ 125 | return 0; 126 | } 127 | return total; 128 | } 129 | 130 | size_t LITTLEFSFS::usedBytes() 131 | { 132 | size_t total,used; 133 | if(esp_littlefs_info(partitionLabel_, &total, &used)){ 134 | return 0; 135 | } 136 | return used; 137 | } 138 | 139 | LITTLEFSFS LITTLEFS; 140 | 141 | -------------------------------------------------------------------------------- /lib/LittleFS_esp32/src/LITTLEFS.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2020 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 | #ifndef _LITTLEFS_H_ 15 | #define _LITTLEFS_H_ 16 | 17 | #include "FS.h" 18 | 19 | namespace fs 20 | { 21 | 22 | class LITTLEFSFS : public FS 23 | { 24 | public: 25 | LITTLEFSFS(); 26 | ~LITTLEFSFS(); 27 | bool begin(bool formatOnFail=false, const char * basePath="/littlefs", uint8_t maxOpenFiles=10, const char * partitionLabel="spiffs"); 28 | bool format(); 29 | size_t totalBytes(); 30 | size_t usedBytes(); 31 | void end(); 32 | 33 | private: 34 | char * partitionLabel_; 35 | }; 36 | 37 | } 38 | 39 | extern fs::LITTLEFSFS LITTLEFS; 40 | 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /lib/LittleFS_esp32/src/esp_littlefs.h: -------------------------------------------------------------------------------- 1 | #ifndef ESP_LITTLEFS_H__ 2 | #define ESP_LITTLEFS_H__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "freertos/FreeRTOS.h" 10 | #include "freertos/semphr.h" 11 | #include "esp_err.h" 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include "sdkconfig.h" 20 | 21 | #include "lfs.h" //#include "littlefs/lfs.h" 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** 28 | * @brief Last Modified Time 29 | * 30 | * Use 't' for LITTLEFS_ATTR_MTIME to match example: 31 | * https://github.com/ARMmbed/littlefs/issues/23#issuecomment-482293539 32 | * And to match other external tools such as: 33 | * https://github.com/earlephilhower/mklittlefs 34 | */ 35 | #define LITTLEFS_ATTR_MTIME ((uint8_t) 't') 36 | 37 | /** 38 | *Configuration structure for esp_vfs_littlefs_register. 39 | */ 40 | typedef struct { 41 | const char *base_path; /**< Mounting point. */ 42 | const char *partition_label; /**< Label of partition to use. */ 43 | uint8_t format_if_mount_failed:1; /**< Format the file system if it fails to mount. */ 44 | uint8_t dont_mount:1; /**< Don't attempt to mount or format. Overrides format_if_mount_failed */ 45 | } esp_vfs_littlefs_conf_t; 46 | 47 | /** 48 | * Register and mount littlefs to VFS with given path prefix. 49 | * 50 | * @param conf Pointer to esp_vfs_littlefs_conf_t configuration structure 51 | * 52 | * @return 53 | * - ESP_OK if success 54 | * - ESP_ERR_NO_MEM if objects could not be allocated 55 | * - ESP_ERR_INVALID_STATE if already mounted or partition is encrypted 56 | * - ESP_ERR_NOT_FOUND if partition for littlefs was not found 57 | * - ESP_FAIL if mount or format fails 58 | */ 59 | esp_err_t esp_vfs_littlefs_register(const esp_vfs_littlefs_conf_t * conf); 60 | 61 | /** 62 | * Unregister and unmount littlefs from VFS 63 | * 64 | * @param partition_label Label of the partition to unregister. 65 | * 66 | * @return 67 | * - ESP_OK if successful 68 | * - ESP_ERR_INVALID_STATE already unregistered 69 | */ 70 | esp_err_t esp_vfs_littlefs_unregister(const char* partition_label); 71 | 72 | /** 73 | * Check if littlefs is mounted 74 | * 75 | * @param partition_label Label of the partition to check. 76 | * 77 | * @return 78 | * - true if mounted 79 | * - false if not mounted 80 | */ 81 | bool esp_littlefs_mounted(const char* partition_label); 82 | 83 | /** 84 | * Format the littlefs partition 85 | * 86 | * @param partition_label Label of the partition to format. 87 | * @return 88 | * - ESP_OK if successful 89 | * - ESP_FAIL on error 90 | */ 91 | esp_err_t esp_littlefs_format(const char* partition_label); 92 | 93 | /** 94 | * Get information for littlefs 95 | * 96 | * @param partition_label Optional, label of the partition to get info for. 97 | * @param[out] total_bytes Size of the file system 98 | * @param[out] used_bytes Current used bytes in the file system 99 | * 100 | * @return 101 | * - ESP_OK if success 102 | * - ESP_ERR_INVALID_STATE if not mounted 103 | */ 104 | esp_err_t esp_littlefs_info(const char* partition_label, size_t *total_bytes, size_t *used_bytes); 105 | 106 | #if CONFIG_LITTLEFS_HUMAN_READABLE 107 | /** 108 | * @brief converts an enumerated lfs error into a string. 109 | * @param lfs_errno The enumerated littlefs error. 110 | */ 111 | const char * esp_littlefs_errno(enum lfs_error lfs_errno); 112 | #endif 113 | 114 | #ifdef __cplusplus 115 | } // extern "C" 116 | #endif 117 | 118 | #endif 119 | -------------------------------------------------------------------------------- /lib/LittleFS_esp32/src/lfs_util.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lfs util functions 3 | * 4 | * Copyright (c) 2017, Arm Limited. All rights reserved. 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | #include "lfs_util.h" 8 | 9 | // Only compile if user does not provide custom config 10 | #ifndef LFS_CONFIG 11 | 12 | 13 | // Software CRC implementation with small lookup table 14 | uint32_t lfs_crc(uint32_t crc, const void *buffer, size_t size) { 15 | static const uint32_t rtable[16] = { 16 | 0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 17 | 0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c, 18 | 0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c, 19 | 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c, 20 | }; 21 | 22 | const uint8_t *data = buffer; 23 | 24 | for (size_t i = 0; i < size; i++) { 25 | crc = (crc >> 4) ^ rtable[(crc ^ (data[i] >> 0)) & 0xf]; 26 | crc = (crc >> 4) ^ rtable[(crc ^ (data[i] >> 4)) & 0xf]; 27 | } 28 | 29 | return crc; 30 | } 31 | 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /lib/LittleFS_esp32/src/littlefs_api.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file littlefs_api.c 3 | * @brief Maps the HAL of esp_partition <-> littlefs 4 | * @author Brian Pugh 5 | */ 6 | 7 | #define ESP_LOCAL_LOG_LEVEL ESP_LOG_INFO 8 | 9 | #include "esp_log.h" 10 | #include "esp_partition.h" 11 | #include "esp_vfs.h" 12 | #include "lfs.h" 13 | #include "esp_littlefs.h" 14 | #include "littlefs_api.h" 15 | 16 | static const char TAG[] = "esp_littlefs_api"; 17 | 18 | int littlefs_api_read(const struct lfs_config *c, lfs_block_t block, 19 | lfs_off_t off, void *buffer, lfs_size_t size) { 20 | esp_littlefs_t * efs = c->context; 21 | size_t part_off = (block * c->block_size) + off; 22 | esp_err_t err = esp_partition_read(efs->partition, part_off, buffer, size); 23 | if (err) { 24 | ESP_LOGE(TAG, "failed to read addr %08x, size %08x, err %d", part_off, size, err); 25 | return LFS_ERR_IO; 26 | } 27 | return 0; 28 | } 29 | 30 | int littlefs_api_prog(const struct lfs_config *c, lfs_block_t block, 31 | lfs_off_t off, const void *buffer, lfs_size_t size) { 32 | esp_littlefs_t * efs = c->context; 33 | size_t part_off = (block * c->block_size) + off; 34 | esp_err_t err = esp_partition_write(efs->partition, part_off, buffer, size); 35 | if (err) { 36 | ESP_LOGE(TAG, "failed to write addr %08x, size %08x, err %d", part_off, size, err); 37 | return LFS_ERR_IO; 38 | } 39 | return 0; 40 | } 41 | 42 | int littlefs_api_erase(const struct lfs_config *c, lfs_block_t block) { 43 | esp_littlefs_t * efs = c->context; 44 | size_t part_off = block * c->block_size; 45 | esp_err_t err = esp_partition_erase_range(efs->partition, part_off, c->block_size); 46 | if (err) { 47 | ESP_LOGE(TAG, "failed to erase addr %08x, size %08x, err %d", part_off, c->block_size, err); 48 | return LFS_ERR_IO; 49 | } 50 | return 0; 51 | 52 | } 53 | 54 | int littlefs_api_sync(const struct lfs_config *c) { 55 | /* Unnecessary for esp-idf */ 56 | return 0; 57 | } 58 | 59 | -------------------------------------------------------------------------------- /lib/LittleFS_esp32/src/littlefs_api.h: -------------------------------------------------------------------------------- 1 | #ifndef ESP_LITTLEFS_API_H__ 2 | #define ESP_LITTLEFS_API_H__ 3 | 4 | #include 5 | #include 6 | #include "freertos/FreeRTOS.h" 7 | #include "freertos/task.h" 8 | #include "freertos/semphr.h" 9 | #include "esp_vfs.h" 10 | #include "esp_partition.h" 11 | #include "lfs.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /** 18 | * @brief a file descriptor 19 | * That's also a singly linked list used for keeping tracks of all opened file descriptor 20 | * 21 | * Shortcomings/potential issues of 32-bit hash (when CONFIG_LITTLEFS_USE_ONLY_HASH) listed here: 22 | * * unlink - If a different file is open that generates a hash collision, it will report an 23 | * error that it cannot unlink an open file. 24 | * * rename - If a different file is open that generates a hash collision with 25 | * src or dst, it will report an error that it cannot rename an open file. 26 | * Potential consequences: 27 | * 1. A file cannot be deleted while a collision-geneating file is open. 28 | * Worst-case, if the other file is always open during the lifecycle 29 | * of your app, it's collision file cannot be deleted, which in the 30 | * worst-case could cause storage-capacity issues. 31 | * 2. Same as (1), but for renames 32 | */ 33 | typedef struct _vfs_littlefs_file_t { 34 | lfs_file_t file; 35 | uint32_t hash; 36 | struct _vfs_littlefs_file_t * next; /*!< Pointer to next file in Singly Linked List */ 37 | #ifndef CONFIG_LITTLEFS_USE_ONLY_HASH 38 | char * path; 39 | #endif 40 | } vfs_littlefs_file_t; 41 | 42 | /** 43 | * @brief littlefs definition structure 44 | */ 45 | typedef struct { 46 | lfs_t *fs; /*!< Handle to the underlying littlefs */ 47 | SemaphoreHandle_t lock; /*!< FS lock */ 48 | const esp_partition_t* partition; /*!< The partition on which littlefs is located */ 49 | char base_path[ESP_VFS_PATH_MAX+1]; /*!< Mount point */ 50 | 51 | struct lfs_config cfg; /*!< littlefs Mount configuration */ 52 | 53 | vfs_littlefs_file_t *file; /*!< Singly Linked List of files */ 54 | 55 | vfs_littlefs_file_t **cache; /*!< A cache of pointers to the opened files */ 56 | uint16_t cache_size; /*!< The cache allocated size (in pointers) */ 57 | uint16_t fd_count; /*!< The count of opened file descriptor used to speed up computation */ 58 | } esp_littlefs_t; 59 | 60 | /** 61 | * @brief Read a region in a block. 62 | * 63 | * Negative error codes are propogated to the user. 64 | * 65 | * @return errorcode. 0 on success. 66 | */ 67 | int littlefs_api_read(const struct lfs_config *c, lfs_block_t block, 68 | lfs_off_t off, void *buffer, lfs_size_t size); 69 | 70 | /** 71 | * @brief Program a region in a block. 72 | * 73 | * The block must have previously been erased. 74 | * Negative error codes are propogated to the user. 75 | * May return LFS_ERR_CORRUPT if the block should be considered bad. 76 | * 77 | * @return errorcode. 0 on success. 78 | */ 79 | int littlefs_api_prog(const struct lfs_config *c, lfs_block_t block, 80 | lfs_off_t off, const void *buffer, lfs_size_t size); 81 | 82 | /** 83 | * @brief Erase a block. 84 | * 85 | * A block must be erased before being programmed. 86 | * The state of an erased block is undefined. 87 | * Negative error codes are propogated to the user. 88 | * May return LFS_ERR_CORRUPT if the block should be considered bad. 89 | * @return errorcode. 0 on success. 90 | */ 91 | int littlefs_api_erase(const struct lfs_config *c, lfs_block_t block); 92 | 93 | /** 94 | * @brief Sync the state of the underlying block device. 95 | * 96 | * Negative error codes are propogated to the user. 97 | * 98 | * @return errorcode. 0 on success. 99 | */ 100 | int littlefs_api_sync(const struct lfs_config *c); 101 | 102 | #ifdef __cplusplus 103 | } 104 | #endif 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /lib/MenuSystem/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | 6 | # Compiled Dynamic libraries 7 | *.so 8 | *.dylib 9 | 10 | # Compiled Static libraries 11 | *.lai 12 | *.la 13 | *.a 14 | 15 | # Vim 16 | *~ 17 | *.swp 18 | *.swo 19 | 20 | # arduino-mk 21 | **/build-* 22 | -------------------------------------------------------------------------------- /lib/MenuSystem/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Jon Black 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 13 | all 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 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /lib/MenuSystem/README.md: -------------------------------------------------------------------------------- 1 | # menusystem 2 | 3 | An arduino library for implementing a menu system. 4 | 5 | ## Documentation 6 | 7 | Other than the examples included in the library, the following pages might be 8 | useful to you: 9 | 10 | * [Arduino forum post](http://arduino.cc/forum/index.php/topic,105866.0.html) 11 | * [Humble Coder](http://www.humblecoder.com/) 12 | * [Arduino Menu System Library](http://blog.humblecoder.com/arduino-menu-system-library/) 13 | * [Animated LED matrix menu transitions on the Arduino](http://blog.humblecoder.com/animated-led-matrix-menu-transitions-on-the-arduino/) 14 | 15 | ## Contribution 16 | 17 | If you'd like to contribute to `arduino-menusystem`, please submit a 18 | pull-request. 19 | 20 | ## Changelog 21 | 22 | **2.1.1 - 22/03/2016** 23 | 24 | * Fix regression - add reset option to select 25 | 26 | **2.1.0 - 20/03/2016** 27 | 28 | * Fix bug resetting the menu. Now possible via `reset()` 29 | 30 | **2.0.2 - 23/01/2016** 31 | 32 | * Fix deprecated conversion from string constant to char* 33 | * Add Sure Electronics animated LED matrix example 34 | 35 | **2.0.1 - 16/08/2015** 36 | 37 | * Add Sure Electronics LED Matrix example 38 | 39 | **2.0.0 - 14/08/2015** 40 | 41 | * Add LCD Nav Keypad example from (thanks to @SauleVire) 42 | * Remove AUTHORS file: too much hassle to maintain 43 | * Add library.properties 44 | 45 | **1.0.1 - 20/13/2013** 46 | 47 | * Renamed project to `arduino-menusystem`; 48 | * Fix buffer overflow when adding a menu; 49 | * Menu components are now dynamically allocated (previously it was fixed at 50 | five items). 51 | 52 | **1.0.0 - 15/12/2013** 53 | 54 | * Selected menu item can be remembered (thanks to @KipK) 55 | * Examples for serial and LCDs (thanks to @niesteszeck) 56 | * Add AUTHORS file 57 | 58 | **0.3.0 - 23/03/2013** 59 | 60 | * Merged in another minor improvement provided by @thomasjfox: 61 | * Add the ability to loop through a menu in `prev()` and `next()` 62 | 63 | **0.2.0 - 18/03/2013** 64 | 65 | * Merged in minor improvements provided by thomasjfox 66 | * `get_menu_component()`: Use 'byte' instead of 16bit integer for index 67 | * Add return value to `MenuSystem.back()` 68 | * Prevent memory corruption by inserting too many items 69 | * Whitespace cleanup 70 | 71 | **0.1.0 - 25/05/2012** 72 | 73 | * Added support for displaying all current menu items (thanks to arcachofo) 74 | * Added this readme 75 | 76 | Note: The changes made for this release break backwards compatability. The 77 | issues are relatively easy to fix. 78 | -------------------------------------------------------------------------------- /lib/MenuSystem/examples/current_item/Makefile: -------------------------------------------------------------------------------- 1 | ARDUINO_DIR = $(HOME)/.arduino_ide 2 | ARDUINO_LIBS = arduino-menusystem 3 | ARDMK_DIR = $(HOME)/.arduino_mk 4 | BOARD_TAG = uno 5 | 6 | CXXFLAGS_STD += -std=gnu++11 7 | 8 | include $(ARDMK_DIR)/Arduino.mk 9 | -------------------------------------------------------------------------------- /lib/MenuSystem/examples/current_item/current_item.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * current_item.ino - Example code using the menu system library. 3 | * 4 | * This example shows only the current menu item. 5 | * 6 | * Copyright (c) 2015 arduino-menusystem 7 | * Licensed under the MIT license (see LICENSE) 8 | */ 9 | 10 | #include 11 | 12 | // renderer 13 | 14 | class MyRenderer : public MenuComponentRenderer 15 | { 16 | public: 17 | virtual void render(Menu const& menu) const 18 | { 19 | menu.get_current_component()->render(*this); 20 | } 21 | 22 | virtual void render_menu_item(MenuItem const& menu_item) const 23 | { 24 | Serial.println(menu_item.get_name()); 25 | } 26 | 27 | virtual void render_back_menu_item(BackMenuItem const& menu_item) const 28 | { 29 | Serial.println(menu_item.get_name()); 30 | } 31 | 32 | virtual void render_numeric_menu_item(NumericMenuItem const& menu_item) const 33 | { 34 | Serial.println(menu_item.get_name()); 35 | } 36 | 37 | virtual void render_menu(Menu const& menu) const 38 | { 39 | Serial.println(menu.get_name()); 40 | } 41 | }; 42 | MyRenderer my_renderer; 43 | 44 | // forward declarations 45 | 46 | void on_item1_selected(MenuItem* p_menu_item); 47 | void on_item2_selected(MenuItem* p_menu_item); 48 | void on_item3_selected(MenuItem* p_menu_item); 49 | void on_item4_selected(MenuItem* p_menu_item); 50 | 51 | // Menu variables 52 | 53 | MenuSystem ms(my_renderer); 54 | 55 | MenuItem mm_mi1("Level 1 - Item 1 (Item)", &on_item1_selected); 56 | MenuItem mm_mi2("Level 1 - Item 2 (Item)", &on_item2_selected); 57 | Menu mu1("Level 1 - Item 3 (Menu)"); 58 | MenuItem mu1_mi1("Level 2 - Item 1 (Item)", &on_item3_selected); 59 | MenuItem mu1_mi2("Level 2 - Item 2 (Item)", &on_item4_selected); 60 | 61 | // Menu callback function 62 | 63 | bool bRanCallback = false; 64 | 65 | void on_item1_selected(MenuItem* p_menu_item) 66 | { 67 | Serial.println("Item1 Selected"); 68 | bRanCallback = true; 69 | } 70 | 71 | void on_item2_selected(MenuItem* p_menu_item) 72 | { 73 | Serial.println("Item2 Selected"); 74 | bRanCallback = true; 75 | } 76 | 77 | void on_item3_selected(MenuItem* p_menu_item) 78 | { 79 | Serial.println("Item3 Selected"); 80 | bRanCallback = true; 81 | } 82 | 83 | void on_item4_selected(MenuItem* p_menu_item) 84 | { 85 | Serial.println("Item4 Selected"); 86 | bRanCallback = false; 87 | ms.reset(); 88 | } 89 | 90 | // Standard arduino functions 91 | 92 | void setup() 93 | { 94 | Serial.begin(9600); 95 | 96 | ms.get_root_menu().add_item(&mm_mi1); 97 | ms.get_root_menu().add_item(&mm_mi2); 98 | ms.get_root_menu().add_menu(&mu1); 99 | mu1.add_item(&mu1_mi1); 100 | mu1.add_item(&mu1_mi2); 101 | } 102 | 103 | void loop() 104 | { 105 | ms.display(); 106 | ms.select(); 107 | if (bRanCallback) 108 | { 109 | ms.next(); 110 | bRanCallback = false; 111 | } 112 | delay(2000); 113 | } 114 | -------------------------------------------------------------------------------- /lib/MenuSystem/examples/current_menu/Makefile: -------------------------------------------------------------------------------- 1 | ARDUINO_DIR = $(HOME)/.arduino_ide 2 | ARDUINO_LIBS = arduino-menusystem 3 | ARDMK_DIR = $(HOME)/.arduino_mk 4 | BOARD_TAG = uno 5 | 6 | CXXFLAGS_STD += -std=gnu++11 7 | 8 | include $(ARDMK_DIR)/Arduino.mk 9 | -------------------------------------------------------------------------------- /lib/MenuSystem/examples/current_menu/current_menu.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * current_menu.ino - Example code using the menu system library. 3 | * 4 | * This example shows all items in the current menu. 5 | * 6 | * Copyright (c) 2015 arduino-menusystem 7 | * Licensed under the MIT license (see LICENSE) 8 | */ 9 | 10 | #include 11 | 12 | // renderer 13 | 14 | class MyRenderer : public MenuComponentRenderer 15 | { 16 | public: 17 | virtual void render(Menu const& menu) const 18 | { 19 | Serial.println(""); 20 | for (int i = 0; i < menu.get_num_components(); ++i) 21 | { 22 | MenuComponent const* cp_m_comp = menu.get_menu_component(i); 23 | cp_m_comp->render(*this); 24 | 25 | if (cp_m_comp->is_current()) 26 | Serial.print("<<< "); 27 | Serial.println(""); 28 | } 29 | } 30 | 31 | virtual void render_menu_item(MenuItem const& menu_item) const 32 | { 33 | Serial.print(menu_item.get_name()); 34 | } 35 | 36 | virtual void render_back_menu_item(BackMenuItem const& menu_item) const 37 | { 38 | Serial.print(menu_item.get_name()); 39 | } 40 | 41 | virtual void render_numeric_menu_item(NumericMenuItem const& menu_item) const 42 | { 43 | Serial.print(menu_item.get_name()); 44 | } 45 | 46 | virtual void render_menu(Menu const& menu) const 47 | { 48 | Serial.print(menu.get_name()); 49 | } 50 | }; 51 | MyRenderer my_renderer; 52 | 53 | // forward declarations 54 | 55 | void on_item1_selected(MenuItem* p_menu_item); 56 | void on_item2_selected(MenuItem* p_menu_item); 57 | void on_item3_selected(MenuItem* p_menu_item); 58 | 59 | // Menu variables 60 | 61 | MenuSystem ms(my_renderer); 62 | 63 | MenuItem mm_mi1("Level 1 - Item 1 (Item)", &on_item1_selected); 64 | MenuItem mm_mi2("Level 1 - Item 2 (Item)", &on_item2_selected); 65 | Menu mu1("Level 1 - Item 3 (Menu)"); 66 | MenuItem mu1_mi1("Level 2 - Item 1 (Item)", &on_item3_selected); 67 | 68 | // Menu callback function 69 | 70 | bool done = false; 71 | 72 | void on_item1_selected(MenuItem* p_menu_item) 73 | { 74 | Serial.println("Item1 Selected"); 75 | } 76 | 77 | void on_item2_selected(MenuItem* p_menu_item) 78 | { 79 | Serial.println("Item2 Selected"); 80 | } 81 | 82 | void on_item3_selected(MenuItem* p_menu_item) 83 | { 84 | Serial.println("Item3 Selected"); 85 | done = true; 86 | } 87 | 88 | // Standard arduino functions 89 | 90 | void setup() 91 | { 92 | Serial.begin(9600); 93 | 94 | ms.get_root_menu().add_item(&mm_mi1); 95 | ms.get_root_menu().add_item(&mm_mi2); 96 | ms.get_root_menu().add_menu(&mu1); 97 | mu1.add_item(&mu1_mi1); 98 | } 99 | 100 | void loop() 101 | { 102 | ms.display(); 103 | 104 | // Simulate using the menu by walking over the entire structure. 105 | ms.select(); 106 | ms.next(); 107 | 108 | if (done) 109 | { 110 | ms.reset(); 111 | done = false; 112 | } 113 | 114 | delay(2000); 115 | } 116 | -------------------------------------------------------------------------------- /lib/MenuSystem/examples/lcd_nav/Makefile: -------------------------------------------------------------------------------- 1 | ARDUINO_DIR = $(HOME)/.arduino_ide 2 | ARDUINO_LIBS = arduino-menusystem LiquidCrystal 3 | ARDMK_DIR = $(HOME)/.arduino_mk 4 | BOARD_TAG = uno 5 | 6 | CXXFLAGS_STD += -std=gnu++11 7 | 8 | include $(ARDMK_DIR)/Arduino.mk 9 | -------------------------------------------------------------------------------- /lib/MenuSystem/examples/lcd_nav/lcd_nav.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * lcd_nav.ino - Example code using the menu system library 3 | * 4 | * This example shows using the menu system with a 16x2 LCD display 5 | * (controled over serial). 6 | * 7 | * Copyright (c) 2015 arduino-menusystem 8 | * Licensed under the MIT license (see LICENSE) 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | // renderer 15 | 16 | // The LCD circuit: 17 | // * LCD RS pin to digital pin 8 18 | // * LCD Enable pin to digital pin 9 19 | // * LCD D4 pin to digital pin 4 20 | // * LCD D5 pin to digital pin 5 21 | // * LCD D6 pin to digital pin 6 22 | // * LCD D7 pin to digital pin 7 23 | // * LCD R/W pin to ground 24 | LiquidCrystal lcd = LiquidCrystal(8, 9, 4, 5, 6, 7); 25 | 26 | class MyRenderer : public MenuComponentRenderer 27 | { 28 | public: 29 | virtual void render(Menu const& menu) const 30 | { 31 | lcd.clear(); 32 | lcd.setCursor(0,0); 33 | lcd.print(menu.get_name()); 34 | lcd.setCursor(0,1); 35 | menu.get_current_component()->render(*this); 36 | } 37 | 38 | virtual void render_menu_item(MenuItem const& menu_item) const 39 | { 40 | lcd.print(menu_item.get_name()); 41 | } 42 | 43 | virtual void render_back_menu_item(BackMenuItem const& menu_item) const 44 | { 45 | lcd.print(menu_item.get_name()); 46 | } 47 | 48 | virtual void render_numeric_menu_item(NumericMenuItem const& menu_item) const 49 | { 50 | lcd.print(menu_item.get_name()); 51 | } 52 | 53 | virtual void render_menu(Menu const& menu) const 54 | { 55 | lcd.print(menu.get_name()); 56 | } 57 | }; 58 | MyRenderer my_renderer; 59 | 60 | // Forward declarations 61 | 62 | void on_item1_selected(MenuItem* p_menu_item); 63 | void on_item2_selected(MenuItem* p_menu_item); 64 | void on_item3_selected(MenuItem* p_menu_item); 65 | 66 | // Menu variables 67 | 68 | MenuSystem ms(my_renderer); 69 | MenuItem mm_mi1("Level 1 - Item 1 (Item)", &on_item1_selected); 70 | MenuItem mm_mi2("Level 1 - Item 2 (Item)", &on_item2_selected); 71 | Menu mu1("Level 1 - Item 3 (Menu)"); 72 | MenuItem mu1_mi1("Level 2 - Item 1 (Item)", on_item3_selected); 73 | 74 | // Menu callback function 75 | 76 | void on_item1_selected(MenuItem* p_menu_item) 77 | { 78 | lcd.setCursor(0,1); 79 | lcd.print("Item1 Selected "); 80 | delay(1500); // so we can look the result on the LCD 81 | } 82 | 83 | void on_item2_selected(MenuItem* p_menu_item) 84 | { 85 | lcd.setCursor(0,1); 86 | lcd.print("Item2 Selected "); 87 | delay(1500); // so we can look the result on the LCD 88 | } 89 | 90 | void on_item3_selected(MenuItem* p_menu_item) 91 | { 92 | lcd.setCursor(0,1); 93 | lcd.print("Item3 Selected "); 94 | delay(1500); // so we can look the result on the LCD 95 | } 96 | 97 | void serialPrintHelp() { 98 | Serial.println("***************"); 99 | Serial.println("w: go to previus item (up)"); 100 | Serial.println("s: go to next item (down)"); 101 | Serial.println("a: go back (right)"); 102 | Serial.println("d: select \"selected\" item"); 103 | Serial.println("?: print this help"); 104 | Serial.println("h: print this help"); 105 | Serial.println("***************"); 106 | } 107 | 108 | void serialHandler() { 109 | char inChar; 110 | if((inChar = Serial.read())>0) { 111 | switch (inChar) { 112 | case 'w': // Previus item 113 | ms.prev(); 114 | ms.display(); 115 | break; 116 | case 's': // Next item 117 | ms.next(); 118 | ms.display(); 119 | break; 120 | case 'a': // Back presed 121 | ms.back(); 122 | ms.display(); 123 | break; 124 | case 'd': // Select presed 125 | ms.select(); 126 | ms.display(); 127 | break; 128 | case '?': 129 | case 'h': // Display help 130 | serialPrintHelp(); 131 | break; 132 | default: 133 | break; 134 | } 135 | } 136 | } 137 | 138 | // Standard arduino functions 139 | 140 | void setup() 141 | { 142 | Serial.begin(9600); 143 | lcd.begin(16, 2); 144 | 145 | serialPrintHelp(); 146 | 147 | ms.get_root_menu().add_item(&mm_mi1); 148 | ms.get_root_menu().add_item(&mm_mi2); 149 | ms.get_root_menu().add_menu(&mu1); 150 | mu1.add_item(&mu1_mi1); 151 | 152 | ms.display(); 153 | } 154 | 155 | void loop() 156 | { 157 | serialHandler(); 158 | } 159 | -------------------------------------------------------------------------------- /lib/MenuSystem/examples/led_matrix/Makefile: -------------------------------------------------------------------------------- 1 | ARDUINO_DIR = $(HOME)/.arduino_ide 2 | ARDUINO_LIBS = arduino-menusystem arduino-ht1632c 3 | ARDMK_DIR = $(HOME)/.arduino_mk 4 | BOARD_TAG = uno 5 | 6 | CXXFLAGS_STD += -std=gnu++11 7 | 8 | include $(ARDMK_DIR)/Arduino.mk 9 | -------------------------------------------------------------------------------- /lib/MenuSystem/examples/led_matrix/README.md: -------------------------------------------------------------------------------- 1 | This example depends on the arduino-ht1632c library which can be found at 2 | https://github.com/jonblack/ht1632c. This is a fork of 3 | https://github.com/wildstray/ht1632c with some fixes applied. 4 | -------------------------------------------------------------------------------- /lib/MenuSystem/examples/led_matrix/led_matrix.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * current_item.ino - Example code using the menu system library. 3 | * 4 | * This example demonstrates using the library with a Sure Electronics 32x16 5 | * LED matrix. 6 | * 7 | * Copyright (c) 2015 arduino-menusystem 8 | * Licensed under the MIT license (see LICENSE) 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | // Display constants 15 | 16 | #define PIN_LED_DATA 0 17 | #define PIN_LED_WR 3 18 | #define PIN_LED_CLOCK 5 19 | #define PIN_LED_CS 4 20 | 21 | // Renderer 22 | 23 | ht1632c ledMatrix = ht1632c(&PORTB, PIN_LED_DATA, PIN_LED_WR, PIN_LED_CLOCK, PIN_LED_CS, GEOM_32x16, 2); 24 | 25 | class MyRenderer : public MenuComponentRenderer 26 | { 27 | public: 28 | MyRenderer() 29 | : _led_height(16), 30 | _led_width(32), 31 | _font_width(5), 32 | _font_height(7), 33 | _color(RED) 34 | { 35 | } 36 | 37 | virtual void render(Menu const& menu) const 38 | { 39 | ledMatrix.clear(); 40 | MenuComponent const* cp_m_comp = menu.get_current_component(); 41 | cp_m_comp->render(*this); 42 | } 43 | 44 | virtual void render_menu_item(MenuItem const& menu_item) const 45 | { 46 | char const* name = menu_item.get_name(); 47 | _render_text_center(name); 48 | } 49 | 50 | virtual void render_back_menu_item(BackMenuItem const& menu_item) const 51 | { 52 | char const* name = menu_item.get_name(); 53 | _render_text_center(name); 54 | } 55 | 56 | virtual void render_numeric_menu_item(NumericMenuItem const& menu_item) const 57 | { 58 | char const* name = menu_item.get_name(); 59 | _render_text_center(name); 60 | } 61 | 62 | virtual void render_menu(Menu const& menu) const 63 | { 64 | char const* name = menu.get_name(); 65 | _render_text_center(name); 66 | } 67 | 68 | private: 69 | void _render_text_center(char const* name) const 70 | { 71 | uint8_t x_idnt = _get_x_indent(name); 72 | uint8_t y_idnt = _get_y_indent(); 73 | 74 | for (size_t i = 0; i < strlen(name); i++) 75 | ledMatrix.putchar((i * _font_width) + x_idnt, y_idnt, name[i], _color); 76 | ledMatrix.sendframe(); 77 | } 78 | 79 | uint8_t _get_x_indent(char const* name) const 80 | { 81 | uint8_t text_width = _font_width * strlen(name); 82 | uint8_t pixel_spare = _led_width - text_width; 83 | return (uint8_t) floor(pixel_spare / 2); 84 | } 85 | 86 | uint8_t _get_y_indent() const 87 | { 88 | return (_led_width/ 2) - (_led_height / 2); 89 | } 90 | 91 | private: 92 | const uint8_t _led_height; 93 | const uint8_t _led_width; 94 | const uint8_t _font_width; 95 | const uint8_t _font_height; 96 | const uint8_t _color; 97 | }; 98 | MyRenderer my_renderer; 99 | 100 | // Menu callback functions 101 | 102 | void on_time_selected(MenuItem* p_menu_item) 103 | { 104 | Serial.println("Time selected"); 105 | } 106 | 107 | void on_date_selected(MenuItem* p_menu_item) 108 | { 109 | Serial.println("Date selected"); 110 | } 111 | 112 | void on_brightness_selected(MenuItem* p_menu_item) 113 | { 114 | Serial.println("Brightness selected"); 115 | } 116 | 117 | void on_color_selected(MenuItem* p_menu_item) 118 | { 119 | Serial.println("Color selected"); 120 | } 121 | 122 | // Menu variables 123 | 124 | MenuSystem ms(my_renderer); 125 | MenuItem mi_time("TIME", &on_time_selected); 126 | MenuItem mi_date("DATE", &on_date_selected); 127 | Menu mu_disp("DISP*"); 128 | MenuItem mi_brightness("BRTNS", &on_brightness_selected); 129 | MenuItem mi_color("COLOR", &on_color_selected); 130 | 131 | // Functions 132 | 133 | void serial_handler() 134 | { 135 | char inChar; 136 | if ((inChar = Serial.read()) > 0) 137 | { 138 | switch (inChar) 139 | { 140 | case 'w': // Previus item 141 | ms.prev(); 142 | ms.display(); 143 | break; 144 | case 's': // Next item 145 | ms.next(); 146 | ms.display(); 147 | break; 148 | case 'a': // Back presed 149 | ms.back(); 150 | ms.display(); 151 | break; 152 | case 'd': // Select presed 153 | ms.select(); 154 | ms.display(); 155 | break; 156 | default: 157 | break; 158 | } 159 | } 160 | } 161 | 162 | // Standard arduino functions 163 | 164 | void setup() { 165 | Serial.begin(9600); 166 | 167 | ledMatrix.clear(); 168 | ledMatrix.setfont(FONT_5x7); 169 | 170 | ms.get_root_menu().add_item(&mi_time); 171 | ms.get_root_menu().add_item(&mi_date); 172 | ms.get_root_menu().add_menu(&mu_disp); 173 | mu_disp.add_item(&mi_brightness); 174 | mu_disp.add_item(&mi_color); 175 | ms.display(); 176 | } 177 | 178 | void loop() { 179 | serial_handler(); 180 | } 181 | -------------------------------------------------------------------------------- /lib/MenuSystem/examples/led_matrix_animated/Makefile: -------------------------------------------------------------------------------- 1 | ARDUINO_DIR = $(HOME)/.arduino_ide 2 | ARDUINO_LIBS = arduino-menusystem arduino-ht1632c 3 | ARDMK_DIR = $(HOME)/.arduino_mk 4 | BOARD_TAG = uno 5 | 6 | CXXFLAGS_STD += -std=gnu++11 7 | 8 | include $(ARDMK_DIR)/Arduino.mk 9 | -------------------------------------------------------------------------------- /lib/MenuSystem/examples/led_matrix_animated/README.md: -------------------------------------------------------------------------------- 1 | This example depends on the arduino-ht1632c library which can be found at 2 | https://github.com/jonblack/ht1632c. This is a fork of 3 | https://github.com/wildstray/ht1632c with some fixes applied. 4 | -------------------------------------------------------------------------------- /lib/MenuSystem/examples/pcd8544_nav/Makefile: -------------------------------------------------------------------------------- 1 | ARDUINO_DIR = $(HOME)/.arduino_ide 2 | ARDUINO_LIBS = Adafruit_GFX_Library Adafruit_PCD8544_Nokia_5110_LCD_library \ 3 | arduino-menusystem SPI 4 | ARDMK_DIR = $(HOME)/.arduino_mk 5 | BOARD_TAG = uno 6 | 7 | CXXFLAGS_STD += -std=gnu++11 8 | 9 | include $(ARDMK_DIR)/Arduino.mk 10 | -------------------------------------------------------------------------------- /lib/MenuSystem/examples/pcd8544_nav/pcd8544_nav.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * pcd8544_nav.ino - Example code using the menu system library 3 | * 4 | * This example shows using the menu system with a pcd8544 LCD display 5 | * (controlled over serial). 6 | * 7 | * Copyright (c) 2016 arduino-menusystem 8 | * Licensed under the MIT license (see LICENSE) 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #define PCD8544_CHAR_HEIGHT 8 17 | 18 | // LCD 19 | 20 | // Software SPI (slower updates, more flexible pin options): 21 | // pin 7 - Serial clock out (SCLK) 22 | // pin 6 - Serial data out (DIN) 23 | // pin 5 - Data/Command select (D/C) 24 | // pin 4 - LCD chip select (CS) 25 | // pin 3 - LCD reset (RST) 26 | //Adafruit_PCD8544 lcd = Adafruit_PCD8544(7, 6, 5, 4, 3); 27 | 28 | // Hardware SPI (faster, but must use certain hardware pins): 29 | // SCK is LCD serial clock (SCLK) - this is pin 13 on Arduino Uno 30 | // MOSI is LCD DIN - this is pin 11 on an Arduino Uno 31 | // pin 5 - Data/Command select (D/C) 32 | // pin 4 - LCD chip select (CS) 33 | // pin 3 - LCD reset (RST) 34 | Adafruit_PCD8544 lcd = Adafruit_PCD8544(5, 4, 3); 35 | // Note with hardware SPI MISO and SS pins aren't used but will still be read 36 | // and written to during SPI transfer. Be careful sharing these pins! 37 | 38 | // Renderer 39 | 40 | class MyRenderer : public MenuComponentRenderer 41 | { 42 | public: 43 | virtual void render(Menu const& menu) const 44 | { 45 | lcd.clearDisplay(); 46 | menu.render(*this); 47 | menu.get_current_component()->render(*this); 48 | lcd.display(); 49 | } 50 | 51 | virtual void render_menu_item(MenuItem const& menu_item) const 52 | { 53 | lcd.setCursor(0, 1 * PCD8544_CHAR_HEIGHT); 54 | lcd.print(menu_item.get_name()); 55 | } 56 | 57 | virtual void render_back_menu_item(BackMenuItem const& menu_item) const 58 | { 59 | lcd.setCursor(0, 1 * PCD8544_CHAR_HEIGHT); 60 | lcd.print(menu_item.get_name()); 61 | } 62 | 63 | virtual void render_numeric_menu_item(NumericMenuItem const& menu_item) const 64 | { 65 | lcd.setCursor(0, 1 * PCD8544_CHAR_HEIGHT); 66 | lcd.print(menu_item.get_name()); 67 | } 68 | 69 | virtual void render_menu(Menu const& menu) const 70 | { 71 | lcd.setCursor(0, 0 * PCD8544_CHAR_HEIGHT); 72 | lcd.print(menu.get_name()); 73 | } 74 | }; 75 | MyRenderer my_renderer; 76 | 77 | // Menu callback function 78 | 79 | void on_item1_selected(MenuItem* p_menu_item) 80 | { 81 | lcd.setCursor(0, 2 * PCD8544_CHAR_HEIGHT); 82 | lcd.print("Item1 Selectd"); 83 | lcd.display(); 84 | delay(1500); // so we can look the result on the LCD 85 | } 86 | 87 | void on_item2_selected(MenuItem* p_menu_item) 88 | { 89 | lcd.setCursor(0, 2 * PCD8544_CHAR_HEIGHT); 90 | lcd.print("Item2 Selectd"); 91 | lcd.display(); 92 | delay(1500); // so we can look the result on the LCD 93 | } 94 | 95 | void on_item3_selected(MenuItem* p_menu_item) 96 | { 97 | lcd.setCursor(0, 2 * PCD8544_CHAR_HEIGHT); 98 | lcd.print("Item3 Selectd"); 99 | lcd.display(); 100 | delay(1500); // so we can look the result on the LCD 101 | } 102 | 103 | 104 | // Menu variables 105 | 106 | MenuSystem ms(my_renderer); 107 | MenuItem mm_mi1("Lvl1-Item1(I)", &on_item1_selected); 108 | MenuItem mm_mi2("Lvl1-Item2(I)", &on_item2_selected); 109 | Menu mu1("Lvl1-Item3(M)"); 110 | MenuItem mu1_mi1("Lvl2-Item1(I)", &on_item3_selected); 111 | 112 | void serialPrintHelp() { 113 | Serial.println("***************"); 114 | Serial.println("w: go to previus item (up)"); 115 | Serial.println("s: go to next item (down)"); 116 | Serial.println("a: go back (right)"); 117 | Serial.println("d: select \"selected\" item"); 118 | Serial.println("?: print this help"); 119 | Serial.println("h: print this help"); 120 | Serial.println("***************"); 121 | } 122 | 123 | void serialHandler() { 124 | char inChar; 125 | if((inChar = Serial.read())>0) { 126 | switch (inChar) { 127 | case 'w': // Previus item 128 | ms.prev(); 129 | ms.display(); 130 | break; 131 | case 's': // Next item 132 | ms.next(); 133 | ms.display(); 134 | break; 135 | case 'a': // Back pressed 136 | ms.back(); 137 | ms.display(); 138 | break; 139 | case 'd': // Select pressed 140 | ms.select(); 141 | ms.display(); 142 | break; 143 | case '?': 144 | case 'h': // Display help 145 | serialPrintHelp(); 146 | break; 147 | default: 148 | break; 149 | } 150 | } 151 | } 152 | 153 | // Standard arduino functions 154 | 155 | void setup() 156 | { 157 | Serial.begin(9600); 158 | 159 | lcd.begin(); 160 | lcd.setContrast(60); 161 | 162 | #ifdef HIDE_SPLASH 163 | lcd.clearDisplay(); 164 | #else 165 | lcd.display(); 166 | delay(2000); 167 | #endif 168 | 169 | lcd.setTextSize(1); 170 | 171 | serialPrintHelp(); 172 | 173 | ms.get_root_menu().add_item(&mm_mi1); 174 | ms.get_root_menu().add_item(&mm_mi2); 175 | ms.get_root_menu().add_menu(&mu1); 176 | mu1.add_item(&mu1_mi1); 177 | ms.display(); 178 | } 179 | 180 | void loop() 181 | { 182 | serialHandler(); 183 | } 184 | -------------------------------------------------------------------------------- /lib/MenuSystem/examples/serial_nav/CustomNumericMenuItem.cpp: -------------------------------------------------------------------------------- 1 | #include "CustomNumericMenuItem.h" 2 | 3 | CustomNumericMenuItem::CustomNumericMenuItem( 4 | uint8_t width, const char* name, float value, float minValue, 5 | float maxValue, float increment, FormatValueFnPtr on_format_value) 6 | : NumericMenuItem(name, nullptr, value, minValue, maxValue, increment, 7 | on_format_value), 8 | _width(width) 9 | { 10 | } 11 | 12 | uint8_t CustomNumericMenuItem::get_width() const 13 | { 14 | return _width; 15 | } 16 | 17 | void CustomNumericMenuItem::render(MenuComponentRenderer const& renderer) const 18 | { 19 | MyRenderer const& my_renderer = static_cast(renderer); 20 | my_renderer.render_custom_numeric_menu_item(*this); 21 | } 22 | -------------------------------------------------------------------------------- /lib/MenuSystem/examples/serial_nav/CustomNumericMenuItem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * An example of a custom NumericMenuItem. 3 | * It tries to display some ASCII graphics in edit mode. 4 | * This can be useful if you want to give the end user an overview of the value limits. 5 | * 6 | * Copyright (c) 2016 arduino-menusystem 7 | * Licensed under the MIT license (see LICENSE) 8 | */ 9 | 10 | #ifndef _CUSTOMNUMERICMENUITEM_H 11 | #define _CUSTOMNUMERICMENUITEM_H 12 | 13 | #include 14 | #include "MyRenderer.h" 15 | 16 | class MyRenderer; 17 | 18 | class CustomNumericMenuItem : public NumericMenuItem 19 | { 20 | public: 21 | /** 22 | * @param width the width of the edit mode 'ASCII graphics', must be > 1 23 | * @param name The name of the menu item. 24 | * @param value Default value. 25 | * @param minValue The minimum value. 26 | * @param maxValue The maximum value. 27 | * @param increment How much the value should be incremented by. 28 | * @param valueFormatter The custom formatter. If nullptr the String float 29 | * formatter will be used. 30 | */ 31 | CustomNumericMenuItem(uint8_t width, const char* name, float value, 32 | float minValue, float maxValue, float increment=1.0, 33 | FormatValueFnPtr on_format_value=nullptr); 34 | 35 | uint8_t get_width() const; 36 | 37 | virtual void render(MenuComponentRenderer const& renderer) const; 38 | 39 | private: 40 | const uint8_t _width; 41 | }; 42 | 43 | #endif // _CUSTOMNUMERICMENUITEM_H 44 | -------------------------------------------------------------------------------- /lib/MenuSystem/examples/serial_nav/Makefile: -------------------------------------------------------------------------------- 1 | ARDUINO_DIR = $(HOME)/.arduino_ide 2 | ARDUINO_LIBS = arduino-menusystem 3 | ARDMK_DIR = $(HOME)/.arduino_mk 4 | BOARD_TAG = uno 5 | 6 | CXXFLAGS_STD += -std=gnu++11 7 | 8 | include $(ARDMK_DIR)/Arduino.mk 9 | -------------------------------------------------------------------------------- /lib/MenuSystem/examples/serial_nav/MyRenderer.cpp: -------------------------------------------------------------------------------- 1 | #include "MyRenderer.h" 2 | 3 | void MyRenderer::render(Menu const& menu) const 4 | { 5 | Serial.print("\nCurrent menu name: "); 6 | Serial.println(menu.get_name()); 7 | String buffer; 8 | for (int i = 0; i < menu.get_num_components(); ++i) 9 | { 10 | MenuComponent const* cp_m_comp = menu.get_menu_component(i); 11 | cp_m_comp->render(*this); 12 | 13 | if (cp_m_comp->is_current()) 14 | Serial.print("<<< "); 15 | Serial.println(""); 16 | } 17 | } 18 | 19 | void MyRenderer::render_menu_item(MenuItem const& menu_item) const 20 | { 21 | Serial.print(menu_item.get_name()); 22 | } 23 | 24 | void MyRenderer::render_back_menu_item(BackMenuItem const& menu_item) const 25 | { 26 | Serial.print(menu_item.get_name()); 27 | } 28 | 29 | void MyRenderer::render_numeric_menu_item(NumericMenuItem const& menu_item) const 30 | { 31 | String buffer; 32 | 33 | buffer = menu_item.get_name(); 34 | buffer += menu_item.has_focus() ? '<' : '='; 35 | buffer += menu_item.get_value_string(); 36 | 37 | if (menu_item.has_focus()) 38 | buffer += '>'; 39 | 40 | Serial.print(buffer); 41 | } 42 | 43 | void MyRenderer::render_custom_numeric_menu_item(CustomNumericMenuItem const& menu_item) const 44 | { 45 | // This condition can be put in the CustomNumericMenuItem class as well 46 | if (menu_item.has_focus()) 47 | { 48 | // Only display the ASCII graphics in edit mode. 49 | 50 | String buffer; 51 | 52 | // make room for a ' ' at the end and the terminating 0 53 | char graphics[menu_item.get_width() + 2]; 54 | 55 | // fill the string with '-' 56 | for (int i = 0; i < menu_item.get_width(); i++) 57 | graphics[i] = '-'; 58 | 59 | // insert a '|' at the relative _value position 60 | graphics[int( 61 | (menu_item.get_width() - 1) * 62 | (menu_item.get_value() - menu_item.get_minValue()) / 63 | (menu_item.get_maxValue() - menu_item.get_minValue()) 64 | )] = '|'; 65 | graphics[menu_item.get_width()] = ' '; 66 | graphics[menu_item.get_width() + 1] = 0; 67 | buffer = graphics; 68 | 69 | buffer += menu_item.get_value(); 70 | 71 | Serial.println(buffer); 72 | } 73 | else 74 | { 75 | // Non edit mode: Let parent class handle this 76 | return render_numeric_menu_item(menu_item); 77 | } 78 | } 79 | 80 | void MyRenderer::render_menu(Menu const& menu) const 81 | { 82 | Serial.print(menu.get_name()); 83 | } 84 | -------------------------------------------------------------------------------- /lib/MenuSystem/examples/serial_nav/MyRenderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * An example of a custom NumericMenuItem. 3 | * It tries to display some ASCII graphics in edit mode. 4 | * This can be useful if you want to give the end user an overview of the value limits. 5 | * 6 | * Copyright (c) 2016 arduino-menusystem 7 | * Licensed under the MIT license (see LICENSE) 8 | */ 9 | 10 | #ifndef _MY_RENDERER_H 11 | #define _MY_RENDERER_H 12 | 13 | #include 14 | #include "CustomNumericMenuItem.h" 15 | 16 | class CustomNumericMenuItem; 17 | 18 | class MyRenderer : public MenuComponentRenderer 19 | { 20 | public: 21 | virtual void render(Menu const& menu) const; 22 | virtual void render_menu_item(MenuItem const& menu_item) const; 23 | virtual void render_back_menu_item(BackMenuItem const& menu_item) const; 24 | virtual void render_numeric_menu_item(NumericMenuItem const& menu_item) const; 25 | virtual void render_custom_numeric_menu_item(CustomNumericMenuItem const& menu_item) const; 26 | virtual void render_menu(Menu const& menu) const; 27 | }; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /lib/MenuSystem/examples/serial_nav/serial_nav.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * serial_nav.ino - Example code using the menu system library 3 | * 4 | * This example shows the menu system being controlled over the serial port. 5 | * 6 | * Copyright (c) 2015, 2016 arduino-menusystem 7 | * Licensed under the MIT license (see LICENSE) 8 | */ 9 | 10 | #include 11 | #include "CustomNumericMenuItem.h" 12 | #include "MyRenderer.h" 13 | 14 | // forward declarations 15 | const String format_float(const float value); 16 | const String format_int(const float value); 17 | const String format_color(const float value); 18 | void on_item1_selected(MenuItem* p_menu_item); 19 | void on_item2_selected(MenuItem* p_menu_item); 20 | void on_item3_selected(MenuItem* p_menu_item); 21 | void on_back_item_selected(MenuItem* p_menu_item); 22 | 23 | // Menu variables 24 | 25 | MyRenderer my_renderer; 26 | MenuSystem ms(my_renderer); 27 | 28 | MenuItem mm_mi1("Level 1 - Item 1 (Item)", &on_item1_selected); 29 | MenuItem mm_mi2("Level 1 - Item 2 (Item)", &on_item2_selected); 30 | Menu mu1("Level 1 - Item 3 (Menu)"); 31 | BackMenuItem mu1_mi0("Level 2 - Back (Item)", &on_back_item_selected, &ms); 32 | MenuItem mu1_mi1("Level 2 - Item 1 (Item)", &on_item3_selected); 33 | NumericMenuItem mu1_mi2("Level 2 - Txt Item 2 (Item)", nullptr, 0, 0, 2, 1, format_color); 34 | CustomNumericMenuItem mu1_mi3(12, "Level 2 - Cust Item 3 (Item)", 80, 65, 121, 3, format_int); 35 | NumericMenuItem mm_mi4("Level 1 - Float Item 4 (Item)", nullptr, 0.5, 0.0, 1.0, 0.1, format_float); 36 | NumericMenuItem mm_mi5("Level 1 - Int Item 5 (Item)", nullptr, 50, -100, 100, 1, format_int); 37 | 38 | // Menu callback function 39 | 40 | // writes the (int) value of a float into a char buffer. 41 | const String format_int(const float value) 42 | { 43 | return String((int) value); 44 | } 45 | 46 | // writes the value of a float into a char buffer. 47 | const String format_float(const float value) 48 | { 49 | return String(value); 50 | } 51 | 52 | // writes the value of a float into a char buffer as predefined colors. 53 | const String format_color(const float value) 54 | { 55 | String buffer; 56 | 57 | switch((int) value) 58 | { 59 | case 0: 60 | buffer += "Red"; 61 | break; 62 | case 1: 63 | buffer += "Green"; 64 | break; 65 | case 2: 66 | buffer += "Blue"; 67 | break; 68 | default: 69 | buffer += "undef"; 70 | } 71 | 72 | return buffer; 73 | } 74 | 75 | // In this example all menu items use the same callback. 76 | 77 | void on_item1_selected(MenuItem* p_menu_item) 78 | { 79 | Serial.println("Item1 Selected"); 80 | } 81 | 82 | void on_item2_selected(MenuItem* p_menu_item) 83 | { 84 | Serial.println("Item2 Selected"); 85 | } 86 | 87 | void on_item3_selected(MenuItem* p_menu_item) 88 | { 89 | Serial.println("Item3 Selected"); 90 | } 91 | 92 | void on_back_item_selected(MenuItem* p_menu_item) 93 | { 94 | Serial.println("Back item Selected"); 95 | } 96 | 97 | void display_help() { 98 | Serial.println("***************"); 99 | Serial.println("w: go to previus item (up)"); 100 | Serial.println("s: go to next item (down)"); 101 | Serial.println("a: go back (right)"); 102 | Serial.println("d: select \"selected\" item"); 103 | Serial.println("?: print this help"); 104 | Serial.println("h: print this help"); 105 | Serial.println("***************"); 106 | } 107 | 108 | void serial_handler() 109 | { 110 | char inChar; 111 | if ((inChar = Serial.read()) > 0) 112 | { 113 | switch (inChar) 114 | { 115 | case 'w': // Previus item 116 | ms.prev(); 117 | ms.display(); 118 | Serial.println(""); 119 | break; 120 | case 's': // Next item 121 | ms.next(); 122 | ms.display(); 123 | Serial.println(""); 124 | break; 125 | case 'a': // Back presed 126 | ms.back(); 127 | ms.display(); 128 | Serial.println(""); 129 | break; 130 | case 'd': // Select presed 131 | ms.select(); 132 | ms.display(); 133 | Serial.println(""); 134 | break; 135 | case '?': 136 | case 'h': // Display help 137 | ms.display(); 138 | Serial.println(""); 139 | break; 140 | default: 141 | break; 142 | } 143 | } 144 | } 145 | 146 | // Standard arduino functions 147 | 148 | void setup() 149 | { 150 | Serial.begin(9600); 151 | 152 | ms.get_root_menu().add_item(&mm_mi1); 153 | ms.get_root_menu().add_item(&mm_mi2); 154 | ms.get_root_menu().add_menu(&mu1); 155 | mu1.add_item(&mu1_mi0); 156 | mu1.add_item(&mu1_mi1); 157 | mu1.add_item(&mu1_mi2); 158 | mu1.add_item(&mu1_mi3); 159 | ms.get_root_menu().add_item(&mm_mi4); 160 | ms.get_root_menu().add_item(&mm_mi5); 161 | 162 | display_help(); 163 | ms.display(); 164 | Serial.println(""); 165 | } 166 | 167 | void loop() 168 | { 169 | serial_handler(); 170 | } 171 | -------------------------------------------------------------------------------- /lib/MenuSystem/keywords.txt: -------------------------------------------------------------------------------- 1 | Menu KEYWORD1 2 | MenuItem KEYWORD1 3 | NumericMenuItem KEYWORD1 4 | BackMenuItem KEYWORD1 5 | MenuSystem KEYWORD1 6 | MenuComponent KEYWORD1 7 | -------------------------------------------------------------------------------- /lib/MenuSystem/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "MenuSystem", 3 | "keywords": "display, menu", 4 | "description": "A library for implementing a menu system", 5 | "repository": 6 | { 7 | "type": "git", 8 | "url": "https://github.com/jonblack/arduino-menusystem.git" 9 | }, 10 | "version": "2.1.1", 11 | "frameworks": "arduino", 12 | "platforms": "atmelavr" 13 | } 14 | -------------------------------------------------------------------------------- /lib/OneWire/.piopm: -------------------------------------------------------------------------------- 1 | {"type": "library", "name": "OneWire", "version": "2.3.8", "spec": {"owner": "paulstoffregen", "id": 1, "name": "OneWire", "requirements": null, "uri": null}} -------------------------------------------------------------------------------- /lib/OneWire/examples/DS18x20_Temperature/DS18x20_Temperature.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // OneWire DS18S20, DS18B20, DS1822 Temperature Example 4 | // 5 | // http://www.pjrc.com/teensy/td_libs_OneWire.html 6 | // 7 | // The DallasTemperature library can do all this work for you! 8 | // https://github.com/milesburton/Arduino-Temperature-Control-Library 9 | 10 | OneWire ds(10); // on pin 10 (a 4.7K resistor is necessary) 11 | 12 | void setup(void) { 13 | Serial.begin(9600); 14 | } 15 | 16 | void loop(void) { 17 | byte i; 18 | byte present = 0; 19 | byte type_s; 20 | byte data[9]; 21 | byte addr[8]; 22 | float celsius, fahrenheit; 23 | 24 | if ( !ds.search(addr)) { 25 | Serial.println("No more addresses."); 26 | Serial.println(); 27 | ds.reset_search(); 28 | delay(250); 29 | return; 30 | } 31 | 32 | Serial.print("ROM ="); 33 | for( i = 0; i < 8; i++) { 34 | Serial.write(' '); 35 | Serial.print(addr[i], HEX); 36 | } 37 | 38 | if (OneWire::crc8(addr, 7) != addr[7]) { 39 | Serial.println("CRC is not valid!"); 40 | return; 41 | } 42 | Serial.println(); 43 | 44 | // the first ROM byte indicates which chip 45 | switch (addr[0]) { 46 | case 0x10: 47 | Serial.println(" Chip = DS18S20"); // or old DS1820 48 | type_s = 1; 49 | break; 50 | case 0x28: 51 | Serial.println(" Chip = DS18B20"); 52 | type_s = 0; 53 | break; 54 | case 0x22: 55 | Serial.println(" Chip = DS1822"); 56 | type_s = 0; 57 | break; 58 | default: 59 | Serial.println("Device is not a DS18x20 family device."); 60 | return; 61 | } 62 | 63 | ds.reset(); 64 | ds.select(addr); 65 | ds.write(0x44, 1); // start conversion, with parasite power on at the end 66 | 67 | delay(1000); // maybe 750ms is enough, maybe not 68 | // we might do a ds.depower() here, but the reset will take care of it. 69 | 70 | present = ds.reset(); 71 | ds.select(addr); 72 | ds.write(0xBE); // Read Scratchpad 73 | 74 | Serial.print(" Data = "); 75 | Serial.print(present, HEX); 76 | Serial.print(" "); 77 | for ( i = 0; i < 9; i++) { // we need 9 bytes 78 | data[i] = ds.read(); 79 | Serial.print(data[i], HEX); 80 | Serial.print(" "); 81 | } 82 | Serial.print(" CRC="); 83 | Serial.print(OneWire::crc8(data, 8), HEX); 84 | Serial.println(); 85 | 86 | // Convert the data to actual temperature 87 | // because the result is a 16 bit signed integer, it should 88 | // be stored to an "int16_t" type, which is always 16 bits 89 | // even when compiled on a 32 bit processor. 90 | int16_t raw = (data[1] << 8) | data[0]; 91 | if (type_s) { 92 | raw = raw << 3; // 9 bit resolution default 93 | if (data[7] == 0x10) { 94 | // "count remain" gives full 12 bit resolution 95 | raw = (raw & 0xFFF0) + 12 - data[6]; 96 | } 97 | } else { 98 | byte cfg = (data[4] & 0x60); 99 | // at lower res, the low bits are undefined, so let's zero them 100 | if (cfg == 0x00) raw = raw & ~7; // 9 bit resolution, 93.75 ms 101 | else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms 102 | else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms 103 | //// default is 12 bit resolution, 750 ms conversion time 104 | } 105 | celsius = (float)raw / 16.0; 106 | fahrenheit = celsius * 1.8 + 32.0; 107 | Serial.print(" Temperature = "); 108 | Serial.print(celsius); 109 | Serial.print(" Celsius, "); 110 | Serial.print(fahrenheit); 111 | Serial.println(" Fahrenheit"); 112 | } 113 | -------------------------------------------------------------------------------- /lib/OneWire/examples/DS2408_Switch/DS2408_Switch.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* 4 | * DS2408 8-Channel Addressable Switch 5 | * 6 | * Writte by Glenn Trewitt, glenn at trewitt dot org 7 | * 8 | * Some notes about the DS2408: 9 | * - Unlike most input/output ports, the DS2408 doesn't have mode bits to 10 | * set whether the pins are input or output. If you issue a read command, 11 | * they're inputs. If you write to them, they're outputs. 12 | * - For reading from a switch, you should use 10K pull-up resisters. 13 | */ 14 | 15 | OneWire net(10); // on pin 10 16 | 17 | 18 | void PrintBytes(const uint8_t* addr, uint8_t count, bool newline=false) { 19 | for (uint8_t i = 0; i < count; i++) { 20 | Serial.print(addr[i]>>4, HEX); 21 | Serial.print(addr[i]&0x0f, HEX); 22 | } 23 | if (newline) 24 | Serial.println(); 25 | } 26 | 27 | 28 | void setup(void) { 29 | Serial.begin(9600); 30 | } 31 | 32 | void loop(void) { 33 | byte addr[8]; 34 | 35 | if (!net.search(addr)) { 36 | Serial.print("No more addresses.\n"); 37 | net.reset_search(); 38 | delay(1000); 39 | return; 40 | } 41 | 42 | if (OneWire::crc8(addr, 7) != addr[7]) { 43 | Serial.print("CRC is not valid!\n"); 44 | return; 45 | } 46 | 47 | if (addr[0] != 0x29) { 48 | PrintBytes(addr, 8); 49 | Serial.print(" is not a DS2408.\n"); 50 | return; 51 | } 52 | 53 | Serial.print(" Reading DS2408 "); 54 | PrintBytes(addr, 8); 55 | Serial.println(); 56 | 57 | uint8_t buf[13]; // Put everything in the buffer so we can compute CRC easily. 58 | buf[0] = 0xF0; // Read PIO Registers 59 | buf[1] = 0x88; // LSB address 60 | buf[2] = 0x00; // MSB address 61 | net.write_bytes(buf, 3); 62 | net.read_bytes(buf+3, 10); // 3 cmd bytes, 6 data bytes, 2 0xFF, 2 CRC16 63 | net.reset(); 64 | 65 | if (!OneWire::check_crc16(buf, 11, &buf[11])) { 66 | Serial.print("CRC failure in DS2408 at "); 67 | PrintBytes(addr, 8, true); 68 | return; 69 | } 70 | Serial.print(" DS2408 data = "); 71 | // First 3 bytes contain command, register address. 72 | Serial.println(buf[3], BIN); 73 | } 74 | 75 | -------------------------------------------------------------------------------- /lib/OneWire/examples/DS250x_PROM/DS250x_PROM.ino: -------------------------------------------------------------------------------- 1 | /* 2 | DS250x add-only programmable memory reader w/SKIP ROM. 3 | 4 | The DS250x is a 512/1024bit add-only PROM(you can add data but cannot change the old one) that's used mainly for device identification purposes 5 | like serial number, mfgr data, unique identifiers, etc. It uses the Maxim 1-wire bus. 6 | 7 | This sketch will use the SKIP ROM function that skips the 1-Wire search phase since we only have one device connected in the bus on digital pin 6. 8 | If more than one device is connected to the bus, it will fail. 9 | Sketch will not verify if device connected is from the DS250x family since the skip rom function effectively skips the family-id byte readout. 10 | thus it is possible to run this sketch with any Maxim OneWire device in which case the command CRC will most likely fail. 11 | Sketch will only read the first page of memory(32bits) starting from the lower address(0000h), if more than 1 device is present, then use the sketch with search functions. 12 | Remember to put a 4.7K pullup resistor between pin 6 and +Vcc 13 | 14 | To change the range or ammount of data to read, simply change the data array size, LSB/MSB addresses and for loop iterations 15 | 16 | This example code is in the public domain and is provided AS-IS. 17 | 18 | Built with Arduino 0022 and PJRC OneWire 2.0 library http://www.pjrc.com/teensy/td_libs_OneWire.html 19 | 20 | created by Guillermo Lovato 21 | march/2011 22 | 23 | */ 24 | 25 | #include 26 | OneWire ds(6); // OneWire bus on digital pin 6 27 | void setup() { 28 | Serial.begin (9600); 29 | } 30 | 31 | void loop() { 32 | byte i; // This is for the for loops 33 | boolean present; // device present var 34 | byte data[32]; // container for the data from device 35 | byte leemem[3] = { // array with the commands to initiate a read, DS250x devices expect 3 bytes to start a read: command,LSB&MSB adresses 36 | 0xF0 , 0x00 , 0x00 }; // 0xF0 is the Read Data command, followed by 00h 00h as starting address(the beginning, 0000h) 37 | byte ccrc; // Variable to store the command CRC 38 | byte ccrc_calc; 39 | 40 | present = ds.reset(); // OneWire bus reset, always needed to start operation on the bus, returns a 1/TRUE if there's a device present. 41 | ds.skip(); // Skip ROM search 42 | 43 | if (present == true) { // We only try to read the data if there's a device present 44 | Serial.println("DS250x device present"); 45 | ds.write(leemem[0],1); // Read data command, leave ghost power on 46 | ds.write(leemem[1],1); // LSB starting address, leave ghost power on 47 | ds.write(leemem[2],1); // MSB starting address, leave ghost power on 48 | 49 | ccrc = ds.read(); // DS250x generates a CRC for the command we sent, we assign a read slot and store it's value 50 | ccrc_calc = OneWire::crc8(leemem, 3); // We calculate the CRC of the commands we sent using the library function and store it 51 | 52 | if ( ccrc_calc != ccrc) { // Then we compare it to the value the ds250x calculated, if it fails, we print debug messages and abort 53 | Serial.println("Invalid command CRC!"); 54 | Serial.print("Calculated CRC:"); 55 | Serial.println(ccrc_calc,HEX); // HEX makes it easier to observe and compare 56 | Serial.print("DS250x readback CRC:"); 57 | Serial.println(ccrc,HEX); 58 | return; // Since CRC failed, we abort the rest of the loop and start over 59 | } 60 | Serial.println("Data is: "); // For the printout of the data 61 | for ( i = 0; i < 32; i++) { // Now it's time to read the PROM data itself, each page is 32 bytes so we need 32 read commands 62 | data[i] = ds.read(); // we store each read byte to a different position in the data array 63 | Serial.print(data[i]); // printout in ASCII 64 | Serial.print(" "); // blank space 65 | } 66 | Serial.println(); 67 | delay(5000); // Delay so we don't saturate the serial output 68 | } 69 | else { // Nothing is connected in the bus 70 | Serial.println("Nothing connected"); 71 | delay(3000); 72 | } 73 | } 74 | 75 | 76 | -------------------------------------------------------------------------------- /lib/OneWire/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For OneWire 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | OneWire KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | 15 | reset KEYWORD2 16 | write_bit KEYWORD2 17 | read_bit KEYWORD2 18 | write KEYWORD2 19 | write_bytes KEYWORD2 20 | read KEYWORD2 21 | read_bytes KEYWORD2 22 | select KEYWORD2 23 | skip KEYWORD2 24 | depower KEYWORD2 25 | reset_search KEYWORD2 26 | search KEYWORD2 27 | crc8 KEYWORD2 28 | crc16 KEYWORD2 29 | check_crc16 KEYWORD2 30 | 31 | ####################################### 32 | # Instances (KEYWORD2) 33 | ####################################### 34 | 35 | 36 | ####################################### 37 | # Constants (LITERAL1) 38 | ####################################### 39 | -------------------------------------------------------------------------------- /lib/OneWire/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "OneWire", 3 | "description": "Control 1-Wire protocol (DS18S20, DS18B20, DS2408 and etc)", 4 | "keywords": "onewire, 1-wire, bus, sensor, temperature, ibutton", 5 | "authors": [ 6 | { 7 | "name": "Paul Stoffregen", 8 | "email": "paul@pjrc.com", 9 | "url": "http://www.pjrc.com", 10 | "maintainer": true 11 | }, 12 | { 13 | "name": "Jim Studt" 14 | }, 15 | { 16 | "name": "Tom Pollard", 17 | "email": "pollard@alum.mit.edu" 18 | }, 19 | { 20 | "name": "Derek Yerger" 21 | }, 22 | { 23 | "name": "Josh Larios" 24 | }, 25 | { 26 | "name": "Robin James" 27 | }, 28 | { 29 | "name": "Glenn Trewitt" 30 | }, 31 | { 32 | "name": "Jason Dangel", 33 | "email": "dangel.jason AT gmail.com" 34 | }, 35 | { 36 | "name": "Guillermo Lovato" 37 | }, 38 | { 39 | "name": "Ken Butcher" 40 | }, 41 | { 42 | "name": "Mark Tillotson" 43 | }, 44 | { 45 | "name": "Bertrik Sikken" 46 | }, 47 | { 48 | "name": "Scott Roberts" 49 | } 50 | ], 51 | "repository": { 52 | "type": "git", 53 | "url": "https://github.com/PaulStoffregen/OneWire" 54 | }, 55 | "version": "2.3.8", 56 | "homepage": "https://www.pjrc.com/teensy/td_libs_OneWire.html", 57 | "frameworks": "Arduino", 58 | "examples": [ 59 | "examples/*/*.pde" 60 | ] 61 | } 62 | -------------------------------------------------------------------------------- /lib/OneWire/library.properties: -------------------------------------------------------------------------------- 1 | name=OneWire 2 | version=2.3.8 3 | author=Jim Studt, Tom Pollard, Robin James, Glenn Trewitt, Jason Dangel, Guillermo Lovato, Paul Stoffregen, Scott Roberts, Bertrik Sikken, Mark Tillotson, Ken Butcher, Roger Clark, Love Nystrom 4 | maintainer=Paul Stoffregen 5 | sentence=Access 1-wire temperature sensors, memory and other chips. 6 | paragraph= 7 | category=Communication 8 | url=http://www.pjrc.com/teensy/td_libs_OneWire.html 9 | architectures=* 10 | 11 | -------------------------------------------------------------------------------- /lib/OneWire/util/OneWire_direct_regtype.h: -------------------------------------------------------------------------------- 1 | #ifndef OneWire_Direct_RegType_h 2 | #define OneWire_Direct_RegType_h 3 | 4 | #include 5 | 6 | // Platform specific I/O register type 7 | 8 | #if defined(__AVR__) 9 | #define IO_REG_TYPE uint8_t 10 | 11 | #elif defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK66FX1M0__) || defined(__MK64FX512__) 12 | #define IO_REG_TYPE uint8_t 13 | 14 | #elif defined(__IMXRT1052__) || defined(__IMXRT1062__) 15 | #define IO_REG_TYPE uint32_t 16 | 17 | #elif defined(__MKL26Z64__) 18 | #define IO_REG_TYPE uint8_t 19 | 20 | #elif defined(__SAM3X8E__) || defined(__SAM3A8C__) || defined(__SAM3A4C__) 21 | #define IO_REG_TYPE uint32_t 22 | 23 | #elif defined(__PIC32MX__) 24 | #define IO_REG_TYPE uint32_t 25 | 26 | #elif defined(ARDUINO_ARCH_ESP8266) 27 | #define IO_REG_TYPE uint32_t 28 | 29 | #elif defined(ARDUINO_ARCH_ESP32) 30 | #define IO_REG_TYPE uint32_t 31 | #define IO_REG_MASK_ATTR 32 | 33 | #elif defined(ARDUINO_ARCH_STM32) 34 | #define IO_REG_TYPE uint32_t 35 | 36 | #elif defined(__SAMD21G18A__) 37 | #define IO_REG_TYPE uint32_t 38 | 39 | #elif defined(__ASR6501__) 40 | #define IO_REG_TYPE uint32_t 41 | 42 | #elif defined(RBL_NRF51822) 43 | #define IO_REG_TYPE uint32_t 44 | 45 | #elif defined(__arc__) /* Arduino101/Genuino101 specifics */ 46 | #define IO_REG_TYPE uint32_t 47 | 48 | #elif defined(__MBED__) 49 | #include "DigitalInOut.h" 50 | #define IO_REG_TYPE mbed::DigitalInOut* 51 | 52 | #elif defined(__riscv) 53 | #define IO_REG_TYPE uint32_t 54 | 55 | #else 56 | #define IO_REG_TYPE unsigned int 57 | 58 | #endif 59 | #endif 60 | -------------------------------------------------------------------------------- /lib/Queue/library.properties: -------------------------------------------------------------------------------- 1 | name=Queue 2 | version=1.9 3 | author=SMFSW 4 | maintainer=SMFSW 5 | sentence=Queue handling library. 6 | paragraph=Arduino designed library, yet may be compiled without change with gcc for other purporses/targets 7 | category=Data Storage 8 | url=https://github.com/SMFSW/Queue 9 | architectures=* 10 | -------------------------------------------------------------------------------- /lib/Queue/src/cppQueue.cpp: -------------------------------------------------------------------------------- 1 | /*!\file cppQueue.cpp 2 | ** \author SMFSW 3 | ** \copyright BSD 3-Clause License (c) 2017-2020, SMFSW 4 | ** \brief cppQueue handling library (designed on Arduino) 5 | ** \details cppQueue handling library (designed on Arduino) 6 | ** This library was designed for Arduino, yet may be compiled without change with gcc for other purposes/targets 7 | **/ 8 | /****************************************************************/ 9 | #include 10 | #include 11 | #include 12 | 13 | #include "cppQueue.h" 14 | /****************************************************************/ 15 | 16 | 17 | /*! \brief Increment index 18 | ** \details Increment buffer index \b pIdx rolling back to \b start when limit \b end is reached 19 | ** \param [in,out] pIdx - pointer to index value 20 | ** \param [in] end - counter upper limit value 21 | ** \param [in] start - counter lower limit value 22 | **/ 23 | static inline void __attribute__((nonnull, always_inline)) inc_idx(uint16_t * const pIdx, const uint16_t end, const uint16_t start) 24 | { 25 | if (*pIdx < end - 1) { (*pIdx)++; } 26 | else { *pIdx = start; } 27 | } 28 | 29 | /*! \brief Decrement index 30 | ** \details Decrement buffer index \b pIdx rolling back to \b end when limit \b start is reached 31 | ** \param [in,out] pIdx - pointer to index value 32 | ** \param [in] end - counter upper limit value 33 | ** \param [in] start - counter lower limit value 34 | **/ 35 | static inline void __attribute__((nonnull, always_inline)) dec_idx(uint16_t * const pIdx, const uint16_t end, const uint16_t start) 36 | { 37 | if (*pIdx > start) { (*pIdx)--; } 38 | else { *pIdx = end - 1; } 39 | } 40 | 41 | 42 | cppQueue::cppQueue(const uint16_t size_rec, const uint16_t nb_recs, const cppQueueType type, const bool overwrite) 43 | { 44 | const uint32_t size = nb_recs * size_rec; 45 | 46 | rec_nb = nb_recs; 47 | rec_sz = size_rec; 48 | impl = type; 49 | ovw = overwrite; 50 | 51 | init = 0; 52 | 53 | if (queue) { free(queue); } // Free existing data (if any) 54 | //#ifdef BOARD_HAS_PSRAM 55 | //queue = (uint8_t *) ps_malloc(size); 56 | //#else 57 | //queue = (uint8_t *) malloc(size); 58 | queue = (uint8_t *) calloc(sizeof(uint8_t),size); 59 | //#endif 60 | 61 | if (queue == NULL) { queue_sz = 0; return; } // Return here if cppQueue not allocated 62 | else { queue_sz = size; } 63 | 64 | init = QUEUE_INITIALIZED; 65 | flush(); 66 | } 67 | 68 | cppQueue::~cppQueue() 69 | { 70 | if (init == QUEUE_INITIALIZED) free(queue); 71 | } 72 | 73 | 74 | void cppQueue::flush(void) 75 | { 76 | in = 0; 77 | out = 0; 78 | cnt = 0; 79 | } 80 | 81 | 82 | bool __attribute__((nonnull)) cppQueue::push(const void * const record) 83 | { 84 | if ((!ovw) && isFull()) { return false; } 85 | 86 | uint8_t * const pStart = queue + (rec_sz * in); 87 | memcpy(pStart, record, rec_sz); 88 | 89 | inc_idx(&in, rec_nb, 0); 90 | 91 | if (!isFull()) { cnt++; } // Increase records count 92 | else if (ovw) // cppQueue is full and overwrite is allowed 93 | { 94 | if (impl == FIFO) { inc_idx(&out, rec_nb, 0); } // as oldest record is overwritten, increment out 95 | //else if (impl == LIFO) {} // Nothing to do in this case 96 | } 97 | 98 | return true; 99 | } 100 | 101 | bool __attribute__((nonnull)) cppQueue::pop(void * const record) 102 | { 103 | const uint8_t * pStart; 104 | 105 | if (isEmpty()) { return false; } // No more records 106 | 107 | if (impl == FIFO) 108 | { 109 | pStart = queue + (rec_sz * out); 110 | inc_idx(&out, rec_nb, 0); 111 | } 112 | else if (impl == LIFO) 113 | { 114 | dec_idx(&in, rec_nb, 0); 115 | pStart = queue + (rec_sz * in); 116 | } 117 | else { return false; } 118 | 119 | memcpy(record, pStart, rec_sz); 120 | cnt--; // Decrease records count 121 | return true; 122 | } 123 | 124 | 125 | bool __attribute__((nonnull)) cppQueue::peek(void * const record) 126 | { 127 | const uint8_t * pStart; 128 | 129 | if (isEmpty()) { return false; } // No more records 130 | 131 | if (impl == FIFO) 132 | { 133 | pStart = queue + (rec_sz * out); 134 | // No change on out var as it's just a peek 135 | } 136 | else if (impl == LIFO) 137 | { 138 | uint16_t rec = in; // Temporary var for peek (no change on in with dec_idx) 139 | dec_idx(&rec, rec_nb, 0); 140 | pStart = queue + (rec_sz * rec); 141 | } 142 | else { return false; } 143 | 144 | memcpy(record, pStart, rec_sz); 145 | return true; 146 | } 147 | 148 | 149 | bool cppQueue::drop(void) 150 | { 151 | if (isEmpty()) { return false; } // No more records 152 | 153 | if (impl == FIFO) { inc_idx(&out, rec_nb, 0); } 154 | else if (impl == LIFO) { dec_idx(&in, rec_nb, 0); } 155 | else { return false; } 156 | 157 | cnt--; // Decrease records count 158 | return true; 159 | } 160 | 161 | 162 | bool cppQueue::peekIdx(void * const record, const uint16_t idx) 163 | { 164 | const uint8_t * pStart; 165 | 166 | if (idx + 1 > getCount()) { return false; } // Index out of range 167 | 168 | if (impl == FIFO) 169 | { 170 | pStart = queue + (rec_sz * ((out + idx) % rec_nb)); 171 | } 172 | else if (impl == LIFO) 173 | { 174 | pStart = queue + (rec_sz * idx); 175 | } 176 | else { return false; } 177 | 178 | memcpy(record, pStart, rec_sz); 179 | return true; 180 | } 181 | 182 | -------------------------------------------------------------------------------- /lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | 48 | Rotary encoder action 49 | -Dashboard: dial up/down for select page,push long 3sec to MENU Mode 50 | -Check Box: push to toggle checked 51 | -Text Box: push to enter charector and next charactor,doble push(click) to Blackspace,dial up/down for select charactor,push long 3sec for Exit edit 52 | -Combo Box: push to exit,dial up/down for select item 53 | 54 | Display Dashboard MAP 55 | |STATISTICS 56 | 57 | 58 | Display Menu MAP 59 | |WiFi/BT/RF 60 | |-WiFi AP 61 | |-WiFi Client 62 | |-Blue Tooth 63 | |-RF Module 64 | 65 | |APRS 66 | |-APRS IGATE 67 | | |-APRS-IS 68 | | |-Position 69 | | |-Filter 70 | | |-Beacon 71 | 72 | |-APRS TRACKER 73 | | |-Position 74 | | |-Function 75 | | |-Filter 76 | | |-Smart Beacon 77 | 78 | |-DIGI REPEATER 79 | | |-Position 80 | | |-Function 81 | | |-Filter 82 | 83 | |SYSTEM 84 | |-Save/Load 85 | | |-Save Config 86 | | |-Load Config 87 | | |-Factore Reset 88 | |-OLED Display 89 | |-Monitor Popup 90 | |-ABOUT 91 | | |-OTA Update 92 | | |-WiFi Status 93 | | |-Infomations 94 | | |-Dash Board 95 | 96 | IGATE Mode support 97 | -Easy to select symbol icon 98 | -[RF2INET] RF to Internet gateway 99 | -[INET2RF] Internet to RF gateway 100 | -[POS2INET] Beacon Position to internet 101 | -[POS2RF] Beacon Position to radio 102 | -Support OBJECT name (use for multi station more SSID) 103 | -Support generate PHG (Height,TX Power,Gain,Antt direction) 104 | -Protect INET2RF packet not ax.25 105 | -Protect RF2INET packet from rf/inet to inet loop 106 | -Fix/GPS Position 107 | -One Symbol 108 | -Auto pass code 109 | 110 | DIGI Mode Support 111 | -Supoort PATH: WIDEn-N,TRACEn-N,RELAY,RFONLY, -------------------------------------------------------------------------------- /lib/lwfec/README.md: -------------------------------------------------------------------------------- 1 | # LwFEC - Lightweight Forward Error Correction library 2 | LwFEC is a full Reed-Solomon FEC encoder and decoder C library dedicated for embedded and other RAM usage restricted systems. 3 | ## Memory usage 4 | The aim of this library is to be safe and deterministic, thus: 5 | * No heap (malloc) is used 6 | * No stack-allocated arrays are used 7 | 8 | Parity byte count limit can be changed freely according to application requirements. This allows the memory usage to stay at the required minimum. 9 | 10 | ## Example usage 11 | The example below shows how to initialize library, encode and decode a message: 12 | ```C 13 | #include //standard integer types header 14 | #include "rs.h" //RS FEC library 15 | 16 | #define K 12 //data size 17 | #define T 5 //parity size 18 | #define FCR 0 //first consecutive root index 19 | 20 | struct LwFecRS rs; //RS encoder/decoder instance 21 | 22 | void LwFEC(void) 23 | { 24 | RsInit(&rs, T, FCR); 25 | uint8_t data[RS_BLOCK_SIZE] = {'H', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '\0'}; 26 | RsEncode(&rs, data, N); //encode message 27 | 28 | //then N=RS_BLOCK_SIZE bytes of data are sent through some channel 29 | //or stored on some disk 30 | //this may introduce errors that the decoder will try to fix 31 | 32 | //alter some bytes for demonstration 33 | data[1] = 'h'; 34 | data[5] = 'x'; 35 | 36 | uint8_t bytesFixed = 0; //store number of corrected bytes here 37 | if(RsDecode(&rs, data, K, &bytesFixed)) //decode message 38 | { 39 | //message decoded succesfully 40 | } 41 | else 42 | { 43 | //too many errors in message 44 | } 45 | } 46 | ``` 47 | ## Important notes 48 | The block size is always equal to RS_BLOCK_SIZE (255 bytes) due to use of GF(2^8), however the library can handle any data size *K* provided *T + K <= RS_BLOCK_SIZE*. The remaining block space is padded automatically with zeros. The application just needs to provide *K* bytes of data. 49 | ## Size limit change 50 | Size limits used for array preallocation are stored in *rs.h*: 51 | ```C 52 | #define RS_MAX_REDUNDANCY_BYTES 64 //maximum parity bytes 53 | ``` 54 | ## License 55 | The code is based on [*Reed-Solomon codes for coders*](https://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders). 56 | The project is licensed under the GNU GPL v3 license (see [LICENSE](LICENSE)). 57 | 58 | -------------------------------------------------------------------------------- /lib/lwfec/rs.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of LwFEC. 3 | 4 | LwFEC is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | LwFEC 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 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with LwFEC. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #define RS_MAX_REDUNDANCY_BYTES 64 //maximum parity bytes 22 | 23 | 24 | #define RS_BLOCK_SIZE 255 //natural full RS block size 25 | #define RS_MAX_DATA_SIZE (RS_BLOCK_SIZE - RS_MAX_REDUNDANCY_BYTES) 26 | 27 | /** 28 | * @brief Reed-Solomon module configuration structure 29 | */ 30 | struct LwFecRS 31 | { 32 | uint8_t generator[RS_MAX_REDUNDANCY_BYTES + 1]; //generator polynomial 33 | uint8_t T; //number of redundancy/parity bytes 34 | uint8_t fcr; //first consecutive root index 35 | }; 36 | 37 | /** 38 | * @brief Decode message using Reed-Solomon FEC 39 | * 40 | * This function takes input buffer with K data bytes and T parity bytes 41 | * Then it moves parity bytes to the end and fills everything inbetween with zeros. 42 | * Next the in-place decoding is performed. 43 | * @param *rs RS coder/decoder instance 44 | * @param *data Input/output buffer. Must be of size N = 255 45 | * @param size Data size = K 46 | * @param *fixed Output number of bytes corrected 47 | * @return True on success, false on failure 48 | */ 49 | bool RsDecode(struct LwFecRS *rs, uint8_t *data, uint8_t size, uint8_t *fixed); 50 | 51 | /** 52 | * @brief Encode message using Reed-Solomon FEC 53 | * @param *rs RS coder/decoder instance 54 | * @param *data Input/output buffer. Must be of size N = 255 55 | * @param size Data size = K 56 | */ 57 | void RsEncode(struct LwFecRS *rs, uint8_t *data, uint8_t size); 58 | 59 | /** 60 | * @brief Initialize Reed-Solomon coder/decoder 61 | * 62 | * This function calculates generator polynomial and stores required constants. 63 | * @param *rs RS coder/decoder instance to be filled 64 | * @param T Number of parity check bytes 65 | * @param fcr First consecutive root index 66 | */ 67 | void RsInit(struct LwFecRS *rs, uint8_t T, uint8_t fcr); 68 | -------------------------------------------------------------------------------- /lilygo-t-twr.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino":{ 4 | "ldscript": "esp32s3_out.ld", 5 | "memory_type": "qio_opi", 6 | "partitions": "default_16MB.csv" 7 | }, 8 | "core": "esp32", 9 | "extra_flags": [ 10 | "-DBOARD_HAS_PSRAM", 11 | "-DARDUINO_USB_MODE=1" 12 | ], 13 | "f_cpu": "240000000L", 14 | "f_flash": "80000000L", 15 | "flash_mode": "qio", 16 | "hwids": [ 17 | [ 18 | "0X303A", 19 | "0x1001" 20 | ] 21 | ], 22 | "mcu": "esp32s3", 23 | "variant": "esp32s3" 24 | }, 25 | "connectivity": [ 26 | "wifi", 27 | "bluetooth" 28 | ], 29 | "debug": { 30 | "openocd_target": "esp32s3.cfg" 31 | }, 32 | "frameworks": [ 33 | "arduino", 34 | "espidf" 35 | ], 36 | "name": "LILYGO T-TWR", 37 | "upload": { 38 | "flash_size": "16MB", 39 | "maximum_ram_size": 327680, 40 | "maximum_size": 16777216, 41 | "require_upload_port": true, 42 | "speed": 921600 43 | }, 44 | "url": "https://www.adafruit.com/product/5290", 45 | "vendor": "LILYGO" 46 | } -------------------------------------------------------------------------------- /partitions.csv: -------------------------------------------------------------------------------- 1 | # Name, Type, SubType, Offset, Size, Flags 2 | nvs, data, nvs, 0x9000, 0x5000, 3 | otadata, data, ota, 0xe000, 0x2000, 4 | app0, app, ota_0, 0x10000, 0x400000, 5 | app1, app, ota_1, 0x410000,0x400000, 6 | spiffs, data, spiffs, 0x810000,0x7E0000, 7 | coredump, data, coredump,0xFF0000,0x10000, 8 | -------------------------------------------------------------------------------- /platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter 4 | ; Upload options: custom upload port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; Advanced options: extra scripting 7 | ; 8 | ; Please visit documentation for the other options and examples 9 | ; https://docs.platformio.org/page/projectconf.html 10 | 11 | 12 | [env:esp32s3-twrplus] 13 | ;platform = https://github.com/pioarduino/platform-espressif32/releases/download/51.03.07/platform-espressif32.zip 14 | ;platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip 15 | platform = https://github.com/pioarduino/platform-espressif32/releases/download/54.03.20-rc1/platform-espressif32.zip 16 | board = esp32s3box 17 | board_build.f_cpu = 240000000L 18 | board_build.f_flash = 80000000L 19 | board_build.mcu = esp32s3 20 | board_build.partitions = partitions.csv 21 | board_build.arduino.memory_type = dio_opi 22 | framework = arduino 23 | monitor_speed = 115200 24 | upload_protocol = esptool 25 | monitor_filters = esp32_exception_decoder 26 | lib_deps = 27 | ;ESP32Async/AsyncTCP 28 | ;ESP32Async/ESPAsyncWebServer 29 | adafruit/Adafruit SSD1306@^2.5.7 30 | densaugeo/base64@^1.2.1 31 | mikalhart/TinyGPSPlus@^1.0.2 32 | suculent/ESP32httpUpdate@^2.1.145 33 | lewisxhe/XPowersLib@^0.1.7 34 | adafruit/Adafruit NeoPixel@^1.11.0 35 | igorantolic/Ai Esp32 Rotary Encoder@^1.6 36 | zmeiresearch/Wireguard client for LwIP on ESP32@^1.0.1 37 | ricmoo/QRCode@^0.0.1 38 | plerup/EspSoftwareSerial@8.1.0 39 | 4-20ma/ModbusMaster@^2.0.1 40 | adafruit/Adafruit BME280 Library@^2.2.4 41 | adafruit/Adafruit BMP280 Library@^2.6.8 42 | adafruit/Adafruit Si7021 Library@^1.5.3 43 | adafruit/Adafruit CCS811 Library@^1.1.3 44 | sensirion/arduino-sht@^1.2.5 45 | milesburton/DallasTemperature@^3.11.0 46 | h2zero/NimBLE-Arduino@^2.2.2 47 | ;afpineda/NuS-NimBLE-Serial@^3.3.3 48 | ;aki237/Adafruit_ESP32_SH1106 @ ^1.0.2 49 | bblanchon/ArduinoJson@^7.3.0 50 | build_flags = 51 | -L./lib 52 | -Wl,-Map,output.map 53 | -DWEBSERVER_MAX_POST_ARGS=80 54 | -DBOARD_HAS_PSRAM 55 | -DARDUINO_USB_MODE=1 56 | -DARDUINO_USB_CDC_ON_BOOT=1 57 | -mfix-esp32-psram-cache-issue 58 | -mfix-esp32-psram-cache-strategy=memw 59 | -DCONFIG_I2C_ENABLE_DEBUG_LOG=0 60 | -DCORE_DEBUG_LEVEL=0 61 | -DENABLE_FX25 62 | -DAXP21XX_SUPPORT 63 | ;-DCONFIG_ARDUINO_ISR_IRAM=0 64 | ;-DCONFIG_SPIRAM_USE_MALLOC=1 65 | ;-DCONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST=1 66 | ;-DCONFIG_BT_BLE_DYNAMIC_ENV_MEMORY=1 67 | ;-DCONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=1 68 | 69 | ; [env:sa868_vhf_open_edition] 70 | ; build_flags = ${env.build_flags} -DSA868_OPEN_EDITION 71 | ; lib_deps = plerup/EspSoftwareSerial@^8.2.0 72 | 73 | ; [env:sa868_vhf_open_edition_debug] 74 | ; debug_tool = esp-builtin 75 | ; build_type = debug 76 | ; build_flags = ${env:sa868_vhf_open_edition.build_flags} -DCORE_DEBUG_LEVEL=5 77 | ; lib_deps = plerup/EspSoftwareSerial@^8.2.0 78 | -------------------------------------------------------------------------------- /src/wireguard_vpn.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Wireguard VPN Client demo for LwIP/ESP32 3 | //============================================================================== 4 | 5 | //============================================================================== 6 | // Includes 7 | //============================================================================== 8 | #include 9 | #include "main.h" 10 | 11 | //ใช้ตัวแปรโกลบอลในไฟล์ main.cpp 12 | extern Configuration config; 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif // __cplusplus 17 | 18 | #include "wireguardif.h" 19 | #include "wireguard.h" 20 | 21 | #include "wireguard_vpn.h" 22 | //============================================================================== 23 | // Defines 24 | //============================================================================== 25 | #define CMP_NAME "WG_VPN" 26 | 27 | //============================================================================== 28 | // Local types 29 | //============================================================================== 30 | 31 | //============================================================================== 32 | // Local data 33 | //============================================================================== 34 | static struct netif wg_netif_struct = {0}; 35 | static struct netif *wg_netif = NULL; 36 | static uint8_t wireguard_peer_index_local = WIREGUARDIF_INVALID_INDEX; 37 | 38 | //============================================================================== 39 | // Exported data 40 | //============================================================================== 41 | 42 | //============================================================================== 43 | // Local functions 44 | //============================================================================== 45 | 46 | //============================================================================== 47 | // Exported functions 48 | //============================================================================== 49 | bool wireguard_active() 50 | { 51 | if(wg_netif!=NULL) return true; 52 | return false; 53 | } 54 | 55 | void wireguard_remove() 56 | { 57 | 58 | if(wg_netif!=NULL){ 59 | wireguardif_disconnect(wg_netif, wireguard_peer_index_local); 60 | wireguardif_remove_peer(wg_netif, wireguard_peer_index_local); 61 | //netif_set_down(wg_netif); 62 | //netif_remove(&wg_netif_struct); 63 | } 64 | } 65 | 66 | void wireguard_setup() 67 | { 68 | struct wireguardif_init_data wg; 69 | struct wireguardif_peer peer; 70 | 71 | if(strlen(config.wg_public_key)!=44) return; 72 | if(strlen(config.wg_private_key)!=44) return; 73 | ip_addr_t ipaddr; 74 | ip_addr_t netmask; 75 | ip_addr_t gateway; 76 | ip_addr_t peer_address; 77 | 78 | ipaddr_aton(config.wg_local_address,&ipaddr); 79 | ipaddr_aton(config.wg_netmask_address,&netmask); 80 | ipaddr_aton(config.wg_gw_address,&gateway); 81 | ipaddr_aton(config.wg_peer_address,&peer_address); 82 | 83 | // Setup the WireGuard device structure 84 | wg.private_key = config.wg_private_key; 85 | wg.listen_port = config.wg_port+1; 86 | wg.bind_netif = NULL; // NB! not working on ESP32 even if set! 87 | 88 | if(wg_netif==NULL){ 89 | TCP_MUTEX_LOCK(); 90 | // Register the new WireGuard network interface with lwIP 91 | wg_netif = netif_add(&wg_netif_struct, ip_2_ip4(&ipaddr), ip_2_ip4(&netmask), ip_2_ip4(&gateway), &wg, &wireguardif_init, &ip_input); 92 | 93 | // Mark the interface as administratively up, link up flag is set automatically when peer connects 94 | netif_set_up(wg_netif); 95 | TCP_MUTEX_UNLOCK(); 96 | } 97 | 98 | // Initialise the first WireGuard peer structure 99 | wireguardif_peer_init(&peer); 100 | peer.public_key = config.wg_public_key; 101 | peer.preshared_key = NULL; 102 | // Allow all IPs through tunnel 103 | //peer.allowed_ip = IPADDR4_INIT_BYTES(0, 0, 0, 0); 104 | IP_ADDR4(&peer.allowed_ip, 0, 0, 0, 0); 105 | IP_ADDR4(&peer.allowed_mask, 0, 0, 0, 0); 106 | 107 | // If we know the endpoint's address can add here 108 | ip_addr_set(&peer.endpoint_ip, &peer_address); 109 | peer.endport_port = config.wg_port; 110 | 111 | // Register the new WireGuard peer with the netwok interface 112 | wireguardif_add_peer(wg_netif, &peer, &wireguard_peer_index_local); 113 | 114 | if ((wireguard_peer_index_local != WIREGUARDIF_INVALID_INDEX) && !ip_addr_isany(&peer.endpoint_ip)) 115 | { 116 | // Start outbound connection to peer 117 | wireguardif_connect(wg_netif, wireguard_peer_index_local); 118 | } 119 | } 120 | 121 | #ifdef __cplusplus 122 | } 123 | #endif // __cplusplus --------------------------------------------------------------------------------