Skip to content

Commit

Permalink
Replace portTICK_RATE_MS with portTICK_PERIOD_MS espressif/esp-idf#51
Browse files Browse the repository at this point in the history
  • Loading branch information
mmrein committed Apr 16, 2024
1 parent 9f7222e commit 55f9594
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion components/mconfig/mconfig_blufi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ mdf_err_t mconfig_blufi_init(const mconfig_blufi_config_t *cfg)
ret = esp_bluedroid_enable();
MDF_ERROR_CHECK(ret != ESP_OK, ret, "Enable bluedroid");

vTaskDelay(esp_random() % 100 / portTICK_RATE_MS);
vTaskDelay(esp_random() % 100 / portTICK_PERIOD_MS);

ret = esp_ble_gap_register_callback(mconfig_blufi_gap_event_handler);
MDF_ERROR_CHECK(ret != ESP_OK, ret, "BLE gap register callback");
Expand Down
12 changes: 6 additions & 6 deletions components/mconfig/mconfig_chain.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ static void mconfig_chain_master_task(void *arg)
*/
espnow_size = ESPNOW_BUFFER_LEN;
ret = mespnow_read(MESPNOW_TRANS_PIPE_MCONFIG, src_addr, espnow_data,
&espnow_size, MCONFIG_CHAIN_EXIT_DELAY / portTICK_RATE_MS);
&espnow_size, MCONFIG_CHAIN_EXIT_DELAY / portTICK_PERIOD_MS);

