Skip to content

Commit d1e7c92

Browse files
authored
Merge branch 'master' into master
2 parents fe1c366 + 8d1a845 commit d1e7c92

File tree

75 files changed

+1962
-112
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1962
-112
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
2. [ ] Please provide related links (*eg. Issue which will be closed by this Pull Request*)
66
3. [ ] Please **update relevant Documentation** if applicable
77
4. [ ] Please check [Contributing guide](https://docs.espressif.com/projects/arduino-esp32/en/latest/contributing.html)
8+
5. [ ] Please **confirm option to "Allow edits and access to secrets by maintainers"** when opening a Pull Request
89

910
*This entire section above can be deleted if all items are checked.*
1011

.github/scripts/tests_build.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ while [ ! -z "$1" ]; do
4646
shift
4747
done
4848

49-
source ${SCRIPTS_DIR}/install-arduino-ide.sh
49+
#source ${SCRIPTS_DIR}/install-arduino-ide.sh
50+
source ${SCRIPTS_DIR}/install-arduino-cli.sh
5051
source ${SCRIPTS_DIR}/install-arduino-core-esp32.sh
5152

5253
args="-ai $ARDUINO_IDE_PATH -au $ARDUINO_USR_PATH"

.github/workflows/boards.yml

+10
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ jobs:
4545
- name: Checkout repository
4646
uses: actions/checkout@v3
4747

48+
- name: Check if build.board is uppercase
49+
run: |
50+
board_name=$(echo ${{ matrix.fqbn }} | awk -F':' '{print $NF}')
51+
if grep -q "^$board_name.build.board=[A-Z0-9_]*$" boards.txt; then
52+
echo "$board_name.build.board is valid.";
53+
else
54+
echo "Error: $board_name.build.board is not uppercase!";
55+
exit 1;
56+
fi
57+
4858
- name: Compile sketch
4959
uses: P-R-O-C-H-Y/compile-sketches@main
5060
with:

.github/workflows/dangerjs.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: DangerJS Pull Request linter
2+
on:
3+
pull_request_target:
4+
types: [opened, edited, reopened, synchronize]
5+
6+
permissions:
7+
pull-requests: write
8+
contents: write
9+
10+
jobs:
11+
pull-request-style-linter:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Check out PR head
15+
uses: actions/checkout@v4
16+
with:
17+
ref: ${{ github.event.pull_request.head.sha }}
18+
19+
- name: DangerJS pull request linter
20+
uses: espressif/shared-github-dangerjs@v1
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ set(LIBRARY_SRCS
115115
libraries/Update/src/Updater.cpp
116116
libraries/Update/src/HttpsOTAUpdate.cpp
117117
libraries/USB/src/USBHID.cpp
118+
libraries/USB/src/USBMIDI.cpp
118119
libraries/USB/src/USBHIDMouse.cpp
119120
libraries/USB/src/USBHIDKeyboard.cpp
120121
libraries/USB/src/USBHIDGamepad.cpp

boards.txt

+9-7
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,8 @@ esp32c6.menu.PartitionScheme.custom.upload.maximum_size=16777216
430430

431431
esp32c6.menu.CPUFreq.160=160MHz (WiFi)
432432
esp32c6.menu.CPUFreq.160.build.f_cpu=160000000L
433+
esp32c6.menu.CPUFreq.120=120MHz (WiFi)
434+
esp32c6.menu.CPUFreq.120.build.f_cpu=120000000L
433435
esp32c6.menu.CPUFreq.80=80MHz (WiFi)
434436
esp32c6.menu.CPUFreq.80.build.f_cpu=80000000L
435437
esp32c6.menu.CPUFreq.40=40MHz
@@ -17110,7 +17112,7 @@ heltec_wifi_kit_32.build.target=esp32
1711017112
heltec_wifi_kit_32.build.mcu=esp32
1711117113
heltec_wifi_kit_32.build.core=esp32
1711217114
heltec_wifi_kit_32.build.variant=heltec_wifi_kit_32
17113-
heltec_wifi_kit_32.build.board=heltec_wifi_kit_32
17115+
heltec_wifi_kit_32.build.board=HELTEC_WIFI_KIT_32
1711417116

1711517117
heltec_wifi_kit_32.build.f_cpu=240000000L
1711617118
heltec_wifi_kit_32.build.flash_size=4MB
@@ -17199,7 +17201,7 @@ heltec_wifi_kit_32_V3.build.target=esp32s3
1719917201
heltec_wifi_kit_32_V3.build.mcu=esp32s3
1720017202
heltec_wifi_kit_32_V3.build.core=esp32
1720117203
heltec_wifi_kit_32_V3.build.variant=heltec_wifi_kit_32_V3
17202-
heltec_wifi_kit_32_V3.build.board=heltec_wifi_kit_32_V3
17204+
heltec_wifi_kit_32_V3.build.board=HELTEC_WIFI_KIT_32_V3
1720317205

1720417206
heltec_wifi_kit_32_V3.build.usb_mode=1
1720517207
heltec_wifi_kit_32_V3.build.cdc_on_boot=0
@@ -17298,7 +17300,7 @@ heltec_wifi_lora_32.build.target=esp32
1729817300
heltec_wifi_lora_32.build.mcu=esp32
1729917301
heltec_wifi_lora_32.build.core=esp32
1730017302
heltec_wifi_lora_32.build.variant=heltec_wifi_lora_32
17301-
heltec_wifi_lora_32.build.board=heltec_wifi_lora_32
17303+
heltec_wifi_lora_32.build.board=HELTEC_WIFI_LORA_32
1730217304

1730317305
heltec_wifi_lora_32.build.f_cpu=240000000L
1730417306
heltec_wifi_lora_32.build.flash_size=4MB
@@ -17435,7 +17437,7 @@ heltec_wifi_lora_32_V2.build.target=esp32
1743517437
heltec_wifi_lora_32_V2.build.mcu=esp32
1743617438
heltec_wifi_lora_32_V2.build.core=esp32
1743717439
heltec_wifi_lora_32_V2.build.variant=heltec_wifi_lora_32_V2
17438-
heltec_wifi_lora_32_V2.build.board=heltec_wifi_lora_32_V2
17440+
heltec_wifi_lora_32_V2.build.board=HELTEC_WIFI_LORA_32_V2
1743917441

1744017442
heltec_wifi_lora_32_V2.build.f_cpu=240000000L
1744117443
heltec_wifi_lora_32_V2.build.flash_size=8MB
@@ -17551,7 +17553,7 @@ heltec_wifi_lora_32_V3.build.target=esp32s3
1755117553
heltec_wifi_lora_32_V3.build.mcu=esp32s3
1755217554
heltec_wifi_lora_32_V3.build.core=esp32
1755317555
heltec_wifi_lora_32_V3.build.variant=heltec_wifi_lora_32_V3
17554-
heltec_wifi_lora_32_V3.build.board=heltec_wifi_32_lora_V3
17556+
heltec_wifi_lora_32_V3.build.board=HELTEC_WIFI_LORA_32_V3
1755517557

1755617558
heltec_wifi_lora_32_V3.build.usb_mode=1
1755717559
heltec_wifi_lora_32_V3.build.cdc_on_boot=0
@@ -17693,7 +17695,7 @@ heltec_wireless_stick.build.target=esp32
1769317695
heltec_wireless_stick.build.mcu=esp32
1769417696
heltec_wireless_stick.build.core=esp32
1769517697
heltec_wireless_stick.build.variant=heltec_wireless_stick
17696-
heltec_wireless_stick.build.board=heltec_wireless_stick
17698+
heltec_wireless_stick.build.board=HELTEC_WIRELESS_STICK
1769717699

1769817700
heltec_wireless_stick.build.f_cpu=240000000L
1769917701
heltec_wireless_stick.build.flash_size=8MB
@@ -17806,7 +17808,7 @@ heltec_wireless_stick_lite.build.target=esp32
1780617808
heltec_wireless_stick_lite.build.mcu=esp32
1780717809
heltec_wireless_stick_lite.build.core=esp32
1780817810
heltec_wireless_stick_lite.build.variant=heltec_wireless_stick_lite
17809-
heltec_wireless_stick_lite.build.board=heltec_wireless_stick_LITE
17811+
heltec_wireless_stick_lite.build.board=HELTEC_WIRELESS_STICK_LITE
1781017812

1781117813
heltec_wireless_stick_lite.build.f_cpu=240000000L
1781217814
heltec_wireless_stick_lite.build.flash_size=4MB

cores/esp32/esp32-hal-cpu.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,11 @@ bool setCpuFrequencyMhz(uint32_t cpu_freq_mhz){
188188
}
189189
#endif
190190
#ifndef CONFIG_IDF_TARGET_ESP32H2
191-
if(cpu_freq_mhz > xtal && cpu_freq_mhz != 240 && cpu_freq_mhz != 160 && cpu_freq_mhz != 80){
191+
if(cpu_freq_mhz > xtal && cpu_freq_mhz != 240 && cpu_freq_mhz != 160 && cpu_freq_mhz != 120 && cpu_freq_mhz != 80){
192192
if(xtal >= RTC_XTAL_FREQ_40M){
193-
log_e("Bad frequency: %u MHz! Options are: 240, 160, 80, %u, %u and %u MHz", cpu_freq_mhz, xtal, xtal/2, xtal/4);
193+
log_e("Bad frequency: %u MHz! Options are: 240, 160, 120, 80, %u, %u and %u MHz", cpu_freq_mhz, xtal, xtal/2, xtal/4);
194194
} else {
195-
log_e("Bad frequency: %u MHz! Options are: 240, 160, 80, %u and %u MHz", cpu_freq_mhz, xtal, xtal/2);
195+
log_e("Bad frequency: %u MHz! Options are: 240, 160, 120, 80, %u and %u MHz", cpu_freq_mhz, xtal, xtal/2);
196196
}
197197
return false;
198198
}

cores/esp32/esp32-hal-tinyusb.c

+12-1
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,11 @@ static void usb_device_task(void *param) {
678678
#endif
679679
static bool tinyusb_is_initialized = false;
680680

681-
esp_err_t tinyusb_enable_interface(tinyusb_interface_t interface, uint16_t descriptor_len, tinyusb_descriptor_cb_t cb)
681+
esp_err_t tinyusb_enable_interface(tinyusb_interface_t interface, uint16_t descriptor_len, tinyusb_descriptor_cb_t cb){
682+
return tinyusb_enable_interface2(interface, descriptor_len, cb, false);
683+
}
684+
685+
esp_err_t tinyusb_enable_interface2(tinyusb_interface_t interface, uint16_t descriptor_len, tinyusb_descriptor_cb_t cb, bool reserve_endpoints)
682686
{
683687
if(tinyusb_is_initialized){
684688
log_e("TinyUSB has already started! Interface %s not enabled", (interface >= USB_INTERFACE_MAX)?"":tinyusb_interface_names[interface]);
@@ -688,6 +692,13 @@ esp_err_t tinyusb_enable_interface(tinyusb_interface_t interface, uint16_t descr
688692
log_e("Interface %s invalid or already enabled", (interface >= USB_INTERFACE_MAX)?"":tinyusb_interface_names[interface]);
689693
return ESP_FAIL;
690694
}
695+
if(interface == USB_INTERFACE_HID && reserve_endpoints){
696+
// Some simple PC BIOS requires specific endpoint addresses for keyboard at boot
697+
if(!tinyusb_reserve_out_endpoint(1) ||!tinyusb_reserve_in_endpoint(1)){
698+
log_e("HID Reserve Endpoints Failed");
699+
return ESP_FAIL;
700+
}
701+
}
691702
if(interface == USB_INTERFACE_CDC){
692703
if(!tinyusb_reserve_out_endpoint(3) ||!tinyusb_reserve_in_endpoint(4) || !tinyusb_reserve_in_endpoint(5)){
693704
log_e("CDC Reserve Endpoints Failed");

cores/esp32/esp32-hal-tinyusb.h

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ typedef enum {
9797
typedef uint16_t (*tinyusb_descriptor_cb_t)(uint8_t * dst, uint8_t * itf);
9898

9999
esp_err_t tinyusb_enable_interface(tinyusb_interface_t interface, uint16_t descriptor_len, tinyusb_descriptor_cb_t cb);
100+
esp_err_t tinyusb_enable_interface2(tinyusb_interface_t interface, uint16_t descriptor_len, tinyusb_descriptor_cb_t cb, bool reserve_endpoints);
100101
uint8_t tinyusb_add_string_descriptor(const char * str);
101102
uint8_t tinyusb_get_free_duplex_endpoint(void);
102103
uint8_t tinyusb_get_free_in_endpoint(void);

docs/source/api/reset_reason.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ To get started with Reset Reason, you can try:
1515
Reset Reason
1616
************
1717

18-
.. literalinclude:: ../../../libraries/ESP32/examples/ResetReason/ResetReason.ino
19-
:language: arduino
18+
.. literalinclude:: ../../../libraries/ESP32/examples/ResetReason/ResetReason/ResetReason.ino
19+
:language: arduino

docs/source/api/wifi.rst

+106-3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,102 @@ Common API
5050

5151
Here are the common APIs that are used for both modes, AP and STA.
5252

53+
onEvent (and removeEvent)
54+
*************************
55+
56+
Registers a caller-supplied function to be called when WiFi events
57+
occur. Several forms are available.
58+
59+
Function pointer callback taking the event ID:
60+
61+
.. code-block:: arduino
62+
63+
typedef void (*WiFiEventCb)(arduino_event_id_t);
64+
wifi_event_id_t onEvent(WiFiEventCb, arduino_event_id_t = ARDUINO_EVENT_MAX);
65+
66+
Function pointer callback taking an event-ID-and-info struct:
67+
68+
.. code-block:: arduino
69+
70+
typedef struct{
71+
arduino_event_id_t event_id;
72+
arduino_event_info_t event_info;
73+
} arduino_event_t;
74+
75+
typedef void (*WiFiEventSysCb)(arduino_event_t *);
76+
wifi_event_id_t onEvent(WiFiEventSysCb, arduino_event_id_t = ARDUINO_EVENT_MAX);
77+
78+
Callback using ``std::function`` taking event ID and info separately:
79+
80+
.. code-block:: arduino
81+
82+
typedef std::function<void(arduino_event_id_t, arduino_event_info_t)> WiFiEventFuncCb;
83+
wifi_event_id_t onEvent(WiFiEventFuncCb, arduino_event_id_t = ARDUINO_EVENT_MAX);
84+
85+
A similar set of functions are available to remove callbacks:
86+
87+
.. code-block:: arduino
88+
89+
void removeEvent(WiFiEventCb, arduino_event_id_t = ARDUINO_EVENT_MAX);
90+
void removeEvent(WiFiEventSysCb, arduino_event_id_t = ARDUINO_EVENT_MAX);
91+
void removeEvent(wifi_event_id_t = ARDUINO_EVENT_MAX);
92+
93+
In all cases, the subscribing function accepts an optional event type to
94+
invoke the callback only for that specific event; with the default
95+
``ARDUINO_EVENT_MAX``, the callback will be invoked for all WiFi events.
96+
97+
Any callback function is given the event type in a parameter.
98+
Some of the possible callback function formats also take an
99+
``arduino_event_info_t`` (or use ``arduino_event_t`` which includes both
100+
ID and info) which is a union of structs with additional information
101+
about different event types.
102+
103+
See
104+
`WiFiGeneric.h <https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/src/WiFiGeneric.h>`_
105+
for the list of event types and "info" substructures, and also see a full
106+
example of event handling: `events example`_.
107+
108+
.. warning::
109+
110+
Event callback functions are invoked on a separate
111+
`thread <https://en.wikipedia.org/wiki/Thread_(computing)>`_
112+
(`FreeRTOS task <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/freertos_idf.html#tasks>`_)
113+
independent of the main application thread that runs ``setup()`` and
114+
``loop()``. Callback functions must therefore be
115+
`thread-safe <https://en.wikipedia.org/wiki/Thread_safety>`_;
116+
they must not access shared/global variables directly without locking,
117+
and must only call similarly thread-safe functions.
118+
119+
Some core operations like ``Serial.print()`` are thread-safe but many
120+
functions are not. Notably, ``WiFi.onEvent()`` and ``WiFi.removeEvent()``
121+
are not thread-safe and should never be invoked from a callback thread.
122+
123+
setHostname (and getHostname)
124+
*****************************
125+
126+
Sets the name the DHCP client uses to identify itself. In a typical network
127+
setup this will be the name that shows up in the Wi-Fi router's device list.
128+
The hostname must be no longer than 32 characters.
129+
130+
.. code-block:: arduino
131+
132+
setHostname(const char *hostname);
133+
134+
If the hostname is never specified, a default one will be assigned based
135+
on the chip type and MAC address. The current hostname (default or custom)
136+
may be retrieved:
137+
138+
.. code-block:: arduino
139+
140+
const char *getHostname();
141+
142+
.. warning::
143+
144+
The ``setHostname()`` function must be called BEFORE WiFi is started with
145+
``WiFi.begin()``, ``WiFi.softAP()``, ``WiFi.mode()``, or ``WiFi.run()``.
146+
To change the name, reset WiFi with ``WiFi.mode(WIFI_MODE_NULL)``,
147+
then proceed with ``WiFi.setHostname(...)`` and restart WiFi from scratch.
148+
53149
useStaticBuffers
54150
****************
55151

@@ -547,11 +643,13 @@ Loads all infos from a scanned wifi in to the ptr parameters.
547643
548644
bool getNetworkInfo(uint8_t networkItem, String &ssid, uint8_t &encryptionType, int32_t &RSSI, uint8_t* &BSSID, int32_t &channel);
549645
550-
To see how to use the ``WiFiScan``, take a look at the ``WiFiScan.ino`` example available.
646+
To see how to use the ``WiFiScan``, take a look at the ``WiFiScan.ino`` or ``WiFiScanAsync.ino`` example available.
551647

552648
Examples
553649
--------
554650

651+
`Complete list of WiFi examples <https://github.com/espressif/arduino-esp32/tree/master/libraries/WiFi/examples>`_.
652+
555653
.. _ap example:
556654

557655
Wi-Fi AP Example
@@ -568,5 +666,10 @@ Wi-Fi STA Example
568666
.. literalinclude:: ../../../libraries/WiFi/examples/WiFiClient/WiFiClient.ino
569667
:language: arduino
570668

571-
References
572-
----------
669+
.. _events example:
670+
671+
Wi-Fi Events Example
672+
********************
673+
674+
.. literalinclude:: ../../../libraries/WiFi/examples/WiFiClientEvents/WiFiClientEvents.ino
675+
:language: arduino

idf_component.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,5 @@ dependencies:
6666
rules:
6767
- if: "target in [esp32s3]"
6868
examples:
69-
- path: ../idf_component_examples/
69+
- path: idf_component_examples/
7070

libraries/BLE/src/BLERemoteCharacteristic.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -520,10 +520,9 @@ void BLERemoteCharacteristic::registerForNotify(notify_callback notifyCallback,
520520
void BLERemoteCharacteristic::removeDescriptors() {
521521
// Iterate through all the descriptors releasing their storage and erasing them from the map.
522522
for (auto &myPair : m_descriptorMap) {
523-
m_descriptorMap.erase(myPair.first);
524523
delete myPair.second;
525524
}
526-
m_descriptorMap.clear(); // Technically not neeeded, but just to be sure.
525+
m_descriptorMap.clear();
527526
} // removeCharacteristics
528527

529528

0 commit comments

Comments
 (0)