|
16 | 16 | */
|
17 | 17 |
|
18 | 18 | #define IDENT "MediumOne ESP32 Bridge"
|
19 |
| -#define VERSION "0.8.2" |
| 19 | +#define VERSION "0.8.3" |
20 | 20 |
|
21 | 21 | #include <WiFiClientSecure.h> // https://github.com/espressif/arduino-esp32/tree/master/libraries/WiFiClientSecure
|
22 | 22 | #define MQTT_MAX_PACKET_SIZE 1024
|
23 | 23 | #include <PubSubClient.h>
|
24 | 24 | #include <ArduinoJson.h>
|
25 | 25 |
|
| 26 | + /* Board select */ |
| 27 | +#define BOARD_SELECT_HUZZAH32 0 |
| 28 | +#define BOARD_SELECT_HUZZAH32_SWAPPED 1 |
| 29 | +#define BOARD_SELECT_ESP32_DEVKITC 0 |
| 30 | +#define BOARD_SELECT_ESP32_DEVKITC_SWAPPED 0 |
| 31 | +#define BOARD_SELECT_MIKRO_WIFI_BLE_CLICK 0 |
| 32 | +#define BOARD_SELECT_CUSTOM 0 |
| 33 | + |
| 34 | +#if defined(BOARD_SELECT_HUZZAH32) && BOARD_SELECT_HUZZAH32 == 1 |
| 35 | + /* Adafruit HUZZAH32 with default TX/RX pins */ |
| 36 | +#define CONSOLE_SERIAL Serial /* console serial port for info & debug messages */ |
| 37 | +#define CLIENT_SERIAL Serial1 /* client serial port for incoming AT commands */ |
| 38 | +#define REMAP_UART_PINS 0 /* 0=use default TX/RX pin mappings, 1=remap to alternate pins */ |
| 39 | +#define HAS_LED_BUILTIN 1 /* 0=board does not have LED_BUILT_IN, 1=has LED_BUILTIN */ |
| 40 | +#elif defined(BOARD_SELECT_HUZZAH32_SWAPPED) && BOARD_SELECT_HUZZAH32_SWAPPED == 1 |
| 41 | + /* Adafruit HUZZAH32 with swapped TX/RX pins */ |
| 42 | +#define CONSOLE_SERIAL Serial /* console serial port for info & debug messages */ |
| 43 | +#define CLIENT_SERIAL Serial1 /* client serial port for incoming AT commands */ |
| 44 | +#define REMAP_UART_PINS 1 /* 0=use default TX/RX pin mappings, 1=remap to alternate pins */ |
| 45 | +#define CLIENT_SERIAL_RX_GPIO 17 /* GPIO17 = chip pin 28 (IO17) = JP1-2 on HUZZAH32 */ |
| 46 | +#define CLIENT_SERIAL_TX_GPIO 16 /* GPIO16 = chip pin 27 (IO16) = JP1-3 on HUZZAH32 */ |
| 47 | +#define HAS_LED_BUILTIN 1 /* 0=board does not have LED_BUILT_IN, 1=has LED_BUILTIN */ |
| 48 | +#elif defined(BOARD_SELECT_ESP32_DEVKITC) && BOARD_SELECT_ESP32_DEVKITC == 1 |
| 49 | + /* ESP32 DevKitC with default TX/RX pins */ |
| 50 | +#define CONSOLE_SERIAL Serial /* console serial port for info & debug messages */ |
| 51 | +#define CLIENT_SERIAL Serial2 /* client serial port for incoming AT commands */ |
| 52 | +#define REMAP_UART_PINS 0 /* 0=use default TX/RX pin mappings, 1=remap to alternate pins */ |
| 53 | +#define HAS_LED_BUILTIN 1 /* 0=board does not have LED_BUILT_IN, 1=has LED_BUILTIN */ |
| 54 | +#elif defined(BOARD_SELECT_ESP32_DEVKITC_SWAPPED) && BOARD_SELECT_ESP32_DEVKITC_SWAPPED == 1 |
| 55 | + /* ESP32 DevKitC with swapped TX/RX pins */ |
26 | 56 | #define CONSOLE_SERIAL Serial /* console serial port for info & debug messages */
|
27 | 57 | #define CLIENT_SERIAL Serial2 /* client serial port for incoming AT commands */
|
| 58 | +#define REMAP_UART_PINS 1 /* 0=use default TX/RX pin mappings, 1=remap to alternate pins */ |
| 59 | +#define CLIENT_SERIAL_RX_GPIO 4 /* GPIO4 = chip pin 26 = IO4 = J3-13 on DevKitC */ |
| 60 | +#define CLIENT_SERIAL_TX_GPIO 2 /* GPIO2 = chip pin 24 = IO2 = J3-15 on DevKitC */ |
| 61 | +#define HAS_LED_BUILTIN 1 /* 0=board does not have LED_BUILT_IN, 1=has LED_BUILTIN */ |
| 62 | +#elif defined(BOARD_SELECT_MIKRO_WIFI_BLE_CLICK) && BOARD_SELECT_MIKRO_WIFI_BLE_CLICK |
| 63 | + /* Mikro Wi-Fi BLE Click */ |
| 64 | +#define CONSOLE_SERIAL Serial /* console serial port for info & debug messages */ |
| 65 | +#define CLIENT_SERIAL Serial2 /* client serial port for incoming AT commands */ |
| 66 | +#define REMAP_UART_PINS 0 /* 0=use default TX/RX pin mappings, 1=remap to alternate pins */ |
| 67 | +#define HAS_LED_BUILTIN 1 /* 0=board does not have LED_BUILT_IN, 1=has LED_BUILTIN */ |
| 68 | +#elif defined(BOARD_SELECT_CUSTOM) && BOARD_SELECT_CUSTOM == 1 |
| 69 | + /* Custom board definition */ |
| 70 | +#define CONSOLE_SERIAL Serial /* console serial port for info & debug messages */ |
| 71 | +#define CLIENT_SERIAL Serial1 /* client serial port for incoming AT commands */ |
| 72 | +#define REMAP_UART_PINS 0 /* 0=use default TX/RX pin mappings, 1=remap to alternate pins */ |
| 73 | +#define HAS_LED_BUILTIN 0 /* 0=board does not have LED_BUILT_IN, 1=has LED_BUILTIN */ |
| 74 | +#else |
| 75 | + /* Default settings if no pre-defined board selected */ |
| 76 | +#define CONSOLE_SERIAL Serial /* console serial port for info & debug messages */ |
| 77 | +#define CLIENT_SERIAL Serial1 /* client serial port for incoming AT commands */ |
28 | 78 | #define REMAP_UART_PINS 0 /* 0=use default TX/RX pin mappings, 1=remap to alternate pins */
|
29 | 79 | #define HAS_LED_BUILTIN 0 /* 0=board does not have LED_BUILT_IN, 1=has LED_BUILTIN */
|
| 80 | +#endif |
| 81 | + |
30 | 82 | /* Defaults on Adafruit HUZZAH32 ESP32 Feather:
|
31 | 83 | * Serial RX & TX are mapped to USB-to-Serial converter.
|
32 |
| - * Serial1 RX is mapped to GPIO16 = chip pin 27 (IO16) = JP3-3 (RX), |
33 |
| - * Serial1 TX is mapped to GPIO17 = chip pin 28 (IO17) = JP3-2 (TX). |
| 84 | + * Serial1 RX is mapped to GPIO16 = chip pin 27 (IO16) = JP1-3 (RX), |
| 85 | + * Serial1 TX is mapped to GPIO17 = chip pin 28 (IO17) = JP1-2 (TX). |
34 | 86 | * For HUZZAH32 use CONSOLE_SERIAL=Serial, CLIENT_SERIAL=Serial1, REMAP_UART_PINS=0, and HAS_LED_BUILTIN=1.
|
35 | 87 | * Defaults on ESP32 DevKitC:
|
36 | 88 | * Serial RX & TX are mapped to USB-to-Serial converter
|
|
48 | 100 | * For Mikro WiFi BLE Click use CONSOLE_SERIAL=Serial, CLIENT_SERIAL=Serial2, REMAP_UART_PINS=0,
|
49 | 101 | * and HAS_LED_BUILTIN=0.
|
50 | 102 | */
|
51 |
| -#if defined(REMAP_UART_PINS) && REMAP_UART_PINS == 1 |
52 |
| -/* Optional serial RX & TX port pin remapping used with CLIENT_SERIAL. */ |
53 |
| -#define CLIENT_SERIAL_RX_GPIO 4 /* GPIO4 = chip pin 26 = IO4 = J3-13 on DevKitC */ |
54 |
| -#define CLIENT_SERIAL_TX_GPIO 2 /* GPIO2 = chip pin 24 = IO2 = J3-15 on DevKitC */ |
55 |
| -#endif |
| 103 | + |
56 | 104 | /* Serial data rates */
|
57 | 105 | #define CONSOLE_SERIAL_BAUD 115200
|
58 | 106 | #define CLIENT_SERIAL_BAUD 115200
|
|
0 commit comments