Skip to content

Commit 968d513

Browse files
authored
Merge branch 'espressif:master' into master
2 parents 0b108e7 + 855f526 commit 968d513

File tree

25 files changed

+2511
-1272
lines changed

25 files changed

+2511
-1272
lines changed

boards.txt

Lines changed: 1940 additions & 1148 deletions
Large diffs are not rendered by default.

cores/esp32/HWCDC.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ ESP_EVENT_DEFINE_BASE(ARDUINO_HW_CDC_EVENTS);
2828

2929
static RingbufHandle_t tx_ring_buf = NULL;
3030
static xQueueHandle rx_queue = NULL;
31-
static uint8_t rx_data_buf[64];
31+
static uint8_t rx_data_buf[64] = {0};
3232
static intr_handle_t intr_handle = NULL;
3333
static volatile bool initial_empty = false;
3434
static xSemaphoreHandle tx_lock = NULL;
@@ -195,6 +195,7 @@ void HWCDC::end()
195195
intr_handle = NULL;
196196
if(tx_lock != NULL) {
197197
vSemaphoreDelete(tx_lock);
198+
tx_lock = NULL;
198199
}
199200
setRxBufferSize(0);
200201
setTxBufferSize(0);
@@ -217,10 +218,10 @@ void HWCDC::setTxTimeoutMs(uint32_t timeout){
217218

218219
size_t HWCDC::setTxBufferSize(size_t tx_queue_len){
219220
if(tx_ring_buf){
220-
if(!tx_queue_len){
221-
vRingbufferDelete(tx_ring_buf);
222-
tx_ring_buf = NULL;
223-
}
221+
vRingbufferDelete(tx_ring_buf);
222+
tx_ring_buf = NULL;
223+
}
224+
if(!tx_queue_len){
224225
return 0;
225226
}
226227
tx_ring_buf = xRingbufferCreate(tx_queue_len, RINGBUF_TYPE_BYTEBUF);
@@ -318,19 +319,16 @@ void HWCDC::flush(void)
318319

319320
size_t HWCDC::setRxBufferSize(size_t rx_queue_len){
320321
if(rx_queue){
321-
if(!rx_queue_len){
322-
vQueueDelete(rx_queue);
323-
rx_queue = NULL;
324-
}
322+
vQueueDelete(rx_queue);
323+
rx_queue = NULL;
324+
}
325+
if(!rx_queue_len){
325326
return 0;
326327
}
327328
rx_queue = xQueueCreate(rx_queue_len, sizeof(uint8_t));
328329
if(!rx_queue){
329330
return 0;
330331
}
331-
if(!tx_ring_buf){
332-
tx_ring_buf = xRingbufferCreate(rx_queue_len, RINGBUF_TYPE_BYTEBUF);
333-
}
334332
return rx_queue_len;
335333
}
336334

cores/esp32/esp32-hal-bt.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
#ifdef CONFIG_BT_ENABLED
1818

19-
bool btInUse(){ return true; }
19+
// user may want to change it to free resources
20+
__attribute__((weak)) bool btInUse(){ return true; }
2021

2122
#include "esp_bt.h"
2223

cores/esp32/esp32-hal-misc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,8 @@ bool verifyRollbackLater() { return false; }
209209
#endif
210210

211211
#ifdef CONFIG_BT_ENABLED
212-
//overwritten in esp32-hal-bt.c
213-
bool btInUse() __attribute__((weak));
214-
bool btInUse(){ return false; }
212+
//from esp32-hal-bt.c
213+
extern bool btInUse();
215214
#endif
216215

217216
void initArduino()

libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
//#define CAMERA_MODEL_ESP32_CAM_BOARD
2929
//#define CAMERA_MODEL_ESP32S2_CAM_BOARD
3030
//#define CAMERA_MODEL_ESP32S3_CAM_LCD
31-
31+
//#define CAMERA_MODEL_DFRobot_FireBeetle2_ESP32S3 // Has PSRAM
32+
//#define CAMERA_MODEL_DFRobot_Romeo_ESP32S3 // Has PSRAM
3233
#include "camera_pins.h"
3334

3435
// ===========================

libraries/ESP32/examples/Camera/CameraWebServer/camera_pins.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,25 @@
293293
#define HREF_GPIO_NUM 7
294294
#define PCLK_GPIO_NUM 13
295295

296+
#elif defined(CAMERA_MODEL_DFRobot_FireBeetle2_ESP32S3) || defined(CAMERA_MODEL_DFRobot_Romeo_ESP32S3)
297+
#define PWDN_GPIO_NUM -1
298+
#define RESET_GPIO_NUM -1
299+
#define XCLK_GPIO_NUM 45
300+
#define SIOD_GPIO_NUM 1
301+
#define SIOC_GPIO_NUM 2
302+
303+
#define Y9_GPIO_NUM 48
304+
#define Y8_GPIO_NUM 46
305+
#define Y7_GPIO_NUM 8
306+
#define Y6_GPIO_NUM 7
307+
#define Y5_GPIO_NUM 4
308+
#define Y4_GPIO_NUM 41
309+
#define Y3_GPIO_NUM 40
310+
#define Y2_GPIO_NUM 39
311+
#define VSYNC_GPIO_NUM 6
312+
#define HREF_GPIO_NUM 42
313+
#define PCLK_GPIO_NUM 5
314+
296315
#else
297316
#error "Camera model not selected"
298317
#endif

libraries/RainMaker/src/RMakerDevice.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,31 @@
55
static esp_err_t err;
66
typedef void (*deviceWriteCb)(Device*, Param*, const param_val_t val, void *priv_data, write_ctx_t *ctx);
77
typedef void (*deviceReadCb)(Device*, Param*, void *priv_data, read_ctx_t *ctx);
8-
9-
void (*write_cb)(Device*, Param*, param_val_t, void*, write_ctx_t*);
10-
void (*read_cb)(Device*, Param*, void*, read_ctx_t*);
11-
Device device;
12-
Param param;
8+
typedef struct {
9+
void *priv_data;
10+
deviceWriteCb write_cb;
11+
deviceReadCb read_cb;
12+
} RMakerDevicePrivT;
1313

1414
static esp_err_t write_callback(const device_handle_t *dev_handle, const param_handle_t *par_handle, const param_val_t val, void *priv_data, write_ctx_t *ctx)
1515
{
16+
Device device;
17+
Param param;
1618
device.setDeviceHandle(dev_handle);
1719
param.setParamHandle(par_handle);
18-
19-
write_cb(&device, &param, val, priv_data, ctx);
20+
deviceWriteCb cb = ((RMakerDevicePrivT *)priv_data)->write_cb;
21+
cb(&device, &param, val, ((RMakerDevicePrivT *)priv_data)->priv_data, ctx);
2022
return ESP_OK;
2123
}
2224

2325
static esp_err_t read_callback(const device_handle_t *dev_handle, const param_handle_t *par_handle, void *priv_data, read_ctx_t *ctx)
2426
{
27+
Device device;
28+
Param param;
2529
device.setDeviceHandle(dev_handle);
2630
param.setParamHandle(par_handle);
27-
28-
read_cb(&device, &param, priv_data, ctx);
31+
deviceReadCb cb = ((RMakerDevicePrivT *)priv_data)->read_cb;
32+
cb(&device, &param, ((RMakerDevicePrivT *)priv_data)->priv_data, ctx);
2933
return ESP_OK;
3034
}
3135

@@ -41,8 +45,8 @@ esp_err_t Device::deleteDevice()
4145

4246
void Device::addCb(deviceWriteCb writeCb, deviceReadCb readCb)
4347
{
44-
write_cb = writeCb;
45-
read_cb = readCb;
48+
this->private_data.write_cb = writeCb;
49+
this->private_data.read_cb = readCb;
4650
err = esp_rmaker_device_add_cb(getDeviceHandle(), write_callback, read_callback);
4751
if(err != ESP_OK) {
4852
log_e("Failed to register callback");

libraries/RainMaker/src/RMakerDevice.h

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,42 @@
2121

2222
class Device
2323
{
24+
public:
25+
typedef void (*deviceWriteCb)(Device*, Param*, const param_val_t val, void *priv_data, write_ctx_t *ctx);
26+
typedef void (*deviceReadCb)(Device*, Param*, void *priv_data, read_ctx_t *ctx);
27+
typedef struct {
28+
void *priv_data;
29+
deviceWriteCb write_cb;
30+
deviceReadCb read_cb;
31+
} RMakerDevicePrivT;
2432
private:
2533
const device_handle_t *device_handle;
34+
RMakerDevicePrivT private_data;
2635

36+
protected:
37+
void setPrivateData(void *priv_data) {
38+
this->private_data.priv_data = priv_data;
39+
}
40+
41+
const RMakerDevicePrivT* getDevicePrivateData()
42+
{
43+
return &this->private_data;
44+
}
2745
public:
2846
Device()
2947
{
3048
device_handle = NULL;
31-
}
49+
this->private_data.priv_data = NULL;
50+
this->private_data.write_cb = NULL;
51+
this->private_data.read_cb = NULL;
52+
}
53+
3254
Device(const char *dev_name, const char *dev_type = NULL, void *priv_data = NULL)
3355
{
34-
device_handle = esp_rmaker_device_create(dev_name, dev_type, priv_data);
56+
this->private_data.priv_data = priv_data;
57+
this->private_data.write_cb = NULL;
58+
this->private_data.read_cb = NULL;
59+
device_handle = esp_rmaker_device_create(dev_name, dev_type, &this->private_data);
3560
if(device_handle == NULL){
3661
log_e("Device create error");
3762
}
@@ -48,9 +73,6 @@ class Device
4873
{
4974
return device_handle;
5075
}
51-
52-
typedef void (*deviceWriteCb)(Device*, Param*, const param_val_t val, void *priv_data, write_ctx_t *ctx);
53-
typedef void (*deviceReadCb)(Device*, Param*, void *priv_data, read_ctx_t *ctx);
5476

5577
esp_err_t deleteDevice();
5678
void addCb(deviceWriteCb write_cb, deviceReadCb read_cb = NULL);
@@ -94,7 +116,8 @@ class Switch : public Device
94116
}
95117
void standardSwitchDevice(const char *dev_name, void *priv_data, bool power)
96118
{
97-
esp_rmaker_device_t *dev_handle = esp_rmaker_switch_device_create(dev_name, priv_data, power);
119+
this->setPrivateData(priv_data);
120+
esp_rmaker_device_t *dev_handle = esp_rmaker_switch_device_create(dev_name, (void *)this->getDevicePrivateData(), power);
98121
setDeviceHandle(dev_handle);
99122
if(dev_handle == NULL){
100123
log_e("Switch device not created");
@@ -115,7 +138,8 @@ class LightBulb : public Device
115138
}
116139
void standardLightBulbDevice(const char *dev_name, void *priv_data, bool power)
117140
{
118-
esp_rmaker_device_t *dev_handle = esp_rmaker_lightbulb_device_create(dev_name, priv_data, power);
141+
this->setPrivateData(priv_data);
142+
esp_rmaker_device_t *dev_handle = esp_rmaker_lightbulb_device_create(dev_name, (void *)this->getDevicePrivateData(), power);
119143
setDeviceHandle(dev_handle);
120144
if(dev_handle == NULL){
121145
log_e("Light device not created");
@@ -157,7 +181,8 @@ class TemperatureSensor : public Device
157181
}
158182
void standardTemperatureSensorDevice(const char *dev_name, void *priv_data, float temp)
159183
{
160-
esp_rmaker_device_t *dev_handle = esp_rmaker_temp_sensor_device_create(dev_name, priv_data, temp);
184+
this->setPrivateData(priv_data);
185+
esp_rmaker_device_t *dev_handle = esp_rmaker_temp_sensor_device_create(dev_name, (void *)this->getDevicePrivateData(), temp);
161186
setDeviceHandle(dev_handle);
162187
if(dev_handle == NULL){
163188
log_e("Temperature Sensor device not created");

libraries/WebServer/src/WebServer.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,17 +285,16 @@ void WebServer::serveStatic(const char* uri, FS& fs, const char* path, const cha
285285

286286
void WebServer::handleClient() {
287287
if (_currentStatus == HC_NONE) {
288-
WiFiClient client = _server.available();
289-
if (!client) {
288+
_currentClient = _server.available();
289+
if (!_currentClient) {
290290
if (_nullDelay) {
291291
delay(1);
292292
}
293293
return;
294294
}
295295

296-
log_v("New client: client.localIP()=%s", client.localIP().toString().c_str());
296+
log_v("New client: client.localIP()=%s", _currentClient.localIP().toString().c_str());
297297

298-
_currentClient = client;
299298
_currentStatus = HC_WAIT_READ;
300299
_statusChange = millis();
301300
}

0 commit comments

Comments
 (0)