
/*
ESP32-S2  is NOT OK, it has NOT ENOUGH memory to perform FW update (heap size < 64kB when HomeSpan is working)
ESP32S    is OK
ESP32-S3  is OK
ESP32-C3  not tested yet
*/

#if DEVICE_ID == 1                    // ESP32-S, Free=117420bytes
    #define HOSTNAME                  "bridge1"
    #define BOARD_TYPE                1     // 1 = ESP32-S, 2 = ESP32-S2, 3 = ESP32-S3, 4 = ESP32-C3
    // bridge fake MAC
    uint8_t FixedMACAddress[] =       {0x1A, 0xFF, 0x01, 0x01, 0x01, 0x01};
    #define STATUS_LED_GPIO           33
    #define ERROR_RED_LED_GPIO        32
    #define CONTROL_PIN               23

    // with MAX17048
    #define CUSTOM_SDA_GPIO           21   // override default SDA pin
    #define CUSTOM_SCL_GPIO           22   // override default SCL pin
    #define USE_MAX17048              1   // use "0" to disable
    #define POWER_GPIO                25  // GREEN, STDB PIN6 on TP4056, LOW on CHARGED (LED ON),       comment out if not in use - don't use "0" here
    #define CHARGING_GPIO             26  // RED,   CHRG PIN7 on TP4056, LOW during CHARGING (LED ON),  comment out if not in use - don't use "0" here
    
    #define HEARTBEAT_INTERVAL_S      180 // 300 // bridge heartbeat every 5 minutes
    #define FW_CHECK_INTERVAL_M       (60*12)  // 60 minutes, how often to check FW on server - 30 for debugging and development - REVERT TO 60    
    #define CHECK_FW_ON_BOOT          1   // check FW on boot or not

    #define USE_INFLUXDB              0
    #define USE_MQTT                  1
    #define USE_WEBLOG                1

    // used to update data structure on sensors and bridge - change to 0 when all are upgraded to the same struct
    #define ALLOW_DATA_SIZE_MISMATCH 1       // HomeSpan.cpp 2488: void SpanPoint::dataReceived(....

  #pragma message "compilation for: DEVICE_ID=1, ESP32-S, " HOSTNAME
// ---------------------------------------------------------------------------------------------------

#elif DEVICE_ID == 3                   // ESP32-S3 bare
    #define HOSTNAME                  "test-bridge-s3"
    #define BOARD_TYPE                3     // 1 = ESP32-S, 2 = ESP32-S2, 3 = ESP32-S3, 4 = ESP32-C3
    // bridge fake MAC
    uint8_t FixedMACAddress[] =       {0x1A, 0x02, 0x01, 0x01, 0x01, 0x03}; // second byte device type: 0x01 - sensor box from espnow, 0x02 bridge/standalone sensor, 0xFF bridge for espnow
    
    #define STATUS_LED_GPIO           12
    #define ERROR_RED_LED_GPIO        12
    #define CONTROL_PIN               11

    #define CUSTOM_SDA_GPIO           1
    #define CUSTOM_SCL_GPIO           2

    #define HEARTBEAT_INTERVAL_S      30 // 300 // bridge heartbeat every 5 minutes
    #define FW_CHECK_INTERVAL_M       10  // 60 minutes, how often to check FW on server - 30 for debugging and development - REVERT TO 60    
    #define CHECK_FW_ON_BOOT          1   // check FW on boot or not
    #define SENSORS_INTERVAL_S        10

    #define USE_MQTT                  1
    #define USE_WEBLOG                1

    // #define ENABLE_3V_GPIO            4   // comment out if not in use - don't use "0" here unless you mean GPIO=0 - mandatory for I2C devices on new boards
    // #define POWER_GPIO                38  // GREEN, STDB PIN6 on TP4056, LOW on CHARGED (LED ON),       comment out if not in use - don't use "0" here
    // #define CHARGING_GPIO             39  // RED,   CHRG PIN7 on TP4056, LOW during CHARGING (LED ON),  comment out if not in use - don't use "0" here
    // #define USE_MAX17048              0   // use "0" to disable

    #define USE_MQTT                  1
    #define USE_WEBLOG                1

    // used to update data structure on sensors and bridge - change to 0 when all are upgraded to the same struct
    #define ALLOW_DATA_SIZE_MISMATCH  1       // HomeSpan.cpp 2488: void SpanPoint::dataReceived(....

    #define ZH_ST7789_LCD             1   // MOSI=7, CLK=6, RST=8, DC=9, MISO/CS = N/A (40)
    #define ZH_ST7789_LCD_LED_GPIO    10  // backlight LED
    #define ZH_ST7789_LCD_VCC_GPIO    5   // LCD power
    #define SCREEN_ROTATION           0
    // ESP32-S3 GPIOs: "Table 2-1. Pin Overview" in esp32-s3_datasheet_en.pdf
    // GPIO 0, 3, 45-46 - strap
    // UART: 43-44->FTDI converter
    // N/A: 26-38 - SPI FLASH ETC. depending on the memory used - see docs.
    // USB: 19-20->directly to USB, but can be used if not used for USB
    // PREDEFINED IN pins_arduino.h:
      // SDA=8, SCL=9
      // MOSI=35, SCK=36, MISO=37, SS=42
      // all can be redefined
    // FREE: 1-2, 4-18 = 16 GPIOs
      // LCD GPIOS: 5-10
      // SDA: 1, SCL: 2 - reconfigured here: CUSTOM_SDA_GPIO,CUSTOM_SCL_GPIO - otherwise as per pins_arduino.h above
      // ENABLE_3V_GPIO: 4
      // CONTROL_PIN: 11
      // LEDS: 12

  #pragma message "compilation for: DEVICE_ID=3, ESP32-S3 bare, " HOSTNAME
// ---------------------------------------------------------------------------------------------------



#elif DEVICE_ID == 11                   // ESP32-S, Free=117420bytes
    #define HOSTNAME                  "test-bridge-11"
    #define BOARD_TYPE                1     // 1 = ESP32-S, 2 = ESP32-S2, 3 = ESP32-S3, 4 = ESP32-C3
    // bridge fake MAC
    uint8_t FixedMACAddress[] =       {0x1A, 0xFF, 0x01, 0x01, 0x01, 0x01};
    #define STATUS_LED_GPIO           33
    #define ERROR_RED_LED_GPIO        32
    #define CONTROL_PIN               23

    // with MAX17048
    #define CUSTOM_SDA_GPIO           21   // override default SDA pin
    #define CUSTOM_SCL_GPIO           22   // override default SCL pin
    #define USE_MAX17048              0   // use "0" to disable
    #define POWER_GPIO                25  // GREEN, STDB PIN6 on TP4056, LOW on CHARGED (LED ON),       comment out if not in use - don't use "0" here
    #define CHARGING_GPIO             26  // RED,   CHRG PIN7 on TP4056, LOW during CHARGING (LED ON),  comment out if not in use - don't use "0" here
    
    #define HEARTBEAT_INTERVAL_S      180 // 300 // bridge heartbeat every 5 minutes
    #define FW_CHECK_INTERVAL_M       (60*12)  // 60 minutes, how often to check FW on server - 30 for debugging and development - REVERT TO 60    
    #define CHECK_FW_ON_BOOT          1   // check FW on boot or not

    #define USE_INFLUXDB              0
    #define USE_MQTT                  1
    #define USE_WEBLOG                1

    // used to update data structure on sensors and bridge - change to 0 when all are upgraded to the same struct
    #define ALLOW_DATA_SIZE_MISMATCH  1       // HomeSpan.cpp 2488: void SpanPoint::dataReceived(....


  #pragma message "compilation for: DEVICE_ID=11, ESP32-S, " HOSTNAME
// ---------------------------------------------------------------------------------------------------


#else
  #error "Wrong DEVICE_ID chosen"
#endif



// assigning MODEL and checking if proper board is selected
#ifndef BOARD_TYPE
  #error BOARD_TYPE not defined
#else
  #if (BOARD_TYPE == 1) and (!defined(CONFIG_IDF_TARGET_ESP32))
    #error wrong board selected in Arduino - choose ESP32DEV
  #endif
  #if (BOARD_TYPE == 2) and (!defined(CONFIG_IDF_TARGET_ESP32S2))
    #error wrong board selected in Arduino - choose S2
  #endif
  #if (BOARD_TYPE == 3) and (!defined(CONFIG_IDF_TARGET_ESP32S3))
    #error wrong board selected in Arduino - choose S3
  #endif
  #if (BOARD_TYPE == 4) and (!defined(CONFIG_IDF_TARGET_ESP32C3))
    #error wrong board selected in Arduino - choose C3
  #endif

  #if (BOARD_TYPE == 1)
    #define MODEL "ESP32"
    #ifdef PRINT_COMPILER_MESSAGES
      #pragma message "chosen BOARD_TYPE = ESP32"
    #endif
  #elif (BOARD_TYPE == 2)
    #error "ESP32-S2 has NOT ENOUGH MEMORY to run!"
    #define MODEL "ESP32S2"
    #ifdef PRINT_COMPILER_MESSAGES
      #pragma message "chosen BOARD_TYPE = ESP32S2"
    #endif
  #elif (BOARD_TYPE == 3)
    #define MODEL "ESP32S3"
    #ifdef PRINT_COMPILER_MESSAGES
      #pragma message "chosen BOARD_TYPE = ESP32S3"
    #endif
  #elif (BOARD_TYPE == 4)
    #define MODEL "ESP32C3"
    #ifdef PRINT_COMPILER_MESSAGES
      #pragma message "chosen BOARD_TYPE = ESP32C3"
    #endif
  #else
    #error BOARD_TYPE not defined
  #endif
#endif
// assigning MODEL and checking if proper board is selected END