Commit a4fff014 authored by Jozef Kralik's avatar Jozef Kralik

remove warnings

parent 9fc5ba65
Pipeline #1183 passed with stage
in 3 minutes and 38 seconds
......@@ -24,7 +24,7 @@
#include "freertos/event_groups.h"
#include "nvs_flash.h"
#include "esp_wifi.h"
#include "esp_event_loop.h"
#include "esp_event.h"
#include "esp_log.h"
#include "driver/gpio.h"
#include "debug_print.h"
......@@ -146,6 +146,7 @@ signal_event_loop(void)
pthread_mutex_unlock(&mutex);
}
/*
static void
handle_signal(int signal)
{
......@@ -153,58 +154,77 @@ handle_signal(int signal)
signal_event_loop();
quit = 1;
}
*/
static esp_err_t event_handler(void *ctx, system_event_t *event)
static void sta_start(void *esp_netif, esp_event_base_t event_base,
int32_t event_id, void *event_data)
{
switch (event->event_id)
{
case SYSTEM_EVENT_STA_START:
esp_wifi_connect();
break;
case SYSTEM_EVENT_STA_GOT_IP:
xEventGroupSetBits(wifi_event_group, IPV4_CONNECTED_BIT);
break;
case SYSTEM_EVENT_STA_DISCONNECTED:
/* This is a workaround as ESP32 WiFi libs don't currently
auto-reassociate. */
esp_wifi_connect();
xEventGroupClearBits(wifi_event_group, IPV4_CONNECTED_BIT);
xEventGroupClearBits(wifi_event_group, IPV6_CONNECTED_BIT);
break;
esp_wifi_connect();
}
case SYSTEM_EVENT_STA_CONNECTED:
tcpip_adapter_create_ip6_linklocal(TCPIP_ADAPTER_IF_STA);
break;
static void sta_disconnected(void *esp_netif, esp_event_base_t event_base,
int32_t event_id, void *event_data)
{
PRINT("sta_disconnected\n");
esp_wifi_connect();
xEventGroupClearBits(wifi_event_group, IPV4_CONNECTED_BIT);
xEventGroupClearBits(wifi_event_group, IPV6_CONNECTED_BIT);
}
case SYSTEM_EVENT_AP_STA_GOT_IP6:
xEventGroupSetBits(wifi_event_group, IPV6_CONNECTED_BIT);
break;
static void sta_connected(void *esp_netif, esp_event_base_t event_base,
int32_t event_id, void *event_data)
{
esp_netif_create_ip6_linklocal(esp_netif);
}
default:
break;
}
static void got_ip(void *esp_netif, esp_event_base_t event_base,
int32_t event_id, void *event_data)
{
xEventGroupSetBits(wifi_event_group, IPV4_CONNECTED_BIT);
}
return ESP_OK;
static void got_ip6(void *esp_netif, esp_event_base_t event_base,
int32_t event_id, void *event_data)
{
xEventGroupSetBits(wifi_event_group, IPV6_CONNECTED_BIT);
}
static void initialise_wifi(void)
{
esp_netif_init();
wifi_event_group = xEventGroupCreate();
ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL));
esp_netif_create_default_wifi_sta();
esp_err_t err = esp_event_loop_create_default();
if (err != ESP_OK && err != ESP_ERR_INVALID_STATE)
{
ESP_ERROR_CHECK(err);
}
ESP_ERROR_CHECK(esp_netif_init());
char *desc;
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
esp_netif_inherent_config_t esp_netif_config = ESP_NETIF_INHERENT_DEFAULT_WIFI_STA();
// Prefix the interface description with the module TAG
// Warning: the interface desc is used in tests to capture actual connection details (IP, gw, mask)
asprintf(&desc, "%s: %s", TAG, esp_netif_config.if_desc);
esp_netif_config.if_desc = desc;
esp_netif_config.route_prio = 128;
esp_netif_t *netif = esp_netif_create_wifi(WIFI_IF_STA, &esp_netif_config);
free(desc);
ESP_ERROR_CHECK(esp_wifi_set_default_wifi_sta_handlers());
wifi_event_group = xEventGroupCreate();
ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_DISCONNECTED, sta_disconnected, NULL));
ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_START, sta_start, NULL));
ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_CONNECTED, sta_connected, netif));
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, got_ip, NULL));
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_GOT_IP6, got_ip6, NULL));
wifi_config_t wifi_config = {
.sta = {
.ssid = EXAMPLE_WIFI_SSID,
.password = EXAMPLE_WIFI_PASS,
},
};
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config));
ESP_ERROR_CHECK(esp_wifi_start());
......@@ -267,30 +287,29 @@ void factory_presets_cb_new(size_t device, void *data)
PRINT("factory_presets_cb: %d\n", (int)device);
const char *cert = "-----BEGIN CERTIFICATE-----\n"
"MIIEFDCCA7qgAwIBAgIJAI0K+3tTsk4eMAoGCCqGSM49BAMCMFsxDDAKBgNVBAoM\n"
"A09DRjEiMCAGA1UECwwZS3lyaW8gVGVzdCBJbmZyYXN0cnVjdHVyZTEnMCUGA1UE\n"
"AwweS3lyaW8gVEVTVCBJbnRlcm1lZGlhdGUgQ0EwMDAyMB4XDTIwMDQxNDE3MzMy\n"
"NloXDTIwMDUxNDE3MzMyNlowYTEMMAoGA1UECgwDT0NGMSIwIAYDVQQLDBlLeXJp\n"
"byBUZXN0IEluZnJhc3RydWN0dXJlMS0wKwYDVQQDDCQyYjI1ODQ4Mi04ZDZhLTQ5\n"
"OTEtOGQ2OS0zMTAxNDE5ODE2NDYwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARZ\n"
"H0LnMEg5BR41xctwQMPoNwa0ERVB1J9WWUvdrKq4GVkX/HwPUGvViISpmIS0GM8z\n"
"Ky2IjHm+rMrc4oSTfyX0o4ICXzCCAlswCQYDVR0TBAIwADAOBgNVHQ8BAf8EBAMC\n"
"A4gwKQYDVR0lBCIwIAYIKwYBBQUHAwIGCCsGAQUFBwMBBgorBgEEAYLefAEGMB0G\n"
"A1UdDgQWBBTS5/x0htLNUYt8JoL82HU2rkjuWDAfBgNVHSMEGDAWgBQZc2oEGgsH\n"
"cE9TeVM2h/wMunyuCzCBlgYIKwYBBQUHAQEEgYkwg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n"
"MDAGCisGAQQBg5FWAQIEIjAgDA4xLjMuNi4xLjQuMS43MQwJRGlzY292ZXJ5DAMx\n"
"LjAwCgYIKoZIzj0EAwIDSAAwRQIgedG7zHeLh9YzM0bU3DQBnKDRIFnJHiDayyuE\n"
"8pVfJOQCIQCo/llZOZD87IHzsyxEfXm/QhkTNA5WJOa7sjF2ngQ1/g==\n"
"-----END CERTIFICATE-----\n";
const char *key = "-----BEGIN EC PARAMETERS-----\n"
"BggqhkjOPQMBBw==\n"
......@@ -301,37 +320,37 @@ void factory_presets_cb_new(size_t device, void *data)
"1YiEqZiEtBjPMystiIx5vqzK3OKEk38l9A==\n"
"-----END EC PRIVATE KEY-----\n";
const char *inter_ca = "-----BEGIN CERTIFICATE-----\n"
"MIIC+jCCAqGgAwIBAgIJAPObjMBXKhG1MAoGCCqGSM49BAMCMFMxDDAKBgNVBAoM\n"
"A09DRjEiMCAGA1UECwwZS3lyaW8gVGVzdCBJbmZyYXN0cnVjdHVyZTEfMB0GA1UE\n"
"AwwWS3lyaW8gVEVTVCBST09UIENBMDAwMjAeFw0xODExMzAxODEyMTVaFw0yODEx\n"
"MjYxODEyMTVaMFsxDDAKBgNVBAoMA09DRjEiMCAGA1UECwwZS3lyaW8gVGVzdCBJ\n"
"bmZyYXN0cnVjdHVyZTEnMCUGA1UEAwweS3lyaW8gVEVTVCBJbnRlcm1lZGlhdGUg\n"
"Q0EwMDAyMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEvA+Gn3ofRpH40XuVppBR\n"
"f78mDtfclOkBd7/32yQcmK2LQ0wm/uyl2cyeABPuN6NFcR9+LYkXZ5P4Ovy9R43Q\n"
"vqOCAVQwggFQMBIGA1UdEwEB/wQIMAYBAf8CAQAwDgYDVR0PAQH/BAQDAgGGMB0G\n"
"A1UdDgQWBBQZc2oEGgsHcE9TeVM2h/wMunyuCzAfBgNVHSMEGDAWgBQoSOTlJ1jZ\n"
"CO4JNOSxuz1ZZh/I9TCBjQYIKwY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/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBQoSOTlJ1jZ\n"
"CO4JNOSxuz1ZZh/I9TAKBggqhkjOPQQDAgNIADBFAiAlMUwgVeL8d5W4jZdFJ5Zg\n"
"clk7XT66LNMfGkExSjU1ngIhANOvTmd32A0kEtIpHbiKA8+RFDCPJWjN4loxrBC7\n"
"v0JE\n"
"-----END CERTIFICATE-----\n";
"MIIB3zCCAYWgAwIBAgIJAPObjMBXKhGyMAoGCCqGSM49BAMCMFMxDDAKBgNVBAoM\n"
"A09DRjEiMCAGA1UECwwZS3lyaW8gVGVzdCBJbmZyYXN0cnVjdHVyZTEfMB0GA1UE\n"
"AwwWS3lyaW8gVEVTVCBST09UIENBMDAwMjAeFw0xODExMzAxNzMxMDVaFw0yODEx\n"
"MjcxNzMxMDVaMFMxDDAKBgNVBAoMA09DRjEiMCAGA1UECwwZS3lyaW8gVGVzdCBJ\n"
"bmZyYXN0cnVjdHVyZTEfMB0GA1UEAwwWS3lyaW8gVEVTVCBST09UIENBMDAwMjBZ\n"
"MBMGByqGSM49AgEGCCqGSM49AwEHA0IABGt1sU2QhQcK/kflKSF9TCrvKaDckLWd\n"
"ZoyvP6z0OrqNdtBscZgVYsSHMQZ1R19wWxsflvNr8bMVW1K3HWMkpsijQjBAMA8G\n"
"A1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBQoSOTlJ1jZ\n"
"CO4JNOSxuz1ZZh/I9TAKBggqhkjOPQQDAgNIADBFAiAlMUwgVeL8d5W4jZdFJ5Zg\n"
"clk7XT66LNMfGkExSjU1ngIhANOvTmd32A0kEtIpHbiKA8+RFDCPJWjN4loxrBC7\n"
"v0JE\n"
"-----END CERTIFICATE-----\n";
int ee_credid = oc_pki_add_mfg_cert(0, (const unsigned char *)cert, strlen(cert),
(const unsigned char *)key, strlen(key));
......@@ -343,7 +362,8 @@ void factory_presets_cb_new(size_t device, void *data)
int subca_credid = oc_pki_add_mfg_intermediate_cert(0, ee_credid, (const unsigned char *)inter_ca, strlen(inter_ca));
if (subca_credid < 0) {
if (subca_credid < 0)
{
PRINT("ERROR installing intermediate CA cert\n");
return;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment