Skip to content

Commit d7bca83

Browse files
authored
feat(hwcdc): adjusts APIs
Fixes the example to use the new added APIs for checking if USB cable is plugged and for checking if CDC is connected.
1 parent a0eb4c0 commit d7bca83

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

Diff for: libraries/ESP32/examples/HWSerial_Events/HWSerial_Events.ino

+4-10
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ void loop(){}
2424
HWCDC HWCDCSerial;
2525
#endif
2626

27-
#include "driver/usb_serial_jtag.h"
28-
2927
// USB Event Callback Function that will log CDC events into UART0
3028
static void usbEventCallback(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data) {
3129
if (event_base == ARDUINO_HW_CDC_EVENTS) {
@@ -51,20 +49,16 @@ static void usbEventCallback(void* arg, esp_event_base_t event_base, int32_t eve
5149
}
5250
}
5351

54-
bool isPlugged() {
55-
return usb_serial_jtag_is_connected();
56-
}
57-
5852
const char* _hwcdc_status[] = {
59-
" USB Plugged but CDC is not connected\r\n",
53+
" USB Plugged but CDC is NOT connected\r\n",
6054
" USB Plugged and CDC is connected\r\n",
61-
" USB Unplugged and CDC not connected\r\n",
55+
" USB Unplugged and CDC NOT connected\r\n",
6256
" USB Unplugged BUT CDC is connected :: PROBLEM\r\n",
6357
};
6458

6559
const char* HWCDC_Status() {
66-
int i = isPlugged() ? 0 : 2;
67-
if(HWCDCSerial) i += 1;
60+
int i = HWCDCSerial.isPlugged() ? 0 : 2;
61+
if(HWCDCSerial.isConnected()) i += 1;
6862
return _hwcdc_status[i];
6963
}
7064

0 commit comments

Comments
 (0)