diff --git a/src/display.cpp b/src/display.cpp index bfc55f05..ba71a544 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -4,7 +4,7 @@ #include "globals.h" #include // needed for reading ESP32 chip attributes -HAS_DISPLAY u8x8(OLED_RST, OLED_SCL, OLED_SDA); +HAS_DISPLAY u8x8(OLED_RST, I2C_SCL, I2C_SDA); // helper string for converting LoRa spread factor values #if defined(CFG_eu868) diff --git a/src/hal/generic.h b/src/hal/generic.h index bedff5e8..d5863038 100644 --- a/src/hal/generic.h +++ b/src/hal/generic.h @@ -34,5 +34,5 @@ // pin definitions for I2C interface of OLED Display #define OLED_RST GPIO_NUM_16 // SSD1306 RST -#define OLED_SDA GPIO_NUM_4 // SD1306 D1+D2 -#define OLED_SCL GPIO_NUM_15 // SD1306 D0 \ No newline at end of file +#define I2C_SDA GPIO_NUM_4 // SD1306 D1+D2 +#define I2C_SCL GPIO_NUM_15 // SD1306 D0 \ No newline at end of file diff --git a/src/hal/heltec.h b/src/hal/heltec.h index 2671fac8..44316c63 100644 --- a/src/hal/heltec.h +++ b/src/hal/heltec.h @@ -22,5 +22,5 @@ // Hardware pin definitions for Heltec LoRa-32 Board with OLED SSD1306 I2C Display #define OLED_RST GPIO_NUM_16 // ESP32 GPIO16 (Pin16) -- SD1306 RST -#define OLED_SDA GPIO_NUM_4 // ESP32 GPIO4 (Pin4) -- SD1306 D1+D2 -#define OLED_SCL GPIO_NUM_15 // ESP32 GPIO15 (Pin15) -- SD1306 D0 +#define I2C_SDA GPIO_NUM_4 // ESP32 GPIO4 (Pin4) -- SD1306 D1+D2 +#define I2C_SCL GPIO_NUM_15 // ESP32 GPIO15 (Pin15) -- SD1306 D0 diff --git a/src/hal/lolin32litelora.h b/src/hal/lolin32litelora.h index 4275ea00..6427dbcd 100644 --- a/src/hal/lolin32litelora.h +++ b/src/hal/lolin32litelora.h @@ -31,8 +31,8 @@ // Hardware pin definitions for LoRaNode32 Board with OLED I2C Display #define OLED_RST U8X8_PIN_NONE // Not reset pin -#define OLED_SDA 14 // ESP32 GPIO14 (Pin14) -- OLED SDA -#define OLED_SCL 12 // ESP32 GPIO12 (Pin12) -- OLED SCL +#define I2C_SDA 14 // ESP32 GPIO14 (Pin14) -- OLED SDA +#define I2C_SCL 12 // ESP32 GPIO12 (Pin12) -- OLED SCL // I2C config for Microchip 24AA02E64 DEVEUI unique address #define MCP_24AA02E64_I2C_ADDRESS 0x50 // I2C address for the 24AA02E64 diff --git a/src/hal/lolin32lora.h b/src/hal/lolin32lora.h index 976092d7..7964a561 100644 --- a/src/hal/lolin32lora.h +++ b/src/hal/lolin32lora.h @@ -32,8 +32,8 @@ // Hardware pin definitions for LoRaNode32 Board with OLED I2C Display #define OLED_RST U8X8_PIN_NONE // Not reset pin -#define OLED_SDA 21 // ESP32 GPIO21 (Pin21) -- OLED SDA -#define OLED_SCL 22 // ESP32 GPIO22 (Pin22) -- OLED SCL +#define I2C_SDA 21 // ESP32 GPIO21 (Pin21) -- OLED SDA +#define I2C_SCL 22 // ESP32 GPIO22 (Pin22) -- OLED SCL // I2C config for Microchip 24AA02E64 DEVEUI unique address #define MCP_24AA02E64_I2C_ADDRESS 0x50 // I2C address for the 24AA02E64 diff --git a/src/hal/ttgov1.h b/src/hal/ttgov1.h index fb04cbb0..f64fe380 100644 --- a/src/hal/ttgov1.h +++ b/src/hal/ttgov1.h @@ -24,5 +24,5 @@ // Hardware pin definitions for TTGOv1 Board with OLED SSD1306 I2C Display #define OLED_RST GPIO_NUM_16 // ESP32 GPIO16 (Pin16) -- SD1306 Reset -#define OLED_SDA GPIO_NUM_4 // ESP32 GPIO4 (Pin4) -- SD1306 Data -#define OLED_SCL GPIO_NUM_15 // ESP32 GPIO15 (Pin15) -- SD1306 Clock +#define I2C_SDA GPIO_NUM_4 // ESP32 GPIO4 (Pin4) -- SD1306 Data +#define I2C_SCL GPIO_NUM_15 // ESP32 GPIO15 (Pin15) -- SD1306 Clock diff --git a/src/hal/ttgov2.h b/src/hal/ttgov2.h index e622af02..0df3146e 100644 --- a/src/hal/ttgov2.h +++ b/src/hal/ttgov2.h @@ -25,8 +25,8 @@ // Hardware pin definitions for TTGO V2 Board with OLED SSD1306 0,96" I2C Display #define OLED_RST U8X8_PIN_NONE // connected to CPU RST/EN -#define OLED_SDA GPIO_NUM_21 // ESP32 GPIO21 -- SD1306 D1+D2 -#define OLED_SCL GPIO_NUM_22 // ESP32 GPIO22 -- SD1306 D0 +#define I2C_SDA GPIO_NUM_21 // ESP32 GPIO21 -- SD1306 D1+D2 +#define I2C_SCL GPIO_NUM_22 // ESP32 GPIO22 -- SD1306 D0 /* source: https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-2/11973 diff --git a/src/hal/ttgov21new.h b/src/hal/ttgov21new.h index ce64323f..5cadc961 100644 --- a/src/hal/ttgov21new.h +++ b/src/hal/ttgov21new.h @@ -26,5 +26,5 @@ // Hardware pin definitions for TTGO V2 Board with OLED SSD1306 0,96" I2C Display #define OLED_RST U8X8_PIN_NONE // connected to CPU RST/EN -#define OLED_SDA GPIO_NUM_21 // ESP32 GPIO21 -- SD1306 D1+D2 -#define OLED_SCL GPIO_NUM_22 // ESP32 GPIO22 -- SD1306 D0 \ No newline at end of file +#define I2C_SDA GPIO_NUM_21 // ESP32 GPIO21 -- SD1306 D1+D2 +#define I2C_SCL GPIO_NUM_22 // ESP32 GPIO22 -- SD1306 D0 \ No newline at end of file diff --git a/src/hal/ttgov21old.h b/src/hal/ttgov21old.h index f6882187..c423ca67 100644 --- a/src/hal/ttgov21old.h +++ b/src/hal/ttgov21old.h @@ -28,5 +28,5 @@ // Hardware pin definitions for TTGO V2 Board with OLED SSD1306 0,96" I2C Display #define OLED_RST U8X8_PIN_NONE // connected to CPU RST/EN -#define OLED_SDA GPIO_NUM_21 // ESP32 GPIO21 -- SD1306 D1+D2 -#define OLED_SCL GPIO_NUM_22 // ESP32 GPIO22 -- SD1306 D0 +#define I2C_SDA GPIO_NUM_21 // ESP32 GPIO21 -- SD1306 D1+D2 +#define I2C_SCL GPIO_NUM_22 // ESP32 GPIO22 -- SD1306 D0 diff --git a/src/lorawan.cpp b/src/lorawan.cpp index 0ee8b6c0..5ffed2cb 100644 --- a/src/lorawan.cpp +++ b/src/lorawan.cpp @@ -37,6 +37,27 @@ void gen_lora_deveui(uint8_t *pdeveui) { } } +/* The above function should be changed to this one, but this would be a breaking change + +// DevEUI generator using devices's MAC address +void gen_lora_deveui(uint8_t *pdeveui) { + uint8_t *p = pdeveui, dmac[6]; + ESP_ERROR_CHECK(esp_efuse_mac_get_default(dmac)); + // deveui is LSB, we reverse it so TTN DEVEUI display + // will remain the same as MAC address + // MAC is 6 bytes, devEUI 8, set middle 2 ones + // to an arbitrary value + *p++ = dmac[5]; + *p++ = dmac[4]; + *p++ = dmac[3]; + *p++ = 0xff; + *p++ = 0xfe; + *p++ = dmac[2]; + *p++ = dmac[1]; + *p++ = dmac[0]; +} +*/ + // Function to do a byte swap in a byte array void RevBytes(unsigned char *b, size_t c) { u1_t i; @@ -79,7 +100,7 @@ void get_hard_deveui(uint8_t *pdeveui) { #ifdef MCP_24AA02E64_I2C_ADDRESS uint8_t i2c_ret; // Init this just in case, no more to 100KHz - Wire.begin(OLED_SDA, OLED_SCL, 100000); + Wire.begin(I2C_SDA, I2C_SCL, 100000); Wire.beginTransmission(MCP_24AA02E64_I2C_ADDRESS); Wire.write(MCP_24AA02E64_MAC_ADDRESS); i2c_ret = Wire.endTransmission();