if (ret != ESP_OK || espnow_size != MCONFIG_RSA_PUBKEY_PEM_DATA_SIZE + 1) {
MDF_LOGV("receive, size: %d, data:\n%s", espnow_size, espnow_data);
Expand Down Expand Up @@ -304,7 +304,7 @@ static bool scan_mesh_device(uint8_t *bssid, int8_t *rssi)
mconfig_scan_info_t scan_info = {0};
uint32_t start_ticks = xTaskGetTickCount();

if (!xQueueReceive(g_mconfig_scan_queue, &scan_info, MCONFIG_CHAIN_EXIT_DELAY / portTICK_RATE_MS)) {
if (!xQueueReceive(g_mconfig_scan_queue, &scan_info, MCONFIG_CHAIN_EXIT_DELAY / portTICK_PERIOD_MS)) {
if (g_switch_channel_flag && g_chain_slave_flag) {
ESP_ERROR_CHECK(esp_wifi_get_channel(&channel, &second));

Expand All @@ -330,7 +330,7 @@ static bool scan_mesh_device(uint8_t *bssid, int8_t *rssi)
memcpy(bssid, scan_info.bssid, MWIFI_ADDR_LEN);

/**< Device that achieves the best signal strength */
for (TickType_t wait_ticks = MCONFIG_CHAIN_EXIT_DELAY / portTICK_RATE_MS;
for (TickType_t wait_ticks = MCONFIG_CHAIN_EXIT_DELAY / portTICK_PERIOD_MS;
xQueueReceive(g_mconfig_scan_queue, &scan_info, wait_ticks) == pdTRUE;
wait_ticks = xTaskGetTickCount() - start_ticks < wait_ticks ?
wait_ticks - (xTaskGetTickCount() - start_ticks) : 0) {
Expand Down Expand Up @@ -412,7 +412,7 @@ static void mconfig_chain_slave_task(void *arg)

if (ret != MDF_OK) {
MDF_LOGD("<%s> mespnow_write", mdf_err_to_name(ret));
vTaskDelay(500 / portTICK_RATE_MS);
vTaskDelay(500 / portTICK_PERIOD_MS);
continue;
}

Expand All @@ -422,7 +422,7 @@ static void mconfig_chain_slave_task(void *arg)
ESP_ERROR_CHECK(mespnow_add_peer(ESP_IF_WIFI_STA, dest_addr, (uint8_t *)CONFIG_MCONFIG_CHAIN_LMK));
espnow_size = ESPNOW_BUFFER_LEN;
ret = mespnow_read(MESPNOW_TRANS_PIPE_MCONFIG, dest_addr,
espnow_data, &espnow_size, 1000 / portTICK_RATE_MS);
espnow_data, &espnow_size, 1000 / portTICK_PERIOD_MS);

if (ret != ESP_OK || espnow_size != (MCONFIG_RSA_CIPHERTEXT_SIZE - MCONFIG_RSA_PLAINTEXT_MAX_SIZE) + sizeof(mconfig_chain_data_t)) {
MDF_LOGD("<%s> mespnow_read", mdf_err_to_name(ret));
Expand Down Expand Up @@ -467,7 +467,7 @@ static void mconfig_chain_slave_task(void *arg)
do {
whitelist_compress_size = mconfig_data->whitelist_size + 64;
ret = mespnow_read(MESPNOW_TRANS_PIPE_MCONFIG, src_addr, whitelist_compress_data,
(size_t *)&whitelist_compress_size, 10000 / portTICK_RATE_MS);
(size_t *)&whitelist_compress_size, 10000 / portTICK_PERIOD_MS);

if (ret == MDF_ERR_TIMEOUT) {
break;
Expand Down
4 changes: 2 additions & 2 deletions components/mdebug/mdebug_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ static int coredump_func(int argc, char **argv)
break;
}

vTaskDelay(100 / portTICK_RATE_MS);
vTaskDelay(100 / portTICK_PERIOD_MS);
}

MDF_ERROR_BREAK(ret != MDF_OK, "mdebug_espnow_write, seq: %d", packet->seq);
Expand All @@ -423,7 +423,7 @@ static int coredump_func(int argc, char **argv)
* @brief TODO Since espnow is now an unreliable transmission,
* sending too fast will result in packet loss.
*/
vTaskDelay(20 / portTICK_RATE_MS);
vTaskDelay(20 / portTICK_PERIOD_MS);
}

packet->type = MDEBUG_COREDUMP_END;
Expand Down
2 changes: 1 addition & 1 deletion components/mlink/mlink_handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ static mdf_err_t mlink_handle_add_device(mlink_handle_data_t *handle_data)

mlink_json_parse(handle_data->req_data, "timeout", &duration_ms);

ret = mconfig_chain_master(mconfig_data, duration_ms / portTICK_RATE_MS);
ret = mconfig_chain_master(mconfig_data, duration_ms / portTICK_PERIOD_MS);
MDF_ERROR_GOTO(ret != MDF_OK, EXIT, "<%s> Sending network configuration information to the devices",
mdf_err_to_name(ret));

Expand Down
8 changes: 4 additions & 4 deletions components/mlink/mlink_httpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ static mdf_err_t mlink_connection_add(httpd_req_t *req, uint16_t chunks_num)
g_conn_list[i].flag = (chunks_num > 1) ? MLINK_HTTPD_CHUNKS_HEADER : MLINK_HTTPD_CHUNKS_DATA;
g_conn_list[i].handle = req->handle;
g_conn_list[i].sockfd = httpd_req_to_sockfd(req);
g_conn_list[i].timer = xTimerCreate("chunk_timer", MLINK_HTTPD_RESP_TIMEROUT_MS / portTICK_RATE_MS,
g_conn_list[i].timer = xTimerCreate("chunk_timer", MLINK_HTTPD_RESP_TIMEROUT_MS / portTICK_PERIOD_MS,
false, g_conn_list + i, mlink_connection_timeout_cb);
MDF_ERROR_CHECK(!g_conn_list[i].timer, MDF_FAIL, "xTimerCreate mlink_conn fail");
xTimerStart(g_conn_list[i].timer, portMAX_DELAY);
Expand Down Expand Up @@ -483,7 +483,7 @@ static void mlink_ota_send_task(void *arg)
MDF_LOGW("<%s> Root sends firmware to other nodes", mdf_err_to_name(ret));
} else {
MDF_LOGI("Firmware is sent to the device to complete, Spend time: %ds",
(xTaskGetTickCount() - start_time) * portTICK_RATE_MS / 1000);
(xTaskGetTickCount() - start_time) * portTICK_PERIOD_MS / 1000);
}

MDF_FREE(mlink_httpd->addrs_list);
Expand Down Expand Up @@ -569,7 +569,7 @@ static esp_err_t mlink_ota_firmware(httpd_req_t *req)
}

MDF_LOGI("Firmware is sent to the device to complete, Spend time: %ds",
(xTaskGetTickCount() - start_time) * portTICK_RATE_MS / 1000);
(xTaskGetTickCount() - start_time) * portTICK_PERIOD_MS / 1000);
start_time = xTaskGetTickCount();

mlink_httpd_resp_200(req);
Expand Down Expand Up @@ -696,7 +696,7 @@ static esp_err_t mlink_ota_url(httpd_req_t *req)
}

