Guys, I found out that BLEDevice::init() will crash with ETH.begin(). If I call them separately, both works well. But whenever I try to use both ethernet and BLE, that 2 functions will keep on reset my board.
Does anyone met the same issue previously? To reproduce the issue, try the code below:
#include <ETH.h>
#include <WiFi.h>
#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <BLE2902.h>
/*
* ETH_CLOCK_GPIO0_IN - default: external clock from crystal oscillator
* ETH_CLOCK_GPIO0_OUT - 50MHz clock from internal APLL output on GPIO0 - possibly an inverter is needed for LAN8720
* ETH_CLOCK_GPIO16_OUT - 50MHz clock from internal APLL output on GPIO16 - possibly an inverter is needed for LAN8720
* ETH_CLOCK_GPIO17_OUT - 50MHz clock from internal APLL inverted output on GPIO17 - tested with LAN8720
*/
#define ETH_CLK_MODE ETH_CLOCK_GPIO17_OUT
// Pin# of the enable signal for the external crystal oscillator (-1 to disable for internal APLL source)
#define ETH_POWER_PIN 16 // GPIO16, HS1_DATA4, U2RXD, EMAC_CLK_OUT
// Type of the Ethernet PHY (LAN8720 or TLK110)
#define ETH_TYPE ETH_PHY_LAN8720
// I²C-address of Ethernet PHY (0 or 1 for LAN8720, 31 for TLK110)
#define ETH_ADDR 1
// Pin# of the I²C clock signal for the Ethernet PHY
#define ETH_MDC_PIN 23 // GPIO23, VSPID, HS1_STROBE
// Pin# of the I²C IO signal for the Ethernet PHY
#define ETH_MDIO_PIN 18 // GPIO18, VSPICLK, HS1_DATA7
void setup()
{
Serial.begin(115200);
// Create and name the BLE Device
BLEDevice::init("DEVICE_NAME");
Serial.println("DEBUG_1"); // DEBUG
ETH.begin(ETH_ADDR, ETH_POWER_PIN, ETH_MDC_PIN, ETH_MDIO_PIN, ETH_TYPE, ETH_CLK_MODE);
Serial.println("DEBUG_2"); // DEBUG
}
void loop()
{}
We will see the board keep getting reset, but if we comment out the ETH.begin(), it will work.