Skip to content

Commit b4641c8

Browse files
committed
Merge branch 'bugfix/idf5.x' into 'master'
Fixes for idf v5.0 See merge request app-frameworks/esp-rainmaker!289
2 parents f1028ae + 2a08ed9 commit b4641c8

File tree

10 files changed

+86
-67
lines changed

10 files changed

+86
-67
lines changed

.gitlab-ci.yml

+1-30
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,8 @@ before_script:
4747
- ls
4848
- cd $CI_PROJECT_DIR/examples/switch
4949
- echo Building for esp32
50-
- idf.py build
5150
- idf.py set-target esp32
52-
- echo Running make
51+
- idf.py build
5352
- rm -rf build/ sdkconfig
5453
- echo Building for esp32s2
5554
- idf.py set-target esp32s2
@@ -62,10 +61,6 @@ before_script:
6261
- echo Building for esp32s3
6362
- idf.py set-target esp32s3
6463
- idf.py build
65-
- rm -rf build/ sdkconfig
66-
- echo Running make
67-
- make defconfig
68-
- make $MAKEFLAGS
6964
- echo Building switch app - Done
7065
# Building switch app - Done
7166
# Copying switch.bin to esp-rainmaker-bins-${CI_JOB_ID}/
@@ -78,10 +73,6 @@ before_script:
7873
- echo Running idf.py
7974
- cd $CI_PROJECT_DIR/examples/led_light
8075
- idf.py build
81-
- echo Running make
82-
- rm -rf build/ sdkconfig
83-
- make defconfig
84-
- make $MAKEFLAGS
8576
- echo Building led_light app - Done
8677
# Building led_light app - Done
8778
# Copying led_light.bin to esp-rainmaker-bins-${CI_JOB_ID}/
@@ -94,10 +85,6 @@ before_script:
9485
- echo Running idf.py
9586
- cd $CI_PROJECT_DIR/examples/fan
9687
- idf.py build
97-
- echo Running make
98-
- rm -rf build/ sdkconfig
99-
- make defconfig
100-
- make $MAKEFLAGS
10188
- echo Building fan app - Done
10289
# Building fan app - Done
10390
# Copying fan.bin to esp-rainmaker-bins-${CI_JOB_ID}/
@@ -110,10 +97,6 @@ before_script:
11097
- echo Running idf.py
11198
- cd $CI_PROJECT_DIR/examples/temperature_sensor
11299
- idf.py build
113-
- echo Running make
114-
- rm -rf build/ sdkconfig
115-
- make defconfig
116-
- make $MAKEFLAGS
117100
- echo Building temperature_sensor app - Done
118101
# Building temperature_sensor app - Done
119102
# Copying temperature_sensor.bin to esp-rainmaker-bins-${CI_JOB_ID}/
@@ -126,10 +109,6 @@ before_script:
126109
- echo Running idf.py
127110
- cd $CI_PROJECT_DIR/examples/multi_device
128111
- idf.py build
129-
- echo Running make
130-
- rm -rf build/ sdkconfig
131-
- make defconfig
132-
- make $MAKEFLAGS
133112
- echo Building multi_device app - Done
134113
# Building multi_device app - Done
135114
# Copying multi_device.bin to esp-rainmaker-bins-${CI_JOB_ID}/
@@ -142,10 +121,6 @@ before_script:
142121
- echo Running idf.py
143122
- cd $CI_PROJECT_DIR/examples/gpio
144123
- idf.py build
145-
- echo Running make
146-
- rm -rf build/ sdkconfig
147-
- make defconfig
148-
- make $MAKEFLAGS
149124
- echo Building gpio app - Done
150125
# Building gpio app - Done
151126
# Copying gpio.bin to esp-rainmaker-bins-${CI_JOB_ID}/
@@ -163,10 +138,6 @@ before_script:
163138
- echo Building homekit_switch app - Started
164139
- echo Running idf.py
165140
- idf.py build
166-
# - echo Running make
167-
# - rm -rf build/ sdkconfig
168-
# - make defconfig
169-
# - make $MAKEFLAGS
170141
- echo Building homekit_switch app - Done
171142
# Building homekit_switch app - Done
172143
# Copying homekit_switch.bin to esp-rainmaker-bins-${CI_JOB_ID}/

