October 14, 2024, 08:09:49 AM

OLIMEX Gateway Eth Ble

Started by LoxSimi, April 24, 2020, 06:01:18 PM

Previous topic - Next topic

LoxSimi

Hello!
Eth connection is established successfully and if
ble advertising or search is launched you will be constantly disconnected.
Why is that?

ETH Connected
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 25 - MAX
[D][WiFiGeneric.cpp:421] _eventCallback(): ETH IP: 192.168.100.66, MASK: 255.255.255.0, GW: 192.168.100.1
D, FULL_DUPLEX, 100Mbps
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 24 - ETH_GOT_IP
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 23 - ETH_DISCONNECTED
ETH Connected
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 25 - MAX
[D][WiFiGeneric.cpp:421] _eventCallback(): ETH IP: 192.168.100.66, MASK: 255.255.255.0, GW: 192.168.100.1
, IPv4: 192.168.100.66, FULL_DUPLEX, 100Mbps
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 24 - ETH_GOT_IP
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 23 - ETH_DISCONNECTED
ETH Connected
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 25 - MAX
[D][WiFiGeneric.cpp:421] _eventCallback(): ETH IP: 192.168.100.66, MASK: 255.255.255.0, GW: 192.168.100.1
, IPv4: 192.168.100.66, FULL_DUPLEX, 100Mbps

JohnS

Imagine someone wanted to reproduce it.  What (in proper detail) would they need?

I hope you already are using software that is not out of date as I see several issues that sound similar about espressif...

John

LoxSimi

I use the latest versions. I added sample code. Search for BLE devices forwarded..
But if the search goes to eth connect, disconnect continuously.


#define ETH_CLK_MODE ETH_CLOCK_GPIO17_OUT
#define ETH_PHY_POWER 12

#include <ETH.h>
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEScan.h>
#include <BLEAdvertisedDevice.h>
 
BLEScan *pBLEScan;
static bool eth_connected = false;

class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
    void onResult(BLEAdvertisedDevice advertisedDevice) {
      //Serial.printf("Advertised Device: %s \n", advertisedDevice.toString().c_str());
    }
};

void WiFiEvent(WiFiEvent_t event)
{
  switch (event) {
    case SYSTEM_EVENT_ETH_START:
      Serial.println("ETH Started");
      //set eth hostname here
      ETH.setHostname("esp32-ethernet");
      break;
    case SYSTEM_EVENT_ETH_CONNECTED:
      Serial.println("ETH Connected");
      break;
    case SYSTEM_EVENT_ETH_GOT_IP:
      Serial.print("ETH MAC: ");
      Serial.print(ETH.macAddress());
      Serial.print(", IPv4: ");
      Serial.print(ETH.localIP());
      if (ETH.fullDuplex()) {
        Serial.print(", FULL_DUPLEX");
      }
      Serial.print(", ");
      Serial.print(ETH.linkSpeed());
      Serial.println("Mbps");
      eth_connected = true;
      break;
    case SYSTEM_EVENT_ETH_DISCONNECTED:
      Serial.println("ETH Disconnected");
      eth_connected = false;
      break;
    case SYSTEM_EVENT_ETH_STOP:
      Serial.println("ETH Stopped");
      eth_connected = false;
      break;
    default:
      break;
  }
}


void setup()
{
  Serial.begin(115200);
  WiFi.onEvent(WiFiEvent);
  ETH.begin();

  pBLEScan = BLEDevice::getScan(); //create new scan
  pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
  pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
  pBLEScan->setInterval(100);
  pBLEScan->setWindow(99);  // less or equal setInterval value
 
}


void loop(){
  // put your main code here, to run repeatedly:
  BLEScanResults foundDevices = pBLEScan->start(10, false);
  Serial.print("Devices found: ");
  Serial.println(foundDevices.getCount());
  Serial.println("Scan done!");
  pBLEScan->clearResults();   // delete results fromBLEScan buffer to release memory
  delay(2000);
 
}

LubOlimex

Ethernet and BLE should be capable of running together so I think the module runs out of memory when running Ethernet and Bluetooth. Some adjustments of the libraries might be needed.I'd recommend posting the Arduino IDE GitHub page for this issue.

Please notice that this is not the case if you want to run WIFI and BT - they share a radio so some time-sharing applies: https://esp32.com/viewtopic.php?t=6707 - despite that I've seen people use WIFI + BT on ESP32 successfully.
Technical support and documentation manager at Olimex