├── ESP32_Heltec_V1_LoRa_Mote ├── libraries │ ├── Adafruit_GFX_Library │ │ ├── Adafruit_GFX.cpp │ │ ├── Adafruit_GFX.h │ │ ├── Adafruit_SPITFT.cpp │ │ ├── Adafruit_SPITFT.h │ │ ├── Adafruit_SPITFT_Macros.h │ │ ├── Fonts │ │ │ ├── FreeMono12pt7b.h │ │ │ ├── FreeMono18pt7b.h │ │ │ ├── FreeMono24pt7b.h │ │ │ ├── FreeMono9pt7b.h │ │ │ ├── FreeMonoBold12pt7b.h │ │ │ ├── FreeMonoBold18pt7b.h │ │ │ ├── FreeMonoBold24pt7b.h │ │ │ ├── FreeMonoBold9pt7b.h │ │ │ ├── FreeMonoBoldOblique12pt7b.h │ │ │ ├── FreeMonoBoldOblique18pt7b.h │ │ │ ├── FreeMonoBoldOblique24pt7b.h │ │ │ ├── FreeMonoBoldOblique9pt7b.h │ │ │ ├── FreeMonoOblique12pt7b.h │ │ │ ├── FreeMonoOblique18pt7b.h │ │ │ ├── FreeMonoOblique24pt7b.h │ │ │ ├── FreeMonoOblique9pt7b.h │ │ │ ├── FreeSans12pt7b.h │ │ │ ├── FreeSans18pt7b.h │ │ │ ├── FreeSans24pt7b.h │ │ │ ├── FreeSans9pt7b.h │ │ │ ├── FreeSansBold12pt7b.h │ │ │ ├── FreeSansBold18pt7b.h │ │ │ ├── FreeSansBold24pt7b.h │ │ │ ├── FreeSansBold9pt7b.h │ │ │ ├── FreeSansBoldOblique12pt7b.h │ │ │ ├── FreeSansBoldOblique18pt7b.h │ │ │ ├── FreeSansBoldOblique24pt7b.h │ │ │ ├── FreeSansBoldOblique9pt7b.h │ │ │ ├── FreeSansOblique12pt7b.h │ │ │ ├── FreeSansOblique18pt7b.h │ │ │ ├── FreeSansOblique24pt7b.h │ │ │ ├── FreeSansOblique9pt7b.h │ │ │ ├── FreeSerif12pt7b.h │ │ │ ├── FreeSerif18pt7b.h │ │ │ ├── FreeSerif24pt7b.h │ │ │ ├── FreeSerif9pt7b.h │ │ │ ├── FreeSerifBold12pt7b.h │ │ │ ├── FreeSerifBold18pt7b.h │ │ │ ├── FreeSerifBold24pt7b.h │ │ │ ├── FreeSerifBold9pt7b.h │ │ │ ├── FreeSerifBoldItalic12pt7b.h │ │ │ ├── FreeSerifBoldItalic18pt7b.h │ │ │ ├── FreeSerifBoldItalic24pt7b.h │ │ │ ├── FreeSerifBoldItalic9pt7b.h │ │ │ ├── FreeSerifItalic12pt7b.h │ │ │ ├── FreeSerifItalic18pt7b.h │ │ │ ├── FreeSerifItalic24pt7b.h │ │ │ ├── FreeSerifItalic9pt7b.h │ │ │ ├── Org_01.h │ │ │ ├── Picopixel.h │ │ │ ├── Tiny3x3a2pt7b │ │ │ └── TomThumb.h │ │ ├── README.md │ │ ├── examples │ │ │ └── mock_ili9341 │ │ │ │ └── mock_ili9341.ino │ │ ├── fontconvert │ │ │ ├── Makefile │ │ │ ├── fontconvert.c │ │ │ ├── fontconvert_win.md │ │ │ └── makefonts.sh │ │ ├── gfxfont.h │ │ ├── glcdfont.c │ │ ├── library.properties │ │ └── license.txt │ ├── Adafruit_Unified_Sensor │ │ ├── Adafruit_Sensor.h │ │ ├── README.md │ │ └── library.properties │ ├── DHT_sensor_library │ │ ├── DHT.cpp │ │ ├── DHT.h │ │ ├── DHT_U.cpp │ │ ├── DHT_U.h │ │ ├── README.md │ │ ├── examples │ │ │ ├── DHT_Unified_Sensor │ │ │ │ └── DHT_Unified_Sensor.ino │ │ │ └── DHTtester │ │ │ │ └── DHTtester.ino │ │ ├── keywords.txt │ │ └── library.properties │ ├── MCCI_LoRaWAN_LMIC_library │ │ ├── HOWTO-ADD-REGION.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── assets │ │ │ ├── Feather-M0-LoRa-Wire.ai │ │ │ └── Feather-M0-LoRa-Wire.png │ │ ├── doc │ │ │ ├── LMiC-v1.6.docx │ │ │ ├── LMiC-v1.6.pdf │ │ │ ├── README.txt │ │ │ └── release-notes.txt │ │ ├── examples │ │ │ ├── header_test │ │ │ │ └── header_test.ino │ │ │ ├── raw-feather │ │ │ │ └── raw-feather.ino │ │ │ ├── raw │ │ │ │ └── raw.ino │ │ │ ├── ttn-abp-feather-us915-dht22 │ │ │ │ └── ttn-abp-feather-us915-dht22.ino │ │ │ ├── ttn-abp │ │ │ │ └── ttn-abp.ino │ │ │ ├── ttn-otaa-feather-us915-dht22 │ │ │ │ └── ttn-otaa-feather-us915-dht22.ino │ │ │ ├── ttn-otaa-feather-us915 │ │ │ │ └── ttn-otaa-feather-us915.ino │ │ │ └── ttn-otaa │ │ │ │ └── ttn-otaa.ino │ │ ├── library.properties │ │ ├── project_config │ │ │ └── lmic_project_config.h │ │ └── src │ │ │ ├── aes │ │ │ ├── ideetron │ │ │ │ └── AES-128_V10.cpp │ │ │ ├── lmic.c │ │ │ └── other.c │ │ │ ├── hal │ │ │ ├── hal.cpp │ │ │ └── hal.h │ │ │ ├── lmic.h │ │ │ └── lmic │ │ │ ├── config.h │ │ │ ├── hal.h │ │ │ ├── lmic.c │ │ │ ├── lmic.h │ │ │ ├── lmic_as923.c │ │ │ ├── lmic_au921.c │ │ │ ├── lmic_bandplan.h │ │ │ ├── lmic_bandplan_as923.h │ │ │ ├── lmic_bandplan_au921.h │ │ │ ├── lmic_bandplan_eu868.h │ │ │ ├── lmic_bandplan_in866.h │ │ │ ├── lmic_bandplan_us915.h │ │ │ ├── lmic_config_preconditions.h │ │ │ ├── lmic_eu868.c │ │ │ ├── lmic_eu_like.c │ │ │ ├── lmic_eu_like.h │ │ │ ├── lmic_in866.c │ │ │ ├── lmic_us915.c │ │ │ ├── lmic_us_like.c │ │ │ ├── lmic_us_like.h │ │ │ ├── lmic_util.c │ │ │ ├── lmic_util.h │ │ │ ├── lorabase.h │ │ │ ├── lorabase_as923.h │ │ │ ├── lorabase_au921.h │ │ │ ├── lorabase_eu868.h │ │ │ ├── lorabase_in866.h │ │ │ ├── lorabase_us915.h │ │ │ ├── oslmic.c │ │ │ ├── oslmic.h │ │ │ └── radio.c │ └── SSD1306 │ │ ├── README.md │ │ ├── README.txt │ │ ├── examples │ │ └── ssd1306_128x64_i2c │ │ │ └── ssd1306_128x64_i2c.ino │ │ ├── library.properties │ │ ├── license.txt │ │ └── src │ │ ├── ssd1306.cpp │ │ └── ssd1306.h ├── ttn-otaa-Heltec-lora-eu868-dht22-OLED │ └── ttn-otaa-Heltec-lora-eu868-dht22-OLED.ino └── ttn-otaa-Heltec-lora-eu868-dht22 │ └── ttn-otaa-Heltec-lora-eu868-dht22.ino └── README.md /ESP32_Heltec_V1_LoRa_Mote/libraries/Adafruit_GFX_Library/Adafruit_SPITFT.h: -------------------------------------------------------------------------------- 1 | #ifndef _ADAFRUIT_SPITFT_ 2 | #define _ADAFRUIT_SPITFT_ 3 | 4 | #if ARDUINO >= 100 5 | #include "Arduino.h" 6 | #include "Print.h" 7 | #else 8 | #include "WProgram.h" 9 | #endif 10 | #include 11 | #include "Adafruit_GFX.h" 12 | 13 | #define USE_FAST_PINIO 14 | 15 | #if defined(__AVR__) 16 | typedef volatile uint8_t RwReg; 17 | #elif defined(ARDUINO_STM32_FEATHER) 18 | typedef volatile uint32 RwReg; 19 | #undef USE_FAST_PINIO 20 | #elif defined(__OPENCR__) || defined (__OPENCM904__) 21 | #undef USE_FAST_PINIO 22 | #elif defined(ARDUINO_FEATHER52) || defined(__arm__) 23 | typedef volatile uint32_t RwReg; 24 | #elif defined(ESP32) || defined(ESP8266) 25 | typedef volatile uint32_t RwReg; 26 | #undef USE_FAST_PINIO 27 | #else 28 | #undef USE_FAST_PINIO 29 | #endif 30 | 31 | #include "Adafruit_SPITFT_Macros.h" 32 | 33 | /// A heavily optimized SPI display subclass of GFX. Manages SPI bitbanging, transactions, DMA, etc! Despite being called SPITFT, the classic SPI data/command interface is also used by OLEDs. 34 | class Adafruit_SPITFT : public Adafruit_GFX { 35 | protected: 36 | 37 | public: 38 | Adafruit_SPITFT(uint16_t w, uint16_t h, int8_t _CS, int8_t _DC, int8_t _MOSI, int8_t _SCLK, int8_t _RST = -1, int8_t _MISO = -1); 39 | Adafruit_SPITFT(uint16_t w, uint16_t h, int8_t _CS, int8_t _DC, int8_t _RST = -1); 40 | Adafruit_SPITFT(uint16_t w, uint16_t h, SPIClass *spiClass, int8_t _CS, int8_t _DC, int8_t _RST = -1); 41 | 42 | virtual void begin(uint32_t freq) = 0; ///< Virtual begin() function to set SPI frequency, must be overridden in subclass. @param freq Maximum SPI hardware clock speed 43 | 44 | void initSPI(uint32_t freq); 45 | 46 | // Required Non-Transaction 47 | void drawPixel(int16_t x, int16_t y, uint16_t color); 48 | 49 | // Transaction API 50 | void startWrite(void); 51 | void endWrite(void); 52 | 53 | void writePixel(int16_t x, int16_t y, uint16_t color); 54 | void writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); 55 | void writeFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); 56 | void writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); 57 | 58 | // Transaction API not used by GFX 59 | 60 | /*! 61 | @brief SPI displays set an address window rectangle for blitting pixels 62 | @param x Top left corner x coordinate 63 | @param y Top left corner x coordinate 64 | @param w Width of window 65 | @param h Height of window 66 | */ 67 | virtual void setAddrWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h) = 0; 68 | 69 | /*! 70 | @brief Write a 2-byte color (must have a transaction in progress) 71 | @param color 16-bit 5-6-5 Color to draw 72 | */ 73 | void inline writePixel(uint16_t color) { SPI_WRITE16(color); } 74 | void writePixels(uint16_t * colors, uint32_t len); 75 | void writeColor(uint16_t color, uint32_t len); 76 | void pushColor(uint16_t color); 77 | 78 | // Recommended Non-Transaction 79 | void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); 80 | void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); 81 | void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); 82 | 83 | using Adafruit_GFX::drawRGBBitmap; // Check base class first 84 | void drawRGBBitmap(int16_t x, int16_t y, 85 | uint16_t *pcolors, int16_t w, int16_t h); 86 | void invertDisplay(boolean i); 87 | 88 | uint16_t color565(uint8_t r, uint8_t g, uint8_t b); 89 | 90 | protected: 91 | SPIClass *_spi; ///< The SPI device we want to use (set in constructor) 92 | uint32_t _freq; ///< SPI clock frequency (for hardware SPI) 93 | #if defined (__AVR__) || defined(TEENSYDUINO) || defined (ESP8266) || defined (ESP32) 94 | int8_t _cs, _dc, _rst, _sclk, _mosi, _miso; 95 | #else 96 | int32_t _cs, ///< Arduino pin # for chip-select pin 97 | _dc, ///< Arduino pin # for data-command pin 98 | _rst, ///< Arduino pin # for reset pin 99 | _sclk, ///< Arduino pin # for SPI clock pin 100 | _mosi, ///< Arduino pin # for SPI MOSI pin 101 | _miso; ///< Arduino pin # for SPI MISO pin 102 | #endif 103 | 104 | #ifdef USE_FAST_PINIO 105 | volatile RwReg *mosiport, ///< Direct chip register for toggling MOSI with fast bitbang IO 106 | *misoport, ///< Direct chip register for toggling MISO with fast bitbang IO 107 | *clkport, ///< Direct chip register for toggling CLK with fast bitbang IO 108 | *dcport, ///< Direct chip register for toggling DC with fast bitbang IO 109 | *csport; ///< Direct chip register for toggling CS with fast bitbang IO 110 | RwReg mosipinmask, ///< bitmask for turning on/off MOSI with fast register bitbang IO 111 | misopinmask, ///< bitmask for turning on/off MISO with fast register bitbang IO 112 | clkpinmask, ///< bitmask for turning on/off CLK with fast register bitbang IO 113 | cspinmask, ///< bitmask for turning on/off CS with fast register bitbang IO 114 | dcpinmask; ///< bitmask for turning on/off DC with fast register bitbang IO 115 | #endif 116 | 117 | void writeCommand(uint8_t cmd); 118 | void spiWrite(uint8_t v); 119 | uint8_t spiRead(void); 120 | 121 | uint8_t invertOnCommand = 0, ///< SPI command byte to turn on invert 122 | invertOffCommand = 0; ///< SPI command byte to turn off invert 123 | int16_t _xstart = 0; ///< Many displays don't have pixels starting at (0,0) of the internal framebuffer, this is the x offset from 0 to align 124 | int16_t _ystart = 0; ///< Many displays don't have pixels starting at (0,0) of the internal framebuffer, this is the y offset from 0 to align 125 | }; 126 | 127 | #endif 128 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/Adafruit_GFX_Library/Adafruit_SPITFT_Macros.h: -------------------------------------------------------------------------------- 1 | #ifndef _ADAFRUIT_SPITFT_MACROS 2 | #define _ADAFRUIT_SPITFT_MACROS 3 | 4 | /* 5 | * Control Pins 6 | * */ 7 | 8 | #ifdef USE_FAST_PINIO 9 | #define SPI_DC_HIGH() *dcport |= dcpinmask 10 | #define SPI_DC_LOW() *dcport &= ~dcpinmask 11 | #define SPI_CS_HIGH() *csport |= cspinmask 12 | #define SPI_CS_LOW() *csport &= ~cspinmask 13 | #else 14 | #define SPI_DC_HIGH() digitalWrite(_dc, HIGH) 15 | #define SPI_DC_LOW() digitalWrite(_dc, LOW) 16 | #define SPI_CS_HIGH() { if(_cs >= 0) digitalWrite(_cs, HIGH); } 17 | #define SPI_CS_LOW() { if(_cs >= 0) digitalWrite(_cs, LOW); } 18 | #endif 19 | 20 | /* 21 | * Software SPI Macros 22 | * */ 23 | 24 | #ifdef USE_FAST_PINIO 25 | #define SSPI_MOSI_HIGH() *mosiport |= mosipinmask 26 | #define SSPI_MOSI_LOW() *mosiport &= ~mosipinmask 27 | #define SSPI_SCK_HIGH() *clkport |= clkpinmask 28 | #define SSPI_SCK_LOW() *clkport &= ~clkpinmask 29 | #define SSPI_MISO_READ() ((*misoport & misopinmask) != 0) 30 | #else 31 | #define SSPI_MOSI_HIGH() digitalWrite(_mosi, HIGH) 32 | #define SSPI_MOSI_LOW() digitalWrite(_mosi, LOW) 33 | #define SSPI_SCK_HIGH() digitalWrite(_sclk, HIGH) 34 | #define SSPI_SCK_LOW() digitalWrite(_sclk, LOW) 35 | #define SSPI_MISO_READ() digitalRead(_miso) 36 | #endif 37 | 38 | #define SSPI_BEGIN_TRANSACTION() 39 | #define SSPI_END_TRANSACTION() 40 | #define SSPI_WRITE(v) spiWrite(v) 41 | #define SSPI_WRITE16(s) SSPI_WRITE((s) >> 8); SSPI_WRITE(s) 42 | #define SSPI_WRITE32(l) SSPI_WRITE((l) >> 24); SSPI_WRITE((l) >> 16); SSPI_WRITE((l) >> 8); SSPI_WRITE(l) 43 | #define SSPI_WRITE_PIXELS(c,l) for(uint32_t i=0; i<(l); i+=2){ SSPI_WRITE(((uint8_t*)(c))[i+1]); SSPI_WRITE(((uint8_t*)(c))[i]); } 44 | 45 | /* 46 | * Hardware SPI Macros 47 | * */ 48 | 49 | #if defined (__AVR__) || defined(TEENSYDUINO) || defined(ARDUINO_ARCH_STM32F1) 50 | #define HSPI_SET_CLOCK() _spi->setClockDivider(SPI_CLOCK_DIV2); 51 | #elif defined (__arm__) 52 | #define HSPI_SET_CLOCK() _spi->setClockDivider(11); 53 | #elif defined(ESP8266) || defined(ESP32) 54 | #define HSPI_SET_CLOCK() _spi->setFrequency(_freq); 55 | #elif defined(RASPI) 56 | #define HSPI_SET_CLOCK() _spi->setClock(_freq); 57 | #elif defined(ARDUINO_ARCH_STM32F1) 58 | #define HSPI_SET_CLOCK() _spi->setClock(_freq); 59 | #else 60 | #define HSPI_SET_CLOCK() 61 | #endif 62 | 63 | #ifdef SPI_HAS_TRANSACTION 64 | #define HSPI_BEGIN_TRANSACTION() _spi->beginTransaction(SPISettings(_freq, MSBFIRST, SPI_MODE0)) 65 | #define HSPI_END_TRANSACTION() _spi->endTransaction() 66 | #else 67 | #define HSPI_BEGIN_TRANSACTION() HSPI_SET_CLOCK(); _spi->setBitOrder(MSBFIRST); _spi->setDataMode(SPI_MODE0) 68 | #define HSPI_END_TRANSACTION() 69 | #endif 70 | 71 | #ifdef ESP32 72 | #define SPI_HAS_WRITE_PIXELS 73 | #endif 74 | #if defined(ESP8266) || defined(ESP32) 75 | // Optimized SPI (ESP8266 and ESP32) 76 | #define HSPI_READ() _spi->transfer(0) 77 | #define HSPI_WRITE(b) _spi->write(b) 78 | #define HSPI_WRITE16(s) _spi->write16(s) 79 | #define HSPI_WRITE32(l) _spi->write32(l) 80 | #ifdef SPI_HAS_WRITE_PIXELS 81 | #define SPI_MAX_PIXELS_AT_ONCE 32 82 | #define HSPI_WRITE_PIXELS(c,l) _spi->writePixels(c,l) 83 | #else 84 | #define HSPI_WRITE_PIXELS(c,l) for(uint32_t i=0; i<((l)/2); i++){ SPI_WRITE16(((uint16_t*)(c))[i]); } 85 | #endif 86 | #else 87 | // Standard Byte-by-Byte SPI 88 | 89 | #if defined (__AVR__) || defined(TEENSYDUINO) 90 | static inline uint8_t _avr_spi_read(void) __attribute__((always_inline)); 91 | static inline uint8_t _avr_spi_read(void) { 92 | uint8_t r = 0; 93 | SPDR = r; 94 | while(!(SPSR & _BV(SPIF))); 95 | r = SPDR; 96 | return r; 97 | } 98 | #define HSPI_WRITE(b) {SPDR = (b); while(!(SPSR & _BV(SPIF)));} 99 | #define HSPI_READ() _avr_spi_read() 100 | #else 101 | #define HSPI_WRITE(b) _spi->transfer((uint8_t)(b)) 102 | #define HSPI_READ() HSPI_WRITE(0) 103 | #endif 104 | #define HSPI_WRITE16(s) HSPI_WRITE((s) >> 8); HSPI_WRITE(s) 105 | #define HSPI_WRITE32(l) HSPI_WRITE((l) >> 24); HSPI_WRITE((l) >> 16); HSPI_WRITE((l) >> 8); HSPI_WRITE(l) 106 | #define HSPI_WRITE_PIXELS(c,l) for(uint32_t i=0; i<(l); i+=2){ HSPI_WRITE(((uint8_t*)(c))[i+1]); HSPI_WRITE(((uint8_t*)(c))[i]); } 107 | #endif 108 | 109 | #define SPI_BEGIN() if(_sclk < 0){_spi->begin();} 110 | #define SPI_BEGIN_TRANSACTION() if(_sclk < 0){HSPI_BEGIN_TRANSACTION();} 111 | #define SPI_END_TRANSACTION() if(_sclk < 0){HSPI_END_TRANSACTION();} 112 | #define SPI_WRITE16(s) if(_sclk < 0){HSPI_WRITE16(s);}else{SSPI_WRITE16(s);} 113 | #define SPI_WRITE32(l) if(_sclk < 0){HSPI_WRITE32(l);}else{SSPI_WRITE32(l);} 114 | #define SPI_WRITE_PIXELS(c,l) if(_sclk < 0){HSPI_WRITE_PIXELS(c,l);}else{SSPI_WRITE_PIXELS(c,l);} 115 | 116 | #endif // _ADAFRUIT_SPITFT_MACROS 117 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/Adafruit_GFX_Library/Fonts/Org_01.h: -------------------------------------------------------------------------------- 1 | // Org_v01 by Orgdot (www.orgdot.com/aliasfonts). A tiny, 2 | // stylized font with all characters within a 6 pixel height. 3 | 4 | const uint8_t Org_01Bitmaps[] PROGMEM = { 5 | 0xE8, 0xA0, 0x57, 0xD5, 0xF5, 0x00, 0xFD, 0x3E, 0x5F, 0x80, 0x88, 0x88, 6 | 0x88, 0x80, 0xF4, 0xBF, 0x2E, 0x80, 0x80, 0x6A, 0x40, 0x95, 0x80, 0xAA, 7 | 0x80, 0x5D, 0x00, 0xC0, 0xF0, 0x80, 0x08, 0x88, 0x88, 0x00, 0xFC, 0x63, 8 | 0x1F, 0x80, 0xF8, 0xF8, 0x7F, 0x0F, 0x80, 0xF8, 0x7E, 0x1F, 0x80, 0x8C, 9 | 0x7E, 0x10, 0x80, 0xFC, 0x3E, 0x1F, 0x80, 0xFC, 0x3F, 0x1F, 0x80, 0xF8, 10 | 0x42, 0x10, 0x80, 0xFC, 0x7F, 0x1F, 0x80, 0xFC, 0x7E, 0x1F, 0x80, 0x90, 11 | 0xB0, 0x2A, 0x22, 0xF0, 0xF0, 0x88, 0xA8, 0xF8, 0x4E, 0x02, 0x00, 0xFD, 12 | 0x6F, 0x0F, 0x80, 0xFC, 0x7F, 0x18, 0x80, 0xF4, 0x7D, 0x1F, 0x00, 0xFC, 13 | 0x21, 0x0F, 0x80, 0xF4, 0x63, 0x1F, 0x00, 0xFC, 0x3F, 0x0F, 0x80, 0xFC, 14 | 0x3F, 0x08, 0x00, 0xFC, 0x2F, 0x1F, 0x80, 0x8C, 0x7F, 0x18, 0x80, 0xF9, 15 | 0x08, 0x4F, 0x80, 0x78, 0x85, 0x2F, 0x80, 0x8D, 0xB1, 0x68, 0x80, 0x84, 16 | 0x21, 0x0F, 0x80, 0xFD, 0x6B, 0x5A, 0x80, 0xFC, 0x63, 0x18, 0x80, 0xFC, 17 | 0x63, 0x1F, 0x80, 0xFC, 0x7F, 0x08, 0x00, 0xFC, 0x63, 0x3F, 0x80, 0xFC, 18 | 0x7F, 0x29, 0x00, 0xFC, 0x3E, 0x1F, 0x80, 0xF9, 0x08, 0x42, 0x00, 0x8C, 19 | 0x63, 0x1F, 0x80, 0x8C, 0x62, 0xA2, 0x00, 0xAD, 0x6B, 0x5F, 0x80, 0x8A, 20 | 0x88, 0xA8, 0x80, 0x8C, 0x54, 0x42, 0x00, 0xF8, 0x7F, 0x0F, 0x80, 0xEA, 21 | 0xC0, 0x82, 0x08, 0x20, 0x80, 0xD5, 0xC0, 0x54, 0xF8, 0x80, 0xF1, 0xFF, 22 | 0x8F, 0x99, 0xF0, 0xF8, 0x8F, 0x1F, 0x99, 0xF0, 0xFF, 0x8F, 0x6B, 0xA4, 23 | 0xF9, 0x9F, 0x10, 0x8F, 0x99, 0x90, 0xF0, 0x55, 0xC0, 0x8A, 0xF9, 0x90, 24 | 0xF8, 0xFD, 0x63, 0x10, 0xF9, 0x99, 0xF9, 0x9F, 0xF9, 0x9F, 0x80, 0xF9, 25 | 0x9F, 0x20, 0xF8, 0x88, 0x47, 0x1F, 0x27, 0xC8, 0x42, 0x00, 0x99, 0x9F, 26 | 0x99, 0x97, 0x8C, 0x6B, 0xF0, 0x96, 0x69, 0x99, 0x9F, 0x10, 0x2E, 0x8F, 27 | 0x2B, 0x22, 0xF8, 0x89, 0xA8, 0x0F, 0xE0 }; 28 | 29 | const GFXglyph Org_01Glyphs[] PROGMEM = { 30 | { 0, 0, 0, 6, 0, 1 }, // 0x20 ' ' 31 | { 0, 1, 5, 2, 0, -4 }, // 0x21 '!' 32 | { 1, 3, 1, 4, 0, -4 }, // 0x22 '"' 33 | { 2, 5, 5, 6, 0, -4 }, // 0x23 '#' 34 | { 6, 5, 5, 6, 0, -4 }, // 0x24 '$' 35 | { 10, 5, 5, 6, 0, -4 }, // 0x25 '%' 36 | { 14, 5, 5, 6, 0, -4 }, // 0x26 '&' 37 | { 18, 1, 1, 2, 0, -4 }, // 0x27 ''' 38 | { 19, 2, 5, 3, 0, -4 }, // 0x28 '(' 39 | { 21, 2, 5, 3, 0, -4 }, // 0x29 ')' 40 | { 23, 3, 3, 4, 0, -3 }, // 0x2A '*' 41 | { 25, 3, 3, 4, 0, -3 }, // 0x2B '+' 42 | { 27, 1, 2, 2, 0, 0 }, // 0x2C ',' 43 | { 28, 4, 1, 5, 0, -2 }, // 0x2D '-' 44 | { 29, 1, 1, 2, 0, 0 }, // 0x2E '.' 45 | { 30, 5, 5, 6, 0, -4 }, // 0x2F '/' 46 | { 34, 5, 5, 6, 0, -4 }, // 0x30 '0' 47 | { 38, 1, 5, 2, 0, -4 }, // 0x31 '1' 48 | { 39, 5, 5, 6, 0, -4 }, // 0x32 '2' 49 | { 43, 5, 5, 6, 0, -4 }, // 0x33 '3' 50 | { 47, 5, 5, 6, 0, -4 }, // 0x34 '4' 51 | { 51, 5, 5, 6, 0, -4 }, // 0x35 '5' 52 | { 55, 5, 5, 6, 0, -4 }, // 0x36 '6' 53 | { 59, 5, 5, 6, 0, -4 }, // 0x37 '7' 54 | { 63, 5, 5, 6, 0, -4 }, // 0x38 '8' 55 | { 67, 5, 5, 6, 0, -4 }, // 0x39 '9' 56 | { 71, 1, 4, 2, 0, -3 }, // 0x3A ':' 57 | { 72, 1, 4, 2, 0, -3 }, // 0x3B ';' 58 | { 73, 3, 5, 4, 0, -4 }, // 0x3C '<' 59 | { 75, 4, 3, 5, 0, -3 }, // 0x3D '=' 60 | { 77, 3, 5, 4, 0, -4 }, // 0x3E '>' 61 | { 79, 5, 5, 6, 0, -4 }, // 0x3F '?' 62 | { 83, 5, 5, 6, 0, -4 }, // 0x40 '@' 63 | { 87, 5, 5, 6, 0, -4 }, // 0x41 'A' 64 | { 91, 5, 5, 6, 0, -4 }, // 0x42 'B' 65 | { 95, 5, 5, 6, 0, -4 }, // 0x43 'C' 66 | { 99, 5, 5, 6, 0, -4 }, // 0x44 'D' 67 | { 103, 5, 5, 6, 0, -4 }, // 0x45 'E' 68 | { 107, 5, 5, 6, 0, -4 }, // 0x46 'F' 69 | { 111, 5, 5, 6, 0, -4 }, // 0x47 'G' 70 | { 115, 5, 5, 6, 0, -4 }, // 0x48 'H' 71 | { 119, 5, 5, 6, 0, -4 }, // 0x49 'I' 72 | { 123, 5, 5, 6, 0, -4 }, // 0x4A 'J' 73 | { 127, 5, 5, 6, 0, -4 }, // 0x4B 'K' 74 | { 131, 5, 5, 6, 0, -4 }, // 0x4C 'L' 75 | { 135, 5, 5, 6, 0, -4 }, // 0x4D 'M' 76 | { 139, 5, 5, 6, 0, -4 }, // 0x4E 'N' 77 | { 143, 5, 5, 6, 0, -4 }, // 0x4F 'O' 78 | { 147, 5, 5, 6, 0, -4 }, // 0x50 'P' 79 | { 151, 5, 5, 6, 0, -4 }, // 0x51 'Q' 80 | { 155, 5, 5, 6, 0, -4 }, // 0x52 'R' 81 | { 159, 5, 5, 6, 0, -4 }, // 0x53 'S' 82 | { 163, 5, 5, 6, 0, -4 }, // 0x54 'T' 83 | { 167, 5, 5, 6, 0, -4 }, // 0x55 'U' 84 | { 171, 5, 5, 6, 0, -4 }, // 0x56 'V' 85 | { 175, 5, 5, 6, 0, -4 }, // 0x57 'W' 86 | { 179, 5, 5, 6, 0, -4 }, // 0x58 'X' 87 | { 183, 5, 5, 6, 0, -4 }, // 0x59 'Y' 88 | { 187, 5, 5, 6, 0, -4 }, // 0x5A 'Z' 89 | { 191, 2, 5, 3, 0, -4 }, // 0x5B '[' 90 | { 193, 5, 5, 6, 0, -4 }, // 0x5C '\' 91 | { 197, 2, 5, 3, 0, -4 }, // 0x5D ']' 92 | { 199, 3, 2, 4, 0, -4 }, // 0x5E '^' 93 | { 200, 5, 1, 6, 0, 1 }, // 0x5F '_' 94 | { 201, 1, 1, 2, 0, -4 }, // 0x60 '`' 95 | { 202, 4, 4, 5, 0, -3 }, // 0x61 'a' 96 | { 204, 4, 5, 5, 0, -4 }, // 0x62 'b' 97 | { 207, 4, 4, 5, 0, -3 }, // 0x63 'c' 98 | { 209, 4, 5, 5, 0, -4 }, // 0x64 'd' 99 | { 212, 4, 4, 5, 0, -3 }, // 0x65 'e' 100 | { 214, 3, 5, 4, 0, -4 }, // 0x66 'f' 101 | { 216, 4, 5, 5, 0, -3 }, // 0x67 'g' 102 | { 219, 4, 5, 5, 0, -4 }, // 0x68 'h' 103 | { 222, 1, 4, 2, 0, -3 }, // 0x69 'i' 104 | { 223, 2, 5, 3, 0, -3 }, // 0x6A 'j' 105 | { 225, 4, 5, 5, 0, -4 }, // 0x6B 'k' 106 | { 228, 1, 5, 2, 0, -4 }, // 0x6C 'l' 107 | { 229, 5, 4, 6, 0, -3 }, // 0x6D 'm' 108 | { 232, 4, 4, 5, 0, -3 }, // 0x6E 'n' 109 | { 234, 4, 4, 5, 0, -3 }, // 0x6F 'o' 110 | { 236, 4, 5, 5, 0, -3 }, // 0x70 'p' 111 | { 239, 4, 5, 5, 0, -3 }, // 0x71 'q' 112 | { 242, 4, 4, 5, 0, -3 }, // 0x72 'r' 113 | { 244, 4, 4, 5, 0, -3 }, // 0x73 's' 114 | { 246, 5, 5, 6, 0, -4 }, // 0x74 't' 115 | { 250, 4, 4, 5, 0, -3 }, // 0x75 'u' 116 | { 252, 4, 4, 5, 0, -3 }, // 0x76 'v' 117 | { 254, 5, 4, 6, 0, -3 }, // 0x77 'w' 118 | { 257, 4, 4, 5, 0, -3 }, // 0x78 'x' 119 | { 259, 4, 5, 5, 0, -3 }, // 0x79 'y' 120 | { 262, 4, 4, 5, 0, -3 }, // 0x7A 'z' 121 | { 264, 3, 5, 4, 0, -4 }, // 0x7B '{' 122 | { 266, 1, 5, 2, 0, -4 }, // 0x7C '|' 123 | { 267, 3, 5, 4, 0, -4 }, // 0x7D '}' 124 | { 269, 5, 3, 6, 0, -3 } }; // 0x7E '~' 125 | 126 | const GFXfont Org_01 PROGMEM = { 127 | (uint8_t *)Org_01Bitmaps, 128 | (GFXglyph *)Org_01Glyphs, 129 | 0x20, 0x7E, 7 }; 130 | 131 | // Approx. 943 bytes 132 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/Adafruit_GFX_Library/Fonts/Picopixel.h: -------------------------------------------------------------------------------- 1 | // Picopixel by Sebastian Weber. A tiny font 2 | // with all characters within a 6 pixel height. 3 | 4 | const uint8_t PicopixelBitmaps[] PROGMEM = { 5 | 0xE8, 0xB4, 0x57, 0xD5, 0xF5, 0x00, 0x4E, 0x3E, 0x80, 0xA5, 0x4A, 0x4A, 6 | 0x5A, 0x50, 0xC0, 0x6A, 0x40, 0x95, 0x80, 0xAA, 0x80, 0x5D, 0x00, 0x60, 7 | 0xE0, 0x80, 0x25, 0x48, 0x56, 0xD4, 0x75, 0x40, 0xC5, 0x4E, 0xC5, 0x1C, 8 | 0x97, 0x92, 0xF3, 0x1C, 0x53, 0x54, 0xE5, 0x48, 0x55, 0x54, 0x55, 0x94, 9 | 0xA0, 0x46, 0x64, 0xE3, 0x80, 0x98, 0xC5, 0x04, 0x56, 0xC6, 0x57, 0xDA, 10 | 0xD7, 0x5C, 0x72, 0x46, 0xD6, 0xDC, 0xF3, 0xCE, 0xF3, 0x48, 0x72, 0xD4, 11 | 0xB7, 0xDA, 0xF8, 0x24, 0xD4, 0xBB, 0x5A, 0x92, 0x4E, 0x8E, 0xEB, 0x58, 12 | 0x80, 0x9D, 0xB9, 0x90, 0x56, 0xD4, 0xD7, 0x48, 0x56, 0xD4, 0x40, 0xD7, 13 | 0x5A, 0x71, 0x1C, 0xE9, 0x24, 0xB6, 0xD4, 0xB6, 0xA4, 0x8C, 0x6B, 0x55, 14 | 0x00, 0xB5, 0x5A, 0xB5, 0x24, 0xE5, 0x4E, 0xEA, 0xC0, 0x91, 0x12, 0xD5, 15 | 0xC0, 0x54, 0xF0, 0x90, 0xC7, 0xF0, 0x93, 0x5E, 0x71, 0x80, 0x25, 0xDE, 16 | 0x5E, 0x30, 0x6E, 0x80, 0x77, 0x9C, 0x93, 0x5A, 0xB8, 0x45, 0x60, 0x92, 17 | 0xEA, 0xAA, 0x40, 0xD5, 0x6A, 0xD6, 0x80, 0x55, 0x00, 0xD7, 0x40, 0x75, 18 | 0x90, 0xE8, 0x71, 0xE0, 0xBA, 0x40, 0xB5, 0x80, 0xB5, 0x00, 0x8D, 0x54, 19 | 0xAA, 0x80, 0xAC, 0xE0, 0xE5, 0x70, 0x6A, 0x26, 0xFC, 0xC8, 0xAC, 0x5A }; 20 | 21 | const GFXglyph PicopixelGlyphs[] PROGMEM = { 22 | { 0, 0, 0, 2, 0, 1 }, // 0x20 ' ' 23 | { 0, 1, 5, 2, 0, -4 }, // 0x21 '!' 24 | { 1, 3, 2, 4, 0, -4 }, // 0x22 '"' 25 | { 2, 5, 5, 6, 0, -4 }, // 0x23 '#' 26 | { 6, 3, 6, 4, 0, -4 }, // 0x24 '$' 27 | { 9, 3, 5, 4, 0, -4 }, // 0x25 '%' 28 | { 11, 4, 5, 5, 0, -4 }, // 0x26 '&' 29 | { 14, 1, 2, 2, 0, -4 }, // 0x27 ''' 30 | { 15, 2, 5, 3, 0, -4 }, // 0x28 '(' 31 | { 17, 2, 5, 3, 0, -4 }, // 0x29 ')' 32 | { 19, 3, 3, 4, 0, -3 }, // 0x2A '*' 33 | { 21, 3, 3, 4, 0, -3 }, // 0x2B '+' 34 | { 23, 2, 2, 3, 0, 0 }, // 0x2C ',' 35 | { 24, 3, 1, 4, 0, -2 }, // 0x2D '-' 36 | { 25, 1, 1, 2, 0, 0 }, // 0x2E '.' 37 | { 26, 3, 5, 4, 0, -4 }, // 0x2F '/' 38 | { 28, 3, 5, 4, 0, -4 }, // 0x30 '0' 39 | { 30, 2, 5, 3, 0, -4 }, // 0x31 '1' 40 | { 32, 3, 5, 4, 0, -4 }, // 0x32 '2' 41 | { 34, 3, 5, 4, 0, -4 }, // 0x33 '3' 42 | { 36, 3, 5, 4, 0, -4 }, // 0x34 '4' 43 | { 38, 3, 5, 4, 0, -4 }, // 0x35 '5' 44 | { 40, 3, 5, 4, 0, -4 }, // 0x36 '6' 45 | { 42, 3, 5, 4, 0, -4 }, // 0x37 '7' 46 | { 44, 3, 5, 4, 0, -4 }, // 0x38 '8' 47 | { 46, 3, 5, 4, 0, -4 }, // 0x39 '9' 48 | { 48, 1, 3, 2, 0, -3 }, // 0x3A ':' 49 | { 49, 2, 4, 3, 0, -3 }, // 0x3B ';' 50 | { 50, 2, 3, 3, 0, -3 }, // 0x3C '<' 51 | { 51, 3, 3, 4, 0, -3 }, // 0x3D '=' 52 | { 53, 2, 3, 3, 0, -3 }, // 0x3E '>' 53 | { 54, 3, 5, 4, 0, -4 }, // 0x3F '?' 54 | { 56, 3, 5, 4, 0, -4 }, // 0x40 '@' 55 | { 58, 3, 5, 4, 0, -4 }, // 0x41 'A' 56 | { 60, 3, 5, 4, 0, -4 }, // 0x42 'B' 57 | { 62, 3, 5, 4, 0, -4 }, // 0x43 'C' 58 | { 64, 3, 5, 4, 0, -4 }, // 0x44 'D' 59 | { 66, 3, 5, 4, 0, -4 }, // 0x45 'E' 60 | { 68, 3, 5, 4, 0, -4 }, // 0x46 'F' 61 | { 70, 3, 5, 4, 0, -4 }, // 0x47 'G' 62 | { 72, 3, 5, 4, 0, -4 }, // 0x48 'H' 63 | { 74, 1, 5, 2, 0, -4 }, // 0x49 'I' 64 | { 75, 3, 5, 4, 0, -4 }, // 0x4A 'J' 65 | { 77, 3, 5, 4, 0, -4 }, // 0x4B 'K' 66 | { 79, 3, 5, 4, 0, -4 }, // 0x4C 'L' 67 | { 81, 5, 5, 6, 0, -4 }, // 0x4D 'M' 68 | { 85, 4, 5, 5, 0, -4 }, // 0x4E 'N' 69 | { 88, 3, 5, 4, 0, -4 }, // 0x4F 'O' 70 | { 90, 3, 5, 4, 0, -4 }, // 0x50 'P' 71 | { 92, 3, 6, 4, 0, -4 }, // 0x51 'Q' 72 | { 95, 3, 5, 4, 0, -4 }, // 0x52 'R' 73 | { 97, 3, 5, 4, 0, -4 }, // 0x53 'S' 74 | { 99, 3, 5, 4, 0, -4 }, // 0x54 'T' 75 | { 101, 3, 5, 4, 0, -4 }, // 0x55 'U' 76 | { 103, 3, 5, 4, 0, -4 }, // 0x56 'V' 77 | { 105, 5, 5, 6, 0, -4 }, // 0x57 'W' 78 | { 109, 3, 5, 4, 0, -4 }, // 0x58 'X' 79 | { 111, 3, 5, 4, 0, -4 }, // 0x59 'Y' 80 | { 113, 3, 5, 4, 0, -4 }, // 0x5A 'Z' 81 | { 115, 2, 5, 3, 0, -4 }, // 0x5B '[' 82 | { 117, 3, 5, 4, 0, -4 }, // 0x5C '\' 83 | { 119, 2, 5, 3, 0, -4 }, // 0x5D ']' 84 | { 121, 3, 2, 4, 0, -4 }, // 0x5E '^' 85 | { 122, 4, 1, 4, 0, 1 }, // 0x5F '_' 86 | { 123, 2, 2, 3, 0, -4 }, // 0x60 '`' 87 | { 124, 3, 4, 4, 0, -3 }, // 0x61 'a' 88 | { 126, 3, 5, 4, 0, -4 }, // 0x62 'b' 89 | { 128, 3, 3, 4, 0, -2 }, // 0x63 'c' 90 | { 130, 3, 5, 4, 0, -4 }, // 0x64 'd' 91 | { 132, 3, 4, 4, 0, -3 }, // 0x65 'e' 92 | { 134, 2, 5, 3, 0, -4 }, // 0x66 'f' 93 | { 136, 3, 5, 4, 0, -3 }, // 0x67 'g' 94 | { 138, 3, 5, 4, 0, -4 }, // 0x68 'h' 95 | { 140, 1, 5, 2, 0, -4 }, // 0x69 'i' 96 | { 141, 2, 6, 3, 0, -4 }, // 0x6A 'j' 97 | { 143, 3, 5, 4, 0, -4 }, // 0x6B 'k' 98 | { 145, 2, 5, 3, 0, -4 }, // 0x6C 'l' 99 | { 147, 5, 3, 6, 0, -2 }, // 0x6D 'm' 100 | { 149, 3, 3, 4, 0, -2 }, // 0x6E 'n' 101 | { 151, 3, 3, 4, 0, -2 }, // 0x6F 'o' 102 | { 153, 3, 4, 4, 0, -2 }, // 0x70 'p' 103 | { 155, 3, 4, 4, 0, -2 }, // 0x71 'q' 104 | { 157, 2, 3, 3, 0, -2 }, // 0x72 'r' 105 | { 158, 3, 4, 4, 0, -3 }, // 0x73 's' 106 | { 160, 2, 5, 3, 0, -4 }, // 0x74 't' 107 | { 162, 3, 3, 4, 0, -2 }, // 0x75 'u' 108 | { 164, 3, 3, 4, 0, -2 }, // 0x76 'v' 109 | { 166, 5, 3, 6, 0, -2 }, // 0x77 'w' 110 | { 168, 3, 3, 4, 0, -2 }, // 0x78 'x' 111 | { 170, 3, 4, 4, 0, -2 }, // 0x79 'y' 112 | { 172, 3, 4, 4, 0, -3 }, // 0x7A 'z' 113 | { 174, 3, 5, 4, 0, -4 }, // 0x7B '{' 114 | { 176, 1, 6, 2, 0, -4 }, // 0x7C '|' 115 | { 177, 3, 5, 4, 0, -4 }, // 0x7D '}' 116 | { 179, 4, 2, 5, 0, -3 } }; // 0x7E '~' 117 | 118 | const GFXfont Picopixel PROGMEM = { 119 | (uint8_t *)PicopixelBitmaps, 120 | (GFXglyph *)PicopixelGlyphs, 121 | 0x20, 0x7E, 7 }; 122 | 123 | // Approx. 852 bytes 124 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/Adafruit_GFX_Library/Fonts/Tiny3x3a2pt7b: -------------------------------------------------------------------------------- 1 | /** 2 | ** The FontStruction “Tiny3x3a” 3 | ** (https://fontstruct.com/fontstructions/show/670512) by “Michaelangel007” is 4 | ** licensed under a Creative Commons Attribution Non-commercial Share Alike license 5 | ** (http://creativecommons.org/licenses/by-nc-sa/3.0/). 6 | ** “Tiny3x3a” was originally cloned (copied) from the FontStruction 7 | ** “CHECKER” (https://fontstruct.com/fontstructions/show/2391) by Wolf grant 8 | ** Grant, which is licensed under a Creative Commons Attribution Non-commercial 9 | ** Share Alike license (http://creativecommons.org/licenses/by-nc-sa/3.0/). 10 | * 11 | * Converted by eadmaster with fontconvert 12 | **/ 13 | 14 | const uint8_t Tiny3x3a2pt7bBitmaps[] PROGMEM = { 15 | 0xC0, 0xB4, 0xBF, 0x80, 0x6B, 0x00, 0xDD, 0x80, 0x59, 0x80, 0x80, 0x64, 16 | 0x98, 0xF0, 0x5D, 0x00, 0xC0, 0xE0, 0x80, 0x2A, 0x00, 0x55, 0x00, 0x94, 17 | 0xC9, 0x80, 0xEF, 0x80, 0xBC, 0x80, 0x6B, 0x00, 0x9F, 0x80, 0xE4, 0x80, 18 | 0x7F, 0x00, 0xFC, 0x80, 0xA0, 0x58, 0x64, 0xE3, 0x80, 0x98, 0xD8, 0xD8, 19 | 0x80, 0x5E, 0x80, 0xDF, 0x80, 0x71, 0x80, 0xD7, 0x00, 0xFB, 0x80, 0xFA, 20 | 0x00, 0xD7, 0x80, 0xBE, 0x80, 0xE0, 0x27, 0x00, 0xBA, 0x80, 0x93, 0x80, 21 | 0xFE, 0x80, 0xF6, 0x80, 0xF7, 0x80, 0xFE, 0x00, 0xF7, 0x00, 0xDE, 0x80, 22 | 0x6B, 0x00, 0xE9, 0x00, 0xB7, 0x80, 0xB5, 0x00, 0xBF, 0x80, 0xAA, 0x80, 23 | 0xA9, 0x00, 0xEB, 0x80, 0xEC, 0x88, 0x80, 0xDC, 0x54, 0xE0, 0x90, 0x70, 24 | 0xBC, 0xF0, 0x7C, 0xB0, 0x68, 0xFC, 0xBC, 0xC0, 0x58, 0x9A, 0x80, 0xA4, 25 | 0xDC, 0xD4, 0xF0, 0xF8, 0xF4, 0xE0, 0x60, 0x59, 0x80, 0xBC, 0xA8, 0xEC, 26 | 0xF0, 0xAC, 0x80, 0x90, 0x79, 0x80, 0xF0, 0xCF, 0x00, 0x78 }; 27 | 28 | const GFXglyph Tiny3x3a2pt7bGlyphs[] PROGMEM = { 29 | { 0, 0, 0, 4, 0, 1 }, // 0x20 ' ' 30 | { 0, 1, 2, 3, 1, -2 }, // 0x21 '!' 31 | { 1, 3, 2, 4, 0, -2 }, // 0x22 '"' 32 | { 2, 3, 3, 4, 0, -2 }, // 0x23 '#' 33 | { 4, 3, 3, 4, 0, -2 }, // 0x24 '$' 34 | { 6, 3, 3, 4, 0, -2 }, // 0x25 '%' 35 | { 8, 3, 3, 4, 0, -2 }, // 0x26 '&' 36 | { 10, 1, 1, 3, 1, -2 }, // 0x27 ''' 37 | { 11, 2, 3, 3, 0, -2 }, // 0x28 '(' 38 | { 12, 2, 3, 4, 1, -2 }, // 0x29 ')' 39 | { 13, 2, 2, 4, 1, -2 }, // 0x2A '*' 40 | { 14, 3, 3, 4, 0, -2 }, // 0x2B '+' 41 | { 16, 1, 2, 2, 0, 0 }, // 0x2C ',' 42 | { 17, 3, 1, 4, 0, -1 }, // 0x2D '-' 43 | { 18, 1, 1, 2, 0, 0 }, // 0x2E '.' 44 | { 19, 3, 3, 4, 0, -2 }, // 0x2F '/' 45 | { 21, 3, 3, 4, 0, -2 }, // 0x30 '0' 46 | { 23, 2, 3, 3, 0, -2 }, // 0x31 '1' 47 | { 24, 3, 3, 4, 0, -2 }, // 0x32 '2' 48 | { 26, 3, 3, 4, 0, -2 }, // 0x33 '3' 49 | { 28, 3, 3, 4, 0, -2 }, // 0x34 '4' 50 | { 30, 3, 3, 4, 0, -2 }, // 0x35 '5' 51 | { 32, 3, 3, 4, 0, -2 }, // 0x36 '6' 52 | { 34, 3, 3, 4, 0, -2 }, // 0x37 '7' 53 | { 36, 3, 3, 4, 0, -2 }, // 0x38 '8' 54 | { 38, 3, 3, 4, 0, -2 }, // 0x39 '9' 55 | { 40, 1, 3, 3, 1, -2 }, // 0x3A ':' 56 | { 41, 2, 3, 3, 0, -1 }, // 0x3B ';' 57 | { 42, 2, 3, 3, 0, -2 }, // 0x3C '<' 58 | { 43, 3, 3, 4, 0, -2 }, // 0x3D '=' 59 | { 45, 2, 3, 4, 1, -2 }, // 0x3E '>' 60 | { 46, 2, 3, 4, 1, -2 }, // 0x3F '?' 61 | { 47, 3, 3, 4, 0, -2 }, // 0x40 '@' 62 | { 49, 3, 3, 4, 0, -2 }, // 0x41 'A' 63 | { 51, 3, 3, 4, 0, -2 }, // 0x42 'B' 64 | { 53, 3, 3, 4, 0, -2 }, // 0x43 'C' 65 | { 55, 3, 3, 4, 0, -2 }, // 0x44 'D' 66 | { 57, 3, 3, 4, 0, -2 }, // 0x45 'E' 67 | { 59, 3, 3, 4, 0, -2 }, // 0x46 'F' 68 | { 61, 3, 3, 4, 0, -2 }, // 0x47 'G' 69 | { 63, 3, 3, 4, 0, -2 }, // 0x48 'H' 70 | { 65, 1, 3, 3, 1, -2 }, // 0x49 'I' 71 | { 66, 3, 3, 4, 0, -2 }, // 0x4A 'J' 72 | { 68, 3, 3, 4, 0, -2 }, // 0x4B 'K' 73 | { 70, 3, 3, 4, 0, -2 }, // 0x4C 'L' 74 | { 72, 3, 3, 4, 0, -2 }, // 0x4D 'M' 75 | { 74, 3, 3, 4, 0, -2 }, // 0x4E 'N' 76 | { 76, 3, 3, 4, 0, -2 }, // 0x4F 'O' 77 | { 78, 3, 3, 4, 0, -2 }, // 0x50 'P' 78 | { 80, 3, 3, 4, 0, -2 }, // 0x51 'Q' 79 | { 82, 3, 3, 4, 0, -2 }, // 0x52 'R' 80 | { 84, 3, 3, 4, 0, -2 }, // 0x53 'S' 81 | { 86, 3, 3, 4, 0, -2 }, // 0x54 'T' 82 | { 88, 3, 3, 4, 0, -2 }, // 0x55 'U' 83 | { 90, 3, 3, 4, 0, -2 }, // 0x56 'V' 84 | { 92, 3, 3, 4, 0, -2 }, // 0x57 'W' 85 | { 94, 3, 3, 4, 0, -2 }, // 0x58 'X' 86 | { 96, 3, 3, 4, 0, -2 }, // 0x59 'Y' 87 | { 98, 3, 3, 4, 0, -2 }, // 0x5A 'Z' 88 | { 100, 2, 3, 3, 0, -2 }, // 0x5B '[' 89 | { 101, 3, 3, 4, 0, -2 }, // 0x5C '\' 90 | { 103, 2, 3, 4, 1, -2 }, // 0x5D ']' 91 | { 104, 3, 2, 4, 0, -2 }, // 0x5E '^' 92 | { 105, 3, 1, 4, 0, 0 }, // 0x5F '_' 93 | { 106, 2, 2, 3, 0, -2 }, // 0x60 '`' 94 | { 107, 2, 2, 3, 0, -1 }, // 0x61 'a' 95 | { 108, 2, 3, 3, 0, -2 }, // 0x62 'b' 96 | { 109, 2, 2, 3, 0, -1 }, // 0x63 'c' 97 | { 110, 2, 3, 3, 0, -2 }, // 0x64 'd' 98 | { 111, 2, 2, 3, 0, -1 }, // 0x65 'e' 99 | { 112, 2, 3, 3, 0, -2 }, // 0x66 'f' 100 | { 113, 2, 3, 3, 0, -1 }, // 0x67 'g' 101 | { 114, 2, 3, 3, 0, -2 }, // 0x68 'h' 102 | { 115, 1, 2, 2, 0, -1 }, // 0x69 'i' 103 | { 116, 2, 3, 3, 0, -1 }, // 0x6A 'j' 104 | { 117, 3, 3, 4, 0, -2 }, // 0x6B 'k' 105 | { 119, 2, 3, 3, 0, -2 }, // 0x6C 'l' 106 | { 120, 3, 2, 4, 0, -1 }, // 0x6D 'm' 107 | { 121, 3, 2, 4, 0, -1 }, // 0x6E 'n' 108 | { 122, 2, 2, 3, 0, -1 }, // 0x6F 'o' 109 | { 123, 2, 3, 3, 0, -1 }, // 0x70 'p' 110 | { 124, 2, 3, 3, 0, -1 }, // 0x71 'q' 111 | { 125, 2, 2, 3, 0, -1 }, // 0x72 'r' 112 | { 126, 2, 2, 3, 0, -1 }, // 0x73 's' 113 | { 127, 3, 3, 4, 0, -2 }, // 0x74 't' 114 | { 129, 3, 2, 4, 0, -1 }, // 0x75 'u' 115 | { 130, 3, 2, 4, 0, -1 }, // 0x76 'v' 116 | { 131, 3, 2, 4, 0, -1 }, // 0x77 'w' 117 | { 132, 2, 2, 3, 0, -1 }, // 0x78 'x' 118 | { 133, 3, 3, 4, 0, -1 }, // 0x79 'y' 119 | { 135, 2, 2, 3, 0, -1 }, // 0x7A 'z' 120 | { 136, 3, 3, 4, 0, -2 }, // 0x7B '{' 121 | { 138, 1, 4, 3, 1, -2 }, // 0x7C '|' 122 | { 139, 3, 3, 4, 0, -2 }, // 0x7D '}' 123 | { 141, 3, 2, 4, 0, -2 } }; // 0x7E '~' 124 | 125 | const GFXfont Tiny3x3a2pt7b PROGMEM = { 126 | (uint8_t *)Tiny3x3a2pt7bBitmaps, 127 | (GFXglyph *)Tiny3x3a2pt7bGlyphs, 128 | 0x20, 0x7E, 4 }; 129 | 130 | // Approx. 814 bytes 131 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/Adafruit_GFX_Library/README.md: -------------------------------------------------------------------------------- 1 | # Adafruit GFX Library # [![Build Status](https://travis-ci.org/adafruit/Adafruit-GFX-Library.svg?branch=master)](https://travis-ci.org/adafruit/Adafruit-GFX-Library) 2 | 3 | This is the core graphics library for all our displays, providing a common set of graphics primitives (points, lines, circles, etc.). It needs to be paired with a hardware-specific library for each display device we carry (to handle the lower-level functions). 4 | 5 | Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! 6 | 7 | Written by Limor Fried/Ladyada for Adafruit Industries. 8 | BSD license, check license.txt for more information. 9 | All text above must be included in any redistribution. 10 | 11 | Recent Arduino IDE releases include the Library Manager for easy installation. Otherwise, to download, click the DOWNLOAD ZIP button, uncompress and rename the uncompressed folder Adafruit_GFX. Confirm that the Adafruit_GFX folder contains Adafruit_GFX.cpp and Adafruit_GFX.h. Place the Adafruit_GFX library folder your ArduinoSketchFolder/Libraries/ folder. You may need to create the Libraries subfolder if its your first library. Restart the IDE. 12 | 13 | # Useful Resources 14 | 15 | - Image2Code: This is a handy Java GUI utility to convert a BMP file into the array code necessary to display the image with the drawBitmap function. Check out the code at ehubin's GitHub repository: https://github.com/ehubin/Adafruit-GFX-Library/tree/master/Img2Code 16 | 17 | - drawXBitmap function: You can use the GIMP photo editor to save a .xbm file and use the array saved in the file to draw a bitmap with the drawXBitmap function. See the pull request here for more details: https://github.com/adafruit/Adafruit-GFX-Library/pull/31 18 | 19 | - 'Fonts' folder contains bitmap fonts for use with recent (1.1 and later) Adafruit_GFX. To use a font in your Arduino sketch, \#include the corresponding .h file and pass address of GFXfont struct to setFont(). Pass NULL to revert to 'classic' fixed-space bitmap font. 20 | 21 | - 'fontconvert' folder contains a command-line tool for converting TTF fonts to Adafruit_GFX header format. 22 | 23 | --- 24 | 25 | ### Roadmap 26 | 27 | The PRIME DIRECTIVE is to maintain backward compatibility with existing Arduino sketches -- many are hosted elsewhere and don't track changes here, some are in print and can never be changed! This "little" library has grown organically over time and sometimes we paint ourselves into a design corner and just have to live with it or add ungainly workarounds. 28 | 29 | Highly unlikely to merge any changes for additional or incompatible font formats (see Prime Directive above). There are already two formats and the code is quite bloaty there as it is (this also creates liabilities for tools and documentation). If you *must* have a more sophisticated font format, consider creating a fork with the features required for your project. For similar reasons, also unlikely to add any more bitmap formats, it's getting messy. 30 | 31 | Please don't reformat code for the sake of reformatting code. The resulting large "visual diff" makes it impossible to untangle actual bug fixes from merely rearranged lines. 32 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/Adafruit_GFX_Library/fontconvert/Makefile: -------------------------------------------------------------------------------- 1 | all: fontconvert 2 | 3 | CC = gcc 4 | CFLAGS = -Wall -I/usr/local/include/freetype2 -I/usr/include/freetype2 -I/usr/include 5 | LIBS = -lfreetype 6 | 7 | fontconvert: fontconvert.c 8 | $(CC) $(CFLAGS) $< $(LIBS) -o $@ 9 | strip $@ 10 | 11 | clean: 12 | rm -f fontconvert 13 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/Adafruit_GFX_Library/fontconvert/fontconvert_win.md: -------------------------------------------------------------------------------- 1 | ### A short guide to use fontconvert.c to create your own fonts using MinGW. 2 | 3 | #### STEP 1: INSTALL MinGW 4 | 5 | Install MinGW (Minimalist GNU for Windows) from [MinGW.org](http://www.mingw.org/). 6 | Please read carefully the instructions found on [Getting started page](http://www.mingw.org/wiki/Getting_Started). 7 | I suggest installing with the "Graphical User Interface Installer". 8 | To complete your initial installation you should further install some "packages". 9 | For our purpose you should only install the "Basic Setup" packages. 10 | To do that: 11 | 12 | 1. Open the MinGW Installation Manager 13 | 2. From the left panel click "Basic Setup". 14 | 3. On the right panel choose "mingw32-base", "mingw-gcc-g++", "mingw-gcc-objc" and "msys-base" 15 | and click "Mark for installation" 16 | 4. From the Menu click "Installation" and then "Apply changes". In the pop-up window select "Apply". 17 | 18 | 19 | #### STEP 2: INSTALL Freetype Library 20 | 21 | To read about the freetype project visit [freetype.org](https://www.freetype.org/). 22 | To Download the latest version of freetype go to [download page](http://download.savannah.gnu.org/releases/freetype/) 23 | and choose "freetype-2.7.tar.gz" file (or a newer version if available). 24 | To avoid long cd commands later in the command prompt, I suggest you unzip the file in the C:\ directory. 25 | (I also renamed the folder to "ft27") 26 | Before you build the library it's good to read these articles: 27 | * [Using MSYS with MinGW](http://www.mingw.org/wiki/MSYS) 28 | * [Installation and Use of Supplementary Libraries with MinGW](http://www.mingw.org/wiki/LibraryPathHOWTO) 29 | * [Include Path](http://www.mingw.org/wiki/IncludePathHOWTO) 30 | 31 | Inside the unzipped folder there is another folder named "docs". Open it and read the INSTALL.UNIX (using notepad). 32 | Pay attention to paragraph 3 (Build and Install the Library). So, let's begin the installation. 33 | To give the appropriate commands we will use the MSYS command prompt (not cmd.exe of windows) which is UNIX like. 34 | Follow the path C:\MinGW\msys\1.0 and double click "msys.bat". The command prompt environment appears. 35 | Enter "ft27" directory using the cd commands: 36 | ``` 37 | cd /c 38 | cd ft27 39 | ``` 40 | 41 | and then type one by one the commands: 42 | ``` 43 | ./configure --prefix=/mingw 44 | make 45 | make install 46 | ``` 47 | Once you're finished, go inside "C:\MinGW\include" and there should be a new folder named "freetype2". 48 | That, hopefully, means that you have installed the library correctly !! 49 | 50 | #### STEP 3: Build fontconvert.c 51 | 52 | Before proceeding I suggest you make a copy of Adafruit_GFX_library folder in C:\ directory. 53 | Then, inside "fontconvert" folder open the "makefile" with an editor ( I used notepad++). 54 | Change the commands so in the end the program looks like : 55 | ``` 56 | all: fontconvert 57 | 58 | CC = gcc 59 | CFLAGS = -Wall -I c:/mingw/include/freetype2 60 | LIBS = -lfreetype 61 | 62 | fontconvert: fontconvert.c 63 | $(CC) $(CFLAGS) $< $(LIBS) -o $@ 64 | 65 | clean: 66 | rm -f fontconvert 67 | ``` 68 | Go back in the command prompt and with a cd command enter the fontconvert directory. 69 | ``` 70 | cd /c/adafruit_gfx_library\fontconvert 71 | ``` 72 | Give the command: 73 | ``` 74 | make 75 | ``` 76 | This command will, eventually, create a "fontconvert.exe" file inside fontconvert directory. 77 | 78 | #### STEP 4: Create your own font header files 79 | 80 | Now that you have an executable file, you can use it to create your own fonts to work with Adafruit GFX lib. 81 | So, if we suppose that you already have a .ttf file with your favorite fonts, jump to the command prompt and type: 82 | ``` 83 | ./fontconvert yourfonts.ttf 9 > yourfonts9pt7b.h 84 | ``` 85 | You can read more details at: [learn.adafruit](https://learn.adafruit.com/adafruit-gfx-graphics-library/using-fonts). 86 | 87 | Taraaaaaammm !! you've just created your new font header file. Put it inside the "Fonts" folder, grab a cup of coffee 88 | and start playing with your Arduino (or whatever else ....)+ display module project. 89 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/Adafruit_GFX_Library/fontconvert/makefonts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Ugly little Bash script, generates a set of .h files for GFX using 4 | # GNU FreeFont sources. There are three fonts: 'Mono' (Courier-like), 5 | # 'Sans' (Helvetica-like) and 'Serif' (Times-like); four styles: regular, 6 | # bold, oblique or italic, and bold+oblique or bold+italic; and four 7 | # sizes: 9, 12, 18 and 24 point. No real error checking or anything, 8 | # this just powers through all the combinations, calling the fontconvert 9 | # utility and redirecting the output to a .h file for each combo. 10 | 11 | # Adafruit_GFX repository does not include the source outline fonts 12 | # (huge zipfile, different license) but they're easily acquired: 13 | # http://savannah.gnu.org/projects/freefont/ 14 | 15 | convert=./fontconvert 16 | inpath=~/Desktop/freefont/ 17 | outpath=../Fonts/ 18 | fonts=(FreeMono FreeSans FreeSerif) 19 | styles=("" Bold Italic BoldItalic Oblique BoldOblique) 20 | sizes=(9 12 18 24) 21 | 22 | for f in ${fonts[*]} 23 | do 24 | for index in ${!styles[*]} 25 | do 26 | st=${styles[$index]} 27 | for si in ${sizes[*]} 28 | do 29 | infile=$inpath$f$st".ttf" 30 | if [ -f $infile ] # Does source combination exist? 31 | then 32 | outfile=$outpath$f$st$si"pt7b.h" 33 | # printf "%s %s %s > %s\n" $convert $infile $si $outfile 34 | $convert $infile $si > $outfile 35 | fi 36 | done 37 | done 38 | done 39 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/Adafruit_GFX_Library/gfxfont.h: -------------------------------------------------------------------------------- 1 | // Font structures for newer Adafruit_GFX (1.1 and later). 2 | // Example fonts are included in 'Fonts' directory. 3 | // To use a font in your Arduino sketch, #include the corresponding .h 4 | // file and pass address of GFXfont struct to setFont(). Pass NULL to 5 | // revert to 'classic' fixed-space bitmap font. 6 | 7 | #ifndef _GFXFONT_H_ 8 | #define _GFXFONT_H_ 9 | 10 | /// Font data stored PER GLYPH 11 | typedef struct { 12 | uint16_t bitmapOffset; ///< Pointer into GFXfont->bitmap 13 | uint8_t width; ///< Bitmap dimensions in pixels 14 | uint8_t height; ///< Bitmap dimensions in pixels 15 | uint8_t xAdvance; ///< Distance to advance cursor (x axis) 16 | int8_t xOffset; ///< X dist from cursor pos to UL corner 17 | int8_t yOffset; ///< Y dist from cursor pos to UL corner 18 | } GFXglyph; 19 | 20 | /// Data stored for FONT AS A WHOLE 21 | typedef struct { 22 | uint8_t *bitmap; ///< Glyph bitmaps, concatenated 23 | GFXglyph *glyph; ///< Glyph array 24 | uint8_t first; ///< ASCII extents (first char) 25 | uint8_t last; ///< ASCII extents (last char) 26 | uint8_t yAdvance; ///< Newline distance (y axis) 27 | } GFXfont; 28 | 29 | #endif // _GFXFONT_H_ 30 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/Adafruit_GFX_Library/library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit GFX Library 2 | version=1.3.2 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Adafruit GFX graphics core library, this is the 'core' class that all our other graphics libraries derive from. 6 | paragraph=Install this library in addition to the display library for your hardware. 7 | category=Display 8 | url=https://github.com/adafruit/Adafruit-GFX-Library 9 | architectures=* 10 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/Adafruit_GFX_Library/license.txt: -------------------------------------------------------------------------------- 1 | Software License Agreement (BSD License) 2 | 3 | Copyright (c) 2012 Adafruit Industries. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | - Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | - Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/Adafruit_Unified_Sensor/Adafruit_Sensor.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enzof6/arduino-lmic-for_ESP32/1c74a7bc086abb0005c0eed961a61d6a8ca4d527/ESP32_Heltec_V1_LoRa_Mote/libraries/Adafruit_Unified_Sensor/Adafruit_Sensor.h -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/Adafruit_Unified_Sensor/library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit Unified Sensor 2 | version=1.0.2 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Required for all Adafruit Unified Sensor based libraries. 6 | paragraph=A unified sensor abstraction layer used by many Adafruit sensor libraries. 7 | category=Sensors 8 | url=https://github.com/adafruit/Adafruit_Sensor 9 | architectures=* 10 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/DHT_sensor_library/DHT.h: -------------------------------------------------------------------------------- 1 | /* DHT library 2 | 3 | MIT license 4 | written by Adafruit Industries 5 | */ 6 | #ifndef DHT_H 7 | #define DHT_H 8 | 9 | #if ARDUINO >= 100 10 | #include "Arduino.h" 11 | #else 12 | #include "WProgram.h" 13 | #endif 14 | 15 | 16 | // Uncomment to enable printing out nice debug messages. 17 | //#define DHT_DEBUG 18 | 19 | // Define where debug output will be printed. 20 | #define DEBUG_PRINTER Serial 21 | 22 | // Setup debug printing macros. 23 | #ifdef DHT_DEBUG 24 | #define DEBUG_PRINT(...) { DEBUG_PRINTER.print(__VA_ARGS__); } 25 | #define DEBUG_PRINTLN(...) { DEBUG_PRINTER.println(__VA_ARGS__); } 26 | #else 27 | #define DEBUG_PRINT(...) {} 28 | #define DEBUG_PRINTLN(...) {} 29 | #endif 30 | 31 | // Define types of sensors. 32 | #define DHT11 11 33 | #define DHT22 22 34 | #define DHT21 21 35 | #define AM2301 21 36 | 37 | 38 | class DHT { 39 | public: 40 | DHT(uint8_t pin, uint8_t type, uint8_t count=6); 41 | void begin(void); 42 | float readTemperature(bool S=false, bool force=false); 43 | float convertCtoF(float); 44 | float convertFtoC(float); 45 | float computeHeatIndex(float temperature, float percentHumidity, bool isFahrenheit=true); 46 | float readHumidity(bool force=false); 47 | boolean read(bool force=false); 48 | 49 | private: 50 | uint8_t data[5]; 51 | uint8_t _pin, _type; 52 | #ifdef __AVR 53 | // Use direct GPIO access on an 8-bit AVR so keep track of the port and bitmask 54 | // for the digital pin connected to the DHT. Other platforms will use digitalRead. 55 | uint8_t _bit, _port; 56 | #endif 57 | uint32_t _lastreadtime, _maxcycles; 58 | bool _lastresult; 59 | 60 | uint32_t expectPulse(bool level); 61 | 62 | }; 63 | 64 | class InterruptLock { 65 | public: 66 | InterruptLock() { 67 | noInterrupts(); 68 | } 69 | ~InterruptLock() { 70 | interrupts(); 71 | } 72 | 73 | }; 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/DHT_sensor_library/DHT_U.cpp: -------------------------------------------------------------------------------- 1 | // DHT Temperature & Humidity Unified Sensor Library 2 | // Copyright (c) 2014 Adafruit Industries 3 | // Author: Tony DiCola 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 | #include "DHT_U.h" 23 | 24 | DHT_Unified::DHT_Unified(uint8_t pin, uint8_t type, uint8_t count, int32_t tempSensorId, int32_t humiditySensorId): 25 | _dht(pin, type, count), 26 | _type(type), 27 | _temp(this, tempSensorId), 28 | _humidity(this, humiditySensorId) 29 | {} 30 | 31 | void DHT_Unified::begin() { 32 | _dht.begin(); 33 | } 34 | 35 | void DHT_Unified::setName(sensor_t* sensor) { 36 | switch(_type) { 37 | case DHT11: 38 | strncpy(sensor->name, "DHT11", sizeof(sensor->name) - 1); 39 | break; 40 | case DHT21: 41 | strncpy(sensor->name, "DHT21", sizeof(sensor->name) - 1); 42 | break; 43 | case DHT22: 44 | strncpy(sensor->name, "DHT22", sizeof(sensor->name) - 1); 45 | break; 46 | default: 47 | // TODO: Perhaps this should be an error? However main DHT library doesn't enforce 48 | // restrictions on the sensor type value. Pick a generic name for now. 49 | strncpy(sensor->name, "DHT?", sizeof(sensor->name) - 1); 50 | break; 51 | } 52 | sensor->name[sizeof(sensor->name)- 1] = 0; 53 | } 54 | 55 | void DHT_Unified::setMinDelay(sensor_t* sensor) { 56 | switch(_type) { 57 | case DHT11: 58 | sensor->min_delay = 1000000L; // 1 second (in microseconds) 59 | break; 60 | case DHT21: 61 | sensor->min_delay = 2000000L; // 2 seconds (in microseconds) 62 | break; 63 | case DHT22: 64 | sensor->min_delay = 2000000L; // 2 seconds (in microseconds) 65 | break; 66 | default: 67 | // Default to slowest sample rate in case of unknown type. 68 | sensor->min_delay = 2000000L; // 2 seconds (in microseconds) 69 | break; 70 | } 71 | } 72 | 73 | DHT_Unified::Temperature::Temperature(DHT_Unified* parent, int32_t id): 74 | _parent(parent), 75 | _id(id) 76 | {} 77 | 78 | bool DHT_Unified::Temperature::getEvent(sensors_event_t* event) { 79 | // Clear event definition. 80 | memset(event, 0, sizeof(sensors_event_t)); 81 | // Populate sensor reading values. 82 | event->version = sizeof(sensors_event_t); 83 | event->sensor_id = _id; 84 | event->type = SENSOR_TYPE_AMBIENT_TEMPERATURE; 85 | event->timestamp = millis(); 86 | event->temperature = _parent->_dht.readTemperature(); 87 | 88 | return true; 89 | } 90 | 91 | void DHT_Unified::Temperature::getSensor(sensor_t* sensor) { 92 | // Clear sensor definition. 93 | memset(sensor, 0, sizeof(sensor_t)); 94 | // Set sensor name. 95 | _parent->setName(sensor); 96 | // Set version and ID 97 | sensor->version = DHT_SENSOR_VERSION; 98 | sensor->sensor_id = _id; 99 | // Set type and characteristics. 100 | sensor->type = SENSOR_TYPE_AMBIENT_TEMPERATURE; 101 | _parent->setMinDelay(sensor); 102 | switch (_parent->_type) { 103 | case DHT11: 104 | sensor->max_value = 50.0F; 105 | sensor->min_value = 0.0F; 106 | sensor->resolution = 2.0F; 107 | break; 108 | case DHT21: 109 | sensor->max_value = 80.0F; 110 | sensor->min_value = -40.0F; 111 | sensor->resolution = 0.1F; 112 | break; 113 | case DHT22: 114 | sensor->max_value = 125.0F; 115 | sensor->min_value = -40.0F; 116 | sensor->resolution = 0.1F; 117 | break; 118 | default: 119 | // Unknown type, default to 0. 120 | sensor->max_value = 0.0F; 121 | sensor->min_value = 0.0F; 122 | sensor->resolution = 0.0F; 123 | break; 124 | } 125 | } 126 | 127 | DHT_Unified::Humidity::Humidity(DHT_Unified* parent, int32_t id): 128 | _parent(parent), 129 | _id(id) 130 | {} 131 | 132 | bool DHT_Unified::Humidity::getEvent(sensors_event_t* event) { 133 | // Clear event definition. 134 | memset(event, 0, sizeof(sensors_event_t)); 135 | // Populate sensor reading values. 136 | event->version = sizeof(sensors_event_t); 137 | event->sensor_id = _id; 138 | event->type = SENSOR_TYPE_RELATIVE_HUMIDITY; 139 | event->timestamp = millis(); 140 | event->relative_humidity = _parent->_dht.readHumidity(); 141 | 142 | return true; 143 | } 144 | 145 | void DHT_Unified::Humidity::getSensor(sensor_t* sensor) { 146 | // Clear sensor definition. 147 | memset(sensor, 0, sizeof(sensor_t)); 148 | // Set sensor name. 149 | _parent->setName(sensor); 150 | // Set version and ID 151 | sensor->version = DHT_SENSOR_VERSION; 152 | sensor->sensor_id = _id; 153 | // Set type and characteristics. 154 | sensor->type = SENSOR_TYPE_RELATIVE_HUMIDITY; 155 | _parent->setMinDelay(sensor); 156 | switch (_parent->_type) { 157 | case DHT11: 158 | sensor->max_value = 80.0F; 159 | sensor->min_value = 20.0F; 160 | sensor->resolution = 5.0F; 161 | break; 162 | case DHT21: 163 | sensor->max_value = 100.0F; 164 | sensor->min_value = 0.0F; 165 | sensor->resolution = 0.1F; 166 | break; 167 | case DHT22: 168 | sensor->max_value = 100.0F; 169 | sensor->min_value = 0.0F; 170 | sensor->resolution = 0.1F; 171 | break; 172 | default: 173 | // Unknown type, default to 0. 174 | sensor->max_value = 0.0F; 175 | sensor->min_value = 0.0F; 176 | sensor->resolution = 0.0F; 177 | break; 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/DHT_sensor_library/DHT_U.h: -------------------------------------------------------------------------------- 1 | // DHT Temperature & Humidity Unified Sensor Library 2 | // Copyright (c) 2014 Adafruit Industries 3 | // Author: Tony DiCola 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 | #ifndef DHT_U_H 23 | #define DHT_U_H 24 | 25 | #include 26 | #include 27 | 28 | #define DHT_SENSOR_VERSION 1 29 | 30 | class DHT_Unified { 31 | public: 32 | DHT_Unified(uint8_t pin, uint8_t type, uint8_t count=6, int32_t tempSensorId=-1, int32_t humiditySensorId=-1); 33 | void begin(); 34 | 35 | class Temperature : public Adafruit_Sensor { 36 | public: 37 | Temperature(DHT_Unified* parent, int32_t id); 38 | bool getEvent(sensors_event_t* event); 39 | void getSensor(sensor_t* sensor); 40 | 41 | private: 42 | DHT_Unified* _parent; 43 | int32_t _id; 44 | 45 | }; 46 | 47 | class Humidity : public Adafruit_Sensor { 48 | public: 49 | Humidity(DHT_Unified* parent, int32_t id); 50 | bool getEvent(sensors_event_t* event); 51 | void getSensor(sensor_t* sensor); 52 | 53 | private: 54 | DHT_Unified* _parent; 55 | int32_t _id; 56 | 57 | }; 58 | 59 | Temperature temperature() { 60 | return _temp; 61 | } 62 | 63 | Humidity humidity() { 64 | return _humidity; 65 | } 66 | 67 | private: 68 | DHT _dht; 69 | uint8_t _type; 70 | Temperature _temp; 71 | Humidity _humidity; 72 | 73 | void setName(sensor_t* sensor); 74 | void setMinDelay(sensor_t* sensor); 75 | 76 | }; 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/DHT_sensor_library/README.md: -------------------------------------------------------------------------------- 1 | This is an Arduino library for the DHT series of low cost temperature/humidity sensors. 2 | 3 | Tutorial: https://learn.adafruit.com/dht 4 | 5 | To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder DHT. Check that the DHT folder contains DHT.cpp and DHT.h. Place the DHT library folder your /libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE. 6 | 7 | # Adafruit DHT Humidity & Temperature Unified Sensor Library 8 | 9 | This library also includes an optional class for the 10 | [DHT humidity and temperature sensor](https://learn.adafruit.com/dht/overview) 11 | which is designed to work with the [Adafruit unified sensor library](https://learn.adafruit.com/using-the-adafruit-unified-sensor-driver/introduction). 12 | 13 | You must have the following Arduino libraries installed to use this class: 14 | 15 | - [Adafruit Unified Sensor Library](https://github.com/adafruit/Adafruit_Sensor) 16 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/DHT_sensor_library/examples/DHT_Unified_Sensor/DHT_Unified_Sensor.ino: -------------------------------------------------------------------------------- 1 | // DHT Temperature & Humidity Sensor 2 | // Unified Sensor Library Example 3 | // Written by Tony DiCola for Adafruit Industries 4 | // Released under an MIT license. 5 | 6 | // Depends on the following Arduino libraries: 7 | // - Adafruit Unified Sensor Library: https://github.com/adafruit/Adafruit_Sensor 8 | // - DHT Sensor Library: https://github.com/adafruit/DHT-sensor-library 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #define DHTPIN 2 // Pin which is connected to the DHT sensor. 15 | 16 | // Uncomment the type of sensor in use: 17 | //#define DHTTYPE DHT11 // DHT 11 18 | #define DHTTYPE DHT22 // DHT 22 (AM2302) 19 | //#define DHTTYPE DHT21 // DHT 21 (AM2301) 20 | 21 | // See guide for details on sensor wiring and usage: 22 | // https://learn.adafruit.com/dht/overview 23 | 24 | DHT_Unified dht(DHTPIN, DHTTYPE); 25 | 26 | uint32_t delayMS; 27 | 28 | void setup() { 29 | Serial.begin(9600); 30 | // Initialize device. 31 | dht.begin(); 32 | Serial.println("DHTxx Unified Sensor Example"); 33 | // Print temperature sensor details. 34 | sensor_t sensor; 35 | dht.temperature().getSensor(&sensor); 36 | Serial.println("------------------------------------"); 37 | Serial.println("Temperature"); 38 | Serial.print ("Sensor: "); Serial.println(sensor.name); 39 | Serial.print ("Driver Ver: "); Serial.println(sensor.version); 40 | Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id); 41 | Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println(" *C"); 42 | Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println(" *C"); 43 | Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println(" *C"); 44 | Serial.println("------------------------------------"); 45 | // Print humidity sensor details. 46 | dht.humidity().getSensor(&sensor); 47 | Serial.println("------------------------------------"); 48 | Serial.println("Humidity"); 49 | Serial.print ("Sensor: "); Serial.println(sensor.name); 50 | Serial.print ("Driver Ver: "); Serial.println(sensor.version); 51 | Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id); 52 | Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println("%"); 53 | Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println("%"); 54 | Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println("%"); 55 | Serial.println("------------------------------------"); 56 | // Set delay between sensor readings based on sensor details. 57 | delayMS = sensor.min_delay / 1000; 58 | } 59 | 60 | void loop() { 61 | // Delay between measurements. 62 | delay(delayMS); 63 | // Get temperature event and print its value. 64 | sensors_event_t event; 65 | dht.temperature().getEvent(&event); 66 | if (isnan(event.temperature)) { 67 | Serial.println("Error reading temperature!"); 68 | } 69 | else { 70 | Serial.print("Temperature: "); 71 | Serial.print(event.temperature); 72 | Serial.println(" *C"); 73 | } 74 | // Get humidity event and print its value. 75 | dht.humidity().getEvent(&event); 76 | if (isnan(event.relative_humidity)) { 77 | Serial.println("Error reading humidity!"); 78 | } 79 | else { 80 | Serial.print("Humidity: "); 81 | Serial.print(event.relative_humidity); 82 | Serial.println("%"); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/DHT_sensor_library/examples/DHTtester/DHTtester.ino: -------------------------------------------------------------------------------- 1 | // Example testing sketch for various DHT humidity/temperature sensors 2 | // Written by ladyada, public domain 3 | 4 | #include "DHT.h" 5 | 6 | #define DHTPIN 2 // what digital pin we're connected to 7 | 8 | // Uncomment whatever type you're using! 9 | //#define DHTTYPE DHT11 // DHT 11 10 | #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 11 | //#define DHTTYPE DHT21 // DHT 21 (AM2301) 12 | 13 | // Connect pin 1 (on the left) of the sensor to +5V 14 | // NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1 15 | // to 3.3V instead of 5V! 16 | // Connect pin 2 of the sensor to whatever your DHTPIN is 17 | // Connect pin 4 (on the right) of the sensor to GROUND 18 | // Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor 19 | 20 | // Initialize DHT sensor. 21 | // Note that older versions of this library took an optional third parameter to 22 | // tweak the timings for faster processors. This parameter is no longer needed 23 | // as the current DHT reading algorithm adjusts itself to work on faster procs. 24 | DHT dht(DHTPIN, DHTTYPE); 25 | 26 | void setup() { 27 | Serial.begin(9600); 28 | Serial.println("DHTxx test!"); 29 | 30 | dht.begin(); 31 | } 32 | 33 | void loop() { 34 | // Wait a few seconds between measurements. 35 | delay(2000); 36 | 37 | // Reading temperature or humidity takes about 250 milliseconds! 38 | // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) 39 | float h = dht.readHumidity(); 40 | // Read temperature as Celsius (the default) 41 | float t = dht.readTemperature(); 42 | // Read temperature as Fahrenheit (isFahrenheit = true) 43 | float f = dht.readTemperature(true); 44 | 45 | // Check if any reads failed and exit early (to try again). 46 | if (isnan(h) || isnan(t) || isnan(f)) { 47 | Serial.println("Failed to read from DHT sensor!"); 48 | return; 49 | } 50 | 51 | // Compute heat index in Fahrenheit (the default) 52 | float hif = dht.computeHeatIndex(f, h); 53 | // Compute heat index in Celsius (isFahreheit = false) 54 | float hic = dht.computeHeatIndex(t, h, false); 55 | 56 | Serial.print("Humidity: "); 57 | Serial.print(h); 58 | Serial.print(" %\t"); 59 | Serial.print("Temperature: "); 60 | Serial.print(t); 61 | Serial.print(" *C "); 62 | Serial.print(f); 63 | Serial.print(" *F\t"); 64 | Serial.print("Heat index: "); 65 | Serial.print(hic); 66 | Serial.print(" *C "); 67 | Serial.print(hif); 68 | Serial.println(" *F"); 69 | } 70 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/DHT_sensor_library/keywords.txt: -------------------------------------------------------------------------------- 1 | ########################################### 2 | # Syntax Coloring Map For DHT-sensor-library 3 | ########################################### 4 | 5 | ########################################### 6 | # Datatypes (KEYWORD1) 7 | ########################################### 8 | 9 | DHT KEYWORD1 10 | 11 | ########################################### 12 | # Methods and Functions (KEYWORD2) 13 | ########################################### 14 | 15 | begin KEYWORD2 16 | readTemperature KEYWORD2 17 | convertCtoF KEYWORD2 18 | convertFtoC KEYWORD2 19 | computeHeatIndex KEYWORD2 20 | readHumidity KEYWORD2 21 | read KEYWORD2 22 | 23 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/DHT_sensor_library/library.properties: -------------------------------------------------------------------------------- 1 | name=DHT sensor library 2 | version=1.3.0 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Arduino library for DHT11, DHT22, etc Temp & Humidity Sensors 6 | paragraph=Arduino library for DHT11, DHT22, etc Temp & Humidity Sensors 7 | category=Sensors 8 | url=https://github.com/adafruit/DHT-sensor-library 9 | architectures=* 10 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/HOWTO-ADD-REGION.md: -------------------------------------------------------------------------------- 1 | # Adding a new region to Arduino LMIC 2 | This variant of the Arduino LMIC code supports adding additional regions beyond the eu868 and us915 bands supoprted by the original IBM LMIC 1.6 code. 3 | 4 | This document sketches how to add a new region. 5 | 6 | ## Planning 7 | 8 | ### Determine the region/region category 9 | Compare the target region (in the LoRaWAN regional specification) to the EU868 and US915 regions. There are three possibilities. 10 | 1. the region is like the EU region. There are a limited number of channels (up to 8), and only a small number of channels are used for OTAA join operations. The response masks refer to individual channels, and the JOIN-response can send frequencies of specific channels to be added. 11 | 12 | 2. The region is like the US region. There are many channels (the US has 64) with fixed frequences, and the channel masks refer to subsets of the fixed channels. 13 | 14 | 3. The region is not really like either the EU or US. At the moment, it seems that CN470-510MHz (section 2.6 of LoRaWAN Regional Parameters spec V1.0.2rB) falls into this category. 15 | 16 | Bandplans in categories (1) and (2) are easily supported. Bandplans in category (3) are not supoprted by the current code. 17 | 18 | ### Check whether the region is already listed in `lmic_config_preconditions.h` 19 | Check `src/lmic/lmic_config_preconditions.h` and scan the `LMIC_REGION_...` definitions. The numeric values are assigned based on the subchapter in section 2 of the LoRaWAN 1.0.2 Regional Parmaters document. If your symbol is already there, then the first part of adaptation has already been done. There will already be a corresponding `CFG_...` symbol. But if your region isn't supported, you'll need to add it here. 20 | 21 | - `LMIC_REGION_myregion` must be a distinct integer, and must be less than 32 (so as to fit into a bitmask) 22 | 23 | ## Make the appropriate changes in `lmic_config_preconditions.h` 24 | 25 | - `LMIC_REGION_SUPPORTED` is a bit mask of all regions supported by the code. Your new region must appear in this list. 26 | - `CFG_LMIC_REGION_MASK` is a bit mask that, when expanded, returns a bitmask for each defined `CFG_...` variable. You must add your `CFG_myregion` symbol to this list. 27 | - `CFG_region` evaluates to the `LMIC_REGION_...` value for the selected region (as long as only one region is selected). The header files check for this, so you don't have to. 28 | - `CFG_LMIC_EU_like_MASK` is a bitmask of regions that are EU-like, and `CFG_LMIC_US_like_MASK` is a bitmask of regions that are US-like. Add your region to the appropriate one of these two variables. 29 | 30 | ## Document your region in `config.h` 31 | You'll see where the regions are listed. Add yours. 32 | 33 | ## Document your region in `README.md` 34 | You'll see where the regions are listed. Add yours. 35 | 36 | ## Add the definitions for your region in `lorabase.h` 37 | - If your region is EU like, copy the EU block. Document any duty-cycle limitations. 38 | - if your region is US like, copy the US block. 39 | - As appropriate, copy `lorabase_eu868.h` or `lorabase_us915.h` to make your own `lorabase_myregion.h`. Fill in the symbols. 40 | 41 | At time of writing, you need to duplicate some code to copy some settings from `..._CONFIG_SYMBOL` to the corresponding `CONFIG_SYMBOL`; and you need to put some region-specific knowledge into the `lorabase.h` header file. The long-term direction is to put all the regional knowledge into the region-specific header, and then the central code will just copy. The architectural impulse is that we'll want to be able to reuse the regional header files in other contexts. On the other hand, because it's error prone, we don't want to `#include` files that aren't being used; otherwise you could accidentally use EU parameters in US code, etc. 42 | 43 | - Now's a good time to test-compile and clean out errors introduced. You'll still have problems compiling, but they should look like this: 44 | ``` 45 | lmic.c:29: In file included from 46 | 47 | lmic_bandplan.h: 52:3: error: #error "maxFrameLen() not defined by bandplan" 48 | # error "maxFrameLen() not defined by bandplan" 49 | 50 | lmic_bandplan.h: 56:3: error: #error "pow2dBm() not defined by bandplan" 51 | # error "pow2dBm() not defined by bandplan" 52 | ``` 53 | 54 | ## Edit `lmic_bandplan.h` 55 | The next step is to add the region-specific interfaces for your region. 56 | 57 | Do this by editing `lmic_bandplan.h` and adding the appropriate call to a (new) region-specific file `lmic_bandplan_myregion.h`, where "myregion" is the abbreviation for your region. 58 | 59 | Then, if your region is eu868-like, copy `lmic_bandplan_eu868.h` to create your new region-specific header file; otherwise copy `lmic_bandplan_us915.h`. 60 | 61 | ## Create `lmic_myregion.c` 62 | Once again, you will start by copying either `lmic_eu868.c` or `lmic_us915.c` to create your new file. Then touch it up as necessary. 63 | 64 | ## General Discussion 65 | - You'll find it easier to do the test compiles using the example scripts in this directory, rather than trying to get all the Catena framework going too. On the other hand, working with the Catena framework will expose more problems. 66 | 67 | ## Addding the region to the Arduino_LoRaWAN library 68 | 69 | In `Arduino_LoRaWAN_ttn.h`: 70 | - Add a new class with name `Arduino_LoRaWAN_ttn_myregion`, copied either from the `Arduino_LoRaWAN_ttn_eu868` class or the `Arduino_LoRaWAN_ttn_us915` class. 71 | - Extend the list of `#if defined(CFG_eu868)` etc to define `Arduino_LoRaWAN_REGION_TAG` to the suffix of your new class if `CFG_myregion` is defined. 72 | 73 | Then copy either `ttn_eu868_netbegin.cpp`/`ttn_eu868_netjoin.cpp` or `ttn_us915_netbegin.cpp`/`ttn_us915_netjoin.cpp` to make your own file(s) for the key functions. -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (C) 2014-2016 IBM Corporation 4 | Copyright (c) 2016-2018 MCCI Corporation 5 | Copyright (c) 2015 Thomas Telkamp and Matthijs Kooijman 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/assets/Feather-M0-LoRa-Wire.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enzof6/arduino-lmic-for_ESP32/1c74a7bc086abb0005c0eed961a61d6a8ca4d527/ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/assets/Feather-M0-LoRa-Wire.ai -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/assets/Feather-M0-LoRa-Wire.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enzof6/arduino-lmic-for_ESP32/1c74a7bc086abb0005c0eed961a61d6a8ca4d527/ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/assets/Feather-M0-LoRa-Wire.png -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/doc/LMiC-v1.6.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enzof6/arduino-lmic-for_ESP32/1c74a7bc086abb0005c0eed961a61d6a8ca4d527/ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/doc/LMiC-v1.6.docx -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/doc/LMiC-v1.6.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enzof6/arduino-lmic-for_ESP32/1c74a7bc086abb0005c0eed961a61d6a8ca4d527/ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/doc/LMiC-v1.6.pdf -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/doc/README.txt: -------------------------------------------------------------------------------- 1 | DISCLAIMER: 2 | Please note that the software is provided AS IS and we cannot 3 | provide support for optimizations, adaptations, integration, 4 | ports to other platforms or device drivers! 5 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/doc/release-notes.txt: -------------------------------------------------------------------------------- 1 | ============================================================================== 2 | LMIC VERSION 1.6 (13-July-2015) 3 | --------------------------------- 4 | 5 | - License changed to BSD 6 | - Modem included, see LMiC-Modem.pdf and examples/modem 7 | - Additional stm32 hardware and Blipper board specific peripheral code 8 | 9 | 10 | ============================================================================== 11 | LMIC VERSION 1.5 (8-May-2015) 12 | ------------------------------ 13 | 14 | - fixed condition in convFreq() 15 | 16 | - fixed freq*100 bug and freq==0 bug for CFList 17 | 18 | - fixed TX scheduling bug 19 | 20 | - better support for GNU compiler toolchain 21 | 22 | 23 | ============================================================================== 24 | LMIC VERSION 1.4 (17-Mar-2015) 25 | ------------------------------- 26 | 27 | - changed API: inverted port indicator flag in LMIC.txrxFlags 28 | (now TXRX_PORT, previously TXRX_NOPORT) 29 | 30 | - fixed offset OFF_CFLIST constant 31 | 32 | - changed CRC-16 algorithm for beacons to CCITT(XMODEM) polynomial 33 | 34 | - fixed radio driver (low data rate optimization for SF11+SF12 only for BW125) 35 | 36 | - fixed timer rollover handling in job queue 37 | 38 | ============================================================================== 39 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/examples/header_test/header_test.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: header_test.ino 4 | 5 | Function: 6 | Simple hello-world (and compile-test) app 7 | 8 | Copyright notice and License: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation April 2018 13 | 14 | */ 15 | 16 | #include 17 | 18 | # define STATIC_ASSERT(e) \ 19 | void STATIC_ASSERT__(int MCCIADK_C_ASSERT_x[(e) ? 1: -1]) 20 | 21 | STATIC_ASSERT(ARDUINO_LMIC_VERSION >= ARDUINO_LMIC_VERSION_CALC(2,1,5,0)); 22 | 23 | STATIC_ASSERT(ARDUINO_LMIC_VERSION_CALC(1,2,3,4) == 0x01020304); 24 | 25 | STATIC_ASSERT(ARDUINO_LMIC_VERSION_GET_MAJOR(ARDUINO_LMIC_VERSION_CALC(1,2,3,4)) == 1); 26 | STATIC_ASSERT(ARDUINO_LMIC_VERSION_GET_MINOR(ARDUINO_LMIC_VERSION_CALC(1,2,3,4)) == 2); 27 | STATIC_ASSERT(ARDUINO_LMIC_VERSION_GET_PATCH(ARDUINO_LMIC_VERSION_CALC(1,2,3,4)) == 3); 28 | STATIC_ASSERT(ARDUINO_LMIC_VERSION_GET_LOCAL(ARDUINO_LMIC_VERSION_CALC(1,2,3,4)) == 4); 29 | 30 | void setup() 31 | { 32 | } 33 | 34 | void loop() 35 | { 36 | } 37 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/examples/raw/raw.ino: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Matthijs Kooijman 3 | * 4 | * Permission is hereby granted, free of charge, to anyone 5 | * obtaining a copy of this document and accompanying files, 6 | * to do whatever they want with them without any restriction, 7 | * including, but not limited to, copying, modification and redistribution. 8 | * NO WARRANTY OF ANY KIND IS PROVIDED. 9 | * 10 | * This example transmits data on hardcoded channel and receives data 11 | * when not transmitting. Running this sketch on two nodes should allow 12 | * them to communicate. 13 | *******************************************************************************/ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #if !defined(DISABLE_INVERT_IQ_ON_RX) 20 | #error This example requires DISABLE_INVERT_IQ_ON_RX to be set. Update \ 21 | config.h in the lmic library to set it. 22 | #endif 23 | 24 | // How often to send a packet. Note that this sketch bypasses the normal 25 | // LMIC duty cycle limiting, so when you change anything in this sketch 26 | // (payload length, frequency, spreading factor), be sure to check if 27 | // this interval should not also be increased. 28 | // See this spreadsheet for an easy airtime and duty cycle calculator: 29 | // https://docs.google.com/spreadsheets/d/1voGAtQAjC1qBmaVuP1ApNKs1ekgUjavHuVQIXyYSvNc 30 | #define TX_INTERVAL 2000 31 | 32 | // Pin mapping 33 | const lmic_pinmap lmic_pins = { 34 | .nss = 6, 35 | .rxtx = LMIC_UNUSED_PIN, 36 | .rst = 5, 37 | .dio = {2, 3, 4}, 38 | }; 39 | 40 | 41 | // These callbacks are only used in over-the-air activation, so they are 42 | // left empty here (we cannot leave them out completely unless 43 | // DISABLE_JOIN is set in config.h, otherwise the linker will complain). 44 | void os_getArtEui (u1_t* buf) { } 45 | void os_getDevEui (u1_t* buf) { } 46 | void os_getDevKey (u1_t* buf) { } 47 | 48 | void onEvent (ev_t ev) { 49 | } 50 | 51 | osjob_t txjob; 52 | osjob_t timeoutjob; 53 | static void tx_func (osjob_t* job); 54 | 55 | // Transmit the given string and call the given function afterwards 56 | void tx(const char *str, osjobcb_t func) { 57 | os_radio(RADIO_RST); // Stop RX first 58 | delay(1); // Wait a bit, without this os_radio below asserts, apparently because the state hasn't changed yet 59 | LMIC.dataLen = 0; 60 | while (*str) 61 | LMIC.frame[LMIC.dataLen++] = *str++; 62 | LMIC.osjob.func = func; 63 | os_radio(RADIO_TX); 64 | Serial.println("TX"); 65 | } 66 | 67 | // Enable rx mode and call func when a packet is received 68 | void rx(osjobcb_t func) { 69 | LMIC.osjob.func = func; 70 | LMIC.rxtime = os_getTime(); // RX _now_ 71 | // Enable "continuous" RX (e.g. without a timeout, still stops after 72 | // receiving a packet) 73 | os_radio(RADIO_RXON); 74 | Serial.println("RX"); 75 | } 76 | 77 | static void rxtimeout_func(osjob_t *job) { 78 | digitalWrite(LED_BUILTIN, LOW); // off 79 | } 80 | 81 | static void rx_func (osjob_t* job) { 82 | // Blink once to confirm reception and then keep the led on 83 | digitalWrite(LED_BUILTIN, LOW); // off 84 | delay(10); 85 | digitalWrite(LED_BUILTIN, HIGH); // on 86 | 87 | // Timeout RX (i.e. update led status) after 3 periods without RX 88 | os_setTimedCallback(&timeoutjob, os_getTime() + ms2osticks(3*TX_INTERVAL), rxtimeout_func); 89 | 90 | // Reschedule TX so that it should not collide with the other side's 91 | // next TX 92 | os_setTimedCallback(&txjob, os_getTime() + ms2osticks(TX_INTERVAL/2), tx_func); 93 | 94 | Serial.print("Got "); 95 | Serial.print(LMIC.dataLen); 96 | Serial.println(" bytes"); 97 | Serial.write(LMIC.frame, LMIC.dataLen); 98 | Serial.println(); 99 | 100 | // Restart RX 101 | rx(rx_func); 102 | } 103 | 104 | static void txdone_func (osjob_t* job) { 105 | rx(rx_func); 106 | } 107 | 108 | // log text to USART and toggle LED 109 | static void tx_func (osjob_t* job) { 110 | // say hello 111 | tx("Hello, world!", txdone_func); 112 | // reschedule job every TX_INTERVAL (plus a bit of random to prevent 113 | // systematic collisions), unless packets are received, then rx_func 114 | // will reschedule at half this time. 115 | os_setTimedCallback(job, os_getTime() + ms2osticks(TX_INTERVAL + random(500)), tx_func); 116 | } 117 | 118 | // application entry point 119 | void setup() { 120 | Serial.begin(115200); 121 | Serial.println("Starting"); 122 | #ifdef VCC_ENABLE 123 | // For Pinoccio Scout boards 124 | pinMode(VCC_ENABLE, OUTPUT); 125 | digitalWrite(VCC_ENABLE, HIGH); 126 | delay(1000); 127 | #endif 128 | 129 | pinMode(LED_BUILTIN, OUTPUT); 130 | 131 | // initialize runtime env 132 | os_init(); 133 | 134 | // Set up these settings once, and use them for both TX and RX 135 | 136 | #if defined(CFG_eu868) 137 | // Use a frequency in the g3 which allows 10% duty cycling. 138 | LMIC.freq = 869525000; 139 | #elif defined(CFG_us915) 140 | LMIC.freq = 902300000; 141 | #endif 142 | 143 | // Maximum TX power 144 | LMIC.txpow = 27; 145 | // Use a medium spread factor. This can be increased up to SF12 for 146 | // better range, but then the interval should be (significantly) 147 | // lowered to comply with duty cycle limits as well. 148 | LMIC.datarate = DR_SF9; 149 | // This sets CR 4/5, BW125 (except for DR_SF7B, which uses BW250) 150 | LMIC.rps = updr2rps(LMIC.datarate); 151 | 152 | Serial.println("Started"); 153 | Serial.flush(); 154 | 155 | // setup initial job 156 | os_setCallback(&txjob, tx_func); 157 | } 158 | 159 | void loop() { 160 | // execute scheduled jobs and events 161 | os_runloop_once(); 162 | } 163 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/examples/ttn-otaa/ttn-otaa.ino: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Thomas Telkamp and Matthijs Kooijman 3 | * Copyright (c) 2018 Terry Moore, MCCI 4 | * 5 | * Permission is hereby granted, free of charge, to anyone 6 | * obtaining a copy of this document and accompanying files, 7 | * to do whatever they want with them without any restriction, 8 | * including, but not limited to, copying, modification and redistribution. 9 | * NO WARRANTY OF ANY KIND IS PROVIDED. 10 | * 11 | * This example sends a valid LoRaWAN packet with payload "Hello, 12 | * world!", using frequency and encryption settings matching those of 13 | * the The Things Network. 14 | * 15 | * This uses OTAA (Over-the-air activation), where where a DevEUI and 16 | * application key is configured, which are used in an over-the-air 17 | * activation procedure where a DevAddr and session keys are 18 | * assigned/generated for use with all further communication. 19 | * 20 | * Note: LoRaWAN per sub-band duty-cycle limitation is enforced (1% in 21 | * g1, 0.1% in g2), but not the TTN fair usage policy (which is probably 22 | * violated by this sketch when left running for longer)! 23 | 24 | * To use this sketch, first register your application and device with 25 | * the things network, to set or generate an AppEUI, DevEUI and AppKey. 26 | * Multiple devices can use the same AppEUI, but each device has its own 27 | * DevEUI and AppKey. 28 | * 29 | * Do not forget to define the radio type correctly in config.h. 30 | * 31 | *******************************************************************************/ 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | // 38 | // For normal use, we require that you edit the sketch to replace FILLMEIN 39 | // with values assigned by the TTN console. However, for regression tests, 40 | // we want to be able to compile these scripts. The regression tests define 41 | // COMPILE_REGRESSION_TEST, and in that case we define FILLMEIN to a non- 42 | // working but innocuous value. 43 | // 44 | #ifdef COMPILE_REGRESSION_TEST 45 | # define FILLMEIN 0 46 | #else 47 | # warning "You must replace the values marked FILLMEIN with real values from the TTN control panel!" 48 | # define FILLMEIN (#dont edit this, edit the lines that use FILLMEIN) 49 | #endif 50 | 51 | // This EUI must be in little-endian format, so least-significant-byte 52 | // first. When copying an EUI from ttnctl output, this means to reverse 53 | // the bytes. For TTN issued EUIs the last bytes should be 0xD5, 0xB3, 54 | // 0x70. 55 | static const u1_t PROGMEM APPEUI[8]={ FILLMEIN }; 56 | void os_getArtEui (u1_t* buf) { memcpy_P(buf, APPEUI, 8);} 57 | 58 | // This should also be in little endian format, see above. 59 | static const u1_t PROGMEM DEVEUI[8]={ FILLMEIN }; 60 | void os_getDevEui (u1_t* buf) { memcpy_P(buf, DEVEUI, 8);} 61 | 62 | // This key should be in big endian format (or, since it is not really a 63 | // number but a block of memory, endianness does not really apply). In 64 | // practice, a key taken from ttnctl can be copied as-is. 65 | static const u1_t PROGMEM APPKEY[16] = { FILLMEIN }; 66 | void os_getDevKey (u1_t* buf) { memcpy_P(buf, APPKEY, 16);} 67 | 68 | static uint8_t mydata[] = "Hello, world!"; 69 | static osjob_t sendjob; 70 | 71 | // Schedule TX every this many seconds (might become longer due to duty 72 | // cycle limitations). 73 | const unsigned TX_INTERVAL = 60; 74 | 75 | // Pin mapping 76 | const lmic_pinmap lmic_pins = { 77 | .nss = 6, 78 | .rxtx = LMIC_UNUSED_PIN, 79 | .rst = 5, 80 | .dio = {2, 3, 4}, 81 | }; 82 | 83 | void onEvent (ev_t ev) { 84 | Serial.print(os_getTime()); 85 | Serial.print(": "); 86 | switch(ev) { 87 | case EV_SCAN_TIMEOUT: 88 | Serial.println(F("EV_SCAN_TIMEOUT")); 89 | break; 90 | case EV_BEACON_FOUND: 91 | Serial.println(F("EV_BEACON_FOUND")); 92 | break; 93 | case EV_BEACON_MISSED: 94 | Serial.println(F("EV_BEACON_MISSED")); 95 | break; 96 | case EV_BEACON_TRACKED: 97 | Serial.println(F("EV_BEACON_TRACKED")); 98 | break; 99 | case EV_JOINING: 100 | Serial.println(F("EV_JOINING")); 101 | break; 102 | case EV_JOINED: 103 | Serial.println(F("EV_JOINED")); 104 | { 105 | u4_t netid = 0; 106 | devaddr_t devaddr = 0; 107 | u1_t nwkKey[16]; 108 | u1_t artKey[16]; 109 | LMIC_getSessionKeys(&netid, &devaddr, nwkKey, artKey); 110 | Serial.print("netid: "); 111 | Serial.println(netid, DEC); 112 | Serial.print("devaddr: "); 113 | Serial.println(devaddr, HEX); 114 | Serial.print("artKey: "); 115 | for (int i=0; i 5 | sentence=Arduino port of the LMIC (LoraWAN-MAC-in-C) framework provided by IBM. 6 | paragraph=Supports SX1272/SX1276 and HopeRF RFM92/RFM95 tranceivers. Refactored to support multiple bandplans beyond the original two supported by the IBM LMIC code. Various enhancements and bug fixes from MCCI and The Things Network New York. Original IBM URL http://www.research.ibm.com/labs/zurich/ics/lrsc/lmic.html. 7 | category=Communication 8 | url=https://github.com/mcci-catena/arduino-lmic 9 | architectures=* 10 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/project_config/lmic_project_config.h: -------------------------------------------------------------------------------- 1 | // project-specific definitions 2 | #define CFG_eu868 1 3 | //#define CFG_us915 1 4 | //#define CFG_au921 1 5 | //#define CFG_as923 1 6 | //#define LMIC_COUNTRY_CODE LMIC_COUNTRY_CODE_JP /* for as923-JP */ 7 | //#define CFG_in866 1 8 | #define CFG_sx1276_radio 1 9 | //#define LMIC_USE_INTERRUPTS 10 | #define ARDUINO_SAMD_FEATHER_M0 11 | //#define LMIC_DEBUG_LEVEL 0 12 | #define ESP32 -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/src/aes/other.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 Matthijs Kooijman 3 | * 4 | * LICENSE 5 | * 6 | * Permission is hereby granted, free of charge, to anyone 7 | * obtaining a copy of this document and accompanying files, 8 | * to do whatever they want with them without any restriction, 9 | * including, but not limited to, copying, modification and 10 | * redistribution. 11 | * 12 | * NO WARRANTY OF ANY KIND IS PROVIDED. 13 | *******************************************************************************/ 14 | 15 | /* 16 | * The original LMIC AES implementation integrates raw AES encryption 17 | * with CMAC and AES-CTR in a single piece of code. Most other AES 18 | * implementations (only) offer raw single block AES encryption, so this 19 | * file contains an implementation of CMAC and AES-CTR, and offers the 20 | * same API through the os_aes() function as the original AES 21 | * implementation. This file assumes that there is an encryption 22 | * function available with this signature: 23 | * 24 | * extern "C" void lmic_aes_encrypt(u1_t *data, u1_t *key); 25 | * 26 | * That takes a single 16-byte buffer and encrypts it wit the given 27 | * 16-byte key. 28 | */ 29 | 30 | #include "../lmic/oslmic.h" 31 | 32 | #if !defined(USE_ORIGINAL_AES) 33 | 34 | // This should be defined elsewhere 35 | void lmic_aes_encrypt(u1_t *data, u1_t *key); 36 | 37 | // global area for passing parameters (aux, key) and for storing round keys 38 | u4_t AESAUX[16/sizeof(u4_t)]; 39 | u4_t AESKEY[11*16/sizeof(u4_t)]; 40 | 41 | // Shift the given buffer left one bit 42 | static void shift_left(xref2u1_t buf, u1_t len) { 43 | while (len--) { 44 | u1_t next = len ? buf[1] : 0; 45 | 46 | u1_t val = (*buf << 1); 47 | if (next & 0x80) 48 | val |= 1; 49 | *buf++ = val; 50 | } 51 | } 52 | 53 | // Apply RFC4493 CMAC, using AESKEY as the key. If prepend_aux is true, 54 | // AESAUX is prepended to the message. AESAUX is used as working memory 55 | // in any case. The CMAC result is returned in AESAUX as well. 56 | static void os_aes_cmac(xref2u1_t buf, u2_t len, u1_t prepend_aux) { 57 | if (prepend_aux) 58 | lmic_aes_encrypt(AESaux, AESkey); 59 | else 60 | memset (AESaux, 0, 16); 61 | 62 | while (len > 0) { 63 | u1_t need_padding = 0; 64 | for (u1_t i = 0; i < 16; ++i, ++buf, --len) { 65 | if (len == 0) { 66 | // The message is padded with 0x80 and then zeroes. 67 | // Since zeroes are no-op for xor, we can just skip them 68 | // and leave AESAUX unchanged for them. 69 | AESaux[i] ^= 0x80; 70 | need_padding = 1; 71 | break; 72 | } 73 | AESaux[i] ^= *buf; 74 | } 75 | 76 | if (len == 0) { 77 | // Final block, xor with K1 or K2. K1 and K2 are calculated 78 | // by encrypting the all-zeroes block and then applying some 79 | // shifts and xor on that. 80 | u1_t final_key[16]; 81 | memset(final_key, 0, sizeof(final_key)); 82 | lmic_aes_encrypt(final_key, AESkey); 83 | 84 | // Calculate K1 85 | u1_t msb = final_key[0] & 0x80; 86 | shift_left(final_key, sizeof(final_key)); 87 | if (msb) 88 | final_key[sizeof(final_key)-1] ^= 0x87; 89 | 90 | // If the final block was not complete, calculate K2 from K1 91 | if (need_padding) { 92 | msb = final_key[0] & 0x80; 93 | shift_left(final_key, sizeof(final_key)); 94 | if (msb) 95 | final_key[sizeof(final_key)-1] ^= 0x87; 96 | } 97 | 98 | // Xor with K1 or K2 99 | for (u1_t i = 0; i < sizeof(final_key); ++i) 100 | AESaux[i] ^= final_key[i]; 101 | } 102 | 103 | lmic_aes_encrypt(AESaux, AESkey); 104 | } 105 | } 106 | 107 | // Run AES-CTR using the key in AESKEY and using AESAUX as the 108 | // counter block. The last byte of the counter block will be incremented 109 | // for every block. The given buffer will be encrypted in place. 110 | static void os_aes_ctr (xref2u1_t buf, u2_t len) { 111 | u1_t ctr[16]; 112 | while (len) { 113 | // Encrypt the counter block with the selected key 114 | memcpy(ctr, AESaux, sizeof(ctr)); 115 | lmic_aes_encrypt(ctr, AESkey); 116 | 117 | // Xor the payload with the resulting ciphertext 118 | for (u1_t i = 0; i < 16 && len > 0; i++, len--, buf++) 119 | *buf ^= ctr[i]; 120 | 121 | // Increment the block index byte 122 | AESaux[15]++; 123 | } 124 | } 125 | 126 | u4_t os_aes (u1_t mode, xref2u1_t buf, u2_t len) { 127 | switch (mode & ~AES_MICNOAUX) { 128 | case AES_MIC: 129 | os_aes_cmac(buf, len, /* prepend_aux */ !(mode & AES_MICNOAUX)); 130 | return os_rmsbf4(AESaux); 131 | 132 | case AES_ENC: 133 | // TODO: Check / handle when len is not a multiple of 16 134 | for (u1_t i = 0; i < len; i += 16) 135 | lmic_aes_encrypt(buf+i, AESkey); 136 | break; 137 | 138 | case AES_CTR: 139 | os_aes_ctr(buf, len); 140 | break; 141 | } 142 | return 0; 143 | } 144 | 145 | #endif // !defined(USE_ORIGINAL_AES) 146 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/src/hal/hal.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015-2016 Matthijs Kooijman 3 | * Copyright (c) 2016-2018 MCCI Corporation 4 | * 5 | * All rights reserved. This program and the accompanying materials 6 | * are made available under the terms of the Eclipse Public License v1.0 7 | * which accompanies this distribution, and is available at 8 | * http://www.eclipse.org/legal/epl-v10.html 9 | * 10 | * This the HAL to run LMIC on top of the Arduino environment. 11 | *******************************************************************************/ 12 | #ifndef _hal_hal_h_ 13 | #define _hal_hal_h_ 14 | 15 | static const int NUM_DIO = 3; 16 | 17 | // be careful of alignment below. 18 | struct lmic_pinmap { 19 | u1_t nss; // byte 0: pin for select 20 | u1_t rxtx; // byte 1: pin for rx/tx control 21 | u1_t rst; // byte 2: pin for reset 22 | u1_t dio[NUM_DIO]; // bytes 3..5: pins for DIO0, DOI1, DIO2 23 | // true if we must set rxtx for rx_active, false for tx_active 24 | u1_t rxtx_rx_active; // byte 6: polarity of rxtx active 25 | s1_t rssi_cal; // byte 7: cal in dB -- added to RSSI 26 | // measured prior to decision. 27 | // Must include noise guardband! 28 | u4_t spi_freq; // bytes 8..11: SPI freq in Hz. 29 | }; 30 | 31 | // Use this for any unused pins. 32 | const u1_t LMIC_UNUSED_PIN = 0xff; 33 | 34 | // Declared here, to be defined and initialized by the application 35 | // use os_init_ex() if you want not to use a const table. 36 | extern const lmic_pinmap lmic_pins; 37 | 38 | #endif // _hal_hal_h_ 39 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/src/lmic.h: -------------------------------------------------------------------------------- 1 | #ifdef __cplusplus 2 | extern "C"{ 3 | #endif 4 | 5 | #include "lmic/lmic.h" 6 | #include "lmic/lmic_bandplan.h" 7 | #include "lmic/lmic_util.h" 8 | 9 | #ifdef __cplusplus 10 | } 11 | #endif 12 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/src/lmic/config.h: -------------------------------------------------------------------------------- 1 | #ifndef _lmic_config_h_ 2 | #define _lmic_config_h_ 3 | 4 | // In the original LMIC code, these config values were defined on the 5 | // gcc commandline. Since Arduino does not allow easily modifying the 6 | // compiler commandline unless you modify the BSP, you have two choices: 7 | // 8 | // - edit {libraries}/arduino-lmic/project_config/lmic_project_config.h; 9 | // - use a BSP like the MCCI Arduino BSPs, which get the configuration 10 | // from the boards.txt file through a menu option. 11 | // 12 | // You definitely should not edit this file. 13 | 14 | // set up preconditions, and load configuration if needed. 15 | #ifndef _LMIC_CONFIG_PRECONDITIONS_H_ 16 | # include "lmic_config_preconditions.h" 17 | #endif 18 | 19 | // check post-conditions. 20 | 21 | // make sure that we have exactly one target region defined. 22 | #if CFG_LMIC_REGION_MASK == 0 23 | # define CFG_eu868 1 24 | #elif (CFG_LMIC_REGION_MASK & (-CFG_LMIC_REGION_MASK)) != CFG_LMIC_REGION_MASK 25 | # error You can define at most one of CFG_... variables 26 | #elif (CFG_LMIC_REGION_MASK & LMIC_REGIONS_SUPPORTED) == 0 27 | # error The selected CFG_... region is not supported yet. 28 | #endif 29 | 30 | // make sure that LMIC_COUNTRY_CODE is defined. 31 | #ifndef LMIC_COUNTRY_CODE 32 | # define LMIC_COUNTRY_CODE LMIC_COUNTRY_CODE_NONE 33 | #endif 34 | 35 | // if the country code is Japan, then the region must be AS923 36 | #if LMIC_COUNTRY_CODE == LMIC_COUNTRY_CODE_JP && CFG_region != LMIC_REGION_as923 37 | # error "If country code is JP, then region must be AS923" 38 | #endif 39 | 40 | // check for internal consistency 41 | #if !(CFG_LMIC_EU_like || CFG_LMIC_US_like) 42 | # error "Internal error: Neither EU-like nor US-like!" 43 | #endif 44 | 45 | // This is the SX1272/SX1273 radio, which is also used on the HopeRF 46 | // RFM92 boards. 47 | //#define CFG_sx1272_radio 1 48 | // This is the SX1276/SX1277/SX1278/SX1279 radio, which is also used on 49 | // the HopeRF RFM95 boards. 50 | #define CFG_sx1276_radio 1 51 | 52 | // ensure that a radio is defined. 53 | #if ! (defined(CFG_sx1272_radio) || defined(CFG_sx1276_radio)) 54 | # warning Target radio not defined, assuming CFG_sx1276_radio 55 | #define CFG_sx1276_radio 1 56 | #elif defined(CFG_sx1272_radio) && defined(CFG_sx1276_radio) 57 | # error You can define at most one of CFG_sx1272_radio and CF_sx1276_radio 58 | #endif 59 | 60 | // LMIC requires ticks to be 15.5μs - 100 μs long 61 | #ifndef OSTICKS_PER_SEC 62 | // 16 μs per tick 63 | # ifndef US_PER_OSTICK_EXPONENT 64 | # define US_PER_OSTICK_EXPONENT 4 65 | # endif 66 | # define US_PER_OSTICK (1 << US_PER_OSTICK_EXPONENT) 67 | # define OSTICKS_PER_SEC (1000000 / US_PER_OSTICK) 68 | #endif /* OSTICKS_PER_SEC */ 69 | 70 | #if ! (10000 <= OSTICKS_PER_SEC && OSTICKS_PER_SEC < 64516) 71 | # error LMIC requires ticks to be 15.5 us to 100 us long 72 | #endif 73 | 74 | // Change the SPI clock speed if you encounter errors 75 | // communicating with the radio. 76 | // The standard range is 125kHz-8MHz, but some boards can go faster. 77 | #ifndef LMIC_SPI_FREQ 78 | #define LMIC_SPI_FREQ 1E6 79 | #endif 80 | 81 | // Set this to 1 to enable some basic debug output (using printf) about 82 | // RF settings used during transmission and reception. Set to 2 to 83 | // enable more verbose output. Make sure that printf is actually 84 | // configured (e.g. on AVR it is not by default), otherwise using it can 85 | // cause crashing. 86 | #ifndef LMIC_DEBUG_LEVEL 87 | #define LMIC_DEBUG_LEVEL 0 88 | #endif 89 | 90 | // Enable this to allow using printf() to print to the given serial port 91 | // (or any other Print object). This can be easy for debugging. The 92 | // current implementation only works on AVR, though. 93 | //#define LMIC_PRINTF_TO Serial 94 | 95 | // Enable this to use interrupt handler routines listening for RISING signals. 96 | // Otherwise, the library polls digital input lines for changes. 97 | //#define LMIC_USE_INTERRUPTS 98 | 99 | // If DISABLE_LMIC_FAILURE_TO is defined, runtime assertion failures 100 | // silently halt execution. Otherwise, LMIC_FAILURE_TO should be defined 101 | // as the name of an object derived from Print, which will be used for 102 | // displaying runtime assertion failures. If you say nothing in your 103 | // lmic_project_config.h, runtime assertion failures are displayed 104 | // using the Serial object. 105 | #if ! defined(DISABLE_LMIC_FAILURE_TO) && ! defined(LMIC_FAILURE_TO) 106 | #define LMIC_FAILURE_TO Serial 107 | #endif 108 | 109 | // define this in lmic_project_config.h to disable all code related to joining 110 | //#define DISABLE_JOIN 111 | // define this in lmic_project_config.h to disable all code related to ping 112 | //#define DISABLE_PING 113 | // define this in lmic_project_config.h to disable all code related to beacon tracking. 114 | // Requires ping to be disabled too 115 | //#define DISABLE_BEACONS 116 | 117 | // define these in lmic_project_config.h to disable the corresponding MAC commands. 118 | // Class A 119 | //#define DISABLE_MCMD_DCAP_REQ // duty cycle cap 120 | //#define DISABLE_MCMD_DN2P_SET // 2nd DN window param 121 | //#define DISABLE_MCMD_SNCH_REQ // set new channel 122 | // Class B 123 | //#define DISABLE_MCMD_PING_SET // set ping freq, automatically disabled by DISABLE_PING 124 | //#define DISABLE_MCMD_BCNI_ANS // next beacon start, automatically disabled by DISABLE_BEACON 125 | 126 | // In LoRaWAN, a gateway applies I/Q inversion on TX, and nodes do the 127 | // same on RX. This ensures that gateways can talk to nodes and vice 128 | // versa, but gateways will not hear other gateways and nodes will not 129 | // hear other nodes. By defining this macro in lmic_project_config.h, 130 | // this inversion is disabled and this node can hear other nodes. If 131 | // two nodes both have this macro set, they can talk to each other 132 | // (but they can no longer hear gateways). This should probably only 133 | // be used when debugging and/or when talking to the radio directly 134 | // (e.g. like in the "raw" example). 135 | //#define DISABLE_INVERT_IQ_ON_RX 136 | 137 | // This allows choosing between multiple included AES implementations. 138 | // Make sure exactly one of these is uncommented. 139 | // 140 | // This selects the original AES implementation included LMIC. This 141 | // implementation is optimized for speed on 32-bit processors using 142 | // fairly big lookup tables, but it takes up big amounts of flash on the 143 | // AVR architecture. 144 | // #define USE_ORIGINAL_AES 145 | // 146 | // This selects the AES implementation written by Ideetroon for their 147 | // own LoRaWAN library. It also uses lookup tables, but smaller 148 | // byte-oriented ones, making it use a lot less flash space (but it is 149 | // also about twice as slow as the original). 150 | // #define USE_IDEETRON_AES 151 | 152 | #if ! (defined(USE_ORIGINAL_AES) || defined(USE_IDEETRON_AES)) 153 | # define USE_IDEETRON_AES 154 | #endif 155 | 156 | #if defined(USE_ORIGINAL_AES) && defined(USE_IDEETRON_AES) 157 | # error "You may define at most one of USE_ORIGINAL_AES and USE_IDEETRON_AES" 158 | #endif 159 | 160 | // LMIC_DISABLE_DR_LEGACY 161 | // turn off legacy DR_* symbols that vary by bandplan. 162 | // Older code uses these for configuration. EU868_DR_*, US915_DR_* 163 | // etc symbols are prefered, but breaking older code is inconvenient for 164 | // everybody. We don't want to use DR_* in the LMIC itself, so we provide 165 | // this #define to allow them to be removed. 166 | #if !defined(LMIC_DR_LEGACY) 167 | # if !defined(LMIC_DISABLE_DR_LEGACY) 168 | # define LMIC_DR_LEGACY 1 169 | # else // defined(LMIC_DISABLE_DR_LEGACY) 170 | # define LMIC_DR_LEGACY 0 171 | # endif // defined(LMIC_DISABLE_DR_LEGACY) 172 | #endif // LMIC_DR_LEGACY 173 | 174 | #endif // _lmic_config_h_ 175 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/src/lmic/hal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2016 IBM Corporation. 3 | * Copyright (c) 2016, 2018 MCCI Corporation. 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 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * 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 | * * Neither the name of the 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 AND CONTRIBUTORS "AS IS" AND 18 | * ANY 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 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 | */ 28 | 29 | #ifndef _hal_hpp_ 30 | #define _hal_hpp_ 31 | 32 | #ifdef __cplusplus 33 | extern "C"{ 34 | #endif 35 | 36 | /* 37 | * initialize hardware (IO, SPI, TIMER, IRQ). 38 | */ 39 | void hal_init (void); 40 | 41 | /* 42 | * initialize hardware, passing in platform-specific context 43 | */ 44 | void hal_init_ex (const void *pContext); 45 | 46 | /* 47 | * drive radio NSS pin (0=low, 1=high). 48 | */ 49 | void hal_pin_nss (u1_t val); 50 | 51 | /* 52 | * drive radio RX/TX pins (0=rx, 1=tx). 53 | */ 54 | void hal_pin_rxtx (u1_t val); 55 | 56 | /* 57 | * control radio RST pin (0=low, 1=high, 2=floating) 58 | */ 59 | void hal_pin_rst (u1_t val); 60 | 61 | /* 62 | * perform 8-bit SPI transaction with radio. 63 | * - write given byte 'outval' 64 | * - read byte and return value 65 | */ 66 | u1_t hal_spi (u1_t outval); 67 | 68 | /* 69 | * disable all CPU interrupts. 70 | * - might be invoked nested 71 | * - will be followed by matching call to hal_enableIRQs() 72 | */ 73 | void hal_disableIRQs (void); 74 | 75 | /* 76 | * enable CPU interrupts. 77 | */ 78 | void hal_enableIRQs (void); 79 | 80 | /* 81 | * put system and CPU in low-power mode, sleep until interrupt. 82 | */ 83 | void hal_sleep (void); 84 | 85 | /* 86 | * return 32-bit system time in ticks. 87 | */ 88 | u4_t hal_ticks (void); 89 | 90 | /* 91 | * busy-wait until specified timestamp (in ticks) is reached. 92 | */ 93 | void hal_waitUntil (u4_t time); 94 | 95 | /* 96 | * check and rewind timer for target time. 97 | * - return 1 if target time is close 98 | * - otherwise rewind timer for target time or full period and return 0 99 | */ 100 | u1_t hal_checkTimer (u4_t targettime); 101 | 102 | /* 103 | * perform fatal failure action. 104 | * - called by assertions 105 | * - action could be HALT or reboot 106 | */ 107 | void hal_failed (const char *file, u2_t line); 108 | 109 | /* 110 | * get the calibration value for radio_rssi 111 | */ 112 | s1_t hal_getRssiCal (void); 113 | 114 | #ifdef __cplusplus 115 | } // extern "C" 116 | #endif 117 | 118 | #endif // _hal_hpp_ 119 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/src/lmic/lmic_au921.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2016 IBM Corporation. 3 | * Copyright (c) 2017 MCCI Corporation. 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 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * 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 | * * Neither the name of the 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 AND CONTRIBUTORS "AS IS" AND 18 | * ANY 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 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 | */ 28 | 29 | #define LMIC_DR_LEGACY 0 30 | 31 | #include "lmic_bandplan.h" 32 | 33 | #if defined(CFG_au921) 34 | // ================================================================================ 35 | // 36 | // BEG: AU921 related stuff 37 | // 38 | 39 | CONST_TABLE(u1_t, _DR2RPS_CRC)[] = { 40 | ILLEGAL_RPS, // [-1] 41 | MAKERPS(SF12, BW125, CR_4_5, 0, 0), // [0] 42 | MAKERPS(SF11, BW125, CR_4_5, 0, 0), // [1] 43 | MAKERPS(SF10, BW125, CR_4_5, 0, 0), // [2] 44 | MAKERPS(SF9 , BW125, CR_4_5, 0, 0), // [3] 45 | MAKERPS(SF8 , BW125, CR_4_5, 0, 0), // [4] 46 | MAKERPS(SF7 , BW125, CR_4_5, 0, 0), // [5] 47 | MAKERPS(SF8 , BW500, CR_4_5, 0, 0), // [6] 48 | ILLEGAL_RPS , // [7] 49 | MAKERPS(SF12, BW500, CR_4_5, 0, 0), // [8] 50 | MAKERPS(SF11, BW500, CR_4_5, 0, 0), // [9] 51 | MAKERPS(SF10, BW500, CR_4_5, 0, 0), // [10] 52 | MAKERPS(SF9 , BW500, CR_4_5, 0, 0), // [11] 53 | MAKERPS(SF8 , BW500, CR_4_5, 0, 0), // [12] 54 | MAKERPS(SF7 , BW500, CR_4_5, 0, 0), // [13] 55 | ILLEGAL_RPS 56 | }; 57 | 58 | static CONST_TABLE(u1_t, maxFrameLens)[] = { 59 | 59+5, 59+5, 59+5, 123+5, 230+5, 230+5, 230+5, 255, 60 | 41+5, 117+5, 230+5, 230+5, 230+5, 230+5 }; 61 | 62 | uint8_t LMICau921_maxFrameLen(uint8_t dr) { 63 | if (dr < LENOF_TABLE(maxFrameLens)) 64 | return TABLE_GET_U1(maxFrameLens, dr); 65 | else 66 | return 0xFF; 67 | } 68 | 69 | static CONST_TABLE(ostime_t, DR2HSYM_osticks)[] = { 70 | us2osticksRound(128 << 7), // DR_SF12 71 | us2osticksRound(128 << 6), // DR_SF11 72 | us2osticksRound(128 << 5), // DR_SF10 73 | us2osticksRound(128 << 4), // DR_SF9 74 | us2osticksRound(128 << 3), // DR_SF8 75 | us2osticksRound(128 << 2), // DR_SF7 76 | us2osticksRound(128 << 1), // DR_SF8C 77 | us2osticksRound(128 << 0), // ------ 78 | us2osticksRound(128 << 5), // DR_SF12CR 79 | us2osticksRound(128 << 4), // DR_SF11CR 80 | us2osticksRound(128 << 3), // DR_SF10CR 81 | us2osticksRound(128 << 2), // DR_SF9CR 82 | us2osticksRound(128 << 1), // DR_SF8CR 83 | us2osticksRound(128 << 0), // DR_SF7CR 84 | }; 85 | 86 | // get ostime for symbols based on datarate. This is not like us915, 87 | // becuase the times don't match between the upper half and lower half 88 | // of the table. 89 | ostime_t LMICau921_dr2hsym(uint8_t dr) { 90 | return TABLE_GET_OSTIME(DR2HSYM_osticks, dr); 91 | } 92 | 93 | 94 | 95 | u4_t LMICau921_convFreq(xref2cu1_t ptr) { 96 | u4_t freq = (os_rlsbf4(ptr - 1) >> 8) * 100; 97 | if (freq < AU921_FREQ_MIN || freq > AU921_FREQ_MAX) 98 | freq = 0; 99 | return freq; 100 | } 101 | 102 | // au921: no support for xchannels. 103 | bit_t LMIC_setupChannel(u1_t chidx, u4_t freq, u2_t drmap, s1_t band) { 104 | return 0; // all channels are hardwired. 105 | } 106 | 107 | void LMIC_disableChannel(u1_t channel) { 108 | if (channel < 72) { 109 | if (ENABLED_CHANNEL(channel)) { 110 | if (IS_CHANNEL_125khz(channel)) 111 | LMIC.activeChannels125khz--; 112 | else if (IS_CHANNEL_500khz(channel)) 113 | LMIC.activeChannels500khz--; 114 | } 115 | LMIC.channelMap[channel >> 4] &= ~(1 << (channel & 0xF)); 116 | } 117 | } 118 | 119 | void LMIC_enableChannel(u1_t channel) { 120 | if (channel < 72) { 121 | if (!ENABLED_CHANNEL(channel)) { 122 | if (IS_CHANNEL_125khz(channel)) 123 | LMIC.activeChannels125khz++; 124 | else if (IS_CHANNEL_500khz(channel)) 125 | LMIC.activeChannels500khz++; 126 | } 127 | LMIC.channelMap[channel >> 4] |= (1 << (channel & 0xF)); 128 | } 129 | } 130 | 131 | void LMIC_enableSubBand(u1_t band) { 132 | ASSERT(band < 8); 133 | u1_t start = band * 8; 134 | u1_t end = start + 8; 135 | 136 | // enable all eight 125 kHz channels in this subband 137 | for (int channel = start; channel < end; ++channel) 138 | LMIC_enableChannel(channel); 139 | 140 | // there's a single 500 kHz channel associated with 141 | // each group of 8 125 kHz channels. Enable it, too. 142 | LMIC_enableChannel(64 + band); 143 | } 144 | void LMIC_disableSubBand(u1_t band) { 145 | ASSERT(band < 8); 146 | u1_t start = band * 8; 147 | u1_t end = start + 8; 148 | 149 | // disable all eight 125 kHz channels in this subband 150 | for (int channel = start; channel < end; ++channel) 151 | LMIC_disableChannel(channel); 152 | 153 | // there's a single 500 kHz channel associated with 154 | // each group of 8 125 kHz channels. Disable it, too. 155 | LMIC_disableChannel(64 + band); 156 | } 157 | void LMIC_selectSubBand(u1_t band) { 158 | ASSERT(band < 8); 159 | for (int b = 0; b<8; ++b) { 160 | if (band == b) 161 | LMIC_enableSubBand(b); 162 | else 163 | LMIC_disableSubBand(b); 164 | } 165 | } 166 | 167 | void LMICau921_updateTx(ostime_t txbeg) { 168 | u1_t chnl = LMIC.txChnl; 169 | LMIC.txpow = AU921_TX_EIRP_MAX_DBM; 170 | if (chnl < 64) { 171 | LMIC.freq = AU921_125kHz_UPFBASE + chnl*AU921_125kHz_UPFSTEP; 172 | } else { 173 | ASSERT(chnl < 64 + 8); 174 | LMIC.freq = AU921_500kHz_UPFBASE + (chnl - 64)*AU921_500kHz_UPFSTEP; 175 | } 176 | 177 | // Update global duty cycle stats 178 | if (LMIC.globalDutyRate != 0) { 179 | ostime_t airtime = calcAirTime(LMIC.rps, LMIC.dataLen); 180 | LMIC.globalDutyAvail = txbeg + (airtime << LMIC.globalDutyRate); 181 | } 182 | } 183 | 184 | #if !defined(DISABLE_BEACONS) 185 | void LMICau921_setBcnRxParams(void) { 186 | LMIC.dataLen = 0; 187 | LMIC.freq = AU921_500kHz_DNFBASE + LMIC.bcnChnl * AU921_500kHz_DNFSTEP; 188 | LMIC.rps = setIh(setNocrc(dndr2rps((dr_t)DR_BCN), 1), LEN_BCN); 189 | } 190 | #endif // !DISABLE_BEACONS 191 | 192 | // set the Rx1 dndr, rps. 193 | void LMICau921_setRx1Params(void) { 194 | u1_t const txdr = LMIC.dndr; 195 | u1_t candidateDr; 196 | LMIC.freq = AU921_500kHz_DNFBASE + (LMIC.txChnl & 0x7) * AU921_500kHz_DNFSTEP; 197 | if ( /* TX datarate */txdr < AU921_DR_SF8C) 198 | candidateDr = txdr + 8 - LMIC.rx1DrOffset; 199 | else 200 | candidateDr = AU921_DR_SF7CR; 201 | 202 | if (candidateDr < LORAWAN_DR8) 203 | candidateDr = LORAWAN_DR8; 204 | else if (candidateDr > LORAWAN_DR13) 205 | candidateDr = LORAWAN_DR13; 206 | 207 | LMIC.dndr = candidateDr; 208 | LMIC.rps = dndr2rps(LMIC.dndr); 209 | } 210 | 211 | 212 | // 213 | // END: AU921 related stuff 214 | // 215 | // ================================================================================ 216 | #endif 217 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/src/lmic/lmic_bandplan.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2016 IBM Corporation. 3 | * Copyright (c) 2017 MCCI Corporation. 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 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * 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 | * * Neither the name of the 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 AND CONTRIBUTORS "AS IS" AND 18 | * ANY 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 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 | */ 28 | 29 | #ifndef _lmic_bandplan_h_ 30 | # define _lmic_bandplan_h_ 31 | 32 | #ifndef _lmic_h_ 33 | # include "lmic.h" 34 | #endif 35 | 36 | #if defined(CFG_eu868) 37 | # include "lmic_bandplan_eu868.h" 38 | #elif defined(CFG_us915) 39 | # include "lmic_bandplan_us915.h" 40 | #elif defined(CFG_au921) 41 | # include "lmic_bandplan_au921.h" 42 | #elif defined(CFG_as923) 43 | # include "lmic_bandplan_as923.h" 44 | #elif defined(CFG_in866) 45 | # include "lmic_bandplan_in866.h" 46 | #else 47 | # error "CFG_... not properly set for bandplan" 48 | #endif 49 | 50 | // check post-conditions 51 | #ifndef DNW2_SAFETY_ZONE 52 | # error "DNW2_SAFETY_ZONE not defined by bandplan" 53 | #endif 54 | 55 | #ifndef maxFrameLen 56 | # error "maxFrameLen() not defined by bandplan" 57 | #endif 58 | 59 | #ifndef pow2dBm 60 | # error "pow2dBm() not defined by bandplan" 61 | #endif 62 | 63 | #ifndef dr2hsym 64 | # error "dr2hsym() not defined by bandplan" 65 | #endif 66 | 67 | #if !defined(LMICbandplan_isValidBeacon1) && !defined(DISABLE_BEACONS) 68 | # error "LMICbandplan_isValidBeacon1 not defined by bandplan" 69 | #endif 70 | 71 | #if !defined(LMICbandplan_isFSK) 72 | # error "LMICbandplan_isFSK() not defined by bandplan" 73 | #endif 74 | 75 | #if !defined(LMICbandplan_txDoneFSK) 76 | # error "LMICbandplan_txDoneFSK() not defined by bandplan" 77 | #endif 78 | 79 | #if !defined(LMICbandplan_joinAcceptChannelClear) 80 | # error "LMICbandplan_joinAcceptChannelClear() not defined by bandplan" 81 | #endif 82 | 83 | #if !defined(LMICbandplan_getInitialDrJoin) 84 | # error "LMICbandplan_getInitialDrJoin() not defined by bandplan" 85 | #endif 86 | 87 | #if !defined(LMICbandplan_hasJoinCFlist) 88 | # error "LMICbandplan_hasJoinCFlist() not defined by bandplan" 89 | #endif 90 | 91 | #if !defined(LMICbandplan_advanceBeaconChannel) 92 | # error "LMICbandplan_advanceBeaconChannel() not defined by bandplan" 93 | #endif 94 | 95 | #if !defined(LMICbandplan_resetDefaultChannels) 96 | # error "LMICbandplan_resetDefaultChannels() not defined by bandplan" 97 | #endif 98 | 99 | #if !defined(LMICbandplan_setSessionInitDefaultChannels) 100 | # error "LMICbandplan_setSessionInitDefaultChannels() not defined by bandplan" 101 | #endif 102 | 103 | #if !defined(LMICbandplan_setBcnRxParams) 104 | # error "LMICbandplan_setBcnRxParams() not defined by bandplan" 105 | #endif 106 | 107 | #if !defined(LMICbandplan_mapChannels) 108 | # error "LMICbandplan_mapChannels() not defined by bandplan" 109 | #endif 110 | 111 | #if !defined(LMICbandplan_convFreq) 112 | # error "LMICbandplan_convFreq() not defined by bandplan" 113 | #endif 114 | 115 | #if !defined(LMICbandplan_setRx1Params) 116 | # error "LMICbandplan_setRx1Params() not defined by bandplan" 117 | #endif 118 | 119 | #if !defined(LMICbandplan_initJoinLoop) 120 | # error "LMICbandplan_initJoinLoop() not defined by bandplan" 121 | #endif 122 | 123 | #if !defined(LMICbandplan_nextTx) 124 | # error "LMICbandplan_nextTx() not defined by bandplan" 125 | #endif 126 | 127 | #if !defined(LMICbandplan_updateTx) 128 | # error "LMICbandplan_updateTx() not defined by bandplan" 129 | #endif 130 | 131 | #if !defined(LMICbandplan_nextJoinState) 132 | # error "LMICbandplan_nextJoinState() not defined by bandplan" 133 | #endif 134 | 135 | #if !defined(LMICbandplan_initDefaultChannels) 136 | # error "LMICbandplan_initDefaultChannels() not defined by bandplan" 137 | #endif 138 | 139 | #if !defined(LMICbandplan_nextJoinTime) 140 | # error "LMICbandplan_nextJoinTime() not defined by bandplan" 141 | #endif 142 | 143 | #if !defined(LMICbandplan_init) 144 | # error "LMICbandplan_init() not defined by bandplan" 145 | #endif 146 | // 147 | // Things common to lmic.c code 148 | // 149 | #if !defined(MINRX_SYMS) 150 | #define MINRX_SYMS 5 151 | #endif // !defined(MINRX_SYMS) 152 | #define PAMBL_SYMS 8 153 | #define PAMBL_FSK 5 154 | #define PRERX_FSK 1 155 | #define RXLEN_FSK (1+5+2) 156 | 157 | #define BCN_INTV_osticks sec2osticks(BCN_INTV_sec) 158 | #define TXRX_GUARD_osticks ms2osticks(TXRX_GUARD_ms) 159 | #define JOIN_GUARD_osticks ms2osticks(JOIN_GUARD_ms) 160 | #define DELAY_JACC1_osticks sec2osticks(DELAY_JACC1) 161 | #define DELAY_JACC2_osticks sec2osticks(DELAY_JACC2) 162 | #define DELAY_EXTDNW2_osticks sec2osticks(DELAY_EXTDNW2) 163 | #define BCN_RESERVE_osticks ms2osticks(BCN_RESERVE_ms) 164 | #define BCN_GUARD_osticks ms2osticks(BCN_GUARD_ms) 165 | #define BCN_WINDOW_osticks ms2osticks(BCN_WINDOW_ms) 166 | #define AIRTIME_BCN_osticks us2osticks(AIRTIME_BCN) 167 | 168 | // Special APIs - for development or testing 169 | #define isTESTMODE() 0 170 | 171 | // internal APIs 172 | ostime_t LMICcore_rndDelay(u1_t secSpan); 173 | void LMICcore_setDrJoin(u1_t reason, u1_t dr); 174 | 175 | #endif // _lmic_bandplan_h_ 176 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/src/lmic/lmic_bandplan_as923.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2016 IBM Corporation. 3 | * Copyright (c) 2017 MCCI Corporation. 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 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * 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 | * * Neither the name of the 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 AND CONTRIBUTORS "AS IS" AND 18 | * ANY 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 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 | */ 28 | 29 | #ifndef _lmic_as923_h_ 30 | # define _lmic_as923_h_ 31 | 32 | #ifndef _lmic_eu_like_h_ 33 | # include "lmic_eu_like.h" 34 | #endif 35 | 36 | uint8_t LMICas923_maxFrameLen(uint8_t dr); 37 | #define maxFrameLen(dr) LMICas923_maxFrameLen(dr) 38 | 39 | int8_t LMICas923_pow2dBm(uint8_t mcmd_ladr_p1); 40 | #define pow2dBm(mcmd_ladr_p1) LMICas923_pow2dBm(mcmd_ladr_p1) 41 | 42 | // Times for half symbol per DR 43 | // Per DR table to minimize rounding errors 44 | ostime_t LMICas923_dr2hsym(uint8_t dr); 45 | #define dr2hsym(dr) LMICas923_dr2hsym(dr) 46 | 47 | static inline int 48 | LMICas923_isValidBeacon1(const uint8_t *d) { 49 | return os_rlsbf2(&d[OFF_BCN_CRC1]) != os_crc16(d, OFF_BCN_CRC1); 50 | } 51 | 52 | #undef LMICbandplan_isValidBeacon1 53 | #define LMICbandplan_isValidBeacon1(pFrame) LMICas923_isValidBeacon1(pFrame) 54 | 55 | // override default for LMICbandplan_resetDefaultChannels 56 | void 57 | LMICas923_resetDefaultChannels(void); 58 | 59 | #undef LMICbandplan_resetDefaultChannels 60 | #define LMICbandplan_resetDefaultChannels() \ 61 | LMICas923_resetDefaultChannels() 62 | 63 | // override default for LMICbandplan_init 64 | void LMICas923_init(void); 65 | 66 | #undef LMICbandplan_init 67 | #define LMICbandplan_init() \ 68 | LMICas923_init() 69 | 70 | 71 | // override default for LMICbandplan_isFSK() 72 | #undef LMICbandplan_isFSK 73 | #define LMICbandplan_isFSK() (/* TX datarate */LMIC.rxsyms == AS923_DR_FSK) 74 | 75 | // txDone handling for FSK. 76 | void 77 | LMICas923_txDoneFSK(ostime_t delay, osjobcb_t func); 78 | 79 | #define LMICbandplan_txDoneFsk(delay, func) LMICas923_txDoneFSK(delay, func) 80 | 81 | #define LMICbandplan_getInitialDrJoin() (AS923_DR_SF10) 82 | 83 | void LMICas923_setBcnRxParams(void); 84 | #define LMICbandplan_setBcnRxParams() LMICas923_setBcnRxParams() 85 | 86 | u4_t LMICas923_convFreq(xref2cu1_t ptr); 87 | #define LMICbandplan_convFreq(ptr) LMICas923_convFreq(ptr) 88 | 89 | void LMICas923_initJoinLoop(void); 90 | #define LMICbandplan_initJoinLoop() LMICas923_initJoinLoop() 91 | 92 | // for as923, depending on dwell, we may need to do something else 93 | #undef LMICbandplan_setRx1Params 94 | void LMICas923_setRx1Params(void); 95 | #define LMICbandplan_setRx1Params() LMICas923_setRx1Params() 96 | 97 | ostime_t LMICas923_nextTx(ostime_t now); 98 | #define LMICbandplan_nextTx(now) LMICas923_nextTx(now) 99 | 100 | ostime_t LMICas923_nextJoinState(void); 101 | #define LMICbandplan_nextJoinState() LMICas923_nextJoinState() 102 | 103 | void LMICas923_initDefaultChannels(bit_t join); 104 | #define LMICbandplan_initDefaultChannels(join) LMICas923_initDefaultChannels(join) 105 | 106 | // override default for LMICbandplan_updateTX 107 | #undef LMICbandplan_updateTx 108 | void LMICas923_updateTx(ostime_t txbeg); 109 | #define LMICbandplan_updateTx(txbeg) LMICas923_updateTx(txbeg) 110 | 111 | #undef LMICbandplan_nextJoinTime 112 | ostime_t LMICas923_nextJoinTime(ostime_t now); 113 | #define LMICbandplan_nextJoinTime(now) LMICas923_nextJoinTime(now) 114 | 115 | #endif // _lmic_as923_h_ 116 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/src/lmic/lmic_bandplan_au921.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2016 IBM Corporation. 3 | * Copyright (c) 2017 MCCI Corporation. 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 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * 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 | * * Neither the name of the 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 AND CONTRIBUTORS "AS IS" AND 18 | * ANY 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 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 | */ 28 | 29 | #ifndef _lmic_au921_h_ 30 | # define _lmic_au921_h_ 31 | 32 | // preconditions for lmic_us_like.h 33 | #define LMICuslike_getFirst500kHzDR() (AU921_DR_SF8C) 34 | 35 | 36 | #ifndef _lmic_us_like_h_ 37 | # include "lmic_us_like.h" 38 | #endif 39 | 40 | uint8_t LMICau921_maxFrameLen(uint8_t dr); 41 | #define maxFrameLen(dr) LMICau921_maxFrameLen(dr) 42 | 43 | #define pow2dBm(mcmd_ladr_p1) ((s1_t)(30 - (((mcmd_ladr_p1)&MCMD_LADR_POW_MASK)<<1))) 44 | 45 | ostime_t LMICau921_dr2hsym(uint8_t dr); 46 | #define dr2hsym(dr) LMICau921_dr2hsym(dr) 47 | 48 | 49 | #define LMICbandplan_getInitialDrJoin() (EU868_DR_SF7) 50 | 51 | void LMICau921_setBcnRxParams(void); 52 | #define LMICbandplan_setBcnRxParams() LMICau921_setBcnRxParams() 53 | 54 | u4_t LMICau921_convFreq(xref2cu1_t ptr); 55 | #define LMICbandplan_convFreq(ptr) LMICau921_convFreq(ptr) 56 | 57 | void LMICau921_setRx1Params(void); 58 | #define LMICbandplan_setRx1Params() LMICau921_setRx1Params() 59 | 60 | void LMICau921_updateTx(ostime_t txbeg); 61 | #define LMICbandplan_updateTx(txbeg) LMICau921_updateTx(txbeg) 62 | 63 | #endif // _lmic_au921_h_ 64 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/src/lmic/lmic_bandplan_eu868.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2016 IBM Corporation. 3 | * Copyright (c) 2017 MCCI Corporation. 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 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * 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 | * * Neither the name of the 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 AND CONTRIBUTORS "AS IS" AND 18 | * ANY 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 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 | */ 28 | 29 | #ifndef _lmic_eu868_h_ 30 | # define _lmic_eu868_h_ 31 | 32 | #ifndef _lmic_eu_like_h_ 33 | # include "lmic_eu_like.h" 34 | #endif 35 | 36 | uint8_t LMICeu868_maxFrameLen(uint8_t dr); 37 | #define maxFrameLen(dr) LMICeu868_maxFrameLen(dr) 38 | 39 | int8_t LMICeu868_pow2dBm(uint8_t mcmd_ladr_p1); 40 | #define pow2dBm(mcmd_ladr_p1) LMICeu868_pow2dBm(mcmd_ladr_p1) 41 | 42 | // Times for half symbol per DR 43 | // Per DR table to minimize rounding errors 44 | ostime_t LMICeu868_dr2hsym(uint8_t dr); 45 | #define dr2hsym(dr) LMICeu868_dr2hsym(dr) 46 | 47 | 48 | // TODO(tmm@mcci.com) this looks bogus compared to current 1.02 regional 49 | // spec. https://github.com/mcci-catena/arduino-lmic/issues/18 50 | static inline int 51 | LMICeu868_isValidBeacon1(const uint8_t *d) { 52 | return d[OFF_BCN_CRC1] != (u1_t)os_crc16(d, OFF_BCN_CRC1); 53 | } 54 | 55 | #undef LMICbandplan_isValidBeacon1 56 | #define LMICbandplan_isValidBeacon1(pFrame) LMICeu868_isValidBeacon1(pFrame) 57 | 58 | // override default for LMICbandplan_isFSK() 59 | #undef LMICbandplan_isFSK 60 | #define LMICbandplan_isFSK() (/* TX datarate */LMIC.rxsyms == EU868_DR_FSK) 61 | 62 | // txDone handling for FSK. 63 | void 64 | LMICeu868_txDoneFSK(ostime_t delay, osjobcb_t func); 65 | 66 | #define LMICbandplan_txDoneFsk(delay, func) LMICeu868_txDoneFSK(delay, func) 67 | 68 | #define LMICbandplan_getInitialDrJoin() (EU868_DR_SF7) 69 | 70 | void LMICeu868_setBcnRxParams(void); 71 | #define LMICbandplan_setBcnRxParams() LMICeu868_setBcnRxParams() 72 | 73 | u4_t LMICeu868_convFreq(xref2cu1_t ptr); 74 | #define LMICbandplan_convFreq(ptr) LMICeu868_convFreq(ptr) 75 | 76 | void LMICeu868_initJoinLoop(void); 77 | #define LMICbandplan_initJoinLoop() LMICeu868_initJoinLoop() 78 | 79 | ostime_t LMICeu868_nextTx(ostime_t now); 80 | #define LMICbandplan_nextTx(now) LMICeu868_nextTx(now) 81 | 82 | ostime_t LMICeu868_nextJoinState(void); 83 | #define LMICbandplan_nextJoinState() LMICeu868_nextJoinState() 84 | 85 | void LMICeu868_initDefaultChannels(bit_t join); 86 | #define LMICbandplan_initDefaultChannels(join) LMICeu868_initDefaultChannels(join) 87 | 88 | #undef LMICbandplan_nextJoinTime 89 | ostime_t LMICeu868_nextJoinTime(ostime_t now); 90 | #define LMICbandplan_nextJoinTime(now) LMICeu868_nextJoinTime(now) 91 | 92 | #endif // _lmic_eu868_h_ 93 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/src/lmic/lmic_bandplan_in866.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2016 IBM Corporation. 3 | * Copyright (c) 2017 MCCI Corporation. 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 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * 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 | * * Neither the name of the 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 AND CONTRIBUTORS "AS IS" AND 18 | * ANY 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 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 | */ 28 | 29 | #ifndef _lmic_in866_h_ 30 | # define _lmic_in866_h_ 31 | 32 | #ifndef _lmic_eu_like_h_ 33 | # include "lmic_eu_like.h" 34 | #endif 35 | 36 | uint8_t LMICin866_maxFrameLen(uint8_t dr); 37 | #define maxFrameLen(dr) LMICin866_maxFrameLen(dr) 38 | 39 | int8_t LMICin866_pow2dBm(uint8_t mcmd_ladr_p1); 40 | #define pow2dBm(mcmd_ladr_p1) LMICin866_pow2dBm(mcmd_ladr_p1) 41 | 42 | // Times for half symbol per DR 43 | // Per DR table to minimize rounding errors 44 | ostime_t LMICin866_dr2hsym(uint8_t dr); 45 | #define dr2hsym(dr) LMICin866_dr2hsym(dr) 46 | 47 | static inline int 48 | LMICin866_isValidBeacon1(const uint8_t *d) { 49 | return os_rlsbf2(&d[OFF_BCN_CRC1]) != os_crc16(d, OFF_BCN_CRC1); 50 | } 51 | 52 | #undef LMICbandplan_isValidBeacon1 53 | #define LMICbandplan_isValidBeacon1(pFrame) LMICin866_isValidBeacon1(pFrame) 54 | 55 | // override default for LMICbandplan_isFSK() 56 | #undef LMICbandplan_isFSK 57 | #define LMICbandplan_isFSK() (/* TX datarate */LMIC.rxsyms == IN866_DR_FSK) 58 | 59 | // txDone handling for FSK. 60 | void 61 | LMICin866_txDoneFSK(ostime_t delay, osjobcb_t func); 62 | 63 | #define LMICbandplan_txDoneFsk(delay, func) LMICin866_txDoneFSK(delay, func) 64 | 65 | #define LMICbandplan_getInitialDrJoin() (IN866_DR_SF7) 66 | 67 | void LMICin866_setBcnRxParams(void); 68 | #define LMICbandplan_setBcnRxParams() LMICin866_setBcnRxParams() 69 | 70 | u4_t LMICin866_convFreq(xref2cu1_t ptr); 71 | #define LMICbandplan_convFreq(ptr) LMICin866_convFreq(ptr) 72 | 73 | void LMICin866_initJoinLoop(void); 74 | #define LMICbandplan_initJoinLoop() LMICin866_initJoinLoop() 75 | 76 | ostime_t LMICin866_nextTx(ostime_t now); 77 | #define LMICbandplan_nextTx(now) LMICin866_nextTx(now) 78 | 79 | ostime_t LMICin866_nextJoinState(void); 80 | #define LMICbandplan_nextJoinState() LMICin866_nextJoinState() 81 | 82 | void LMICin866_initDefaultChannels(bit_t join); 83 | #define LMICbandplan_initDefaultChannels(join) LMICin866_initDefaultChannels(join) 84 | 85 | #endif // _lmic_in866_h_ 86 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/src/lmic/lmic_bandplan_us915.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2016 IBM Corporation. 3 | * Copyright (c) 2017 MCCI Corporation. 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 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * 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 | * * Neither the name of the 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 AND CONTRIBUTORS "AS IS" AND 18 | * ANY 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 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 | */ 28 | 29 | #ifndef _lmic_us915_h_ 30 | # define _lmic_us915_h_ 31 | 32 | // preconditions for lmic_us_like.h 33 | #define LMICuslike_getFirst500kHzDR() (US915_DR_SF8C) 34 | 35 | #ifndef _lmic_us_like_h_ 36 | # include "lmic_us_like.h" 37 | #endif 38 | 39 | uint8_t LMICus915_maxFrameLen(uint8_t dr); 40 | #define maxFrameLen(dr) LMICus915_maxFrameLen(dr) 41 | 42 | #define pow2dBm(mcmd_ladr_p1) ((s1_t)(US915_TX_MAX_DBM - (((mcmd_ladr_p1)&MCMD_LADR_POW_MASK)<<1))) 43 | 44 | ostime_t LMICus915_dr2hsym(uint8_t dr); 45 | #define dr2hsym(dr) LMICus915_dr2hsym(dr) 46 | 47 | 48 | #define LMICbandplan_getInitialDrJoin() (US915_DR_SF7) 49 | 50 | void LMICus915_setBcnRxParams(void); 51 | #define LMICbandplan_setBcnRxParams() LMICus915_setBcnRxParams() 52 | 53 | u4_t LMICus915_convFreq(xref2cu1_t ptr); 54 | #define LMICbandplan_convFreq(ptr) LMICus915_convFreq(ptr) 55 | 56 | void LMICus915_setRx1Params(void); 57 | #define LMICbandplan_setRx1Params() LMICus915_setRx1Params() 58 | 59 | void LMICus915_updateTx(ostime_t txbeg); 60 | #define LMICbandplan_updateTx(txbeg) LMICus915_updateTx(txbeg) 61 | 62 | #endif // _lmic_us915_h_ 63 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/src/lmic/lmic_config_preconditions.h: -------------------------------------------------------------------------------- 1 | /* lmic_config_preconditions.h Fri May 19 2017 23:58:34 tmm */ 2 | 3 | /* 4 | 5 | Module: lmic_config_preconditions.h 6 | 7 | Function: 8 | Preconditions for LMIC configuration. 9 | 10 | Version: 11 | V2.0.0 Sun Aug 06 2017 17:40:44 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | MIT License 21 | 22 | Permission is hereby granted, free of charge, to any person obtaining a copy 23 | of this software and associated documentation files (the "Software"), to deal 24 | in the Software without restriction, including without limitation the rights 25 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 26 | copies of the Software, and to permit persons to whom the Software is 27 | furnished to do so, subject to the following conditions: 28 | 29 | The above copyright notice and this permission notice shall be included in all 30 | copies or substantial portions of the Software. 31 | 32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 33 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 34 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 35 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 36 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 37 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 38 | SOFTWARE. 39 | 40 | Author: 41 | Terry Moore, MCCI Corporation July 2017 42 | 43 | Revision history: 44 | 2.0.0 Sun Aug 06 2017 17:40:44 tmm 45 | Module created. 46 | 47 | */ 48 | 49 | #ifndef _LMIC_CONFIG_PRECONDITIONS_H_ 50 | # define _LMIC_CONFIG_PRECONDITIONS_H_ 51 | 52 | // We need to be able to compile with different options without editing source. 53 | // When building with a more advanced environment, set the following variable: 54 | // ARDUINO_LMIC_PROJECT_CONFIG_H=my_project_config.h 55 | // 56 | // otherwise the lmic_project_config.h from the ../../project_config directory will be used. 57 | #ifndef ARDUINO_LMIC_PROJECT_CONFIG_H 58 | # define ARDUINO_LMIC_PROJECT_CONFIG_H ../../project_config/lmic_project_config.h 59 | #endif 60 | 61 | #define CFG_TEXT_1(x) CFG_TEXT_2(x) 62 | #define CFG_TEXT_2(x) #x 63 | 64 | // constants for comparison 65 | #define LMIC_REGION_eu868 1 66 | #define LMIC_REGION_us915 2 67 | #define LMIC_REGION_cn783 3 68 | #define LMIC_REGION_eu433 4 69 | #define LMIC_REGION_au921 5 70 | #define LMIC_REGION_cn490 6 71 | #define LMIC_REGION_as923 7 72 | #define LMIC_REGION_kr921 8 73 | #define LMIC_REGION_in866 9 74 | 75 | // Some regions have country-specific overrides. For generality, we specify 76 | // country codes using the LMIC_COUNTY_CODE_C() macro These values are chosen 77 | // from the 2-letter domain suffixes standardized by ISO-3166-1 alpha2 (see 78 | // https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). They are therefore 79 | // 16-bit constants. By convention, we use UPPER-CASE letters, thus 80 | // LMIC_COUNTRY_CODE('J', 'P'), not ('j', 'p'). 81 | #define LMIC_COUNTRY_CODE_C(c1, c2) ((c1) * 256 + (c2)) 82 | 83 | // this special code means "no country code defined" 84 | #define LMIC_COUNTRY_CODE_NONE 0 85 | 86 | // specific countries. Only the ones that are needed by the code are defined. 87 | #define LMIC_COUNTRY_CODE_JP LMIC_COUNTRY_CODE_C('J', 'P') 88 | 89 | // include the file that the user is really supposed to edit. But for really strange 90 | // ports, this can be suppressed 91 | #ifndef ARDUINO_LMIC_PROJECT_CONFIG_H_SUPPRESS 92 | # include CFG_TEXT_1(ARDUINO_LMIC_PROJECT_CONFIG_H) 93 | #endif /* ARDUINO_LMIC_PROJECT_CONFIG_H_SUPPRESS */ 94 | 95 | // a mask of the supported regions 96 | // TODO(tmm@mcci.com) consider moving this block to a central file as it's not 97 | // user-editable. 98 | #define LMIC_REGIONS_SUPPORTED ( \ 99 | (1 << LMIC_REGION_eu868) | \ 100 | (1 << LMIC_REGION_us915) | \ 101 | /* (1 << LMIC_REGION_cn783) | */ \ 102 | /* (1 << LMIC_REGION_eu433) | */ \ 103 | (1 << LMIC_REGION_au921) | \ 104 | /* (1 << LMIC_REGION_cn490) | */ \ 105 | (1 << LMIC_REGION_as923) | \ 106 | /* (1 << LMIC_REGION_kr921) | */ \ 107 | (1 << LMIC_REGION_in866) | \ 108 | 0) 109 | 110 | // 111 | // Our input is a -D of one of CFG_eu868, CFG_us915, CFG_as923, CFG_au915, CFG_in866 112 | // More will be added in the the future. So at this point we create CFG_region with 113 | // following values. These are in order of the sections in the manual. Not all of the 114 | // below are supported yet. 115 | // 116 | # define CFG_LMIC_REGION_MASK \ 117 | ((defined(CFG_eu868) << LMIC_REGION_eu868) | \ 118 | (defined(CFG_us915) << LMIC_REGION_us915) | \ 119 | (defined(CFG_cn783) << LMIC_REGION_cn783) | \ 120 | (defined(CFG_eu433) << LMIC_REGION_eu433) | \ 121 | (defined(CFG_au921) << LMIC_REGION_au921) | \ 122 | (defined(CFG_cn490) << LMIC_REGION_cn490) | \ 123 | (defined(CFG_as923) << LMIC_REGION_as923) | \ 124 | (defined(CFG_kr921) << LMIC_REGION_kr921) | \ 125 | (defined(CFG_in866) << LMIC_REGION_in866) | \ 126 | 0) 127 | 128 | // the selected region. 129 | #if defined(CFG_eu868) 130 | # define CFG_region LMIC_REGION_eu868 131 | #elif defined(CFG_us915) 132 | # define CFG_region LMIC_REGION_us915 133 | #elif defined(CFG_cn783) 134 | # define CFG_region LMIC_REGION_cn783 135 | #elif defined(CFG_eu433) 136 | # define CFG_region LMIC_REGION_eu433 137 | #elif defined(CFG_au921) 138 | # define CFG_region LMIC_REGION_au921 139 | #elif defined(CFG_cn490) 140 | # define CFG_region LMIC_REGION_cn490 141 | #elif defined(CFG_as923) 142 | # define CFG_region LMIC_REGION_as923 143 | #elif defined(CFG_kr921) 144 | # define CFG_region LMIC_REGION_kr921 145 | #elif defined(CFG_in866) 146 | # define CFG_region LMIC_REGION_in866 147 | #else 148 | # define CFG_region 0 149 | #endif 150 | 151 | // finally the mask of` US-like and EU-like regions 152 | #define CFG_LMIC_EU_like_MASK ( \ 153 | (1 << LMIC_REGION_eu868) | \ 154 | /* (1 << LMIC_REGION_us915) | */ \ 155 | (1 << LMIC_REGION_cn783) | \ 156 | (1 << LMIC_REGION_eu433) | \ 157 | /* (1 << LMIC_REGION_au921) | */ \ 158 | /* (1 << LMIC_REGION_cn490) | */ \ 159 | (1 << LMIC_REGION_as923) | \ 160 | (1 << LMIC_REGION_kr921) | \ 161 | (1 << LMIC_REGION_in866) | \ 162 | 0) 163 | 164 | #define CFG_LMIC_US_like_MASK ( \ 165 | /* (1 << LMIC_REGION_eu868) | */ \ 166 | (1 << LMIC_REGION_us915) | \ 167 | /* (1 << LMIC_REGION_cn783) | */ \ 168 | /* (1 << LMIC_REGION_eu433) | */ \ 169 | (1 << LMIC_REGION_au921) | \ 170 | /* (1 << LMIC_REGION_cn490) | */ \ 171 | /* (1 << LMIC_REGION_as923) | */ \ 172 | /* (1 << LMIC_REGION_kr921) | */ \ 173 | /* (1 << LMIC_REGION_in866) | */ \ 174 | 0) 175 | 176 | #define CFG_LMIC_EU_like (!!(CFG_LMIC_REGION_MASK & CFG_LMIC_EU_like_MASK)) 177 | #define CFG_LMIC_US_like (!!(CFG_LMIC_REGION_MASK & CFG_LMIC_US_like_MASK)) 178 | 179 | 180 | 181 | #endif /* _LMIC_CONFIG_PRECONDITIONS_H_ */ 182 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/src/lmic/lmic_eu_like.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2016 IBM Corporation. 3 | * Copyright (c) 2017 MCCI Corporation. 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 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * 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 | * * Neither the name of the 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 AND CONTRIBUTORS "AS IS" AND 18 | * ANY 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 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 | */ 28 | 29 | #define LMIC_DR_LEGACY 0 30 | 31 | #include "lmic_bandplan.h" 32 | 33 | #if CFG_LMIC_EU_like 34 | 35 | void LMIC_enableSubBand(u1_t band) { 36 | } 37 | 38 | void LMIC_disableSubBand(u1_t band) { 39 | } 40 | 41 | void LMIC_disableChannel(u1_t channel) { 42 | LMIC.channelFreq[channel] = 0; 43 | LMIC.channelDrMap[channel] = 0; 44 | LMIC.channelMap &= ~(1 << channel); 45 | } 46 | 47 | // this is a no-op provided for compatibilty 48 | void LMIC_enableChannel(u1_t channel) { 49 | } 50 | 51 | u1_t LMICeulike_mapChannels(u1_t chpage, u2_t chmap) { 52 | // Bad page, disable all channel, enable non-existent 53 | if (chpage != 0 || chmap == 0 || (chmap & ~LMIC.channelMap) != 0) 54 | return 0; // illegal input 55 | for (u1_t chnl = 0; chnltxpow; 88 | band->avail = txbeg + airtime * band->txcap; 89 | if (LMIC.globalDutyRate != 0) 90 | LMIC.globalDutyAvail = txbeg + (airtime << LMIC.globalDutyRate); 91 | } 92 | 93 | #if !defined(DISABLE_JOIN) 94 | // 95 | // TODO(tmm@mcci.com): 96 | // 97 | // The definition of this is a little strange. this seems to return a time, but 98 | // in reality it returns 0 if the caller should continue scanning through 99 | // channels, and 1 if the caller has scanned all channels on this session, 100 | // and therefore should reset to the beginning. The IBM 1.6 code is the 101 | // same way, so apparently I just carried this across. We should declare 102 | // as bool_t and change callers to use the result clearly as a flag. 103 | // 104 | ostime_t LMICeulike_nextJoinState(uint8_t nDefaultChannels) { 105 | u1_t failed = 0; 106 | 107 | // Try each default channel with same DR 108 | // If all fail try next lower datarate 109 | if (++LMIC.txChnl == /* NUM_DEFAULT_CHANNELS */ nDefaultChannels) 110 | LMIC.txChnl = 0; 111 | if ((++LMIC.txCnt % nDefaultChannels) == 0) { 112 | // Lower DR every nth try (having all default channels with same DR) 113 | // 114 | // TODO(tmm@mcci.com) add new DR_REGIN_JOIN_MIN instead of LORAWAN_DR0; 115 | // then we can eliminate the LMIC_REGION_as923 below because we'll set 116 | // the failed flag here. This will cause the outer caller to take the 117 | // appropriate join path. Or add new LMICeulike_GetLowestJoinDR() 118 | // 119 | if (LMIC.datarate == LORAWAN_DR0) 120 | failed = 1; // we have tried all DR - signal EV_JOIN_FAILED 121 | else 122 | { 123 | // TODO(tmm@mcci.com) - see above; please remove regional dependency from this file. 124 | #if CFG_region != LMIC_REGION_as923 125 | LMICcore_setDrJoin(DRCHG_NOJACC, decDR((dr_t)LMIC.datarate)); 126 | #else 127 | // in the join of AS923 v1.1 or older, only DR2 is used. 128 | // no need to change the DR. 129 | LMIC.datarate = AS923_DR_SF10; 130 | #endif 131 | } 132 | } 133 | // Clear NEXTCHNL because join state engine controls channel hopping 134 | LMIC.opmode &= ~OP_NEXTCHNL; 135 | // Move txend to randomize synchronized concurrent joins. 136 | // Duty cycle is based on txend. 137 | ostime_t const time = LMICbandplan_nextJoinTime(os_getTime()); 138 | 139 | // TODO(tmm@mcci.com): change delay to (0:1) secs + a known t0, but randomized; 140 | // starting adding a bias after 1 hour, 25 hours, etc.; and limit the duty 141 | // cycle on power up. For testability, add a way to set the join start time 142 | // externally (a test API) so we can check this feature. 143 | // See https://github.com/mcci-catena/arduino-lmic/issues/2 144 | // Current code doesn't match LoRaWAN 1.0.2 requirements. 145 | 146 | LMIC.txend = time + 147 | (isTESTMODE() 148 | // Avoid collision with JOIN ACCEPT @ SF12 being sent by GW (but we missed it) 149 | ? DNW2_SAFETY_ZONE 150 | // Otherwise: randomize join (street lamp case): 151 | // SF12:255, SF11:127, .., SF7:8secs 152 | // 153 | : DNW2_SAFETY_ZONE + LMICcore_rndDelay(255 >> LMIC.datarate)); 154 | // 1 - triggers EV_JOIN_FAILED event 155 | return failed; 156 | } 157 | #endif // !DISABLE_JOIN 158 | 159 | #endif // CFG_LMIC_EU_like 160 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/src/lmic/lmic_eu_like.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2016 IBM Corporation. 3 | * Copyright (c) 2017 MCCI Corporation. 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 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * 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 | * * Neither the name of the 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 AND CONTRIBUTORS "AS IS" AND 18 | * ANY 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 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 | */ 28 | 29 | #ifndef _lmic_eu_like_h_ 30 | # define _lmic_eu_like_h_ 31 | 32 | #ifndef _lmic_h_ 33 | # include "lmic.h" 34 | #endif 35 | 36 | // make sure we want US-like code 37 | #if !CFG_LMIC_EU_like 38 | # error "lmic not configured for EU-like bandplan" 39 | #endif 40 | 41 | // TODO(tmm@mcci.com): this should come from the lmic.h or lorabase.h file; and 42 | // it's probably affected by the fix to this issue: 43 | // https://github.com/mcci-catena/arduino-lmic/issues/2 44 | #define DNW2_SAFETY_ZONE ms2osticks(3000) 45 | 46 | // provide a default for LMICbandplan_isValidBeacon1() 47 | static inline int 48 | LMICeulike_isValidBeacon1(const uint8_t *d) { 49 | return os_rlsbf2(&d[OFF_BCN_CRC1]) != os_crc16(d, OFF_BCN_CRC1); 50 | } 51 | 52 | #define LMICbandplan_isValidBeacon1(pFrame) LMICeulike_isValidBeacon1(pFrame) 53 | 54 | 55 | // provide a default for LMICbandplan_isFSK() 56 | #define LMICbandplan_isFSK() (0) 57 | 58 | // provide a default LMICbandplan_txDoneDoFSK() 59 | #define LMICbandplan_txDoneFSK(delay, func) do { } while (0) 60 | 61 | #define LMICbandplan_joinAcceptChannelClear() LMICbandplan_initDefaultChannels(/* normal, not join */ 0) 62 | 63 | enum { BAND_MILLI = 0, BAND_CENTI = 1, BAND_DECI = 2, BAND_AUX = 3 }; 64 | 65 | // there's a CFList on joins for EU-like plans 66 | #define LMICbandplan_hasJoinCFlist() (1) 67 | 68 | #define LMICbandplan_advanceBeaconChannel() \ 69 | do { /* nothing */ } while (0) 70 | 71 | #define LMICbandplan_resetDefaultChannels() \ 72 | do { /* nothing */ } while (0) 73 | 74 | #define LMICbandplan_setSessionInitDefaultChannels() \ 75 | do { LMICbandplan_initDefaultChannels(/* normal, not join */ 0); } while (0) 76 | 77 | u1_t LMICeulike_mapChannels(u1_t chpage, u2_t chmap); 78 | #define LMICbandplan_mapChannels(c, m) LMICeulike_mapChannels(c, m) 79 | 80 | void LMICeulike_initJoinLoop(u1_t nDefaultChannels, s1_t adrTxPow); 81 | 82 | #define LMICbandplan_setRx1Params() \ 83 | do { /*LMIC.freq/rps remain unchanged*/ } while (0) 84 | 85 | void LMICeulike_updateTx(ostime_t txbeg); 86 | #define LMICbandplan_updateTx(t) LMICeulike_updateTx(t) 87 | 88 | ostime_t LMICeulike_nextJoinState(uint8_t nDefaultChannels); 89 | 90 | static inline ostime_t LMICeulike_nextJoinTime(ostime_t now) { 91 | return now; 92 | } 93 | #define LMICbandplan_nextJoinTime(now) LMICeulike_nextJoinTime(now) 94 | 95 | #define LMICbandplan_init() \ 96 | do { /* nothing */ } while (0) 97 | 98 | #endif // _lmic_eu_like_h_ 99 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/src/lmic/lmic_in866.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2016 IBM Corporation. 3 | * Copyright (c) 2017 MCCI Corporation. 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 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * 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 | * * Neither the name of the 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 AND CONTRIBUTORS "AS IS" AND 18 | * ANY 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 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 | */ 28 | 29 | #define LMIC_DR_LEGACY 0 30 | 31 | #include "lmic_bandplan.h" 32 | 33 | #if defined(CFG_in866) 34 | // ================================================================================ 35 | // 36 | // BEG: IN866 related stuff 37 | // 38 | 39 | CONST_TABLE(u1_t, _DR2RPS_CRC)[] = { 40 | ILLEGAL_RPS, 41 | (u1_t)MAKERPS(SF12, BW125, CR_4_5, 0, 0), // [0] 42 | (u1_t)MAKERPS(SF11, BW125, CR_4_5, 0, 0), // [1] 43 | (u1_t)MAKERPS(SF10, BW125, CR_4_5, 0, 0), // [2] 44 | (u1_t)MAKERPS(SF9, BW125, CR_4_5, 0, 0), // [3] 45 | (u1_t)MAKERPS(SF8, BW125, CR_4_5, 0, 0), // [4] 46 | (u1_t)MAKERPS(SF7, BW125, CR_4_5, 0, 0), // [5] 47 | ILLEGAL_RPS, // [6] 48 | (u1_t)MAKERPS(FSK, BW125, CR_4_5, 0, 0), // [7] 49 | ILLEGAL_RPS 50 | }; 51 | 52 | static CONST_TABLE(u1_t, maxFrameLens)[] = { 59+5,59+5,59+5,123+5, 230+5, 230+5 }; 53 | 54 | uint8_t LMICin866_maxFrameLen(uint8_t dr) { 55 | if (dr < LENOF_TABLE(maxFrameLens)) 56 | return TABLE_GET_U1(maxFrameLens, dr); 57 | else 58 | return 0xFF; 59 | } 60 | 61 | static CONST_TABLE(s1_t, TXPOWLEVELS)[] = { 62 | 20, 14, 11, 8, 5, 2, 0,0, 0,0,0,0, 0,0,0,0 63 | }; 64 | 65 | int8_t LMICin866_pow2dBm(uint8_t mcmd_ladr_p1) { 66 | return TABLE_GET_S1(TXPOWLEVELS, (mcmd_ladr_p1&MCMD_LADR_POW_MASK)>>MCMD_LADR_POW_SHIFT); 67 | } 68 | 69 | // only used in this module, but used by variant macro dr2hsym(). 70 | static CONST_TABLE(ostime_t, DR2HSYM_osticks)[] = { 71 | us2osticksRound(128 << 7), // DR_SF12 72 | us2osticksRound(128 << 6), // DR_SF11 73 | us2osticksRound(128 << 5), // DR_SF10 74 | us2osticksRound(128 << 4), // DR_SF9 75 | us2osticksRound(128 << 3), // DR_SF8 76 | us2osticksRound(128 << 2), // DR_SF7 77 | us2osticksRound(128 << 1), // -- 78 | us2osticksRound(80) // FSK -- not used (time for 1/2 byte) 79 | }; 80 | 81 | ostime_t LMICin866_dr2hsym(uint8_t dr) { 82 | return TABLE_GET_OSTIME(DR2HSYM_osticks, dr); 83 | } 84 | 85 | 86 | // All frequencies are marked as BAND_MILLI, and we don't do duty-cycle. But this lets 87 | // us reuse code. 88 | enum { NUM_DEFAULT_CHANNELS = 3 }; 89 | static CONST_TABLE(u4_t, iniChannelFreq)[NUM_DEFAULT_CHANNELS] = { 90 | // Default operational frequencies 91 | IN866_F1 | BAND_MILLI, 92 | IN866_F2 | BAND_MILLI, 93 | IN866_F3 | BAND_MILLI, 94 | }; 95 | 96 | // india ignores join, becuase the channel setup is the same either way. 97 | void LMICin866_initDefaultChannels(bit_t join) { 98 | os_clearMem(&LMIC.channelFreq, sizeof(LMIC.channelFreq)); 99 | os_clearMem(&LMIC.channelDrMap, sizeof(LMIC.channelDrMap)); 100 | os_clearMem(&LMIC.bands, sizeof(LMIC.bands)); 101 | 102 | LMIC.channelMap = (1 << NUM_DEFAULT_CHANNELS) - 1; 103 | for (u1_t fu = 0; fu BAND_MILLI) return 0; 116 | //band_t* b = &LMIC.bands[bandidx]; 117 | xref2band_t b = &LMIC.bands[bandidx]; 118 | b->txpow = txpow; 119 | b->txcap = txcap; 120 | b->avail = os_getTime(); 121 | b->lastchnl = os_getRndU1() % MAX_CHANNELS; 122 | return 1; 123 | } 124 | 125 | bit_t LMIC_setupChannel(u1_t chidx, u4_t freq, u2_t drmap, s1_t band) { 126 | if (chidx >= MAX_CHANNELS) 127 | return 0; 128 | if (band == -1) { 129 | freq |= BAND_MILLI; 130 | } else { 131 | if (band > BAND_MILLI) return 0; 132 | freq = (freq&~3) | band; 133 | } 134 | LMIC.channelFreq[chidx] = freq; 135 | LMIC.channelDrMap[chidx] = drmap == 0 ? DR_RANGE_MAP(IN866_DR_SF12, IN866_DR_SF7) : drmap; 136 | LMIC.channelMap |= 1 << chidx; // enabled right away 137 | return 1; 138 | } 139 | 140 | 141 | 142 | u4_t LMICin866_convFreq(xref2cu1_t ptr) { 143 | u4_t freq = (os_rlsbf4(ptr - 1) >> 8) * 100; 144 | if (freq < IN866_FREQ_MIN || freq > IN866_FREQ_MAX) 145 | freq = 0; 146 | return freq; 147 | } 148 | 149 | // return the next time, but also do channel hopping here 150 | // since there's no duty cycle limitation, and no dwell limitation, 151 | // we simply loop through the channels sequentially. 152 | ostime_t LMICin866_nextTx(ostime_t now) { 153 | const u1_t band = BAND_MILLI; 154 | 155 | for (u1_t ci = 0; ci < MAX_CHANNELS; ci++) { 156 | // Find next channel in given band 157 | u1_t chnl = LMIC.bands[band].lastchnl; 158 | for (u1_t ci = 0; ci= MAX_CHANNELS) 160 | chnl -= MAX_CHANNELS; 161 | if ((LMIC.channelMap & (1 << chnl)) != 0 && // channel enabled 162 | (LMIC.channelDrMap[chnl] & (1 << (LMIC.datarate & 0xF))) != 0 && 163 | band == (LMIC.channelFreq[chnl] & 0x3)) { // in selected band 164 | LMIC.txChnl = LMIC.bands[band].lastchnl = chnl; 165 | return now; 166 | } 167 | } 168 | } 169 | 170 | // no enabled channel found! just use the last channel. 171 | return now; 172 | } 173 | 174 | #if !defined(DISABLE_BEACONS) 175 | void LMICin866_setBcnRxParams(void) { 176 | LMIC.dataLen = 0; 177 | LMIC.freq = LMIC.channelFreq[LMIC.bcnChnl] & ~(u4_t)3; 178 | LMIC.rps = setIh(setNocrc(dndr2rps((dr_t)DR_BCN), 1), LEN_BCN); 179 | } 180 | #endif // !DISABLE_BEACONS 181 | 182 | #if !defined(DISABLE_JOIN) 183 | ostime_t LMICin866_nextJoinState(void) { 184 | return LMICeulike_nextJoinState(NUM_DEFAULT_CHANNELS); 185 | } 186 | #endif // !DISABLE_JOIN 187 | 188 | // txDone handling for FSK. 189 | void 190 | LMICin866_txDoneFSK(ostime_t delay, osjobcb_t func) { 191 | LMIC.rxtime = LMIC.txend + delay - PRERX_FSK*us2osticksRound(160); 192 | LMIC.rxsyms = RXLEN_FSK; 193 | os_setTimedCallback(&LMIC.osjob, LMIC.rxtime - RX_RAMPUP, func); 194 | } 195 | 196 | void 197 | LMICin866_initJoinLoop(void) { 198 | LMICeulike_initJoinLoop(NUM_DEFAULT_CHANNELS, /* adr dBm */ IN866_TX_EIRP_MAX_DBM); 199 | } 200 | 201 | // 202 | // END: IN866 related stuff 203 | // 204 | // ================================================================================ 205 | #endif -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/src/lmic/lmic_us915.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2016 IBM Corporation. 3 | * Copyright (c) 2017 MCCI Corporation. 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 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * 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 | * * Neither the name of the 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 AND CONTRIBUTORS "AS IS" AND 18 | * ANY 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 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 | */ 28 | 29 | #define LMIC_DR_LEGACY 0 30 | 31 | #include "lmic_bandplan.h" 32 | 33 | #if defined(CFG_us915) 34 | // ================================================================================ 35 | // 36 | // BEG: US915 related stuff 37 | // 38 | 39 | CONST_TABLE(u1_t, _DR2RPS_CRC)[] = { 40 | ILLEGAL_RPS, // [-1] 41 | MAKERPS(SF10, BW125, CR_4_5, 0, 0), // [0] 42 | MAKERPS(SF9 , BW125, CR_4_5, 0, 0), // [1] 43 | MAKERPS(SF8 , BW125, CR_4_5, 0, 0), // [2] 44 | MAKERPS(SF7 , BW125, CR_4_5, 0, 0), // [3] 45 | MAKERPS(SF8 , BW500, CR_4_5, 0, 0), // [4] 46 | ILLEGAL_RPS , // [5] 47 | ILLEGAL_RPS , // [6] 48 | ILLEGAL_RPS , // [7] 49 | MAKERPS(SF12, BW500, CR_4_5, 0, 0), // [8] 50 | MAKERPS(SF11, BW500, CR_4_5, 0, 0), // [9] 51 | MAKERPS(SF10, BW500, CR_4_5, 0, 0), // [10] 52 | MAKERPS(SF9 , BW500, CR_4_5, 0, 0), // [11] 53 | MAKERPS(SF8 , BW500, CR_4_5, 0, 0), // [12] 54 | MAKERPS(SF7 , BW500, CR_4_5, 0, 0), // [13] 55 | ILLEGAL_RPS // [14] 56 | }; 57 | 58 | static CONST_TABLE(u1_t, maxFrameLens)[] = { 24,66,142,255,255,255,255,255, 66,142 }; 59 | 60 | uint8_t LMICus915_maxFrameLen(uint8_t dr) { 61 | if (dr < LENOF_TABLE(maxFrameLens)) 62 | return TABLE_GET_U1(maxFrameLens, dr); 63 | else 64 | return 0xFF; 65 | } 66 | 67 | static CONST_TABLE(ostime_t, DR2HSYM_osticks)[] = { 68 | us2osticksRound(128 << 5), // DR_SF10 DR_SF12CR 69 | us2osticksRound(128 << 4), // DR_SF9 DR_SF11CR 70 | us2osticksRound(128 << 3), // DR_SF8 DR_SF10CR 71 | us2osticksRound(128 << 2), // DR_SF7 DR_SF9CR 72 | us2osticksRound(128 << 1), // DR_SF8C DR_SF8CR 73 | us2osticksRound(128 << 0) // ------ DR_SF7CR 74 | }; 75 | 76 | ostime_t LMICus915_dr2hsym(uint8_t dr) { 77 | return TABLE_GET_OSTIME(DR2HSYM_osticks, (dr) & 7); // map DR_SFnCR -> 0-6 78 | } 79 | 80 | 81 | 82 | u4_t LMICus915_convFreq(xref2cu1_t ptr) { 83 | u4_t freq = (os_rlsbf4(ptr - 1) >> 8) * 100; 84 | if (freq < US915_FREQ_MIN || freq > US915_FREQ_MAX) 85 | freq = 0; 86 | return freq; 87 | } 88 | 89 | bit_t LMIC_setupChannel(u1_t chidx, u4_t freq, u2_t drmap, s1_t band) { 90 | if (chidx < 72 || chidx >= 72 + MAX_XCHANNELS) 91 | return 0; // channels 0..71 are hardwired 92 | LMIC.xchFreq[chidx - 72] = freq; 93 | // TODO(tmm@mcci.com): don't use US SF directly, use something from the LMIC context or a static const 94 | LMIC.xchDrMap[chidx - 72] = drmap == 0 ? DR_RANGE_MAP(US915_DR_SF10, US915_DR_SF8C) : drmap; 95 | LMIC.channelMap[chidx >> 4] |= (1 << (chidx & 0xF)); 96 | return 1; 97 | } 98 | 99 | void LMIC_disableChannel(u1_t channel) { 100 | if (channel < 72 + MAX_XCHANNELS) { 101 | if (ENABLED_CHANNEL(channel)) { 102 | if (IS_CHANNEL_125khz(channel)) 103 | LMIC.activeChannels125khz--; 104 | else if (IS_CHANNEL_500khz(channel)) 105 | LMIC.activeChannels500khz--; 106 | } 107 | LMIC.channelMap[channel >> 4] &= ~(1 << (channel & 0xF)); 108 | } 109 | } 110 | 111 | void LMIC_enableChannel(u1_t channel) { 112 | if (channel < 72 + MAX_XCHANNELS) { 113 | if (!ENABLED_CHANNEL(channel)) { 114 | if (IS_CHANNEL_125khz(channel)) 115 | LMIC.activeChannels125khz++; 116 | else if (IS_CHANNEL_500khz(channel)) 117 | LMIC.activeChannels500khz++; 118 | } 119 | LMIC.channelMap[channel >> 4] |= (1 << (channel & 0xF)); 120 | } 121 | } 122 | 123 | void LMIC_enableSubBand(u1_t band) { 124 | ASSERT(band < 8); 125 | u1_t start = band * 8; 126 | u1_t end = start + 8; 127 | 128 | // enable all eight 125 kHz channels in this subband 129 | for (int channel = start; channel < end; ++channel) 130 | LMIC_enableChannel(channel); 131 | 132 | // there's a single 500 kHz channel associated with 133 | // each group of 8 125 kHz channels. Enable it, too. 134 | LMIC_enableChannel(64 + band); 135 | } 136 | void LMIC_disableSubBand(u1_t band) { 137 | ASSERT(band < 8); 138 | u1_t start = band * 8; 139 | u1_t end = start + 8; 140 | 141 | // disable all eight 125 kHz channels in this subband 142 | for (int channel = start; channel < end; ++channel) 143 | LMIC_disableChannel(channel); 144 | 145 | // there's a single 500 kHz channel associated with 146 | // each group of 8 125 kHz channels. Disable it, too. 147 | LMIC_disableChannel(64 + band); 148 | } 149 | void LMIC_selectSubBand(u1_t band) { 150 | ASSERT(band < 8); 151 | for (int b = 0; b<8; ++b) { 152 | if (band == b) 153 | LMIC_enableSubBand(b); 154 | else 155 | LMIC_disableSubBand(b); 156 | } 157 | } 158 | 159 | void LMICus915_updateTx(ostime_t txbeg) { 160 | u1_t chnl = LMIC.txChnl; 161 | if (chnl < 64) { 162 | LMIC.freq = US915_125kHz_UPFBASE + chnl*US915_125kHz_UPFSTEP; 163 | if (LMIC.activeChannels125khz >= 50) 164 | LMIC.txpow = 30; 165 | else 166 | LMIC.txpow = 21; 167 | } else { 168 | // at 500kHz bandwidth, we're allowed more power. 169 | LMIC.txpow = 26; 170 | if (chnl < 64 + 8) { 171 | LMIC.freq = US915_500kHz_UPFBASE + (chnl - 64)*US915_500kHz_UPFSTEP; 172 | } 173 | else { 174 | ASSERT(chnl < 64 + 8 + MAX_XCHANNELS); 175 | LMIC.freq = LMIC.xchFreq[chnl - 72]; 176 | } 177 | } 178 | 179 | // Update global duty cycle stats 180 | if (LMIC.globalDutyRate != 0) { 181 | ostime_t airtime = calcAirTime(LMIC.rps, LMIC.dataLen); 182 | LMIC.globalDutyAvail = txbeg + (airtime << LMIC.globalDutyRate); 183 | } 184 | } 185 | 186 | #if !defined(DISABLE_BEACONS) 187 | void LMICus915_setBcnRxParams(void) { 188 | LMIC.dataLen = 0; 189 | LMIC.freq = US915_500kHz_DNFBASE + LMIC.bcnChnl * US915_500kHz_DNFSTEP; 190 | LMIC.rps = setIh(setNocrc(dndr2rps((dr_t)DR_BCN), 1), LEN_BCN); 191 | } 192 | #endif // !DISABLE_BEACONS 193 | 194 | // TODO(tmm@mcci.com): parmeterize for US-like 195 | void LMICus915_setRx1Params(void) { 196 | LMIC.freq = US915_500kHz_DNFBASE + (LMIC.txChnl & 0x7) * US915_500kHz_DNFSTEP; 197 | if( /* TX datarate */LMIC.dndr < US915_DR_SF8C ) 198 | LMIC.dndr += US915_DR_SF10CR - US915_DR_SF10; 199 | else if( LMIC.dndr == US915_DR_SF8C ) 200 | LMIC.dndr = US915_DR_SF7CR; 201 | LMIC.rps = dndr2rps(LMIC.dndr); 202 | } 203 | 204 | 205 | // 206 | // END: US915 related stuff 207 | // 208 | // ================================================================================ 209 | #endif 210 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/src/lmic/lmic_us_like.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2016 IBM Corporation. 3 | * Copyright (c) 2017 MCCI Corporation. 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 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * 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 | * * Neither the name of the 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 AND CONTRIBUTORS "AS IS" AND 18 | * ANY 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 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 | */ 28 | 29 | #ifndef _lmic_us_like_h_ 30 | # define _lmic_us_like_h_ 31 | 32 | // make sure we want US-like code 33 | #if !CFG_LMIC_US_like 34 | # error "lmic not configured for us-like bandplan" 35 | #endif 36 | 37 | // TODO(tmm@mcci.com): this should come from the lmic.h or lorabase.h file; and 38 | // it's probably affected by the fix to this issue: 39 | // https://github.com/mcci-catena/arduino-lmic/issues/2 40 | #define DNW2_SAFETY_ZONE ms2osticks(750) 41 | 42 | #define IS_CHANNEL_125khz(c) (c<64) 43 | #define IS_CHANNEL_500khz(c) (c>=64 && c<72) 44 | #define ENABLED_CHANNEL(chnl) ((LMIC.channelMap[(chnl >> 4)] & (1<<(chnl & 0x0F))) != 0) 45 | 46 | // provide the isValidBeacon1 function -- int for bool. 47 | static inline int 48 | LMICuslike_isValidBeacon1(const uint8_t *d) { 49 | return os_rlsbf2(&d[OFF_BCN_CRC1]) != os_crc16(d, OFF_BCN_CRC1); 50 | } 51 | 52 | #define LMICbandplan_isValidBeacon1(pFrame) LMICuslike_isValidBeacon1(pFrame) 53 | 54 | // provide a default for LMICbandplan_isFSK() 55 | #define LMICbandplan_isFSK() (0) 56 | 57 | // provide a default LMICbandplan_txDoneFSK() 58 | #define LMICbandplan_txDoneFSK(delay, func) do { } while (0) 59 | 60 | // provide a default LMICbandplan_joinAcceptChannelClear() 61 | #define LMICbandplan_joinAcceptChannelClear() do { } while (0) 62 | 63 | // no CFList on joins for US-like plans 64 | #define LMICbandplan_hasJoinCFlist() (0) 65 | 66 | #define LMICbandplan_advanceBeaconChannel() \ 67 | do { LMIC.bcnChnl = (LMIC.bcnChnl+1) & 7; } while (0) 68 | 69 | // TODO(tmm@mcci.com): decide whether we want to do this on every 70 | // reset or just restore the last sub-band selected by the user. 71 | #define LMICbandplan_resetDefaultChannels() \ 72 | LMICbandplan_initDefaultChannels(/* normal */ 0) 73 | 74 | void LMICuslike_initDefaultChannels(bit_t fJoin); 75 | #define LMICbandplan_initDefaultChannels(fJoin) LMICuslike_initDefaultChannels(fJoin) 76 | 77 | #define LMICbandplan_setSessionInitDefaultChannels() \ 78 | do { /* nothing */} while (0) 79 | 80 | u1_t LMICuslike_mapChannels(u1_t chpage, u2_t chmap); 81 | #define LMICbandplan_mapChannels(chpage, chmap) LMICuslike_mapChannels(chpage, chmap) 82 | 83 | ostime_t LMICuslike_nextTx(ostime_t now); 84 | #define LMICbandplan_nextTx(now) LMICuslike_nextTx(now) 85 | 86 | void LMICuslike_initJoinLoop(void); 87 | #define LMICbandplan_initJoinLoop() LMICuslike_initJoinLoop() 88 | 89 | ostime_t LMICuslike_nextJoinState(void); 90 | #define LMICbandplan_nextJoinState() LMICuslike_nextJoinState(); 91 | 92 | static inline ostime_t LMICeulike_nextJoinTime(ostime_t now) { 93 | return now; 94 | } 95 | #define LMICbandplan_nextJoinTime(now) LMICeulike_nextJoinTime(now) 96 | 97 | #define LMICbandplan_init() \ 98 | do { /* nothing */ } while (0) 99 | 100 | #endif // _lmic_us_like_h_ 101 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/src/lmic/lmic_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: lmic_util.h 4 | 5 | Function: 6 | Declare encoding and decoding utilities for LMIC clients. 7 | 8 | Copyright & License: 9 | See accompanying LICENSE file. 10 | 11 | Author: 12 | Terry Moore, MCCI September 2019 13 | 14 | */ 15 | 16 | #ifndef _LMIC_UTIL_H_ 17 | # define _LMIC_UTIL_H_ 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | #include 24 | 25 | uint16_t LMIC_f2sflt16(float); 26 | uint16_t LMIC_f2sflt12(float); 27 | uint16_t LMIC_f2uflt16(float); 28 | uint16_t LMIC_f2uflt12(float); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif /* _LMIC_UTIL_H_ */ 35 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/src/lmic/lorabase_as923.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2016 IBM Corporation. 3 | * All rights reserved. 4 | * 5 | * Copyright (c) 2017 MCCI Corporation 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * * Neither the name of the nor the 16 | * names of its contributors may be used to endorse or promote products 17 | * derived from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef _lorabase_as923_h_ 32 | #define _lorabase_as923_h_ 33 | 34 | #ifndef _LMIC_CONFIG_PRECONDITIONS_H_ 35 | # include "lmic_config_preconditions.h" 36 | #endif 37 | 38 | /****************************************************************************\ 39 | | 40 | | Basic definitions for AS923 (always in scope) 41 | | 42 | \****************************************************************************/ 43 | 44 | enum _dr_as923_t { 45 | AS923_DR_SF12 = 0, 46 | AS923_DR_SF11, 47 | AS923_DR_SF10, 48 | AS923_DR_SF9, 49 | AS923_DR_SF8, 50 | AS923_DR_SF7, 51 | AS923_DR_SF7B, 52 | AS923_DR_FSK, 53 | AS923_DR_NONE 54 | }; 55 | 56 | // Bands: 57 | // g1 : 1% 16dBm 58 | // freq band datarates 59 | enum { 60 | AS923_F1 = 923200000, // g1 SF7-12 61 | AS923_F2 = 923400000, // g1 SF7-12 62 | AS923_FDOWN = 923200000, // (RX2 freq, DR2) 63 | AS923_FBCN = 923400000, // default BCN, DR3 64 | AS923_FPING = 923400000, // default ping, DR3 65 | }; 66 | enum { 67 | AS923_FREQ_MIN = 915000000, 68 | AS923_FREQ_MAX = 928000000 69 | }; 70 | enum { 71 | AS923_TX_EIRP_MAX_DBM = 16 // 16 dBm 72 | }; 73 | enum { DR_PAGE_AS923 = 0x10 * (LMIC_REGION_as923 - 1) }; 74 | 75 | enum { AS923_LMIC_REGION_EIRP = 1 }; // region uses EIRP 76 | 77 | enum { AS923JP_LBT_US = 5000 }; // microseconds of LBT time -- 5000 ==> 78 | // 5 ms. We use us rather than ms for 79 | // future 128us support, and just for 80 | // backward compatibility -- there 81 | // is code that uses the _US constant, 82 | // and it's awkward to break it. 83 | 84 | enum { AS923JP_LBT_DB_MAX = -80 }; // maximum channel strength in dB; if TX 85 | // we measure more than this, we don't tx. 86 | 87 | // AS923 v1.1, all channels face a 1% duty cycle. So this will have to change 88 | // in the future via a config. But this code base needs major changes for 89 | // v1.1 in any case. 90 | enum { AS923_V102_TX_CAP = 100 }; // v1.0.2 allows 100% 91 | 92 | #ifndef AS923_TX_CAP 93 | # define AS923_TX_CAP AS923_V102_TX_CAP 94 | #endif 95 | 96 | #endif /* _lorabase_as923_h_ */ 97 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/src/lmic/lorabase_au921.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2016 IBM Corporation. 3 | * All rights reserved. 4 | * 5 | * Copyright (c) 2017 MCCI Corporation 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * * Neither the name of the nor the 16 | * names of its contributors may be used to endorse or promote products 17 | * derived from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef _lorabase_au921_h_ 32 | #define _lorabase_au921_h_ 33 | 34 | #ifndef _LMIC_CONFIG_PRECONDITIONS_H_ 35 | # include "lmic_config_preconditions.h" 36 | #endif 37 | 38 | /****************************************************************************\ 39 | | 40 | | Basic definitions for AS921 (always in scope) 41 | | 42 | \****************************************************************************/ 43 | 44 | // Frequency plan for AU 921 MHz 45 | enum _dr_as921_t { 46 | AU921_DR_SF12 = 0, 47 | AU921_DR_SF11, 48 | AU921_DR_SF10, 49 | AU921_DR_SF9, 50 | AU921_DR_SF8, 51 | AU921_DR_SF7, 52 | AU921_DR_SF8C, 53 | AU921_DR_NONE, 54 | // Devices behind a router: 55 | AU921_DR_SF12CR = 8, 56 | AU921_DR_SF11CR, 57 | AU921_DR_SF10CR, 58 | AU921_DR_SF9CR, 59 | AU921_DR_SF8CR, 60 | AU921_DR_SF7CR 61 | }; 62 | 63 | // Default frequency plan for AU 921MHz 64 | enum { 65 | AU921_125kHz_UPFBASE = 915200000, 66 | AU921_125kHz_UPFSTEP = 200000, 67 | AU921_500kHz_UPFBASE = 915900000, 68 | AU921_500kHz_UPFSTEP = 1600000, 69 | AU921_500kHz_DNFBASE = 923300000, 70 | AU921_500kHz_DNFSTEP = 600000 71 | }; 72 | enum { 73 | AU921_FREQ_MIN = 915000000, 74 | AU921_FREQ_MAX = 928000000 75 | }; 76 | enum { 77 | AU921_TX_EIRP_MAX_DBM = 30 // 30 dBm 78 | }; 79 | 80 | enum { DR_PAGE_AU921 = 0x10 * (LMIC_REGION_au921 - 1) }; 81 | 82 | enum { AU921_LMIC_REGION_EIRP = 1 }; // region uses EIRP 83 | 84 | #endif /* _lorabase_au921_h_ */ -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/src/lmic/lorabase_eu868.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2016 IBM Corporation. 3 | * All rights reserved. 4 | * 5 | * Copyright (c) 2017 MCCI Corporation 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * * Neither the name of the nor the 16 | * names of its contributors may be used to endorse or promote products 17 | * derived from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef _lorabase_eu868_h_ 32 | #define _lorabase_eu868_h_ 33 | 34 | #ifndef _LMIC_CONFIG_PRECONDITIONS_H_ 35 | # include "lmic_config_preconditions.h" 36 | #endif 37 | 38 | /****************************************************************************\ 39 | | 40 | | Basic definitions for EU868 (always in scope) 41 | | 42 | \****************************************************************************/ 43 | 44 | // 45 | // Default frequency plan for EU 868MHz ISM band 46 | // data rates 47 | // this is a little confusing: the integer values of these constants are the 48 | // DataRates from the LoRaWAN Regional Parmaeter spec. The names are just 49 | // convenient indications, so we can use them in the rare case that we need to 50 | // choose a DataRate by SF and configuration, not by DR code. 51 | 52 | enum _dr_eu868_t { 53 | EU868_DR_SF12 = 0, 54 | EU868_DR_SF11, 55 | EU868_DR_SF10, 56 | EU868_DR_SF9, 57 | EU868_DR_SF8, 58 | EU868_DR_SF7, 59 | EU868_DR_SF7B, 60 | EU868_DR_FSK, 61 | EU868_DR_NONE 62 | }; 63 | 64 | // Bands: 65 | // g1 : 1% 14dBm 66 | // g2 : 0.1% 14dBm 67 | // g3 : 10% 27dBm 68 | // freq band datarates 69 | enum { 70 | EU868_F1 = 868100000, // g1 SF7-12 71 | EU868_F2 = 868300000, // g1 SF7-12 FSK SF7/250 72 | EU868_F3 = 868500000, // g1 SF7-12 73 | EU868_F4 = 868850000, // g2 SF7-12 74 | EU868_F5 = 869050000, // g2 SF7-12 75 | EU868_F6 = 869525000, // g3 SF7-12 76 | EU868_J4 = 864100000, // g2 SF7-12 used during join 77 | EU868_J5 = 864300000, // g2 SF7-12 ditto 78 | EU868_J6 = 864500000, // g2 SF7-12 ditto 79 | }; 80 | enum { 81 | EU868_FREQ_MIN = 863000000, 82 | EU868_FREQ_MAX = 870000000 83 | }; 84 | enum { 85 | EU868_TX_EIRP_MAX_DBM = 16 // 16 dBm EIRP. So subtract 3 dBm for a 3 dBi antenna. 86 | }; 87 | 88 | enum { EU868_LMIC_REGION_EIRP = 1 }; // region uses EIRP 89 | 90 | enum { DR_PAGE_EU868 = 0x10 * (LMIC_REGION_eu868 - 1) }; 91 | 92 | #endif /* _lorabase_eu868_h_ */ -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/src/lmic/lorabase_in866.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2016 IBM Corporation. 3 | * All rights reserved. 4 | * 5 | * Copyright (c) 2017 MCCI Corporation 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * * Neither the name of the nor the 16 | * names of its contributors may be used to endorse or promote products 17 | * derived from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef _lorabase_in866_h_ 32 | #define _lorabase_in866_h_ 33 | 34 | #ifndef _LMIC_CONFIG_PRECONDITIONS_H_ 35 | # include "lmic_config_preconditions.h" 36 | #endif 37 | 38 | /****************************************************************************\ 39 | | 40 | | Basic definitions for IN866 (always in scope) 41 | | 42 | \****************************************************************************/ 43 | 44 | enum _dr_in866_t { 45 | IN866_DR_SF12 = 0, // DR0 46 | IN866_DR_SF11, // DR1 47 | IN866_DR_SF10, // DR2 48 | IN866_DR_SF9, // DR3 49 | IN866_DR_SF8, // DR4 50 | IN866_DR_SF7, // DR5 51 | IN866_DR_RFU, // - 52 | IN866_DR_FSK, // DR7 53 | IN866_DR_NONE 54 | }; 55 | 56 | // There is no dwell-time or duty-cycle limitation for IN 57 | // 58 | // max power: 30dBM 59 | // 60 | // freq datarates 61 | enum { 62 | IN866_F1 = 865062500, // SF7-12 (DR0-5) 63 | IN866_F2 = 865402500, // SF7-12 (DR0-5) 64 | IN866_F3 = 865985000, // SF7-12 (DR0-5) 65 | IN866_FB = 866550000, // beacon/ping 66 | }; 67 | enum { 68 | IN866_FREQ_MIN = 865000000, 69 | IN866_FREQ_MAX = 867000000 70 | }; 71 | enum { 72 | IN866_TX_EIRP_MAX_DBM = 30 // 30 dBm 73 | }; 74 | enum { DR_PAGE_IN866 = 0x10 * (LMIC_REGION_in866 - 1) }; 75 | 76 | enum { IN866_LMIC_REGION_EIRP = 1 }; // region uses EIRP 77 | 78 | #endif /* _lorabase_in866_h_ */ -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/src/lmic/lorabase_us915.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2016 IBM Corporation. 3 | * All rights reserved. 4 | * 5 | * Copyright (c) 2017 MCCI Corporation 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * * Neither the name of the nor the 16 | * names of its contributors may be used to endorse or promote products 17 | * derived from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef _lorabase_us915_h_ 32 | #define _lorabase_us915_h_ 33 | 34 | #ifndef _LMIC_CONFIG_PRECONDITIONS_H_ 35 | # include "lmic_config_preconditions.h" 36 | #endif 37 | 38 | /****************************************************************************\ 39 | | 40 | | Basic definitions for US915 (always in scope) 41 | | 42 | \****************************************************************************/ 43 | 44 | // Frequency plan for US 915MHz ISM band 45 | // data rates 46 | enum _dr_us915_t { 47 | US915_DR_SF10 = 0, 48 | US915_DR_SF9, 49 | US915_DR_SF8, 50 | US915_DR_SF7, 51 | US915_DR_SF8C, 52 | US915_DR_NONE, 53 | // Devices "behind a router" (and upper half of DR list): 54 | US915_DR_SF12CR = 8, 55 | US915_DR_SF11CR, 56 | US915_DR_SF10CR, 57 | US915_DR_SF9CR, 58 | US915_DR_SF8CR, 59 | US915_DR_SF7CR 60 | }; 61 | 62 | // Default frequency plan for US 915MHz 63 | enum { 64 | US915_125kHz_UPFBASE = 902300000, 65 | US915_125kHz_UPFSTEP = 200000, 66 | US915_500kHz_UPFBASE = 903000000, 67 | US915_500kHz_UPFSTEP = 1600000, 68 | US915_500kHz_DNFBASE = 923300000, 69 | US915_500kHz_DNFSTEP = 600000 70 | }; 71 | enum { 72 | US915_FREQ_MIN = 902000000, 73 | US915_FREQ_MAX = 928000000 74 | }; 75 | enum { 76 | US915_TX_MAX_DBM = 30 // 30 dBm (but not EIRP): assumes we're 77 | // on an 64-channel bandplan. See code 78 | // that computes tx power. 79 | }; 80 | enum { DR_PAGE_US915 = 0x10 * (LMIC_REGION_us915 - 1) }; 81 | 82 | enum { US915_LMIC_REGION_EIRP = 0 }; // region doesn't use EIRP, uses tx power 83 | 84 | #endif /* _lorabase_us915_h_ */ -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/MCCI_LoRaWAN_LMIC_library/src/lmic/oslmic.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2016 IBM Corporation. 3 | * Copyright (c) 2016-2017 MCCI Corporation. 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 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * 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 | * * Neither the name of the 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 AND CONTRIBUTORS "AS IS" AND 18 | * ANY 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 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 | */ 28 | 29 | #define LMIC_DR_LEGACY 0 30 | 31 | #include "lmic.h" 32 | 33 | extern const struct lmic_pinmap lmic_pins; 34 | 35 | // RUNTIME STATE 36 | static struct { 37 | osjob_t* scheduledjobs; 38 | osjob_t* runnablejobs; 39 | } OS; 40 | 41 | int os_init_ex (const void *pintable) { 42 | memset(&OS, 0x00, sizeof(OS)); 43 | hal_init_ex(pintable); 44 | if (! radio_init()) 45 | return 0; 46 | LMIC_init(); 47 | return 1; 48 | } 49 | 50 | void os_init() { 51 | if (os_init_ex((const void *)&lmic_pins)) 52 | return; 53 | ASSERT(0); 54 | } 55 | 56 | ostime_t os_getTime () { 57 | return hal_ticks(); 58 | } 59 | 60 | // unlink job from queue, return if removed 61 | static int unlinkjob (osjob_t** pnext, osjob_t* job) { 62 | for( ; *pnext; pnext = &((*pnext)->next)) { 63 | if(*pnext == job) { // unlink 64 | *pnext = job->next; 65 | return 1; 66 | } 67 | } 68 | return 0; 69 | } 70 | 71 | // clear scheduled job 72 | void os_clearCallback (osjob_t* job) { 73 | hal_disableIRQs(); 74 | unlinkjob(&OS.scheduledjobs, job) || unlinkjob(&OS.runnablejobs, job); 75 | hal_enableIRQs(); 76 | } 77 | 78 | // schedule immediately runnable job 79 | void os_setCallback (osjob_t* job, osjobcb_t cb) { 80 | osjob_t** pnext; 81 | hal_disableIRQs(); 82 | // remove if job was already queued 83 | unlinkjob(&OS.runnablejobs, job); 84 | // fill-in job 85 | job->func = cb; 86 | job->next = NULL; 87 | // add to end of run queue 88 | for(pnext=&OS.runnablejobs; *pnext; pnext=&((*pnext)->next)); 89 | *pnext = job; 90 | hal_enableIRQs(); 91 | } 92 | 93 | // schedule timed job 94 | void os_setTimedCallback (osjob_t* job, ostime_t time, osjobcb_t cb) { 95 | osjob_t** pnext; 96 | hal_disableIRQs(); 97 | // remove if job was already queued 98 | unlinkjob(&OS.scheduledjobs, job); 99 | // fill-in job 100 | job->deadline = time; 101 | job->func = cb; 102 | job->next = NULL; 103 | // insert into schedule 104 | for(pnext=&OS.scheduledjobs; *pnext; pnext=&((*pnext)->next)) { 105 | if((*pnext)->deadline - time > 0) { // (cmp diff, not abs!) 106 | // enqueue before next element and stop 107 | job->next = *pnext; 108 | break; 109 | } 110 | } 111 | *pnext = job; 112 | hal_enableIRQs(); 113 | } 114 | 115 | // execute jobs from timer and from run queue 116 | void os_runloop () { 117 | while(1) { 118 | os_runloop_once(); 119 | } 120 | } 121 | 122 | void os_runloop_once() { 123 | osjob_t* j = NULL; 124 | hal_disableIRQs(); 125 | // check for runnable jobs 126 | if(OS.runnablejobs) { 127 | j = OS.runnablejobs; 128 | OS.runnablejobs = j->next; 129 | } else if(OS.scheduledjobs && hal_checkTimer(OS.scheduledjobs->deadline)) { // check for expired timed jobs 130 | j = OS.scheduledjobs; 131 | OS.scheduledjobs = j->next; 132 | } else { // nothing pending 133 | hal_sleep(); // wake by irq (timer already restarted) 134 | } 135 | hal_enableIRQs(); 136 | if(j) { // run job callback 137 | j->func(j); 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/SSD1306/README.md: -------------------------------------------------------------------------------- 1 | # SSD1306 2 | 3 | 4 | ## Compatibility 5 | 6 | MCU | Tested Works | Doesn't Work | Not Tested | Notes 7 | ------------------ | :----------: | :----------: | :---------: | ----- 8 | HelTec Wifi Lora 32|20180712|||100KHz unless additional 3.3k pullups, max 430KHz, 9 | 10 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/SSD1306/README.txt: -------------------------------------------------------------------------------- 1 | This is a library for our Monochrome OLEDs based on SSD1306 drivers 2 | 3 | Pick one up today in the adafruit shop! 4 | ------> http://www.adafruit.com/category/63_98 5 | 6 | These displays use SPI to communicate, 4 or 5 pins are required to 7 | interface 8 | 9 | Adafruit invests time and resources providing this open source code, 10 | please support Adafruit and open-source hardware by purchasing 11 | products from Adafruit! 12 | 13 | Written by Limor Fried/Ladyada for Adafruit Industries. 14 | Scrolling code contributed by Michael Gregg 15 | BSD license, check license.txt for more information 16 | All text above must be included in any redistribution 17 | 18 | To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_SSD1306. Check that the Adafruit_SSD1306 folder contains Adafruit_SSD1306.cpp and Adafruit_SSD1306.h 19 | 20 | Place the Adafruit_SSD1306 library folder your /libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE. 21 | 22 | You will also have to download the Adafruit GFX Graphics core which does all the circles, text, rectangles, etc. You can get it from 23 | https://github.com/adafruit/Adafruit-GFX-Library 24 | and download/install that library as well 25 | 26 | 07/12/2018 @stickbreaker 27 | Modified by adding refresh cliping rectange to increase i2c performance. 28 | Changed to use block i2c transfer instead of byte. 29 | Only i2c interface support. 30 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/SSD1306/library.properties: -------------------------------------------------------------------------------- 1 | name=SSD1306 2 | version=1.0.0 3 | author=Adafruit+stickbreaker 4 | maintainer=stickbreaker 5 | sentence=SSD1306 oled driver library for 'monochrome' 128x64 and 128x32 OLEDs! 6 | paragraph=SSD1306 oled driver library for 'monochrome' 128x64 and 128x32 OLEDs! based on AdaFruit_SSD1306. Only i2c Support provided. 7 | category=Display 8 | url=https://github.com/stickbreaker/SSD1306 9 | architectures=esp32 10 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/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 | -------------------------------------------------------------------------------- /ESP32_Heltec_V1_LoRa_Mote/libraries/SSD1306/src/ssd1306.h: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | This is a library for our Monochrome OLEDs based on SSD1306 drivers 3 | 4 | Pick one up today in the adafruit shop! 5 | ------> http://www.adafruit.com/category/63_98 6 | 7 | These displays use SPI to communicate, 4 or 5 pins are required to 8 | 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. 15 | BSD license, check license.txt for more information 16 | All text above, and the splash screen must be included in any redistribution 17 | *********************************************************************/ 18 | #ifndef _SSD1306_H_ 19 | #define _SSD1306_H_ 20 | 21 | #if ARDUINO >= 100 22 | #include "Arduino.h" 23 | #define WIRE_WRITE Wire.write 24 | #else 25 | #include "WProgram.h" 26 | #define WIRE_WRITE Wire.send 27 | #endif 28 | 29 | #if defined(__SAM3X8E__) 30 | typedef volatile RwReg PortReg; 31 | typedef uint32_t PortMask; 32 | #define HAVE_PORTREG 33 | #elif defined(ARDUINO_ARCH_SAMD) 34 | // not supported 35 | #elif defined(ESP8266) || defined(ESP32) || defined(ARDUINO_STM32_FEATHER) || defined(__arc__) 36 | typedef volatile uint32_t PortReg; 37 | typedef uint32_t PortMask; 38 | #elif defined(__AVR__) 39 | typedef volatile uint8_t PortReg; 40 | typedef uint8_t PortMask; 41 | #define HAVE_PORTREG 42 | #else 43 | // chances are its 32 bit so assume that 44 | typedef volatile uint32_t PortReg; 45 | typedef uint32_t PortMask; 46 | #endif 47 | 48 | #include 49 | #include 50 | 51 | #define BLACK 0 52 | #define WHITE 1 53 | #define INVERSE 2 54 | 55 | #define SSD1306_I2C_ADDRESS 0x3C // 011110+SA0+RW - 0x3C or 0x3D 56 | // Address for 128x32 is 0x3C 57 | // Address for 128x64 is 0x3D (default) or 0x3C (if SA0 is grounded) 58 | 59 | /*========================================================================= 60 | SSD1306 Displays 61 | ----------------------------------------------------------------------- 62 | The driver is used in multiple displays (128x64, 128x32, etc.). 63 | Select the appropriate display below to create an appropriately 64 | sized framebuffer, etc. 65 | 66 | SSD1306_128_64 128x64 pixel display 67 | 68 | SSD1306_128_32 128x32 pixel display 69 | 70 | SSD1306_96_16 71 | 72 | -----------------------------------------------------------------------*/ 73 | #define SSD1306_128_64 74 | // #define SSD1306_128_32 75 | // #define SSD1306_96_16 76 | /*=========================================================================*/ 77 | 78 | #if defined SSD1306_128_64 && defined SSD1306_128_32 79 | #error "Only one SSD1306 display can be specified at once in SSD1306.h" 80 | #endif 81 | #if !defined SSD1306_128_64 && !defined SSD1306_128_32 && !defined SSD1306_96_16 82 | #error "At least one SSD1306 display must be specified in SSD1306.h" 83 | #endif 84 | 85 | #if defined SSD1306_128_64 86 | #define SSD1306_LCDWIDTH 128 87 | #define SSD1306_LCDHEIGHT 64 88 | #endif 89 | #if defined SSD1306_128_32 90 | #define SSD1306_LCDWIDTH 128 91 | #define SSD1306_LCDHEIGHT 32 92 | #endif 93 | #if defined SSD1306_96_16 94 | #define SSD1306_LCDWIDTH 96 95 | #define SSD1306_LCDHEIGHT 16 96 | #endif 97 | 98 | #define SSD1306_SETCONTRAST 0x81 99 | #define SSD1306_DISPLAYALLON_RESUME 0xA4 100 | #define SSD1306_DISPLAYALLON 0xA5 101 | #define SSD1306_NORMALDISPLAY 0xA6 102 | #define SSD1306_INVERTDISPLAY 0xA7 103 | #define SSD1306_DISPLAYOFF 0xAE 104 | #define SSD1306_DISPLAYON 0xAF 105 | 106 | #define SSD1306_SETDISPLAYOFFSET 0xD3 107 | #define SSD1306_SETCOMPINS 0xDA 108 | 109 | #define SSD1306_SETVCOMDETECT 0xDB 110 | 111 | #define SSD1306_SETDISPLAYCLOCKDIV 0xD5 112 | #define SSD1306_SETPRECHARGE 0xD9 113 | 114 | #define SSD1306_SETMULTIPLEX 0xA8 115 | 116 | #define SSD1306_SETLOWCOLUMN 0x00 117 | #define SSD1306_SETHIGHCOLUMN 0x10 118 | 119 | #define SSD1306_SETSTARTLINE 0x40 120 | 121 | #define SSD1306_MEMORYMODE 0x20 122 | #define SSD1306_COLUMNADDR 0x21 123 | #define SSD1306_PAGEADDR 0x22 124 | 125 | #define SSD1306_COMSCANINC 0xC0 126 | #define SSD1306_COMSCANDEC 0xC8 127 | 128 | #define SSD1306_SEGREMAP 0xA0 129 | 130 | #define SSD1306_CHARGEPUMP 0x8D 131 | 132 | #define SSD1306_EXTERNALVCC 0x1 133 | #define SSD1306_SWITCHCAPVCC 0x2 134 | 135 | // Scrolling #defines 136 | #define SSD1306_ACTIVATE_SCROLL 0x2F 137 | #define SSD1306_DEACTIVATE_SCROLL 0x2E 138 | #define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3 139 | #define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26 140 | #define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27 141 | #define SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29 142 | #define SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A 143 | 144 | class SSD1306 : public Adafruit_GFX { 145 | public: 146 | SSD1306(int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS); 147 | SSD1306(int8_t DC, int8_t RST, int8_t CS); 148 | SSD1306(int8_t RST = -1); 149 | 150 | void begin(uint8_t switchvcc = SSD1306_SWITCHCAPVCC, uint8_t i2caddr = SSD1306_I2C_ADDRESS, bool reset=true); 151 | void ssd1306_command(uint8_t c); 152 | 153 | void clearDisplay(void); 154 | void invertDisplay(uint8_t i); 155 | void display(); 156 | 157 | void startscrollright(uint8_t start, uint8_t stop); 158 | void startscrollleft(uint8_t start, uint8_t stop); 159 | 160 | void startscrolldiagright(uint8_t start, uint8_t stop); 161 | void startscrolldiagleft(uint8_t start, uint8_t stop); 162 | void stopscroll(void); 163 | 164 | void dim(boolean dim); 165 | 166 | void drawPixel(int16_t x, int16_t y, uint16_t color); 167 | 168 | virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); 169 | virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); 170 | 171 | private: 172 | int8_t _i2caddr, _vccstate, sid, sclk, dc, rst, cs; 173 | void fastSPIwrite(uint8_t c); 174 | 175 | boolean hwSPI; 176 | #ifdef HAVE_PORTREG 177 | PortReg *mosiport, *clkport, *csport, *dcport; 178 | PortMask mosipinmask, clkpinmask, cspinmask, dcpinmask; 179 | #endif 180 | 181 | inline void drawFastVLineInternal(int16_t x, int16_t y, int16_t h, uint16_t color) __attribute__((always_inline)); 182 | inline void drawFastHLineInternal(int16_t x, int16_t y, int16_t w, uint16_t color) __attribute__((always_inline)); 183 | 184 | }; 185 | 186 | #endif /* _SSD1306_H_ */ 187 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ESP32 LoRaWAN Mote (end node) # 2 | 3 | Vist https://digitalelectronicsprojects.wordpress.com/2018/11/23/esp32-lorawan-mote/ for a full walk through of how too set it up. 4 | 5 | Work on this is still in progress and the above code is used in the Arduino IDE and has been tried and tested on a Heltec WiFi LoRa V1 Board bought from here https://www.banggood.com/868MHz-915MHz-SX1276-ESP32-LoRa-0_96-Inch-Blue-OLED-Display-Bluetooth-WIFI-Lora-Kit-32-Module-p-1248583.html?rmmds=search&cur_warehouse=CN and set up on TTN which receives the data sent from the Mote and DHT22 sensor attached. Please read the README.md of all the libraries used within the repo for help in setting up till i get the how too done. CHEERS!!!! and have fun...... 6 | 7 | Download ZIP and on an Windows machine go to Documents->Arduino and extract there. Build one of the two examples in the root of the extracted folder for ESP32 and upload to the board. 8 | 9 | Full walk through is now up and ready for use at the above link. 28/11/2018. 10 | --------------------------------------------------------------------------------