Skip to content

Commit aee11ba

Browse files
authored
Merge branch 'master' into master
2 parents 6ab100c + 8985a77 commit aee11ba

15 files changed

+395
-123
lines changed

boards.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16275,7 +16275,7 @@ m5stack-core2.build.f_cpu=240000000L
1627516275
m5stack-core2.build.flash_size=16MB
1627616276
m5stack-core2.build.flash_freq=80m
1627716277
m5stack-core2.build.flash_mode=dio
16278-
m5stack-core2.build.boot=dio
16278+
m5stack-core2.build.boot=qio
1627916279
m5stack-core2.build.partitions=default_16MB
1628016280
m5stack-core2.build.defines=
1628116281

cores/esp32/esp32-hal.h

-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ void yield(void);
8686
#include "esp32-hal-psram.h"
8787
#include "esp32-hal-rgb-led.h"
8888
#include "esp32-hal-cpu.h"
89-
#include "esp32-hal-periman.h"
9089

9190
void analogWrite(uint8_t pin, int value);
9291
void analogWriteFrequency(uint8_t pin, uint32_t freq);

cores/esp32/io_pin_remap.h

-10
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,6 @@ int8_t gpioNumberToDigitalPin(int8_t gpioNumber);
7171
#define pinMatrixOutAttach(pin, function, invertOut, invertEnable) pinMatrixOutAttach(digitalPinToGPIONumber(pin), function, invertOut, invertEnable)
7272
#define pinMatrixOutDetach(pin, invertOut, invertEnable) pinMatrixOutDetach(digitalPinToGPIONumber(pin), invertOut, invertEnable)
7373

74-
// cores/esp32/esp32-hal-periman.h
75-
#define perimanSetPinBus(pin, type, bus, bus_num, bus_channel) perimanSetPinBus(digitalPinToGPIONumber(pin), type, bus, bus_num, bus_channel)
76-
#define perimanGetPinBus(pin, type) perimanGetPinBus(digitalPinToGPIONumber(pin), type)
77-
#define perimanGetPinBusType(pin) perimanGetPinBusType(digitalPinToGPIONumber(pin))
78-
#define perimanGetPinBusNum(pin) perimanGetPinBusNum(digitalPinToGPIONumber(pin))
79-
#define perimanGetPinBusChannel(pin) perimanGetPinBusChannel(digitalPinToGPIONumber(pin))
80-
#define perimanPinIsValid(pin) perimanPinIsValid(digitalPinToGPIONumber(pin))
81-
#define perimanSetPinBusExtraType(pin, extra_type) perimanSetPinBusExtraType(digitalPinToGPIONumber(pin), extra_type)
82-
#define perimanGetPinBusExtraType(pin) perimanGetPinBusExtraType(digitalPinToGPIONumber(pin))
83-
8474
// cores/esp32/esp32-hal-rgb-led.h
8575
#define neopixelWrite(pin, red_val, green_val, blue_val) neopixelWrite(digitalPinToGPIONumber(pin), red_val, green_val, blue_val)
8676

libraries/BLE/src/BLEAdvertising.cpp

+35
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,41 @@ void BLEAdvertising::addServiceUUID(const char* serviceUUID) {
7979
} // addServiceUUID
8080

8181

