├── 3D Printables ├── Base_slicer.JPG ├── Daly2SofarBase_04.stl ├── Daly2SofarTop_04.stl └── Top_slicer.JPG ├── Arduino dependencies ├── Adafruit_SSD1306 │ ├── Adafruit_SSD1306.cpp │ ├── Adafruit_SSD1306.h │ ├── README.md │ ├── desktop.ini │ ├── examples │ │ ├── desktop.ini │ │ ├── ssd1306_128x32_i2c │ │ │ ├── desktop.ini │ │ │ └── ssd1306_128x32_i2c.ino │ │ ├── ssd1306_128x32_spi │ │ │ ├── desktop.ini │ │ │ └── ssd1306_128x32_spi.ino │ │ ├── ssd1306_128x64_i2c │ │ │ ├── desktop.ini │ │ │ └── ssd1306_128x64_i2c.ino │ │ └── ssd1306_128x64_spi │ │ │ ├── desktop.ini │ │ │ └── ssd1306_128x64_spi.ino │ ├── library.properties │ ├── license.txt │ └── splash.h ├── AsyncTCP-master │ ├── .github │ │ ├── scripts │ │ │ ├── install-arduino-core-esp32.sh │ │ │ ├── install-arduino-ide.sh │ │ │ ├── install-platformio.sh │ │ │ └── on-push.sh │ │ ├── stale.yml │ │ └── workflows │ │ │ └── push.yml │ ├── .gitignore │ ├── .travis.yml │ ├── CMakeLists.txt │ ├── Kconfig.projbuild │ ├── LICENSE │ ├── README.md │ ├── component.mk │ ├── library.json │ ├── library.properties │ └── src │ │ ├── AsyncTCP.cpp │ │ └── AsyncTCP.h ├── ESP32-Arduino-CAN-master │ ├── .gitignore │ ├── LICENSE │ ├── README.md │ ├── examples │ │ ├── esp32can_basic │ │ │ └── esp32can_basic.ino │ │ ├── esp32can_filter │ │ │ └── esp32can_filter.ino │ │ └── esp32can_mirror │ │ │ └── esp32can_mirror.ino │ ├── keywords.txt │ ├── library.properties │ └── src │ │ ├── CAN.c │ │ ├── CAN.h │ │ ├── CAN_config.h │ │ ├── ESP32CAN.cpp │ │ ├── ESP32CAN.h │ │ └── can_regdef.h ├── async-mqtt-client-develop │ ├── .editorconfig │ ├── .github │ │ └── workflows │ │ │ ├── build_examples_pio.yml │ │ │ └── cpplint.yml │ ├── .gitignore │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── async-mqtt-client.cppcheck │ ├── docs │ │ ├── 1.-Getting-started.md │ │ ├── 2.-API-reference.md │ │ ├── 3.-Memory-management.md │ │ ├── 4.-Limitations-and-known-issues.md │ │ ├── 5.-Troubleshooting.md │ │ ├── README.md │ │ └── index.md │ ├── examples │ │ ├── FullyFeatured-ESP32 │ │ │ └── FullyFeatured-ESP32.ino │ │ ├── FullyFeatured-ESP8266 │ │ │ └── FullyFeatured-ESP8266.ino │ │ └── FullyFeaturedSSL │ │ │ ├── platformio.ini │ │ │ └── src │ │ │ └── main.cpp │ ├── keywords.txt │ ├── library.json │ ├── library.properties │ ├── scripts │ │ ├── CI │ │ │ ├── build_examples_pio.sh │ │ │ ├── platformio_esp32.ini │ │ │ └── platformio_esp8266.ini │ │ └── get-fingerprint │ │ │ └── get-fingerprint.py │ └── src │ │ ├── AsyncMqttClient.cpp │ │ ├── AsyncMqttClient.h │ │ ├── AsyncMqttClient.hpp │ │ └── AsyncMqttClient │ │ ├── Callbacks.hpp │ │ ├── DisconnectReasons.hpp │ │ ├── Errors.hpp │ │ ├── Flags.hpp │ │ ├── Helpers.hpp │ │ ├── MessageProperties.hpp │ │ ├── Packets │ │ ├── ConnAckPacket.cpp │ │ ├── ConnAckPacket.hpp │ │ ├── Out │ │ │ ├── Connect.cpp │ │ │ ├── Connect.hpp │ │ │ ├── Disconn.cpp │ │ │ ├── Disconn.hpp │ │ │ ├── OutPacket.cpp │ │ │ ├── OutPacket.hpp │ │ │ ├── PingReq.cpp │ │ │ ├── PingReq.hpp │ │ │ ├── PubAck.cpp │ │ │ ├── PubAck.hpp │ │ │ ├── Publish.cpp │ │ │ ├── Publish.hpp │ │ │ ├── Subscribe.cpp │ │ │ ├── Subscribe.hpp │ │ │ ├── Unsubscribe.cpp │ │ │ └── Unsubscribe.hpp │ │ ├── Packet.hpp │ │ ├── PingRespPacket.cpp │ │ ├── PingRespPacket.hpp │ │ ├── PubAckPacket.cpp │ │ ├── PubAckPacket.hpp │ │ ├── PubCompPacket.cpp │ │ ├── PubCompPacket.hpp │ │ ├── PubRecPacket.cpp │ │ ├── PubRecPacket.hpp │ │ ├── PubRelPacket.cpp │ │ ├── PubRelPacket.hpp │ │ ├── PublishPacket.cpp │ │ ├── PublishPacket.hpp │ │ ├── SubAckPacket.cpp │ │ ├── SubAckPacket.hpp │ │ ├── UnsubAckPacket.cpp │ │ └── UnsubAckPacket.hpp │ │ ├── ParsingInformation.hpp │ │ └── Storage.hpp └── daly-bms-uart-main │ ├── LICENSE.txt │ ├── README.md │ ├── daly-bms-uart.cpp │ ├── daly-bms-uart.h │ ├── docs │ ├── Part 4_ Daly RS485+UART Protocol.pdf │ └── UART Interface.jpg │ ├── example-sketch │ └── daly-bms-example │ │ └── daly-bms-example.ino │ ├── logic-analyzer-captures │ └── Idle BMS & PC Talking.sal │ └── pc-software │ ├── DalyBmsMonitorV1.1.5.zip │ └── README.md ├── Daly2Sofar Node-Red to HA example.jpg ├── Daly2Sofar Node-Red to Home Assistant flow.json ├── Daly2Sofar schematic.jpg ├── Daly2Sofar_1.jpg ├── Daly2Sofar_2.jpg ├── Daly2Sofar_3.jpg ├── Daly2Sofar_v0.92 ├── Daly2Sofar_v0.92.ino ├── I_MQTTstuff.ino ├── J_CANBUSstuff.ino ├── K_OledStuff.ino ├── L_GeneralFunctions.ino └── X_Main.ino ├── Home Assistant sensors example.jpg └── README.md /3D Printables/Base_slicer.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loopyengineeringco/Daly2Sofar/553ce9e89f5d734e8a7a2f2f7913b9901f184311/3D Printables/Base_slicer.JPG -------------------------------------------------------------------------------- /3D Printables/Daly2SofarBase_04.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loopyengineeringco/Daly2Sofar/553ce9e89f5d734e8a7a2f2f7913b9901f184311/3D Printables/Daly2SofarBase_04.stl -------------------------------------------------------------------------------- /3D Printables/Daly2SofarTop_04.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loopyengineeringco/Daly2Sofar/553ce9e89f5d734e8a7a2f2f7913b9901f184311/3D Printables/Daly2SofarTop_04.stl -------------------------------------------------------------------------------- /3D Printables/Top_slicer.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loopyengineeringco/Daly2Sofar/553ce9e89f5d734e8a7a2f2f7913b9901f184311/3D Printables/Top_slicer.JPG -------------------------------------------------------------------------------- /Arduino dependencies/Adafruit_SSD1306/Adafruit_SSD1306.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file Adafruit_SSD1306.h 3 | * 4 | * This is part of for Adafruit's SSD1306 library for monochrome 5 | * OLED displays: http://www.adafruit.com/category/63_98 6 | * 7 | * These displays use I2C or SPI to communicate. I2C requires 2 pins 8 | * (SCL+SDA) and optionally a RESET pin. SPI requires 4 pins (MOSI, SCK, 9 | * select, data/command) and optionally a reset pin. Hardware SPI or 10 | * 'bitbang' software SPI are both supported. 11 | * 12 | * Adafruit invests time and resources providing this open source code, 13 | * please support Adafruit and open-source hardware by purchasing 14 | * products from Adafruit! 15 | * 16 | * Written by Limor Fried/Ladyada for Adafruit Industries, with 17 | * contributions from the open source community. 18 | * 19 | * BSD license, all text above, and the splash screen header file, 20 | * must be included in any redistribution. 21 | * 22 | */ 23 | 24 | #ifndef _Adafruit_SSD1306_H_ 25 | #define _Adafruit_SSD1306_H_ 26 | 27 | // ONE of the following three lines must be #defined: 28 | //#define SSD1306_128_64 ///< DEPRECTAED: old way to specify 128x64 screen 29 | #define SSD1306_128_32 ///< DEPRECATED: old way to specify 128x32 screen 30 | //#define SSD1306_96_16 ///< DEPRECATED: old way to specify 96x16 screen 31 | // This establishes the screen dimensions in old Adafruit_SSD1306 sketches 32 | // (NEW CODE SHOULD IGNORE THIS, USE THE CONSTRUCTORS THAT ACCEPT WIDTH 33 | // AND HEIGHT ARGUMENTS). 34 | 35 | #if defined(ARDUINO_STM32_FEATHER) 36 | typedef class HardwareSPI SPIClass; 37 | #endif 38 | 39 | #include 40 | #include 41 | #include 42 | 43 | #if defined(__AVR__) 44 | typedef volatile uint8_t PortReg; 45 | typedef uint8_t PortMask; 46 | #define HAVE_PORTREG 47 | #elif defined(__SAM3X8E__) 48 | typedef volatile RwReg PortReg; 49 | typedef uint32_t PortMask; 50 | #define HAVE_PORTREG 51 | #elif defined(__arm__) || defined(ARDUINO_FEATHER52) 52 | typedef volatile uint32_t PortReg; 53 | typedef uint32_t PortMask; 54 | #define HAVE_PORTREG 55 | #endif 56 | 57 | #define BLACK 0 ///< Draw 'off' pixels 58 | #define WHITE 1 ///< Draw 'on' pixels 59 | #define INVERSE 2 ///< Invert pixels 60 | 61 | #define SSD1306_MEMORYMODE 0x20 ///< See datasheet 62 | #define SSD1306_COLUMNADDR 0x21 ///< See datasheet 63 | #define SSD1306_PAGEADDR 0x22 ///< See datasheet 64 | #define SSD1306_SETCONTRAST 0x81 ///< See datasheet 65 | #define SSD1306_CHARGEPUMP 0x8D ///< See datasheet 66 | #define SSD1306_SEGREMAP 0xA0 ///< See datasheet 67 | #define SSD1306_DISPLAYALLON_RESUME 0xA4 ///< See datasheet 68 | #define SSD1306_DISPLAYALLON 0xA5 ///< Not currently used 69 | #define SSD1306_NORMALDISPLAY 0xA6 ///< See datasheet 70 | #define SSD1306_INVERTDISPLAY 0xA7 ///< See datasheet 71 | #define SSD1306_SETMULTIPLEX 0xA8 ///< See datasheet 72 | #define SSD1306_DISPLAYOFF 0xAE ///< See datasheet 73 | #define SSD1306_DISPLAYON 0xAF ///< See datasheet 74 | #define SSD1306_COMSCANINC 0xC0 ///< Not currently used 75 | #define SSD1306_COMSCANDEC 0xC8 ///< See datasheet 76 | #define SSD1306_SETDISPLAYOFFSET 0xD3 ///< See datasheet 77 | #define SSD1306_SETDISPLAYCLOCKDIV 0xD5 ///< See datasheet 78 | #define SSD1306_SETPRECHARGE 0xD9 ///< See datasheet 79 | #define SSD1306_SETCOMPINS 0xDA ///< See datasheet 80 | #define SSD1306_SETVCOMDETECT 0xDB ///< See datasheet 81 | 82 | #define SSD1306_SETLOWCOLUMN 0x00 ///< Not currently used 83 | #define SSD1306_SETHIGHCOLUMN 0x10 ///< Not currently used 84 | #define SSD1306_SETSTARTLINE 0x40 ///< See datasheet 85 | 86 | #define SSD1306_EXTERNALVCC 0x01 ///< External display voltage source 87 | #define SSD1306_SWITCHCAPVCC 0x02 ///< Gen. display voltage from 3.3V 88 | 89 | #define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26 ///< Init rt scroll 90 | #define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27 ///< Init left scroll 91 | #define SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29 ///< Init diag scroll 92 | #define SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A ///< Init diag scroll 93 | #define SSD1306_DEACTIVATE_SCROLL 0x2E ///< Stop scroll 94 | #define SSD1306_ACTIVATE_SCROLL 0x2F ///< Start scroll 95 | #define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3 ///< Set scroll range 96 | 97 | // Deprecated size stuff for backwards compatibility with old sketches 98 | #if defined SSD1306_128_64 99 | #define SSD1306_LCDWIDTH 128 ///< DEPRECATED: width w/SSD1306_128_64 defined 100 | #define SSD1306_LCDHEIGHT 64 ///< DEPRECATED: height w/SSD1306_128_64 defined 101 | #endif 102 | #if defined SSD1306_128_32 103 | #define SSD1306_LCDWIDTH 128 ///< DEPRECATED: width w/SSD1306_128_32 defined 104 | #define SSD1306_LCDHEIGHT 32 ///< DEPRECATED: height w/SSD1306_128_32 defined 105 | #endif 106 | #if defined SSD1306_96_16 107 | #define SSD1306_LCDWIDTH 96 ///< DEPRECATED: width w/SSD1306_96_16 defined 108 | #define SSD1306_LCDHEIGHT 16 ///< DEPRECATED: height w/SSD1306_96_16 defined 109 | #endif 110 | 111 | /*! 112 | @brief Class that stores state and functions for interacting with 113 | SSD1306 OLED displays. 114 | */ 115 | class Adafruit_SSD1306 : public Adafruit_GFX { 116 | public: 117 | // NEW CONSTRUCTORS -- recommended for new projects 118 | Adafruit_SSD1306(uint8_t w, uint8_t h, TwoWire *twi=&Wire, int8_t rst_pin=-1, 119 | uint32_t clkDuring=400000UL, uint32_t clkAfter=100000UL); 120 | Adafruit_SSD1306(uint8_t w, uint8_t h, int8_t mosi_pin, int8_t sclk_pin, 121 | int8_t dc_pin, int8_t rst_pin, int8_t cs_pin); 122 | Adafruit_SSD1306(uint8_t w, uint8_t h, SPIClass *spi, 123 | int8_t dc_pin, int8_t rst_pin, int8_t cs_pin, uint32_t bitrate=8000000UL); 124 | 125 | // DEPRECATED CONSTRUCTORS - for back compatibility, avoid in new projects 126 | Adafruit_SSD1306(int8_t mosi_pin, int8_t sclk_pin, int8_t dc_pin, 127 | int8_t rst_pin, int8_t cs_pin); 128 | Adafruit_SSD1306(int8_t dc_pin, int8_t rst_pin, int8_t cs_pin); 129 | Adafruit_SSD1306(int8_t rst_pin = -1); 130 | 131 | ~Adafruit_SSD1306(void); 132 | 133 | boolean begin(uint8_t switchvcc=SSD1306_SWITCHCAPVCC, 134 | uint8_t i2caddr=0, boolean reset=true, 135 | boolean periphBegin=true); 136 | void display(void); 137 | void clearDisplay(void); 138 | void invertDisplay(boolean i); 139 | void dim(boolean dim); 140 | void drawPixel(int16_t x, int16_t y, uint16_t color); 141 | virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); 142 | virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); 143 | void startscrollright(uint8_t start, uint8_t stop); 144 | void startscrollleft(uint8_t start, uint8_t stop); 145 | void startscrolldiagright(uint8_t start, uint8_t stop); 146 | void startscrolldiagleft(uint8_t start, uint8_t stop); 147 | void stopscroll(void); 148 | void ssd1306_command(uint8_t c); 149 | boolean getPixel(int16_t x, int16_t y); 150 | uint8_t *getBuffer(void); 151 | 152 | private: 153 | inline void SPIwrite(uint8_t d) __attribute__((always_inline)); 154 | void drawFastHLineInternal(int16_t x, int16_t y, int16_t w, 155 | uint16_t color); 156 | void drawFastVLineInternal(int16_t x, int16_t y, int16_t h, 157 | uint16_t color); 158 | void ssd1306_command1(uint8_t c); 159 | void ssd1306_commandList(const uint8_t *c, uint8_t n); 160 | 161 | SPIClass *spi; 162 | TwoWire *wire; 163 | uint8_t *buffer; 164 | int8_t i2caddr, vccstate, page_end; 165 | int8_t mosiPin , clkPin , dcPin , csPin, rstPin; 166 | #ifdef HAVE_PORTREG 167 | PortReg *mosiPort , *clkPort , *dcPort , *csPort; 168 | PortMask mosiPinMask, clkPinMask, dcPinMask, csPinMask; 169 | #endif 170 | #if defined(SPI_HAS_TRANSACTION) 171 | SPISettings spiSettings; 172 | #endif 173 | #if ARDUINO >= 157 174 | uint32_t wireClk; // Wire speed for SSD1306 transfers 175 | uint32_t restoreClk; // Wire speed following SSD1306 transfers 176 | #endif 177 | }; 178 | 179 | #endif // _Adafruit_SSD1306_H_ 180 | -------------------------------------------------------------------------------- /Arduino dependencies/Adafruit_SSD1306/README.md: -------------------------------------------------------------------------------- 1 | # Adafruit_SSD1306 [![Build Status](https://travis-ci.org/adafruit/Adafruit_SSD1306.svg?branch=master)](https://travis-ci.org/adafruit/Adafruit_SSD1306) 2 | 3 | This is a library for our Monochrome OLEDs based on SSD1306 drivers 4 | 5 | Pick one up today in the adafruit shop! 6 | ------> http://www.adafruit.com/category/63_98 7 | 8 | These displays use I2C or SPI to communicate, 2 to 5 pins are required to interface. 9 | 10 | Adafruit invests time and resources providing this open source code, 11 | please support Adafruit and open-source hardware by purchasing 12 | products from Adafruit! 13 | 14 | Written by Limor Fried/Ladyada for Adafruit Industries, with contributions from the open source community. Scrolling code contributed by Michael Gregg. Dynamic buffer allocation based on work by Andrew Canaday. 15 | BSD license, check license.txt for more information. All text above must be included in any redistribution 16 | 17 | Preferred installation method is to use the Arduino IDE Library Manager. To download the source from Github instead, click "Clone or download" above, then "Download ZIP." After uncompressing, rename the resulting folder Adafruit_SSD1306. Check that the Adafruit_SSD1306 folder contains Adafruit_SSD1306.cpp and Adafruit_SSD1306.h. 18 | 19 | You will also have to install the **Adafruit GFX library** which provides graphics primitves such as lines, circles, text, etc. This also can be found in the Arduino Library Manager, or you can get the source from https://github.com/adafruit/Adafruit-GFX-Library 20 | 21 | ## Changes 22 | 23 | Version 1.2 (November 2018) introduces some significant changes: 24 | 25 | * Display dimensions are now specified in the constructor...you no longer need to edit the .h file for different screens (though old sketches can continue to work that way). 26 | * SPI transactions are used and SPI bitrate can be specified (both require Arduino 1.6 or later). 27 | * SPI and Wire (I2C) interfaces other than the defaults are supported. 28 | 29 | 30 | 31 | ## Compatibility 32 | 33 | MCU |Tested Works|Doesn't Work|Not Tested|Notes 34 | ------------|:----------:|:----------:|:--------:|----- 35 | Atmega328 | X | | | 36 | Atmega32u4 | X | | | 37 | Atmega2560 | X | | | 38 | ESP8266 | X | | | Change OLED_RESET to different pin if using default I2C pins D4/D5. 39 | ESP32 | X | | | 40 | ATSAM3X8E | X | | | 41 | ATSAM21D | X | | | 42 | Intel Curie | X | | | 43 | WICED | X | | | No hardware SPI - bitbang only 44 | ATtiny85 | | X | | 45 | 46 | * ATmega328 : Arduino UNO, Adafruit Pro Trinket, Adafruit Metro 328, Adafruit Metro Mini 47 | * ATmega32u4 : Arduino Leonardo, Arduino Micro, Arduino Yun, Teensy 2.0, Adafruit Flora, Bluefruit Micro 48 | * ATmega2560 : Arduino Mega 49 | * ESP8266 : Adafruit Huzzah 50 | * ATSAM3X8E : Arduino Due 51 | * ATSAM21D : Arduino Zero, M0 Pro, Adafruit Metro Express, Feather M0 52 | * ATtiny85 : Adafruit Gemma, Arduino Gemma, Adafruit Trinket 53 | 54 | 55 | -------------------------------------------------------------------------------- /Arduino dependencies/Adafruit_SSD1306/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | ConfirmFileOp=0 3 | IconResource=C:\Program Files\Google\Drive File Stream\45.0.12.0\GoogleDriveFS.exe,23 4 | -------------------------------------------------------------------------------- /Arduino dependencies/Adafruit_SSD1306/examples/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | ConfirmFileOp=0 3 | IconResource=C:\Program Files\Google\Drive File Stream\45.0.12.0\GoogleDriveFS.exe,23 4 | -------------------------------------------------------------------------------- /Arduino dependencies/Adafruit_SSD1306/examples/ssd1306_128x32_i2c/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | ConfirmFileOp=0 3 | IconResource=C:\Program Files\Google\Drive File Stream\45.0.12.0\GoogleDriveFS.exe,23 4 | -------------------------------------------------------------------------------- /Arduino dependencies/Adafruit_SSD1306/examples/ssd1306_128x32_spi/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | ConfirmFileOp=0 3 | IconResource=C:\Program Files\Google\Drive File Stream\45.0.12.0\GoogleDriveFS.exe,23 4 | -------------------------------------------------------------------------------- /Arduino dependencies/Adafruit_SSD1306/examples/ssd1306_128x64_i2c/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | ConfirmFileOp=0 3 | IconResource=C:\Program Files\Google\Drive File Stream\45.0.12.0\GoogleDriveFS.exe,23 4 | -------------------------------------------------------------------------------- /Arduino dependencies/Adafruit_SSD1306/examples/ssd1306_128x64_spi/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | ConfirmFileOp=0 3 | IconResource=C:\Program Files\Google\Drive File Stream\45.0.12.0\GoogleDriveFS.exe,23 4 | -------------------------------------------------------------------------------- /Arduino dependencies/Adafruit_SSD1306/library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit SSD1306 2 | version=1.2.9 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=SSD1306 oled driver library for monochrome 128x64 and 128x32 displays 6 | paragraph=SSD1306 oled driver library for monochrome 128x64 and 128x32 displays 7 | category=Display 8 | url=https://github.com/adafruit/Adafruit_SSD1306 9 | architectures=* 10 | -------------------------------------------------------------------------------- /Arduino dependencies/Adafruit_SSD1306/license.txt: -------------------------------------------------------------------------------- 1 | Software License Agreement (BSD License) 2 | 3 | Copyright (c) 2012, Adafruit Industries 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 3. Neither the name of the copyright holders nor the 14 | names of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 21 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /Arduino dependencies/Adafruit_SSD1306/splash.h: -------------------------------------------------------------------------------- 1 | #define splash1_width 82 2 | #define splash1_height 64 3 | 4 | const uint8_t PROGMEM splash1_data[] = { 5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 6 | 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 7 | 0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 8 | 0x00, 0x00, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 9 | 0x00, 0x0F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 10 | 0x1F, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 11 | 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xE0, 12 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF0, 0x00, 13 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xF0, 0x00, 0x00, 14 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xF8, 0x7F, 0xF0, 0x00, 0x00, 0x00, 15 | 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFE, 0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 16 | 0x00, 0x00, 0x00, 0x3F, 0xFF, 0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 17 | 0x00, 0x00, 0x1F, 0xFF, 0xFB, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 18 | 0x00, 0x0F, 0xFF, 0xF9, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 19 | 0x0F, 0xFF, 0xF9, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 20 | 0xFF, 0xF1, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFC, 21 | 0x73, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFE, 0x3F, 22 | 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x1E, 0x0F, 23 | 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFE, 0x1F, 0xFC, 24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xF8, 0x00, 25 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xDF, 0xFF, 0xE0, 0x00, 0x00, 26 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x19, 0xFF, 0xC0, 0x00, 0x00, 0x00, 27 | 0x00, 0x00, 0x00, 0x00, 0x3F, 0x3C, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 28 | 0x00, 0x00, 0x00, 0x7E, 0x7C, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 29 | 0x00, 0x00, 0x7F, 0xFE, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 30 | 0x00, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 31 | 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 32 | 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xEF, 33 | 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xCF, 0xFE, 34 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0x07, 0xFE, 0x00, 35 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFC, 0x07, 0xFE, 0x00, 0x00, 36 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xF0, 0x03, 0xFE, 0x00, 0x00, 0x00, 37 | 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 38 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 39 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 40 | 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 41 | 0x80, 0x00, 0xFC, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x07, 0x80, 42 | 0x01, 0xFC, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x07, 0x80, 0x01, 43 | 0xFC, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x07, 0x80, 0x01, 0xE0, 44 | 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x07, 0x80, 0x01, 0xE0, 0x00, 45 | 0x00, 0x00, 0x1E, 0x00, 0x7F, 0xE3, 0xF7, 0x9F, 0xF9, 0xFD, 0xE7, 0x78, 46 | 0x7B, 0xDF, 0xC0, 0xFF, 0xF7, 0xFF, 0xBF, 0xFD, 0xFD, 0xFF, 0x78, 0x7B, 47 | 0xDF, 0xC0, 0xFF, 0xF7, 0xFF, 0xBF, 0xFD, 0xFD, 0xFF, 0x78, 0x7B, 0xDF, 48 | 0xC0, 0xF0, 0xF7, 0x87, 0xBC, 0x3D, 0xE1, 0xFF, 0x78, 0x7B, 0xDE, 0x00, 49 | 0xF0, 0xF7, 0x87, 0xBC, 0x3D, 0xE1, 0xF0, 0x78, 0x7B, 0xDE, 0x00, 0x00, 50 | 0xF7, 0x87, 0x80, 0x3D, 0xE1, 0xE0, 0x78, 0x7B, 0xDE, 0x00, 0x7F, 0xF7, 51 | 0x87, 0x9F, 0xFD, 0xE1, 0xE0, 0x78, 0x7B, 0xDE, 0x00, 0xFF, 0xF7, 0x87, 52 | 0xBF, 0xFD, 0xE1, 0xE0, 0x78, 0x7B, 0xDE, 0x00, 0xF0, 0xF7, 0x87, 0xBC, 53 | 0x3D, 0xE1, 0xE0, 0x78, 0x7B, 0xDE, 0x00, 0xF0, 0xF7, 0x87, 0xBC, 0x3D, 54 | 0xE1, 0xE0, 0x78, 0x7B, 0xDE, 0x00, 0xF0, 0xF7, 0x87, 0xBC, 0x3D, 0xE1, 55 | 0xE0, 0x78, 0x7B, 0xDE, 0x00, 0xFF, 0xF7, 0xFF, 0xBF, 0xFD, 0xE1, 0xE0, 56 | 0x7F, 0xFB, 0xDF, 0xC0, 0xFF, 0xF7, 0xFF, 0xBF, 0xFD, 0xE1, 0xE0, 0x7F, 57 | 0xFB, 0xDF, 0xC0, 0x7C, 0xF3, 0xF3, 0x9F, 0x3D, 0xE1, 0xE0, 0x3E, 0x7B, 58 | 0xCF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 59 | 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 60 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFD, 0x68, 0xDB, 0x11, 0x1A, 0x31, 0xC0, 0xFF, 61 | 0xFF, 0xFF, 0xFF, 0xFD, 0x2B, 0x5A, 0xFB, 0x6A, 0xEF, 0xC0, 0xFF, 0xFF, 62 | 0xFF, 0xFF, 0xFD, 0x4B, 0x5B, 0x3B, 0x1A, 0x33, 0xC0, 0xFF, 0xFF, 0xFF, 63 | 0xFF, 0xFD, 0x6B, 0x5B, 0xDB, 0x6A, 0xFD, 0xC0 }; 64 | 65 | #define splash2_width 115 66 | #define splash2_height 32 67 | 68 | const uint8_t PROGMEM splash2_data[] = { 69 | 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 70 | 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 71 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x00, 72 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF0, 73 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 74 | 0x00, 0x03, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 75 | 0x00, 0x00, 0x00, 0x00, 0x07, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 76 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xF8, 0x00, 0x00, 0x00, 77 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF8, 78 | 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x7E, 0x00, 0x00, 0x01, 0xE0, 0x00, 79 | 0x7F, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0xFE, 0x00, 0x00, 80 | 0x01, 0xE0, 0x00, 0xFF, 0xEF, 0xF8, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 81 | 0xFE, 0x00, 0x00, 0x01, 0xE0, 0x00, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 82 | 0x03, 0xC0, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x7F, 0xFE, 0x7F, 83 | 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x0F, 0x00, 84 | 0x3F, 0xFE, 0x7F, 0xF8, 0x3F, 0xF1, 0xFB, 0xCF, 0xFC, 0xFE, 0xF3, 0xBC, 85 | 0x3D, 0xEF, 0xE0, 0x1F, 0xFE, 0x7F, 0xFF, 0x7F, 0xFB, 0xFF, 0xDF, 0xFE, 86 | 0xFE, 0xFF, 0xBC, 0x3D, 0xEF, 0xE0, 0x1F, 0xC6, 0xFF, 0xFF, 0x7F, 0xFB, 87 | 0xFF, 0xDF, 0xFE, 0xFE, 0xFF, 0xBC, 0x3D, 0xEF, 0xE0, 0x0F, 0xE3, 0xC7, 88 | 0xFE, 0x78, 0x7B, 0xC3, 0xDE, 0x1E, 0xF0, 0xFF, 0xBC, 0x3D, 0xEF, 0x00, 89 | 0x07, 0xFF, 0x87, 0xFC, 0x78, 0x7B, 0xC3, 0xDE, 0x1E, 0xF0, 0xF8, 0x3C, 90 | 0x3D, 0xEF, 0x00, 0x01, 0xFF, 0xFF, 0xF0, 0x00, 0x7B, 0xC3, 0xC0, 0x1E, 91 | 0xF0, 0xF0, 0x3C, 0x3D, 0xEF, 0x00, 0x01, 0xF3, 0x7F, 0xE0, 0x3F, 0xFB, 92 | 0xC3, 0xCF, 0xFE, 0xF0, 0xF0, 0x3C, 0x3D, 0xEF, 0x00, 0x03, 0xE3, 0x3F, 93 | 0x80, 0x7F, 0xFB, 0xC3, 0xDF, 0xFE, 0xF0, 0xF0, 0x3C, 0x3D, 0xEF, 0x00, 94 | 0x07, 0xE7, 0x3C, 0x00, 0x78, 0x7B, 0xC3, 0xDE, 0x1E, 0xF0, 0xF0, 0x3C, 95 | 0x3D, 0xEF, 0x00, 0x07, 0xFF, 0xBE, 0x00, 0x78, 0x7B, 0xC3, 0xDE, 0x1E, 96 | 0xF0, 0xF0, 0x3C, 0x3D, 0xEF, 0x00, 0x07, 0xFF, 0xFE, 0x00, 0x78, 0x7B, 97 | 0xC3, 0xDE, 0x1E, 0xF0, 0xF0, 0x3C, 0x3D, 0xEF, 0x00, 0x0F, 0xFF, 0xFE, 98 | 0x00, 0x7F, 0xFB, 0xFF, 0xDF, 0xFE, 0xF0, 0xF0, 0x3F, 0xFD, 0xEF, 0xE0, 99 | 0x0F, 0xFF, 0xFF, 0x00, 0x7F, 0xFB, 0xFF, 0xDF, 0xFE, 0xF0, 0xF0, 0x3F, 100 | 0xFD, 0xEF, 0xE0, 0x0F, 0xF9, 0xFF, 0x00, 0x3E, 0x79, 0xF9, 0xCF, 0x9E, 101 | 0xF0, 0xF0, 0x1F, 0x3D, 0xE7, 0xE0, 0x1F, 0xF1, 0xFF, 0x00, 0x00, 0x00, 102 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x80, 0xFF, 103 | 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 104 | 0x1C, 0x00, 0x7F, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFE, 0xB4, 0x6D, 0x88, 105 | 0x8D, 0x18, 0xE0, 0x00, 0x00, 0x1F, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFE, 106 | 0x95, 0xAD, 0x7D, 0xB5, 0x77, 0xE0, 0x00, 0x00, 0x0F, 0x00, 0x7F, 0xFF, 107 | 0xFF, 0xFF, 0xFE, 0xA5, 0xAD, 0x9D, 0x8D, 0x19, 0xE0, 0x00, 0x00, 0x06, 108 | 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFE, 0xB5, 0xAD, 0xED, 0xB5, 0x7E, 0xE0 }; 109 | -------------------------------------------------------------------------------- /Arduino dependencies/AsyncTCP-master/.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 | pip install pyserial > /dev/null 12 | 13 | if [ "$OS_IS_WINDOWS" == "1" ]; then 14 | echo "Installing Python Requests ..." 15 | pip 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 && python get.py 32 | cd $script_init_path 33 | 34 | echo "ESP32 Arduino has been installed in '$ARDUINO_ESP32_PATH'" 35 | echo "" 36 | fi 37 | -------------------------------------------------------------------------------- /Arduino dependencies/AsyncTCP-master/.github/scripts/install-arduino-ide.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #OSTYPE: 'linux-gnu', ARCH: 'x86_64' => linux64 4 | #OSTYPE: 'msys', ARCH: 'x86_64' => win32 5 | #OSTYPE: 'darwin18', ARCH: 'i386' => macos 6 | 7 | OSBITS=`arch` 8 | if [[ "$OSTYPE" == "linux"* ]]; then 9 | export OS_IS_LINUX="1" 10 | ARCHIVE_FORMAT="tar.xz" 11 | if [[ "$OSBITS" == "i686" ]]; then 12 | OS_NAME="linux32" 13 | elif [[ "$OSBITS" == "x86_64" ]]; then 14 | OS_NAME="linux64" 15 | elif [[ "$OSBITS" == "armv7l" || "$OSBITS" == "aarch64" ]]; then 16 | OS_NAME="linuxarm" 17 | else 18 | OS_NAME="$OSTYPE-$OSBITS" 19 | echo "Unknown OS '$OS_NAME'" 20 | exit 1 21 | fi 22 | elif [[ "$OSTYPE" == "darwin"* ]]; then 23 | export OS_IS_MACOS="1" 24 | ARCHIVE_FORMAT="zip" 25 | OS_NAME="macosx" 26 | elif [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then 27 | export OS_IS_WINDOWS="1" 28 | ARCHIVE_FORMAT="zip" 29 | OS_NAME="windows" 30 | else 31 | OS_NAME="$OSTYPE-$OSBITS" 32 | echo "Unknown OS '$OS_NAME'" 33 | exit 1 34 | fi 35 | export OS_NAME 36 | 37 | ARDUINO_BUILD_DIR="$HOME/.arduino/build.tmp" 38 | ARDUINO_CACHE_DIR="$HOME/.arduino/cache.tmp" 39 | 40 | if [ "$OS_IS_MACOS" == "1" ]; then 41 | export ARDUINO_IDE_PATH="/Applications/Arduino.app/Contents/Java" 42 | export ARDUINO_USR_PATH="$HOME/Documents/Arduino" 43 | elif [ "$OS_IS_WINDOWS" == "1" ]; then 44 | export ARDUINO_IDE_PATH="$HOME/arduino_ide" 45 | export ARDUINO_USR_PATH="$HOME/Documents/Arduino" 46 | else 47 | export ARDUINO_IDE_PATH="$HOME/arduino_ide" 48 | export ARDUINO_USR_PATH="$HOME/Arduino" 49 | fi 50 | 51 | if [ ! -d "$ARDUINO_IDE_PATH" ]; then 52 | echo "Installing Arduino IDE on $OS_NAME ..." 53 | echo "Downloading 'arduino-nightly-$OS_NAME.$ARCHIVE_FORMAT' to 'arduino.$ARCHIVE_FORMAT' ..." 54 | if [ "$OS_IS_LINUX" == "1" ]; then 55 | wget -O "arduino.$ARCHIVE_FORMAT" "https://www.arduino.cc/download.php?f=/arduino-nightly-$OS_NAME.$ARCHIVE_FORMAT" > /dev/null 2>&1 56 | echo "Extracting 'arduino.$ARCHIVE_FORMAT' ..." 57 | tar xf "arduino.$ARCHIVE_FORMAT" > /dev/null 58 | mv arduino-nightly "$ARDUINO_IDE_PATH" 59 | else 60 | curl -o "arduino.$ARCHIVE_FORMAT" -L "https://www.arduino.cc/download.php?f=/arduino-nightly-$OS_NAME.$ARCHIVE_FORMAT" > /dev/null 2>&1 61 | echo "Extracting 'arduino.$ARCHIVE_FORMAT' ..." 62 | unzip "arduino.$ARCHIVE_FORMAT" > /dev/null 63 | if [ "$OS_IS_MACOS" == "1" ]; then 64 | mv "Arduino.app" "/Applications/Arduino.app" 65 | else 66 | mv arduino-nightly "$ARDUINO_IDE_PATH" 67 | fi 68 | fi 69 | rm -rf "arduino.$ARCHIVE_FORMAT" 70 | 71 | mkdir -p "$ARDUINO_USR_PATH/libraries" 72 | mkdir -p "$ARDUINO_USR_PATH/hardware" 73 | 74 | echo "Arduino IDE Installed in '$ARDUINO_IDE_PATH'" 75 | echo "" 76 | fi 77 | 78 | function build_sketch(){ # build_sketch [extra-options] 79 | if [ "$#" -lt 2 ]; then 80 | echo "ERROR: Illegal number of parameters" 81 | echo "USAGE: build_sketch [extra-options]" 82 | return 1 83 | fi 84 | 85 | local fqbn="$1" 86 | local sketch="$2" 87 | local xtra_opts="$3" 88 | local win_opts="" 89 | if [ "$OS_IS_WINDOWS" == "1" ]; then 90 | local ctags_version=`ls "$ARDUINO_IDE_PATH/tools-builder/ctags/"` 91 | local preprocessor_version=`ls "$ARDUINO_IDE_PATH/tools-builder/arduino-preprocessor/"` 92 | win_opts="-prefs=runtime.tools.ctags.path=$ARDUINO_IDE_PATH/tools-builder/ctags/$ctags_version -prefs=runtime.tools.arduino-preprocessor.path=$ARDUINO_IDE_PATH/tools-builder/arduino-preprocessor/$preprocessor_version" 93 | fi 94 | 95 | echo "" 96 | echo "Compiling '"$(basename "$sketch")"' ..." 97 | mkdir -p "$ARDUINO_BUILD_DIR" 98 | mkdir -p "$ARDUINO_CACHE_DIR" 99 | $ARDUINO_IDE_PATH/arduino-builder -compile -logger=human -core-api-version=10810 \ 100 | -fqbn=$fqbn \ 101 | -warnings="all" \ 102 | -tools "$ARDUINO_IDE_PATH/tools-builder" \ 103 | -tools "$ARDUINO_IDE_PATH/tools" \ 104 | -built-in-libraries "$ARDUINO_IDE_PATH/libraries" \ 105 | -hardware "$ARDUINO_IDE_PATH/hardware" \ 106 | -hardware "$ARDUINO_USR_PATH/hardware" \ 107 | -libraries "$ARDUINO_USR_PATH/libraries" \ 108 | -build-cache "$ARDUINO_CACHE_DIR" \ 109 | -build-path "$ARDUINO_BUILD_DIR" \ 110 | $win_opts $xtra_opts "$sketch" 111 | } 112 | 113 | function count_sketches() # count_sketches 114 | { 115 | local examples="$1" 116 | rm -rf sketches.txt 117 | if [ ! -d "$examples" ]; then 118 | touch sketches.txt 119 | return 0 120 | fi 121 | local sketches=$(find $examples -name *.ino) 122 | local sketchnum=0 123 | for sketch in $sketches; do 124 | local sketchdir=$(dirname $sketch) 125 | local sketchdirname=$(basename $sketchdir) 126 | local sketchname=$(basename $sketch) 127 | if [[ "${sketchdirname}.ino" != "$sketchname" ]]; then 128 | continue 129 | fi; 130 | if [[ -f "$sketchdir/.test.skip" ]]; then 131 | continue 132 | fi 133 | echo $sketch >> sketches.txt 134 | sketchnum=$(($sketchnum + 1)) 135 | done 136 | return $sketchnum 137 | } 138 | 139 | function build_sketches() # build_sketches [extra-options] 140 | { 141 | local fqbn=$1 142 | local examples=$2 143 | local chunk_idex=$3 144 | local chunks_num=$4 145 | local xtra_opts=$5 146 | 147 | if [ "$#" -lt 2 ]; then 148 | echo "ERROR: Illegal number of parameters" 149 | echo "USAGE: build_sketches [ ] [extra-options]" 150 | return 1 151 | fi 152 | 153 | if [ "$#" -lt 4 ]; then 154 | chunk_idex="0" 155 | chunks_num="1" 156 | xtra_opts=$3 157 | fi 158 | 159 | if [ "$chunks_num" -le 0 ]; then 160 | echo "ERROR: Chunks count must be positive number" 161 | return 1 162 | fi 163 | if [ "$chunk_idex" -ge "$chunks_num" ]; then 164 | echo "ERROR: Chunk index must be less than chunks count" 165 | return 1 166 | fi 167 | 168 | set +e 169 | count_sketches "$examples" 170 | local sketchcount=$? 171 | set -e 172 | local sketches=$(cat sketches.txt) 173 | rm -rf sketches.txt 174 | 175 | local chunk_size=$(( $sketchcount / $chunks_num )) 176 | local all_chunks=$(( $chunks_num * $chunk_size )) 177 | if [ "$all_chunks" -lt "$sketchcount" ]; then 178 | chunk_size=$(( $chunk_size + 1 )) 179 | fi 180 | 181 | local start_index=$(( $chunk_idex * $chunk_size )) 182 | if [ "$sketchcount" -le "$start_index" ]; then 183 | echo "Skipping job" 184 | return 0 185 | fi 186 | 187 | local end_index=$(( $(( $chunk_idex + 1 )) * $chunk_size )) 188 | if [ "$end_index" -gt "$sketchcount" ]; then 189 | end_index=$sketchcount 190 | fi 191 | 192 | local start_num=$(( $start_index + 1 )) 193 | echo "Found $sketchcount Sketches"; 194 | echo "Chunk Count : $chunks_num" 195 | echo "Chunk Size : $chunk_size" 196 | echo "Start Sketch: $start_num" 197 | echo "End Sketch : $end_index" 198 | 199 | local sketchnum=0 200 | for sketch in $sketches; do 201 | local sketchdir=$(dirname $sketch) 202 | local sketchdirname=$(basename $sketchdir) 203 | local sketchname=$(basename $sketch) 204 | if [ "${sketchdirname}.ino" != "$sketchname" ] \ 205 | || [ -f "$sketchdir/.test.skip" ]; then 206 | continue 207 | fi 208 | sketchnum=$(($sketchnum + 1)) 209 | if [ "$sketchnum" -le "$start_index" ] \ 210 | || [ "$sketchnum" -gt "$end_index" ]; then 211 | continue 212 | fi 213 | build_sketch "$fqbn" "$sketch" "$xtra_opts" 214 | local result=$? 215 | if [ $result -ne 0 ]; then 216 | return $result 217 | fi 218 | done 219 | return 0 220 | } 221 | -------------------------------------------------------------------------------- /Arduino dependencies/AsyncTCP-master/.github/scripts/install-platformio.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Installing Python Wheel ..." 4 | pip install wheel > /dev/null 2>&1 5 | 6 | echo "Installing PlatformIO ..." 7 | pip 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 2 ]; 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 sketch_dir=$(dirname "$sketch") 23 | echo "" 24 | echo "Compiling '"$(basename "$sketch")"' ..." 25 | python -m platformio ci -l '.' --board "$board" "$sketch_dir" --project-option="board_build.partitions = huge_app.csv" 26 | } 27 | 28 | function count_sketches() # count_sketches 29 | { 30 | local examples="$1" 31 | rm -rf sketches.txt 32 | if [ ! -d "$examples" ]; then 33 | touch sketches.txt 34 | return 0 35 | fi 36 | local sketches=$(find $examples -name *.ino) 37 | local sketchnum=0 38 | for sketch in $sketches; do 39 | local sketchdir=$(dirname $sketch) 40 | local sketchdirname=$(basename $sketchdir) 41 | local sketchname=$(basename $sketch) 42 | if [[ "${sketchdirname}.ino" != "$sketchname" ]]; then 43 | continue 44 | fi; 45 | if [[ -f "$sketchdir/.test.skip" ]]; then 46 | continue 47 | fi 48 | echo $sketch >> sketches.txt 49 | sketchnum=$(($sketchnum + 1)) 50 | done 51 | return $sketchnum 52 | } 53 | 54 | function build_pio_sketches() # build_pio_sketches 55 | { 56 | if [ "$#" -lt 2 ]; then 57 | echo "ERROR: Illegal number of parameters" 58 | echo "USAGE: build_pio_sketches [ ]" 59 | return 1 60 | fi 61 | 62 | local board=$1 63 | local examples=$2 64 | local chunk_idex=$3 65 | local chunks_num=$4 66 | 67 | if [ "$#" -lt 4 ]; then 68 | chunk_idex="0" 69 | chunks_num="1" 70 | fi 71 | 72 | if [ "$chunks_num" -le 0 ]; then 73 | echo "ERROR: Chunks count must be positive number" 74 | return 1 75 | fi 76 | if [ "$chunk_idex" -ge "$chunks_num" ]; then 77 | echo "ERROR: Chunk index must be less than chunks count" 78 | return 1 79 | fi 80 | 81 | set +e 82 | count_sketches "$examples" 83 | local sketchcount=$? 84 | set -e 85 | local sketches=$(cat sketches.txt) 86 | rm -rf sketches.txt 87 | 88 | local chunk_size=$(( $sketchcount / $chunks_num )) 89 | local all_chunks=$(( $chunks_num * $chunk_size )) 90 | if [ "$all_chunks" -lt "$sketchcount" ]; then 91 | chunk_size=$(( $chunk_size + 1 )) 92 | fi 93 | 94 | local start_index=$(( $chunk_idex * $chunk_size )) 95 | if [ "$sketchcount" -le "$start_index" ]; then 96 | echo "Skipping job" 97 | return 0 98 | fi 99 | 100 | local end_index=$(( $(( $chunk_idex + 1 )) * $chunk_size )) 101 | if [ "$end_index" -gt "$sketchcount" ]; then 102 | end_index=$sketchcount 103 | fi 104 | 105 | local start_num=$(( $start_index + 1 )) 106 | echo "Found $sketchcount Sketches"; 107 | echo "Chunk Count : $chunks_num" 108 | echo "Chunk Size : $chunk_size" 109 | echo "Start Sketch: $start_num" 110 | echo "End Sketch : $end_index" 111 | 112 | local sketchnum=0 113 | for sketch in $sketches; do 114 | local sketchdir=$(dirname $sketch) 115 | local sketchdirname=$(basename $sketchdir) 116 | local sketchname=$(basename $sketch) 117 | if [ "${sketchdirname}.ino" != "$sketchname" ] \ 118 | || [ -f "$sketchdir/.test.skip" ]; then 119 | continue 120 | fi 121 | sketchnum=$(($sketchnum + 1)) 122 | if [ "$sketchnum" -le "$start_index" ] \ 123 | || [ "$sketchnum" -gt "$end_index" ]; then 124 | continue 125 | fi 126 | build_pio_sketch "$board" "$sketch" 127 | local result=$? 128 | if [ $result -ne 0 ]; then 129 | return $result 130 | fi 131 | done 132 | return 0 133 | } 134 | -------------------------------------------------------------------------------- /Arduino dependencies/AsyncTCP-master/.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/AsyncTCP" 11 | fi 12 | 13 | CHUNK_INDEX=$1 14 | CHUNKS_CNT=$2 15 | BUILD_PIO=0 16 | if [ "$#" -lt 2 ] || [ "$CHUNKS_CNT" -le 0 ]; then 17 | CHUNK_INDEX=0 18 | CHUNKS_CNT=1 19 | elif [ "$CHUNK_INDEX" -gt "$CHUNKS_CNT" ]; then 20 | CHUNK_INDEX=$CHUNKS_CNT 21 | elif [ "$CHUNK_INDEX" -eq "$CHUNKS_CNT" ]; then 22 | BUILD_PIO=1 23 | fi 24 | 25 | if [ "$BUILD_PIO" -eq 0 ]; then 26 | # ArduinoIDE Test 27 | source ./.github/scripts/install-arduino-ide.sh 28 | source ./.github/scripts/install-arduino-core-esp32.sh 29 | 30 | echo "Installing AsyncTCP ..." 31 | cp -rf "$GITHUB_WORKSPACE" "$ARDUINO_USR_PATH/libraries/AsyncTCP" 32 | 33 | FQBN="espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app" 34 | build_sketches "$FQBN" "$GITHUB_WORKSPACE/examples" 35 | if [ ! "$OS_IS_WINDOWS" == "1" ]; then 36 | echo "Installing ESPAsyncWebServer ..." 37 | git clone https://github.com/me-no-dev/ESPAsyncWebServer "$ARDUINO_USR_PATH/libraries/ESPAsyncWebServer" > /dev/null 2>&1 38 | 39 | echo "Installing ArduinoJson ..." 40 | git clone https://github.com/bblanchon/ArduinoJson "$ARDUINO_USR_PATH/libraries/ArduinoJson" > /dev/null 2>&1 41 | 42 | build_sketches "$FQBN" "$ARDUINO_USR_PATH/libraries/ESPAsyncWebServer/examples" 43 | fi 44 | else 45 | # PlatformIO Test 46 | source ./.github/scripts/install-platformio.sh 47 | 48 | echo "Installing AsyncTCP ..." 49 | python -m platformio lib --storage-dir "$GITHUB_WORKSPACE" install 50 | 51 | BOARD="esp32dev" 52 | build_pio_sketches "$BOARD" "$GITHUB_WORKSPACE/examples" 53 | 54 | if [[ "$OSTYPE" != "cygwin" ]] && [[ "$OSTYPE" != "msys" ]] && [[ "$OSTYPE" != "win32" ]]; then 55 | echo "Installing ESPAsyncWebServer ..." 56 | python -m platformio lib -g install https://github.com/me-no-dev/ESPAsyncWebServer.git > /dev/null 2>&1 57 | git clone https://github.com/me-no-dev/ESPAsyncWebServer "$HOME/ESPAsyncWebServer" > /dev/null 2>&1 58 | 59 | echo "Installing ArduinoJson ..." 60 | python -m platformio lib -g install https://github.com/bblanchon/ArduinoJson.git > /dev/null 2>&1 61 | 62 | build_pio_sketches "$BOARD" "$HOME/ESPAsyncWebServer/examples" 63 | fi 64 | fi 65 | -------------------------------------------------------------------------------- /Arduino dependencies/AsyncTCP-master/.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 | -------------------------------------------------------------------------------- /Arduino dependencies/AsyncTCP-master/.github/workflows/push.yml: -------------------------------------------------------------------------------- 1 | name: Async TCP 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 on ${{ matrix.os }} 14 | runs-on: ${{ matrix.os }} 15 | strategy: 16 | matrix: 17 | os: [ubuntu-latest, macOS-latest] 18 | steps: 19 | - uses: actions/checkout@v1 20 | - name: Build Tests 21 | run: bash ./.github/scripts/on-push.sh 0 1 22 | 23 | build-pio: 24 | name: PlatformIO on ${{ matrix.os }} 25 | runs-on: ${{ matrix.os }} 26 | strategy: 27 | matrix: 28 | os: [ubuntu-latest, macOS-latest] 29 | steps: 30 | - uses: actions/checkout@v1 31 | - name: Build Tests 32 | run: bash ./.github/scripts/on-push.sh 1 1 33 | -------------------------------------------------------------------------------- /Arduino dependencies/AsyncTCP-master/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /Arduino dependencies/AsyncTCP-master/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: python 3 | os: 4 | - linux 5 | 6 | git: 7 | depth: false 8 | 9 | stages: 10 | - build 11 | 12 | jobs: 13 | include: 14 | 15 | - name: "Arduino Build" 16 | if: tag IS blank AND (type = pull_request OR (type = push AND branch = master)) 17 | stage: build 18 | script: bash $TRAVIS_BUILD_DIR/.github/scripts/on-push.sh 19 | 20 | - name: "PlatformIO Build" 21 | if: tag IS blank AND (type = pull_request OR (type = push AND branch = master)) 22 | stage: build 23 | script: bash $TRAVIS_BUILD_DIR/.github/scripts/on-push.sh 1 1 24 | 25 | notifications: 26 | email: 27 | on_success: change 28 | on_failure: change 29 | webhooks: 30 | urls: 31 | - https://webhooks.gitter.im/e/60e65d0c78ea0a920347 32 | on_success: change # options: [always|never|change] default: always 33 | on_failure: always # options: [always|never|change] default: always 34 | on_start: false # default: false 35 | -------------------------------------------------------------------------------- /Arduino dependencies/AsyncTCP-master/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 | ) 12 | 13 | register_component() 14 | 15 | target_compile_options(${COMPONENT_TARGET} PRIVATE -fno-rtti) 16 | -------------------------------------------------------------------------------- /Arduino dependencies/AsyncTCP-master/Kconfig.projbuild: -------------------------------------------------------------------------------- 1 | menu "AsyncTCP Configuration" 2 | 3 | choice ASYNC_TCP_RUNNING_CORE 4 | bool "Core on which AsyncTCP's thread is running" 5 | default ASYNC_TCP_RUN_CORE1 6 | help 7 | Select on which core AsyncTCP is running 8 | 9 | config ASYNC_TCP_RUN_CORE0 10 | bool "CORE 0" 11 | config ASYNC_TCP_RUN_CORE1 12 | bool "CORE 1" 13 | config ASYNC_TCP_RUN_NO_AFFINITY 14 | bool "BOTH" 15 | 16 | endchoice 17 | 18 | config ASYNC_TCP_RUNNING_CORE 19 | int 20 | default 0 if ASYNC_TCP_RUN_CORE0 21 | default 1 if ASYNC_TCP_RUN_CORE1 22 | default -1 if ASYNC_TCP_RUN_NO_AFFINITY 23 | 24 | config ASYNC_TCP_USE_WDT 25 | bool "Enable WDT for the AsyncTCP task" 26 | default "y" 27 | help 28 | Enable WDT for the AsyncTCP task, so it will trigger if a handler is locking the thread. 29 | 30 | endmenu 31 | -------------------------------------------------------------------------------- /Arduino dependencies/AsyncTCP-master/LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /Arduino dependencies/AsyncTCP-master/README.md: -------------------------------------------------------------------------------- 1 | # AsyncTCP 2 | [![Build Status](https://travis-ci.org/me-no-dev/AsyncTCP.svg?branch=master)](https://travis-ci.org/me-no-dev/AsyncTCP) ![](https://github.com/me-no-dev/AsyncTCP/workflows/Async%20TCP%20CI/badge.svg) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/2f7e4d1df8b446d192cbfec6dc174d2d)](https://www.codacy.com/manual/me-no-dev/AsyncTCP?utm_source=github.com&utm_medium=referral&utm_content=me-no-dev/AsyncTCP&utm_campaign=Badge_Grade) 3 | 4 | ### Async TCP Library for ESP32 Arduino 5 | 6 | [![Join the chat at https://gitter.im/me-no-dev/ESPAsyncWebServer](https://badges.gitter.im/me-no-dev/ESPAsyncWebServer.svg)](https://gitter.im/me-no-dev/ESPAsyncWebServer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 7 | 8 | This is a fully asynchronous TCP library, aimed at enabling trouble-free, multi-connection network environment for Espressif's ESP32 MCUs. 9 | 10 | This library is the base for [ESPAsyncWebServer](https://github.com/me-no-dev/ESPAsyncWebServer) 11 | 12 | ## AsyncClient and AsyncServer 13 | The base classes on which everything else is built. They expose all possible scenarios, but are really raw and require more skills to use. 14 | -------------------------------------------------------------------------------- /Arduino dependencies/AsyncTCP-master/component.mk: -------------------------------------------------------------------------------- 1 | COMPONENT_ADD_INCLUDEDIRS := src 2 | COMPONENT_SRCDIRS := src 3 | CXXFLAGS += -fno-rtti 4 | -------------------------------------------------------------------------------- /Arduino dependencies/AsyncTCP-master/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name":"AsyncTCP", 3 | "description":"Asynchronous TCP Library for ESP32", 4 | "keywords":"async,tcp", 5 | "authors": 6 | { 7 | "name": "Hristo Gochkov", 8 | "maintainer": true 9 | }, 10 | "repository": 11 | { 12 | "type": "git", 13 | "url": "https://github.com/me-no-dev/AsyncTCP.git" 14 | }, 15 | "version": "1.1.1", 16 | "license": "LGPL-3.0", 17 | "frameworks": "arduino", 18 | "platforms": "espressif32", 19 | "build": { 20 | "libCompatMode": 2 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Arduino dependencies/AsyncTCP-master/library.properties: -------------------------------------------------------------------------------- 1 | name=AsyncTCP 2 | version=1.1.1 3 | author=Me-No-Dev 4 | maintainer=Me-No-Dev 5 | sentence=Async TCP Library for ESP32 6 | paragraph=Async TCP Library for ESP32 7 | category=Other 8 | url=https://github.com/me-no-dev/AsyncTCP 9 | architectures=* 10 | -------------------------------------------------------------------------------- /Arduino dependencies/ESP32-Arduino-CAN-master/.gitignore: -------------------------------------------------------------------------------- 1 | .pioenvs 2 | .piolibdeps 3 | .vscode/**/* 4 | .travis.yml 5 | platformio.ini 6 | lib/readme.txt -------------------------------------------------------------------------------- /Arduino dependencies/ESP32-Arduino-CAN-master/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Michael Wagner 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Arduino dependencies/ESP32-Arduino-CAN-master/README.md: -------------------------------------------------------------------------------- 1 | # Arduino Library for the ESP32 CAN Bus (ESP32-Arduino-CAN) 2 | 3 | ## Features 4 | 5 | * Support the CAN Bus from the ESP32 (SJA1000) 6 | * CAN Messages send and receive 7 | * Various Bus speeds 8 | * Standard and Extended Frames 9 | * CAN Message Filter 10 | 11 | 12 | 13 | ## Third Party Components 14 | 15 | - Arduino-ESP32-CAN-Demo 16 | - Arduino CAN Demo from [iotsharing.com - nhatuan84](https://github.com/nhatuan84/arduino-esp32-can-demo) 17 | 18 | - ESPCan Driver 19 | - Base CAN Driver from [Thomas Barth](https://github.com/ThomasBarth/ESP32-CAN-Driver) and [Nayar Systems](https://github.com/nayarsystems/ESP32-CAN-Driver) 20 | - General [Component CAN Driver Pack](https://github.com/ESP32DE/ESP32-CAN-Driver/tree/Component_CAN_Driver_Pack) Work for ESP-IDF with menuconfig from [rudi ;-)](http://esp32.de) 21 | 22 | ## Usage 23 | 24 | See the examples in the [/examples](examples) folder. -------------------------------------------------------------------------------- /Arduino dependencies/ESP32-Arduino-CAN-master/examples/esp32can_basic/esp32can_basic.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | CAN_device_t CAN_cfg; // CAN Config 6 | unsigned long previousMillis = 0; // will store last time a CAN Message was send 7 | const int interval = 1000; // interval at which send CAN Messages (milliseconds) 8 | const int rx_queue_size = 10; // Receive Queue size 9 | 10 | void setup() { 11 | Serial.begin(115200); 12 | Serial.println("Basic Demo - ESP32-Arduino-CAN"); 13 | CAN_cfg.speed = CAN_SPEED_125KBPS; 14 | CAN_cfg.tx_pin_id = GPIO_NUM_5; 15 | CAN_cfg.rx_pin_id = GPIO_NUM_4; 16 | CAN_cfg.rx_queue = xQueueCreate(rx_queue_size, sizeof(CAN_frame_t)); 17 | // Init CAN Module 18 | ESP32Can.CANInit(); 19 | } 20 | 21 | void loop() { 22 | 23 | CAN_frame_t rx_frame; 24 | 25 | unsigned long currentMillis = millis(); 26 | 27 | // Receive next CAN frame from queue 28 | if (xQueueReceive(CAN_cfg.rx_queue, &rx_frame, 3 * portTICK_PERIOD_MS) == pdTRUE) { 29 | 30 | if (rx_frame.FIR.B.FF == CAN_frame_std) { 31 | printf("New standard frame"); 32 | } 33 | else { 34 | printf("New extended frame"); 35 | } 36 | 37 | if (rx_frame.FIR.B.RTR == CAN_RTR) { 38 | printf(" RTR from 0x%08X, DLC %d\r\n", rx_frame.MsgID, rx_frame.FIR.B.DLC); 39 | } 40 | else { 41 | printf(" from 0x%08X, DLC %d, Data ", rx_frame.MsgID, rx_frame.FIR.B.DLC); 42 | for (int i = 0; i < rx_frame.FIR.B.DLC; i++) { 43 | printf("0x%02X ", rx_frame.data.u8[i]); 44 | } 45 | printf("\n"); 46 | } 47 | } 48 | // Send CAN Message 49 | if (currentMillis - previousMillis >= interval) { 50 | previousMillis = currentMillis; 51 | CAN_frame_t tx_frame; 52 | tx_frame.FIR.B.FF = CAN_frame_std; 53 | tx_frame.MsgID = 0x001; 54 | tx_frame.FIR.B.DLC = 8; 55 | tx_frame.data.u8[0] = 0x00; 56 | tx_frame.data.u8[1] = 0x01; 57 | tx_frame.data.u8[2] = 0x02; 58 | tx_frame.data.u8[3] = 0x03; 59 | tx_frame.data.u8[4] = 0x04; 60 | tx_frame.data.u8[5] = 0x05; 61 | tx_frame.data.u8[6] = 0x06; 62 | tx_frame.data.u8[7] = 0x07; 63 | ESP32Can.CANWriteFrame(&tx_frame); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Arduino dependencies/ESP32-Arduino-CAN-master/examples/esp32can_filter/esp32can_filter.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | CAN_device_t CAN_cfg; // CAN Config 6 | const int rx_queue_size = 10; // Receive Queue size 7 | 8 | void setup() { 9 | Serial.begin(115200); 10 | Serial.println("Filter Demo - ESP32-Arduino-CAN"); 11 | CAN_cfg.speed = CAN_SPEED_125KBPS; 12 | CAN_cfg.tx_pin_id = GPIO_NUM_5; 13 | CAN_cfg.rx_pin_id = GPIO_NUM_4; 14 | CAN_cfg.rx_queue = xQueueCreate(rx_queue_size, sizeof(CAN_frame_t)); 15 | 16 | // Set CAN Filter 17 | // See in the SJA1000 Datasheet chapter "6.4.15 Acceptance filter" 18 | // and the APPLICATION NOTE AN97076 chapter "4.1.2 Acceptance Filter" 19 | // for PeliCAN Mode 20 | CAN_filter_t p_filter; 21 | p_filter.FM = Single_Mode; 22 | 23 | p_filter.ACR0 = 0x29; 24 | p_filter.ACR1 = 0; 25 | p_filter.ACR2 = 0; 26 | p_filter.ACR3 = 0; 27 | 28 | p_filter.AMR0 = 0; 29 | p_filter.AMR1 = 0xFF; 30 | p_filter.AMR2 = 0xFF; 31 | p_filter.AMR3 = 0xFF; 32 | ESP32Can.CANConfigFilter(&p_filter); 33 | 34 | // Init CAN Module 35 | ESP32Can.CANInit(); 36 | } 37 | 38 | void loop() { 39 | 40 | CAN_frame_t rx_frame; 41 | 42 | unsigned long currentMillis = millis(); 43 | 44 | // Receive next CAN frame from queue 45 | if (xQueueReceive(CAN_cfg.rx_queue, &rx_frame, 3 * portTICK_PERIOD_MS) == pdTRUE) { 46 | 47 | if (rx_frame.FIR.B.FF == CAN_frame_std) { 48 | printf("New standard frame"); 49 | } 50 | else { 51 | printf("New extended frame"); 52 | } 53 | 54 | if (rx_frame.FIR.B.RTR == CAN_RTR) { 55 | printf(" RTR from 0x%08X, DLC %d\r\n", rx_frame.MsgID, rx_frame.FIR.B.DLC); 56 | } 57 | else { 58 | printf(" from 0x%08X, DLC %d, Data ", rx_frame.MsgID, rx_frame.FIR.B.DLC); 59 | for (int i = 0; i < rx_frame.FIR.B.DLC; i++) { 60 | printf("0x%02X ", rx_frame.data.u8[i]); 61 | } 62 | printf("\n"); 63 | } 64 | } 65 | } 66 | 67 | -------------------------------------------------------------------------------- /Arduino dependencies/ESP32-Arduino-CAN-master/examples/esp32can_mirror/esp32can_mirror.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | CAN_device_t CAN_cfg; // CAN Config 6 | const int rx_queue_size = 10; // Receive Queue size 7 | 8 | void setup() { 9 | Serial.begin(115200); 10 | Serial.println("Mirror Demo - ESP32-Arduino-CAN"); 11 | CAN_cfg.speed = CAN_SPEED_125KBPS; 12 | CAN_cfg.tx_pin_id = GPIO_NUM_5; 13 | CAN_cfg.rx_pin_id = GPIO_NUM_4; 14 | CAN_cfg.rx_queue = xQueueCreate(rx_queue_size, sizeof(CAN_frame_t)); 15 | // Init CAN Module 16 | ESP32Can.CANInit(); 17 | } 18 | 19 | void loop() { 20 | CAN_frame_t rx_frame; 21 | //receive next CAN frame from queue 22 | if (xQueueReceive(CAN_cfg.rx_queue, &rx_frame, 3 * portTICK_PERIOD_MS) == pdTRUE) { 23 | 24 | if (rx_frame.FIR.B.FF == CAN_frame_std) { 25 | printf("New standard frame"); 26 | } 27 | else { 28 | printf("New extended frame"); 29 | } 30 | 31 | if (rx_frame.FIR.B.RTR == CAN_RTR) { 32 | printf(" RTR from 0x%08X, DLC %d\r\n", rx_frame.MsgID, rx_frame.FIR.B.DLC); 33 | } 34 | else { 35 | printf(" from 0x%08X, DLC %d, Data ", rx_frame.MsgID, rx_frame.FIR.B.DLC); 36 | for (int i = 0; i < rx_frame.FIR.B.DLC; i++) { 37 | printf("0x%02X ", rx_frame.data.u8[i]); 38 | } 39 | printf("\n"); 40 | } 41 | 42 | //respond to sender 43 | ESP32Can.CANWriteFrame(&rx_frame); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /Arduino dependencies/ESP32-Arduino-CAN-master/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map ESP32CAN 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | ESP32CAN KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | CANInit KEYWORD2 15 | CANWriteFrame KEYWORD2 16 | CANStop KEYWORD2 17 | CANConfigFilter KEYWORD2 18 | ####################################### 19 | # Constants (LITERAL1) 20 | ####################################### 21 | -------------------------------------------------------------------------------- /Arduino dependencies/ESP32-Arduino-CAN-master/library.properties: -------------------------------------------------------------------------------- 1 | name=ESP32CAN 2 | version=0.0.1 3 | author=Michael Wagner 4 | maintainer=https://github.com/miwagner 5 | sentence=ESP32-Arduino-CAN 6 | paragraph=ESP32-Arduino-CAN 7 | category=Device Control 8 | url=https://github.com/miwagner/ESP32-Arduino-CAN 9 | architectures=esp32 10 | -------------------------------------------------------------------------------- /Arduino dependencies/ESP32-Arduino-CAN-master/src/CAN.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @section License 3 | * 4 | * The MIT License (MIT) 5 | * 6 | * Copyright (c) 2017, Thomas Barth, barth-dev.de 7 | * 2018, Michael Wagner, mw@iot-make.de 8 | * Permission is hereby granted, free of charge, to any person 9 | * obtaining a copy of this software and associated documentation 10 | * files (the "Software"), to deal in the Software without 11 | * restriction, including without limitation the rights to use, copy, 12 | * modify, merge, publish, distribute, sublicense, and/or sell copies 13 | * of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 23 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 24 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 25 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | * SOFTWARE. 27 | */ 28 | 29 | #ifndef __DRIVERS_CAN_H__ 30 | #define __DRIVERS_CAN_H__ 31 | 32 | #include 33 | #include "CAN_config.h" 34 | 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** 40 | * \brief CAN frame type (standard/extended) 41 | */ 42 | typedef enum { 43 | CAN_frame_std = 0, /**< Standard frame, using 11 bit identifer. */ 44 | CAN_frame_ext = 1 /**< Extended frame, using 29 bit identifer. */ 45 | } CAN_frame_format_t; 46 | 47 | /** 48 | * \brief CAN RTR 49 | */ 50 | typedef enum { 51 | CAN_no_RTR = 0, /**< No RTR frame. */ 52 | CAN_RTR = 1 /**< RTR frame. */ 53 | } CAN_RTR_t; 54 | 55 | /** \brief Frame information record type */ 56 | typedef union { 57 | uint32_t U; /**< \brief Unsigned access */ 58 | struct { 59 | uint8_t DLC : 4; /**< \brief [3:0] DLC, Data length container */ 60 | unsigned int unknown_2 : 2; /**< \brief \internal unknown */ 61 | CAN_RTR_t RTR : 1; /**< \brief [6:6] RTR, Remote Transmission Request */ 62 | CAN_frame_format_t FF : 1; /**< \brief [7:7] Frame Format, see# CAN_frame_format_t*/ 63 | unsigned int reserved_24 : 24; /**< \brief \internal Reserved */ 64 | } B; 65 | } CAN_FIR_t; 66 | 67 | /** \brief CAN Frame structure */ 68 | typedef struct { 69 | CAN_FIR_t FIR; /**< \brief Frame information record*/ 70 | uint32_t MsgID; /**< \brief Message ID */ 71 | union { 72 | uint8_t u8[8]; /**< \brief Payload byte access*/ 73 | uint32_t u32[2]; /**< \brief Payload u32 access*/ 74 | uint64_t u64; /**< \brief Payload u64 access*/ 75 | } data; 76 | } CAN_frame_t; 77 | 78 | typedef enum { 79 | Dual_Mode=0, /**< \brief The dual acceptance filter option is enabled (two filters, each with the length of 16 bit are active) */ 80 | Single_Mode=1 /**< \brief The single acceptance filter option is enabled (one filter with the length of 32 bit is active) */ 81 | } CAN_filter_mode_t; 82 | 83 | /** \brief CAN Filter structure */ 84 | typedef struct { 85 | CAN_filter_mode_t FM:1; /**< \brief [0:0] Filter Mode */ 86 | uint8_t ACR0; /**< \brief Acceptance Code Register ACR0 */ 87 | uint8_t ACR1; /**< \brief Acceptance Code Register ACR1 */ 88 | uint8_t ACR2; /**< \brief Acceptance Code Register ACR2 */ 89 | uint8_t ACR3; /**< \brief Acceptance Code Register ACR3 */ 90 | uint8_t AMR0; /**< \brief Acceptance Mask Register AMR0 */ 91 | uint8_t AMR1; /**< \brief Acceptance Mask Register AMR1 */ 92 | uint8_t AMR2; /**< \brief Acceptance Mask Register AMR2 */ 93 | uint8_t AMR3; /**< \brief Acceptance Mask Register AMR3 */ 94 | } CAN_filter_t; 95 | 96 | /** 97 | * \brief Initialize the CAN Module 98 | * 99 | * \return 0 CAN Module had been initialized 100 | */ 101 | int CAN_init(void); 102 | 103 | /** 104 | * \brief Send a can frame 105 | * 106 | * \param p_frame Pointer to the frame to be send, see #CAN_frame_t 107 | * \return 0 Frame has been written to the module 108 | */ 109 | int CAN_write_frame(const CAN_frame_t *p_frame); 110 | 111 | /** 112 | * \brief Stops the CAN Module 113 | * 114 | * \return 0 CAN Module was stopped 115 | */ 116 | int CAN_stop(void); 117 | 118 | /** 119 | * \brief Config CAN Filter, must call before CANInit() 120 | * 121 | * \param p_filter Pointer to the filter, see #CAN_filter_t 122 | * \return 0 CAN Filter had been initialized 123 | */ 124 | int CAN_config_filter(const CAN_filter_t* p_filter); 125 | 126 | 127 | #ifdef __cplusplus 128 | } 129 | #endif 130 | 131 | #endif 132 | -------------------------------------------------------------------------------- /Arduino dependencies/ESP32-Arduino-CAN-master/src/CAN_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @section License 3 | * 4 | * The MIT License (MIT) 5 | * 6 | * Copyright (c) 2017, Thomas Barth, barth-dev.de 7 | * 8 | * Permission is hereby granted, free of charge, to any person 9 | * obtaining a copy of this software and associated documentation 10 | * files (the "Software"), to deal in the Software without 11 | * restriction, including without limitation the rights to use, copy, 12 | * modify, merge, publish, distribute, sublicense, and/or sell copies 13 | * of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 23 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 24 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 25 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | * SOFTWARE. 27 | */ 28 | 29 | #ifndef __DRIVERS_CAN_CFG_H__ 30 | #define __DRIVERS_CAN_CFG_H__ 31 | 32 | #include "freertos/FreeRTOS.h" 33 | #include "freertos/queue.h" 34 | #include "freertos/task.h" 35 | #include "driver/gpio.h" 36 | #include "freertos/semphr.h" 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /** \brief CAN Node Bus speed */ 43 | typedef enum { 44 | CAN_SPEED_100KBPS = 100, /**< \brief CAN Node runs at 100kBit/s. */ 45 | CAN_SPEED_125KBPS = 125, /**< \brief CAN Node runs at 125kBit/s. */ 46 | CAN_SPEED_200KBPS = 200, /**< \brief CAN Node runs at 250kBit/s. */ 47 | CAN_SPEED_250KBPS = 250, /**< \brief CAN Node runs at 250kBit/s. */ 48 | CAN_SPEED_500KBPS = 500, /**< \brief CAN Node runs at 500kBit/s. */ 49 | CAN_SPEED_800KBPS = 800, /**< \brief CAN Node runs at 800kBit/s. */ 50 | CAN_SPEED_1000KBPS = 1000 /**< \brief CAN Node runs at 1000kBit/s. */ 51 | } CAN_speed_t; 52 | 53 | /** \brief CAN configuration structure */ 54 | typedef struct { 55 | CAN_speed_t speed; /**< \brief CAN speed. */ 56 | gpio_num_t tx_pin_id; /**< \brief TX pin. */ 57 | gpio_num_t rx_pin_id; /**< \brief RX pin. */ 58 | QueueHandle_t rx_queue; /**< \brief Handler to FreeRTOS RX queue. */ 59 | QueueHandle_t tx_queue; /**< \brief Handler to FreeRTOS TX queue. */ 60 | TaskHandle_t tx_handle; /**< \brief Handler to FreeRTOS TX task. */ 61 | TaskHandle_t rx_handle; /**< \brief Handler to FreeRTOS RX task. */ 62 | } CAN_device_t; 63 | 64 | /** \brief CAN configuration reference */ 65 | extern CAN_device_t CAN_cfg; 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | 71 | #endif /* __DRIVERS_CAN_CFG_H__ */ 72 | -------------------------------------------------------------------------------- /Arduino dependencies/ESP32-Arduino-CAN-master/src/ESP32CAN.cpp: -------------------------------------------------------------------------------- 1 | #include "ESP32CAN.h" 2 | 3 | int ESP32CAN::CANInit() 4 | { 5 | return CAN_init(); 6 | } 7 | int ESP32CAN::CANWriteFrame(const CAN_frame_t* p_frame) 8 | { 9 | return CAN_write_frame(p_frame); 10 | } 11 | int ESP32CAN::CANStop() 12 | { 13 | return CAN_stop(); 14 | } 15 | int ESP32CAN::CANConfigFilter(const CAN_filter_t* p_filter) 16 | { 17 | return CAN_config_filter(p_filter); 18 | } 19 | 20 | ESP32CAN ESP32Can; 21 | -------------------------------------------------------------------------------- /Arduino dependencies/ESP32-Arduino-CAN-master/src/ESP32CAN.h: -------------------------------------------------------------------------------- 1 | #ifndef ESP32CAN_H 2 | #define ESP32CAN_H 3 | 4 | #include "CAN_config.h" 5 | #include "CAN.h" 6 | 7 | class ESP32CAN 8 | { 9 | public: 10 | int CANInit(); 11 | int CANConfigFilter(const CAN_filter_t* p_filter); 12 | int CANWriteFrame(const CAN_frame_t* p_frame); 13 | int CANStop(); 14 | }; 15 | 16 | extern ESP32CAN ESP32Can; 17 | #endif 18 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | charset = utf-8 7 | indent_style = space 8 | indent_size = 2 9 | trim_trailing_whitespace = true 10 | 11 | [keywords.txt] 12 | indent_style = tab 13 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/.github/workflows/build_examples_pio.yml: -------------------------------------------------------------------------------- 1 | name: Build with Platformio 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v1 12 | - name: Set up Python 13 | uses: actions/setup-python@v1 14 | - name: Install dependencies 15 | run: | 16 | python -m pip install --upgrade pip 17 | pip install platformio 18 | - name: Add libraries 19 | run: | 20 | platformio lib -g install AsyncTCP 21 | platformio lib -g install ESPAsyncTCP 22 | - name: Getting ready 23 | run: | 24 | chmod +x ./scripts/CI/build_examples_pio.sh 25 | - name: Build examples 26 | run: | 27 | ./scripts/CI/build_examples_pio.sh 28 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/.github/workflows/cpplint.yml: -------------------------------------------------------------------------------- 1 | name: cpplint 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v1 12 | - name: Set up Python 13 | uses: actions/setup-python@v1 14 | - name: Install dependencies 15 | run: | 16 | python -m pip install --upgrade pip 17 | pip install cpplint 18 | - name: Linting 19 | run: | 20 | cpplint --repository=. --recursive --filter=-whitespace/line_length,-legal/copyright,-runtime/printf,-build/include,-build/namespace ./src 21 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/.gitignore: -------------------------------------------------------------------------------- 1 | /config.json 2 | .vscode/ -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015-2021 Marvin Roger 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/Makefile: -------------------------------------------------------------------------------- 1 | cpplint: 2 | cpplint --repository=. --recursive --filter=-whitespace/line_length,-legal/copyright,-runtime/printf,-build/include,-build/namespace ./src 3 | .PHONY: cpplint 4 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/README.md: -------------------------------------------------------------------------------- 1 | # Async MQTT client for ESP8266 and ESP32 2 | 3 | ![Build with PlatformIO](https://github.com/marvinroger/async-mqtt-client/workflows/Build%20with%20Platformio/badge.svg) 4 | ![cpplint](https://github.com/marvinroger/async-mqtt-client/workflows/cpplint/badge.svg) 5 | 6 | An Arduino for ESP8266 and ESP32 asynchronous [MQTT](http://mqtt.org/) client implementation, built on [me-no-dev/ESPAsyncTCP (ESP8266)](https://github.com/me-no-dev/ESPAsyncTCP) | [me-no-dev/AsyncTCP (ESP32)](https://github.com/me-no-dev/AsyncTCP) . 7 | 8 | ## Features 9 | 10 | * Compliant with the 3.1.1 version of the protocol 11 | * Fully asynchronous 12 | * Subscribe at QoS 0, 1 and 2 13 | * Publish at QoS 0, 1 and 2 14 | * SSL/TLS support 15 | * Available in the [PlatformIO registry](http://platformio.org/lib/show/346/AsyncMqttClient) 16 | 17 | ## Requirements, installation and usage 18 | 19 | The project is documented in the [/docs folder](docs). 20 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/async-mqtt-client.cppcheck: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/docs/1.-Getting-started.md: -------------------------------------------------------------------------------- 1 | # Getting started 2 | 3 | To use AsyncMqttClient, you need: 4 | 5 | * An ESP8266 or ESP32 6 | * The Arduino IDE or equivalent IDE for ESP8266/32 7 | * Basic knowledge of the Arduino environment (use the IDE, upload a sketch, import libraries, ...) 8 | 9 | ## Installing AsyncMqttClient 10 | 11 | There are two ways to install AsyncMqttClient. 12 | 13 | ### 1a. For the Arduino IDE 14 | 15 | 1. Download the [corresponding release](https://github.com/marvinroger/async-mqtt-client/releases/latest) 16 | 2. Load the `.zip` with **Sketch → Include Library → Add .ZIP Library** 17 | 18 | AsyncMqttClient has 1 dependency: 19 | * For ESP8266: [ESPAsyncTCP](https://github.com/me-no-dev/ESPAsyncTCP). Download the [.zip](https://github.com/me-no-dev/ESPAsyncTCP/archive/master.zip) and install it with the same method as above. 20 | * For ESP32: [AsyncTCP](https://github.com/me-no-dev/AsyncTCP). Download the [.zip](https://github.com/me-no-dev/AsyncTCP/archive/master.zip) and install it with the same method as above. 21 | 22 | ## Fully-featured sketch 23 | 24 | See [examples/FullyFeatured-ESP8266.ino](../examples/FullyFeatured-ESP8266/FullyFeatured-ESP8266.ino) 25 | 26 | **Very important: As a rule of thumb, never use blocking functions in the callbacks (don't use `delay()` or `yield()`).** Otherwise, you may very probably experience unexpected behaviors. 27 | 28 | You can go to the [API reference](2.-API-reference.md). 29 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/docs/2.-API-reference.md: -------------------------------------------------------------------------------- 1 | # API reference 2 | 3 | #### AsyncMqttClient() 4 | 5 | Instantiate a new AsyncMqttClient object. 6 | 7 | ### Configuration 8 | 9 | #### AsyncMqttClient& setKeepAlive(uint16_t `keepAlive`) 10 | 11 | Set the keep alive. Defaults to 15 seconds. 12 | 13 | * **`keepAlive`**: Keep alive in seconds 14 | 15 | #### AsyncMqttClient& setClientId(const char\* `clientId`) 16 | 17 | Set the client ID. Defaults to `esp8266`. 18 | 19 | * **`clientId`**: Client ID 20 | 21 | #### AsyncMqttClient& setCleanSession(bool `cleanSession`) 22 | 23 | Whether or not to set the CleanSession flag. Defaults to `true`. 24 | 25 | * **`cleanSession`**: clean session wanted or not 26 | 27 | #### AsyncMqttClient& setMaxTopicLength(uint16_t `maxTopicLength`) 28 | 29 | Set the maximum allowed topic length to receive. If an MQTT packet is received 30 | with a topic longer than this maximum, the packet will be ignored. Defaults to `128`. 31 | 32 | * **`maxTopicLength`**: Maximum allowed topic length to receive 33 | 34 | #### AsyncMqttClient& setCredentials(const char\* `username`, const char\* `password` = nullptr) 35 | 36 | Set the username/password. Defaults to non-auth. 37 | 38 | * **`username`**: Username 39 | * **`password`**: Password 40 | 41 | #### AsyncMqttClient& setWill(const char\* `topic`, uint8_t `qos`, bool `retain`, const char\* `payload` = nullptr, size_t `length` = 0) 42 | 43 | Set the Last Will Testament. Defaults to none. 44 | 45 | * **`topic`**: Topic of the LWT 46 | * **`qos`**: QoS of the LWT 47 | * **`retain`**: Retain flag of the LWT 48 | * **`payload`**: Payload of the LWT. If unset, the payload will be empty 49 | * **`length`**: Payload length. If unset or set to 0, the payload will be considered as a string and its size will be calculated using `strlen(payload)` 50 | 51 | #### AsyncMqttClient& setServer(IPAddress `ip`, uint16_t `port`) 52 | 53 | Set the server. 54 | 55 | * **`ip`**: IP of the server 56 | * **`port`**: Port of the server 57 | 58 | #### AsyncMqttClient& setServer(const char\* `host`, uint16_t `port`) 59 | 60 | Set the server. 61 | 62 | * **`host`**: Host of the server 63 | * **`port`**: Port of the server 64 | 65 | #### AsyncMqttClient& setSecure(bool `secure`) 66 | 67 | Whether or not to use SSL. Defaults to `false`. 68 | 69 | * **`secure`**: SSL wanted or not. 70 | 71 | #### AsyncMqttClient& addServerFingerprint(const uint8_t\* `fingerprint`) 72 | 73 | Adds an acceptable server fingerprint (SHA1). This may be called multiple times to permit any one of the specified fingerprints. By default, if no fingerprint is added, any fingerprint is accepted. 74 | 75 | * **`fingerprint`**: Fingerprint to add 76 | 77 | ### Events handlers 78 | 79 | #### AsyncMqttClient& onConnect(AsyncMqttClientInternals::OnConnectUserCallback `callback`) 80 | 81 | Add a connect event handler. 82 | 83 | * **`callback`**: Function to call 84 | 85 | #### AsyncMqttClient& onDisconnect(AsyncMqttClientInternals::OnDisconnectUserCallback `callback`) 86 | 87 | Add a disconnect event handler. 88 | 89 | * **`callback`**: Function to call 90 | 91 | #### AsyncMqttClient& onSubscribe(AsyncMqttClientInternals::OnSubscribeUserCallback `callback`) 92 | 93 | Add a subscribe acknowledged event handler. 94 | 95 | * **`callback`**: Function to call 96 | 97 | #### AsyncMqttClient& onUnsubscribe(AsyncMqttClientInternals::OnUnsubscribeUserCallback `callback`) 98 | 99 | Add an unsubscribe acknowledged event handler. 100 | 101 | * **`callback`**: Function to call 102 | 103 | #### AsyncMqttClient& onMessage(AsyncMqttClientInternals::OnMessageUserCallback `callback`) 104 | 105 | Add a publish received event handler. 106 | 107 | * **`callback`**: Function to call 108 | 109 | #### AsyncMqttClient& onPublish(AsyncMqttClientInternals::OnPublishUserCallback `callback`) 110 | 111 | Add a publish acknowledged event handler. 112 | 113 | * **`callback`**: Function to call 114 | 115 | ### Operation functions 116 | 117 | #### bool connected() 118 | 119 | Return if the client is currently connected to the broker or not. 120 | 121 | #### void connect() 122 | 123 | Connect to the server. 124 | 125 | #### void disconnect(bool `force` = false) 126 | 127 | Disconnect from the server. 128 | 129 | * **`force`**: Whether to force the disconnection. Defaults to `false` (clean disconnection). 130 | 131 | #### uint16_t subscribe(const char\* `topic`, uint8_t `qos`) 132 | 133 | Subscribe to the given topic at the given QoS. 134 | 135 | Return the packet ID or 0 if failed. 136 | 137 | * **`topic`**: Topic 138 | * **`qos`**: QoS 139 | 140 | #### uint16_t unsubscribe(const char\* `topic`) 141 | 142 | Unsubscribe from the given topic. 143 | 144 | Return the packet ID or 0 if failed. 145 | 146 | * **`topic`**: Topic 147 | 148 | #### uint16_t publish(const char\* `topic`, uint8_t `qos`, bool `retain`, const char\* `payload` = nullptr, size_t `length` = 0, bool dup = false, uint16_t message_id = 0) 149 | 150 | Publish a packet. 151 | 152 | Return the packet ID (or 1 if QoS 0) or 0 if failed. 153 | 154 | * **`topic`**: Topic 155 | * **`qos`**: QoS 156 | * **`retain`**: Retain flag 157 | * **`payload`**: Payload. If unset, the payload will be empty 158 | * **`length`**: Payload length. If unset or set to 0, the payload will be considered as a string and its size will be calculated using `strlen(payload)` 159 | * **`dup`**: ~~Duplicate flag. If set or set to 1, the payload will be flagged as a duplicate~~ Setting is not used anymore 160 | * **`message_id`**: ~~The message ID. If unset or set to 0, the message ID will be automtaically assigned. Use this with the DUP flag to identify which message is being duplicated~~ Setting is not used anymore 161 | 162 | #### bool clearQueue() 163 | 164 | When disconnected, clears all queued messages 165 | 166 | Returns true on succes, false on failure (client is no disconnected) 167 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/docs/3.-Memory-management.md: -------------------------------------------------------------------------------- 1 | # Memory management 2 | 3 | AsyncMqttClient buffers outgoing messages in a queue. On sending data is copied to a raw TCP buffer. Received data is passed directly to the API. 4 | 5 | ## Outgoing messages 6 | 7 | You can send data as long as memory permits. A minimum amount of free memory is set at 4096 bytes. You can lower (or raise) this value by setting `MQTT_MIN_FREE_MEMORY` to your desired value. 8 | If the free memory was sufficient to send your packet, the `publish` method will return a packet ID indicating the packet was queued. Otherwise, a `0` will be returned, and it's your responsability to resend the packet with `publish`. 9 | 10 | ## Incoming messages 11 | 12 | No incoming data is buffered by this library. Messages received by the TCP library is passed directly to the API. The max receive size is about 1460 bytes per call to your onMessage callback but the amount of data you can receive is unlimited. If you receive, say, a 300kB payload (such as an OTA payload), then your `onMessage` callback will be called about 200 times, with the according len, index and total parameters. Keep in mind the library will call your `onMessage` callbacks with the same topic buffer, so if you change the buffer on one call, the buffer will remain changed on subsequent calls. 13 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/docs/4.-Limitations-and-known-issues.md: -------------------------------------------------------------------------------- 1 | # Limitations and known issues 2 | 3 | * The library is spec compliant with one limitation. In case of power loss the following is not honored: 4 | 5 | > Must be kept in memory: 6 | * All messages in a QoS 1 or 2 flow, which are not confirmed by the broker 7 | * All received QoS 2 messages, which are not yet confirmed to the broker 8 | 9 | This means retransmission is not honored in case of a power failure. This behaviour is like explained in point 4.1.1 of the MQTT specification v3.1.1 10 | 11 | * You cannot send payload larger that what can fit on RAM. 12 | 13 | ## SSL limitations 14 | 15 | * SSL requires the build flag -DASYNC_TCP_SSL_ENABLED=1 16 | * SSL only supports fingerprints for server validation. 17 | * If you do not specify one or more acceptable server fingerprints, the SSL connection will be vulnerable to man-in-the-middle attacks. 18 | * Some server certificate signature algorithms do not work. SHA1, SHA224, SHA256, and MD5 are working. SHA384, and SHA512 will cause a crash. 19 | * TLS1.2 is not supported. 20 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/docs/5.-Troubleshooting.md: -------------------------------------------------------------------------------- 1 | # Troubleshooting 2 | 3 | * The payload of incoming messages contains **raw data**. You cannot just print out the data without formatting. This is because Arduino's `print` functions expect a C-string as input and a MQTT payload is not. A simple solution is to print each character of the payload: 4 | 5 | ```cpp 6 | for (size_t i = 0; i < len; ++i) { 7 | Serial.print(payload[i]); 8 | } 9 | ``` 10 | 11 | Further reading: https://en.wikipedia.org/wiki/C_string_handling 12 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/docs/README.md: -------------------------------------------------------------------------------- 1 | AsyncMqttClient documentation 2 | ============================= 3 | 4 | See [index.md](index.md) to view it locally, or http://marvinroger.viewdocs.io/async-mqtt-client/ to view it online. 5 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/docs/index.md: -------------------------------------------------------------------------------- 1 | Welcome to the AsyncMqttClient for ESP8266 docs. 2 | 3 | **