MDF_LOGI("The service download firmware is complete, Spend time: %ds",
(xTaskGetTickCount() - start_time) * portTICK_RATE_MS / 1000);
(xTaskGetTickCount() - start_time) * portTICK_PERIOD_MS / 1000);

mlink_httpd_resp_200(req);
MDF_ERROR_GOTO(ret != MDF_OK, EXIT, "Helper function for HTTP 200");
Expand Down
10 changes: 5 additions & 5 deletions components/mlink/mlink_notice.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static mdf_err_t mlink_notice_mdns_init(void)
ardu_txt_data, sizeof(ardu_txt_data) / sizeof(mdns_txt_item_t));

if (ret != MDF_OK) {
vTaskDelay(100 / portTICK_RATE_MS);
vTaskDelay(100 / portTICK_PERIOD_MS);
}
} while (ret != MDF_OK && retry_count--);

Expand Down Expand Up @@ -192,15 +192,15 @@ static void mlink_notice_udp_task(void *arg)
while (!g_notice_udp_exit_flag) {
memset(udp_server_buf, 0, MLINK_NOTICE_UDP_BUF_SIZE);

if (xQueueReceive(g_notice_udp_queue, &q_data, MLINK_NOTICE_UDP_RECV_TIMEROUT_MS / portTICK_RATE_MS)) {
if (xQueueReceive(g_notice_udp_queue, &q_data, MLINK_NOTICE_UDP_RECV_TIMEROUT_MS / portTICK_PERIOD_MS)) {
strncpy(message_tmp, q_data->message, sizeof(message_tmp) - 1);
broadcast_msg_buf = MDF_MALLOC(MLINK_NOTICE_UDP_QUEUE_NUM * 13 + 64);
broadcast_msg_size = sprintf(broadcast_msg_buf, "mac=%02x%02x%02x%02x%02x%02x", MAC2STR(q_data->mac));
MDF_FREE(q_data);

do {
if (!g_notice_udp_queue || !xQueueReceive(g_notice_udp_queue, &q_data,
MLINK_NOTICE_UDP_RECV_TIMEROUT_MS / portTICK_RATE_MS)) {
MLINK_NOTICE_UDP_RECV_TIMEROUT_MS / portTICK_PERIOD_MS)) {
break;
}

Expand All @@ -226,7 +226,7 @@ static void mlink_notice_udp_task(void *arg)
MDF_LOGD("Mlink notice udp broadcast, size: %d, data:\n%s", broadcast_msg_size, broadcast_msg_buf);

for (int i = 0, delay_time_ms = 0; i < MLINK_NOTICE_UDP_RETRY_COUNT; ++i, delay_time_ms += delay_time_ms) {
vTaskDelay(delay_time_ms / portTICK_RATE_MS);
vTaskDelay(delay_time_ms / portTICK_PERIOD_MS);
delay_time_ms = (i == 0) ? 10 : delay_time_ms;
delay_time_ms = (delay_time_ms > 50) ? 50 : delay_time_ms;

Expand Down Expand Up @@ -263,7 +263,7 @@ static void mlink_notice_udp_task(void *arg)

for (int i = 0, delay_time_ms = 0; i < MLINK_NOTICE_UDP_RETRY_COUNT; ++i, delay_time_ms += delay_time_ms) {
vTaskDelay(delay_time_ms);
delay_time_ms = (i == 0) ? (10 / portTICK_RATE_MS) : delay_time_ms;
delay_time_ms = (i == 0) ? (10 / portTICK_PERIOD_MS) : delay_time_ms;

if (sendto(udp_server_sockfd, udp_server_buf, strlen(udp_server_buf),
0, (struct sockaddr *)&from_addr, from_addr_len) <= 0) {
Expand Down
2 changes: 1 addition & 1 deletion components/mlink/mlink_sniffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ typedef struct sniffer_data_list {
mlink_sniffer_data_t data;
} __attribute__((packed)) sniffer_data_list_t;

#define sniffer_timestamp() (xTaskGetTickCount() * portTICK_RATE_MS)
#define sniffer_timestamp() (xTaskGetTickCount() * portTICK_PERIOD_MS)

static const char *TAG = "mlink_sniffer";
static void *g_sniffer_lock = NULL;
Expand Down
2 changes: 1 addition & 1 deletion components/mupgrade/mupgrade_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static bool restart_trigger()
ret = mdf_info_save(MUPGRADE_STORE_RESTART_COUNT_KEY, &restart_count, sizeof(uint32_t));
MDF_ERROR_CHECK(ret != ESP_OK, false, "Save the number of restarts within the set time");

timer = xTimerCreate("restart_count_erase", CONFIG_MUPGRADE_RESTART_TIMEOUT / portTICK_RATE_MS,
timer = xTimerCreate("restart_count_erase", CONFIG_MUPGRADE_RESTART_TIMEOUT / portTICK_PERIOD_MS,
false, NULL, restart_count_erase_timercb);
MDF_ERROR_CHECK(!timer, false, "xTaskCreate, timer: %p", timer);

Expand Down
2 changes: 1 addition & 1 deletion components/mupgrade/mupgrade_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ static mdf_err_t mupgrade_write(const mupgrade_packet_t *packet, size_t size)
MUPGRADE_PACKET_MAX_NUM / 8, ESP_LOG_VERBOSE);
MDF_LOGI("Write total_size: %d, written_size: %d, spend time: %ds",
g_upgrade_config->status.total_size, g_upgrade_config->status.written_size,
(xTaskGetTickCount() - g_upgrade_config->start_time) * portTICK_RATE_MS / 1000);
(xTaskGetTickCount() - g_upgrade_config->start_time) * portTICK_PERIOD_MS / 1000);

/**< If ESP32 was reset duration OTA, and after restart, the update_handle will be invalid,
but it still can switch boot partition and reboot successful */
Expand Down
6 changes: 3 additions & 3 deletions components/mupgrade/mupgrade_root.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ mdf_err_t mupgrade_root_handle(const uint8_t *addr, const void *data, size_t siz
MDF_LOGD("addr: " MACSTR ", size: %d", MAC2STR(addr), size);

if (!xQueueSend(g_upgrade_config->queue, &q_data,
CONFIG_MUPGRADE_WAIT_RESPONSE_TIMEOUT / portTICK_RATE_MS)) {
CONFIG_MUPGRADE_WAIT_RESPONSE_TIMEOUT / portTICK_PERIOD_MS)) {
MDF_LOGW("xQueueSend failed");
MDF_FREE(q_data);
return MDF_ERR_TIMEOUT;
Expand Down Expand Up @@ -190,7 +190,7 @@ static mdf_err_t mupgrade_request_status(uint8_t *progress_array, mupgrade_resul
/**
* @brief Remove the device that the firmware upgrade has completed.
*/
while (xQueueReceive(g_upgrade_config->queue, &q_data, CONFIG_MUPGRADE_WAIT_RESPONSE_TIMEOUT / portTICK_RATE_MS)) {
while (xQueueReceive(g_upgrade_config->queue, &q_data, CONFIG_MUPGRADE_WAIT_RESPONSE_TIMEOUT / portTICK_PERIOD_MS)) {
mupgrade_status_t *status = (mupgrade_status_t *)q_data->data;

if (status->written_size == status->total_size) {
Expand Down Expand Up @@ -236,7 +236,7 @@ static mdf_err_t mupgrade_request_status(uint8_t *progress_array, mupgrade_resul

while (request_num > 0) {
ret = xQueueReceive(g_upgrade_config->queue, &q_data,
CONFIG_MUPGRADE_WAIT_RESPONSE_TIMEOUT / portTICK_RATE_MS);
CONFIG_MUPGRADE_WAIT_RESPONSE_TIMEOUT / portTICK_PERIOD_MS);

if (ret != pdTRUE) {
MDF_LOGD("xQueueReceive failed");
Expand Down
10 changes: 5 additions & 5 deletions components/mwifi/mwifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ mdf_err_t mwifi_stop()

/**< To ensure that all tasks are properly exited */
MDF_LOGD("vTaskDelay 50ms");
vTaskDelay(50 / portTICK_RATE_MS);
vTaskDelay(50 / portTICK_PERIOD_MS);

MDF_ERROR_ASSERT(esp_wifi_set_mode(WIFI_MODE_STA));

Expand Down Expand Up @@ -1009,14 +1009,14 @@ mdf_err_t __mwifi_read(uint8_t *src_addr, mwifi_data_type_t *data_type,
MDF_LOGV("wait_ticks: %d, start_ticks: %d, recv_ticks: %d", wait_ticks, start_ticks, recv_ticks);

/**< Receive a packet targeted to self over the mesh network */
ret = esp_mesh_recv((mesh_addr_t *)src_addr, &mesh_data, recv_ticks * portTICK_RATE_MS,
ret = esp_mesh_recv((mesh_addr_t *)src_addr, &mesh_data, recv_ticks * portTICK_PERIOD_MS,
&data_flag, &mesh_opt, 1);
MDF_LOGV("esp_mesh_recv, src_addr: " MACSTR ", size: %d, data: %.*s",
MAC2STR(src_addr), mesh_data.size, mesh_data.size, mesh_data.data);

if (ret == ESP_ERR_MESH_NOT_START) {
MDF_LOGW("<ESP_ERR_MESH_NOT_START> Node failed to receive packets");
vTaskDelay(100 / portTICK_RATE_MS);
vTaskDelay(100 / portTICK_PERIOD_MS);
continue;
} else if (ret == ESP_ERR_MESH_TIMEOUT) {
MDF_LOGD("<MDF_ERR_MWIFI_TIMEOUT> Node failed to receive packets");
Expand Down Expand Up @@ -1338,11 +1338,11 @@ mdf_err_t __mwifi_root_read(uint8_t *src_addr, mwifi_data_type_t *data_type,

/**< Receive a packet targeted to external IP network */
ret = esp_mesh_recv_toDS((mesh_addr_t *)src_addr, &dest_addr,
&mesh_data, recv_ticks * portTICK_RATE_MS, &data_flag, &mesh_opt, 1);
&mesh_data, recv_ticks * portTICK_PERIOD_MS, &data_flag, &mesh_opt, 1);

if (ret == ESP_ERR_MESH_NOT_START) {
MDF_LOGW("<ESP_ERR_MESH_NOT_START> Node failed to receive packets");
vTaskDelay(100 / portTICK_RATE_MS);
vTaskDelay(100 / portTICK_PERIOD_MS);
continue;
} else if (ret == ESP_ERR_MESH_TIMEOUT) {
MDF_LOGD("<MDF_ERR_MWIFI_TIMEOUT> Node failed to receive packets");
Expand Down
4 changes: 2 additions & 2 deletions components/third_party/aliyun_sdk/aliyun_gateway.c
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ static void aliyun_gateway_read_task(void *arg)
if (aliyun_mqtt_get_connet_status() != MDF_OK) { // if mqtt is disconnect, then ignore all data from subdevice
is_login = false;
buffer->payload_len = CONFIG_ALIYUN_PAYLOAD_SIZE;
aliyun_platform_gateway_read(src_addr, &type, buffer->payload, &buffer->payload_len, CONFIG_ALIYUN_READ_TIMROUT_MS / portTICK_RATE_MS);
aliyun_platform_gateway_read(src_addr, &type, buffer->payload, &buffer->payload_len, CONFIG_ALIYUN_READ_TIMROUT_MS / portTICK_PERIOD_MS);
continue;
}

Expand All @@ -789,7 +789,7 @@ static void aliyun_gateway_read_task(void *arg)
}

buffer->payload_len = CONFIG_ALIYUN_PAYLOAD_SIZE;
ret = aliyun_platform_gateway_read(src_addr, &type, buffer->payload, &buffer->payload_len, CONFIG_ALIYUN_READ_TIMROUT_MS / portTICK_RATE_MS);
ret = aliyun_platform_gateway_read(src_addr, &type, buffer->payload, &buffer->payload_len, CONFIG_ALIYUN_READ_TIMROUT_MS / portTICK_PERIOD_MS);

if (ret == MDF_OK) {
aliyun_gateway_process(type, src_addr, buffer);
Expand Down
2 changes: 1 addition & 1 deletion components/third_party/aliyun_sdk/aliyun_subdevice.c
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ static void aliyun_subdevice_task(void *arg)
subdevice_inform_link_loss();
}

ret = aliyun_platform_subdevice_read(&type, (void **)&payload, &length, CONFIG_ALIYUN_READ_TIMROUT_MS / portTICK_RATE_MS);
ret = aliyun_platform_subdevice_read(&type, (void **)&payload, &length, CONFIG_ALIYUN_READ_TIMROUT_MS / portTICK_PERIOD_MS);

if (ret == MDF_OK) {
aliyun_subdevice_subscribe_callback(type, payload, length);
Expand Down
2 changes: 1 addition & 1 deletion components/third_party/aliyun_sdk/message/aliyun_answer.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static mdf_err_t aliyun_answer_mutex_lock(void)
configASSERT(g_aliyun_answer_lock);
}

return xSemaphoreTake(g_aliyun_answer_lock, 10000 / portTICK_RATE_MS) != pdPASS ? MDF_FAIL : MDF_OK;
return xSemaphoreTake(g_aliyun_answer_lock, 10000 / portTICK_PERIOD_MS) != pdPASS ? MDF_FAIL : MDF_OK;
}

static mdf_err_t aliyun_answer_mutex_unlock(void)
Expand Down
2 changes: 1 addition & 1 deletion components/third_party/aliyun_sdk/message/aliyun_cyclic.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static mdf_err_t aliyun_cyclic_mutex_lock(void)
configASSERT(g_aliyun_cyclic_lock);
}

return xSemaphoreTake(g_aliyun_cyclic_lock, 10000 / portTICK_RATE_MS) != pdPASS ? MDF_FAIL : MDF_OK;
return xSemaphoreTake(g_aliyun_cyclic_lock, 10000 / portTICK_PERIOD_MS) != pdPASS ? MDF_FAIL : MDF_OK;
}

static mdf_err_t aliyun_cyclic_mutex_unlock(void)
Expand Down

0 comments on commit 55f9594

Please sign in to comment.