Skip to content

Commit 0695d57

Browse files
authored
Merge branch 'espressif:master' into Tasmota/207
2 parents 40ebf94 + d228da4 commit 0695d57

File tree

10 files changed

+76
-31
lines changed

10 files changed

+76
-31
lines changed

cores/esp32/Print.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ size_t Print::printf(const char *format, ...)
5757
if(len < 0) {
5858
va_end(arg);
5959
return 0;
60-
};
60+
}
6161
if(len >= (int)sizeof(loc_buf)){ // comparation of same sign type for the compiler
6262
temp = (char*) malloc(len+1);
6363
if(temp == NULL) {

libraries/SD_MMC/src/SD_MMC.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ bool SDMMCFS::setPins(int clk, int cmd, int d0, int d1, int d2, int d3)
7272
(d0 == (int)SDMMC_SLOT1_IOMUX_PIN_NUM_D0) &&
7373
(((d1 == -1) && (d2 == -1) && (d3 == -1)) ||
7474
((d1 == (int)SDMMC_SLOT1_IOMUX_PIN_NUM_D1) &&
75-
(d1 == (int)SDMMC_SLOT1_IOMUX_PIN_NUM_D2) &&
76-
(d1 == (int)SDMMC_SLOT1_IOMUX_PIN_NUM_D3)));
75+
(d2 == (int)SDMMC_SLOT1_IOMUX_PIN_NUM_D2) &&
76+
(d3 == (int)SDMMC_SLOT1_IOMUX_PIN_NUM_D3)));
7777
if (!pins_ok) {
7878
log_e("SDMMCFS: specified pins are not supported by this chip.");
7979
return false;

libraries/Ticker/examples/Arguments/Arguments.ino

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,49 @@
1+
/*
2+
* This example demonstrates used of Ticker with arguments.
3+
* You can call the same callback function with different argument on different times.
4+
* Based on the argument the callback can perform different tasks.
5+
*/
6+
17
#include <Arduino.h>
28
#include <Ticker.h>
39

4-
// attach a LED to GPIO 21
5-
#define LED_PIN 21
10+
// Arguments for the function must remain valid (not run out of scope) otherwise the function would read garbage data.
11+
int LED_PIN_1 = 4;
12+
#ifdef LED_BUILTIN
13+
int LED_PIN_2 = LED_BUILTIN;
14+
#else
15+
int LED_PIN_2 = 8;
16+
#endif
617

718
Ticker tickerSetHigh;
819
Ticker tickerSetLow;
920

10-
void setPin(int state) {
11-
digitalWrite(LED_PIN, state);
21+
// Argument to callback must always be passed a reference
22+
void swapState(int *pin) {
23+
static int led_1_state = 1;
24+
static int led_2_state = 1;
25+
if(*pin == LED_PIN_1){
26+
Serial.printf("[%lu ms] set pin %d to state: %d\n", millis(), *pin, led_1_state);
27+
digitalWrite(*pin, led_1_state);
28+
led_1_state = led_1_state ? 0 : 1; // reverse for next pass
29+
}else if(*pin == LED_PIN_2){
30+
Serial.printf("[%lu ms] set pin %d to state: %d\n", millis(), *pin, led_2_state);
31+
digitalWrite(*pin, led_2_state);
32+
led_2_state = led_2_state ? 0 : 1; // reverse for next pass
33+
}
1234
}
1335

1436
void setup() {
15-
pinMode(LED_PIN, OUTPUT);
16-
digitalWrite(1, LOW);
37+
Serial.begin(115200);
38+
pinMode(LED_PIN_1, OUTPUT);
39+
pinMode(LED_PIN_2, OUTPUT);
40+
//digitalWrite(1, LOW);
1741

18-
// every 25 ms, call setPin(0)
19-
tickerSetLow.attach_ms(25, setPin, 0);
42+
// Blink LED every 500 ms on LED_PIN_1
43+
tickerSetLow.attach_ms(500, swapState, &LED_PIN_1);
2044

21-
// every 26 ms, call setPin(1)
22-
tickerSetHigh.attach_ms(26, setPin, 1);
45+
// Blink LED every 1000 ms on LED_PIN_2
46+
tickerSetHigh.attach_ms(1000, swapState, &LED_PIN_2);
2347
}
2448

2549
void loop() {

libraries/WiFiClientSecure/src/WiFiClientSecure.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,21 @@ int WiFiClientSecure::connect(const char *host, uint16_t port, int32_t timeout){
124124

125125
int WiFiClientSecure::connect(IPAddress ip, uint16_t port, const char *CA_cert, const char *cert, const char *private_key)
126126
{
127-
return connect(ip.toString().c_str(), port, CA_cert, cert, private_key);
127+
return connect(ip, port, NULL, CA_cert, cert, private_key);
128128
}
129129

130130
int WiFiClientSecure::connect(const char *host, uint16_t port, const char *CA_cert, const char *cert, const char *private_key)
131131
{
132-
int ret = start_ssl_client(sslclient, host, port, _timeout, CA_cert, _use_ca_bundle, cert, private_key, NULL, NULL, _use_insecure, _alpn_protos);
132+
IPAddress address;
133+
if (!WiFi.hostByName(host, address))
134+
return 0;
135+
136+
return connect(address, port, host, CA_cert, cert, private_key);
137+
}
138+
139+
int WiFiClientSecure::connect(IPAddress ip, uint16_t port, const char *host, const char *CA_cert, const char *cert, const char *private_key)
140+
{
141+
int ret = start_ssl_client(sslclient, ip, port, host, _timeout, CA_cert, _use_ca_bundle, cert, private_key, NULL, NULL, _use_insecure, _alpn_protos);
133142
_lastError = ret;
134143
if (ret < 0) {
135144
log_e("start_ssl_client: %d", ret);
@@ -146,7 +155,12 @@ int WiFiClientSecure::connect(IPAddress ip, uint16_t port, const char *pskIdent,
146155

147156
int WiFiClientSecure::connect(const char *host, uint16_t port, const char *pskIdent, const char *psKey) {
148157
log_v("start_ssl_client with PSK");
149-
int ret = start_ssl_client(sslclient, host, port, _timeout, NULL, false, NULL, NULL, pskIdent, psKey, _use_insecure, _alpn_protos);
158+
159+
IPAddress address;
160+
if (!WiFi.hostByName(host, address))
161+
return 0;
162+
163+
int ret = start_ssl_client(sslclient, address, port, host, _timeout, NULL, false, NULL, NULL, pskIdent, psKey, _use_insecure, _alpn_protos);
150164
_lastError = ret;
151165
if (ret < 0) {
152166
log_e("start_ssl_client: %d", ret);

libraries/WiFiClientSecure/src/WiFiClientSecure.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class WiFiClientSecure : public WiFiClient
5555
int connect(const char *host, uint16_t port, const char *rootCABuff, const char *cli_cert, const char *cli_key);
5656
int connect(IPAddress ip, uint16_t port, const char *pskIdent, const char *psKey);
5757
int connect(const char *host, uint16_t port, const char *pskIdent, const char *psKey);
58+
int connect(IPAddress ip, uint16_t port, const char *host, const char *CA_cert, const char *cert, const char *private_key);
5859
int peek();
5960
size_t write(uint8_t data);
6061
size_t write(const uint8_t *buf, size_t size);

libraries/WiFiClientSecure/src/ssl_client.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void ssl_init(sslclient_context *ssl_client)
5454
}
5555

5656

57-
int start_ssl_client(sslclient_context *ssl_client, const char *host, uint32_t port, int timeout, const char *rootCABuff, bool useRootCABundle, const char *cli_cert, const char *cli_key, const char *pskIdent, const char *psKey, bool insecure, const char **alpn_protos)
57+
int start_ssl_client(sslclient_context *ssl_client, const IPAddress& ip, uint32_t port, const char* hostname, int timeout, const char *rootCABuff, bool useRootCABundle, const char *cli_cert, const char *cli_key, const char *pskIdent, const char *psKey, bool insecure, const char **alpn_protos)
5858
{
5959
char buf[512];
6060
int ret, flags;
@@ -74,16 +74,11 @@ int start_ssl_client(sslclient_context *ssl_client, const char *host, uint32_t p
7474
return ssl_client->socket;
7575
}
7676

77-
IPAddress srv((uint32_t)0);
78-
if(!WiFiGenericClass::hostByName(host, srv)){
79-
return -1;
80-
}
81-
8277
fcntl( ssl_client->socket, F_SETFL, fcntl( ssl_client->socket, F_GETFL, 0 ) | O_NONBLOCK );
8378
struct sockaddr_in serv_addr;
8479
memset(&serv_addr, 0, sizeof(serv_addr));
8580
serv_addr.sin_family = AF_INET;
86-
serv_addr.sin_addr.s_addr = srv;
81+
serv_addr.sin_addr.s_addr = ip;
8782
serv_addr.sin_port = htons(port);
8883

8984
if(timeout <= 0){
@@ -259,7 +254,7 @@ int start_ssl_client(sslclient_context *ssl_client, const char *host, uint32_t p
259254
log_v("Setting hostname for TLS session...");
260255

261256
// Hostname set here should match CN in server certificate
262-
if((ret = mbedtls_ssl_set_hostname(&ssl_client->ssl_ctx, host)) != 0){
257+
if((ret = mbedtls_ssl_set_hostname(&ssl_client->ssl_ctx, hostname != NULL ? hostname : ip.toString().c_str())) != 0){
263258
return handle_error(ret);
264259
}
265260

libraries/WiFiClientSecure/src/ssl_client.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ typedef struct sslclient_context {
3030

3131

3232
void ssl_init(sslclient_context *ssl_client);
33-
int start_ssl_client(sslclient_context *ssl_client, const char *host, uint32_t port, int timeout, const char *rootCABuff, bool useRootCABundle, const char *cli_cert, const char *cli_key, const char *pskIdent, const char *psKey, bool insecure, const char **alpn_protos);
33+
int start_ssl_client(sslclient_context *ssl_client, const IPAddress& ip, uint32_t port, const char* hostname, int timeout, const char *rootCABuff, bool useRootCABundle, const char *cli_cert, const char *cli_key, const char *pskIdent, const char *psKey, bool insecure, const char **alpn_protos);
3434
void stop_ssl_socket(sslclient_context *ssl_client, const char *rootCABuff, const char *cli_cert, const char *cli_key);
3535
int data_to_read(sslclient_context *ssl_client);
3636
int send_ssl_data(sslclient_context *ssl_client, const uint8_t *data, size_t len);

tools/platformio-build.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,19 @@ def get_partition_table_csv(variants_dir):
5050

5151
if partitions_name:
5252
# A custom partitions file is selected
53-
if isfile(join(variant_partitions_dir, partitions_name)):
53+
if isfile(env.subst(join(variant_partitions_dir, partitions_name))):
5454
return join(variant_partitions_dir, partitions_name)
5555

5656
return abspath(
5757
join(fwpartitions_dir, partitions_name)
58-
if isfile(join(fwpartitions_dir, partitions_name))
58+
if isfile(env.subst(join(fwpartitions_dir, partitions_name)))
5959
else partitions_name
6060
)
6161

6262
variant_partitions = join(variant_partitions_dir, "partitions.csv")
6363
return (
6464
variant_partitions
65-
if isfile(variant_partitions)
65+
if isfile(env.subst(variant_partitions))
6666
else join(fwpartitions_dir, "default.csv")
6767
)
6868

@@ -80,7 +80,7 @@ def get_bootloader_image(variants_dir):
8080

8181
return (
8282
variant_bootloader
83-
if isfile(variant_bootloader)
83+
if isfile(env.subst(variant_bootloader))
8484
else generate_bootloader_image(
8585
join(
8686
FRAMEWORK_DIR,
@@ -125,8 +125,8 @@ def add_tinyuf2_extra_image():
125125
)
126126

127127
# Add the UF2 image only if it exists and it's not already added
128-
if not isfile(tinuf2_image):
129-
print("Warning! The `%s` UF2 bootloader image doesn't exist" % tinuf2_image)
128+
if not isfile(env.subst(tinuf2_image)):
129+
print("Warning! The `%s` UF2 bootloader image doesn't exist" % env.subst(tinuf2_image))
130130
return
131131

132132
if any(

variants/AirM2M_CORE_ESP32C3/pins_arduino.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
#define digitalPinToInterrupt(p) (((p)<NUM_DIGITAL_PINS)?(p):-1)
1212
#define digitalPinHasPWM(p) (p < EXTERNAL_NUM_INTERRUPTS)
1313

14+
static const uint8_t LED_BUILTIN = 12;
15+
#define BUILTIN_LED LED_BUILTIN
16+
static const uint8_t LED_BUILTIN_AUX = 13;
17+
1418
static const uint8_t TX = 21;
1519
static const uint8_t RX = 20;
1620

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include "Arduino.h"
2+
3+
extern "C" void initVariant(void){
4+
// Stop LEDs floating
5+
pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW);
6+
pinMode(LED_BUILTIN_AUX, OUTPUT); digitalWrite(LED_BUILTIN_AUX, LOW);
7+
}

0 commit comments

Comments
 (0)