This documentation is only valid for the AsyncMqttClient version in this repo/directory

** 4 | 5 | ----- 6 | 7 | #### 1. [Getting started](1.-Getting-started.md) 8 | #### 2. [API reference](2.-API-reference.md) 9 | #### 3. [Memory management](3.-Memory-management.md) 10 | #### 4. [Limitations and known issues](4.-Limitations-and-known-issues.md) 11 | #### 5. [Troubleshooting](5.-Troubleshooting.md) 12 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/examples/FullyFeatured-ESP32/FullyFeatured-ESP32.ino: -------------------------------------------------------------------------------- 1 | /* 2 | This example uses FreeRTOS softwaretimers as there is no built-in Ticker library 3 | */ 4 | 5 | 6 | #include 7 | extern "C" { 8 | #include "freertos/FreeRTOS.h" 9 | #include "freertos/timers.h" 10 | } 11 | #include 12 | 13 | #define WIFI_SSID "yourSSID" 14 | #define WIFI_PASSWORD "yourpass" 15 | 16 | #define MQTT_HOST IPAddress(192, 168, 1, 10) 17 | #define MQTT_PORT 1883 18 | 19 | AsyncMqttClient mqttClient; 20 | TimerHandle_t mqttReconnectTimer; 21 | TimerHandle_t wifiReconnectTimer; 22 | 23 | void connectToWifi() { 24 | Serial.println("Connecting to Wi-Fi..."); 25 | WiFi.begin(WIFI_SSID, WIFI_PASSWORD); 26 | } 27 | 28 | void connectToMqtt() { 29 | Serial.println("Connecting to MQTT..."); 30 | mqttClient.connect(); 31 | } 32 | 33 | void WiFiEvent(WiFiEvent_t event) { 34 | Serial.printf("[WiFi-event] event: %d\n", event); 35 | switch(event) { 36 | case SYSTEM_EVENT_STA_GOT_IP: 37 | Serial.println("WiFi connected"); 38 | Serial.println("IP address: "); 39 | Serial.println(WiFi.localIP()); 40 | connectToMqtt(); 41 | break; 42 | case SYSTEM_EVENT_STA_DISCONNECTED: 43 | Serial.println("WiFi lost connection"); 44 | xTimerStop(mqttReconnectTimer, 0); // ensure we don't reconnect to MQTT while reconnecting to Wi-Fi 45 | xTimerStart(wifiReconnectTimer, 0); 46 | break; 47 | } 48 | } 49 | 50 | void onMqttConnect(bool sessionPresent) { 51 | Serial.println("Connected to MQTT."); 52 | Serial.print("Session present: "); 53 | Serial.println(sessionPresent); 54 | uint16_t packetIdSub = mqttClient.subscribe("test/lol", 2); 55 | Serial.print("Subscribing at QoS 2, packetId: "); 56 | Serial.println(packetIdSub); 57 | mqttClient.publish("test/lol", 0, true, "test 1"); 58 | Serial.println("Publishing at QoS 0"); 59 | uint16_t packetIdPub1 = mqttClient.publish("test/lol", 1, true, "test 2"); 60 | Serial.print("Publishing at QoS 1, packetId: "); 61 | Serial.println(packetIdPub1); 62 | uint16_t packetIdPub2 = mqttClient.publish("test/lol", 2, true, "test 3"); 63 | Serial.print("Publishing at QoS 2, packetId: "); 64 | Serial.println(packetIdPub2); 65 | } 66 | 67 | void onMqttDisconnect(AsyncMqttClientDisconnectReason reason) { 68 | Serial.println("Disconnected from MQTT."); 69 | 70 | if (WiFi.isConnected()) { 71 | xTimerStart(mqttReconnectTimer, 0); 72 | } 73 | } 74 | 75 | void onMqttSubscribe(uint16_t packetId, uint8_t qos) { 76 | Serial.println("Subscribe acknowledged."); 77 | Serial.print(" packetId: "); 78 | Serial.println(packetId); 79 | Serial.print(" qos: "); 80 | Serial.println(qos); 81 | } 82 | 83 | void onMqttUnsubscribe(uint16_t packetId) { 84 | Serial.println("Unsubscribe acknowledged."); 85 | Serial.print(" packetId: "); 86 | Serial.println(packetId); 87 | } 88 | 89 | void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total) { 90 | Serial.println("Publish received."); 91 | Serial.print(" topic: "); 92 | Serial.println(topic); 93 | Serial.print(" qos: "); 94 | Serial.println(properties.qos); 95 | Serial.print(" dup: "); 96 | Serial.println(properties.dup); 97 | Serial.print(" retain: "); 98 | Serial.println(properties.retain); 99 | Serial.print(" len: "); 100 | Serial.println(len); 101 | Serial.print(" index: "); 102 | Serial.println(index); 103 | Serial.print(" total: "); 104 | Serial.println(total); 105 | } 106 | 107 | void onMqttPublish(uint16_t packetId) { 108 | Serial.println("Publish acknowledged."); 109 | Serial.print(" packetId: "); 110 | Serial.println(packetId); 111 | } 112 | 113 | void setup() { 114 | Serial.begin(115200); 115 | Serial.println(); 116 | Serial.println(); 117 | 118 | mqttReconnectTimer = xTimerCreate("mqttTimer", pdMS_TO_TICKS(2000), pdFALSE, (void*)0, reinterpret_cast(connectToMqtt)); 119 | wifiReconnectTimer = xTimerCreate("wifiTimer", pdMS_TO_TICKS(2000), pdFALSE, (void*)0, reinterpret_cast(connectToWifi)); 120 | 121 | WiFi.onEvent(WiFiEvent); 122 | 123 | mqttClient.onConnect(onMqttConnect); 124 | mqttClient.onDisconnect(onMqttDisconnect); 125 | mqttClient.onSubscribe(onMqttSubscribe); 126 | mqttClient.onUnsubscribe(onMqttUnsubscribe); 127 | mqttClient.onMessage(onMqttMessage); 128 | mqttClient.onPublish(onMqttPublish); 129 | mqttClient.setServer(MQTT_HOST, MQTT_PORT); 130 | 131 | connectToWifi(); 132 | } 133 | 134 | void loop() { 135 | } 136 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/examples/FullyFeatured-ESP8266/FullyFeatured-ESP8266.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #define WIFI_SSID "My_Wi-Fi" 6 | #define WIFI_PASSWORD "my-awesome-password" 7 | 8 | #define MQTT_HOST IPAddress(192, 168, 1, 10) 9 | #define MQTT_PORT 1883 10 | 11 | AsyncMqttClient mqttClient; 12 | Ticker mqttReconnectTimer; 13 | 14 | WiFiEventHandler wifiConnectHandler; 15 | WiFiEventHandler wifiDisconnectHandler; 16 | Ticker wifiReconnectTimer; 17 | 18 | void connectToWifi() { 19 | Serial.println("Connecting to Wi-Fi..."); 20 | WiFi.begin(WIFI_SSID, WIFI_PASSWORD); 21 | } 22 | 23 | void connectToMqtt() { 24 | Serial.println("Connecting to MQTT..."); 25 | mqttClient.connect(); 26 | } 27 | 28 | void onWifiConnect(const WiFiEventStationModeGotIP& event) { 29 | Serial.println("Connected to Wi-Fi."); 30 | connectToMqtt(); 31 | } 32 | 33 | void onWifiDisconnect(const WiFiEventStationModeDisconnected& event) { 34 | Serial.println("Disconnected from Wi-Fi."); 35 | mqttReconnectTimer.detach(); // ensure we don't reconnect to MQTT while reconnecting to Wi-Fi 36 | wifiReconnectTimer.once(2, connectToWifi); 37 | } 38 | 39 | void onMqttConnect(bool sessionPresent) { 40 | Serial.println("Connected to MQTT."); 41 | Serial.print("Session present: "); 42 | Serial.println(sessionPresent); 43 | uint16_t packetIdSub = mqttClient.subscribe("test/lol", 2); 44 | Serial.print("Subscribing at QoS 2, packetId: "); 45 | Serial.println(packetIdSub); 46 | mqttClient.publish("test/lol", 0, true, "test 1"); 47 | Serial.println("Publishing at QoS 0"); 48 | uint16_t packetIdPub1 = mqttClient.publish("test/lol", 1, true, "test 2"); 49 | Serial.print("Publishing at QoS 1, packetId: "); 50 | Serial.println(packetIdPub1); 51 | uint16_t packetIdPub2 = mqttClient.publish("test/lol", 2, true, "test 3"); 52 | Serial.print("Publishing at QoS 2, packetId: "); 53 | Serial.println(packetIdPub2); 54 | } 55 | 56 | void onMqttDisconnect(AsyncMqttClientDisconnectReason reason) { 57 | Serial.println("Disconnected from MQTT."); 58 | 59 | if (WiFi.isConnected()) { 60 | mqttReconnectTimer.once(2, connectToMqtt); 61 | } 62 | } 63 | 64 | void onMqttSubscribe(uint16_t packetId, uint8_t qos) { 65 | Serial.println("Subscribe acknowledged."); 66 | Serial.print(" packetId: "); 67 | Serial.println(packetId); 68 | Serial.print(" qos: "); 69 | Serial.println(qos); 70 | } 71 | 72 | void onMqttUnsubscribe(uint16_t packetId) { 73 | Serial.println("Unsubscribe acknowledged."); 74 | Serial.print(" packetId: "); 75 | Serial.println(packetId); 76 | } 77 | 78 | void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total) { 79 | Serial.println("Publish received."); 80 | Serial.print(" topic: "); 81 | Serial.println(topic); 82 | Serial.print(" qos: "); 83 | Serial.println(properties.qos); 84 | Serial.print(" dup: "); 85 | Serial.println(properties.dup); 86 | Serial.print(" retain: "); 87 | Serial.println(properties.retain); 88 | Serial.print(" len: "); 89 | Serial.println(len); 90 | Serial.print(" index: "); 91 | Serial.println(index); 92 | Serial.print(" total: "); 93 | Serial.println(total); 94 | } 95 | 96 | void onMqttPublish(uint16_t packetId) { 97 | Serial.println("Publish acknowledged."); 98 | Serial.print(" packetId: "); 99 | Serial.println(packetId); 100 | } 101 | 102 | void setup() { 103 | Serial.begin(115200); 104 | Serial.println(); 105 | Serial.println(); 106 | 107 | wifiConnectHandler = WiFi.onStationModeGotIP(onWifiConnect); 108 | wifiDisconnectHandler = WiFi.onStationModeDisconnected(onWifiDisconnect); 109 | 110 | mqttClient.onConnect(onMqttConnect); 111 | mqttClient.onDisconnect(onMqttDisconnect); 112 | mqttClient.onSubscribe(onMqttSubscribe); 113 | mqttClient.onUnsubscribe(onMqttUnsubscribe); 114 | mqttClient.onMessage(onMqttMessage); 115 | mqttClient.onPublish(onMqttPublish); 116 | mqttClient.setServer(MQTT_HOST, MQTT_PORT); 117 | 118 | connectToWifi(); 119 | } 120 | 121 | void loop() { 122 | } 123 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/examples/FullyFeaturedSSL/platformio.ini: -------------------------------------------------------------------------------- 1 | # 2 | # Example PlatformIO configuration file for SSL and non-SSL builds. 3 | # 4 | # Before you will be able to build the SSL version of this project, you will 5 | # need to explicitly install the espressif8266_stage platform. 6 | # 7 | # To perform this installation, refer to step 1 of: 8 | # http://docs.platformio.org/en/latest/platforms/espressif8266.html#using-arduino-framework-with-staging-version 9 | 10 | [platformio] 11 | env_default = ssl 12 | 13 | [env:ssl] 14 | platform = espressif8266_stage 15 | framework = arduino 16 | board = esp01_1m 17 | build_flags = -DASYNC_TCP_SSL_ENABLED=1 18 | lib_deps = AsyncMqttClient 19 | 20 | [env:nossl] 21 | platform = espressif8266 22 | framework = arduino 23 | board = esp01_1m 24 | lib_deps = AsyncMqttClient 25 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/examples/FullyFeaturedSSL/src/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Example project which can be built with SSL enabled or disabled. 3 | // The espressif8266_stage platform must be installed. 4 | // Refer to platformio.ini for the build configuration and platform installation. 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #define WIFI_SSID "My_Wi-Fi" 12 | #define WIFI_PASSWORD "my-awesome-password" 13 | 14 | #define MQTT_HOST IPAddress(192, 168, 1, 10) 15 | 16 | #if ASYNC_TCP_SSL_ENABLED 17 | #define MQTT_SECURE true 18 | #define MQTT_SERVER_FINGERPRINT {0x7e, 0x36, 0x22, 0x01, 0xf9, 0x7e, 0x99, 0x2f, 0xc5, 0xdb, 0x3d, 0xbe, 0xac, 0x48, 0x67, 0x5b, 0x5d, 0x47, 0x94, 0xd2} 19 | #define MQTT_PORT 8883 20 | #else 21 | #define MQTT_PORT 1883 22 | #endif 23 | 24 | AsyncMqttClient mqttClient; 25 | Ticker mqttReconnectTimer; 26 | 27 | WiFiEventHandler wifiConnectHandler; 28 | WiFiEventHandler wifiDisconnectHandler; 29 | Ticker wifiReconnectTimer; 30 | 31 | void connectToWifi() { 32 | Serial.println("Connecting to Wi-Fi..."); 33 | WiFi.begin(WIFI_SSID, WIFI_PASSWORD); 34 | } 35 | 36 | void connectToMqtt() { 37 | Serial.println("Connecting to MQTT..."); 38 | mqttClient.connect(); 39 | } 40 | 41 | void onWifiConnect(const WiFiEventStationModeGotIP& event) { 42 | Serial.println("Connected to Wi-Fi."); 43 | connectToMqtt(); 44 | } 45 | 46 | void onWifiDisconnect(const WiFiEventStationModeDisconnected& event) { 47 | Serial.println("Disconnected from Wi-Fi."); 48 | mqttReconnectTimer.detach(); // ensure we don't reconnect to MQTT while reconnecting to Wi-Fi 49 | wifiReconnectTimer.once(2, connectToWifi); 50 | } 51 | 52 | void onMqttConnect(bool sessionPresent) { 53 | Serial.println("Connected to MQTT."); 54 | Serial.print("Session present: "); 55 | Serial.println(sessionPresent); 56 | uint16_t packetIdSub = mqttClient.subscribe("test/lol", 2); 57 | Serial.print("Subscribing at QoS 2, packetId: "); 58 | Serial.println(packetIdSub); 59 | mqttClient.publish("test/lol", 0, true, "test 1"); 60 | Serial.println("Publishing at QoS 0"); 61 | uint16_t packetIdPub1 = mqttClient.publish("test/lol", 1, true, "test 2"); 62 | Serial.print("Publishing at QoS 1, packetId: "); 63 | Serial.println(packetIdPub1); 64 | uint16_t packetIdPub2 = mqttClient.publish("test/lol", 2, true, "test 3"); 65 | Serial.print("Publishing at QoS 2, packetId: "); 66 | Serial.println(packetIdPub2); 67 | } 68 | 69 | void onMqttDisconnect(AsyncMqttClientDisconnectReason reason) { 70 | Serial.println("Disconnected from MQTT."); 71 | 72 | if (reason == AsyncMqttClientDisconnectReason::TLS_BAD_FINGERPRINT) { 73 | Serial.println("Bad server fingerprint."); 74 | } 75 | 76 | if (WiFi.isConnected()) { 77 | mqttReconnectTimer.once(2, connectToMqtt); 78 | } 79 | } 80 | 81 | void onMqttSubscribe(uint16_t packetId, uint8_t qos) { 82 | Serial.println("Subscribe acknowledged."); 83 | Serial.print(" packetId: "); 84 | Serial.println(packetId); 85 | Serial.print(" qos: "); 86 | Serial.println(qos); 87 | } 88 | 89 | void onMqttUnsubscribe(uint16_t packetId) { 90 | Serial.println("Unsubscribe acknowledged."); 91 | Serial.print(" packetId: "); 92 | Serial.println(packetId); 93 | } 94 | 95 | void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total) { 96 | Serial.println("Publish received."); 97 | Serial.print(" topic: "); 98 | Serial.println(topic); 99 | Serial.print(" qos: "); 100 | Serial.println(properties.qos); 101 | Serial.print(" dup: "); 102 | Serial.println(properties.dup); 103 | Serial.print(" retain: "); 104 | Serial.println(properties.retain); 105 | Serial.print(" len: "); 106 | Serial.println(len); 107 | Serial.print(" index: "); 108 | Serial.println(index); 109 | Serial.print(" total: "); 110 | Serial.println(total); 111 | } 112 | 113 | void onMqttPublish(uint16_t packetId) { 114 | Serial.println("Publish acknowledged."); 115 | Serial.print(" packetId: "); 116 | Serial.println(packetId); 117 | } 118 | 119 | void setup() { 120 | Serial.begin(115200); 121 | Serial.println(); 122 | Serial.println(); 123 | 124 | wifiConnectHandler = WiFi.onStationModeGotIP(onWifiConnect); 125 | wifiDisconnectHandler = WiFi.onStationModeDisconnected(onWifiDisconnect); 126 | 127 | mqttClient.onConnect(onMqttConnect); 128 | mqttClient.onDisconnect(onMqttDisconnect); 129 | mqttClient.onSubscribe(onMqttSubscribe); 130 | mqttClient.onUnsubscribe(onMqttUnsubscribe); 131 | mqttClient.onMessage(onMqttMessage); 132 | mqttClient.onPublish(onMqttPublish); 133 | mqttClient.setServer(MQTT_HOST, MQTT_PORT); 134 | #if ASYNC_TCP_SSL_ENABLED 135 | mqttClient.setSecure(MQTT_SECURE); 136 | if (MQTT_SECURE) { 137 | mqttClient.addServerFingerprint((const uint8_t[])MQTT_SERVER_FINGERPRINT); 138 | } 139 | #endif 140 | 141 | connectToWifi(); 142 | } 143 | 144 | void loop() { 145 | } 146 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Datatypes (KEYWORD1) 3 | ####################################### 4 | 5 | AsyncMqttClient KEYWORD1 6 | AsyncMqttClientDisconnectReason KEYWORD1 7 | AsyncMqttClientMessageProperties KEYWORD1 8 | 9 | ####################################### 10 | # Methods and Functions (KEYWORD2) 11 | ####################################### 12 | 13 | setKeepAlive KEYWORD2 14 | setClientId KEYWORD2 15 | setCleanSession KEYWORD2 16 | setMaxTopicLength KEYWORD2 17 | setCredentials KEYWORD2 18 | setWill KEYWORD2 19 | setServer KEYWORD2 20 | setSecure KEYWORD2 21 | addServerFingerprint KEYWORD2 22 | 23 | onConnect KEYWORD2 24 | onDisconnect KEYWORD2 25 | onSubscribe KEYWORD2 26 | onUnsubscribe KEYWORD2 27 | onMessage KEYWORD2 28 | onPublish KEYWORD2 29 | 30 | connected KEYWORD2 31 | connect KEYWORD2 32 | disconnect KEYWORD2 33 | subscribe KEYWORD2 34 | unsubscribe KEYWORD2 35 | publish KEYWORD2 36 | clearQueue KEYWORD2 37 | 38 | ####################################### 39 | # Constants (LITERAL1) 40 | ####################################### 41 | 42 | TCP_DISCONNECTED LITERAL1 43 | 44 | MQTT_UNACCEPTABLE_PROTOCOL_VERSION LITERAL1 45 | MQTT_IDENTIFIER_REJECTED LITERAL1 46 | MQTT_SERVER_UNAVAILABLE LITERAL1 47 | MQTT_MALFORMED_CREDENTIALS LITERAL1 48 | MQTT_NOT_AUTHORIZED LITERAL1 49 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "AsyncMqttClient", 3 | "keywords": "iot, home, automation, async, mqtt, client, esp8266", 4 | "description": "An Arduino for ESP8266 / ESP32 asynchronous MQTT client implementation", 5 | "authors": 6 | { 7 | "name": "Marvin ROGER", 8 | "url": "https://www.marvinroger.fr" 9 | }, 10 | "repository": 11 | { 12 | "type": "git", 13 | "url": "https://github.com/marvinroger/async-mqtt-client.git" 14 | }, 15 | "version": "0.9.0", 16 | "frameworks": "arduino", 17 | "platforms": ["espressif8266", "espressif32"], 18 | "dependencies": [ 19 | { 20 | "name": "ESPAsyncTCP", 21 | "version": ">=1.2.2", 22 | "platforms": "espressif8266" 23 | }, 24 | { 25 | "name": "AsyncTCP", 26 | "version": ">=1.1.1", 27 | "platforms": "espressif32" 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/library.properties: -------------------------------------------------------------------------------- 1 | name=AsyncMqttClient 2 | version=0.9.0 3 | author=Marvin ROGER 4 | maintainer=Marvin ROGER 5 | sentence=An Arduino for ESP8266 and ESP32 asynchronous MQTT client implementation 6 | paragraph=Like this project? Please star it on GitHub! 7 | category=Communication 8 | url=https://github.com/marvinroger/async-mqtt-client 9 | architectures=esp8266,esp32 10 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/scripts/CI/build_examples_pio.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #pip install -U platformio 4 | #platformio update 5 | platformio lib -g install AsyncTCP 6 | platformio lib -g install ESPAsyncTCP 7 | 8 | RED='\033[0;31m' 9 | GREEN='\033[0;32m' 10 | YELLOW='\033[0;33m' 11 | NC='\033[0m' 12 | 13 | lines=$(find ./examples/ -maxdepth 1 -mindepth 1 -type d) 14 | retval=0 15 | while read line; do 16 | if [[ "$line" != *ESP8266 && "$line" != *ESP32 ]] 17 | then 18 | echo -e "========================== BUILDING $line ==========================" 19 | echo -e "${YELLOW}SKIPPING${NC}" 20 | continue 21 | fi 22 | echo -e "========================== BUILDING $line ==========================" 23 | if [[ -e "$line/platformio.ini" ]] 24 | then 25 | # skipping 26 | #output=$(platformio ci --lib="." --project-conf="$line/platformio.ini" $line 2>&1) 27 | : 28 | else 29 | if [[ "$line" == *ESP8266 ]] 30 | then 31 | output=$(platformio ci --lib="." --project-conf="scripts/CI/platformio_esp8266.ini" $line 2>&1) 32 | else 33 | output=$(platformio ci --lib="." --project-conf="scripts/CI/platformio_esp32.ini" $line 2>&1) 34 | fi 35 | fi 36 | if [ $? -ne 0 ]; then 37 | echo "$output" 38 | echo -e "Building $line ${RED}FAILED${NC}" 39 | retval=1 40 | else 41 | echo -e "${GREEN}SUCCESS${NC}" 42 | fi 43 | done <<< "$lines" 44 | 45 | # cleanup 46 | platformio lib -g uninstall AsyncTCP 47 | platformio lib -g uninstall ESPAsyncTCP 48 | 49 | exit "$retval" 50 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/scripts/CI/platformio_esp32.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter 4 | ; Upload options: custom upload port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; Advanced options: extra scripting 7 | ; 8 | ; Please visit documentation for the other options and examples 9 | ; https://docs.platformio.org/page/projectconf.html 10 | 11 | [env:esp32] 12 | platform = espressif32 13 | board = esp32dev 14 | framework = arduino 15 | build_flags = 16 | -Wall -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/scripts/CI/platformio_esp8266.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter 4 | ; Upload options: custom upload port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; Advanced options: extra scripting 7 | ; 8 | ; Please visit documentation for the other options and examples 9 | ; https://docs.platformio.org/page/projectconf.html 10 | 11 | [env:esp8266] 12 | platform = espressif8266 13 | board = esp01_1m 14 | framework = arduino 15 | build_flags = 16 | -Wall 17 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/scripts/get-fingerprint/get-fingerprint.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import argparse 4 | import ssl 5 | import hashlib 6 | 7 | parser = argparse.ArgumentParser(description='Compute SSL/TLS fingerprints.') 8 | parser.add_argument('--host', required=True) 9 | parser.add_argument('--port', default=8883) 10 | 11 | args = parser.parse_args() 12 | print(args.host) 13 | 14 | cert_pem = ssl.get_server_certificate((args.host, args.port)) 15 | cert_der = ssl.PEM_cert_to_DER_cert(cert_pem) 16 | 17 | md5 = hashlib.md5(cert_der).hexdigest() 18 | sha1 = hashlib.sha1(cert_der).hexdigest() 19 | sha256 = hashlib.sha256(cert_der).hexdigest() 20 | print("MD5: " + md5) 21 | print("SHA1: " + sha1) 22 | print("SHA256: " + sha256) 23 | 24 | print("\nSHA1 as array initializer:") 25 | print("const uint8_t fingerprint[] = {0x" + ", 0x".join([sha1[i:i+2] for i in range(0, len(sha1), 2)]) + "};") 26 | 27 | print("\nSHA1 as function call:") 28 | print("mqttClient.addServerFingerprint((const uint8_t[]){0x" + ", 0x".join([sha1[i:i+2] for i in range(0, len(sha1), 2)]) + "});") 29 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient.h: -------------------------------------------------------------------------------- 1 | #ifndef SRC_ASYNCMQTTCLIENT_H_ 2 | #define SRC_ASYNCMQTTCLIENT_H_ 3 | 4 | #include "AsyncMqttClient.hpp" 5 | 6 | #endif // SRC_ASYNCMQTTCLIENT_H_ 7 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "Arduino.h" 7 | 8 | #ifndef MQTT_MIN_FREE_MEMORY 9 | #define MQTT_MIN_FREE_MEMORY 4096 10 | #endif 11 | 12 | #ifdef ESP32 13 | #include 14 | #include 15 | #elif defined(ESP8266) 16 | #include 17 | #else 18 | #error Platform not supported 19 | #endif 20 | 21 | #if ASYNC_TCP_SSL_ENABLED 22 | #include 23 | #define SHA1_SIZE 20 24 | #endif 25 | 26 | #include "AsyncMqttClient/Flags.hpp" 27 | #include "AsyncMqttClient/ParsingInformation.hpp" 28 | #include "AsyncMqttClient/MessageProperties.hpp" 29 | #include "AsyncMqttClient/Helpers.hpp" 30 | #include "AsyncMqttClient/Callbacks.hpp" 31 | #include "AsyncMqttClient/DisconnectReasons.hpp" 32 | #include "AsyncMqttClient/Storage.hpp" 33 | 34 | #include "AsyncMqttClient/Packets/Packet.hpp" 35 | #include "AsyncMqttClient/Packets/ConnAckPacket.hpp" 36 | #include "AsyncMqttClient/Packets/PingRespPacket.hpp" 37 | #include "AsyncMqttClient/Packets/SubAckPacket.hpp" 38 | #include "AsyncMqttClient/Packets/UnsubAckPacket.hpp" 39 | #include "AsyncMqttClient/Packets/PublishPacket.hpp" 40 | #include "AsyncMqttClient/Packets/PubRelPacket.hpp" 41 | #include "AsyncMqttClient/Packets/PubAckPacket.hpp" 42 | #include "AsyncMqttClient/Packets/PubRecPacket.hpp" 43 | #include "AsyncMqttClient/Packets/PubCompPacket.hpp" 44 | 45 | #include "AsyncMqttClient/Packets/Out/Connect.hpp" 46 | #include "AsyncMqttClient/Packets/Out/PingReq.hpp" 47 | #include "AsyncMqttClient/Packets/Out/PubAck.hpp" 48 | #include "AsyncMqttClient/Packets/Out/Disconn.hpp" 49 | #include "AsyncMqttClient/Packets/Out/Subscribe.hpp" 50 | #include "AsyncMqttClient/Packets/Out/Unsubscribe.hpp" 51 | #include "AsyncMqttClient/Packets/Out/Publish.hpp" 52 | 53 | class AsyncMqttClient { 54 | public: 55 | AsyncMqttClient(); 56 | ~AsyncMqttClient(); 57 | 58 | AsyncMqttClient& setKeepAlive(uint16_t keepAlive); 59 | AsyncMqttClient& setClientId(const char* clientId); 60 | AsyncMqttClient& setCleanSession(bool cleanSession); 61 | AsyncMqttClient& setMaxTopicLength(uint16_t maxTopicLength); 62 | AsyncMqttClient& setCredentials(const char* username, const char* password = nullptr); 63 | AsyncMqttClient& setWill(const char* topic, uint8_t qos, bool retain, const char* payload = nullptr, size_t length = 0); 64 | AsyncMqttClient& setServer(IPAddress ip, uint16_t port); 65 | AsyncMqttClient& setServer(const char* host, uint16_t port); 66 | #if ASYNC_TCP_SSL_ENABLED 67 | AsyncMqttClient& setSecure(bool secure); 68 | AsyncMqttClient& addServerFingerprint(const uint8_t* fingerprint); 69 | #endif 70 | 71 | AsyncMqttClient& onConnect(AsyncMqttClientInternals::OnConnectUserCallback callback); 72 | AsyncMqttClient& onDisconnect(AsyncMqttClientInternals::OnDisconnectUserCallback callback); 73 | AsyncMqttClient& onSubscribe(AsyncMqttClientInternals::OnSubscribeUserCallback callback); 74 | AsyncMqttClient& onUnsubscribe(AsyncMqttClientInternals::OnUnsubscribeUserCallback callback); 75 | AsyncMqttClient& onMessage(AsyncMqttClientInternals::OnMessageUserCallback callback); 76 | AsyncMqttClient& onPublish(AsyncMqttClientInternals::OnPublishUserCallback callback); 77 | 78 | bool connected() const; 79 | void connect(); 80 | void disconnect(bool force = false); 81 | uint16_t subscribe(const char* topic, uint8_t qos); 82 | uint16_t unsubscribe(const char* topic); 83 | uint16_t publish(const char* topic, uint8_t qos, bool retain, const char* payload = nullptr, size_t length = 0, bool dup = false, uint16_t message_id = 0); 84 | bool clearQueue(); // Not MQTT compliant! 85 | 86 | const char* getClientId() const; 87 | 88 | private: 89 | AsyncClient _client; 90 | AsyncMqttClientInternals::OutPacket* _head; 91 | AsyncMqttClientInternals::OutPacket* _tail; 92 | size_t _sent; 93 | enum { 94 | CONNECTING, 95 | CONNECTED, 96 | DISCONNECTING, 97 | DISCONNECTED 98 | } _state; 99 | AsyncMqttClientDisconnectReason _disconnectReason; 100 | uint32_t _lastClientActivity; 101 | uint32_t _lastServerActivity; 102 | uint32_t _lastPingRequestTime; 103 | 104 | char _generatedClientId[18 + 1]; // esp8266-abc123 and esp32-abcdef123456 105 | IPAddress _ip; 106 | const char* _host; 107 | bool _useIp; 108 | #if ASYNC_TCP_SSL_ENABLED 109 | bool _secure; 110 | #endif 111 | uint16_t _port; 112 | uint16_t _keepAlive; 113 | bool _cleanSession; 114 | const char* _clientId; 115 | const char* _username; 116 | const char* _password; 117 | const char* _willTopic; 118 | const char* _willPayload; 119 | uint16_t _willPayloadLength; 120 | uint8_t _willQos; 121 | bool _willRetain; 122 | 123 | #if ASYNC_TCP_SSL_ENABLED 124 | std::vector> _secureServerFingerprints; 125 | #endif 126 | 127 | std::vector _onConnectUserCallbacks; 128 | std::vector _onDisconnectUserCallbacks; 129 | std::vector _onSubscribeUserCallbacks; 130 | std::vector _onUnsubscribeUserCallbacks; 131 | std::vector _onMessageUserCallbacks; 132 | std::vector _onPublishUserCallbacks; 133 | 134 | AsyncMqttClientInternals::ParsingInformation _parsingInformation; 135 | AsyncMqttClientInternals::Packet* _currentParsedPacket; 136 | uint8_t _remainingLengthBufferPosition; 137 | char _remainingLengthBuffer[4]; 138 | 139 | std::vector _pendingPubRels; 140 | 141 | #if defined(ESP32) 142 | SemaphoreHandle_t _xSemaphore = nullptr; 143 | #elif defined(ESP8266) 144 | bool _xSemaphore = false; 145 | #endif 146 | 147 | void _clear(); 148 | void _freeCurrentParsedPacket(); 149 | 150 | // TCP 151 | void _onConnect(); 152 | void _onDisconnect(); 153 | // void _onError(int8_t error); 154 | // void _onTimeout(); 155 | void _onAck(size_t len); 156 | void _onData(char* data, size_t len); 157 | void _onPoll(); 158 | 159 | // QUEUE 160 | void _insert(AsyncMqttClientInternals::OutPacket* packet); // for PUBREL 161 | void _addFront(AsyncMqttClientInternals::OutPacket* packet); // for CONNECT 162 | void _addBack(AsyncMqttClientInternals::OutPacket* packet); // all the rest 163 | void _handleQueue(); 164 | void _clearQueue(bool keepSessionData); 165 | 166 | // MQTT 167 | void _onPingResp(); 168 | void _onConnAck(bool sessionPresent, uint8_t connectReturnCode); 169 | void _onSubAck(uint16_t packetId, char status); 170 | void _onUnsubAck(uint16_t packetId); 171 | void _onMessage(char* topic, char* payload, uint8_t qos, bool dup, bool retain, size_t len, size_t index, size_t total, uint16_t packetId); 172 | void _onPublish(uint16_t packetId, uint8_t qos); 173 | void _onPubRel(uint16_t packetId); 174 | void _onPubAck(uint16_t packetId); 175 | void _onPubRec(uint16_t packetId); 176 | void _onPubComp(uint16_t packetId); 177 | 178 | void _sendPing(); 179 | }; 180 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Callbacks.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "DisconnectReasons.hpp" 6 | #include "MessageProperties.hpp" 7 | #include "Errors.hpp" 8 | 9 | namespace AsyncMqttClientInternals { 10 | // user callbacks 11 | typedef std::function OnConnectUserCallback; 12 | typedef std::function OnDisconnectUserCallback; 13 | typedef std::function OnSubscribeUserCallback; 14 | typedef std::function OnUnsubscribeUserCallback; 15 | typedef std::function OnMessageUserCallback; 16 | typedef std::function OnPublishUserCallback; 17 | typedef std::function OnErrorUserCallback; 18 | 19 | // internal callbacks 20 | typedef std::function OnConnAckInternalCallback; 21 | typedef std::function OnPingRespInternalCallback; 22 | typedef std::function OnSubAckInternalCallback; 23 | typedef std::function OnUnsubAckInternalCallback; 24 | typedef std::function OnMessageInternalCallback; 25 | typedef std::function OnPublishInternalCallback; 26 | typedef std::function OnPubRelInternalCallback; 27 | typedef std::function OnPubAckInternalCallback; 28 | typedef std::function OnPubRecInternalCallback; 29 | typedef std::function OnPubCompInternalCallback; 30 | } // namespace AsyncMqttClientInternals 31 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/DisconnectReasons.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum class AsyncMqttClientDisconnectReason : uint8_t { 4 | TCP_DISCONNECTED = 0, 5 | 6 | MQTT_UNACCEPTABLE_PROTOCOL_VERSION = 1, 7 | MQTT_IDENTIFIER_REJECTED = 2, 8 | MQTT_SERVER_UNAVAILABLE = 3, 9 | MQTT_MALFORMED_CREDENTIALS = 4, 10 | MQTT_NOT_AUTHORIZED = 5, 11 | 12 | ESP8266_NOT_ENOUGH_SPACE = 6, 13 | 14 | TLS_BAD_FINGERPRINT = 7 15 | }; 16 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Errors.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum class AsyncMqttClientError : uint8_t { 4 | MAX_RETRIES = 0, 5 | OUT_OF_MEMORY = 1 6 | }; 7 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Flags.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace AsyncMqttClientInternals { 4 | constexpr struct { 5 | const uint8_t RESERVED = 0; 6 | const uint8_t CONNECT = 1; 7 | const uint8_t CONNACK = 2; 8 | const uint8_t PUBLISH = 3; 9 | const uint8_t PUBACK = 4; 10 | const uint8_t PUBREC = 5; 11 | const uint8_t PUBREL = 6; 12 | const uint8_t PUBCOMP = 7; 13 | const uint8_t SUBSCRIBE = 8; 14 | const uint8_t SUBACK = 9; 15 | const uint8_t UNSUBSCRIBE = 10; 16 | const uint8_t UNSUBACK = 11; 17 | const uint8_t PINGREQ = 12; 18 | const uint8_t PINGRESP = 13; 19 | const uint8_t DISCONNECT = 14; 20 | const uint8_t RESERVED2 = 1; 21 | } PacketType; 22 | 23 | constexpr struct { 24 | const uint8_t CONNECT_RESERVED = 0x00; 25 | const uint8_t CONNACK_RESERVED = 0x00; 26 | const uint8_t PUBLISH_DUP = 0x08; 27 | const uint8_t PUBLISH_QOS0 = 0x00; 28 | const uint8_t PUBLISH_QOS1 = 0x02; 29 | const uint8_t PUBLISH_QOS2 = 0x04; 30 | const uint8_t PUBLISH_QOSRESERVED = 0x06; 31 | const uint8_t PUBLISH_RETAIN = 0x01; 32 | const uint8_t PUBACK_RESERVED = 0x00; 33 | const uint8_t PUBREC_RESERVED = 0x00; 34 | const uint8_t PUBREL_RESERVED = 0x02; 35 | const uint8_t PUBCOMP_RESERVED = 0x00; 36 | const uint8_t SUBSCRIBE_RESERVED = 0x02; 37 | const uint8_t SUBACK_RESERVED = 0x00; 38 | const uint8_t UNSUBSCRIBE_RESERVED = 0x02; 39 | const uint8_t UNSUBACK_RESERVED = 0x00; 40 | const uint8_t PINGREQ_RESERVED = 0x00; 41 | const uint8_t PINGRESP_RESERVED = 0x00; 42 | const uint8_t DISCONNECT_RESERVED = 0x00; 43 | const uint8_t RESERVED2_RESERVED = 0x00; 44 | } HeaderFlag; 45 | 46 | constexpr struct { 47 | const uint8_t USERNAME = 0x80; 48 | const uint8_t PASSWORD = 0x40; 49 | const uint8_t WILL_RETAIN = 0x20; 50 | const uint8_t WILL_QOS0 = 0x00; 51 | const uint8_t WILL_QOS1 = 0x08; 52 | const uint8_t WILL_QOS2 = 0x10; 53 | const uint8_t WILL = 0x04; 54 | const uint8_t CLEAN_SESSION = 0x02; 55 | const uint8_t RESERVED = 0x00; 56 | } ConnectFlag; 57 | } // namespace AsyncMqttClientInternals 58 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Helpers.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace AsyncMqttClientInternals { 4 | class Helpers { 5 | public: 6 | static uint32_t decodeRemainingLength(char* bytes) { 7 | uint32_t multiplier = 1; 8 | uint32_t value = 0; 9 | uint8_t currentByte = 0; 10 | uint8_t encodedByte; 11 | do { 12 | encodedByte = bytes[currentByte++]; 13 | value += (encodedByte & 127) * multiplier; 14 | multiplier *= 128; 15 | } while ((encodedByte & 128) != 0); 16 | 17 | return value; 18 | } 19 | 20 | static uint8_t encodeRemainingLength(uint32_t remainingLength, char* destination) { 21 | uint8_t currentByte = 0; 22 | uint8_t bytesNeeded = 0; 23 | 24 | do { 25 | uint8_t encodedByte = remainingLength % 128; 26 | remainingLength /= 128; 27 | if (remainingLength > 0) { 28 | encodedByte = encodedByte | 128; 29 | } 30 | 31 | destination[currentByte++] = encodedByte; 32 | bytesNeeded++; 33 | } while (remainingLength > 0); 34 | 35 | return bytesNeeded; 36 | } 37 | }; 38 | 39 | #if defined(ARDUINO_ARCH_ESP32) 40 | #define SEMAPHORE_TAKE() xSemaphoreTake(_xSemaphore, portMAX_DELAY) 41 | #define SEMAPHORE_GIVE() xSemaphoreGive(_xSemaphore) 42 | #define GET_FREE_MEMORY() ESP.getMaxAllocHeap() 43 | #include 44 | #elif defined(ARDUINO_ARCH_ESP8266) 45 | #define SEMAPHORE_TAKE(X) while (_xSemaphore) { /*ESP.wdtFeed();*/ } _xSemaphore = true 46 | #define SEMAPHORE_GIVE() _xSemaphore = false 47 | #define GET_FREE_MEMORY() ESP.getMaxFreeBlockSize() 48 | #if defined(DEBUG_ESP_PORT) && defined(DEBUG_ASYNC_MQTT_CLIENT) 49 | #define log_i(...) DEBUG_ESP_PORT.printf(__VA_ARGS__); DEBUG_ESP_PORT.print("\n") 50 | #define log_e(...) DEBUG_ESP_PORT.printf(__VA_ARGS__); DEBUG_ESP_PORT.print("\n") 51 | #define log_w(...) DEBUG_ESP_PORT.printf(__VA_ARGS__); DEBUG_ESP_PORT.print("\n") 52 | #else 53 | #define log_i(...) 54 | #define log_e(...) 55 | #define log_w(...) 56 | #endif 57 | #else 58 | #pragma error "No valid architecture" 59 | #endif 60 | 61 | } // namespace AsyncMqttClientInternals 62 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/MessageProperties.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct AsyncMqttClientMessageProperties { 4 | uint8_t qos; 5 | bool dup; 6 | bool retain; 7 | }; 8 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/ConnAckPacket.cpp: -------------------------------------------------------------------------------- 1 | #include "ConnAckPacket.hpp" 2 | 3 | using AsyncMqttClientInternals::ConnAckPacket; 4 | 5 | ConnAckPacket::ConnAckPacket(ParsingInformation* parsingInformation, OnConnAckInternalCallback callback) 6 | : _parsingInformation(parsingInformation) 7 | , _callback(callback) 8 | , _bytePosition(0) 9 | , _sessionPresent(false) 10 | , _connectReturnCode(0) { 11 | } 12 | 13 | ConnAckPacket::~ConnAckPacket() { 14 | } 15 | 16 | void ConnAckPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) { 17 | char currentByte = data[(*currentBytePosition)++]; 18 | if (_bytePosition++ == 0) { 19 | _sessionPresent = (currentByte << 7) >> 7; 20 | } else { 21 | _connectReturnCode = currentByte; 22 | _parsingInformation->bufferState = BufferState::NONE; 23 | _callback(_sessionPresent, _connectReturnCode); 24 | } 25 | } 26 | 27 | void ConnAckPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) { 28 | (void)data; 29 | (void)currentBytePosition; 30 | } 31 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/ConnAckPacket.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Arduino.h" 4 | #include "Packet.hpp" 5 | #include "../ParsingInformation.hpp" 6 | #include "../Callbacks.hpp" 7 | 8 | namespace AsyncMqttClientInternals { 9 | class ConnAckPacket : public Packet { 10 | public: 11 | explicit ConnAckPacket(ParsingInformation* parsingInformation, OnConnAckInternalCallback callback); 12 | ~ConnAckPacket(); 13 | 14 | void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition); 15 | void parsePayload(char* data, size_t len, size_t* currentBytePosition); 16 | 17 | private: 18 | ParsingInformation* _parsingInformation; 19 | OnConnAckInternalCallback _callback; 20 | 21 | uint8_t _bytePosition; 22 | bool _sessionPresent; 23 | uint8_t _connectReturnCode; 24 | }; 25 | } // namespace AsyncMqttClientInternals 26 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/Out/Connect.cpp: -------------------------------------------------------------------------------- 1 | #include "Connect.hpp" 2 | 3 | using AsyncMqttClientInternals::ConnectOutPacket; 4 | 5 | ConnectOutPacket::ConnectOutPacket(bool cleanSession, 6 | const char* username, 7 | const char* password, 8 | const char* willTopic, 9 | bool willRetain, 10 | uint8_t willQos, 11 | const char* willPayload, 12 | uint16_t willPayloadLength, 13 | uint16_t keepAlive, 14 | const char* clientId) { 15 | char fixedHeader[5]; 16 | fixedHeader[0] = AsyncMqttClientInternals::PacketType.CONNECT; 17 | fixedHeader[0] = fixedHeader[0] << 4; 18 | fixedHeader[0] = fixedHeader[0] | AsyncMqttClientInternals::HeaderFlag.CONNECT_RESERVED; 19 | 20 | uint16_t protocolNameLength = 4; 21 | char protocolNameLengthBytes[2]; 22 | protocolNameLengthBytes[0] = protocolNameLength >> 8; 23 | protocolNameLengthBytes[1] = protocolNameLength & 0xFF; 24 | 25 | char protocolLevel[1]; 26 | protocolLevel[0] = 0x04; 27 | 28 | char connectFlags[1]; 29 | connectFlags[0] = 0; 30 | if (cleanSession) connectFlags[0] |= AsyncMqttClientInternals::ConnectFlag.CLEAN_SESSION; 31 | if (username != nullptr) connectFlags[0] |= AsyncMqttClientInternals::ConnectFlag.USERNAME; 32 | if (password != nullptr) connectFlags[0] |= AsyncMqttClientInternals::ConnectFlag.PASSWORD; 33 | if (willTopic != nullptr) { 34 | connectFlags[0] |= AsyncMqttClientInternals::ConnectFlag.WILL; 35 | if (willRetain) connectFlags[0] |= AsyncMqttClientInternals::ConnectFlag.WILL_RETAIN; 36 | switch (willQos) { 37 | case 0: 38 | connectFlags[0] |= AsyncMqttClientInternals::ConnectFlag.WILL_QOS0; 39 | break; 40 | case 1: 41 | connectFlags[0] |= AsyncMqttClientInternals::ConnectFlag.WILL_QOS1; 42 | break; 43 | case 2: 44 | connectFlags[0] |= AsyncMqttClientInternals::ConnectFlag.WILL_QOS2; 45 | break; 46 | } 47 | } 48 | 49 | char keepAliveBytes[2]; 50 | keepAliveBytes[0] = keepAlive >> 8; 51 | keepAliveBytes[1] = keepAlive & 0xFF; 52 | 53 | uint16_t clientIdLength = strlen(clientId); 54 | char clientIdLengthBytes[2]; 55 | clientIdLengthBytes[0] = clientIdLength >> 8; 56 | clientIdLengthBytes[1] = clientIdLength & 0xFF; 57 | 58 | // Optional fields 59 | uint16_t willTopicLength = 0; 60 | char willTopicLengthBytes[2]; 61 | char willPayloadLengthBytes[2]; 62 | if (willTopic != nullptr) { 63 | willTopicLength = strlen(willTopic); 64 | willTopicLengthBytes[0] = willTopicLength >> 8; 65 | willTopicLengthBytes[1] = willTopicLength & 0xFF; 66 | 67 | if (willPayload != nullptr && willPayloadLength == 0) willPayloadLength = strlen(willPayload); 68 | 69 | willPayloadLengthBytes[0] = willPayloadLength >> 8; 70 | willPayloadLengthBytes[1] = willPayloadLength & 0xFF; 71 | } 72 | 73 | uint16_t usernameLength = 0; 74 | char usernameLengthBytes[2]; 75 | if (username != nullptr) { 76 | usernameLength = strlen(username); 77 | usernameLengthBytes[0] = usernameLength >> 8; 78 | usernameLengthBytes[1] = usernameLength & 0xFF; 79 | } 80 | 81 | uint16_t passwordLength = 0; 82 | char passwordLengthBytes[2]; 83 | if (password != nullptr) { 84 | passwordLength = strlen(password); 85 | passwordLengthBytes[0] = passwordLength >> 8; 86 | passwordLengthBytes[1] = passwordLength & 0xFF; 87 | } 88 | 89 | uint32_t remainingLength = 2 + protocolNameLength + 1 + 1 + 2 + 2 + clientIdLength; // always present 90 | if (willTopic != nullptr) remainingLength += 2 + willTopicLength + 2 + willPayloadLength; 91 | if (username != nullptr) remainingLength += 2 + usernameLength; 92 | if (password != nullptr) remainingLength += 2 + passwordLength; 93 | uint8_t remainingLengthLength = AsyncMqttClientInternals::Helpers::encodeRemainingLength(remainingLength, fixedHeader + 1); 94 | 95 | uint32_t neededSpace = 1 + remainingLengthLength; 96 | neededSpace += 2; 97 | neededSpace += protocolNameLength; 98 | neededSpace += 1; 99 | neededSpace += 1; 100 | neededSpace += 2; 101 | neededSpace += 2; 102 | neededSpace += clientIdLength; 103 | if (willTopic != nullptr) { 104 | neededSpace += 2; 105 | neededSpace += willTopicLength; 106 | 107 | neededSpace += 2; 108 | if (willPayload != nullptr) neededSpace += willPayloadLength; 109 | } 110 | if (username != nullptr) { 111 | neededSpace += 2; 112 | neededSpace += usernameLength; 113 | } 114 | if (password != nullptr) { 115 | neededSpace += 2; 116 | neededSpace += passwordLength; 117 | } 118 | 119 | _data.reserve(neededSpace); 120 | 121 | _data.insert(_data.end(), fixedHeader, fixedHeader + 1 + remainingLengthLength); 122 | 123 | _data.push_back(protocolNameLengthBytes[0]); 124 | _data.push_back(protocolNameLengthBytes[1]); 125 | 126 | _data.push_back('M'); 127 | _data.push_back('Q'); 128 | _data.push_back('T'); 129 | _data.push_back('T'); 130 | 131 | _data.push_back(protocolLevel[0]); 132 | _data.push_back(connectFlags[0]); 133 | _data.push_back(keepAliveBytes[0]); 134 | _data.push_back(keepAliveBytes[1]); 135 | _data.push_back(clientIdLengthBytes[0]); 136 | _data.push_back(clientIdLengthBytes[1]); 137 | 138 | _data.insert(_data.end(), clientId, clientId + clientIdLength); 139 | if (willTopic != nullptr) { 140 | _data.insert(_data.end(), willTopicLengthBytes, willTopicLengthBytes + 2); 141 | _data.insert(_data.end(), willTopic, willTopic + willTopicLength); 142 | 143 | _data.insert(_data.end(), willPayloadLengthBytes, willPayloadLengthBytes + 2); 144 | if (willPayload != nullptr) _data.insert(_data.end(), willPayload, willPayload + willPayloadLength); 145 | } 146 | if (username != nullptr) { 147 | _data.insert(_data.end(), usernameLengthBytes, usernameLengthBytes + 2); 148 | _data.insert(_data.end(), username, username + usernameLength); 149 | } 150 | if (password != nullptr) { 151 | _data.insert(_data.end(), passwordLengthBytes, passwordLengthBytes + 2); 152 | _data.insert(_data.end(), password, password + passwordLength); 153 | } 154 | } 155 | 156 | const uint8_t* ConnectOutPacket::data(size_t index) const { 157 | return &_data.data()[index]; 158 | } 159 | 160 | size_t ConnectOutPacket::size() const { 161 | return _data.size(); 162 | } 163 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/Out/Connect.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include // strlen 5 | 6 | #include "OutPacket.hpp" 7 | #include "../../Flags.hpp" 8 | #include "../../Helpers.hpp" 9 | 10 | namespace AsyncMqttClientInternals { 11 | class ConnectOutPacket : public OutPacket { 12 | public: 13 | ConnectOutPacket(bool cleanSession, 14 | const char* username, 15 | const char* password, 16 | const char* willTopic, 17 | bool willRetain, 18 | uint8_t willQos, 19 | const char* willPayload, 20 | uint16_t willPayloadLength, 21 | uint16_t keepAlive, 22 | const char* clientId); 23 | const uint8_t* data(size_t index = 0) const; 24 | size_t size() const; 25 | 26 | private: 27 | std::vector _data; 28 | }; 29 | } // namespace AsyncMqttClientInternals 30 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/Out/Disconn.cpp: -------------------------------------------------------------------------------- 1 | #include "Disconn.hpp" 2 | 3 | using AsyncMqttClientInternals::DisconnOutPacket; 4 | 5 | DisconnOutPacket::DisconnOutPacket() { 6 | _data[0] = AsyncMqttClientInternals::PacketType.DISCONNECT; 7 | _data[0] = _data[0] << 4; 8 | _data[0] = _data[0] | AsyncMqttClientInternals::HeaderFlag.DISCONNECT_RESERVED; 9 | _data[1] = 0; 10 | } 11 | 12 | const uint8_t* DisconnOutPacket::data(size_t index) const { 13 | return &_data[index]; 14 | } 15 | 16 | size_t DisconnOutPacket::size() const { 17 | return 2; 18 | } 19 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/Out/Disconn.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "OutPacket.hpp" 4 | #include "../../Flags.hpp" 5 | #include "../../Helpers.hpp" 6 | 7 | namespace AsyncMqttClientInternals { 8 | class DisconnOutPacket : public OutPacket { 9 | public: 10 | DisconnOutPacket(); 11 | const uint8_t* data(size_t index = 0) const; 12 | size_t size() const; 13 | 14 | private: 15 | uint8_t _data[2]; 16 | }; 17 | } // namespace AsyncMqttClientInternals 18 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/Out/OutPacket.cpp: -------------------------------------------------------------------------------- 1 | #include "OutPacket.hpp" 2 | 3 | using AsyncMqttClientInternals::OutPacket; 4 | 5 | OutPacket::OutPacket() 6 | : next(nullptr) 7 | , timeout(0) 8 | , noTries(0) 9 | , _released(true) 10 | , _packetId(0) {} 11 | 12 | OutPacket::~OutPacket() {} 13 | 14 | bool OutPacket::released() const { 15 | return _released; 16 | } 17 | 18 | uint8_t OutPacket::packetType() const { 19 | return data(0)[0] >> 4; 20 | } 21 | 22 | uint16_t OutPacket::packetId() const { 23 | return _packetId; 24 | } 25 | 26 | uint8_t OutPacket::qos() const { 27 | if (packetType() == AsyncMqttClientInternals::PacketType.PUBLISH) { 28 | return (data()[1] & 0x06) >> 1; 29 | } 30 | return 0; 31 | } 32 | 33 | void OutPacket::release() { 34 | _released = true; 35 | } 36 | 37 | uint16_t OutPacket::_nextPacketId = 0; 38 | 39 | uint16_t OutPacket::_getNextPacketId() { 40 | if (++_nextPacketId == 0) { 41 | ++_nextPacketId; 42 | } 43 | return _nextPacketId; 44 | } 45 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/Out/OutPacket.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include // uint*_t 4 | #include // size_t 5 | #include // std::min 6 | 7 | #include "../../Flags.hpp" 8 | 9 | namespace AsyncMqttClientInternals { 10 | class OutPacket { 11 | public: 12 | OutPacket(); 13 | virtual ~OutPacket(); 14 | virtual const uint8_t* data(size_t index = 0) const = 0; 15 | virtual size_t size() const = 0; 16 | bool released() const; 17 | uint8_t packetType() const; 18 | uint16_t packetId() const; 19 | uint8_t qos() const; 20 | void release(); 21 | 22 | public: 23 | OutPacket* next; 24 | uint32_t timeout; 25 | uint8_t noTries; 26 | 27 | protected: 28 | static uint16_t _getNextPacketId(); 29 | bool _released; 30 | uint16_t _packetId; 31 | 32 | private: 33 | static uint16_t _nextPacketId; 34 | }; 35 | } // namespace AsyncMqttClientInternals 36 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/Out/PingReq.cpp: -------------------------------------------------------------------------------- 1 | #include "PingReq.hpp" 2 | 3 | using AsyncMqttClientInternals::PingReqOutPacket; 4 | 5 | PingReqOutPacket::PingReqOutPacket() { 6 | _data[0] = AsyncMqttClientInternals::PacketType.PINGREQ; 7 | _data[0] = _data[0] << 4; 8 | _data[0] = _data[0] | AsyncMqttClientInternals::HeaderFlag.PINGREQ_RESERVED; 9 | _data[1] = 0; 10 | } 11 | 12 | const uint8_t* PingReqOutPacket::data(size_t index) const { 13 | return &_data[index];; 14 | } 15 | 16 | size_t PingReqOutPacket::size() const { 17 | return 2; 18 | } 19 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/Out/PingReq.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "OutPacket.hpp" 4 | #include "../../Flags.hpp" 5 | #include "../../Helpers.hpp" 6 | 7 | namespace AsyncMqttClientInternals { 8 | class PingReqOutPacket : public OutPacket { 9 | public: 10 | PingReqOutPacket(); 11 | const uint8_t* data(size_t index = 0) const; 12 | size_t size() const; 13 | 14 | private: 15 | uint8_t _data[2]; 16 | }; 17 | } // namespace AsyncMqttClientInternals 18 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/Out/PubAck.cpp: -------------------------------------------------------------------------------- 1 | #include "PubAck.hpp" 2 | 3 | using AsyncMqttClientInternals::PubAckOutPacket; 4 | 5 | PubAckOutPacket::PubAckOutPacket(PendingAck pendingAck) { 6 | _data[0] = pendingAck.packetType; 7 | _data[0] = _data[0] << 4; 8 | _data[0] = _data[0] | pendingAck.headerFlag; 9 | _data[1] = 2; 10 | _packetId = pendingAck.packetId; 11 | _data[2] = pendingAck.packetId >> 8; 12 | _data[3] = pendingAck.packetId & 0xFF; 13 | if (packetType() == AsyncMqttClientInternals::PacketType.PUBREL || 14 | packetType() == AsyncMqttClientInternals::PacketType.PUBREC) { 15 | _released = false; 16 | } 17 | } 18 | 19 | const uint8_t* PubAckOutPacket::data(size_t index) const { 20 | return &_data[index]; 21 | } 22 | 23 | size_t PubAckOutPacket::size() const { 24 | return 4; 25 | } 26 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/Out/PubAck.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "OutPacket.hpp" 4 | #include "../../Flags.hpp" 5 | #include "../../Helpers.hpp" 6 | #include "../../Storage.hpp" 7 | 8 | namespace AsyncMqttClientInternals { 9 | class PubAckOutPacket : public OutPacket { 10 | public: 11 | explicit PubAckOutPacket(PendingAck pendingAck); 12 | const uint8_t* data(size_t index = 0) const; 13 | size_t size() const; 14 | 15 | private: 16 | uint8_t _data[4]; 17 | }; 18 | } // namespace AsyncMqttClientInternals 19 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/Out/Publish.cpp: -------------------------------------------------------------------------------- 1 | #include "Publish.hpp" 2 | 3 | using AsyncMqttClientInternals::PublishOutPacket; 4 | 5 | PublishOutPacket::PublishOutPacket(const char* topic, uint8_t qos, bool retain, const char* payload, size_t length) { 6 | char fixedHeader[5]; 7 | fixedHeader[0] = AsyncMqttClientInternals::PacketType.PUBLISH; 8 | fixedHeader[0] = fixedHeader[0] << 4; 9 | // if (dup) fixedHeader[0] |= AsyncMqttClientInternals::HeaderFlag.PUBLISH_DUP; 10 | if (retain) fixedHeader[0] |= AsyncMqttClientInternals::HeaderFlag.PUBLISH_RETAIN; 11 | switch (qos) { 12 | case 0: 13 | fixedHeader[0] |= AsyncMqttClientInternals::HeaderFlag.PUBLISH_QOS0; 14 | break; 15 | case 1: 16 | fixedHeader[0] |= AsyncMqttClientInternals::HeaderFlag.PUBLISH_QOS1; 17 | break; 18 | case 2: 19 | fixedHeader[0] |= AsyncMqttClientInternals::HeaderFlag.PUBLISH_QOS2; 20 | break; 21 | } 22 | 23 | uint16_t topicLength = strlen(topic); 24 | char topicLengthBytes[2]; 25 | topicLengthBytes[0] = topicLength >> 8; 26 | topicLengthBytes[1] = topicLength & 0xFF; 27 | 28 | uint32_t payloadLength = length; 29 | if (payload != nullptr && payloadLength == 0) payloadLength = strlen(payload); 30 | 31 | uint32_t remainingLength = 2 + topicLength + payloadLength; 32 | if (qos != 0) remainingLength += 2; 33 | uint8_t remainingLengthLength = AsyncMqttClientInternals::Helpers::encodeRemainingLength(remainingLength, fixedHeader + 1); 34 | 35 | size_t neededSpace = 0; 36 | neededSpace += 1 + remainingLengthLength; 37 | neededSpace += 2; 38 | neededSpace += topicLength; 39 | if (qos != 0) neededSpace += 2; 40 | if (payload != nullptr) neededSpace += payloadLength; 41 | 42 | _data.reserve(neededSpace); 43 | 44 | _packetId = (qos !=0) ? _getNextPacketId() : 1; 45 | char packetIdBytes[2]; 46 | packetIdBytes[0] = _packetId >> 8; 47 | packetIdBytes[1] = _packetId & 0xFF; 48 | 49 | _data.insert(_data.end(), fixedHeader, fixedHeader + 1 + remainingLengthLength); 50 | _data.insert(_data.end(), topicLengthBytes, topicLengthBytes + 2); 51 | _data.insert(_data.end(), topic, topic + topicLength); 52 | if (qos != 0) { 53 | _data.insert(_data.end(), packetIdBytes, packetIdBytes + 2); 54 | _released = false; 55 | } 56 | if (payload != nullptr) _data.insert(_data.end(), payload, payload + payloadLength); 57 | } 58 | 59 | const uint8_t* PublishOutPacket::data(size_t index) const { 60 | return &_data.data()[index]; 61 | } 62 | 63 | size_t PublishOutPacket::size() const { 64 | return _data.size(); 65 | } 66 | 67 | void PublishOutPacket::setDup() { 68 | _data[0] |= AsyncMqttClientInternals::HeaderFlag.PUBLISH_DUP; 69 | } 70 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/Out/Publish.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include // strlen 4 | #include 5 | 6 | #include "OutPacket.hpp" 7 | #include "../../Flags.hpp" 8 | #include "../../Helpers.hpp" 9 | #include "../../Storage.hpp" 10 | 11 | namespace AsyncMqttClientInternals { 12 | class PublishOutPacket : public OutPacket { 13 | public: 14 | PublishOutPacket(const char* topic, uint8_t qos, bool retain, const char* payload, size_t length); 15 | const uint8_t* data(size_t index = 0) const; 16 | size_t size() const; 17 | 18 | void setDup(); // you cannot unset dup 19 | 20 | private: 21 | std::vector _data; 22 | }; 23 | } // namespace AsyncMqttClientInternals 24 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/Out/Subscribe.cpp: -------------------------------------------------------------------------------- 1 | #include "Subscribe.hpp" 2 | 3 | using AsyncMqttClientInternals::SubscribeOutPacket; 4 | 5 | SubscribeOutPacket::SubscribeOutPacket(const char* topic, uint8_t qos) { 6 | char fixedHeader[5]; 7 | fixedHeader[0] = AsyncMqttClientInternals::PacketType.SUBSCRIBE; 8 | fixedHeader[0] = fixedHeader[0] << 4; 9 | fixedHeader[0] = fixedHeader[0] | AsyncMqttClientInternals::HeaderFlag.SUBSCRIBE_RESERVED; 10 | 11 | uint16_t topicLength = strlen(topic); 12 | char topicLengthBytes[2]; 13 | topicLengthBytes[0] = topicLength >> 8; 14 | topicLengthBytes[1] = topicLength & 0xFF; 15 | 16 | char qosByte[1]; 17 | qosByte[0] = qos; 18 | 19 | uint8_t remainingLengthLength = AsyncMqttClientInternals::Helpers::encodeRemainingLength(2 + 2 + topicLength + 1, fixedHeader + 1); 20 | 21 | size_t neededSpace = 0; 22 | neededSpace += 1 + remainingLengthLength; 23 | neededSpace += 2; 24 | neededSpace += 2; 25 | neededSpace += topicLength; 26 | neededSpace += 1; 27 | 28 | _data.reserve(neededSpace); 29 | 30 | _packetId = _getNextPacketId(); 31 | char packetIdBytes[2]; 32 | packetIdBytes[0] = _packetId >> 8; 33 | packetIdBytes[1] = _packetId & 0xFF; 34 | 35 | _data.insert(_data.end(), fixedHeader, fixedHeader + 1 + remainingLengthLength); 36 | _data.insert(_data.end(), packetIdBytes, packetIdBytes + 2); 37 | _data.insert(_data.end(), topicLengthBytes, topicLengthBytes + 2); 38 | _data.insert(_data.end(), topic, topic + topicLength); 39 | _data.push_back(qosByte[0]); 40 | _released = false; 41 | } 42 | 43 | const uint8_t* SubscribeOutPacket::data(size_t index) const { 44 | return &_data.data()[index]; 45 | } 46 | 47 | size_t SubscribeOutPacket::size() const { 48 | return _data.size(); 49 | } 50 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/Out/Subscribe.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include // strlen 4 | #include 5 | 6 | #include "OutPacket.hpp" 7 | #include "../../Flags.hpp" 8 | #include "../../Helpers.hpp" 9 | #include "../../Storage.hpp" 10 | 11 | namespace AsyncMqttClientInternals { 12 | class SubscribeOutPacket : public OutPacket { 13 | public: 14 | SubscribeOutPacket(const char* topic, uint8_t qos); 15 | const uint8_t* data(size_t index = 0) const; 16 | size_t size() const; 17 | 18 | private: 19 | std::vector _data; 20 | }; 21 | } // namespace AsyncMqttClientInternals 22 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/Out/Unsubscribe.cpp: -------------------------------------------------------------------------------- 1 | #include "Unsubscribe.hpp" 2 | 3 | using AsyncMqttClientInternals::UnsubscribeOutPacket; 4 | 5 | UnsubscribeOutPacket::UnsubscribeOutPacket(const char* topic) { 6 | char fixedHeader[5]; 7 | fixedHeader[0] = AsyncMqttClientInternals::PacketType.UNSUBSCRIBE; 8 | fixedHeader[0] = fixedHeader[0] << 4; 9 | fixedHeader[0] = fixedHeader[0] | AsyncMqttClientInternals::HeaderFlag.UNSUBSCRIBE_RESERVED; 10 | 11 | uint16_t topicLength = strlen(topic); 12 | char topicLengthBytes[2]; 13 | topicLengthBytes[0] = topicLength >> 8; 14 | topicLengthBytes[1] = topicLength & 0xFF; 15 | 16 | uint8_t remainingLengthLength = AsyncMqttClientInternals::Helpers::encodeRemainingLength(2 + 2 + topicLength, fixedHeader + 1); 17 | 18 | size_t neededSpace = 0; 19 | neededSpace += 1 + remainingLengthLength; 20 | neededSpace += 2; 21 | neededSpace += 2; 22 | neededSpace += topicLength; 23 | 24 | _packetId = _getNextPacketId(); 25 | char packetIdBytes[2]; 26 | packetIdBytes[0] = _packetId >> 8; 27 | packetIdBytes[1] = _packetId & 0xFF; 28 | 29 | _data.insert(_data.end(), fixedHeader, fixedHeader + 1 + remainingLengthLength); 30 | _data.insert(_data.end(), packetIdBytes, packetIdBytes + 2); 31 | _data.insert(_data.end(), topicLengthBytes, topicLengthBytes + 2); 32 | _data.insert(_data.end(), topic, topic + topicLength); 33 | _released = false; 34 | } 35 | 36 | const uint8_t* UnsubscribeOutPacket::data(size_t index) const { 37 | return &_data.data()[index]; 38 | } 39 | 40 | size_t UnsubscribeOutPacket::size() const { 41 | return _data.size(); 42 | } 43 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/Out/Unsubscribe.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include // strlen 4 | #include 5 | 6 | #include "OutPacket.hpp" 7 | #include "../../Flags.hpp" 8 | #include "../../Helpers.hpp" 9 | #include "../../Storage.hpp" 10 | 11 | namespace AsyncMqttClientInternals { 12 | class UnsubscribeOutPacket : public OutPacket { 13 | public: 14 | explicit UnsubscribeOutPacket(const char* topic); 15 | const uint8_t* data(size_t index = 0) const; 16 | size_t size() const; 17 | 18 | private: 19 | std::vector _data; 20 | }; 21 | } // namespace AsyncMqttClientInternals 22 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/Packet.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace AsyncMqttClientInternals { 4 | class Packet { 5 | public: 6 | virtual ~Packet() {} 7 | 8 | virtual void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) = 0; 9 | virtual void parsePayload(char* data, size_t len, size_t* currentBytePosition) = 0; 10 | }; 11 | } // namespace AsyncMqttClientInternals 12 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/PingRespPacket.cpp: -------------------------------------------------------------------------------- 1 | #include "PingRespPacket.hpp" 2 | 3 | using AsyncMqttClientInternals::PingRespPacket; 4 | 5 | PingRespPacket::PingRespPacket(ParsingInformation* parsingInformation, OnPingRespInternalCallback callback) 6 | : _parsingInformation(parsingInformation) 7 | , _callback(callback) { 8 | } 9 | 10 | PingRespPacket::~PingRespPacket() { 11 | } 12 | 13 | void PingRespPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) { 14 | (void)data; 15 | (void)currentBytePosition; 16 | } 17 | 18 | void PingRespPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) { 19 | (void)data; 20 | (void)currentBytePosition; 21 | } 22 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/PingRespPacket.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Arduino.h" 4 | #include "Packet.hpp" 5 | #include "../ParsingInformation.hpp" 6 | #include "../Callbacks.hpp" 7 | 8 | namespace AsyncMqttClientInternals { 9 | class PingRespPacket : public Packet { 10 | public: 11 | explicit PingRespPacket(ParsingInformation* parsingInformation, OnPingRespInternalCallback callback); 12 | ~PingRespPacket(); 13 | 14 | void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition); 15 | void parsePayload(char* data, size_t len, size_t* currentBytePosition); 16 | 17 | private: 18 | ParsingInformation* _parsingInformation; 19 | OnPingRespInternalCallback _callback; 20 | }; 21 | } // namespace AsyncMqttClientInternals 22 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/PubAckPacket.cpp: -------------------------------------------------------------------------------- 1 | #include "PubAckPacket.hpp" 2 | 3 | using AsyncMqttClientInternals::PubAckPacket; 4 | 5 | PubAckPacket::PubAckPacket(ParsingInformation* parsingInformation, OnPubAckInternalCallback callback) 6 | : _parsingInformation(parsingInformation) 7 | , _callback(callback) 8 | , _bytePosition(0) 9 | , _packetIdMsb(0) 10 | , _packetId(0) { 11 | } 12 | 13 | PubAckPacket::~PubAckPacket() { 14 | } 15 | 16 | void PubAckPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) { 17 | char currentByte = data[(*currentBytePosition)++]; 18 | if (_bytePosition++ == 0) { 19 | _packetIdMsb = currentByte; 20 | } else { 21 | _packetId = currentByte | _packetIdMsb << 8; 22 | _parsingInformation->bufferState = BufferState::NONE; 23 | _callback(_packetId); 24 | } 25 | } 26 | 27 | void PubAckPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) { 28 | (void)data; 29 | (void)currentBytePosition; 30 | } 31 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/PubAckPacket.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Arduino.h" 4 | #include "Packet.hpp" 5 | #include "../ParsingInformation.hpp" 6 | #include "../Callbacks.hpp" 7 | 8 | namespace AsyncMqttClientInternals { 9 | class PubAckPacket : public Packet { 10 | public: 11 | explicit PubAckPacket(ParsingInformation* parsingInformation, OnPubAckInternalCallback callback); 12 | ~PubAckPacket(); 13 | 14 | void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition); 15 | void parsePayload(char* data, size_t len, size_t* currentBytePosition); 16 | 17 | private: 18 | ParsingInformation* _parsingInformation; 19 | OnPubAckInternalCallback _callback; 20 | 21 | uint8_t _bytePosition; 22 | char _packetIdMsb; 23 | uint16_t _packetId; 24 | }; 25 | } // namespace AsyncMqttClientInternals 26 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/PubCompPacket.cpp: -------------------------------------------------------------------------------- 1 | #include "PubCompPacket.hpp" 2 | 3 | using AsyncMqttClientInternals::PubCompPacket; 4 | 5 | PubCompPacket::PubCompPacket(ParsingInformation* parsingInformation, OnPubCompInternalCallback callback) 6 | : _parsingInformation(parsingInformation) 7 | , _callback(callback) 8 | , _bytePosition(0) 9 | , _packetIdMsb(0) 10 | , _packetId(0) { 11 | } 12 | 13 | PubCompPacket::~PubCompPacket() { 14 | } 15 | 16 | void PubCompPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) { 17 | char currentByte = data[(*currentBytePosition)++]; 18 | if (_bytePosition++ == 0) { 19 | _packetIdMsb = currentByte; 20 | } else { 21 | _packetId = currentByte | _packetIdMsb << 8; 22 | _parsingInformation->bufferState = BufferState::NONE; 23 | _callback(_packetId); 24 | } 25 | } 26 | 27 | void PubCompPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) { 28 | (void)data; 29 | (void)currentBytePosition; 30 | } 31 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/PubCompPacket.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Arduino.h" 4 | #include "Packet.hpp" 5 | #include "../ParsingInformation.hpp" 6 | #include "../Callbacks.hpp" 7 | 8 | namespace AsyncMqttClientInternals { 9 | class PubCompPacket : public Packet { 10 | public: 11 | explicit PubCompPacket(ParsingInformation* parsingInformation, OnPubCompInternalCallback callback); 12 | ~PubCompPacket(); 13 | 14 | void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition); 15 | void parsePayload(char* data, size_t len, size_t* currentBytePosition); 16 | 17 | private: 18 | ParsingInformation* _parsingInformation; 19 | OnPubCompInternalCallback _callback; 20 | 21 | uint8_t _bytePosition; 22 | char _packetIdMsb; 23 | uint16_t _packetId; 24 | }; 25 | } // namespace AsyncMqttClientInternals 26 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/PubRecPacket.cpp: -------------------------------------------------------------------------------- 1 | #include "PubRecPacket.hpp" 2 | 3 | using AsyncMqttClientInternals::PubRecPacket; 4 | 5 | PubRecPacket::PubRecPacket(ParsingInformation* parsingInformation, OnPubRecInternalCallback callback) 6 | : _parsingInformation(parsingInformation) 7 | , _callback(callback) 8 | , _bytePosition(0) 9 | , _packetIdMsb(0) 10 | , _packetId(0) { 11 | } 12 | 13 | PubRecPacket::~PubRecPacket() { 14 | } 15 | 16 | void PubRecPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) { 17 | char currentByte = data[(*currentBytePosition)++]; 18 | if (_bytePosition++ == 0) { 19 | _packetIdMsb = currentByte; 20 | } else { 21 | _packetId = currentByte | _packetIdMsb << 8; 22 | _parsingInformation->bufferState = BufferState::NONE; 23 | _callback(_packetId); 24 | } 25 | } 26 | 27 | void PubRecPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) { 28 | (void)data; 29 | (void)currentBytePosition; 30 | } 31 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/PubRecPacket.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Arduino.h" 4 | #include "Packet.hpp" 5 | #include "../ParsingInformation.hpp" 6 | #include "../Callbacks.hpp" 7 | 8 | namespace AsyncMqttClientInternals { 9 | class PubRecPacket : public Packet { 10 | public: 11 | explicit PubRecPacket(ParsingInformation* parsingInformation, OnPubRecInternalCallback callback); 12 | ~PubRecPacket(); 13 | 14 | void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition); 15 | void parsePayload(char* data, size_t len, size_t* currentBytePosition); 16 | 17 | private: 18 | ParsingInformation* _parsingInformation; 19 | OnPubRecInternalCallback _callback; 20 | 21 | uint8_t _bytePosition; 22 | char _packetIdMsb; 23 | uint16_t _packetId; 24 | }; 25 | } // namespace AsyncMqttClientInternals 26 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/PubRelPacket.cpp: -------------------------------------------------------------------------------- 1 | #include "PubRelPacket.hpp" 2 | 3 | using AsyncMqttClientInternals::PubRelPacket; 4 | 5 | PubRelPacket::PubRelPacket(ParsingInformation* parsingInformation, OnPubRelInternalCallback callback) 6 | : _parsingInformation(parsingInformation) 7 | , _callback(callback) 8 | , _bytePosition(0) 9 | , _packetIdMsb(0) 10 | , _packetId(0) { 11 | } 12 | 13 | PubRelPacket::~PubRelPacket() { 14 | } 15 | 16 | void PubRelPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) { 17 | char currentByte = data[(*currentBytePosition)++]; 18 | if (_bytePosition++ == 0) { 19 | _packetIdMsb = currentByte; 20 | } else { 21 | _packetId = currentByte | _packetIdMsb << 8; 22 | _parsingInformation->bufferState = BufferState::NONE; 23 | _callback(_packetId); 24 | } 25 | } 26 | 27 | void PubRelPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) { 28 | (void)data; 29 | (void)currentBytePosition; 30 | } 31 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/PubRelPacket.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Arduino.h" 4 | #include "Packet.hpp" 5 | #include "../ParsingInformation.hpp" 6 | #include "../Callbacks.hpp" 7 | 8 | namespace AsyncMqttClientInternals { 9 | class PubRelPacket : public Packet { 10 | public: 11 | explicit PubRelPacket(ParsingInformation* parsingInformation, OnPubRelInternalCallback callback); 12 | ~PubRelPacket(); 13 | 14 | void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition); 15 | void parsePayload(char* data, size_t len, size_t* currentBytePosition); 16 | 17 | private: 18 | ParsingInformation* _parsingInformation; 19 | OnPubRelInternalCallback _callback; 20 | 21 | uint8_t _bytePosition; 22 | char _packetIdMsb; 23 | uint16_t _packetId; 24 | }; 25 | } // namespace AsyncMqttClientInternals 26 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/PublishPacket.cpp: -------------------------------------------------------------------------------- 1 | #include "PublishPacket.hpp" 2 | 3 | using AsyncMqttClientInternals::PublishPacket; 4 | 5 | PublishPacket::PublishPacket(ParsingInformation* parsingInformation, OnMessageInternalCallback dataCallback, OnPublishInternalCallback completeCallback) 6 | : _parsingInformation(parsingInformation) 7 | , _dataCallback(dataCallback) 8 | , _completeCallback(completeCallback) 9 | , _dup(false) 10 | , _qos(0) 11 | , _retain(0) 12 | , _bytePosition(0) 13 | , _topicLengthMsb(0) 14 | , _topicLength(0) 15 | , _ignore(false) 16 | , _packetIdMsb(0) 17 | , _packetId(0) 18 | , _payloadLength(0) 19 | , _payloadBytesRead(0) { 20 | _dup = _parsingInformation->packetFlags & HeaderFlag.PUBLISH_DUP; 21 | _retain = _parsingInformation->packetFlags & HeaderFlag.PUBLISH_RETAIN; 22 | char qosMasked = _parsingInformation->packetFlags & 0x06; 23 | switch (qosMasked) { 24 | case HeaderFlag.PUBLISH_QOS0: 25 | _qos = 0; 26 | break; 27 | case HeaderFlag.PUBLISH_QOS1: 28 | _qos = 1; 29 | break; 30 | case HeaderFlag.PUBLISH_QOS2: 31 | _qos = 2; 32 | break; 33 | } 34 | } 35 | 36 | PublishPacket::~PublishPacket() { 37 | } 38 | 39 | void PublishPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) { 40 | char currentByte = data[(*currentBytePosition)++]; 41 | if (_bytePosition == 0) { 42 | _topicLengthMsb = currentByte; 43 | } else if (_bytePosition == 1) { 44 | _topicLength = currentByte | _topicLengthMsb << 8; 45 | if (_topicLength > _parsingInformation->maxTopicLength) { 46 | _ignore = true; 47 | } else { 48 | _parsingInformation->topicBuffer[_topicLength] = '\0'; 49 | } 50 | } else if (_bytePosition >= 2 && _bytePosition < 2 + _topicLength) { 51 | // Starting from here, _ignore might be true 52 | if (!_ignore) _parsingInformation->topicBuffer[_bytePosition - 2] = currentByte; 53 | if (_bytePosition == 2 + _topicLength - 1 && _qos == 0) { 54 | _preparePayloadHandling(_parsingInformation->remainingLength - (_bytePosition + 1)); 55 | return; 56 | } 57 | } else if (_bytePosition == 2 + _topicLength) { 58 | _packetIdMsb = currentByte; 59 | } else { 60 | _packetId = currentByte | _packetIdMsb << 8; 61 | _preparePayloadHandling(_parsingInformation->remainingLength - (_bytePosition + 1)); 62 | } 63 | _bytePosition++; 64 | } 65 | 66 | void PublishPacket::_preparePayloadHandling(uint32_t payloadLength) { 67 | _payloadLength = payloadLength; 68 | if (payloadLength == 0) { 69 | _parsingInformation->bufferState = BufferState::NONE; 70 | if (!_ignore) { 71 | _dataCallback(_parsingInformation->topicBuffer, nullptr, _qos, _dup, _retain, 0, 0, 0, _packetId); 72 | _completeCallback(_packetId, _qos); 73 | } 74 | } else { 75 | _parsingInformation->bufferState = BufferState::PAYLOAD; 76 | } 77 | } 78 | 79 | void PublishPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) { 80 | size_t remainToRead = len - (*currentBytePosition); 81 | if (_payloadBytesRead + remainToRead > _payloadLength) remainToRead = _payloadLength - _payloadBytesRead; 82 | 83 | if (!_ignore) _dataCallback(_parsingInformation->topicBuffer, data + (*currentBytePosition), _qos, _dup, _retain, remainToRead, _payloadBytesRead, _payloadLength, _packetId); 84 | _payloadBytesRead += remainToRead; 85 | (*currentBytePosition) += remainToRead; 86 | 87 | if (_payloadBytesRead == _payloadLength) { 88 | _parsingInformation->bufferState = BufferState::NONE; 89 | if (!_ignore) _completeCallback(_packetId, _qos); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/PublishPacket.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Arduino.h" 4 | #include "Packet.hpp" 5 | #include "../Flags.hpp" 6 | #include "../ParsingInformation.hpp" 7 | #include "../Callbacks.hpp" 8 | 9 | namespace AsyncMqttClientInternals { 10 | class PublishPacket : public Packet { 11 | public: 12 | explicit PublishPacket(ParsingInformation* parsingInformation, OnMessageInternalCallback dataCallback, OnPublishInternalCallback completeCallback); 13 | ~PublishPacket(); 14 | 15 | void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition); 16 | void parsePayload(char* data, size_t len, size_t* currentBytePosition); 17 | 18 | private: 19 | ParsingInformation* _parsingInformation; 20 | OnMessageInternalCallback _dataCallback; 21 | OnPublishInternalCallback _completeCallback; 22 | 23 | void _preparePayloadHandling(uint32_t payloadLength); 24 | 25 | bool _dup; 26 | uint8_t _qos; 27 | bool _retain; 28 | 29 | uint8_t _bytePosition; 30 | char _topicLengthMsb; 31 | uint16_t _topicLength; 32 | bool _ignore; 33 | char _packetIdMsb; 34 | uint16_t _packetId; 35 | uint32_t _payloadLength; 36 | uint32_t _payloadBytesRead; 37 | }; 38 | } // namespace AsyncMqttClientInternals 39 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/SubAckPacket.cpp: -------------------------------------------------------------------------------- 1 | #include "SubAckPacket.hpp" 2 | 3 | using AsyncMqttClientInternals::SubAckPacket; 4 | 5 | SubAckPacket::SubAckPacket(ParsingInformation* parsingInformation, OnSubAckInternalCallback callback) 6 | : _parsingInformation(parsingInformation) 7 | , _callback(callback) 8 | , _bytePosition(0) 9 | , _packetIdMsb(0) 10 | , _packetId(0) { 11 | } 12 | 13 | SubAckPacket::~SubAckPacket() { 14 | } 15 | 16 | void SubAckPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) { 17 | char currentByte = data[(*currentBytePosition)++]; 18 | if (_bytePosition++ == 0) { 19 | _packetIdMsb = currentByte; 20 | } else { 21 | _packetId = currentByte | _packetIdMsb << 8; 22 | _parsingInformation->bufferState = BufferState::PAYLOAD; 23 | } 24 | } 25 | 26 | void SubAckPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) { 27 | char status = data[(*currentBytePosition)++]; 28 | 29 | /* switch (status) { 30 | case 0: 31 | Serial.println("Success QoS 0"); 32 | break; 33 | case 1: 34 | Serial.println("Success QoS 1"); 35 | break; 36 | case 2: 37 | Serial.println("Success QoS 2"); 38 | break; 39 | case 0x80: 40 | Serial.println("Failure"); 41 | break; 42 | } */ 43 | 44 | _parsingInformation->bufferState = BufferState::NONE; 45 | _callback(_packetId, status); 46 | } 47 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/SubAckPacket.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Arduino.h" 4 | #include "Packet.hpp" 5 | #include "../ParsingInformation.hpp" 6 | #include "../Callbacks.hpp" 7 | 8 | namespace AsyncMqttClientInternals { 9 | class SubAckPacket : public Packet { 10 | public: 11 | explicit SubAckPacket(ParsingInformation* parsingInformation, OnSubAckInternalCallback callback); 12 | ~SubAckPacket(); 13 | 14 | void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition); 15 | void parsePayload(char* data, size_t len, size_t* currentBytePosition); 16 | 17 | private: 18 | ParsingInformation* _parsingInformation; 19 | OnSubAckInternalCallback _callback; 20 | 21 | uint8_t _bytePosition; 22 | char _packetIdMsb; 23 | uint16_t _packetId; 24 | }; 25 | } // namespace AsyncMqttClientInternals 26 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/UnsubAckPacket.cpp: -------------------------------------------------------------------------------- 1 | #include "UnsubAckPacket.hpp" 2 | 3 | using AsyncMqttClientInternals::UnsubAckPacket; 4 | 5 | UnsubAckPacket::UnsubAckPacket(ParsingInformation* parsingInformation, OnUnsubAckInternalCallback callback) 6 | : _parsingInformation(parsingInformation) 7 | , _callback(callback) 8 | , _bytePosition(0) 9 | , _packetIdMsb(0) 10 | , _packetId(0) { 11 | } 12 | 13 | UnsubAckPacket::~UnsubAckPacket() { 14 | } 15 | 16 | void UnsubAckPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) { 17 | char currentByte = data[(*currentBytePosition)++]; 18 | if (_bytePosition++ == 0) { 19 | _packetIdMsb = currentByte; 20 | } else { 21 | _packetId = currentByte | _packetIdMsb << 8; 22 | _parsingInformation->bufferState = BufferState::NONE; 23 | _callback(_packetId); 24 | } 25 | } 26 | 27 | void UnsubAckPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) { 28 | (void)data; 29 | (void)currentBytePosition; 30 | } 31 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Packets/UnsubAckPacket.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Arduino.h" 4 | #include "Packet.hpp" 5 | #include "../ParsingInformation.hpp" 6 | #include "../Callbacks.hpp" 7 | 8 | namespace AsyncMqttClientInternals { 9 | class UnsubAckPacket : public Packet { 10 | public: 11 | explicit UnsubAckPacket(ParsingInformation* parsingInformation, OnUnsubAckInternalCallback callback); 12 | ~UnsubAckPacket(); 13 | 14 | void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition); 15 | void parsePayload(char* data, size_t len, size_t* currentBytePosition); 16 | 17 | private: 18 | ParsingInformation* _parsingInformation; 19 | OnUnsubAckInternalCallback _callback; 20 | 21 | uint8_t _bytePosition; 22 | char _packetIdMsb; 23 | uint16_t _packetId; 24 | }; 25 | } // namespace AsyncMqttClientInternals 26 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/ParsingInformation.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace AsyncMqttClientInternals { 4 | enum class BufferState : uint8_t { 5 | NONE = 0, 6 | REMAINING_LENGTH = 2, 7 | VARIABLE_HEADER = 3, 8 | PAYLOAD = 4 9 | }; 10 | 11 | struct ParsingInformation { 12 | BufferState bufferState; 13 | 14 | uint16_t maxTopicLength; 15 | char* topicBuffer; 16 | 17 | uint8_t packetType; 18 | uint16_t packetFlags; 19 | uint32_t remainingLength; 20 | }; 21 | } // namespace AsyncMqttClientInternals 22 | -------------------------------------------------------------------------------- /Arduino dependencies/async-mqtt-client-develop/src/AsyncMqttClient/Storage.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace AsyncMqttClientInternals { 4 | struct PendingPubRel { 5 | uint16_t packetId; 6 | }; 7 | 8 | struct PendingAck { 9 | uint8_t packetType; 10 | uint8_t headerFlag; 11 | uint16_t packetId; 12 | }; 13 | } // namespace AsyncMqttClientInternals 14 | -------------------------------------------------------------------------------- /Arduino dependencies/daly-bms-uart-main/LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Devin Malanaphy 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /Arduino dependencies/daly-bms-uart-main/README.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | This library uses the Arduino Serial library to communicate with a DALY BMS over UART. It was originally designed for use with the **Teensy 4.0** as a part of [this project](https://github.com/maland16/citicar-charger) and has not been tested on official Arduino hardware. 3 | 4 | ## How to use this library 5 | -Download a zip of this library using the green button above 6 | -Follow [the instructions here](https://www.arduino.cc/en/guide/libraries) under "Manual installation" 7 | -Use the public functions defined in "daly-bms-uart.h" to your heart's content 8 | -Don't forget to construct a Daly_BMS_UART object and Init()! 9 | -See the example that's included in this library 10 | 11 | ## Hardware setup 12 | Below is a picture of the side of my DALY bms (yours might look slightly different) showing which pins are used to communicate over UART. 13 | 14 | I used this library on a teensy 4.0, who's serial pins are only 3V tolerant, so I also used [this logic level shifter](https://www.adafruit.com/product/757) to bring the logic level up to 5V, which is what I observed while using the PC UART USB adapter included with the BMS. 15 | 16 | ## The DALY BMS UART Protocol 17 | I found the UART Protocol used by the Daly BMS described in the PDF inside /docs/ on [diysolarform.com.](https://diysolarforum.com/resources/daly-smart-bms-manual-and-documentation.48/) It can be a little tough to decipher, so here's a brief overview. 18 | 19 | Here's what an outgoing packet will look like. It's always fixed 13 bytes, and the reference manual from Daly doesn't mention anything about how to write data so the "Data" section of outgoing packets is just always going to be 0. See "Future Improvements" below for more on this. 20 | | Start Byte | Host Address | Command ID | Data Length | Data | Checksum | 21 | | - | - | - | - | - | - | 22 | | 0xA5 | 0x80 | See below | 0x08 (fixed) | 0x0000000000000000 (8 bytes) | See below | 23 | 24 | This is what an incoming packet might look like. In this case it's the "Voltage, Current, and SOC" command. 25 | | Start Byte | Host Address | Command ID | Data Length | Data | Checksum | 26 | | - | - | - | - | - | - | 27 | | 0xA5 | 0x01 | 0x90 (see below) | 0x08 (fixed?*) | 0x023A0000753001ED (8 bytes) | 0x0D (See below) | 28 | 29 | \*It's not made totally clear in the protocol description but it seems like the received data length might actually be longer for certain commands. Reading all cell voltages & all temperature sensor readings are examples of commands that could have much longer data sections. 30 | 31 | #### Data section 32 | The first two bytes of the Data correspond to the Voltage in tenths of volts (0x023A = 570 = 57.0V). I'm honestly not sure what the next two bytes are for, the documentation calls them "acquisition voltage". They always come back 0 for me so lets skip them. The next two bytes are the current in tenths of amps, with an offset of 30000 (0x7530 = 300000 - 30,000 = 0 = 0.0A). The final two bytes are the state of chare (or SOC) in tenths of a percent (0x01ED = 493 = 49.3%). 33 | #### Checksum 34 | The last byte of the packet is a checksum, which is calculated by summing up all the rest of the bytes in the packet and truncating the result to one byte. (0xA5 + 0x01 + 0x90 + ... + 0xED = 0x30D = 0x0D). 35 | 36 | ### Supported Commands 37 | Here's an overview of the commands that are supported by this library. See the full protocol info in /docs/ for more info. 38 | | Command | Hex | Support API | 39 | | - | - | - | 40 | | Voltage, Current, SOC | 0x90 | getPackMeasurements() | 41 | | Min & Max Cell Voltages | 0x91 | getMinMaxCellVoltage() | 42 | | Min & Max Temp Sensor readings | 0x92 | getPackTemp() will take the min and max temperature readings, average them, and return that value. Most of the DALY BMSs that I've seen only have one temperature sensor. | 43 | 44 | ## Troubleshooting 45 | - The BMS has no internal power source, and needs to be connected to the battery for the UART communication to work. 46 | - Make sure your Tx/Rx aren't mixed up, in the picture above Tx/Rx are labeled with respect to the BMS. 47 | - I could not have made this work/debugged this without a logic analyzer hooked up to the UART lines to see what's going on. They can be had pretty cheaply and are an invaluable tool for working on these kinds of things. 48 | - Uncomment [this define](https://github.com/maland16/daly-bms-uart/blob/main/daly-bms-uart.h#L8) to get lots of debug printing to the Arduino Serial Monitor. I added these statements to help as I developed the code and ran into issues. Beyond that, I've done my best to comment extensively. 49 | 50 | ## Future Improvements 51 | ### The ability to write data to the BMS 52 | The protocol description (see /docs/) doesn't mention anything about how to write data to the BMS, but it must be possible because the PC application (see /pc-software/) can set the parameters of the BMS. I've included some logic analyzer captures of communication between the BMS and PC application that someone can probably use to reverse engineer the protocol. I'm certain it's pretty simple, I honestly wouldn't be surprised if it were just the reading protocol with some small tweak. 53 | ### Support for more commands 54 | There are a bunch of additional commands that are outlined in the protocol description document, so far I've only added support for the ones I intend to use. 55 | ### Redesign 56 | This library was purpose built for [this project](https://github.com/maland16/citicar-charger) and I made it a library in the hopes someone would get some utility out of it, but it could use to be redesigned from the ground up to be more capable/useful. -------------------------------------------------------------------------------- /Arduino dependencies/daly-bms-uart-main/daly-bms-uart.cpp: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | #include "daly-bms-uart.h" 3 | 4 | //---------------------------------------------------------------------- 5 | // Public Functions 6 | //---------------------------------------------------------------------- 7 | 8 | Daly_BMS_UART::Daly_BMS_UART(HardwareSerial &serial_peripheral) 9 | { 10 | this->my_serialIntf = &serial_peripheral; 11 | } 12 | 13 | bool Daly_BMS_UART::Init() 14 | { 15 | // Null check the serial interface 16 | if (this->my_serialIntf == NULL) 17 | { 18 | #ifdef DALY_BMS_DEBUG 19 | Serial.println(" ERROR: No serial peripheral specificed!"); 20 | #endif 21 | return false; 22 | } 23 | 24 | // Intialize the serial link to 9600 baud with 8 data bits and no parity bits, per the Daly BMS spec 25 | this->my_serialIntf->begin(9600, SERIAL_8N1); 26 | 27 | // Set up the output buffer with some values that won't be changing 28 | this->my_txBuffer[0] = 0xA5; // Start byte 29 | this->my_txBuffer[1] = 0x80; // Host address 30 | // this->my_txBuffer[2] is where our command ID goes 31 | this->my_txBuffer[3] = 0x08; // Length? 32 | 33 | // Fill bytes 5-11 with 0s 34 | for (uint8_t i = 4; i < 12; i++) 35 | { 36 | this->my_txBuffer[i] = 0x00; 37 | } 38 | 39 | return true; 40 | } 41 | 42 | bool Daly_BMS_UART::getPackMeasurements(float &voltage, float ¤t, float &SOC) 43 | { 44 | this->sendCommand(COMMAND::VOUT_IOUT_SOC); 45 | 46 | if (!this->receiveBytes()) 47 | { 48 | #ifdef DALY_BMS_DEBUG 49 | Serial.printf(" Receive failed, V, I, & SOC values won't be modified!\n"); 50 | #endif 51 | return false; 52 | } 53 | 54 | // Pull the relevent values out of the buffer 55 | voltage = (float)((this->my_rxBuffer[4] << 8) | this->my_rxBuffer[5]) / 10; 56 | // The current measurement is given with a 30000 unit offset 57 | current = (float)(((this->my_rxBuffer[8] << 8) | this->my_rxBuffer[9]) - 30000) / 10; 58 | SOC = (float)((this->my_rxBuffer[10] << 8) | this->my_rxBuffer[11]) / 10; 59 | 60 | return true; 61 | } 62 | 63 | bool Daly_BMS_UART::getPackTemp(int8_t &temp) 64 | { 65 | this->sendCommand(COMMAND::MIN_MAX_TEMPERATURE); 66 | 67 | if (!this->receiveBytes()) 68 | { 69 | #ifdef DALY_BMS_DEBUG 70 | Serial.printf(" Receive failed, Temp value won't be modified!\n"); 71 | #endif 72 | return false; 73 | } 74 | 75 | int8_t max_temp = (this->my_rxBuffer[4] - 40); 76 | int8_t min_temp = (this->my_rxBuffer[6] - 40); 77 | 78 | temp = (max_temp + min_temp) / 2; 79 | 80 | return true; 81 | } 82 | 83 | bool Daly_BMS_UART::getMinMaxCellVoltage(float &minCellV, uint8_t &minCellVNum, float &maxCellV, uint8_t &maxCellVNum) 84 | { 85 | this->sendCommand(COMMAND::MIN_MAX_CELL_VOLTAGE); 86 | 87 | if (!receiveBytes()) 88 | { 89 | #ifdef DALY_BMS_DEBUG 90 | Serial.printf(" Receive failed, min/max cell values won't be modified!\n"); 91 | #endif 92 | return false; 93 | } 94 | 95 | maxCellV = (float)((this->my_rxBuffer[4] << 8) | this->my_rxBuffer[5]) / 1000; // Given in mV, convert to V 96 | maxCellVNum = this->my_rxBuffer[6]; 97 | minCellV = (float)((this->my_rxBuffer[7] << 8) | this->my_rxBuffer[8]) / 1000; // Given in mV, convert to V 98 | minCellVNum = this->my_rxBuffer[9]; 99 | 100 | return true; 101 | } 102 | 103 | //---------------------------------------------------------------------- 104 | // Private Functions 105 | //---------------------------------------------------------------------- 106 | 107 | void Daly_BMS_UART::sendCommand(COMMAND cmdID) 108 | { 109 | this->my_txBuffer[2] = cmdID; 110 | 111 | // We can cheat a little when calculating the CRC of the outgoing UART transmission beacause 112 | // the only thing that changes in the outgoing buffer is the command, the rest stays the same. 113 | // Checksum = sum of all bytes, truncated to an 8 bit integer. See the readme for more info. 114 | // Checksum = (0xA5 + 0x80 + Command Num + 0x08) = (0x2D + Command Num) 115 | uint8_t checksum = 0x2D + cmdID; 116 | 117 | this->my_txBuffer[12] = checksum; 118 | 119 | #ifdef DALY_BMS_DEBUG 120 | Serial.print(" Checksum = 0x"); 121 | Serial.println(checksum, HEX); 122 | #endif 123 | 124 | this->my_serialIntf->write(this->my_txBuffer, XFER_BUFFER_LENGTH); 125 | } 126 | 127 | bool Daly_BMS_UART::receiveBytes(void) 128 | { 129 | // Clear out the input buffer 130 | memset(this->my_rxBuffer, 0, XFER_BUFFER_LENGTH); 131 | 132 | // Read bytes from the specified serial interface 133 | uint8_t rxByteNum = this->my_serialIntf->readBytes(this->my_rxBuffer, XFER_BUFFER_LENGTH); 134 | 135 | // Make sure we got the correct number of bytes 136 | if (rxByteNum != XFER_BUFFER_LENGTH) 137 | { 138 | #ifdef DALY_BMS_DEBUG 139 | Serial.print(" Error: Received the wrong number of bytes! Expected 13, got "); 140 | Serial.println(rxByteNum, DEC); 141 | this->barfRXBuffer(); 142 | #endif 143 | return false; 144 | } 145 | 146 | if (!validateChecksum()) 147 | { 148 | #ifdef DALY_BMS_DEBUG 149 | Serial.println(" Error: Checksum failed!"); 150 | this->barfRXBuffer(); 151 | #endif 152 | return false; 153 | } 154 | 155 | return true; 156 | } 157 | 158 | bool Daly_BMS_UART::validateChecksum() 159 | { 160 | uint8_t checksum = 0x00; 161 | 162 | for (int i = 0; i < XFER_BUFFER_LENGTH - 1; i++) 163 | { 164 | checksum += this->my_rxBuffer[i]; 165 | } 166 | 167 | #ifdef DALY_BMS_DEBUG 168 | Serial.printf(" Calculated checksum: 0x%x, Received checksum: 0x%x\n", checksum, this->my_rxBuffer[XFER_BUFFER_LENGTH - 1]); 169 | #endif 170 | 171 | // Compare the calculated checksum to the real checksum (the last received byte) 172 | return (checksum == this->my_rxBuffer[XFER_BUFFER_LENGTH - 1]); 173 | } 174 | 175 | void Daly_BMS_UART::barfRXBuffer(void) 176 | { 177 | Serial.printf(" RX Buffer: ["); 178 | for (int i = 0; i < XFER_BUFFER_LENGTH; i++) 179 | { 180 | Serial.printf("0x%x,", this->my_rxBuffer[i]); 181 | } 182 | Serial.printf("]\n"); 183 | } -------------------------------------------------------------------------------- /Arduino dependencies/daly-bms-uart-main/daly-bms-uart.h: -------------------------------------------------------------------------------- 1 | #ifndef DALY_BMS_UART_H 2 | #define DALY_BMS_UART_H 3 | 4 | // Uncomment the below #define to enable debugging print statements. 5 | // NOTE: You must call Serial.being() in your setup() for this to work 6 | //#define DALY_BMS_DEBUG 7 | 8 | #define XFER_BUFFER_LENGTH 13 9 | 10 | class Daly_BMS_UART 11 | { 12 | public: 13 | // These command names are adapted/translated from the protocol description (see /docs/) 14 | // Note: Not all are currently supported with public functions 15 | enum COMMAND 16 | { 17 | VOUT_IOUT_SOC = 0x90, 18 | MIN_MAX_CELL_VOLTAGE = 0x91, 19 | MIN_MAX_TEMPERATURE = 0x92, 20 | DISCHARGE_CHARGE_MOS_STATUS = 0x93, 21 | STATUS_INFO = 0x94, 22 | CELL_VOLTAGES = 0x95, 23 | FAILURE_CODES = 0x98 24 | }; 25 | 26 | Daly_BMS_UART(HardwareSerial &serialIntf); 27 | 28 | /** 29 | * @brief Initializes this driver 30 | * @details Configures the serial peripheral and pre-loads the transmit buffer with command-independent bytes 31 | */ 32 | bool Init(); 33 | 34 | /** 35 | * @brief Gets Voltage, Current, and SOC measurements from the BMS 36 | * @param voltage returns voltage in volts with deci-volt precision 37 | * @param current returns current in amps with deci-amp precision 38 | * @param SOC returns state of charge out of 100% with tenth of percent precision 39 | * @return True on successful aquisition, false otherwise 40 | */ 41 | bool getPackMeasurements(float &voltage, float ¤t, float &SOC); 42 | 43 | /** 44 | * @brief Gets the pack temperature in degrees celsius 45 | * @details This function uses the MIN_MAX_TEMPERATURE command, and averages the 46 | * min and max temperatures to get the returned value 47 | * @return True on successful aquisition, false otherwise 48 | */ 49 | bool getPackTemp(int8_t &temp); 50 | 51 | /** 52 | * @brief Returns the highest and lowest individual cell voltage, and which cell is highest/lowest 53 | * @details Voltages are returned as floats with milliVolt precision (3 decimal places) 54 | * @return True on successful aquisition, false otherwise 55 | */ 56 | bool getMinMaxCellVoltage(float &minCellV, uint8_t &minCellVNum, float &maxCellV, uint8_t &maxCellVNum); 57 | 58 | private: 59 | /** 60 | * @brief Sends a complete packet with the specified command 61 | * @details calculates the checksum and sends the command over the specified serial connection 62 | */ 63 | void sendCommand(COMMAND cmdID); 64 | 65 | /** 66 | * @brief 67 | * @details 68 | * @return True on success, false on failure 69 | */ 70 | bool receiveBytes(void); 71 | 72 | /** 73 | * @brief Validates the checksum in the RX Buffer 74 | * @return true if checksum matches, false otherwise 75 | */ 76 | bool validateChecksum(); 77 | 78 | /** 79 | * @brief Prints out the contense of the RX buffer 80 | * @details Useful for debugging 81 | */ 82 | void barfRXBuffer(); 83 | 84 | /** 85 | * @brief Serial interface used for communication 86 | * @details This is set in the constructor 87 | */ 88 | HardwareSerial *my_serialIntf; 89 | 90 | /** 91 | * @brief Buffer used to transmit data to the BMS 92 | * @details Populated primarily in the "Init()" function, see the readme for more info 93 | */ 94 | uint8_t my_txBuffer[XFER_BUFFER_LENGTH]; 95 | 96 | /** 97 | * @brief Buffer filled with data from the BMS 98 | */ 99 | uint8_t my_rxBuffer[XFER_BUFFER_LENGTH]; 100 | }; 101 | 102 | #endif // DALY_BMS_UART_H -------------------------------------------------------------------------------- /Arduino dependencies/daly-bms-uart-main/docs/Part 4_ Daly RS485+UART Protocol.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loopyengineeringco/Daly2Sofar/553ce9e89f5d734e8a7a2f2f7913b9901f184311/Arduino dependencies/daly-bms-uart-main/docs/Part 4_ Daly RS485+UART Protocol.pdf -------------------------------------------------------------------------------- /Arduino dependencies/daly-bms-uart-main/docs/UART Interface.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loopyengineeringco/Daly2Sofar/553ce9e89f5d734e8a7a2f2f7913b9901f184311/Arduino dependencies/daly-bms-uart-main/docs/UART Interface.jpg -------------------------------------------------------------------------------- /Arduino dependencies/daly-bms-uart-main/example-sketch/daly-bms-example/daly-bms-example.ino: -------------------------------------------------------------------------------- 1 | #include // This is where the library gets pulled in 2 | 3 | // Constructing the bms driver and passing in the Serial interface (which pins to use) 4 | Daly_BMS_UART bms(Serial1); 5 | 6 | void setup() { 7 | // This is needed to print stuff to the serial monitor 8 | Serial.begin(115200); 9 | 10 | // This call sets up the driver 11 | bms.Init(); 12 | } 13 | 14 | void loop() { 15 | 16 | // Set up some variables to hold the values 17 | float volts = 0; 18 | float amps = 0; 19 | float percentage = 0; 20 | 21 | // Grab those values from the BMS 22 | bms.getPackMeasurements(volts, amps, percentage); 23 | 24 | // And print them out! 25 | Serial.printf("V: %4.1f, I: %4.1f, \%:%4.1f\n",volts, amps, percentage); 26 | 27 | // Now the same thing, but for temperature 28 | int8_t temp = 0; 29 | bms.getPackTemp(temp); 30 | Serial.printf("Temp: %d\n",temp); 31 | 32 | // And again, for min/max cell voltages 33 | float maxCellVoltage = 0; 34 | float minCellVoltage = 0; 35 | uint8_t maxCellNumber = 0; 36 | uint8_t minCellNumber = 0; 37 | bms.getMinMaxCellVoltage(minCellVoltage, minCellNumber, maxCellVoltage, maxCellNumber); 38 | Serial.printf("Highest Cell Voltage: Cell #%d with voltage %4.3f\n",maxCellNumber,maxCellVoltage); 39 | Serial.printf("Lowest Cell Voltage: Cell #%d with voltage %4.3f\n",minCellNumber,minCellVoltage); 40 | 41 | // Lets slow things down a bit... 42 | delay(500); 43 | } 44 | -------------------------------------------------------------------------------- /Arduino dependencies/daly-bms-uart-main/logic-analyzer-captures/Idle BMS & PC Talking.sal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loopyengineeringco/Daly2Sofar/553ce9e89f5d734e8a7a2f2f7913b9901f184311/Arduino dependencies/daly-bms-uart-main/logic-analyzer-captures/Idle BMS & PC Talking.sal -------------------------------------------------------------------------------- /Arduino dependencies/daly-bms-uart-main/pc-software/DalyBmsMonitorV1.1.5.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loopyengineeringco/Daly2Sofar/553ce9e89f5d734e8a7a2f2f7913b9901f184311/Arduino dependencies/daly-bms-uart-main/pc-software/DalyBmsMonitorV1.1.5.zip -------------------------------------------------------------------------------- /Arduino dependencies/daly-bms-uart-main/pc-software/README.md: -------------------------------------------------------------------------------- 1 | # How Do 2 | 1. Unzip folder 3 | 2. Run "PCMaster.exe" 4 | 3. Connect your BMS via UART adapter cable 5 | 4. Click "commset" in the upper write hand corner and set the Port to the port the UART adapter is plugged into (this can be found in Device Manager) 6 | # Tips, tricks, notes 7 | - Sometimes It'll just crash when the BMS wakes up, or when a load is connected. 8 | - I don't know what anything in "Engineering Tasks" does and I'm too afraid to try it 9 | # Where the heck did this come from 10 | This software was found on this DIY Solar Forum post: https://diysolarforum.com/resources/daly-smart-bms-pc-software.50/ 11 | -------------------------------------------------------------------------------- /Daly2Sofar Node-Red to HA example.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loopyengineeringco/Daly2Sofar/553ce9e89f5d734e8a7a2f2f7913b9901f184311/Daly2Sofar Node-Red to HA example.jpg -------------------------------------------------------------------------------- /Daly2Sofar schematic.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loopyengineeringco/Daly2Sofar/553ce9e89f5d734e8a7a2f2f7913b9901f184311/Daly2Sofar schematic.jpg -------------------------------------------------------------------------------- /Daly2Sofar_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loopyengineeringco/Daly2Sofar/553ce9e89f5d734e8a7a2f2f7913b9901f184311/Daly2Sofar_1.jpg -------------------------------------------------------------------------------- /Daly2Sofar_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loopyengineeringco/Daly2Sofar/553ce9e89f5d734e8a7a2f2f7913b9901f184311/Daly2Sofar_2.jpg -------------------------------------------------------------------------------- /Daly2Sofar_3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loopyengineeringco/Daly2Sofar/553ce9e89f5d734e8a7a2f2f7913b9901f184311/Daly2Sofar_3.jpg -------------------------------------------------------------------------------- /Daly2Sofar_v0.92/I_MQTTstuff.ino: -------------------------------------------------------------------------------- 1 | 2 | void connectToWifi() { 3 | Serial.println("Connecting to Wi-Fi..."); 4 | WiFi.begin(WIFI_SSID, WIFI_PASSWORD); 5 | } 6 | 7 | void connectToMqtt() { 8 | Serial.println("Connecting to MQTT..."); 9 | mqttClient.connect(); 10 | } 11 | 12 | void WiFiEvent(WiFiEvent_t event) { 13 | Serial.printf("[WiFi-event] event: %d\n", event); 14 | switch(event) { 15 | case SYSTEM_EVENT_STA_GOT_IP: 16 | Serial.println("WiFi connected"); 17 | Serial.println("IP address: "); 18 | Serial.println(WiFi.localIP()); 19 | WiFiStatus = true; 20 | connectToMqtt(); 21 | break; 22 | case SYSTEM_EVENT_STA_DISCONNECTED: 23 | Serial.println("WiFi lost connection"); 24 | WiFiStatus = false; 25 | xTimerStop(mqttReconnectTimer, 0); // ensure we don't reconnect to MQTT while reconnecting to Wi-Fi 26 | xTimerStart(wifiReconnectTimer, 0); 27 | break; 28 | } 29 | } 30 | 31 | void onMqttDisconnect(AsyncMqttClientDisconnectReason reason) { 32 | Serial.println("Disconnected from MQTT."); 33 | xTimerStop(mqttPublishXTimer, 0); 34 | MQTTStatus = false; 35 | //mqttPublisherTimer->Stop(); 36 | if (WiFi.isConnected()) { 37 | xTimerStart(mqttReconnectTimer, 0); 38 | } 39 | } 40 | 41 | void onMqttSubscribe(uint16_t packetId, uint8_t qos) { 42 | Serial.println("Subscribe acknowledged."); 43 | Serial.print(" packetId: "); 44 | Serial.println(packetId); 45 | Serial.print(" qos: "); 46 | Serial.println(qos); 47 | } 48 | 49 | void onMqttUnsubscribe(uint16_t packetId) { 50 | Serial.println("Unsubscribe acknowledged."); 51 | Serial.print(" packetId: "); 52 | Serial.println(packetId); 53 | } 54 | 55 | void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total) { 56 | Serial.println("Publish received."); 57 | Serial.print(" topic: "); 58 | Serial.println(topic); 59 | Serial.print(" qos: "); 60 | Serial.println(properties.qos); 61 | Serial.print(" dup: "); 62 | Serial.println(properties.dup); 63 | Serial.print(" retain: "); 64 | Serial.println(properties.retain); 65 | Serial.print(" len: "); 66 | Serial.println(len); 67 | Serial.print(" index: "); 68 | Serial.println(index); 69 | Serial.print(" total: "); 70 | Serial.println(total); 71 | } 72 | 73 | void onMqttPublish(uint16_t packetId) { 74 | Serial.println("Publish acknowledged."); 75 | Serial.print(" packetId: "); 76 | Serial.println(packetId); 77 | } 78 | 79 | 80 | void sendMQTTData() { 81 | // Update all parameters and send to MQTT. 82 | String state = "{"; 83 | 84 | if (!( state == "{")) { state += ","; } 85 | state += "\"soc\":"+String(percentage); 86 | 87 | if (!( state == "{")) { state += ","; } 88 | state += "\"voltage\":"+String(volts); 89 | 90 | if (!( state == "{")) { state += ","; } 91 | state += "\"current\":"+String(amps); 92 | 93 | if (!( state == "{")) { state += ","; } 94 | state += "\"power\":"+String(watts); 95 | 96 | if (!( state == "{")) { state += ","; } 97 | state += "\"temp\":"+String(temp); 98 | 99 | if (!( state == "{")) { state += ","; } 100 | state += "\"lowestcell\":"+String(minCellVoltage); 101 | 102 | if (!( state == "{")) { state += ","; } 103 | state += "\"highestcell\":"+String(maxCellVoltage); 104 | 105 | if (!( state == "{")) { state += ","; } 106 | state += "\"cellimbalance\":"+String(cellImbalance); // Cell imbalance is sent in Millivolts 107 | 108 | state = state+"}"; 109 | 110 | //Prefixt the mqtt topic name with deviceName. 111 | String topic (deviceName); 112 | topic += "/state"; 113 | 114 | uint16_t packetIdPub2 = mqttClient.publish(const_cast(topic.c_str()), 1, true, const_cast(state.c_str())); 115 | Serial.println("Publishing at QoS 1"); 116 | Serial.print("Topic: "); 117 | Serial.println(topic); 118 | Serial.print("Payload: "); 119 | Serial.println(state); 120 | 121 | xTimerStart(mqttPublishXTimer, 0); 122 | } 123 | 124 | void onMqttConnect(bool sessionPresent) { 125 | Serial.println("Connected to MQTT."); 126 | Serial.print("Session present: "); 127 | Serial.println(sessionPresent); 128 | MQTTStatus = true; 129 | sendMQTTData(); 130 | //xTimerStart(mqttPublishXTimer, 0); 131 | //mqttPublisherTimer->Start(); 132 | } 133 | -------------------------------------------------------------------------------- /Daly2Sofar_v0.92/J_CANBUSstuff.ino: -------------------------------------------------------------------------------- 1 | 2 | void sendCanTXFrame(byte dataArray[],int dataLength) { 3 | tx_frame.FIR.B.FF = CAN_frame_std; 4 | uint16_t combinedId = 0; // Storage var 5 | uint16_t x1 = (uint16_t)dataArray[0]<<8; // MSB 6 | uint16_t x0 = (uint16_t)dataArray[1]; // LSB 7 | combinedId = x1 | x0; 8 | tx_frame.MsgID = combinedId; // concatenated address from the 1st 2 values in the data array. 9 | tx_frame.FIR.B.DLC = dataLength; 10 | tx_frame.data.u8[0] = dataArray[2]; 11 | tx_frame.data.u8[1] = dataArray[3]; 12 | tx_frame.data.u8[2] = dataArray[4]; 13 | tx_frame.data.u8[3] = dataArray[5]; 14 | tx_frame.data.u8[4] = dataArray[6]; 15 | tx_frame.data.u8[5] = dataArray[7]; 16 | tx_frame.data.u8[6] = dataArray[8]; 17 | tx_frame.data.u8[7] = dataArray[9]; 18 | ESP32Can.CANWriteFrame(&tx_frame); 19 | CANOnline = true; 20 | delay(5); // just to make sure it gets sent in peace. TRY INCREASING THIS 21 | } 22 | 23 | 24 | void checkForRX() { 25 | CAN_frame_t rx_frame; 26 | if (xQueueReceive(CAN_cfg.rx_queue, &rx_frame, 3 * portTICK_PERIOD_MS) == pdTRUE) { 27 | if (rx_frame.FIR.B.FF == CAN_frame_std) { 28 | printf("New standard frame"); 29 | } else { 30 | printf("New extended frame"); 31 | } 32 | 33 | if (rx_frame.FIR.B.RTR == CAN_RTR) { 34 | printf(" RTR from 0x%08X, DLC %d\r\n", rx_frame.MsgID, rx_frame.FIR.B.DLC); 35 | } else { 36 | printf(" from 0x%08X, DLC %d, Data ", rx_frame.MsgID, rx_frame.FIR.B.DLC); 37 | for (int i = 0; i < rx_frame.FIR.B.DLC; i++) { 38 | printf("0x%02X ", rx_frame.data.u8[i]); 39 | } 40 | printf("\n"); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Daly2Sofar_v0.92/K_OledStuff.ino: -------------------------------------------------------------------------------- 1 | void oledMessage(String line1, String line2, String line3, String line4, String line5) {//bool WiFiStatus, bool MQTTStatus) { 2 | display.clearDisplay(); 3 | display.setTextSize(1); 4 | display.setTextColor(WHITE); 5 | 6 | display.setCursor(0,0); 7 | if (line1 != "NULL") { 8 | display.println(line1); 9 | oledLine1 = line1; 10 | } else { 11 | display.println(oledLine1); 12 | } 13 | 14 | display.setCursor(0,12); 15 | if (line2 != "NULL") { 16 | display.println(line2); 17 | oledLine2 = line2; 18 | } else { 19 | display.println(oledLine2); 20 | } 21 | 22 | display.setCursor(0,24); 23 | if (line3 != "NULL") { 24 | display.println(line3); 25 | oledLine3 = line3; 26 | } else { 27 | display.println(oledLine3); 28 | } 29 | 30 | display.setCursor(0,36); 31 | if (line4 != "NULL") { 32 | display.println(line4); 33 | oledLine4 = line4; 34 | } else { 35 | display.println(oledLine4); 36 | } 37 | 38 | display.setCursor(0,48); 39 | if (line4 != "NULL") { 40 | display.println(line5); 41 | oledLine4 = line5; 42 | } else { 43 | display.println(oledLine5); 44 | } 45 | 46 | if (BMSOnline) { 47 | display.drawBitmap(99, 0, dalyOn, 29, 13, WHITE); // display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color) 48 | } else { 49 | display.drawBitmap(99, 0, dalyOff, 32, 13, WHITE); // display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color) 50 | } 51 | 52 | if (CANOnline) { 53 | display.drawBitmap(99, 14, canOn, 29, 13, WHITE); // display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color) 54 | } else { 55 | display.drawBitmap(99, 14, canOff, 32, 13, WHITE); // display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color) 56 | } 57 | 58 | if (WiFiStatus) { 59 | display.drawBitmap(99, 28, wifiOn, 29, 13, WHITE); // display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color) 60 | } else { 61 | display.drawBitmap(99, 28, wifiOff, 32, 13, WHITE); // display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color) 62 | } 63 | 64 | if (MQTTStatus){ 65 | display.drawBitmap(99, 42, mqttOn, 29, 13, WHITE); // display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color) 66 | } else { 67 | display.drawBitmap(99, 42, mqttOff, 29, 13, WHITE); // display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color) 68 | } 69 | 70 | display.display(); 71 | } 72 | -------------------------------------------------------------------------------- /Daly2Sofar_v0.92/L_GeneralFunctions.ino: -------------------------------------------------------------------------------- 1 | void getEverythingFromDaly() { 2 | // Grab values from BMS 3 | 4 | dalyRequestCounter++; 5 | 6 | if (dalyRequestCounter > 3) { 7 | dalyRequestCounter = 1; 8 | } 9 | 10 | if (dalyRequestCounter == 1) { 11 | bms.getPackMeasurements(volts, amps, percentage); 12 | vTaskDelay(100); 13 | if ( volts == 0) { 14 | //if ( bms.getPackMeasurements(volts, amps, percentage) == false) { 15 | BMSOnline = false; 16 | CANOnline = false; 17 | Serial.println("No connection with BMS. Check TX/RX polarity, and that BMS is awake..."); 18 | oledMessage("No BMS found.", "Check TX/RX", "polarity,", "Make sure", "BMS is awake."); 19 | xTimerStart(dalyRetryXTimer, 0); 20 | } else { 21 | watts = amps*volts; 22 | BMSOnline = true; 23 | oledMessage("SOC: "+String(percentage)+"%", "Volts: "+String(volts)+"V", "Amps: "+String(amps)+"A", "Hi/Lo: "+String(minCellVoltage)+"/"+String(maxCellVoltage), "Temp: "+String(temp)); 24 | } 25 | } 26 | 27 | if (dalyRequestCounter == 2) { 28 | bms.getPackTemp(temp); 29 | vTaskDelay(100); 30 | if ( temp == 0) { 31 | //if ( bms.getPackTemp(temp) == false) { 32 | BMSOnline = false; 33 | CANOnline = false; 34 | Serial.println("No connection with BMS. Check TX/RX polarity, and that BMS is awake..."); 35 | oledMessage("No BMS found.", "Check TX/RX", "polarity,", "Make sure", "BMS is awake."); 36 | xTimerStart(dalyRetryXTimer, 0); 37 | } else { 38 | BMSOnline = true; 39 | oledMessage("SOC: "+String(percentage)+"%", "Volts: "+String(volts)+"V", "Amps: "+String(amps)+"A", "Hi/Lo: "+String(minCellVoltage)+"/"+String(maxCellVoltage), "Temp: "+String(temp)); 40 | } 41 | } 42 | 43 | if (dalyRequestCounter == 3) { 44 | bms.getMinMaxCellVoltage(minCellVoltage, minCellNumber, maxCellVoltage, maxCellNumber); 45 | vTaskDelay(100); 46 | if ( minCellVoltage == 0) { 47 | //if ( bms.getMinMaxCellVoltage(minCellVoltage, minCellNumber, maxCellVoltage, maxCellNumber) == false) { 48 | BMSOnline = false; 49 | CANOnline = false; 50 | Serial.println("No connection with BMS. Check TX/RX polarity, and that BMS is awake..."); 51 | oledMessage("No BMS found.", "Check TX/RX", "polarity,", "Make sure", "BMS is awake."); 52 | xTimerStart(dalyRetryXTimer, 0); 53 | } else { 54 | BMSOnline = true; 55 | cellImbalance = (maxCellVoltage-minCellVoltage)*1000; 56 | oledMessage("SOC: "+String(percentage)+"%", "Volts: "+String(volts)+"V", "Amps: "+String(amps)+"A", "Hi/Lo: "+String(minCellVoltage)+"/"+String(maxCellVoltage), "Temp: "+String(temp)); 57 | } 58 | } 59 | 60 | 61 | /* 62 | if (bms.getPackMeasurements(volts, amps, percentage) == false){ 63 | BMSOnline = false; 64 | CANOnline = false; 65 | Serial.println("No connection with BMS. Check TX/RX polarity, and that BMS is awake..."); 66 | oledMessage("No BMS found.", "Check TX/RX", "polarity,", "Make sure", "BMS is awake."); 67 | xTimerStart(dalyRetryXTimer, 0); 68 | } else { 69 | //delay(20); 70 | bms.getPackTemp(temp); 71 | bms.getMinMaxCellVoltage(minCellVoltage, minCellNumber, maxCellVoltage, maxCellNumber); 72 | //delay(20); 73 | //delay(20); 74 | watts = amps*volts; 75 | oledMessage("SOC: "+String(percentage)+"%", "Volts: "+String(volts)+"V", "Amps: "+String(amps)+"A", "Hi/Lo: "+String(minCellVoltage)+"/"+String(maxCellVoltage), "Temp: "+String(temp)); 76 | BMSOnline = true; 77 | // Print above to Serial 78 | //Serial.printf("V: %4.1f, I: %4.1f, \%:%4.1f\n",volts, amps, percentage); 79 | 80 | // Now the same thing, but for temperature 81 | //Serial.printf("Temp: %d\n",temp); 82 | 83 | // And again, for min/max cell voltages 84 | //Serial.printf("Max Cell: Cell #%d at %4.3f\n",maxCellNumber,maxCellVoltage); 85 | //Serial.printf("Min Cell: Cell #%d at %4.3f\n",minCellNumber,minCellVoltage); 86 | } 87 | 88 | */ 89 | } 90 | 91 | void dalyRetry() { 92 | xTimerStop(dalyRetryXTimer, 0); 93 | getEverythingFromDaly(); 94 | } 95 | 96 | void updateTXFrames() { 97 | // SOC. 1:1 scaling, 2 bytes - easy. 98 | CANData355[2] = (int)percentage; 99 | 100 | // Charge voltage 101 | uint16_t uint16chargevolts = batteryChargeVoltage*10; 102 | CANData351[2] = uint16chargevolts; // Arduino/C is big endian. So needs to shift the opposite way of the SMA protocol. 103 | CANData351[3] = uint16chargevolts>>8; 104 | 105 | // High res SOC: 0.01 scale, 2 bytes. rescale, then bitshift. 106 | uint16_t uint16soc = percentage*100; 107 | CANData355[6] = uint16soc; // Arduino/C is big endian. So needs to shift the opposite way of the SMA protocol. 108 | CANData355[7] = uint16soc>>8; 109 | 110 | // Voltage. 0.01 scale, over 2 bytes SIGNED. Not easy. First rescale, then bitshift 111 | int16_t int16volts = volts*100; 112 | CANData356[2] = int16volts; // Arduino/C is big endian. So needs to shift the opposite way of the SMA protocol. 113 | CANData356[3] = int16volts>>8; 114 | 115 | // Current. 0.1 scale, over 2 bytes SIGNED. Not easy. First rescale, then bitshift 116 | int16_t int16amps = amps*10; 117 | CANData356[4] = int16amps; // Arduino/C is big endian. So needs to shift the opposite way of the SMA protocol. 118 | CANData356[5] = int16amps>>8; 119 | 120 | // Battery temp. 0.1 scale, 2 bytes SIGNED. Not easy. First rescale, then bitshift 121 | int16_t int16temp = temp*10; 122 | CANData356[6] = int16temp; // Arduino/C is big endian. So needs to shift the opposite way of the SMA protocol. 123 | CANData356[7] = int16temp>>8; 124 | 125 | // Battery capacity = fixed value from setup section 126 | CANData35F[6] = batteryCapacity; // Arduino/C is big endian. So needs to shift the opposite way of the SMA protocol. 127 | CANData35F[7] = batteryCapacity>>8; // Currently reporting 51200ah :-D obvs wrong... 128 | } 129 | -------------------------------------------------------------------------------- /Daly2Sofar_v0.92/X_Main.ino: -------------------------------------------------------------------------------- 1 | void setup() { 2 | //rtc_wdt_protect_off(); 3 | //rtc_wdt_disable(); 4 | 5 | Serial.begin(115200); 6 | Serial.println("Daly2Sofar-UARTtoCANBUS v1"); 7 | 8 | // Set CAN pins and baudrate 9 | CAN_cfg.speed=CAN_SPEED_500KBPS; 10 | CAN_cfg.tx_pin_id = GPIO_NUM_5; 11 | CAN_cfg.rx_pin_id = GPIO_NUM_4; 12 | 13 | // Create a queue for CAN receiving */ 14 | CAN_cfg.rx_queue = xQueueCreate(rx_queue_size,sizeof(CAN_frame_t)); 15 | 16 | // Initialize CAN Module 17 | ESP32Can.CANInit(); 18 | 19 | // Initialise the Daly comms 20 | bms.Init(); 21 | 22 | Wire.begin(); // sda= GPIO_21 /scl= GPIO_22 23 | display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize OLED with the I2C addr 0x3C (for the 64x48) 24 | display.clearDisplay(); 25 | display.display(); 26 | oledMessage("Hi", "Ola!", "Hello", "Labas", "Zdravstvuyte"); 27 | //delay(500); 28 | 29 | mqttReconnectTimer = xTimerCreate("mqttTimer", pdMS_TO_TICKS(5000), pdFALSE, (void*)0, reinterpret_cast(connectToMqtt)); 30 | wifiReconnectTimer = xTimerCreate("wifiTimer", pdMS_TO_TICKS(2000), pdFALSE, (void*)0, reinterpret_cast(connectToWifi)); 31 | mqttPublishXTimer = xTimerCreate("mqttPubTimer", pdMS_TO_TICKS(2000), pdFALSE, (void*)0, reinterpret_cast(sendMQTTData)); 32 | dalyRetryXTimer = xTimerCreate("dalyRetryTimer", pdMS_TO_TICKS(200), pdFALSE, (void*)0, reinterpret_cast(dalyRetry)); 33 | 34 | 35 | WiFi.onEvent(WiFiEvent); 36 | 37 | mqttClient.setCredentials(mqttUser, mqttPassword); 38 | mqttClient.onConnect(onMqttConnect); 39 | mqttClient.onDisconnect(onMqttDisconnect); 40 | mqttClient.onSubscribe(onMqttSubscribe); 41 | mqttClient.onUnsubscribe(onMqttUnsubscribe); 42 | mqttClient.onMessage(onMqttMessage); 43 | mqttClient.onPublish(onMqttPublish); 44 | mqttClient.setServer(MQTT_HOST, MQTT_PORT); 45 | 46 | connectToWifi(); 47 | } 48 | 49 | 50 | void loop() { 51 | unsigned long currentMillisUARTCAN = millis(); 52 | if (currentMillisUARTCAN - previousMillisUARTCAN >= intervalUARTCAN) { 53 | previousMillisUARTCAN = currentMillisUARTCAN; 54 | 55 | getEverythingFromDaly(); 56 | 57 | if (BMSOnline) { 58 | updateTXFrames(); 59 | 60 | sendCanTXFrame(CANData351, 8); // 0x0351 - 8 bytes 61 | sendCanTXFrame(CANData355, 6); // 0x0355 - 6 bytes 62 | sendCanTXFrame(CANData356, 6); // 0x0356 - 6 bytes 63 | sendCanTXFrame(CANData35A, 8); // 0x035A - 8 bytes 64 | sendCanTXFrame(CANData35B, 2); // 0x035B - 2 bytes 65 | sendCanTXFrame(CANData35E, 8); // 0x035E - 8 bytes 66 | sendCanTXFrame(CANData35F, 8); // 0x035F - 8 bytes 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Home Assistant sensors example.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loopyengineeringco/Daly2Sofar/553ce9e89f5d734e8a7a2f2f7913b9901f184311/Home Assistant sensors example.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # !!! 2 | Due to updates to the Daly library dependency, compilation might throw an error. 3 | Please look at the Issues page for the temporary solution while I do further testing, or use the older version of the Daly lib which is in the Arduino dependencies folder. 4 | !!! 5 | 6 | # Daly2Sofar v0.93 - beta 7 | ESP32 bridge allowing Daly Smart BMS to be used with a Sofar inverter/charger (and others that use SMA CANBUS protocol). 8 | ![image](https://user-images.githubusercontent.com/43951291/164516928-52ea70e6-35d5-4c46-9d18-d0e2efe84e6b.png) 9 | 10 | 11 | It connects to Daly via UART and transmits to the inverter on CANBUS (SMA protocol). 12 | At the same time, it will transmit the BMS data to an MQTT broker if it can connect to your WiFi. 13 | If it can't connect to WiFi or your MQTT broker, it will still work as a BMS-to-Inverter bridge. 14 | The icons on the OLED represent the WiFi & MQTT status. They will be crossed out if there is no connection. 15 | 16 | Data comms is one way only - data is requested from Daly and sent to the Inverter & over MQTT. 17 | May be compatible with other inverters that use the SMA protocol. 18 | 19 | My testing showed that Daly UART port works on 3.3v. PLEASE measure yours before connecting the ESP. Some users report 5V. 20 | 21 | ![image](https://user-images.githubusercontent.com/43951291/164516992-e57eed06-884a-4738-b35d-9d546e7b2dab.png) 22 | 23 | ![Daly2Sofar_3](https://user-images.githubusercontent.com/43951291/164450894-d7f85e7a-e5d1-40e6-8250-39d048bfd524.jpg) 24 | 25 | 26 | # PSA: 27 | USE THIS AT YOUR OWN RISK! 28 | Batteries are dangerous. Don't come to me if you burn your house down. 29 | This release is a working prototype. It might freeze, there might be glitches. Your battery might overcharge/undercharge. Make sure your BMS is set up properly with your own limits. 30 | USE THIS AT YOUR OWN RISK! 31 | 32 | # Schematic 33 | ![image](https://user-images.githubusercontent.com/43951291/164475730-a8ae568a-6bad-427c-bce5-01f2ea579785.png) 34 | 35 | 36 | # Isolation 37 | Some battery setups earth the battery negative, others don't. 38 | For the ones that aren't earthed, you may get a ID05 Fault on the inverter when you connect canbus. 39 | You might get a shock if you touch the comms/3v3/ground pins coming from the BMS, even though they're supposed to be only 3.3v. 40 | 41 | Ask me how I know! 42 | 43 | This is because the Daly UART ground is battery ground, and it makes its way to the inverter. 44 | It might be higher or lower voltage potential, in respect to earth. 45 | 46 | The Daly needs to be isolated in this case, using a digital isolation IC. 47 | Opto-coupler's don't work as the signal becomes inverted. ESP32 serial can be inverted by software but Daly can't. 48 | IL716-3E based isolator IC works, as well as the cheap off-the shelf ADUM1201 based modules. 49 | 50 | 51 | # ESP32 pin remapping 52 | Make sure the I2C pins are mapped correctly for the Oled to work. For me, pins 21 and 22 work great 53 | C:\Users\XXXXX\Documents\Arduino\libraries\Adafruit_SSD1306-1.1.2\Adafruit_SSD1306.cpp 54 | ``` 55 | #define I2C_SDA 21 56 | #define I2C_SCL 22 57 | ``` 58 | 59 | And also Serial2 needs to be correctly mapped in this file (This is Windows. Sorry I don't know where it is on a Mac) 60 | C:\Users\XXXXX\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32\HardwareSerial.cpp 61 | Look for this near the top: 62 | ``` 63 | #ifndef RX2 64 | #define RX2 16 65 | #endif 66 | 67 | #ifndef TX2 68 | #define TX2 17 69 | #endif 70 | ``` 71 | 72 | 73 | # MQTT info: 74 | Add your WiFi and MQTT details to the top of the sketch, as well as your battery capacity and preferred charging voltage (Capacity is broken at the moment, but the Inverter seems happy nonetheless): 75 | 76 | ![image](https://user-images.githubusercontent.com/43951291/164454052-098721e5-b45f-4cef-878d-7d6928e60f59.png) 77 | 78 | Subscribe your MQTT client to: 79 | ```Daly2Sofar/state``` 80 | 81 | topics published are: 82 | ``` 83 | soc 84 | voltage 85 | current 86 | power 87 | temp 88 | lowestcell 89 | highestcell 90 | cellimbalance 91 | ``` 92 | 93 | # Node-RED 94 | For extracting the data into Home Asisstant sensors, use Node-Red. You can import the ```Daly2Sofar Node-Red to Home Assistant flow.json```flow to extract the data into sensor entities, it will look like this: 95 | ![image](https://user-images.githubusercontent.com/43951291/166910404-52b77566-ff52-444a-bd41-08b7f5ddcaa1.png) 96 | 97 | (you may need to install Moving Average filter if you want smoothing of data) 98 | 99 | When the battery is discharging, Node-RED will calculate the remaining battery time based on the current discharge rate. 100 | When it's charging, it will calculate the time left to full charge. 101 | Because charging/discharging and SOC isn't linear, this value is only a rough estimation, but useful nonetheless. 102 | 103 | This has some hard-coded variables - it's based on a 10kWh battery and 80% DOD, and also what percentage to consider 'full' 95% in my case. 104 | Make sure you customise them if you want to use this Flow :-) 105 | ![image](https://user-images.githubusercontent.com/43951291/166910615-47297ec8-0477-4fcf-b30d-cc008e25f745.png) 106 | 107 | Home Assistant dashboard example 108 | ![image](https://user-images.githubusercontent.com/43951291/166928175-bbf1b5a7-a5f7-41d0-8a70-b6e47e459800.png) 109 | 110 | # To do: 111 | - Do proper CANBUS status check. Currently, CAN indicator will go live after the data send, whether it's succesfull or not. 112 | - Add battery cycles: the owner of the Daly library is adding the functionality, and it will be reflected here when it's done. 113 | - Add charge/discharge control via MQTT (as soon as it's available in the Daly lib) 114 | - Tidy up code/refactor where poss. 115 | - Longer term stability testing. 116 | 117 | # Arduino dependencies 118 | 119 | https://github.com/maland16/daly-bms-uart 120 | 121 | https://github.com/miwagner/ESP32-Arduino-CAN 122 | 123 | https://github.com/me-no-dev/AsyncTCP 124 | 125 | https://github.com/marvinroger/async-mqtt-client 126 | 127 | https://github.com/adafruit/Adafruit_SSD1306 128 | 129 | # Notes/links 130 | 131 | CANH & CANL can be live swapped. If display is saying all is good but inverter isn't happy, try swapping the wires. 132 | 133 | Developed on Arduino IDE 1.8.5. Version 1.8.14 failed to compile. Downgrade if you have issues 134 | 135 | Using arduino ESP32 Core version 1.0.6 136 | 137 | Developed & tested with a Sofar HYD6000-ES. Should work fine with all the others, but if you test it on your inverters let me know how it goes! 138 | 139 | Using SMA_CAN_protocol.pdf for the CAN IDs and data format info (google will find you the PDF) 140 | 141 | Using https://cryptii.com/pipes/integer-encoder for working out hex values 142 | 143 | VIEW TEXT > DECODE INTEGER (LITTLE ENDIAN) U16 > VIEW BYTES HEX GROUPED BY BYTES 144 | 145 | https://www.scadacore.com/tools/programming-calculators/online-hex-converter/ for checking hex values 146 | --------------------------------------------------------------------------------