components/button/CMakeLists.txt

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
set(COMPONENT_ADD_INCLUDEDIRS button/include)
2-
set(COMPONENT_SRCS "button/button.c"
3-
"button/button_obj.cpp")
4-
5-
register_component()
1+
idf_component_register(SRCS "button/button.c" "button/button_obj.cpp"
2+
INCLUDE_DIRS "button/include"
3+
REQUIRES "driver")

components/button/button/button.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ struct button_dev{
6565
#define BUTTON_GLITCH_FILTER_TIME_MS CONFIG_IO_GLITCH_FILTER_TIME_MS
6666
static const char* TAG = "button";
6767

68-
static void button_press_cb(xTimerHandle tmr)
68+
static void button_press_cb(TimerHandle_t tmr)
6969
{
7070
button_cb_t* btn_cb = (button_cb_t*) pvTimerGetTimerID(tmr);
7171
button_dev_t* btn = btn_cb->pbtn;
@@ -82,7 +82,7 @@ static void button_press_cb(xTimerHandle tmr)
8282
}
8383
}
8484

85-
static void button_tap_psh_cb(xTimerHandle tmr)
85+
static void button_tap_psh_cb(TimerHandle_t tmr)
8686
{
8787
button_cb_t* btn_cb = (button_cb_t*) pvTimerGetTimerID(tmr);
8888
button_dev_t* btn = btn_cb->pbtn;
@@ -108,7 +108,7 @@ static void button_tap_psh_cb(xTimerHandle tmr)
108108
}
109109
}
110110

111-
static void button_tap_rls_cb(xTimerHandle tmr)
111+
static void button_tap_rls_cb(TimerHandle_t tmr)
112112
{
113113
button_cb_t* btn_cb = (button_cb_t*) pvTimerGetTimerID(tmr);
114114
button_dev_t* btn = btn_cb->pbtn;
@@ -144,7 +144,7 @@ static void button_tap_rls_cb(xTimerHandle tmr)
144144
}
145145
}
146146

147-
static void button_press_serial_cb(xTimerHandle tmr)
147+
static void button_press_serial_cb(TimerHandle_t tmr)
148148
{
149149
button_dev_t* btn = (button_dev_t*) pvTimerGetTimerID(tmr);
150150
if (btn->press_serial_cb.cb) {
@@ -185,7 +185,7 @@ static void button_gpio_isr_handler(void* arg)
185185
}
186186
}
187187

