upgrade to IDF v5.1.1

custom board driver ma120x0 is broken
esp dsp is now IDF managed component
mdns is now IDF managed component

Signed-off-by: Karl Osterseher <karli_o@gmx.at>
This commit is contained in:
Karl Osterseher
2024-01-08 22:49:11 +01:00
Unverified
parent 713cda5816
commit db0f9732b2
454 changed files with 29632 additions and 39819 deletions

View File

@@ -1,3 +1,3 @@
idf_component_register(SRCS "net_functions.c"
INCLUDE_DIRS "include"
REQUIRES mdns wifi_interface)
REQUIRES mdns wifi_interface driver)

View File

@@ -24,136 +24,113 @@ static const char *TAG = "NETF";
extern EventGroupHandle_t s_wifi_event_group;
static const char *if_str[] = { "STA", "AP", "ETH", "MAX" };
static const char *ip_protocol_str[] = { "V4", "V6", "MAX" };
static const char *if_str[] = {"STA", "AP", "ETH", "MAX"};
static const char *ip_protocol_str[] = {"V4", "V6", "MAX"};
void
net_mdns_register (const char *clientname)
{
ESP_LOGI (TAG, "Setup mdns");
ESP_ERROR_CHECK (mdns_init ());
ESP_ERROR_CHECK (mdns_hostname_set (clientname));
ESP_ERROR_CHECK (mdns_instance_name_set ("ESP32 SNAPcast client OTA"));
ESP_ERROR_CHECK (mdns_service_add (NULL, "_http", "_tcp", 8032, NULL, 0));
void net_mdns_register(const char *clientname) {
ESP_LOGI(TAG, "Setup mdns");
ESP_ERROR_CHECK(mdns_init());
ESP_ERROR_CHECK(mdns_hostname_set(clientname));
ESP_ERROR_CHECK(mdns_instance_name_set("ESP32 SNAPcast client OTA"));
ESP_ERROR_CHECK(mdns_service_add(NULL, "_http", "_tcp", 8032, NULL, 0));
}
void
mdns_print_results (mdns_result_t *results)
{
void mdns_print_results(mdns_result_t *results) {
mdns_result_t *r = results;
mdns_ip_addr_t *a = NULL;
int i = 1, t;
while (r)
{
printf ("%d: Interface: %s, Type: %s\n", i++, if_str[r->tcpip_if],
ip_protocol_str[r->ip_protocol]);
if (r->instance_name)
{
printf (" PTR : %s\n", r->instance_name);
}
if (r->hostname)
{
printf (" SRV : %s.local:%u\n", r->hostname, r->port);
}
if (r->txt_count)
{
printf (" TXT : [%u] ", r->txt_count);
for (t = 0; t < r->txt_count; t++)
{
printf ("%s=%s; ", r->txt[t].key, r->txt[t].value);
}
printf ("\n");
}
a = r->addr;
while (a)
{
if (a->addr.type == IPADDR_TYPE_V6)
{
printf (" AAAA: " IPV6STR "\n", IPV62STR (a->addr.u_addr.ip6));
}
else
{
printf (" A : " IPSTR "\n", IP2STR (&(a->addr.u_addr.ip4)));
}
a = a->next;
}
r = r->next;
while (r) {
// printf ("%d: Interface: %s, Type: %s\n", i++, if_str[r->tcpip_if],
// ip_protocol_str[r->ip_protocol]);
printf("%d: Type: %s\n", i++, ip_protocol_str[r->ip_protocol]);
if (r->instance_name) {
printf(" PTR : %s\n", r->instance_name);
}
if (r->hostname) {
printf(" SRV : %s.local:%u\n", r->hostname, r->port);
}
if (r->txt_count) {
printf(" TXT : [%u] ", r->txt_count);
for (t = 0; t < r->txt_count; t++) {
printf("%s=%s; ", r->txt[t].key, r->txt[t].value);
}
printf("\n");
}
a = r->addr;
while (a) {
if (a->addr.type == IPADDR_TYPE_V6) {
printf(" AAAA: " IPV6STR "\n", IPV62STR(a->addr.u_addr.ip6));
} else {
printf(" A : " IPSTR "\n", IP2STR(&(a->addr.u_addr.ip4)));
}
a = a->next;
}
r = r->next;
}
}
uint32_t
find_mdns_service (const char *service_name, const char *proto)
{
ESP_LOGI (TAG, "Query PTR: %s.%s.local", service_name, proto);
uint32_t find_mdns_service(const char *service_name, const char *proto) {
ESP_LOGI(TAG, "Query PTR: %s.%s.local", service_name, proto);
mdns_result_t *r = NULL;
esp_err_t err = mdns_query_ptr (service_name, proto, 3000, 20, &r);
if (err)
{
ESP_LOGE (TAG, "Query Failed");
return -1;
}
if (!r)
{
ESP_LOGW (TAG, "No results found!");
return -1;
}
esp_err_t err = mdns_query_ptr(service_name, proto, 3000, 20, &r);
if (err) {
ESP_LOGE(TAG, "Query Failed");
return -1;
}
if (!r) {
ESP_LOGW(TAG, "No results found!");
return -1;
}
if (r->instance_name)
{
printf (" PTR : %s\n", r->instance_name);
}
if (r->hostname)
{
printf (" SRV : %s.local:%u\n", r->hostname, r->port);
return r->port;
}
mdns_query_results_free (r);
if (r->instance_name) {
printf(" PTR : %s\n", r->instance_name);
}
if (r->hostname) {
printf(" SRV : %s.local:%u\n", r->hostname, r->port);
return r->port;
}
mdns_query_results_free(r);
return 0;
}
/**
*
*/
void
sntp_cb (struct timeval *tv)
{
struct tm timeinfo = { 0 };
void sntp_cb(struct timeval *tv) {
struct tm timeinfo = {0};
time_t now = tv->tv_sec;
localtime_r (&now, &timeinfo);
localtime_r(&now, &timeinfo);
char strftime_buf[64];
strftime (strftime_buf, sizeof (strftime_buf), "%c", &timeinfo);
ESP_LOGI (TAG, "sntp_cb called :%s", strftime_buf);
strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo);
ESP_LOGI(TAG, "sntp_cb called :%s", strftime_buf);
}
void
set_time_from_sntp ()
{
xEventGroupWaitBits (s_wifi_event_group, WIFI_CONNECTED_BIT, false, true,
portMAX_DELAY);
void set_time_from_sntp() {
xEventGroupWaitBits(s_wifi_event_group, WIFI_CONNECTED_BIT, false, true,
portMAX_DELAY);
// ESP_LOGI(TAG, "clock %");
ESP_LOGI (TAG, "Initializing SNTP");
sntp_setoperatingmode (SNTP_OPMODE_POLL);
sntp_setservername (0, CONFIG_SNTP_SERVER);
sntp_init ();
ESP_LOGI(TAG, "Initializing SNTP");
sntp_setoperatingmode(SNTP_OPMODE_POLL);
sntp_setservername(0, CONFIG_SNTP_SERVER);
sntp_init();
// sntp_set_time_sync_notification_cb(sntp_cb);
setenv ("TZ", SNTP_TIMEZONE, 1);
tzset ();
setenv("TZ", SNTP_TIMEZONE, 1);
tzset();
time_t now = 0;
struct tm timeinfo = { 0 };
struct tm timeinfo = {0};
int retry = 0;
const int retry_count = 10;
while (timeinfo.tm_year < (2016 - 1900) && ++retry < retry_count)
{
ESP_LOGI (TAG, "Waiting for system time to be set... (%d/%d)", retry,
retry_count);
vTaskDelay (2000 / portTICK_PERIOD_MS);
time (&now);
localtime_r (&now, &timeinfo);
}
while (timeinfo.tm_year < (2016 - 1900) && ++retry < retry_count) {
ESP_LOGI(TAG, "Waiting for system time to be set... (%d/%d)", retry,
retry_count);
vTaskDelay(2000 / portTICK_PERIOD_MS);
time(&now);
localtime_r(&now, &timeinfo);
}
char strftime_buf[64];
strftime (strftime_buf, sizeof (strftime_buf), "%c", &timeinfo);
ESP_LOGI (TAG, "The current date/time in UTC is: %s", strftime_buf);
strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo);
ESP_LOGI(TAG, "The current date/time in UTC is: %s", strftime_buf);
}