Marijn78

Untitled

Aug 19th, 2020 (edited)
132
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <ETH.h>
  2. static bool eth_connected = false;
  3. #include <BLEDevice.h>
  4. #include <BLEUtils.h>
  5. #include <BLEScan.h>
  6. #include <BLEAdvertisedDevice.h>
  7. BLEScan* pBLEScan;
  8.  
  9. void WiFiEvent(WiFiEvent_t event) {
  10.   switch (event) {
  11.     case SYSTEM_EVENT_ETH_START:
  12.       Serial.println("ETH Started");
  13.       //set eth hostname here
  14.       ETH.setHostname("esp32-ethernet");
  15.       break;
  16.     case SYSTEM_EVENT_ETH_CONNECTED:
  17.       Serial.println("ETH Connected");
  18.       break;
  19.     case SYSTEM_EVENT_ETH_GOT_IP:
  20.       Serial.print("ETH MAC: ");
  21.       Serial.print(ETH.macAddress());
  22.       Serial.print(", IPv4: ");
  23.       Serial.print(ETH.localIP());
  24.       if (ETH.fullDuplex()) {
  25.         Serial.print(", FULL_DUPLEX");
  26.       }
  27.       Serial.print(", ");
  28.       Serial.print(ETH.linkSpeed());
  29.       Serial.println("Mbps");
  30.       eth_connected = true;
  31.       break;
  32.     case SYSTEM_EVENT_ETH_DISCONNECTED:
  33.       Serial.println("ETH Disconnected");
  34.       eth_connected = false;
  35.       break;
  36.     case SYSTEM_EVENT_ETH_STOP:
  37.       Serial.println("ETH Stopped");
  38.       eth_connected = false;
  39.       break;
  40.     default:
  41.       break;
  42.   }
  43. }
  44.  
  45. void scanForBeacons() {
  46.   BLEDevice::init("");
  47. }
  48.  
  49. void setup() {
  50.   Serial.begin(115200);
  51.   WiFi.onEvent(WiFiEvent);
  52.   ETH.begin();
  53.   //scanForBeacons(); // <== introduces crashes..
  54. }
  55.  
  56. void loop() {
  57.  
  58. }
RAW Paste Data