188-
static void button_free_tmr(xTimerHandle* tmr)
188+
static void button_free_tmr(TimerHandle_t* tmr)
189189
{
190190
if (tmr && *tmr) {
191191
xTimerStop(*tmr, portMAX_DELAY);
@@ -295,22 +295,22 @@ esp_err_t iot_button_set_evt_cb(button_handle_t btn_handle, button_cb_type_t typ
295295
if (type == BUTTON_CB_PUSH) {
296296
btn->tap_psh_cb.arg = arg;
297297
btn->tap_psh_cb.cb = cb;
298-
btn->tap_psh_cb.interval = BUTTON_GLITCH_FILTER_TIME_MS / portTICK_RATE_MS;
298+
btn->tap_psh_cb.interval = BUTTON_GLITCH_FILTER_TIME_MS / portTICK_PERIOD_MS;
299299
btn->tap_psh_cb.pbtn = btn;
300300
xTimerChangePeriod(btn->tap_psh_cb.tmr, btn->tap_psh_cb.interval, portMAX_DELAY);
301301
} else if (type == BUTTON_CB_RELEASE) {
302302
btn->tap_rls_cb.arg = arg;
303303
btn->tap_rls_cb.cb = cb;
304-
btn->tap_rls_cb.interval = BUTTON_GLITCH_FILTER_TIME_MS / portTICK_RATE_MS;
304+
btn->tap_rls_cb.interval = BUTTON_GLITCH_FILTER_TIME_MS / portTICK_PERIOD_MS;
305305
btn->tap_rls_cb.pbtn = btn;
306306
xTimerChangePeriod(btn->tap_rls_cb.tmr, btn->tap_psh_cb.interval, portMAX_DELAY);
307307
} else if (type == BUTTON_CB_TAP) {
308308
btn->tap_short_cb.arg = arg;
309309
btn->tap_short_cb.cb = cb;
310-
btn->tap_short_cb.interval = BUTTON_GLITCH_FILTER_TIME_MS / portTICK_RATE_MS;
310+
btn->tap_short_cb.interval = BUTTON_GLITCH_FILTER_TIME_MS / portTICK_PERIOD_MS;
311311
btn->tap_short_cb.pbtn = btn;
312312
} else if (type == BUTTON_CB_SERIAL) {
313-
iot_button_set_serial_cb(btn_handle, 1, 1000 / portTICK_RATE_MS, cb, arg);
313+
iot_button_set_serial_cb(btn_handle, 1, 1000 / portTICK_PERIOD_MS, cb, arg);
314314
}
315315
return ESP_OK;
316316
}

components/esp-insights

Submodule esp-insights updated 51 files

components/esp_rainmaker/src/console/esp_rmaker_console.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static void scli_task(void *arg)
5757
memset(linebuf, 0, sizeof(linebuf));
5858
i = 0;
5959
do {
60-
ret = xQueueReceive(uart_queue, (void * )&event, (portTickType)portMAX_DELAY);
60+
ret = xQueueReceive(uart_queue, (void * )&event, (TickType_t)portMAX_DELAY);
6161
if (ret != pdPASS) {
6262
if(stop == 1) {
6363
break;

components/esp_rainmaker/src/core/esp_rmaker_claim.c

+17-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,17 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
#include <mbedtls/version.h>
16+
/* Keep forward-compatibility with Mbed TLS 3.x */
17+
#if (MBEDTLS_VERSION_NUMBER < 0x03000000)
18+
#define MBEDTLS_2_X_COMPAT
19+
#else /* !(MBEDTLS_VERSION_NUMBER < 0x03000000) */
20+
/* Macro wrapper for struct's private members */
21+
#ifndef MBEDTLS_ALLOW_PRIVATE_ACCESS
22+
#define MBEDTLS_ALLOW_PRIVATE_ACCESS
23+
#endif /* MBEDTLS_ALLOW_PRIVATE_ACCESS */
24+
#endif /* !(MBEDTLS_VERSION_NUMBER < 0x03000000) */
1525

16-
#include "mbedtls/config.h"
1726
#include "mbedtls/platform.h"
1827
#include "mbedtls/pk.h"
1928
#include "mbedtls/rsa.h"
@@ -45,6 +54,7 @@
4554
#include "esp_rmaker_client_data.h"
4655
#include "esp_rmaker_claim.h"
4756

57+
4858
static const char *TAG = "esp_claim";
4959

5060
#define ESP_RMAKER_RANDOM_NUMBER_LEN 64
@@ -796,7 +806,12 @@ esp_err_t __esp_rmaker_claim_init(esp_rmaker_claim_data_t *claim_data)
796806
if (key) {
797807
mbedtls_pk_free(&claim_data->key);
798808
mbedtls_pk_init(&claim_data->key);
799-
if (mbedtls_pk_parse_key(&claim_data->key, (uint8_t *)key, strlen(key) + 1, NULL, 0) == 0) {
809+
#ifdef MBEDTLS_2_X_COMPAT
810+
int ret = mbedtls_pk_parse_key(&claim_data->key, (uint8_t *)key, strlen(key) + 1, NULL, 0);
811+
#else
812+
int ret = mbedtls_pk_parse_key(&claim_data->key, (uint8_t *)key, strlen(key) + 1, NULL, 0, mbedtls_ctr_drbg_random, NULL);
813+
#endif
814+
if (ret == 0) {
800815
ESP_LOGI(TAG, "Private key already exists. No need to re-initialise it.");
801816
claim_data->state = RMAKER_CLAIM_STATE_PK_GENERATED;
802817
}

components/esp_rainmaker/src/core/esp_rmaker_local_ctrl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ static esp_err_t __esp_rmaker_start_local_ctrl_service(const char *serv_name)
327327

328328
/* update the global status */
329329
g_local_ctrl_is_started = true;
330-
esp_rmaker_post_event(RMAKER_EVENT_LOCAL_CTRL_STARTED, serv_name, strlen(serv_name) + 1);
330+
esp_rmaker_post_event(RMAKER_EVENT_LOCAL_CTRL_STARTED, (void *)serv_name, strlen(serv_name) + 1);
331331
return ESP_OK;
332332
}
333333

examples/common/app_insights/app_insights.c

+51-16
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <esp_insights.h>
1313
#include <string.h>
1414
#include <esp_rmaker_core.h>
15-
#include <esp_rmaker_factory.h>
15+
#include <esp_rmaker_common_events.h>
1616

1717
#if CONFIG_APP_INSIGHTS_ENABLE_LOG_TYPE_ALL
1818
#define APP_INSIGHTS_LOG_TYPE ESP_DIAG_LOG_TYPE_ERROR \
@@ -24,6 +24,48 @@
2424

2525
esp_err_t esp_insights_enable(esp_insights_config_t *config);
2626

27+
#define INSIGHTS_TOPIC_SUFFIX "diagnostics/from-node"
28+
29+
static int app_insights_data_send(void *data, size_t len)
30+
{
31+
char topic[128];
32+
int msg_id = -1;
33+
if (data == NULL) {
34+
return 0;
35+
}
36+
char *node_id = esp_rmaker_get_node_id();
37+
if (!node_id) {
38+
return -1;
39+
}
40+
snprintf(topic, sizeof(topic), "node/%s/%s", node_id, INSIGHTS_TOPIC_SUFFIX);
41+
esp_rmaker_mqtt_publish(topic, data, len, RMAKER_MQTT_QOS1, &msg_id);
42+
return msg_id;
43+
}
44+
45+
static void rmaker_common_event_handler(void* arg, esp_event_base_t event_base,
46+
int32_t event_id, void* event_data)
47+
{
48+
if (event_base != RMAKER_COMMON_EVENT) {
49+
return;
50+
}
51+
esp_insights_transport_event_data_t data;
52+
switch(event_id) {
53+
case RMAKER_MQTT_EVENT_PUBLISHED:
54+
memset(&data, 0, sizeof(data));
55+
data.msg_id = *(int *)event_data;
56+
esp_event_post(INSIGHTS_EVENT, INSIGHTS_EVENT_TRANSPORT_SEND_SUCCESS, &data, sizeof(data), portMAX_DELAY);
57+
break;
58+
#ifdef CONFIG_MQTT_REPORT_DELETED_MESSAGES
59+
case RMAKER_MQTT_EVENT_MSG_DELETED:
60+
memset(&data, 0, sizeof(data));
61+
data.msg_id = *(int *)event_data;
62+
esp_event_post(INSIGHTS_EVENT, INSIGHTS_EVENT_TRANSPORT_SEND_FAILED, &data, sizeof(data), portMAX_DELAY);
63+
break;
64+
#endif /* CONFIG_MQTT_REPORT_DELETED_MESSAGES */
65+
default:
66+
break;
67+
}
68+
}
2769
#endif /* CONFIG_ESP_INSIGHTS_ENABLED */
2870

2971
#define TAG "app_insights"
@@ -33,26 +75,19 @@ esp_err_t app_insights_enable(void)
3375
#ifdef CONFIG_ESP_INSIGHTS_ENABLED
3476
#ifdef CONFIG_ESP_RMAKER_SELF_CLAIM
3577
ESP_LOGW(TAG, "Nodes with Self Claiming may not be accessible for Insights.");
36-
/* This is required so that the esp insights component will get correct
37-
* node id from NVS
38-
*/
39-
char *node_id = esp_rmaker_get_node_id();
40-
if (node_id) {
41-
esp_rmaker_factory_set("node_id", node_id, strlen(node_id));
42-
}
4378
#endif
44-
esp_rmaker_mqtt_config_t mqtt_config = {
45-
.init = NULL,
46-
.connect = NULL,
47-
.disconnect = NULL,
48-
.publish = esp_rmaker_mqtt_publish,
49-
.subscribe = esp_rmaker_mqtt_subscribe,
50-
.unsubscribe = esp_rmaker_mqtt_unsubscribe,
79+
char *node_id = esp_rmaker_get_node_id();
80+
81+
esp_insights_transport_config_t transport = {
82+
.callbacks.data_send = app_insights_data_send,
5183
};
52-
esp_insights_mqtt_setup(mqtt_config);
84+
esp_insights_transport_register(&transport);
85+
86+
esp_event_handler_register(RMAKER_COMMON_EVENT, ESP_EVENT_ANY_ID, rmaker_common_event_handler, NULL);
5387

5488
esp_insights_config_t config = {
5589
.log_type = APP_INSIGHTS_LOG_TYPE,
90+
.node_id = node_id,
5691
};
5792
esp_insights_enable(&config);
5893
#else

examples/homekit_switch/main/app_homekit.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <freertos/FreeRTOS.h>
1212
#include <freertos/task.h>
1313
#include <esp_log.h>
14-
14+
#include <esp_netif_types.h>
1515
#include <esp_rmaker_core.h>
1616
#include <esp_rmaker_standard_params.h>
1717

0 commit comments

Comments
 (0)