34 hasPassword_ = cfg.
password !=
nullptr;
37 if (
TWD_LOGGER.enabled() && statsIntervalMs_) {
38 if (xTaskCreate(&Esp32Dongle::statsTask,
"dongleStats", 6144,
this, 10,
nullptr) != pdPASS) {
39 TWD_LOGGER.warning(
"status line: could not start its task");
42 TWD_LOGGER.info(
"starting: ssid='%s'", ssid_.c_str());
46 usb_.setHostMac(link_.macAddress());
47 if (!usb_.begin(product_.c_str()))
return false;
49 if (!link_.begin(ssid_.c_str(), hasPassword_ ? password_.c_str() :
nullptr))
return false;
52 USB.productName(product_.c_str());
57 if (cfg.
pinUsbTask && !usbPin_.begin(xPortGetCoreID())) {
58 TWD_LOGGER.warning(
"USB: could not start the task that pins the USB task; send stalls are more likely");
74 String ssid_, password_, product_;
75 bool hasPassword_ =
false;
76 uint32_t statsIntervalMs_ = 0;
78 static void statsTask(
void* arg) {
81 vTaskDelay(pdMS_TO_TICKS(s->statsIntervalMs_));
86 Esp32UsbNcm::Stats u = s->usb_.
stats();
87 L2Bridge::Stats b = s->bridge_.
stats();
89 TWD_LOGGER.info(
"w%d toL=%u toH=%u rf=%u dr=%u | u rx=%u tx=%u td=%u bz=%u q=%u rs=%u", (
int)s->link_.
connected(),
90 (
unsigned)b.toLink, (
unsigned)b.toHost, (
unsigned)b.reflected, (
unsigned)b.dropped,
91 (
unsigned)u.rxFrames, (
unsigned)u.txFrames, (
unsigned)u.txDrops, (
unsigned)u.txBusy,
92 (
unsigned)s->usb_.
txQueued(), (
unsigned)u.resets);
static twd::LoggerClass TWD_LOGGER
The logger used by all components; configure it in the sketch with TWD_LOGGER.begin(Serial).
ESP32-S2/S3 dongle: raw Ethernet frames between USB and WiFi.
bool begin(const TinyWifiDongleConfig &cfg)
Start USB and WiFi and bridge them; false if a part could not be started.
bool uplinkConnected()
True while the MCU is associated with the access point.
bool usbReady()
True once the USB host has configured the adapter.
USB CDC-NCM network device for the ESP32-S2/S3 (TinyUSB).
void logControllerState()
uint32_t txQueued() const
Number of frames waiting to be sent to the host.
Stats stats() const
Current counters.
Runs the TinyUSB device task on one fixed CPU core.
Raw Ethernet access to the WiFi network through the ESP32's station.
bool connected() override
True while associated with the access point (the MCU has no IP address).
Layer-2 bridge between the USB host and the uplink network.
Stats stats() const
Current counters.
Settings of the dongle; every field has a usable default except the SSID.
const char * productName
USB product string shown on the host.
const char * password
Password of the network (nullptr for an open network).
const char * ssid
WiFi network the MCU joins (the "uplink").