82+
/**
83+
* @brief Remove a service uuid to exposed list of services.
84+
* @param [in] index The index of the service to stop exposing.
85+
*/
86+
bool BLEAdvertising::removeServiceUUID(int index) {
87+
88+
// If index is larger than the size of the
89+
// advertised services, return false
90+
if(index > m_serviceUUIDs.size()) return false;
91+
92+
m_serviceUUIDs.erase(m_serviceUUIDs.begin() + index);
93+
return true;
94+
}
95+
96+
/**
97+
* @brief Remove a service uuid to exposed list of services.
98+
* @param [in] serviceUUID The BLEUUID of the service to stop exposing.
99+
*/
100+
bool BLEAdvertising::removeServiceUUID(BLEUUID serviceUUID) {
101+
for(int i = 0; i < m_serviceUUIDs.size(); i++) {
102+
if(m_serviceUUIDs.at(i).equals(serviceUUID)) {
103+
return removeServiceUUID(i);
104+
}
105+
}
106+
return false;
107+
}
108+
109+
/**
110+
* @brief Remove a service uuid to exposed list of services.
111+
* @param [in] serviceUUID The string of the service to stop exposing.
112+
*/
113+
bool BLEAdvertising::removeServiceUUID(const char* serviceUUID) {
114+
return removeServiceUUID(BLEUUID(serviceUUID));
115+
}
116+
82117
/**
83118
* @brief Set the device appearance in the advertising data.
84119
* The appearance attribute is of type 0x19. The codes for distinct appearances can be found here:

libraries/BLE/src/BLEAdvertising.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ class BLEAdvertising {
5151
public:
5252
BLEAdvertising();
5353
void addServiceUUID(BLEUUID serviceUUID);
54-
void addServiceUUID(const char* serviceUUID);
54+
void addServiceUUID(const char* serviceUUID);
55+
bool removeServiceUUID(int index);
56+
bool removeServiceUUID(BLEUUID serviceUUID);
57+
bool removeServiceUUID(const char* serviceUUID);
5558
void start();
5659
void stop();
5760
void setAppearance(uint16_t appearance);

libraries/ESP_I2S/src/ESP_I2S.cpp

+10-8
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ void I2SClass::setInvertedPdm(bool clk){
281281
}
282282
#endif
283283

284-
bool I2SClass::initSTD(uint32_t rate, i2s_data_bit_width_t bits_cfg, i2s_slot_mode_t ch){
284+
bool I2SClass::initSTD(uint32_t rate, i2s_data_bit_width_t bits_cfg, i2s_slot_mode_t ch, int8_t slot_mask){
285285
// Peripheral manager deinit previous peripheral if pin was used
286286
if (_mclk >= 0) if (!perimanClearPinBus(_mclk)){ return false; }
287287
if (_bclk >= 0) if (!perimanClearPinBus(_bclk)){ return false; }
@@ -307,6 +307,9 @@ bool I2SClass::initSTD(uint32_t rate, i2s_data_bit_width_t bits_cfg, i2s_slot_mo
307307
}
308308

309309
i2s_std_config_t i2s_config = I2S_STD_CHAN_CFG(rate, bits_cfg, ch);
310+
if(slot_mask >= 0 && (i2s_std_slot_mask_t)slot_mask <= I2S_STD_SLOT_BOTH){
311+
i2s_config.slot_cfg.slot_mask = (i2s_std_slot_mask_t)slot_mask;
312+
}
310313
if (tx_chan != NULL) {
311314
tx_sample_rate = rate;
312315
tx_data_bit_width = bits_cfg;
@@ -475,11 +478,7 @@ bool I2SClass::initPDMrx(uint32_t rate, i2s_data_bit_width_t bits_cfg, i2s_slot_
475478
}
476479
#endif
477480

478-
bool I2SClass::begin(i2s_mode_t mode, uint32_t rate, i2s_data_bit_width_t bits_cfg, i2s_slot_mode_t ch
479-
#if SOC_I2S_SUPPORTS_TDM
480-
, int8_t slot_mask
481-
#endif
482-
){
481+
bool I2SClass::begin(i2s_mode_t mode, uint32_t rate, i2s_data_bit_width_t bits_cfg, i2s_slot_mode_t ch, int8_t slot_mask){
483482
/* Setup I2S peripheral */
484483
if (mode >= I2S_MODE_MAX){
485484
log_e("Invalid I2S mode selected.");
@@ -490,7 +489,7 @@ bool I2SClass::begin(i2s_mode_t mode, uint32_t rate, i2s_data_bit_width_t bits_c
490489
bool init = false;
491490
switch (_mode){
492491
case I2S_MODE_STD:
493-
init = initSTD(rate, bits_cfg, ch);
492+
init = initSTD(rate, bits_cfg, ch, slot_mask);
494493
break;
495494
#if SOC_I2S_SUPPORTS_TDM
496495
case I2S_MODE_TDM:
@@ -569,13 +568,16 @@ bool I2SClass::end(){
569568
return true;
570569
}
571570

572-
bool I2SClass::configureTX(uint32_t rate, i2s_data_bit_width_t bits_cfg, i2s_slot_mode_t ch){
571+
bool I2SClass::configureTX(uint32_t rate, i2s_data_bit_width_t bits_cfg, i2s_slot_mode_t ch, int8_t slot_mask){
573572
/* Setup I2S channels */
574573
if (tx_chan != NULL) {
575574
if(tx_sample_rate == rate && tx_data_bit_width == bits_cfg && tx_slot_mode == ch){
576575
return true;
577576
}
578577
i2s_std_config_t i2s_config = I2S_STD_CHAN_CFG(rate, bits_cfg, ch);
578+
if(slot_mask >= 0 && (i2s_std_slot_mask_t)slot_mask <= I2S_STD_SLOT_BOTH){
579+
i2s_config.slot_cfg.slot_mask = (i2s_std_slot_mask_t)slot_mask;
580+
}
579581
I2S_ERROR_CHECK_RETURN_FALSE(i2s_channel_disable(tx_chan));
580582
I2S_ERROR_CHECK_RETURN_FALSE(i2s_channel_reconfig_std_clock(tx_chan, &i2s_config.clk_cfg));
581583
tx_sample_rate = rate;

libraries/ESP_I2S/src/ESP_I2S.h

+3-7
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,8 @@ class I2SClass: public Stream {
5656
void setInvertedPdm(bool clk);
5757
#endif
5858

59-
bool begin(i2s_mode_t mode, uint32_t rate, i2s_data_bit_width_t bits_cfg, i2s_slot_mode_t ch
60-
#if SOC_I2S_SUPPORTS_TDM
61-
, int8_t slot_mask=-1
62-
#endif
63-
);
64-
bool configureTX(uint32_t rate, i2s_data_bit_width_t bits_cfg, i2s_slot_mode_t ch);
59+
bool begin(i2s_mode_t mode, uint32_t rate, i2s_data_bit_width_t bits_cfg, i2s_slot_mode_t ch, int8_t slot_mask=-1);
60+
bool configureTX(uint32_t rate, i2s_data_bit_width_t bits_cfg, i2s_slot_mode_t ch, int8_t slot_mask=-1);
6561
bool configureRX(uint32_t rate, i2s_data_bit_width_t bits_cfg, i2s_slot_mode_t ch, i2s_rx_transform_t transform=I2S_RX_TRANSFORM_NONE);
6662
bool end();
6763

@@ -130,7 +126,7 @@ class I2SClass: public Stream {
130126
bool transformRX(i2s_rx_transform_t transform);
131127

132128
static bool i2sDetachBus(void * bus_pointer);
133-
bool initSTD(uint32_t rate, i2s_data_bit_width_t bits_cfg, i2s_slot_mode_t ch);
129+
bool initSTD(uint32_t rate, i2s_data_bit_width_t bits_cfg, i2s_slot_mode_t ch, int8_t slot_mask);
134130
#if SOC_I2S_SUPPORTS_TDM
135131
bool initTDM(uint32_t rate, i2s_data_bit_width_t bits_cfg, i2s_slot_mode_t ch, int8_t slot_mask);
136132
#endif

libraries/HTTPUpdate/src/HTTPUpdate.cpp

+22-5
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,18 @@
3333
// To do extern "C" uint32_t _SPIFFS_end;
3434

3535
HTTPUpdate::HTTPUpdate(void)
36-
: _httpClientTimeout(8000), _ledPin(-1)
36+
: HTTPUpdate(8000)
3737
{
38-
_followRedirects = HTTPC_DISABLE_FOLLOW_REDIRECTS;
3938
}
4039

4140
HTTPUpdate::HTTPUpdate(int httpClientTimeout)
4241
: _httpClientTimeout(httpClientTimeout), _ledPin(-1)
4342
{
4443
_followRedirects = HTTPC_DISABLE_FOLLOW_REDIRECTS;
44+
_md5Sum = String();
45+
_user = String();
46+
_password = String();
47+
_auth = String();
4548
}
4649

4750
HTTPUpdate::~HTTPUpdate(void)
@@ -220,6 +223,14 @@ HTTPUpdateResult HTTPUpdate::handleUpdate(HTTPClient& http, const String& curren
220223
requestCB(&http);
221224
}
222225

226+
if (!_user.isEmpty() && !_password.isEmpty()) {
227+
http.setAuthorization(_user.c_str(), _password.c_str());
228+
}
229+
230+
if (!_auth.isEmpty()) {
231+
http.setAuthorization(_auth.c_str());
232+
}
233+
223234
const char * headerkeys[] = { "x-MD5" };
224235
size_t headerkeyssize = sizeof(headerkeys) / sizeof(char*);
225236

@@ -243,8 +254,14 @@ HTTPUpdateResult HTTPUpdate::handleUpdate(HTTPClient& http, const String& curren
243254
log_d(" - code: %d\n", code);
244255
log_d(" - len: %d\n", len);
245256

246-
if(http.hasHeader("x-MD5")) {
247-
log_d(" - MD5: %s\n", http.header("x-MD5").c_str());
257+
String md5;
258+
if (_md5Sum.length()) {
259+
md5 = _md5Sum;
260+
} else if(http.hasHeader("x-MD5")) {
261+
md5 = http.header("x-MD5");
262+
}
263+
if(md5.length()) {
264+
log_d(" - MD5: %s\n",md5.c_str());
248265
}
249266

250267
log_d("ESP32 info:\n");
@@ -341,7 +358,7 @@ HTTPUpdateResult HTTPUpdate::handleUpdate(HTTPClient& http, const String& curren
341358
}
342359
*/
343360
}
344-
if(runUpdate(*tcp, len, http.header("x-MD5"), command)) {
361+
if(runUpdate(*tcp, len, md5, command)) {
345362
ret = HTTP_UPDATE_OK;
346363
log_d("Update ok\n");
347364
http.end();

libraries/HTTPUpdate/src/HTTPUpdate.h

+20
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,22 @@ class HTTPUpdate
8585
_ledOn = ledOn;
8686
}
8787

88+
void setMD5sum(const String &md5Sum)
89+
{
90+
_md5Sum = md5Sum;
91+
}
92+
93+
void setAuthorization(const String& user, const String& password)
94+
{
95+
_user = user;
96+
_password = password;
97+
}
98+
99+
void setAuthorization(const String& auth)
100+
{
101+
_auth = auth;
102+
}
103+
88104
t_httpUpdate_return update(WiFiClient& client, const String& url, const String& currentVersion = "", HTTPUpdateRequestCB requestCB = NULL);
89105

90106
t_httpUpdate_return update(WiFiClient& client, const String& host, uint16_t port, const String& uri = "/",
@@ -123,6 +139,10 @@ class HTTPUpdate
123139
private:
124140
int _httpClientTimeout;
125141
followRedirects_t _followRedirects;
142+
String _user;
143+
String _password;
144+
String _auth;
145+
String _md5Sum;
126146

127147
// Callbacks
128148
HTTPUpdateStartCB _cbStart;

libraries/SD/src/sd_diskio.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14+
15+
// Disable the automatic pin remapping of the API calls in this file
16+
#define ARDUINO_CORE_BUILD
17+
1418
#include "sd_diskio.h"
1519
#include "esp_system.h"
1620
#include "esp32-hal-periman.h"
@@ -742,7 +746,7 @@ uint8_t sdcard_init(uint8_t cs, SPIClass * spi, int hz)
742746
card->base_path = NULL;
743747
card->frequency = hz;
744748
card->spi = spi;
745-
card->ssPin = cs;
749+
card->ssPin = digitalPinToGPIONumber(cs);
746750

747751
card->supports_crc = true;
748752
card->type = CARD_NONE;

0 commit comments

Comments
 (0)