Changed from tcpip_adapter_get_ip_info to esp_netif_get_ip_info
This commit is contained in:
@@ -1,16 +0,0 @@
|
|||||||
#
|
|
||||||
# This is a project Makefile. It is assumed the directory this Makefile resides in is a
|
|
||||||
# project subdirectory.
|
|
||||||
#
|
|
||||||
|
|
||||||
PROJECT_NAME := can2mqtt
|
|
||||||
|
|
||||||
include $(IDF_PATH)/make/project.mk
|
|
||||||
|
|
||||||
# Create a SPIFFS image from the contents of the 'spiffs_image' directory
|
|
||||||
# that fits the partition named 'storage'. FLASH_IN_PROJECT indicates that
|
|
||||||
# the generated image should be flashed when the entire project is flashed to
|
|
||||||
# the target with 'make flash'.
|
|
||||||
SPIFFS_IMAGE_FLASH_IN_PROJECT := 1
|
|
||||||
$(eval $(call spiffs_create_partition_image,storage,csv))
|
|
||||||
|
|
||||||
+12
-7
@@ -1,10 +1,10 @@
|
|||||||
/* ESP HTTP Client Example
|
/* ESP HTTP Client Example
|
||||||
|
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, this
|
Unless required by applicable law or agreed to in writing, this
|
||||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||||
CONDITIONS OF ANY KIND, either express or implied.
|
CONDITIONS OF ANY KIND, either express or implied.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -90,6 +90,11 @@ esp_err_t _http_event_handler(esp_http_client_event_t *evt)
|
|||||||
ESP_LOGI(TAG, "Last mbedtls failure: 0x%x", mbedtls_err);
|
ESP_LOGI(TAG, "Last mbedtls failure: 0x%x", mbedtls_err);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case HTTP_EVENT_REDIRECT:
|
||||||
|
ESP_LOGD(TAG, "HTTP_EVENT_REDIRECT");
|
||||||
|
esp_http_client_set_header(evt->client, "From", "user@example.com");
|
||||||
|
esp_http_client_set_header(evt->client, "Accept", "text/html");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
@@ -111,7 +116,7 @@ static void http_rest_with_url(char * path, char * post_data)
|
|||||||
.port = CONFIG_WEB_PORT,
|
.port = CONFIG_WEB_PORT,
|
||||||
.path = path,
|
.path = path,
|
||||||
.event_handler = _http_event_handler,
|
.event_handler = _http_event_handler,
|
||||||
.user_data = local_response_buffer, // Pass address of local buffer to get response
|
.user_data = local_response_buffer, // Pass address of local buffer to get response
|
||||||
.disable_auto_redirect = true,
|
.disable_auto_redirect = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -120,7 +125,7 @@ static void http_rest_with_url(char * path, char * post_data)
|
|||||||
esp_http_client_config_t config = {
|
esp_http_client_config_t config = {
|
||||||
.url = "http://192.168.10.43:8000/post",
|
.url = "http://192.168.10.43:8000/post",
|
||||||
.event_handler = _http_event_handler,
|
.event_handler = _http_event_handler,
|
||||||
.user_data = local_response_buffer, // Pass address of local buffer to get response
|
.user_data = local_response_buffer, // Pass address of local buffer to get response
|
||||||
.disable_auto_redirect = true,
|
.disable_auto_redirect = true,
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@@ -148,7 +153,7 @@ static void http_rest_with_url(char * path, char * post_data)
|
|||||||
|
|
||||||
void http_client_task(void *pvParameters)
|
void http_client_task(void *pvParameters)
|
||||||
{
|
{
|
||||||
ESP_LOGI(TAG, "Start HTTP Client: http://%s:%d", CONFIG_WEB_SERVER, CONFIG_WEB_PORT);
|
ESP_LOGI(TAG, "Start HTTP Client: connect to http://%s:%d", CONFIG_WEB_SERVER, CONFIG_WEB_PORT);
|
||||||
FRAME_t frameBuf;
|
FRAME_t frameBuf;
|
||||||
while (1) {
|
while (1) {
|
||||||
xQueueReceive(xQueue_http_client, &frameBuf, portMAX_DELAY);
|
xQueueReceive(xQueue_http_client, &frameBuf, portMAX_DELAY);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "esp_vfs.h"
|
#include "esp_vfs.h"
|
||||||
#include "esp_spiffs.h"
|
#include "esp_spiffs.h"
|
||||||
#include "esp_http_server.h"
|
#include "esp_http_server.h"
|
||||||
|
#include "esp_chip_info.h"
|
||||||
#include "cJSON.h"
|
#include "cJSON.h"
|
||||||
#include "driver/twai.h"
|
#include "driver/twai.h"
|
||||||
|
|
||||||
|
|||||||
+7
-13
@@ -104,19 +104,10 @@ void wifi_init_sta()
|
|||||||
ESP_LOGI(TAG,"ESP-IDF Ver%d.%d", ESP_IDF_VERSION_MAJOR, ESP_IDF_VERSION_MINOR);
|
ESP_LOGI(TAG,"ESP-IDF Ver%d.%d", ESP_IDF_VERSION_MAJOR, ESP_IDF_VERSION_MINOR);
|
||||||
ESP_LOGI(TAG,"ESP_IDF_VERSION %d", ESP_IDF_VERSION);
|
ESP_LOGI(TAG,"ESP_IDF_VERSION %d", ESP_IDF_VERSION);
|
||||||
|
|
||||||
//#if ESP_IDF_VERSION_MAJOR >= 4 && ESP_IDF_VERSION_MINOR >= 1
|
|
||||||
#if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(4, 1, 0)
|
|
||||||
ESP_LOGI(TAG,"ESP-IDF esp_netif");
|
|
||||||
ESP_ERROR_CHECK(esp_netif_init());
|
ESP_ERROR_CHECK(esp_netif_init());
|
||||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||||
esp_netif_t *netif = esp_netif_create_default_wifi_sta();
|
esp_netif_t *netif = esp_netif_create_default_wifi_sta();
|
||||||
assert(netif);
|
assert(netif);
|
||||||
#else
|
|
||||||
ESP_LOGE(TAG,"esp-idf version 4.1 or higher required");
|
|
||||||
while(1) {
|
|
||||||
vTaskDelay(1);
|
|
||||||
}
|
|
||||||
#endif // ESP_IDF_VERSION
|
|
||||||
|
|
||||||
#if CONFIG_STATIC_IP
|
#if CONFIG_STATIC_IP
|
||||||
|
|
||||||
@@ -357,7 +348,7 @@ esp_err_t build_table(TOPIC_t **topics, char *file, int16_t *ntopic)
|
|||||||
void dump_table(TOPIC_t *topics, int16_t ntopic)
|
void dump_table(TOPIC_t *topics, int16_t ntopic)
|
||||||
{
|
{
|
||||||
for(int i=0;i<ntopic;i++) {
|
for(int i=0;i<ntopic;i++) {
|
||||||
ESP_LOGI(pcTaskGetTaskName(0), "topics[%d] frame=%d canid=0x%x topic=[%s] topic_len=%d",
|
ESP_LOGI(pcTaskGetName(0), "topics[%d] frame=%d canid=0x%x topic=[%s] topic_len=%d",
|
||||||
i, (topics+i)->frame, (topics+i)->canid, (topics+i)->topic, (topics+i)->topic_len);
|
i, (topics+i)->frame, (topics+i)->canid, (topics+i)->topic, (topics+i)->topic_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,11 +407,14 @@ void app_main()
|
|||||||
dump_table(publish, npublish);
|
dump_table(publish, npublish);
|
||||||
|
|
||||||
/* Get the local IP address */
|
/* Get the local IP address */
|
||||||
tcpip_adapter_ip_info_t ip_info;
|
//tcpip_adapter_ip_info_t ip_info;
|
||||||
ESP_ERROR_CHECK(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip_info));
|
//ESP_ERROR_CHECK(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip_info));
|
||||||
|
esp_netif_ip_info_t ip_info;
|
||||||
|
ESP_ERROR_CHECK(esp_netif_get_ip_info(esp_netif_get_handle_from_ifkey("WIFI_STA_DEF"), &ip_info));
|
||||||
|
|
||||||
char cparam0[64];
|
char cparam0[64];
|
||||||
sprintf(cparam0, "%s", ip4addr_ntoa(&ip_info.ip));
|
//sprintf(cparam0, "%s", ip4addr_ntoa(&ip_info.ip));
|
||||||
|
sprintf(cparam0, IPSTR, IP2STR(&ip_info.ip));
|
||||||
xTaskCreate(http_server_task, "server", 1024*6, (void *)cparam0, 2, NULL);
|
xTaskCreate(http_server_task, "server", 1024*6, (void *)cparam0, 2, NULL);
|
||||||
|
|
||||||
xTaskCreate(http_client_task, "client", 1024*6, NULL, 2, NULL);
|
xTaskCreate(http_client_task, "client", 1024*6, NULL, 2, NULL);
|
||||||
|
|||||||
+1
-1
@@ -50,7 +50,7 @@ void twai_task(void *pvParameters)
|
|||||||
|
|
||||||
#if CONFIG_ENABLE_PRINT
|
#if CONFIG_ENABLE_PRINT
|
||||||
if (ext == STANDARD_FRAME) {
|
if (ext == STANDARD_FRAME) {
|
||||||
printf("Standard ID: 0x%03x ", rx_msg.identifier);
|
printf("Standard ID: 0x%03x ", rx_msg.identifier);
|
||||||
} else {
|
} else {
|
||||||
printf("Extended ID: 0x%08x", rx_msg.identifier);
|
printf("Extended ID: 0x%08x", rx_msg.identifier);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,12 +5,6 @@ CONFIG_PARTITION_TABLE_CUSTOM=y
|
|||||||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
|
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
|
||||||
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"
|
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"
|
||||||
|
|
||||||
#
|
|
||||||
# ESP32-specific
|
|
||||||
#
|
|
||||||
CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y
|
|
||||||
CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=240
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# mDNS
|
# mDNS
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user