Skip to content

Commit f9d882f

Browse files
authored
Merge branch 'master' into idf-release/v3.3
2 parents 8c7f261 + bd41334 commit f9d882f

File tree

14 files changed

+93
-24
lines changed

14 files changed

+93
-24
lines changed

.github/scripts/on-pages.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,15 @@ function git_safe_upload_to_pages(){
8787

8888
EVENT_JSON=`cat $GITHUB_EVENT_PATH`
8989

90+
echo "GITHUB_EVENT_PATH: $GITHUB_EVENT_PATH"
91+
echo "EVENT_JSON: $EVENT_JSON"
92+
9093
pages_added=`echo "$EVENT_JSON" | jq -r '.commits[].added[]'`
94+
echo "added: $pages_added"
9195
pages_modified=`echo "$EVENT_JSON" | jq -r '.commits[].modified[]'`
96+
echo "modified: $pages_modified"
9297
pages_removed=`echo "$EVENT_JSON" | jq -r '.commits[].removed[]'`
98+
echo "removed: $pages_removed"
9399

94100
for page in $pages_added; do
95101
if [[ $page != "README.md" && $page != "docs/"* ]]; then

.github/workflows/gh-pages.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ on:
44
push:
55
branches:
66
- master
7+
- pages
78
paths:
89
- 'README.md'
910
- 'docs/**'
11+
- '.github/scripts/on-pages.sh'
12+
- '.github/workflows/gh-pages.yml'
1013

1114
jobs:
1215

cores/esp32/esp32-hal-spi.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -914,8 +914,20 @@ void spiTransferBytesNL(spi_t * spi, const void * data_in, uint8_t * data_out, u
914914
spi->dev->cmd.usr = 1;
915915
while(spi->dev->cmd.usr);
916916
if(result){
917-
for (int i=0; i<c_longs; i++) {
918-
result[i] = spi->dev->data_buf[i];
917+
if(c_len & 3){
918+
for (int i=0; i<(c_longs-1); i++) {
919+
result[i] = spi->dev->data_buf[i];
920+
}
921+
uint32_t last_data = spi->dev->data_buf[c_longs-1];
922+
uint8_t * last_out8 = &result[c_longs-1];
923+
uint8_t * last_data8 = &last_data;
924+
for (int i=0; i<(c_len & 3); i++) {
925+
last_out8[i] = last_data8[i];
926+
}
927+
} else {
928+
for (int i=0; i<c_longs; i++) {
929+
result[i] = spi->dev->data_buf[i];
930+
}
919931
}
920932
}
921933
if(data){

docs/arduino-ide/debian_ubuntu.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Installation instructions for Debian / Ubuntu OS
88
sudo usermod -a -G dialout $USER && \
99
sudo apt-get install git && \
1010
wget https://bootstrap.pypa.io/get-pip.py && \
11-
sudo python get-pip.py && \
12-
sudo pip install pyserial && \
11+
sudo python3 get-pip.py && \
12+
sudo pip3 install pyserial && \
1313
mkdir -p ~/Arduino/hardware/espressif && \
1414
cd ~/Arduino/hardware/espressif && \
1515
git clone https://github.com/espressif/arduino-esp32.git esp32 && \

libraries/BLE/src/BLEAdvertising.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ void BLEAdvertising::setAdvertisementType(esp_ble_adv_type_t adv_type){
9191
m_advParams.adv_type = adv_type;
9292
} // setAdvertisementType
9393

94+
void BLEAdvertising::setAdvertisementChannelMap(esp_ble_adv_channel_t channel_map) {
95+
m_advParams.channel_map = channel_map;
96+
} // setAdvertisementChannelMap
97+
9498
void BLEAdvertising::setMinInterval(uint16_t mininterval) {
9599
m_advParams.adv_int_min = mininterval;
96100
} // setMinInterval

libraries/BLE/src/BLEAdvertising.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class BLEAdvertising {
5353
void stop();
5454
void setAppearance(uint16_t appearance);
5555
void setAdvertisementType(esp_ble_adv_type_t adv_type);
56+
void setAdvertisementChannelMap(esp_ble_adv_channel_t channel_map);
5657
void setMaxInterval(uint16_t maxinterval);
5758
void setMinInterval(uint16_t mininterval);
5859
void setAdvertisementData(BLEAdvertisementData& advertisementData);

libraries/BLE/src/BLERemoteCharacteristic.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ void BLERemoteCharacteristic::gattClientEventHandler(esp_gattc_cb_event_t event,
246246
}
247247
break;
248248

249+
case ESP_GATTC_DISCONNECT_EVT:
250+
m_semaphoreWriteCharEvt.give(1);
251+
break;
252+
249253
default:
250254
break;
251255
} // End switch

libraries/BluetoothSerial/src/BluetoothSerial.cpp

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ const char * _spp_server_name = "ESP32SPP";
4242

4343
#define RX_QUEUE_SIZE 512
4444
#define TX_QUEUE_SIZE 32
45+
#define SPP_TX_QUEUE_TIMEOUT 1000
46+
#define SPP_TX_DONE_TIMEOUT 1000
47+
#define SPP_CONGESTED_TIMEOUT 1000
48+
4549
static uint32_t _spp_client = 0;
4650
static xQueueHandle _spp_rx_queue = NULL;
4751
static xQueueHandle _spp_tx_queue = NULL;
@@ -143,7 +147,7 @@ static esp_err_t _spp_queue_packet(uint8_t *data, size_t len){
143147
}
144148
packet->len = len;
145149
memcpy(packet->data, data, len);
146-
if (xQueueSend(_spp_tx_queue, &packet, portMAX_DELAY) != pdPASS) {
150+
if (!_spp_tx_queue || xQueueSend(_spp_tx_queue, &packet, SPP_TX_QUEUE_TIMEOUT) != pdPASS) {
147151
log_e("SPP TX Queue Send Failed!");
148152
free(packet);
149153
return ESP_FAIL;
@@ -156,19 +160,25 @@ static uint8_t _spp_tx_buffer[SPP_TX_MAX];
156160
static uint16_t _spp_tx_buffer_len = 0;
157161

158162
static bool _spp_send_buffer(){
159-
if((xEventGroupWaitBits(_spp_event_group, SPP_CONGESTED, pdFALSE, pdTRUE, portMAX_DELAY) & SPP_CONGESTED) != 0){
163+
if((xEventGroupWaitBits(_spp_event_group, SPP_CONGESTED, pdFALSE, pdTRUE, SPP_CONGESTED_TIMEOUT) & SPP_CONGESTED) != 0){
164+
if(!_spp_client){
165+
log_v("SPP Client Gone!");
166+
return false;
167+
}
168+
log_v("SPP Write %u", _spp_tx_buffer_len);
160169
esp_err_t err = esp_spp_write(_spp_client, _spp_tx_buffer_len, _spp_tx_buffer);
161170
if(err != ESP_OK){
162171
log_e("SPP Write Failed! [0x%X]", err);
163172
return false;
164173
}
165174
_spp_tx_buffer_len = 0;
166-
if(xSemaphoreTake(_spp_tx_done, portMAX_DELAY) != pdTRUE){
175+
if(xSemaphoreTake(_spp_tx_done, SPP_TX_DONE_TIMEOUT) != pdTRUE){
167176
log_e("SPP Ack Failed!");
168177
return false;
169178
}
170179
return true;
171180
}
181+
log_e("SPP Write Congested!");
172182
return false;
173183
}
174184

@@ -194,13 +204,18 @@ static void _spp_tx_task(void * arg){
194204
_spp_tx_buffer_len = SPP_TX_MAX;
195205
data += to_send;
196206
len -= to_send;
197-
_spp_send_buffer();
207+
if(!_spp_send_buffer()){
208+
len = 0;
209+
}
198210
while(len >= SPP_TX_MAX){
199211
memcpy(_spp_tx_buffer, data, SPP_TX_MAX);
200212
_spp_tx_buffer_len = SPP_TX_MAX;
201213
data += SPP_TX_MAX;
202214
len -= SPP_TX_MAX;
203-
_spp_send_buffer();
215+
if(!_spp_send_buffer()){
216+
len = 0;
217+
break;
218+
}
204219
}
205220
if(len){
206221
memcpy(_spp_tx_buffer, data, len);
@@ -236,9 +251,10 @@ static void esp_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param)
236251

237252
case ESP_SPP_SRV_OPEN_EVT://Server connection open
238253
if (param->srv_open.status == ESP_SPP_SUCCESS) {
239-
log_i("ESP_SPP_SRV_OPEN_EVT");
254+
log_i("ESP_SPP_SRV_OPEN_EVT: %u", _spp_client);
240255
if (!_spp_client){
241256
_spp_client = param->srv_open.handle;
257+
_spp_tx_buffer_len = 0;
242258
} else {
243259
secondConnectionAttempt = true;
244260
esp_spp_disconnect(param->srv_open.handle);
@@ -252,12 +268,13 @@ static void esp_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param)
252268

253269
case ESP_SPP_CLOSE_EVT://Client connection closed
254270
if ((param->close.async == false && param->close.status == ESP_SPP_SUCCESS) || param->close.async) {
255-
log_i("ESP_SPP_CLOSE_EVT");
271+
log_i("ESP_SPP_CLOSE_EVT: %u", secondConnectionAttempt);
256272
if(secondConnectionAttempt) {
257273
secondConnectionAttempt = false;
258274
} else {
259275
_spp_client = 0;
260276
xEventGroupSetBits(_spp_event_group, SPP_DISCONNECTED);
277+
xEventGroupSetBits(_spp_event_group, SPP_CONGESTED);
261278
}
262279
xEventGroupClearBits(_spp_event_group, SPP_CONNECTED);
263280
} else {
@@ -279,11 +296,11 @@ static void esp_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param)
279296
if(param->write.cong){
280297
xEventGroupClearBits(_spp_event_group, SPP_CONGESTED);
281298
}
282-
xSemaphoreGive(_spp_tx_done);//we can try to send another packet
283299
log_v("ESP_SPP_WRITE_EVT: %u %s", param->write.len, param->write.cong?"CONGESTED":"");
284300
} else {
285301
log_e("ESP_SPP_WRITE_EVT failed!, status:%d", param->write.status);
286302
}
303+
xSemaphoreGive(_spp_tx_done);//we can try to send another packet
287304
break;
288305

289306
case ESP_SPP_DATA_IND_EVT://connection received data
@@ -323,6 +340,7 @@ static void esp_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param)
323340
}
324341
xEventGroupClearBits(_spp_event_group, SPP_DISCONNECTED);
325342
xEventGroupSetBits(_spp_event_group, SPP_CONNECTED);
343+
xEventGroupSetBits(_spp_event_group, SPP_CONGESTED);
326344
break;
327345

328346
case ESP_SPP_START_EVT://server started
@@ -693,7 +711,7 @@ void BluetoothSerial::flush()
693711
{
694712
if (_spp_tx_queue != NULL){
695713
while(uxQueueMessagesWaiting(_spp_tx_queue) > 0){
696-
delay(5);
714+
delay(100);
697715
}
698716
}
699717
}

libraries/HTTPClient/src/HTTPClient.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ HTTPClient::~HTTPClient()
109109
if(_currentHeaders) {
110110
delete[] _currentHeaders;
111111
}
112+
if(_tcpDeprecated) {
113+
_tcpDeprecated.reset(nullptr);
114+
}
115+
if(_transportTraits) {
116+
_transportTraits.reset(nullptr);
117+
}
112118
}
113119

114120
void HTTPClient::clear()
@@ -284,7 +290,7 @@ bool HTTPClient::beginInternal(String url, const char* expectedProtocol)
284290
}
285291
_host = the_host;
286292
_uri = url;
287-
log_d("host: %s port: %d url: %s", _host.c_str(), _port, _uri.c_str());
293+
log_d("protocol: %s, host: %s port: %d url: %s", _protocol.c_str(), _host.c_str(), _port, _uri.c_str());
288294
return true;
289295
}
290296

@@ -376,19 +382,19 @@ void HTTPClient::disconnect(bool preserveClient)
376382
}
377383

378384
if(_reuse && _canReuse) {
379-
log_d("tcp keep open for reuse\n");
385+
log_d("tcp keep open for reuse");
380386
} else {
381-
log_d("tcp stop\n");
387+
log_d("tcp stop");
382388
_client->stop();
383389
if(!preserveClient) {
384390
_client = nullptr;
385-
}
386391
#ifdef HTTPCLIENT_1_1_COMPATIBLE
387-
if(_tcpDeprecated) {
388-
_transportTraits.reset(nullptr);
389-
_tcpDeprecated.reset(nullptr);
390-
}
392+
if(_tcpDeprecated) {
393+
_transportTraits.reset(nullptr);
394+
_tcpDeprecated.reset(nullptr);
395+
}
391396
#endif
397+
}
392398
}
393399
} else {
394400
log_d("tcp is closed\n");

libraries/HTTPUpdate/src/HTTPUpdate.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@
3535
HTTPUpdate::HTTPUpdate(void)
3636
: _httpClientTimeout(8000), _ledPin(-1)
3737
{
38+
_followRedirects = HTTPC_DISABLE_FOLLOW_REDIRECTS;
3839
}
3940

4041
HTTPUpdate::HTTPUpdate(int httpClientTimeout)
4142
: _httpClientTimeout(httpClientTimeout), _ledPin(-1)
4243
{
44+
_followRedirects = HTTPC_DISABLE_FOLLOW_REDIRECTS;
4345
}
4446

4547
HTTPUpdate::~HTTPUpdate(void)
@@ -175,6 +177,7 @@ HTTPUpdateResult HTTPUpdate::handleUpdate(HTTPClient& http, const String& curren
175177
// use HTTP/1.0 for update since the update handler not support any transfer Encoding
176178
http.useHTTP10(true);
177179
http.setTimeout(_httpClientTimeout);
180+
http.setFollowRedirects(_followRedirects);
178181
http.setUserAgent("ESP32-http-Update");
179182
http.addHeader("Cache-Control", "no-cache");
180183
http.addHeader("x-ESP32-STA-MAC", WiFi.macAddress());

libraries/HTTPUpdate/src/HTTPUpdate.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ class HTTPUpdate
6363
{
6464
_rebootOnUpdate = reboot;
6565
}
66+
67+
/**
68+
* set redirect follow mode. See `followRedirects_t` enum for avaliable modes.
69+
* @param follow
70+
*/
71+
void setFollowRedirects(followRedirects_t follow)
72+
{
73+
_followRedirects = follow;
74+
}
6675

6776
void setLedPin(int ledPin = -1, uint8_t ledOn = HIGH)
6877
{
@@ -89,6 +98,7 @@ class HTTPUpdate
8998
bool _rebootOnUpdate = true;
9099
private:
91100
int _httpClientTimeout;
101+
followRedirects_t _followRedirects;
92102

93103
int _ledPin;
94104
uint8_t _ledOn;

libraries/WiFi/src/ETH.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ bool ETHClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, I
118118
esp_err_t err = ESP_OK;
119119
tcpip_adapter_ip_info_t info;
120120

121-
if(local_ip != (uint32_t)0x00000000){
121+
if(local_ip != (uint32_t)0x00000000 && local_ip != INADDR_NONE){
122122
info.ip.addr = static_cast<uint32_t>(local_ip);
123123
info.gw.addr = static_cast<uint32_t>(gateway);
124124
info.netmask.addr = static_cast<uint32_t>(subnet);
@@ -153,13 +153,13 @@ bool ETHClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, I
153153
ip_addr_t d;
154154
d.type = IPADDR_TYPE_V4;
155155

156-
if(dns1 != (uint32_t)0x00000000) {
156+
if(dns1 != (uint32_t)0x00000000 && dns1 != INADDR_NONE) {
157157
// Set DNS1-Server
158158
d.u_addr.ip4.addr = static_cast<uint32_t>(dns1);
159159
dns_setserver(0, &d);
160160
}
161161

162-
if(dns2 != (uint32_t)0x00000000) {
162+
if(dns2 != (uint32_t)0x00000000 && dns2 != INADDR_NONE) {
163163
// Set DNS2-Server
164164
d.u_addr.ip4.addr = static_cast<uint32_t>(dns2);
165165
dns_setserver(1, &d);

libraries/WiFi/src/WiFiSTA.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ wl_status_t WiFiSTAClass::begin(const char* ssid, const char *passphrase, int32_
134134
wifi_config_t conf;
135135
memset(&conf, 0, sizeof(wifi_config_t));
136136
strcpy(reinterpret_cast<char*>(conf.sta.ssid), ssid);
137+
conf.sta.scan_method = WIFI_ALL_CHANNEL_SCAN; //force full scan to be able to choose the nearest / strongest AP
137138

138139
if(passphrase) {
139140
if (strlen(passphrase) == 64){ // it's not a passphrase, is the PSK

libraries/WiFi/src/WiFiSTA.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class WiFiSTAClass
7474

7575
const char * getHostname();
7676
bool setHostname(const char * hostname);
77+
bool hostname(const String& aHostname) { return setHostname(aHostname.c_str()); }
7778

7879
// STA WiFi info
7980
static wl_status_t status();

0 commit comments

Comments
 (0)