- major change, use lwip netconn instead of socket API to reduce RAM footprint
o flac works, opus and pcm are untested and not working - improve on resyncing issues - add wifi logger component submodule - optimize stack sizes
This commit is contained in:
@@ -9,9 +9,9 @@
|
||||
|
||||
#define I2S_PORT I2S_NUM_0
|
||||
|
||||
#define LATENCY_MEDIAN_FILTER_LEN 49 // 99
|
||||
#define LATENCY_MEDIAN_FILTER_LEN 29 // 99
|
||||
|
||||
#define SHORT_BUFFER_LEN 29
|
||||
#define SHORT_BUFFER_LEN 9
|
||||
|
||||
typedef struct pcm_chunk_fragment pcm_chunk_fragment_t;
|
||||
struct pcm_chunk_fragment
|
||||
@@ -29,7 +29,7 @@ typedef struct pcm_chunk_message
|
||||
|
||||
typedef enum codec_type_e
|
||||
{
|
||||
NONE,
|
||||
NONE = 0,
|
||||
PCM,
|
||||
FLAC,
|
||||
OGG,
|
||||
@@ -57,7 +57,11 @@ typedef struct snapcastSetting_s
|
||||
int init_player (void);
|
||||
int deinit_player (void);
|
||||
|
||||
int8_t insert_pcm_chunk (wire_chunk_message_t *decodedWireChunk);
|
||||
int8_t allocate_pcm_chunk_memory (pcm_chunk_message_t **pcmChunk,
|
||||
size_t bytes);
|
||||
int8_t insert_pcm_chunk (wire_chunk_message_t *pcmChunk);
|
||||
|
||||
// int8_t insert_pcm_chunk (wire_chunk_message_t *decodedWireChunk);
|
||||
int8_t free_pcm_chunk (pcm_chunk_message_t *pcmChunk);
|
||||
|
||||
int8_t player_latency_insert (int64_t newValue);
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
enum message_type {
|
||||
enum message_type
|
||||
{
|
||||
SNAPCAST_MESSAGE_BASE = 0,
|
||||
SNAPCAST_MESSAGE_CODEC_HEADER = 1,
|
||||
SNAPCAST_MESSAGE_WIRE_CHUNK = 2,
|
||||
@@ -18,12 +19,14 @@ enum message_type {
|
||||
SNAPCAST_MESSAGE_LAST = SNAPCAST_MESSAGE_STREAM_TAGS
|
||||
};
|
||||
|
||||
typedef struct tv {
|
||||
typedef struct tv
|
||||
{
|
||||
int32_t sec;
|
||||
int32_t usec;
|
||||
} tv_t;
|
||||
|
||||
typedef struct base_message {
|
||||
typedef struct base_message
|
||||
{
|
||||
uint16_t type;
|
||||
uint16_t id;
|
||||
uint16_t refersTo;
|
||||
@@ -32,13 +35,13 @@ typedef struct base_message {
|
||||
uint32_t size;
|
||||
} base_message_t;
|
||||
|
||||
extern const int BASE_MESSAGE_SIZE;
|
||||
extern const int TIME_MESSAGE_SIZE;
|
||||
#define BASE_MESSAGE_SIZE 26
|
||||
#define TIME_MESSAGE_SIZE 8
|
||||
|
||||
int base_message_serialize(base_message_t *msg, char *data, uint32_t size);
|
||||
int base_message_serialize (base_message_t *msg, char *data, uint32_t size);
|
||||
|
||||
int base_message_deserialize(base_message_t *msg, const char *data,
|
||||
uint32_t size);
|
||||
int base_message_deserialize (base_message_t *msg, const char *data,
|
||||
uint32_t size);
|
||||
|
||||
/* Sample Hello message
|
||||
{
|
||||
@@ -54,7 +57,8 @@ int base_message_deserialize(base_message_t *msg, const char *data,
|
||||
}
|
||||
*/
|
||||
|
||||
typedef struct hello_message {
|
||||
typedef struct hello_message
|
||||
{
|
||||
char *mac;
|
||||
char *hostname;
|
||||
char *version;
|
||||
@@ -66,45 +70,49 @@ typedef struct hello_message {
|
||||
int protocol_version;
|
||||
} hello_message_t;
|
||||
|
||||
char *hello_message_serialize(hello_message_t *msg, size_t *size);
|
||||
char *hello_message_serialize (hello_message_t *msg, size_t *size);
|
||||
|
||||
typedef struct server_settings_message {
|
||||
typedef struct server_settings_message
|
||||
{
|
||||
int32_t buffer_ms;
|
||||
int32_t latency;
|
||||
uint32_t volume;
|
||||
bool muted;
|
||||
} server_settings_message_t;
|
||||
|
||||
int server_settings_message_deserialize(server_settings_message_t *msg,
|
||||
const char *json_str);
|
||||
int server_settings_message_deserialize (server_settings_message_t *msg,
|
||||
const char *json_str);
|
||||
|
||||
typedef struct codec_header_message {
|
||||
typedef struct codec_header_message
|
||||
{
|
||||
char *codec;
|
||||
uint32_t size;
|
||||
char *payload;
|
||||
} codec_header_message_t;
|
||||
|
||||
int codec_header_message_deserialize(codec_header_message_t *msg,
|
||||
const char *data, uint32_t size);
|
||||
void codec_header_message_free(codec_header_message_t *msg);
|
||||
int codec_header_message_deserialize (codec_header_message_t *msg,
|
||||
const char *data, uint32_t size);
|
||||
void codec_header_message_free (codec_header_message_t *msg);
|
||||
|
||||
typedef struct wire_chunk_message {
|
||||
typedef struct wire_chunk_message
|
||||
{
|
||||
tv_t timestamp;
|
||||
size_t size;
|
||||
char *payload;
|
||||
} wire_chunk_message_t;
|
||||
|
||||
// TODO currently copies, could be made to not copy probably
|
||||
int wire_chunk_message_deserialize(wire_chunk_message_t *msg, const char *data,
|
||||
uint32_t size);
|
||||
void wire_chunk_message_free(wire_chunk_message_t *msg);
|
||||
int wire_chunk_message_deserialize (wire_chunk_message_t *msg,
|
||||
const char *data, uint32_t size);
|
||||
void wire_chunk_message_free (wire_chunk_message_t *msg);
|
||||
|
||||
typedef struct time_message {
|
||||
typedef struct time_message
|
||||
{
|
||||
tv_t latency;
|
||||
} time_message_t;
|
||||
|
||||
int time_message_serialize(time_message_t *msg, char *data, uint32_t size);
|
||||
int time_message_deserialize(time_message_t *msg, const char *data,
|
||||
uint32_t size);
|
||||
int time_message_serialize (time_message_t *msg, char *data, uint32_t size);
|
||||
int time_message_deserialize (time_message_t *msg, const char *data,
|
||||
uint32_t size);
|
||||
|
||||
#endif // __SNAPCAST_H__
|
||||
#endif // __SNAPCAST_H__
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,47 +19,49 @@
|
||||
/* Logging tag */
|
||||
static const char *TAG = "libSNAPCAST";
|
||||
|
||||
const int BASE_MESSAGE_SIZE = 26;
|
||||
const int TIME_MESSAGE_SIZE = 8;
|
||||
|
||||
int base_message_serialize(base_message_t *msg, char *data, uint32_t size) {
|
||||
int
|
||||
base_message_serialize (base_message_t *msg, char *data, uint32_t size)
|
||||
{
|
||||
write_buffer_t buffer;
|
||||
int result = 0;
|
||||
|
||||
buffer_write_init(&buffer, data, size);
|
||||
buffer_write_init (&buffer, data, size);
|
||||
|
||||
result |= buffer_write_uint16(&buffer, msg->type);
|
||||
result |= buffer_write_uint16(&buffer, msg->id);
|
||||
result |= buffer_write_uint16(&buffer, msg->refersTo);
|
||||
result |= buffer_write_int32(&buffer, msg->sent.sec);
|
||||
result |= buffer_write_int32(&buffer, msg->sent.usec);
|
||||
result |= buffer_write_int32(&buffer, msg->received.sec);
|
||||
result |= buffer_write_int32(&buffer, msg->received.usec);
|
||||
result |= buffer_write_uint32(&buffer, msg->size);
|
||||
result |= buffer_write_uint16 (&buffer, msg->type);
|
||||
result |= buffer_write_uint16 (&buffer, msg->id);
|
||||
result |= buffer_write_uint16 (&buffer, msg->refersTo);
|
||||
result |= buffer_write_int32 (&buffer, msg->sent.sec);
|
||||
result |= buffer_write_int32 (&buffer, msg->sent.usec);
|
||||
result |= buffer_write_int32 (&buffer, msg->received.sec);
|
||||
result |= buffer_write_int32 (&buffer, msg->received.usec);
|
||||
result |= buffer_write_uint32 (&buffer, msg->size);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int base_message_deserialize(base_message_t *msg, const char *data,
|
||||
uint32_t size) {
|
||||
int
|
||||
base_message_deserialize (base_message_t *msg, const char *data, uint32_t size)
|
||||
{
|
||||
read_buffer_t buffer;
|
||||
int result = 0;
|
||||
|
||||
buffer_read_init(&buffer, data, size);
|
||||
buffer_read_init (&buffer, data, size);
|
||||
|
||||
result |= buffer_read_uint16(&buffer, &(msg->type));
|
||||
result |= buffer_read_uint16(&buffer, &(msg->id));
|
||||
result |= buffer_read_uint16(&buffer, &(msg->refersTo));
|
||||
result |= buffer_read_int32(&buffer, &(msg->sent.sec));
|
||||
result |= buffer_read_int32(&buffer, &(msg->sent.usec));
|
||||
result |= buffer_read_int32(&buffer, &(msg->received.sec));
|
||||
result |= buffer_read_int32(&buffer, &(msg->received.usec));
|
||||
result |= buffer_read_uint32(&buffer, &(msg->size));
|
||||
result |= buffer_read_uint16 (&buffer, &(msg->type));
|
||||
result |= buffer_read_uint16 (&buffer, &(msg->id));
|
||||
result |= buffer_read_uint16 (&buffer, &(msg->refersTo));
|
||||
result |= buffer_read_int32 (&buffer, &(msg->sent.sec));
|
||||
result |= buffer_read_int32 (&buffer, &(msg->sent.usec));
|
||||
result |= buffer_read_int32 (&buffer, &(msg->received.sec));
|
||||
result |= buffer_read_int32 (&buffer, &(msg->received.usec));
|
||||
result |= buffer_read_uint32 (&buffer, &(msg->size));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static cJSON *hello_message_to_json(hello_message_t *msg) {
|
||||
static cJSON *
|
||||
hello_message_to_json (hello_message_t *msg)
|
||||
{
|
||||
cJSON *mac;
|
||||
cJSON *hostname;
|
||||
cJSON *version;
|
||||
@@ -71,257 +73,304 @@ static cJSON *hello_message_to_json(hello_message_t *msg) {
|
||||
cJSON *protocol_version;
|
||||
cJSON *json = NULL;
|
||||
|
||||
json = cJSON_CreateObject();
|
||||
if (!json) {
|
||||
goto error;
|
||||
}
|
||||
json = cJSON_CreateObject ();
|
||||
if (!json)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
mac = cJSON_CreateString(msg->mac);
|
||||
if (!mac) {
|
||||
goto error;
|
||||
}
|
||||
cJSON_AddItemToObject(json, "MAC", mac);
|
||||
mac = cJSON_CreateString (msg->mac);
|
||||
if (!mac)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
cJSON_AddItemToObject (json, "MAC", mac);
|
||||
|
||||
hostname = cJSON_CreateString(msg->hostname);
|
||||
if (!hostname) {
|
||||
goto error;
|
||||
}
|
||||
cJSON_AddItemToObject(json, "HostName", hostname);
|
||||
hostname = cJSON_CreateString (msg->hostname);
|
||||
if (!hostname)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
cJSON_AddItemToObject (json, "HostName", hostname);
|
||||
|
||||
version = cJSON_CreateString(msg->version);
|
||||
if (!version) {
|
||||
goto error;
|
||||
}
|
||||
cJSON_AddItemToObject(json, "Version", version);
|
||||
version = cJSON_CreateString (msg->version);
|
||||
if (!version)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
cJSON_AddItemToObject (json, "Version", version);
|
||||
|
||||
client_name = cJSON_CreateString(msg->client_name);
|
||||
if (!client_name) {
|
||||
goto error;
|
||||
}
|
||||
cJSON_AddItemToObject(json, "ClientName", client_name);
|
||||
client_name = cJSON_CreateString (msg->client_name);
|
||||
if (!client_name)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
cJSON_AddItemToObject (json, "ClientName", client_name);
|
||||
|
||||
os = cJSON_CreateString(msg->os);
|
||||
if (!os) {
|
||||
goto error;
|
||||
}
|
||||
cJSON_AddItemToObject(json, "OS", os);
|
||||
os = cJSON_CreateString (msg->os);
|
||||
if (!os)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
cJSON_AddItemToObject (json, "OS", os);
|
||||
|
||||
arch = cJSON_CreateString(msg->arch);
|
||||
if (!arch) {
|
||||
goto error;
|
||||
}
|
||||
cJSON_AddItemToObject(json, "Arch", arch);
|
||||
arch = cJSON_CreateString (msg->arch);
|
||||
if (!arch)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
cJSON_AddItemToObject (json, "Arch", arch);
|
||||
|
||||
instance = cJSON_CreateNumber(msg->instance);
|
||||
if (!instance) {
|
||||
goto error;
|
||||
}
|
||||
cJSON_AddItemToObject(json, "Instance", instance);
|
||||
instance = cJSON_CreateNumber (msg->instance);
|
||||
if (!instance)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
cJSON_AddItemToObject (json, "Instance", instance);
|
||||
|
||||
id = cJSON_CreateString(msg->id);
|
||||
if (!id) {
|
||||
goto error;
|
||||
}
|
||||
cJSON_AddItemToObject(json, "ID", id);
|
||||
id = cJSON_CreateString (msg->id);
|
||||
if (!id)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
cJSON_AddItemToObject (json, "ID", id);
|
||||
|
||||
protocol_version = cJSON_CreateNumber(msg->protocol_version);
|
||||
if (!protocol_version) {
|
||||
goto error;
|
||||
}
|
||||
cJSON_AddItemToObject(json, "SnapStreamProtocolVersion", protocol_version);
|
||||
protocol_version = cJSON_CreateNumber (msg->protocol_version);
|
||||
if (!protocol_version)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
cJSON_AddItemToObject (json, "SnapStreamProtocolVersion", protocol_version);
|
||||
|
||||
goto end;
|
||||
error:
|
||||
cJSON_Delete(json);
|
||||
cJSON_Delete (json);
|
||||
|
||||
end:
|
||||
return json;
|
||||
}
|
||||
|
||||
char *hello_message_serialize(hello_message_t *msg, size_t *size) {
|
||||
char *
|
||||
hello_message_serialize (hello_message_t *msg, size_t *size)
|
||||
{
|
||||
int str_length, prefixed_length;
|
||||
cJSON *json;
|
||||
char *str = NULL;
|
||||
char *prefixed_str = NULL;
|
||||
|
||||
json = hello_message_to_json(msg);
|
||||
if (!json) {
|
||||
return NULL;
|
||||
}
|
||||
json = hello_message_to_json (msg);
|
||||
if (!json)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
str = cJSON_PrintUnformatted(json);
|
||||
if (!str) {
|
||||
return NULL;
|
||||
}
|
||||
cJSON_Delete(json);
|
||||
str = cJSON_PrintUnformatted (json);
|
||||
if (!str)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
cJSON_Delete (json);
|
||||
|
||||
str_length = strlen(str);
|
||||
str_length = strlen (str);
|
||||
prefixed_length = str_length + 4;
|
||||
prefixed_str = malloc(prefixed_length);
|
||||
if (!prefixed_str) {
|
||||
return NULL;
|
||||
}
|
||||
prefixed_str = malloc (prefixed_length);
|
||||
if (!prefixed_str)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
prefixed_str[0] = str_length & 0xff;
|
||||
prefixed_str[1] = (str_length >> 8) & 0xff;
|
||||
prefixed_str[2] = (str_length >> 16) & 0xff;
|
||||
prefixed_str[3] = (str_length >> 24) & 0xff;
|
||||
memcpy(&(prefixed_str[4]), str, str_length);
|
||||
free(str);
|
||||
memcpy (&(prefixed_str[4]), str, str_length);
|
||||
free (str);
|
||||
*size = prefixed_length;
|
||||
|
||||
return prefixed_str;
|
||||
}
|
||||
|
||||
int server_settings_message_deserialize(server_settings_message_t *msg,
|
||||
const char *json_str) {
|
||||
int
|
||||
server_settings_message_deserialize (server_settings_message_t *msg,
|
||||
const char *json_str)
|
||||
{
|
||||
int status = 1;
|
||||
cJSON *value = NULL;
|
||||
cJSON *json = cJSON_Parse(json_str);
|
||||
if (!json) {
|
||||
const char *error_ptr = cJSON_GetErrorPtr();
|
||||
if (error_ptr) {
|
||||
ESP_LOGE(TAG, "Error before: %s", error_ptr);
|
||||
cJSON *json = cJSON_Parse (json_str);
|
||||
if (!json)
|
||||
{
|
||||
const char *error_ptr = cJSON_GetErrorPtr ();
|
||||
if (error_ptr)
|
||||
{
|
||||
ESP_LOGE (TAG, "Error before: %s", error_ptr);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (msg == NULL)
|
||||
{
|
||||
status = 2;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (msg == NULL) {
|
||||
status = 2;
|
||||
goto end;
|
||||
}
|
||||
value = cJSON_GetObjectItemCaseSensitive (json, "bufferMs");
|
||||
if (cJSON_IsNumber (value))
|
||||
{
|
||||
msg->buffer_ms = value->valueint;
|
||||
}
|
||||
|
||||
value = cJSON_GetObjectItemCaseSensitive(json, "bufferMs");
|
||||
if (cJSON_IsNumber(value)) {
|
||||
msg->buffer_ms = value->valueint;
|
||||
}
|
||||
value = cJSON_GetObjectItemCaseSensitive (json, "latency");
|
||||
if (cJSON_IsNumber (value))
|
||||
{
|
||||
msg->latency = value->valueint;
|
||||
}
|
||||
|
||||
value = cJSON_GetObjectItemCaseSensitive(json, "latency");
|
||||
if (cJSON_IsNumber(value)) {
|
||||
msg->latency = value->valueint;
|
||||
}
|
||||
value = cJSON_GetObjectItemCaseSensitive (json, "volume");
|
||||
if (cJSON_IsNumber (value))
|
||||
{
|
||||
msg->volume = value->valueint;
|
||||
}
|
||||
|
||||
value = cJSON_GetObjectItemCaseSensitive(json, "volume");
|
||||
if (cJSON_IsNumber(value)) {
|
||||
msg->volume = value->valueint;
|
||||
}
|
||||
|
||||
value = cJSON_GetObjectItemCaseSensitive(json, "muted");
|
||||
msg->muted = cJSON_IsTrue(value);
|
||||
value = cJSON_GetObjectItemCaseSensitive (json, "muted");
|
||||
msg->muted = cJSON_IsTrue (value);
|
||||
status = 0;
|
||||
end:
|
||||
cJSON_Delete(json);
|
||||
cJSON_Delete (json);
|
||||
return status;
|
||||
}
|
||||
|
||||
int codec_header_message_deserialize(codec_header_message_t *msg,
|
||||
const char *data, uint32_t size) {
|
||||
int
|
||||
codec_header_message_deserialize (codec_header_message_t *msg,
|
||||
const char *data, uint32_t size)
|
||||
{
|
||||
read_buffer_t buffer;
|
||||
uint32_t string_size;
|
||||
int result = 0;
|
||||
|
||||
buffer_read_init(&buffer, data, size);
|
||||
buffer_read_init (&buffer, data, size);
|
||||
|
||||
result |= buffer_read_uint32(&buffer, &string_size);
|
||||
if (result) {
|
||||
// Can't allocate the proper size string if we didn't read the size, so fail
|
||||
// early
|
||||
return 1;
|
||||
}
|
||||
result |= buffer_read_uint32 (&buffer, &string_size);
|
||||
if (result)
|
||||
{
|
||||
// Can't allocate the proper size string if we didn't read the size, so
|
||||
// fail early
|
||||
return 1;
|
||||
}
|
||||
|
||||
msg->codec = malloc(string_size + 1);
|
||||
if (!msg->codec) {
|
||||
return 2;
|
||||
}
|
||||
msg->codec = malloc (string_size + 1);
|
||||
if (!msg->codec)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
result |= buffer_read_buffer(&buffer, msg->codec, string_size);
|
||||
result |= buffer_read_buffer (&buffer, msg->codec, string_size);
|
||||
// Make sure the codec is a proper C string by terminating it with a null
|
||||
// character
|
||||
msg->codec[string_size] = '\0';
|
||||
|
||||
result |= buffer_read_uint32(&buffer, &(msg->size));
|
||||
if (result) {
|
||||
// Can't allocate the proper size string if we didn't read the size, so fail
|
||||
// early
|
||||
return 1;
|
||||
}
|
||||
result |= buffer_read_uint32 (&buffer, &(msg->size));
|
||||
if (result)
|
||||
{
|
||||
// Can't allocate the proper size string if we didn't read the size, so
|
||||
// fail early
|
||||
return 1;
|
||||
}
|
||||
|
||||
msg->payload = malloc(msg->size);
|
||||
if (!msg->payload) {
|
||||
return 2;
|
||||
}
|
||||
// msg->payload = malloc(msg->size);
|
||||
// if (!msg->payload) {
|
||||
// return 2;
|
||||
// }
|
||||
|
||||
result |= buffer_read_buffer(&buffer, msg->payload, msg->size);
|
||||
msg->payload = &data[buffer.index];
|
||||
|
||||
// result |= buffer_read_buffer(&buffer, msg->payload, msg->size);
|
||||
return result;
|
||||
}
|
||||
|
||||
int wire_chunk_message_deserialize(wire_chunk_message_t *msg, const char *data,
|
||||
uint32_t size) {
|
||||
int
|
||||
wire_chunk_message_deserialize (wire_chunk_message_t *msg, const char *data,
|
||||
uint32_t size)
|
||||
{
|
||||
read_buffer_t buffer;
|
||||
int result = 0;
|
||||
|
||||
buffer_read_init(&buffer, data, size);
|
||||
buffer_read_init (&buffer, data, size);
|
||||
|
||||
result |= buffer_read_int32(&buffer, &(msg->timestamp.sec));
|
||||
result |= buffer_read_int32(&buffer, &(msg->timestamp.usec));
|
||||
result |= buffer_read_uint32(&buffer, &(msg->size));
|
||||
result |= buffer_read_int32 (&buffer, &(msg->timestamp.sec));
|
||||
result |= buffer_read_int32 (&buffer, &(msg->timestamp.usec));
|
||||
result |= buffer_read_uint32 (&buffer, &(msg->size));
|
||||
|
||||
// If there's been an error already (especially for the size bit) return early
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
// If there's been an error already (especially for the size bit) return
|
||||
// early
|
||||
if (result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
// TODO maybe should check to see if need to free memory?
|
||||
//#if CONFIG_USE_PSRAM
|
||||
// msg->payload =
|
||||
// (char *)heap_caps_malloc(msg->size * sizeof(char),
|
||||
// MALLOC_CAP_SPIRAM);
|
||||
//#else
|
||||
// msg->payload = heap_caps_malloc(msg->size * sizeof(char),
|
||||
// MALLOC_CAP_8BIT);
|
||||
//#endif
|
||||
|
||||
msg->payload = &data[buffer.index];
|
||||
|
||||
// TODO maybe should check to see if need to free memory?
|
||||
#if CONFIG_USE_PSRAM
|
||||
msg->payload =
|
||||
(char *)heap_caps_malloc(msg->size * sizeof(char), MALLOC_CAP_SPIRAM);
|
||||
#else
|
||||
msg->payload = malloc(msg->size * sizeof(char));
|
||||
#endif
|
||||
// Failed to allocate the memory
|
||||
if (!msg->payload) {
|
||||
return 2;
|
||||
}
|
||||
if (!msg->payload)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
result |= buffer_read_buffer(&buffer, msg->payload, msg->size);
|
||||
// result |= buffer_read_buffer(&buffer, msg->payload, msg->size);
|
||||
return result;
|
||||
}
|
||||
|
||||
void codec_header_message_free(codec_header_message_t *msg) {
|
||||
free(msg->codec);
|
||||
void
|
||||
codec_header_message_free (codec_header_message_t *msg)
|
||||
{
|
||||
free (msg->codec);
|
||||
msg->codec = NULL;
|
||||
free(msg->payload);
|
||||
msg->payload = NULL;
|
||||
// free(msg->payload);
|
||||
// msg->payload = NULL;
|
||||
}
|
||||
|
||||
void wire_chunk_message_free(wire_chunk_message_t *msg) {
|
||||
if (msg->payload) {
|
||||
free(msg->payload);
|
||||
msg->payload = NULL;
|
||||
}
|
||||
void
|
||||
wire_chunk_message_free (wire_chunk_message_t *msg)
|
||||
{
|
||||
// if (msg->payload) {
|
||||
// free(msg->payload);
|
||||
// msg->payload = NULL;
|
||||
// }
|
||||
}
|
||||
|
||||
int time_message_serialize(time_message_t *msg, char *data, uint32_t size) {
|
||||
int
|
||||
time_message_serialize (time_message_t *msg, char *data, uint32_t size)
|
||||
{
|
||||
write_buffer_t buffer;
|
||||
int result = 0;
|
||||
|
||||
buffer_write_init(&buffer, data, size);
|
||||
buffer_write_init (&buffer, data, size);
|
||||
|
||||
result |= buffer_write_int32(&buffer, msg->latency.sec);
|
||||
result |= buffer_write_int32(&buffer, msg->latency.usec);
|
||||
result |= buffer_write_int32 (&buffer, msg->latency.sec);
|
||||
result |= buffer_write_int32 (&buffer, msg->latency.usec);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int time_message_deserialize(time_message_t *msg, const char *data,
|
||||
uint32_t size) {
|
||||
int
|
||||
time_message_deserialize (time_message_t *msg, const char *data, uint32_t size)
|
||||
{
|
||||
read_buffer_t buffer;
|
||||
int result = 0;
|
||||
|
||||
buffer_read_init(&buffer, data, size);
|
||||
buffer_read_init (&buffer, data, size);
|
||||
|
||||
result |= buffer_read_int32(&buffer, &(msg->latency.sec));
|
||||
result |= buffer_read_int32(&buffer, &(msg->latency.usec));
|
||||
result |= buffer_read_int32 (&buffer, &(msg->latency.sec));
|
||||
result |= buffer_read_int32 (&buffer, &(msg->latency.usec));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
idf_component_register(SRCS "ota_server.c"
|
||||
INCLUDE_DIRS "include"
|
||||
REQUIRES app_update dsp_processor wifi_interface lightsnapcast)
|
||||
REQUIRES app_update dsp_processor wifi_interface lightsnapcast wifi_logger)
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
#include "ota_server.h"
|
||||
|
||||
#include "wifi_logger.h"
|
||||
|
||||
extern xTaskHandle t_http_get_task;
|
||||
|
||||
const int OTA_CONNECTED_BIT = BIT0;
|
||||
@@ -30,11 +32,17 @@ EventGroupHandle_t ota_event_group;
|
||||
/*socket*/
|
||||
static int connect_socket = 0;
|
||||
|
||||
void ota_server_task(void *param) {
|
||||
void
|
||||
ota_server_task (void *param)
|
||||
{
|
||||
// xEventGroupWaitBits(ota_event_group, OTA_CONNECTED_BIT, false, true,
|
||||
// portMAX_DELAY);
|
||||
ota_server_start_my();
|
||||
vTaskDelete(NULL);
|
||||
|
||||
// TODO: find a god place to verify app is working properly after OTA
|
||||
esp_ota_mark_app_valid_cancel_rollback ();
|
||||
|
||||
ota_server_start_my ();
|
||||
vTaskDelete (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -81,175 +89,208 @@ void initialise_wifi(void)
|
||||
}
|
||||
*/
|
||||
|
||||
static int get_socket_error_code(int socket) {
|
||||
static int
|
||||
get_socket_error_code (int socket)
|
||||
{
|
||||
int result;
|
||||
u32_t optlen = sizeof(int);
|
||||
u32_t optlen = sizeof (int);
|
||||
|
||||
int err = getsockopt(socket, SOL_SOCKET, SO_ERROR, &result, &optlen);
|
||||
int err = getsockopt (socket, SOL_SOCKET, SO_ERROR, &result, &optlen);
|
||||
|
||||
if (err == -1) {
|
||||
ESP_LOGE(TAG, "getsockopt failed:%s", strerror(err));
|
||||
return -1;
|
||||
}
|
||||
if (err == -1)
|
||||
{
|
||||
ESP_LOGE (TAG, "getsockopt failed:%s", strerror (err));
|
||||
return -1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static int show_socket_error_reason(const char *str, int socket) {
|
||||
int err = get_socket_error_code(socket);
|
||||
static int
|
||||
show_socket_error_reason (const char *str, int socket)
|
||||
{
|
||||
int err = get_socket_error_code (socket);
|
||||
|
||||
if (err != 0) {
|
||||
ESP_LOGW(TAG, "%s socket error %d %s", str, err, strerror(err));
|
||||
}
|
||||
if (err != 0)
|
||||
{
|
||||
ESP_LOGW (TAG, "%s socket error %d %s", str, err, strerror (err));
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static esp_err_t create_tcp_server() {
|
||||
ESP_LOGI(TAG,
|
||||
"idf.py build ; curl snapclient.local:%d --data-binary @- < "
|
||||
"build/snapclient.bin",
|
||||
OTA_LISTEN_PORT);
|
||||
static esp_err_t
|
||||
create_tcp_server ()
|
||||
{
|
||||
ESP_LOGI (TAG,
|
||||
"idf.py build ; curl snapclient.local:%d --data-binary @- < "
|
||||
"build/snapclient.bin",
|
||||
OTA_LISTEN_PORT);
|
||||
int server_socket = 0;
|
||||
struct sockaddr_in server_addr;
|
||||
server_socket = socket(AF_INET, SOCK_STREAM, 0);
|
||||
server_socket = socket (AF_INET, SOCK_STREAM, 0);
|
||||
|
||||
if (server_socket < 0) {
|
||||
show_socket_error_reason("create_server", server_socket);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
if (server_socket < 0)
|
||||
{
|
||||
show_socket_error_reason ("create_server", server_socket);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
server_addr.sin_family = AF_INET;
|
||||
server_addr.sin_port = htons(OTA_LISTEN_PORT);
|
||||
server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
if (bind(server_socket, (struct sockaddr *)&server_addr,
|
||||
sizeof(server_addr)) < 0) {
|
||||
show_socket_error_reason("bind_server", server_socket);
|
||||
close(server_socket);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
server_addr.sin_port = htons (OTA_LISTEN_PORT);
|
||||
server_addr.sin_addr.s_addr = htonl (INADDR_ANY);
|
||||
if (bind (server_socket, (struct sockaddr *)&server_addr,
|
||||
sizeof (server_addr))
|
||||
< 0)
|
||||
{
|
||||
show_socket_error_reason ("bind_server", server_socket);
|
||||
close (server_socket);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
if (listen(server_socket, 5) < 0) {
|
||||
show_socket_error_reason("listen_server", server_socket);
|
||||
close(server_socket);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
if (listen (server_socket, 5) < 0)
|
||||
{
|
||||
show_socket_error_reason ("listen_server", server_socket);
|
||||
close (server_socket);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
struct sockaddr_in client_addr;
|
||||
unsigned int socklen = sizeof(client_addr);
|
||||
connect_socket =
|
||||
accept(server_socket, (struct sockaddr *)&client_addr, &socklen);
|
||||
unsigned int socklen = sizeof (client_addr);
|
||||
connect_socket
|
||||
= accept (server_socket, (struct sockaddr *)&client_addr, &socklen);
|
||||
|
||||
if (connect_socket < 0) {
|
||||
show_socket_error_reason("accept_server", connect_socket);
|
||||
close(server_socket);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
if (connect_socket < 0)
|
||||
{
|
||||
show_socket_error_reason ("accept_server", connect_socket);
|
||||
close (server_socket);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
/*connection established,now can send/recv*/
|
||||
ESP_LOGI(TAG, "tcp connection established!");
|
||||
ESP_LOGI (TAG, "tcp connection established!");
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void ota_server_start_my(void) {
|
||||
void
|
||||
ota_server_start_my (void)
|
||||
{
|
||||
uint8_t percent_loaded;
|
||||
uint8_t old_percent_loaded;
|
||||
|
||||
ESP_ERROR_CHECK(create_tcp_server());
|
||||
ESP_ERROR_CHECK (create_tcp_server ());
|
||||
|
||||
const esp_partition_t *update_partition =
|
||||
esp_ota_get_next_update_partition(NULL);
|
||||
const esp_partition_t *update_partition
|
||||
= esp_ota_get_next_update_partition (NULL);
|
||||
|
||||
ESP_LOGI(TAG, "Writing to partition subtype %d at offset 0x%x",
|
||||
update_partition->subtype, update_partition->address);
|
||||
ESP_LOGI (TAG, "Writing to partition subtype %d at offset 0x%x",
|
||||
update_partition->subtype, update_partition->address);
|
||||
|
||||
// https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/system/log.html
|
||||
// I don't want to see all the Log esp_image stuff while its flashing it
|
||||
esp_log_level_set(
|
||||
esp_log_level_set (
|
||||
"esp_image",
|
||||
ESP_LOG_ERROR); // set all components to ERROR level ESP_LOG_NONE
|
||||
ESP_LOG_ERROR); // set all components to ERROR level ESP_LOG_NONE
|
||||
|
||||
// We don't want any other thread running during this update.
|
||||
// SuspendAllThreads();
|
||||
// KillAllThreads();
|
||||
// dsp_i2s_task_deinit();
|
||||
vTaskDelete(t_http_get_task);
|
||||
deinit_player(); // ensure this is called after http_task was killed
|
||||
vTaskDelete (t_http_get_task);
|
||||
deinit_player (); // ensure this is called after http_task was killed
|
||||
stop_wifi_logger ();
|
||||
|
||||
int recv_len;
|
||||
char ota_buff[OTA_BUFF_SIZE] = {0};
|
||||
char ota_buff[OTA_BUFF_SIZE] = { 0 };
|
||||
bool is_req_body_started = false;
|
||||
int content_length = -1;
|
||||
int content_received = 0;
|
||||
|
||||
esp_ota_handle_t ota_handle;
|
||||
|
||||
do {
|
||||
recv_len = recv(connect_socket, ota_buff, OTA_BUFF_SIZE, 0);
|
||||
do
|
||||
{
|
||||
// ESP_LOGW (TAG, "stack free: %d",
|
||||
// uxTaskGetStackHighWaterMark(NULL));
|
||||
|
||||
if (recv_len > 0) {
|
||||
if (!is_req_body_started) {
|
||||
const char *content_length_start = "Content-Length: ";
|
||||
char *content_length_start_p = strstr(ota_buff, content_length_start) +
|
||||
strlen(content_length_start);
|
||||
sscanf(content_length_start_p, "%d", &content_length);
|
||||
ESP_LOGI(TAG, "Detected content length: %d", content_length);
|
||||
ESP_ERROR_CHECK(
|
||||
esp_ota_begin(update_partition, OTA_SIZE_UNKNOWN, &ota_handle));
|
||||
const char *header_end = "\r\n\r\n";
|
||||
char *body_start_p = strstr(ota_buff, header_end) + strlen(header_end);
|
||||
int body_part_len = recv_len - (body_start_p - ota_buff);
|
||||
esp_ota_write(ota_handle, body_start_p, body_part_len);
|
||||
content_received += body_part_len;
|
||||
is_req_body_started = true;
|
||||
} else {
|
||||
esp_ota_write(ota_handle, ota_buff, recv_len);
|
||||
content_received += recv_len;
|
||||
recv_len = recv (connect_socket, ota_buff, OTA_BUFF_SIZE, 0);
|
||||
|
||||
percent_loaded =
|
||||
(((float)content_received / (float)content_length) * 100.00);
|
||||
if ((percent_loaded % 10 == 0) &
|
||||
(percent_loaded != old_percent_loaded)) {
|
||||
old_percent_loaded = percent_loaded;
|
||||
ESP_LOGI(TAG, "Uploaded %03u%%", percent_loaded);
|
||||
if (recv_len > 0)
|
||||
{
|
||||
if (!is_req_body_started)
|
||||
{
|
||||
const char *content_length_start = "Content-Length: ";
|
||||
char *content_length_start_p
|
||||
= strstr (ota_buff, content_length_start)
|
||||
+ strlen (content_length_start);
|
||||
sscanf (content_length_start_p, "%d", &content_length);
|
||||
ESP_LOGI (TAG, "Detected content length: %d", content_length);
|
||||
ESP_ERROR_CHECK (esp_ota_begin (update_partition,
|
||||
OTA_SIZE_UNKNOWN, &ota_handle));
|
||||
const char *header_end = "\r\n\r\n";
|
||||
char *body_start_p
|
||||
= strstr (ota_buff, header_end) + strlen (header_end);
|
||||
int body_part_len = recv_len - (body_start_p - ota_buff);
|
||||
esp_ota_write (ota_handle, body_start_p, body_part_len);
|
||||
content_received += body_part_len;
|
||||
is_req_body_started = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
esp_ota_write (ota_handle, ota_buff, recv_len);
|
||||
content_received += recv_len;
|
||||
|
||||
percent_loaded
|
||||
= (((float)content_received / (float)content_length)
|
||||
* 100.00);
|
||||
if ((percent_loaded % 10 == 0)
|
||||
& (percent_loaded != old_percent_loaded))
|
||||
{
|
||||
old_percent_loaded = percent_loaded;
|
||||
ESP_LOGI (TAG, "Uploaded %03u%%", percent_loaded);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (recv_len < 0)
|
||||
{
|
||||
ESP_LOGI (TAG, "Error: recv data error! errno=%d", errno);
|
||||
}
|
||||
}
|
||||
} else if (recv_len < 0) {
|
||||
ESP_LOGI(TAG, "Error: recv data error! errno=%d", errno);
|
||||
}
|
||||
while (recv_len > 0 && content_received < content_length);
|
||||
|
||||
} while (recv_len > 0 && content_received < content_length);
|
||||
|
||||
ESP_LOGI(TAG, "OTA Transferred Finished: %d bytes", content_received);
|
||||
ESP_LOGI (TAG, "OTA Transferred Finished: %d bytes", content_received);
|
||||
|
||||
char res_buff[128];
|
||||
int send_len;
|
||||
send_len = sprintf(res_buff, "200 OK\n\n");
|
||||
send(connect_socket, res_buff, send_len, 0);
|
||||
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
||||
close(connect_socket);
|
||||
send_len = sprintf (res_buff, "200 OK\n\n");
|
||||
send (connect_socket, res_buff, send_len, 0);
|
||||
vTaskDelay (2000 / portTICK_PERIOD_MS);
|
||||
close (connect_socket);
|
||||
|
||||
ESP_ERROR_CHECK(esp_ota_end(ota_handle));
|
||||
ESP_ERROR_CHECK (esp_ota_end (ota_handle));
|
||||
|
||||
esp_err_t err = esp_ota_set_boot_partition(update_partition);
|
||||
esp_err_t err = esp_ota_set_boot_partition (update_partition);
|
||||
|
||||
if (err == ESP_OK) {
|
||||
const esp_partition_t *boot_partition = esp_ota_get_boot_partition();
|
||||
if (err == ESP_OK)
|
||||
{
|
||||
const esp_partition_t *boot_partition = esp_ota_get_boot_partition ();
|
||||
|
||||
ESP_LOGI(TAG,
|
||||
"***********************************************************");
|
||||
ESP_LOGI(TAG, "OTA Successful");
|
||||
ESP_LOGI(TAG, "Next Boot Partition Subtype %d At Offset 0x%x",
|
||||
boot_partition->subtype, boot_partition->address);
|
||||
ESP_LOGI(TAG,
|
||||
"***********************************************************");
|
||||
} else {
|
||||
ESP_LOGI(TAG, "!!! OTA Failed !!!");
|
||||
}
|
||||
ESP_LOGI (TAG,
|
||||
"***********************************************************");
|
||||
ESP_LOGI (TAG, "OTA Successful");
|
||||
ESP_LOGI (TAG, "Next Boot Partition Subtype %d At Offset 0x%x",
|
||||
boot_partition->subtype, boot_partition->address);
|
||||
ESP_LOGI (TAG,
|
||||
"***********************************************************");
|
||||
}
|
||||
else
|
||||
{
|
||||
ESP_LOGI (TAG, "!!! OTA Failed !!!");
|
||||
}
|
||||
|
||||
// for (int x = 2; x >= 1; x--)
|
||||
//{
|
||||
ESP_LOGI(TAG, "Prepare to restart system..");
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
ESP_LOGI (TAG, "Prepare to restart system..");
|
||||
vTaskDelay (1000 / portTICK_PERIOD_MS);
|
||||
//}
|
||||
|
||||
esp_restart();
|
||||
esp_restart ();
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
Select audio source (Snapcast, RTPrx, Bluetooth, Signal generator)
|
||||
Enable DSP processing
|
||||
1 Device communication I2C
|
||||
2 GPIO manipolation
|
||||
2 GPIO manipulation
|
||||
3 Audio generator
|
||||
4 Telemetri subsystem
|
||||
5 Test function
|
||||
|
||||
4
components/protocol_examples_common/CMakeLists.txt
Normal file
4
components/protocol_examples_common/CMakeLists.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
idf_component_register(SRCS "connect.c" "stdin_out.c" "addr_from_stdin.c"
|
||||
INCLUDE_DIRS "include"
|
||||
PRIV_REQUIRES esp_netif wifi_interface
|
||||
)
|
||||
218
components/protocol_examples_common/Kconfig.projbuild
Normal file
218
components/protocol_examples_common/Kconfig.projbuild
Normal file
@@ -0,0 +1,218 @@
|
||||
menu "Example Connection Configuration"
|
||||
|
||||
config EXAMPLE_CONNECT_WIFI
|
||||
bool "connect using WiFi interface"
|
||||
default y
|
||||
help
|
||||
Protocol examples can use Wi-Fi and/or Ethernet to connect to the network.
|
||||
Choose this option to connect with WiFi
|
||||
|
||||
if EXAMPLE_CONNECT_WIFI
|
||||
config EXAMPLE_WIFI_SSID
|
||||
string "WiFi SSID"
|
||||
default "myssid"
|
||||
help
|
||||
SSID (network name) for the example to connect to.
|
||||
|
||||
config EXAMPLE_WIFI_PASSWORD
|
||||
string "WiFi Password"
|
||||
default "mypassword"
|
||||
help
|
||||
WiFi password (WPA or WPA2) for the example to use.
|
||||
Can be left blank if the network has no security set.
|
||||
endif
|
||||
|
||||
config EXAMPLE_CONNECT_ETHERNET
|
||||
bool "connect using Ethernet interface"
|
||||
default n
|
||||
help
|
||||
Protocol examples can use Wi-Fi and/or Ethernet to connect to the network.
|
||||
Choose this option to connect with Ethernet
|
||||
|
||||
if EXAMPLE_CONNECT_ETHERNET
|
||||
choice EXAMPLE_USE_ETHERNET
|
||||
prompt "Ethernet Type"
|
||||
default EXAMPLE_USE_INTERNAL_ETHERNET if IDF_TARGET_ESP32
|
||||
default EXAMPLE_USE_DM9051 if !IDF_TARGET_ESP32
|
||||
help
|
||||
Select which kind of Ethernet will be used in the example.
|
||||
|
||||
config EXAMPLE_USE_INTERNAL_ETHERNET
|
||||
depends on IDF_TARGET_ESP32
|
||||
select ETH_USE_ESP32_EMAC
|
||||
bool "Internal EMAC"
|
||||
help
|
||||
Select internal Ethernet MAC controller.
|
||||
|
||||
config EXAMPLE_USE_DM9051
|
||||
bool "DM9051 Module"
|
||||
select ETH_USE_SPI_ETHERNET
|
||||
select ETH_SPI_ETHERNET_DM9051
|
||||
help
|
||||
Select external SPI-Ethernet module.
|
||||
|
||||
config EXAMPLE_USE_OPENETH
|
||||
bool "OpenCores Ethernet MAC (EXPERIMENTAL)"
|
||||
select ETH_USE_OPENETH
|
||||
help
|
||||
When this option is enabled, the example is built with support for
|
||||
OpenCores Ethernet MAC, which allows testing the example in QEMU.
|
||||
Note that this option is used for internal testing purposes, and
|
||||
not officially supported. Examples built with this option enabled
|
||||
will not run on a real ESP32 chip.
|
||||
|
||||
endchoice
|
||||
|
||||
if EXAMPLE_USE_INTERNAL_ETHERNET
|
||||
choice EXAMPLE_ETH_PHY_MODEL
|
||||
prompt "Ethernet PHY Device"
|
||||
default EXAMPLE_ETH_PHY_IP101
|
||||
help
|
||||
Select the Ethernet PHY device to use in the example.
|
||||
|
||||
config EXAMPLE_ETH_PHY_IP101
|
||||
bool "IP101"
|
||||
help
|
||||
IP101 is a single port 10/100 MII/RMII/TP/Fiber Fast Ethernet Transceiver.
|
||||
Goto http://www.icplus.com.tw/pp-IP101G.html for more information about it.
|
||||
|
||||
config EXAMPLE_ETH_PHY_RTL8201
|
||||
bool "RTL8201/SR8201"
|
||||
help
|
||||
RTL8201F/SR8201F is a single port 10/100Mb Ethernet Transceiver with auto MDIX.
|
||||
Goto http://www.corechip-sz.com/productsview.asp?id=22 for more information about it.
|
||||
|
||||
config EXAMPLE_ETH_PHY_LAN8720
|
||||
bool "LAN8720"
|
||||
help
|
||||
LAN8720A is a small footprint RMII 10/100 Ethernet Transceiver with HP Auto-MDIX Support.
|
||||
Goto https://www.microchip.com/LAN8720A for more information about it.
|
||||
|
||||
config EXAMPLE_ETH_PHY_DP83848
|
||||
bool "DP83848"
|
||||
help
|
||||
DP83848 is a single port 10/100Mb/s Ethernet Physical Layer Transceiver.
|
||||
Goto http://www.ti.com/product/DP83848J for more information about it.
|
||||
endchoice
|
||||
|
||||
config EXAMPLE_ETH_MDC_GPIO
|
||||
int "SMI MDC GPIO number"
|
||||
default 23
|
||||
help
|
||||
Set the GPIO number used by SMI MDC.
|
||||
|
||||
config EXAMPLE_ETH_MDIO_GPIO
|
||||
int "SMI MDIO GPIO number"
|
||||
default 18
|
||||
help
|
||||
Set the GPIO number used by SMI MDIO.
|
||||
endif
|
||||
|
||||
if EXAMPLE_USE_DM9051
|
||||
config EXAMPLE_DM9051_SPI_HOST
|
||||
int "SPI Host Number"
|
||||
range 0 2
|
||||
default 1
|
||||
help
|
||||
Set the SPI host used to communicate with DM9051.
|
||||
|
||||
config EXAMPLE_DM9051_SCLK_GPIO
|
||||
int "SPI SCLK GPIO number"
|
||||
range 0 33
|
||||
default 19
|
||||
help
|
||||
Set the GPIO number used by SPI SCLK.
|
||||
|
||||
config EXAMPLE_DM9051_MOSI_GPIO
|
||||
int "SPI MOSI GPIO number"
|
||||
range 0 33
|
||||
default 23
|
||||
help
|
||||
Set the GPIO number used by SPI MOSI.
|
||||
|
||||
config EXAMPLE_DM9051_MISO_GPIO
|
||||
int "SPI MISO GPIO number"
|
||||
range 0 33
|
||||
default 25
|
||||
help
|
||||
Set the GPIO number used by SPI MISO.
|
||||
|
||||
config EXAMPLE_DM9051_CS_GPIO
|
||||
int "SPI CS GPIO number"
|
||||
range 0 33
|
||||
default 22
|
||||
help
|
||||
Set the GPIO number used by SPI CS.
|
||||
|
||||
config EXAMPLE_DM9051_SPI_CLOCK_MHZ
|
||||
int "SPI clock speed (MHz)"
|
||||
range 20 80
|
||||
default 20
|
||||
help
|
||||
Set the clock speed (MHz) of SPI interface.
|
||||
|
||||
config EXAMPLE_DM9051_INT_GPIO
|
||||
int "Interrupt GPIO number"
|
||||
default 4
|
||||
help
|
||||
Set the GPIO number used by DM9051 interrupt.
|
||||
endif
|
||||
|
||||
config EXAMPLE_ETH_PHY_RST_GPIO
|
||||
int "PHY Reset GPIO number"
|
||||
default 5
|
||||
help
|
||||
Set the GPIO number used to reset PHY chip.
|
||||
Set to -1 to disable PHY chip hardware reset.
|
||||
|
||||
config EXAMPLE_ETH_PHY_ADDR
|
||||
int "PHY Address"
|
||||
range 0 31 if EXAMPLE_USE_INTERNAL_ETHERNET
|
||||
range 1 1 if !EXAMPLE_USE_INTERNAL_ETHERNET
|
||||
default 1
|
||||
help
|
||||
Set PHY address according your board schematic.
|
||||
endif
|
||||
|
||||
config EXAMPLE_CONNECT_IPV6
|
||||
bool "Obtain IPv6 address"
|
||||
default y
|
||||
help
|
||||
By default, examples will wait until IPv4 and IPv6 local link addresses are obtained.
|
||||
Disable this option if the network does not support IPv6.
|
||||
Choose the preferred IPv6 address type if the connection code should wait until other than
|
||||
the local link address gets assigned.
|
||||
|
||||
if EXAMPLE_CONNECT_IPV6
|
||||
choice EXAMPLE_CONNECT_PREFERRED_IPV6
|
||||
prompt "Preferred IPv6 Type"
|
||||
default EXAMPLE_CONNECT_IPV6_PREF_LOCAL_LINK
|
||||
help
|
||||
Select which kind of IPv6 address the connect logic waits for.
|
||||
|
||||
config EXAMPLE_CONNECT_IPV6_PREF_LOCAL_LINK
|
||||
bool "Local Link Address"
|
||||
help
|
||||
Blocks until Local link address assigned.
|
||||
|
||||
config EXAMPLE_CONNECT_IPV6_PREF_GLOBAL
|
||||
bool "Global Address"
|
||||
help
|
||||
Blocks until Global address assigned.
|
||||
|
||||
config EXAMPLE_CONNECT_IPV6_PREF_SITE_LOCAL
|
||||
bool "Site Local Address"
|
||||
help
|
||||
Blocks until Site link address assigned.
|
||||
|
||||
config EXAMPLE_CONNECT_IPV6_PREF_UNIQUE_LOCAL
|
||||
bool "Unique Local Link Address"
|
||||
help
|
||||
Blocks until Unique local address assigned.
|
||||
|
||||
endchoice
|
||||
|
||||
endif
|
||||
|
||||
|
||||
endmenu
|
||||
75
components/protocol_examples_common/addr_from_stdin.c
Normal file
75
components/protocol_examples_common/addr_from_stdin.c
Normal file
@@ -0,0 +1,75 @@
|
||||
#include "esp_log.h"
|
||||
#include "esp_netif.h"
|
||||
#include "esp_system.h"
|
||||
#include "protocol_examples_common.h"
|
||||
#include <string.h>
|
||||
|
||||
#include "lwip/sockets.h"
|
||||
#include <arpa/inet.h>
|
||||
#include <lwip/netdb.h>
|
||||
|
||||
#define HOST_IP_SIZE 128
|
||||
|
||||
esp_err_t
|
||||
get_addr_from_stdin (int port, int sock_type, int *ip_protocol,
|
||||
int *addr_family, struct sockaddr_in6 *dest_addr)
|
||||
{
|
||||
char host_ip[HOST_IP_SIZE];
|
||||
int len;
|
||||
static bool already_init = false;
|
||||
|
||||
// this function could be called multiple times -> make sure UART init runs
|
||||
// only once
|
||||
if (!already_init)
|
||||
{
|
||||
example_configure_stdin_stdout ();
|
||||
already_init = true;
|
||||
}
|
||||
|
||||
// ignore empty or LF only string (could receive from DUT class)
|
||||
do
|
||||
{
|
||||
fgets (host_ip, HOST_IP_SIZE, stdin);
|
||||
len = strlen (host_ip);
|
||||
}
|
||||
while (len <= 1 && host_ip[0] == '\n');
|
||||
host_ip[len - 1] = '\0';
|
||||
|
||||
struct addrinfo hints, *addr_list, *cur;
|
||||
memset (&hints, 0, sizeof (hints));
|
||||
|
||||
// run getaddrinfo() to decide on the IP protocol
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_socktype = sock_type;
|
||||
hints.ai_protocol = IPPROTO_TCP;
|
||||
if (getaddrinfo (host_ip, NULL, &hints, &addr_list) != 0)
|
||||
{
|
||||
return ESP_FAIL;
|
||||
}
|
||||
for (cur = addr_list; cur != NULL; cur = cur->ai_next)
|
||||
{
|
||||
memcpy (dest_addr, cur->ai_addr, sizeof (*dest_addr));
|
||||
if (cur->ai_family == AF_INET)
|
||||
{
|
||||
*ip_protocol = IPPROTO_IP;
|
||||
*addr_family = AF_INET;
|
||||
// add port number and return on first IPv4 match
|
||||
((struct sockaddr_in *)dest_addr)->sin_port = htons (port);
|
||||
freeaddrinfo (addr_list);
|
||||
return ESP_OK;
|
||||
}
|
||||
// else if (cur->ai_family == AF_INET6) {
|
||||
// *ip_protocol = IPPROTO_IPV6;
|
||||
// *addr_family = AF_INET6;
|
||||
// // add port and interface number and return on first IPv6
|
||||
// match dest_addr->sin6_port = htons(port);
|
||||
// dest_addr->sin6_scope_id =
|
||||
// esp_netif_get_netif_impl_index(EXAMPLE_INTERFACE);
|
||||
// freeaddrinfo( addr_list );
|
||||
// return ESP_OK;
|
||||
// }
|
||||
}
|
||||
// no match found
|
||||
freeaddrinfo (addr_list);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
0
components/protocol_examples_common/component.mk
Normal file
0
components/protocol_examples_common/component.mk
Normal file
488
components/protocol_examples_common/connect.c
Normal file
488
components/protocol_examples_common/connect.c
Normal file
@@ -0,0 +1,488 @@
|
||||
/* Common functions for protocol examples, to establish Wi-Fi or Ethernet
|
||||
connection.
|
||||
|
||||
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
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
|
||||
#include "esp_event.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_wifi_default.h"
|
||||
#include "protocol_examples_common.h"
|
||||
#include "sdkconfig.h"
|
||||
#include <string.h>
|
||||
#if CONFIG_EXAMPLE_CONNECT_ETHERNET
|
||||
#include "esp_eth.h"
|
||||
#endif
|
||||
#include "driver/gpio.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_netif.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/event_groups.h"
|
||||
#include "freertos/task.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "wifi_interface.h"
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_CONNECT_IPV6
|
||||
#define MAX_IP6_ADDRS_PER_NETIF (5)
|
||||
#define NR_OF_IP_ADDRESSES_TO_WAIT_FOR (s_active_interfaces * 2)
|
||||
|
||||
#if defined(CONFIG_EXAMPLE_CONNECT_IPV6_PREF_LOCAL_LINK)
|
||||
#define EXAMPLE_CONNECT_PREFERRED_IPV6_TYPE ESP_IP6_ADDR_IS_LINK_LOCAL
|
||||
#elif defined(CONFIG_EXAMPLE_CONNECT_IPV6_PREF_GLOBAL)
|
||||
#define EXAMPLE_CONNECT_PREFERRED_IPV6_TYPE ESP_IP6_ADDR_IS_GLOBAL
|
||||
#elif defined(CONFIG_EXAMPLE_CONNECT_IPV6_PREF_SITE_LOCAL)
|
||||
#define EXAMPLE_CONNECT_PREFERRED_IPV6_TYPE ESP_IP6_ADDR_IS_SITE_LOCAL
|
||||
#elif defined(CONFIG_EXAMPLE_CONNECT_IPV6_PREF_UNIQUE_LOCAL)
|
||||
#define EXAMPLE_CONNECT_PREFERRED_IPV6_TYPE ESP_IP6_ADDR_IS_UNIQUE_LOCAL
|
||||
#endif // if-elif CONFIG_EXAMPLE_CONNECT_IPV6_PREF_...
|
||||
|
||||
#else
|
||||
#define NR_OF_IP_ADDRESSES_TO_WAIT_FOR (s_active_interfaces)
|
||||
#endif
|
||||
|
||||
static int s_active_interfaces = 0;
|
||||
static xSemaphoreHandle s_semph_get_ip_addrs;
|
||||
static esp_ip4_addr_t s_ip_addr;
|
||||
// static esp_netif_t *s_example_esp_netif = NULL;
|
||||
|
||||
// extern esp_netif_t *esp_wifi_netif;
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_CONNECT_IPV6
|
||||
static esp_ip6_addr_t s_ipv6_addr;
|
||||
|
||||
/* types of ipv6 addresses to be displayed on ipv6 events */
|
||||
static const char *s_ipv6_addr_types[]
|
||||
= { "ESP_IP6_ADDR_IS_UNKNOWN", "ESP_IP6_ADDR_IS_GLOBAL",
|
||||
"ESP_IP6_ADDR_IS_LINK_LOCAL", "ESP_IP6_ADDR_IS_SITE_LOCAL",
|
||||
"ESP_IP6_ADDR_IS_UNIQUE_LOCAL", "ESP_IP6_ADDR_IS_IPV4_MAPPED_IPV6" };
|
||||
#endif
|
||||
|
||||
static const char *TAG = "example_connect";
|
||||
|
||||
#if CONFIG_EXAMPLE_CONNECT_WIFI
|
||||
static esp_netif_t *wifi_start (void);
|
||||
static void wifi_stop (void);
|
||||
#endif
|
||||
#if CONFIG_EXAMPLE_CONNECT_ETHERNET
|
||||
static esp_netif_t *eth_start (void);
|
||||
static void eth_stop (void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Checks the netif description if it contains specified prefix.
|
||||
* All netifs created withing common connect component are prefixed with the
|
||||
* module TAG, so it returns true if the specified netif is owned by this
|
||||
* module
|
||||
*/
|
||||
static bool
|
||||
is_our_netif (const char *prefix, esp_netif_t *netif)
|
||||
{
|
||||
return strncmp (prefix, esp_netif_get_desc (netif), strlen (prefix) - 1)
|
||||
== 0;
|
||||
}
|
||||
|
||||
/* set up connection, Wi-Fi and/or Ethernet */
|
||||
static void
|
||||
start (void)
|
||||
{
|
||||
|
||||
#if CONFIG_EXAMPLE_CONNECT_WIFI
|
||||
esp_wifi_netif = wifi_start ();
|
||||
s_active_interfaces++;
|
||||
#endif
|
||||
|
||||
#if CONFIG_EXAMPLE_CONNECT_ETHERNET
|
||||
esp_wifi_netif = eth_start ();
|
||||
s_active_interfaces++;
|
||||
#endif
|
||||
|
||||
#if CONFIG_EXAMPLE_CONNECT_WIFI && CONFIG_EXAMPLE_CONNECT_ETHERNET
|
||||
/* if both intefaces at once, clear out to indicate that multiple netifs are
|
||||
* active */
|
||||
esp_wifi_netif = NULL;
|
||||
#endif
|
||||
|
||||
s_semph_get_ip_addrs
|
||||
= xSemaphoreCreateCounting (NR_OF_IP_ADDRESSES_TO_WAIT_FOR, 0);
|
||||
}
|
||||
|
||||
/* tear down connection, release resources */
|
||||
static void
|
||||
stop (void)
|
||||
{
|
||||
#if CONFIG_EXAMPLE_CONNECT_WIFI
|
||||
wifi_stop ();
|
||||
s_active_interfaces--;
|
||||
#endif
|
||||
|
||||
#if CONFIG_EXAMPLE_CONNECT_ETHERNET
|
||||
eth_stop ();
|
||||
s_active_interfaces--;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
on_got_ip (void *arg, esp_event_base_t event_base, int32_t event_id,
|
||||
void *event_data)
|
||||
{
|
||||
ip_event_got_ip_t *event = (ip_event_got_ip_t *)event_data;
|
||||
if (!is_our_netif (TAG, event->esp_netif))
|
||||
{
|
||||
ESP_LOGW (TAG, "Got IPv4 from another interface \"%s\": ignored",
|
||||
esp_netif_get_desc (event->esp_netif));
|
||||
return;
|
||||
}
|
||||
ESP_LOGI (TAG, "Got IPv4 event: Interface \"%s\" address: " IPSTR,
|
||||
esp_netif_get_desc (event->esp_netif),
|
||||
IP2STR (&event->ip_info.ip));
|
||||
memcpy (&s_ip_addr, &event->ip_info.ip, sizeof (s_ip_addr));
|
||||
xSemaphoreGive (s_semph_get_ip_addrs);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_CONNECT_IPV6
|
||||
|
||||
static void
|
||||
on_got_ipv6 (void *arg, esp_event_base_t event_base, int32_t event_id,
|
||||
void *event_data)
|
||||
{
|
||||
ip_event_got_ip6_t *event = (ip_event_got_ip6_t *)event_data;
|
||||
if (!is_our_netif (TAG, event->esp_netif))
|
||||
{
|
||||
ESP_LOGW (TAG, "Got IPv6 from another netif: ignored");
|
||||
return;
|
||||
}
|
||||
esp_ip6_addr_type_t ipv6_type
|
||||
= esp_netif_ip6_get_addr_type (&event->ip6_info.ip);
|
||||
ESP_LOGI (TAG,
|
||||
"Got IPv6 event: Interface \"%s\" address: " IPV6STR ", type: %s",
|
||||
esp_netif_get_desc (event->esp_netif),
|
||||
IPV62STR (event->ip6_info.ip), s_ipv6_addr_types[ipv6_type]);
|
||||
if (ipv6_type == EXAMPLE_CONNECT_PREFERRED_IPV6_TYPE)
|
||||
{
|
||||
memcpy (&s_ipv6_addr, &event->ip6_info.ip, sizeof (s_ipv6_addr));
|
||||
xSemaphoreGive (s_semph_get_ip_addrs);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // CONFIG_EXAMPLE_CONNECT_IPV6
|
||||
|
||||
esp_err_t
|
||||
example_connect (void)
|
||||
{
|
||||
if (s_semph_get_ip_addrs != NULL)
|
||||
{
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
start ();
|
||||
ESP_ERROR_CHECK (esp_register_shutdown_handler (&stop));
|
||||
// ESP_LOGI(TAG, "Waiting for IP(s)");
|
||||
// for (int i=0; i<NR_OF_IP_ADDRESSES_TO_WAIT_FOR; ++i) {
|
||||
// xSemaphoreTake(s_semph_get_ip_addrs, portMAX_DELAY);
|
||||
// }
|
||||
// iterate over active interfaces, and print out IPs of "our" netifs
|
||||
esp_netif_t *netif = NULL;
|
||||
esp_netif_ip_info_t ip;
|
||||
for (int i = 0; i < esp_netif_get_nr_of_ifs (); ++i)
|
||||
{
|
||||
netif = esp_netif_next (netif);
|
||||
if (is_our_netif (TAG, netif))
|
||||
{
|
||||
ESP_LOGI (TAG, "Connected to %s", esp_netif_get_desc (netif));
|
||||
ESP_ERROR_CHECK (esp_netif_get_ip_info (netif, &ip));
|
||||
|
||||
ESP_LOGI (TAG, "- IPv4 address: " IPSTR, IP2STR (&ip.ip));
|
||||
#ifdef CONFIG_EXAMPLE_CONNECT_IPV6
|
||||
esp_ip6_addr_t ip6[MAX_IP6_ADDRS_PER_NETIF];
|
||||
int ip6_addrs = esp_netif_get_all_ip6 (netif, ip6);
|
||||
for (int j = 0; j < ip6_addrs; ++j)
|
||||
{
|
||||
esp_ip6_addr_type_t ipv6_type
|
||||
= esp_netif_ip6_get_addr_type (&(ip6[j]));
|
||||
ESP_LOGI (TAG, "- IPv6 address: " IPV6STR ", type: %s",
|
||||
IPV62STR (ip6[j]), s_ipv6_addr_types[ipv6_type]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t
|
||||
example_disconnect (void)
|
||||
{
|
||||
if (s_semph_get_ip_addrs == NULL)
|
||||
{
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
vSemaphoreDelete (s_semph_get_ip_addrs);
|
||||
s_semph_get_ip_addrs = NULL;
|
||||
stop ();
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_CONNECT_WIFI
|
||||
|
||||
static void
|
||||
on_wifi_disconnect (void *arg, esp_event_base_t event_base, int32_t event_id,
|
||||
void *event_data)
|
||||
{
|
||||
ESP_LOGI (TAG, "Wi-Fi disconnected, trying to reconnect...");
|
||||
esp_err_t err = esp_wifi_connect ();
|
||||
if (err == ESP_ERR_WIFI_NOT_STARTED)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ESP_ERROR_CHECK (err);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_CONNECT_IPV6
|
||||
|
||||
static void
|
||||
on_wifi_connect (void *esp_netif, esp_event_base_t event_base,
|
||||
int32_t event_id, void *event_data)
|
||||
{
|
||||
esp_netif_create_ip6_linklocal (esp_netif);
|
||||
}
|
||||
|
||||
#endif // CONFIG_EXAMPLE_CONNECT_IPV6
|
||||
|
||||
static esp_netif_t *
|
||||
wifi_start (void)
|
||||
{
|
||||
char *desc;
|
||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT ();
|
||||
ESP_ERROR_CHECK (esp_wifi_init (&cfg));
|
||||
|
||||
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_wifi_set_default_wifi_sta_handlers ();
|
||||
|
||||
ESP_ERROR_CHECK (esp_event_handler_register (
|
||||
WIFI_EVENT, WIFI_EVENT_STA_DISCONNECTED, &on_wifi_disconnect, NULL));
|
||||
ESP_ERROR_CHECK (esp_event_handler_register (IP_EVENT, IP_EVENT_STA_GOT_IP,
|
||||
&on_got_ip, NULL));
|
||||
#ifdef CONFIG_EXAMPLE_CONNECT_IPV6
|
||||
ESP_ERROR_CHECK (esp_event_handler_register (
|
||||
WIFI_EVENT, WIFI_EVENT_STA_CONNECTED, &on_wifi_connect, netif));
|
||||
ESP_ERROR_CHECK (esp_event_handler_register (IP_EVENT, IP_EVENT_GOT_IP6,
|
||||
&on_got_ipv6, NULL));
|
||||
#endif
|
||||
|
||||
ESP_ERROR_CHECK (esp_wifi_set_storage (WIFI_STORAGE_RAM));
|
||||
wifi_config_t wifi_config = {
|
||||
.sta = {
|
||||
.ssid = CONFIG_EXAMPLE_WIFI_SSID,
|
||||
.password = CONFIG_EXAMPLE_WIFI_PASSWORD,
|
||||
},
|
||||
};
|
||||
ESP_LOGI (TAG, "Connecting to %s...", wifi_config.sta.ssid);
|
||||
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 ());
|
||||
ESP_ERROR_CHECK (esp_wifi_connect ());
|
||||
return netif;
|
||||
}
|
||||
|
||||
static void
|
||||
wifi_stop (void)
|
||||
{
|
||||
esp_netif_t *wifi_netif = get_example_netif_from_desc ("sta");
|
||||
ESP_ERROR_CHECK (esp_event_handler_unregister (
|
||||
WIFI_EVENT, WIFI_EVENT_STA_DISCONNECTED, &on_wifi_disconnect));
|
||||
ESP_ERROR_CHECK (esp_event_handler_unregister (IP_EVENT, IP_EVENT_STA_GOT_IP,
|
||||
&on_got_ip));
|
||||
#ifdef CONFIG_EXAMPLE_CONNECT_IPV6
|
||||
ESP_ERROR_CHECK (
|
||||
esp_event_handler_unregister (IP_EVENT, IP_EVENT_GOT_IP6, &on_got_ipv6));
|
||||
ESP_ERROR_CHECK (esp_event_handler_unregister (
|
||||
WIFI_EVENT, WIFI_EVENT_STA_CONNECTED, &on_wifi_connect));
|
||||
#endif
|
||||
esp_err_t err = esp_wifi_stop ();
|
||||
if (err == ESP_ERR_WIFI_NOT_INIT)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ESP_ERROR_CHECK (err);
|
||||
ESP_ERROR_CHECK (esp_wifi_deinit ());
|
||||
ESP_ERROR_CHECK (
|
||||
esp_wifi_clear_default_wifi_driver_and_handlers (wifi_netif));
|
||||
esp_netif_destroy (wifi_netif);
|
||||
esp_wifi_netif = NULL;
|
||||
}
|
||||
#endif // CONFIG_EXAMPLE_CONNECT_WIFI
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_CONNECT_ETHERNET
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_CONNECT_IPV6
|
||||
|
||||
/** Event handler for Ethernet events */
|
||||
static void
|
||||
on_eth_event (void *esp_netif, esp_event_base_t event_base, int32_t event_id,
|
||||
void *event_data)
|
||||
{
|
||||
switch (event_id)
|
||||
{
|
||||
case ETHERNET_EVENT_CONNECTED:
|
||||
ESP_LOGI (TAG, "Ethernet Link Up");
|
||||
esp_netif_create_ip6_linklocal (esp_netif);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // CONFIG_EXAMPLE_CONNECT_IPV6
|
||||
|
||||
static esp_eth_handle_t s_eth_handle = NULL;
|
||||
static esp_eth_mac_t *s_mac = NULL;
|
||||
static esp_eth_phy_t *s_phy = NULL;
|
||||
static void *s_eth_glue = NULL;
|
||||
|
||||
static esp_netif_t *
|
||||
eth_start (void)
|
||||
{
|
||||
char *desc;
|
||||
esp_netif_inherent_config_t esp_netif_config
|
||||
= ESP_NETIF_INHERENT_DEFAULT_ETH ();
|
||||
// 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 = 64;
|
||||
esp_netif_config_t netif_config
|
||||
= { .base = &esp_netif_config, .stack = ESP_NETIF_NETSTACK_DEFAULT_ETH };
|
||||
esp_netif_t *netif = esp_netif_new (&netif_config);
|
||||
assert (netif);
|
||||
free (desc);
|
||||
// Set default handlers to process TCP/IP stuffs
|
||||
ESP_ERROR_CHECK (esp_eth_set_default_handlers (netif));
|
||||
// Register user defined event handers
|
||||
ESP_ERROR_CHECK (esp_event_handler_register (IP_EVENT, IP_EVENT_ETH_GOT_IP,
|
||||
&on_got_ip, NULL));
|
||||
#ifdef CONFIG_EXAMPLE_CONNECT_IPV6
|
||||
ESP_ERROR_CHECK (esp_event_handler_register (
|
||||
ETH_EVENT, ETHERNET_EVENT_CONNECTED, &on_eth_event, netif));
|
||||
ESP_ERROR_CHECK (esp_event_handler_register (IP_EVENT, IP_EVENT_GOT_IP6,
|
||||
&on_got_ipv6, NULL));
|
||||
#endif
|
||||
eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG ();
|
||||
eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG ();
|
||||
phy_config.phy_addr = CONFIG_EXAMPLE_ETH_PHY_ADDR;
|
||||
phy_config.reset_gpio_num = CONFIG_EXAMPLE_ETH_PHY_RST_GPIO;
|
||||
#if CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET
|
||||
mac_config.smi_mdc_gpio_num = CONFIG_EXAMPLE_ETH_MDC_GPIO;
|
||||
mac_config.smi_mdio_gpio_num = CONFIG_EXAMPLE_ETH_MDIO_GPIO;
|
||||
s_mac = esp_eth_mac_new_esp32 (&mac_config);
|
||||
#if CONFIG_EXAMPLE_ETH_PHY_IP101
|
||||
s_phy = esp_eth_phy_new_ip101 (&phy_config);
|
||||
#elif CONFIG_EXAMPLE_ETH_PHY_RTL8201
|
||||
s_phy = esp_eth_phy_new_rtl8201 (&phy_config);
|
||||
#elif CONFIG_EXAMPLE_ETH_PHY_LAN8720
|
||||
s_phy = esp_eth_phy_new_lan8720 (&phy_config);
|
||||
#elif CONFIG_EXAMPLE_ETH_PHY_DP83848
|
||||
s_phy = esp_eth_phy_new_dp83848 (&phy_config);
|
||||
#endif
|
||||
#elif CONFIG_EXAMPLE_USE_DM9051
|
||||
gpio_install_isr_service (0);
|
||||
spi_device_handle_t spi_handle = NULL;
|
||||
spi_bus_config_t buscfg = {
|
||||
.miso_io_num = CONFIG_EXAMPLE_DM9051_MISO_GPIO,
|
||||
.mosi_io_num = CONFIG_EXAMPLE_DM9051_MOSI_GPIO,
|
||||
.sclk_io_num = CONFIG_EXAMPLE_DM9051_SCLK_GPIO,
|
||||
.quadwp_io_num = -1,
|
||||
.quadhd_io_num = -1,
|
||||
};
|
||||
ESP_ERROR_CHECK (
|
||||
spi_bus_initialize (CONFIG_EXAMPLE_DM9051_SPI_HOST, &buscfg, 1));
|
||||
spi_device_interface_config_t devcfg
|
||||
= { .command_bits = 1,
|
||||
.address_bits = 7,
|
||||
.mode = 0,
|
||||
.clock_speed_hz = CONFIG_EXAMPLE_DM9051_SPI_CLOCK_MHZ * 1000 * 1000,
|
||||
.spics_io_num = CONFIG_EXAMPLE_DM9051_CS_GPIO,
|
||||
.queue_size = 20 };
|
||||
ESP_ERROR_CHECK (spi_bus_add_device (CONFIG_EXAMPLE_DM9051_SPI_HOST, &devcfg,
|
||||
&spi_handle));
|
||||
/* dm9051 ethernet driver is based on spi driver */
|
||||
eth_dm9051_config_t dm9051_config = ETH_DM9051_DEFAULT_CONFIG (spi_handle);
|
||||
dm9051_config.int_gpio_num = CONFIG_EXAMPLE_DM9051_INT_GPIO;
|
||||
s_mac = esp_eth_mac_new_dm9051 (&dm9051_config, &mac_config);
|
||||
s_phy = esp_eth_phy_new_dm9051 (&phy_config);
|
||||
#elif CONFIG_EXAMPLE_USE_OPENETH
|
||||
phy_config.autonego_timeout_ms = 100;
|
||||
s_mac = esp_eth_mac_new_openeth (&mac_config);
|
||||
s_phy = esp_eth_phy_new_dp83848 (&phy_config);
|
||||
#endif
|
||||
|
||||
// Install Ethernet driver
|
||||
esp_eth_config_t config = ETH_DEFAULT_CONFIG (s_mac, s_phy);
|
||||
ESP_ERROR_CHECK (esp_eth_driver_install (&config, &s_eth_handle));
|
||||
// combine driver with netif
|
||||
s_eth_glue = esp_eth_new_netif_glue (s_eth_handle);
|
||||
esp_netif_attach (netif, s_eth_glue);
|
||||
esp_eth_start (s_eth_handle);
|
||||
return netif;
|
||||
}
|
||||
|
||||
static void
|
||||
eth_stop (void)
|
||||
{
|
||||
esp_netif_t *eth_netif = get_example_netif_from_desc ("eth");
|
||||
ESP_ERROR_CHECK (esp_event_handler_unregister (IP_EVENT, IP_EVENT_ETH_GOT_IP,
|
||||
&on_got_ip));
|
||||
#ifdef CONFIG_EXAMPLE_CONNECT_IPV6
|
||||
ESP_ERROR_CHECK (
|
||||
esp_event_handler_unregister (IP_EVENT, IP_EVENT_GOT_IP6, &on_got_ipv6));
|
||||
ESP_ERROR_CHECK (esp_event_handler_unregister (
|
||||
ETH_EVENT, ETHERNET_EVENT_CONNECTED, &on_eth_event));
|
||||
#endif
|
||||
ESP_ERROR_CHECK (esp_eth_stop (s_eth_handle));
|
||||
ESP_ERROR_CHECK (esp_eth_del_netif_glue (s_eth_glue));
|
||||
ESP_ERROR_CHECK (esp_eth_clear_default_handlers (eth_netif));
|
||||
ESP_ERROR_CHECK (esp_eth_driver_uninstall (s_eth_handle));
|
||||
ESP_ERROR_CHECK (s_phy->del (s_phy));
|
||||
ESP_ERROR_CHECK (s_mac->del (s_mac));
|
||||
|
||||
esp_netif_destroy (eth_netif);
|
||||
esp_wifi_netif = NULL;
|
||||
}
|
||||
|
||||
#endif // CONFIG_EXAMPLE_CONNECT_ETHERNET
|
||||
|
||||
esp_netif_t *
|
||||
get_example_netif (void)
|
||||
{
|
||||
return get_current_netif ();
|
||||
}
|
||||
|
||||
esp_netif_t *
|
||||
get_example_netif_from_desc (const char *desc)
|
||||
{
|
||||
esp_netif_t *netif = NULL;
|
||||
char *expected_desc;
|
||||
asprintf (&expected_desc, "%s: %s", TAG, desc);
|
||||
while ((netif = esp_netif_next (netif)) != NULL)
|
||||
{
|
||||
if (strcmp (esp_netif_get_desc (netif), expected_desc) == 0)
|
||||
{
|
||||
free (expected_desc);
|
||||
return netif;
|
||||
}
|
||||
}
|
||||
free (expected_desc);
|
||||
return netif;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/* Common utilities for socket address input interface:
|
||||
The API get_addr_from_stdin() is mainly used by socket client examples
|
||||
which read IP address from stdin (if configured). This option is typically
|
||||
used in the CI, but could be enabled in the project configuration. In that
|
||||
case this component is used to receive a string that is evaluated and
|
||||
processed to output socket structures to open a connectio 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
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "lwip/sys.h"
|
||||
#include <arpa/inet.h>
|
||||
#include <lwip/netdb.h>
|
||||
|
||||
/**
|
||||
* @brief Read and evaluate IP address from stdin
|
||||
*
|
||||
* This API reads stdin and parses the input address using getaddrinfo()
|
||||
* to fill in struct sockaddr_in6 (for both IPv4 and IPv6) used to open
|
||||
* a socket. IP protocol is guessed from the IP address string.
|
||||
*
|
||||
* @param[in] port port number of expected connection
|
||||
* @param[in] sock_type expected protocol: SOCK_STREAM or SOCK_DGRAM
|
||||
* @param[out] ip_protocol resultant IP protocol: IPPROTO_IP or IPPROTO_IP6
|
||||
* @param[out] addr_family resultant address family: AF_INET or AF_INET6
|
||||
* @param[out] dest_addr sockaddr_in6 structure (for both IPv4 and IPv6)
|
||||
* @return ESP_OK on success, ESP_FAIL otherwise
|
||||
*/
|
||||
esp_err_t get_addr_from_stdin (int port, int sock_type, int *ip_protocol,
|
||||
int *addr_family,
|
||||
struct sockaddr_in6 *dest_addr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,80 @@
|
||||
/* Common functions for protocol examples, to establish Wi-Fi or Ethernet
|
||||
connection.
|
||||
|
||||
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
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_netif.h"
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_CONNECT_ETHERNET
|
||||
#define EXAMPLE_INTERFACE get_example_netif ()
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_CONNECT_WIFI
|
||||
#define EXAMPLE_INTERFACE get_example_netif ()
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Configure Wi-Fi or Ethernet, connect, wait for IP
|
||||
*
|
||||
* This all-in-one helper function is used in protocols examples to
|
||||
* reduce the amount of boilerplate in the example.
|
||||
*
|
||||
* It is not intended to be used in real world applications.
|
||||
* See examples under examples/wifi/getting_started/ and examples/ethernet/
|
||||
* for more complete Wi-Fi or Ethernet initialization code.
|
||||
*
|
||||
* Read "Establishing Wi-Fi or Ethernet Connection" section in
|
||||
* examples/protocols/README.md for more information about this function.
|
||||
*
|
||||
* @return ESP_OK on successful connection
|
||||
*/
|
||||
esp_err_t example_connect (void);
|
||||
|
||||
/**
|
||||
* Counterpart to example_connect, de-initializes Wi-Fi or Ethernet
|
||||
*/
|
||||
esp_err_t example_disconnect (void);
|
||||
|
||||
/**
|
||||
* @brief Configure stdin and stdout to use blocking I/O
|
||||
*
|
||||
* This helper function is used in ASIO examples. It wraps installing the
|
||||
* UART driver and configuring VFS layer to use UART driver for console I/O.
|
||||
*/
|
||||
esp_err_t example_configure_stdin_stdout (void);
|
||||
|
||||
/**
|
||||
* @brief Returns esp-netif pointer created by example_connect()
|
||||
*
|
||||
* @note If multiple interfaces active at once, this API return NULL
|
||||
* In that case the get_example_netif_from_desc() should be used
|
||||
* to get esp-netif pointer based on interface description
|
||||
*/
|
||||
esp_netif_t *get_example_netif (void);
|
||||
|
||||
/**
|
||||
* @brief Returns esp-netif pointer created by example_connect() described by
|
||||
* the supplied desc field
|
||||
*
|
||||
* @param desc Textual interface of created network interface, for example
|
||||
* "sta" indicate default WiFi station, "eth" default Ethernet interface.
|
||||
*
|
||||
*/
|
||||
esp_netif_t *get_example_netif_from_desc (const char *desc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
32
components/protocol_examples_common/stdin_out.c
Normal file
32
components/protocol_examples_common/stdin_out.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/* Common functions for protocol examples, to configure stdin and stdout.
|
||||
|
||||
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
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
|
||||
#include "driver/uart.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_vfs_dev.h"
|
||||
#include "protocol_examples_common.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
esp_err_t
|
||||
example_configure_stdin_stdout (void)
|
||||
{
|
||||
// Initialize VFS & UART so we can use std::cout/cin
|
||||
setvbuf (stdin, NULL, _IONBF, 0);
|
||||
/* Install UART driver for interrupt-driven reads and writes */
|
||||
ESP_ERROR_CHECK (uart_driver_install (
|
||||
(uart_port_t)CONFIG_ESP_CONSOLE_UART_NUM, 256, 0, 0, NULL, 0));
|
||||
/* Tell VFS to use UART driver */
|
||||
esp_vfs_dev_uart_use_driver (CONFIG_ESP_CONSOLE_UART_NUM);
|
||||
esp_vfs_dev_uart_port_set_rx_line_endings (CONFIG_ESP_CONSOLE_UART_NUM,
|
||||
ESP_LINE_ENDINGS_CR);
|
||||
/* Move the caret to the beginning of the next line on '\n' */
|
||||
esp_vfs_dev_uart_port_set_tx_line_endings (CONFIG_ESP_CONSOLE_UART_NUM,
|
||||
ESP_LINE_ENDINGS_CRLF);
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef _WIFI_INTERFACE_H_
|
||||
#define _WIFI_INTERFACE_H_
|
||||
|
||||
#include "esp_netif_types.h"
|
||||
#include "freertos/event_groups.h"
|
||||
|
||||
// use wifi provisioning
|
||||
@@ -23,6 +24,7 @@
|
||||
#define WIFI_CONNECTED_BIT BIT0
|
||||
#define WIFI_FAIL_BIT BIT1
|
||||
|
||||
void wifi_init(void);
|
||||
void wifi_init (void);
|
||||
esp_netif_t *get_current_netif (void);
|
||||
|
||||
#endif /* _WIFI_INTERFACE_H_ */
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "wifi_interface.h"
|
||||
|
||||
#if ENABLE_WIFI_PROVISIONING
|
||||
#include <string.h> // for memcpy
|
||||
#include <string.h> // for memcpy
|
||||
#include <wifi_provisioning/manager.h>
|
||||
#include <wifi_provisioning/scheme_softap.h>
|
||||
#endif
|
||||
@@ -29,6 +29,8 @@ EventGroupHandle_t s_wifi_event_group;
|
||||
static int s_retry_num = 0;
|
||||
static wifi_config_t wifi_config;
|
||||
|
||||
static esp_netif_t *esp_wifi_netif = NULL;
|
||||
|
||||
/* FreeRTOS event group to signal when we are connected & ready to make a
|
||||
* request */
|
||||
// static EventGroupHandle_t wifi_event_group;
|
||||
@@ -38,183 +40,211 @@ static wifi_config_t wifi_config;
|
||||
to the AP with an IP? */
|
||||
|
||||
// Event handler for catching system events
|
||||
static void event_handler(void *arg, esp_event_base_t event_base, int event_id,
|
||||
void *event_data) {
|
||||
if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) {
|
||||
esp_wifi_connect();
|
||||
} else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {
|
||||
ip_event_got_ip_t *event = (ip_event_got_ip_t *)event_data;
|
||||
ESP_LOGI(TAG, "Connected with IP Address:" IPSTR,
|
||||
IP2STR(&event->ip_info.ip));
|
||||
s_retry_num = 0;
|
||||
// Signal main application to continue execution
|
||||
xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
|
||||
} else if (event_base == WIFI_EVENT &&
|
||||
event_id == WIFI_EVENT_STA_DISCONNECTED) {
|
||||
if ((s_retry_num < WIFI_MAXIMUM_RETRY) || (WIFI_MAXIMUM_RETRY == 0)) {
|
||||
esp_wifi_connect();
|
||||
s_retry_num++;
|
||||
ESP_LOGI(TAG, "retry to connect to the AP");
|
||||
} else {
|
||||
xEventGroupSetBits(s_wifi_event_group, WIFI_FAIL_BIT);
|
||||
static void
|
||||
event_handler (void *arg, esp_event_base_t event_base, int event_id,
|
||||
void *event_data)
|
||||
{
|
||||
if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START)
|
||||
{
|
||||
esp_wifi_connect ();
|
||||
}
|
||||
ESP_LOGI(TAG, "connect to the AP fail");
|
||||
} else {
|
||||
else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP)
|
||||
{
|
||||
ip_event_got_ip_t *event = (ip_event_got_ip_t *)event_data;
|
||||
ESP_LOGI (TAG, "Connected with IP Address:" IPSTR,
|
||||
IP2STR (&event->ip_info.ip));
|
||||
|
||||
s_retry_num = 0;
|
||||
// Signal main application to continue execution
|
||||
xEventGroupSetBits (s_wifi_event_group, WIFI_CONNECTED_BIT);
|
||||
}
|
||||
else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED)
|
||||
{
|
||||
if ((s_retry_num < WIFI_MAXIMUM_RETRY) || (WIFI_MAXIMUM_RETRY == 0))
|
||||
{
|
||||
esp_wifi_connect ();
|
||||
s_retry_num++;
|
||||
ESP_LOGI (TAG, "retry to connect to the AP");
|
||||
}
|
||||
else
|
||||
{
|
||||
xEventGroupSetBits (s_wifi_event_group, WIFI_FAIL_BIT);
|
||||
}
|
||||
ESP_LOGI (TAG, "connect to the AP fail");
|
||||
}
|
||||
else
|
||||
{
|
||||
#if ENABLE_WIFI_PROVISIONING
|
||||
if (event_base == WIFI_PROV_EVENT) {
|
||||
switch (event_id) {
|
||||
case WIFI_PROV_START:
|
||||
ESP_LOGI(TAG, "Provisioning started");
|
||||
break;
|
||||
case WIFI_PROV_CRED_RECV: {
|
||||
wifi_sta_config_t *wifi_sta_cfg = (wifi_sta_config_t *)event_data;
|
||||
ESP_LOGI(TAG,
|
||||
"Received Wi-Fi credentials"
|
||||
"\n\tSSID : %s\n\tPassword : %s",
|
||||
(const char *)wifi_sta_cfg->ssid,
|
||||
(const char *)wifi_sta_cfg->password);
|
||||
memcpy(&(wifi_config.sta), wifi_sta_cfg, sizeof(wifi_sta_config_t));
|
||||
break;
|
||||
if (event_base == WIFI_PROV_EVENT)
|
||||
{
|
||||
switch (event_id)
|
||||
{
|
||||
case WIFI_PROV_START:
|
||||
ESP_LOGI (TAG, "Provisioning started");
|
||||
break;
|
||||
case WIFI_PROV_CRED_RECV:
|
||||
{
|
||||
wifi_sta_config_t *wifi_sta_cfg
|
||||
= (wifi_sta_config_t *)event_data;
|
||||
ESP_LOGI (TAG,
|
||||
"Received Wi-Fi credentials"
|
||||
"\n\tSSID : %s\n\tPassword : %s",
|
||||
(const char *)wifi_sta_cfg->ssid,
|
||||
(const char *)wifi_sta_cfg->password);
|
||||
memcpy (&(wifi_config.sta), wifi_sta_cfg,
|
||||
sizeof (wifi_sta_config_t));
|
||||
break;
|
||||
}
|
||||
case WIFI_PROV_CRED_FAIL:
|
||||
{
|
||||
wifi_prov_sta_fail_reason_t *reason
|
||||
= (wifi_prov_sta_fail_reason_t *)event_data;
|
||||
ESP_LOGE (TAG,
|
||||
"Provisioning failed!\n\tReason : %s"
|
||||
"\n\tPlease reset to factory and retry provisioning",
|
||||
(*reason == WIFI_PROV_STA_AUTH_ERROR)
|
||||
? "Wi-Fi station authentication failed"
|
||||
: "Wi-Fi access-point not found");
|
||||
break;
|
||||
}
|
||||
case WIFI_PROV_CRED_SUCCESS:
|
||||
ESP_LOGI (TAG, "Provisioning successful");
|
||||
break;
|
||||
case WIFI_PROV_END:
|
||||
/* De-initialize manager once provisioning is finished */
|
||||
wifi_prov_mgr_deinit ();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
case WIFI_PROV_CRED_FAIL: {
|
||||
wifi_prov_sta_fail_reason_t *reason =
|
||||
(wifi_prov_sta_fail_reason_t *)event_data;
|
||||
ESP_LOGE(TAG,
|
||||
"Provisioning failed!\n\tReason : %s"
|
||||
"\n\tPlease reset to factory and retry provisioning",
|
||||
(*reason == WIFI_PROV_STA_AUTH_ERROR)
|
||||
? "Wi-Fi station authentication failed"
|
||||
: "Wi-Fi access-point not found");
|
||||
break;
|
||||
}
|
||||
case WIFI_PROV_CRED_SUCCESS:
|
||||
ESP_LOGI(TAG, "Provisioning successful");
|
||||
break;
|
||||
case WIFI_PROV_END:
|
||||
/* De-initialize manager once provisioning is finished */
|
||||
wifi_prov_mgr_deinit();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLE_WIFI_PROVISIONING
|
||||
static void get_device_service_name(char *service_name, size_t max) {
|
||||
static void
|
||||
get_device_service_name (char *service_name, size_t max)
|
||||
{
|
||||
uint8_t eth_mac[6];
|
||||
const char *ssid_prefix = "PROV_";
|
||||
esp_wifi_get_mac(WIFI_IF_STA, eth_mac);
|
||||
snprintf(service_name, max, "%s%02X%02X%02X", ssid_prefix, eth_mac[3],
|
||||
eth_mac[4], eth_mac[5]);
|
||||
esp_wifi_get_mac (WIFI_IF_STA, eth_mac);
|
||||
snprintf (service_name, max, "%s%02X%02X%02X", ssid_prefix, eth_mac[3],
|
||||
eth_mac[4], eth_mac[5]);
|
||||
}
|
||||
#endif
|
||||
|
||||
void wifi_init(void) {
|
||||
s_wifi_event_group = xEventGroupCreate();
|
||||
void
|
||||
wifi_init (void)
|
||||
{
|
||||
s_wifi_event_group = xEventGroupCreate ();
|
||||
|
||||
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_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID,
|
||||
&event_handler, NULL));
|
||||
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP,
|
||||
&event_handler, NULL));
|
||||
ESP_ERROR_CHECK (esp_event_handler_register (WIFI_EVENT, ESP_EVENT_ANY_ID,
|
||||
&event_handler, NULL));
|
||||
ESP_ERROR_CHECK (esp_event_handler_register (IP_EVENT, IP_EVENT_STA_GOT_IP,
|
||||
&event_handler, NULL));
|
||||
#if ENABLE_WIFI_PROVISIONING
|
||||
ESP_ERROR_CHECK(esp_event_handler_register(WIFI_PROV_EVENT, ESP_EVENT_ANY_ID,
|
||||
&event_handler, NULL));
|
||||
ESP_ERROR_CHECK (esp_event_handler_register (
|
||||
WIFI_PROV_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL));
|
||||
#endif
|
||||
|
||||
esp_netif_create_default_wifi_sta();
|
||||
esp_wifi_netif = esp_netif_create_default_wifi_sta ();
|
||||
#if ENABLE_WIFI_PROVISIONING
|
||||
esp_netif_create_default_wifi_ap();
|
||||
esp_netif_create_default_wifi_ap ();
|
||||
#endif
|
||||
|
||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
|
||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT ();
|
||||
ESP_ERROR_CHECK (esp_wifi_init (&cfg));
|
||||
|
||||
// esp_wifi_set_ps(WIFI_PS_MIN_MODEM);
|
||||
// esp_wifi_set_ps(WIFI_PS_NONE);
|
||||
|
||||
#if ENABLE_WIFI_PROVISIONING
|
||||
// Configuration for the provisioning manager
|
||||
wifi_prov_mgr_config_t config = {
|
||||
.scheme = wifi_prov_scheme_softap,
|
||||
.scheme_event_handler = WIFI_PROV_EVENT_HANDLER_NONE};
|
||||
wifi_prov_mgr_config_t config
|
||||
= { .scheme = wifi_prov_scheme_softap,
|
||||
.scheme_event_handler = WIFI_PROV_EVENT_HANDLER_NONE };
|
||||
|
||||
// Initialize provisioning manager with the
|
||||
// configuration parameters set above
|
||||
ESP_ERROR_CHECK(wifi_prov_mgr_init(config));
|
||||
ESP_ERROR_CHECK (wifi_prov_mgr_init (config));
|
||||
|
||||
bool provisioned = false;
|
||||
/* Let's find out if the device is provisioned */
|
||||
ESP_ERROR_CHECK(wifi_prov_mgr_is_provisioned(&provisioned));
|
||||
ESP_ERROR_CHECK (wifi_prov_mgr_is_provisioned (&provisioned));
|
||||
|
||||
/* If device is not yet provisioned start provisioning service */
|
||||
if (!provisioned) {
|
||||
ESP_LOGI(TAG, "Starting provisioning");
|
||||
if (!provisioned)
|
||||
{
|
||||
ESP_LOGI (TAG, "Starting provisioning");
|
||||
|
||||
// Wi-Fi SSID when scheme is wifi_prov_scheme_softap
|
||||
char service_name[12];
|
||||
get_device_service_name(service_name, sizeof(service_name));
|
||||
// Wi-Fi SSID when scheme is wifi_prov_scheme_softap
|
||||
char service_name[12];
|
||||
get_device_service_name (service_name, sizeof (service_name));
|
||||
|
||||
/* What is the security level that we want (0 or 1):
|
||||
* - WIFI_PROV_SECURITY_0 is simply plain text communication.
|
||||
* - WIFI_PROV_SECURITY_1 is secure communication which consists of
|
||||
* secure handshake using X25519 key exchange and proof of possession (pop)
|
||||
* and AES-CTR for encryption/decryption of messages.
|
||||
*/
|
||||
wifi_prov_security_t security = WIFI_PROV_SECURITY_1;
|
||||
/* What is the security level that we want (0 or 1):
|
||||
* - WIFI_PROV_SECURITY_0 is simply plain text communication.
|
||||
* - WIFI_PROV_SECURITY_1 is secure communication which consists of
|
||||
* secure handshake using X25519 key exchange and proof of possession
|
||||
* (pop) and AES-CTR for encryption/decryption of messages.
|
||||
*/
|
||||
wifi_prov_security_t security = WIFI_PROV_SECURITY_1;
|
||||
|
||||
/* Do we want a proof-of-possession (ignored if Security 0 is selected):
|
||||
* - this should be a string with length > 0
|
||||
* - NULL if not used
|
||||
*/
|
||||
const char *pop = NULL; //"abcd1234";
|
||||
/* Do we want a proof-of-possession (ignored if Security 0 is selected):
|
||||
* - this should be a string with length > 0
|
||||
* - NULL if not used
|
||||
*/
|
||||
const char *pop = NULL; //"abcd1234";
|
||||
|
||||
/* What is the service key (could be NULL)
|
||||
* This translates to :
|
||||
* - Wi-Fi password when scheme is wifi_prov_scheme_softap
|
||||
* - simply ignored when scheme is wifi_prov_scheme_ble
|
||||
*/
|
||||
const char *service_key = "12345678";
|
||||
/* What is the service key (could be NULL)
|
||||
* This translates to :
|
||||
* - Wi-Fi password when scheme is wifi_prov_scheme_softap
|
||||
* - simply ignored when scheme is wifi_prov_scheme_ble
|
||||
*/
|
||||
const char *service_key = "12345678";
|
||||
|
||||
/* An optional endpoint that applications can create if they expect to
|
||||
* get some additional custom data during provisioning workflow.
|
||||
* The endpoint name can be anything of your choice.
|
||||
* This call must be made before starting the provisioning.
|
||||
*/
|
||||
// wifi_prov_mgr_endpoint_create("custom-data");
|
||||
/* Start provisioning service */
|
||||
ESP_ERROR_CHECK(wifi_prov_mgr_start_provisioning(
|
||||
security, pop, service_name, service_key));
|
||||
/* An optional endpoint that applications can create if they expect to
|
||||
* get some additional custom data during provisioning workflow.
|
||||
* The endpoint name can be anything of your choice.
|
||||
* This call must be made before starting the provisioning.
|
||||
*/
|
||||
// wifi_prov_mgr_endpoint_create("custom-data");
|
||||
/* Start provisioning service */
|
||||
ESP_ERROR_CHECK (wifi_prov_mgr_start_provisioning (
|
||||
security, pop, service_name, service_key));
|
||||
|
||||
/* The handler for the optional endpoint created above.
|
||||
* This call must be made after starting the provisioning, and only if the
|
||||
* endpoint has already been created above.
|
||||
*/
|
||||
// wifi_prov_mgr_endpoint_register("custom-data", custom_prov_data_handler,
|
||||
// NULL);
|
||||
/* The handler for the optional endpoint created above.
|
||||
* This call must be made after starting the provisioning, and only if
|
||||
* the endpoint has already been created above.
|
||||
*/
|
||||
// wifi_prov_mgr_endpoint_register("custom-data",
|
||||
// custom_prov_data_handler, NULL);
|
||||
|
||||
/* Uncomment the following to wait for the provisioning to finish and then
|
||||
* release the resources of the manager. Since in this case
|
||||
* de-initialization is triggered by the default event loop handler, we
|
||||
* don't need to call the following */
|
||||
// wifi_prov_mgr_wait();
|
||||
// wifi_prov_mgr_deinit();
|
||||
} else {
|
||||
ESP_LOGI(TAG, "Already provisioned, starting Wi-Fi STA");
|
||||
/* Uncomment the following to wait for the provisioning to finish and
|
||||
* then release the resources of the manager. Since in this case
|
||||
* de-initialization is triggered by the default event loop handler, we
|
||||
* don't need to call the following */
|
||||
// wifi_prov_mgr_wait();
|
||||
// wifi_prov_mgr_deinit();
|
||||
}
|
||||
else
|
||||
{
|
||||
ESP_LOGI (TAG, "Already provisioned, starting Wi-Fi STA");
|
||||
|
||||
/* We don't need the manager as device is already provisioned,
|
||||
* so let's release it's resources */
|
||||
wifi_prov_mgr_deinit();
|
||||
/* We don't need the manager as device is already provisioned,
|
||||
* so let's release it's resources */
|
||||
wifi_prov_mgr_deinit ();
|
||||
|
||||
/* Start Wi-Fi station */
|
||||
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
|
||||
ESP_ERROR_CHECK(esp_wifi_start());
|
||||
/* Start Wi-Fi station */
|
||||
ESP_ERROR_CHECK (esp_wifi_set_mode (WIFI_MODE_STA));
|
||||
ESP_ERROR_CHECK (esp_wifi_start ());
|
||||
|
||||
ESP_LOGI(TAG, "wifi_init_sta finished.");
|
||||
}
|
||||
ESP_LOGI (TAG, "wifi_init_sta finished.");
|
||||
}
|
||||
#else
|
||||
wifi_config_t wifi_config = {
|
||||
.sta =
|
||||
@@ -225,40 +255,52 @@ void wifi_init(void) {
|
||||
.pmf_cfg = {.capable = true, .required = false},
|
||||
},
|
||||
};
|
||||
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config));
|
||||
ESP_ERROR_CHECK (esp_wifi_set_config (ESP_IF_WIFI_STA, &wifi_config));
|
||||
|
||||
/* Start Wi-Fi station */
|
||||
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
|
||||
ESP_ERROR_CHECK(esp_wifi_start());
|
||||
ESP_ERROR_CHECK (esp_wifi_set_mode (WIFI_MODE_STA));
|
||||
ESP_ERROR_CHECK (esp_wifi_start ());
|
||||
|
||||
ESP_LOGI(TAG, "wifi_init_sta finished.");
|
||||
ESP_LOGI (TAG, "wifi_init_sta finished.");
|
||||
#endif
|
||||
|
||||
/* Waiting until either the connection is established (WIFI_CONNECTED_BIT) or
|
||||
* connection failed for the maximum number of re-tries (WIFI_FAIL_BIT). The
|
||||
* bits are set by event_handler() (see above) */
|
||||
EventBits_t bits = xEventGroupWaitBits(s_wifi_event_group,
|
||||
WIFI_CONNECTED_BIT | WIFI_FAIL_BIT,
|
||||
pdFALSE, pdFALSE, portMAX_DELAY);
|
||||
EventBits_t bits = xEventGroupWaitBits (s_wifi_event_group,
|
||||
WIFI_CONNECTED_BIT | WIFI_FAIL_BIT,
|
||||
pdFALSE, pdFALSE, portMAX_DELAY);
|
||||
|
||||
/* xEventGroupWaitBits() returns the bits before the call returned, hence we
|
||||
* can test which event actually happened. */
|
||||
if (bits & WIFI_CONNECTED_BIT) {
|
||||
ESP_LOGI(TAG, "connected to ap SSID: %s", wifi_config.sta.ssid);
|
||||
} else if (bits & WIFI_FAIL_BIT) {
|
||||
ESP_LOGI(TAG, "Failed to connect to SSID:%s, password:%s",
|
||||
wifi_config.sta.ssid, wifi_config.sta.password);
|
||||
} else {
|
||||
ESP_LOGE(TAG, "UNEXPECTED EVENT");
|
||||
}
|
||||
if (bits & WIFI_CONNECTED_BIT)
|
||||
{
|
||||
ESP_LOGI (TAG, "connected to ap SSID: %s", wifi_config.sta.ssid);
|
||||
}
|
||||
else if (bits & WIFI_FAIL_BIT)
|
||||
{
|
||||
ESP_LOGI (TAG, "Failed to connect to SSID:%s, password:%s",
|
||||
wifi_config.sta.ssid, wifi_config.sta.password);
|
||||
}
|
||||
else
|
||||
{
|
||||
ESP_LOGE (TAG, "UNEXPECTED EVENT");
|
||||
}
|
||||
|
||||
uint8_t base_mac[6];
|
||||
// Get MAC address for WiFi station
|
||||
esp_read_mac(base_mac, ESP_MAC_WIFI_STA);
|
||||
sprintf(mac_address, "%02X:%02X:%02X:%02X:%02X:%02X", base_mac[0],
|
||||
base_mac[1], base_mac[2], base_mac[3], base_mac[4], base_mac[5]);
|
||||
esp_read_mac (base_mac, ESP_MAC_WIFI_STA);
|
||||
sprintf (mac_address, "%02X:%02X:%02X:%02X:%02X:%02X", base_mac[0],
|
||||
base_mac[1], base_mac[2], base_mac[3], base_mac[4], base_mac[5]);
|
||||
|
||||
// ESP_ERROR_CHECK(esp_event_handler_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP,
|
||||
// &event_handler)); ESP_ERROR_CHECK(esp_event_handler_unregister(WIFI_EVENT,
|
||||
// ESP_EVENT_ANY_ID, &event_handler)); vEventGroupDelete(s_wifi_event_group);
|
||||
// ESP_ERROR_CHECK(esp_event_handler_unregister(IP_EVENT,
|
||||
// IP_EVENT_STA_GOT_IP, &event_handler));
|
||||
// ESP_ERROR_CHECK(esp_event_handler_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID,
|
||||
// &event_handler)); vEventGroupDelete(s_wifi_event_group);
|
||||
}
|
||||
|
||||
esp_netif_t *
|
||||
get_current_netif (void)
|
||||
{
|
||||
return esp_wifi_netif;
|
||||
}
|
||||
|
||||
1
components/wifi_logger
Submodule
1
components/wifi_logger
Submodule
Submodule components/wifi_logger added at 23bf246c86
2479
main/main.c
2479
main/main.c
File diff suppressed because it is too large
Load Diff
102
sdkconfig
102
sdkconfig
@@ -152,11 +152,19 @@ CONFIG_SNTP_TIMEZONE="UTC"
|
||||
CONFIG_SNTP_SERVER="pool.ntp.org"
|
||||
# end of SNTP Configuration
|
||||
|
||||
#
|
||||
# Example Connection Configuration
|
||||
#
|
||||
# CONFIG_EXAMPLE_CONNECT_WIFI is not set
|
||||
# CONFIG_EXAMPLE_CONNECT_ETHERNET is not set
|
||||
# CONFIG_EXAMPLE_CONNECT_IPV6 is not set
|
||||
# end of Example Connection Configuration
|
||||
|
||||
#
|
||||
# Wifi Configuration
|
||||
#
|
||||
CONFIG_ENABLE_WIFI_PROVISIONING=y
|
||||
CONFIG_WIFI_MAXIMUM_RETRY=5
|
||||
CONFIG_WIFI_MAXIMUM_RETRY=0
|
||||
# end of Wifi Configuration
|
||||
|
||||
#
|
||||
@@ -244,6 +252,7 @@ CONFIG_BT_CTRL_SLEEP_MODE_EFF=0
|
||||
CONFIG_BT_CTRL_SLEEP_CLOCK_EFF=0
|
||||
CONFIG_BT_CTRL_HCI_TL_EFF=1
|
||||
CONFIG_BT_RESERVE_DRAM=0
|
||||
CONFIG_BT_NIMBLE_USE_ESP_TIMER=y
|
||||
# end of Bluetooth
|
||||
|
||||
#
|
||||
@@ -270,9 +279,9 @@ CONFIG_ADC_DISABLE_DAC=y
|
||||
# SPI configuration
|
||||
#
|
||||
# CONFIG_SPI_MASTER_IN_IRAM is not set
|
||||
CONFIG_SPI_MASTER_ISR_IN_IRAM=y
|
||||
# CONFIG_SPI_MASTER_ISR_IN_IRAM is not set
|
||||
# CONFIG_SPI_SLAVE_IN_IRAM is not set
|
||||
CONFIG_SPI_SLAVE_ISR_IN_IRAM=y
|
||||
# CONFIG_SPI_SLAVE_ISR_IN_IRAM is not set
|
||||
# end of SPI configuration
|
||||
|
||||
#
|
||||
@@ -375,6 +384,7 @@ CONFIG_ESP32_XTAL_FREQ=40
|
||||
# CONFIG_ESP32_DISABLE_BASIC_ROM_CONSOLE is not set
|
||||
# CONFIG_ESP32_NO_BLOBS is not set
|
||||
# CONFIG_ESP32_COMPATIBLE_PRE_V2_1_BOOTLOADERS is not set
|
||||
# CONFIG_ESP32_COMPATIBLE_PRE_V3_1_BOOTLOADERS is not set
|
||||
# CONFIG_ESP32_USE_FIXED_STATIC_RAM_SIZE is not set
|
||||
CONFIG_ESP32_DPORT_DIS_INTERRUPT_LVL=5
|
||||
# end of ESP32-specific
|
||||
@@ -525,23 +535,28 @@ CONFIG_ESP_TIMER_IMPL_TG0_LAC=y
|
||||
#
|
||||
# Wi-Fi
|
||||
#
|
||||
CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=6
|
||||
CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=24
|
||||
CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=25
|
||||
CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=128
|
||||
# CONFIG_ESP32_WIFI_STATIC_TX_BUFFER is not set
|
||||
CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER=y
|
||||
CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1
|
||||
CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=18
|
||||
CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=16
|
||||
# CONFIG_ESP32_WIFI_CSI_ENABLED is not set
|
||||
CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y
|
||||
CONFIG_ESP32_WIFI_TX_BA_WIN=12
|
||||
CONFIG_ESP32_WIFI_TX_BA_WIN=16
|
||||
CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y
|
||||
CONFIG_ESP32_WIFI_RX_BA_WIN=6
|
||||
CONFIG_ESP32_WIFI_RX_BA_WIN=25
|
||||
CONFIG_ESP32_WIFI_NVS_ENABLED=y
|
||||
CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0=y
|
||||
# CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1 is not set
|
||||
CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN=752
|
||||
CONFIG_ESP32_WIFI_MGMT_SBUF_NUM=32
|
||||
# CONFIG_ESP32_WIFI_DEBUG_LOG_ENABLE is not set
|
||||
# CONFIG_WIFI_LOG_DEFAULT_LEVEL_NONE is not set
|
||||
# CONFIG_WIFI_LOG_DEFAULT_LEVEL_ERROR is not set
|
||||
# CONFIG_WIFI_LOG_DEFAULT_LEVEL_WARN is not set
|
||||
CONFIG_WIFI_LOG_DEFAULT_LEVEL_INFO=y
|
||||
# CONFIG_WIFI_LOG_DEFAULT_LEVEL_DEBUG is not set
|
||||
# CONFIG_WIFI_LOG_DEFAULT_LEVEL_VERBOSE is not set
|
||||
# CONFIG_ESP32_WIFI_IRAM_OPT is not set
|
||||
# CONFIG_ESP32_WIFI_RX_IRAM_OPT is not set
|
||||
CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE=y
|
||||
@@ -662,7 +677,7 @@ CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0
|
||||
# CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS is not set
|
||||
CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y
|
||||
# CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set
|
||||
# CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH is not set
|
||||
CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y
|
||||
CONFIG_FREERTOS_DEBUG_OCDAWARE=y
|
||||
# CONFIG_FREERTOS_FPU_IN_ISR is not set
|
||||
# end of FreeRTOS
|
||||
@@ -702,8 +717,8 @@ CONFIG_LOG_DEFAULT_LEVEL_INFO=y
|
||||
# CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set
|
||||
CONFIG_LOG_DEFAULT_LEVEL=3
|
||||
CONFIG_LOG_COLORS=y
|
||||
CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y
|
||||
# CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM is not set
|
||||
# CONFIG_LOG_TIMESTAMP_SOURCE_RTOS is not set
|
||||
CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM=y
|
||||
# end of Log output
|
||||
|
||||
#
|
||||
@@ -718,7 +733,7 @@ CONFIG_LWIP_MAX_SOCKETS=6
|
||||
# CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set
|
||||
# CONFIG_LWIP_SO_LINGER is not set
|
||||
CONFIG_LWIP_SO_REUSE=y
|
||||
CONFIG_LWIP_SO_REUSE_RXTOALL=y
|
||||
# CONFIG_LWIP_SO_REUSE_RXTOALL is not set
|
||||
# CONFIG_LWIP_SO_RCVBUF is not set
|
||||
# CONFIG_LWIP_NETBUF_RECVINFO is not set
|
||||
CONFIG_LWIP_IP4_FRAG=y
|
||||
@@ -726,17 +741,19 @@ CONFIG_LWIP_IP6_FRAG=y
|
||||
# CONFIG_LWIP_IP4_REASSEMBLY is not set
|
||||
# CONFIG_LWIP_IP6_REASSEMBLY is not set
|
||||
# CONFIG_LWIP_IP_FORWARD is not set
|
||||
CONFIG_LWIP_STATS=y
|
||||
# CONFIG_LWIP_STATS is not set
|
||||
# CONFIG_LWIP_ETHARP_TRUST_IP_MAC is not set
|
||||
CONFIG_LWIP_ESP_GRATUITOUS_ARP=y
|
||||
CONFIG_LWIP_GARP_TMR_INTERVAL=60
|
||||
CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=12
|
||||
CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32
|
||||
CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y
|
||||
# CONFIG_LWIP_DHCP_DISABLE_CLIENT_ID is not set
|
||||
# CONFIG_LWIP_DHCP_RESTORE_LAST_IP is not set
|
||||
|
||||
#
|
||||
# DHCP server
|
||||
#
|
||||
CONFIG_LWIP_DHCPS=y
|
||||
CONFIG_LWIP_DHCPS_LEASE_UNIT=60
|
||||
CONFIG_LWIP_DHCPS_MAX_STATION_NUM=8
|
||||
# end of DHCP server
|
||||
@@ -750,7 +767,7 @@ CONFIG_LWIP_LOOPBACK_MAX_PBUFS=8
|
||||
#
|
||||
# TCP
|
||||
#
|
||||
CONFIG_LWIP_MAX_ACTIVE_TCP=3
|
||||
CONFIG_LWIP_MAX_ACTIVE_TCP=6
|
||||
CONFIG_LWIP_MAX_LISTENING_TCP=3
|
||||
CONFIG_LWIP_TCP_HIGH_SPEED_RETRANSMISSION=y
|
||||
CONFIG_LWIP_TCP_MAXRTX=12
|
||||
@@ -758,11 +775,11 @@ CONFIG_LWIP_TCP_SYNMAXRTX=12
|
||||
CONFIG_LWIP_TCP_MSS=1460
|
||||
CONFIG_LWIP_TCP_TMR_INTERVAL=250
|
||||
CONFIG_LWIP_TCP_MSL=60000
|
||||
CONFIG_LWIP_TCP_SND_BUF_DEFAULT=5840
|
||||
CONFIG_LWIP_TCP_WND_DEFAULT=5840
|
||||
CONFIG_LWIP_TCP_RECVMBOX_SIZE=12
|
||||
CONFIG_LWIP_TCP_SND_BUF_DEFAULT=65534
|
||||
CONFIG_LWIP_TCP_WND_DEFAULT=65534
|
||||
CONFIG_LWIP_TCP_RECVMBOX_SIZE=6
|
||||
CONFIG_LWIP_TCP_QUEUE_OOSEQ=y
|
||||
# CONFIG_LWIP_TCP_SACK_OUT is not set
|
||||
CONFIG_LWIP_TCP_SACK_OUT=y
|
||||
# CONFIG_LWIP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES is not set
|
||||
CONFIG_LWIP_TCP_OVERSIZE_MSS=y
|
||||
# CONFIG_LWIP_TCP_OVERSIZE_QUARTER_MSS is not set
|
||||
@@ -785,7 +802,7 @@ CONFIG_LWIP_UDP_RECVMBOX_SIZE=6
|
||||
CONFIG_LWIP_CHECKSUM_CHECK_ICMP=y
|
||||
# end of Checksums
|
||||
|
||||
CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=2048
|
||||
CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=3072
|
||||
CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY=y
|
||||
# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0 is not set
|
||||
# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU1 is not set
|
||||
@@ -798,6 +815,7 @@ CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS=5
|
||||
#
|
||||
# ICMP
|
||||
#
|
||||
CONFIG_LWIP_ICMP=y
|
||||
# CONFIG_LWIP_MULTICAST_PING is not set
|
||||
# CONFIG_LWIP_BROADCAST_PING is not set
|
||||
# end of ICMP
|
||||
@@ -849,11 +867,7 @@ CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=4096
|
||||
#
|
||||
# Certificate Bundle
|
||||
#
|
||||
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y
|
||||
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y
|
||||
# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set
|
||||
# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE is not set
|
||||
# CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE is not set
|
||||
# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE is not set
|
||||
# end of Certificate Bundle
|
||||
|
||||
# CONFIG_MBEDTLS_ECP_RESTARTABLE is not set
|
||||
@@ -897,6 +911,8 @@ CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y
|
||||
# CONFIG_MBEDTLS_SSL_PROTO_DTLS is not set
|
||||
CONFIG_MBEDTLS_SSL_ALPN=y
|
||||
CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=y
|
||||
CONFIG_MBEDTLS_X509_CHECK_KEY_USAGE=y
|
||||
CONFIG_MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE=y
|
||||
CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS=y
|
||||
|
||||
#
|
||||
@@ -912,6 +928,7 @@ CONFIG_MBEDTLS_RC4_DISABLED=y
|
||||
# CONFIG_MBEDTLS_XTEA_C is not set
|
||||
CONFIG_MBEDTLS_CCM_C=y
|
||||
CONFIG_MBEDTLS_GCM_C=y
|
||||
# CONFIG_MBEDTLS_NIST_KW_C is not set
|
||||
# end of Symmetric Ciphers
|
||||
|
||||
# CONFIG_MBEDTLS_RIPEMD160_C is not set
|
||||
@@ -955,7 +972,7 @@ CONFIG_MBEDTLS_ECP_NIST_OPTIM=y
|
||||
#
|
||||
CONFIG_MDNS_MAX_SERVICES=10
|
||||
CONFIG_MDNS_TASK_PRIORITY=1
|
||||
CONFIG_MDNS_TASK_STACK_SIZE=2048
|
||||
CONFIG_MDNS_TASK_STACK_SIZE=2304
|
||||
CONFIG_MDNS_TASK_AFFINITY_NO_AFFINITY=y
|
||||
# CONFIG_MDNS_TASK_AFFINITY_CPU0 is not set
|
||||
# CONFIG_MDNS_TASK_AFFINITY_CPU1 is not set
|
||||
@@ -1089,7 +1106,13 @@ CONFIG_SPIFFS_USE_MTIME=y
|
||||
#
|
||||
# TCP Transport
|
||||
#
|
||||
|
||||
#
|
||||
# Websocket
|
||||
#
|
||||
CONFIG_WS_TRANSPORT=y
|
||||
CONFIG_WS_BUFFER_SIZE=1024
|
||||
# end of Websocket
|
||||
# end of TCP Transport
|
||||
|
||||
#
|
||||
@@ -1136,7 +1159,7 @@ CONFIG_WPA_MBEDTLS_CRYPTO=y
|
||||
# CONFIG_WPA_WAPI_PSK is not set
|
||||
# CONFIG_WPA_DEBUG_PRINT is not set
|
||||
# CONFIG_WPA_TESTING_OPTIONS is not set
|
||||
# CONFIG_WPA_WPS_WARS is not set
|
||||
# CONFIG_WPA_WPS_STRICT is not set
|
||||
# CONFIG_WPA_11KV_SUPPORT is not set
|
||||
# end of Supplicant
|
||||
|
||||
@@ -1166,6 +1189,19 @@ CONFIG_WEBSOCKET_SERVER_TASK_STACK_DEPTH=3000
|
||||
CONFIG_WEBSOCKET_SERVER_TASK_PRIORITY=5
|
||||
# CONFIG_WEBSOCKET_SERVER_PINNED is not set
|
||||
# end of WebSocket Server
|
||||
|
||||
#
|
||||
# WiFi Logger configuration
|
||||
#
|
||||
CONFIG_TRANSPORT_PROTOCOL_UDP=y
|
||||
# CONFIG_TRANSPORT_PROTOCOL_TCP is not set
|
||||
# CONFIG_TRANSPORT_PROTOCOL_WEBSOCKET is not set
|
||||
CONFIG_ROUTE_ESP_IDF_API_LOGS_TO_WIFI=y
|
||||
CONFIG_SERVER_IP_ADDRESS="192.168.0.10"
|
||||
CONFIG_SERVER_PORT=9999
|
||||
CONFIG_MESSAGE_QUEUE_SIZE=1000
|
||||
CONFIG_BUFFER_SIZE=512
|
||||
# end of WiFi Logger configuration
|
||||
# end of Component config
|
||||
|
||||
#
|
||||
@@ -1296,21 +1332,21 @@ CONFIG_TIMER_QUEUE_LENGTH=5
|
||||
# CONFIG_USE_ONLY_LWIP_SELECT is not set
|
||||
CONFIG_ESP_GRATUITOUS_ARP=y
|
||||
CONFIG_GARP_TMR_INTERVAL=60
|
||||
CONFIG_TCPIP_RECVMBOX_SIZE=12
|
||||
CONFIG_TCPIP_RECVMBOX_SIZE=32
|
||||
CONFIG_TCP_MAXRTX=12
|
||||
CONFIG_TCP_SYNMAXRTX=12
|
||||
CONFIG_TCP_MSS=1460
|
||||
CONFIG_TCP_MSL=60000
|
||||
CONFIG_TCP_SND_BUF_DEFAULT=5840
|
||||
CONFIG_TCP_WND_DEFAULT=5840
|
||||
CONFIG_TCP_RECVMBOX_SIZE=12
|
||||
CONFIG_TCP_SND_BUF_DEFAULT=65534
|
||||
CONFIG_TCP_WND_DEFAULT=65534
|
||||
CONFIG_TCP_RECVMBOX_SIZE=6
|
||||
CONFIG_TCP_QUEUE_OOSEQ=y
|
||||
# CONFIG_ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES is not set
|
||||
CONFIG_TCP_OVERSIZE_MSS=y
|
||||
# CONFIG_TCP_OVERSIZE_QUARTER_MSS is not set
|
||||
# CONFIG_TCP_OVERSIZE_DISABLE is not set
|
||||
CONFIG_UDP_RECVMBOX_SIZE=6
|
||||
CONFIG_TCPIP_TASK_STACK_SIZE=2048
|
||||
CONFIG_TCPIP_TASK_STACK_SIZE=3072
|
||||
CONFIG_TCPIP_TASK_AFFINITY_NO_AFFINITY=y
|
||||
# CONFIG_TCPIP_TASK_AFFINITY_CPU0 is not set
|
||||
# CONFIG_TCPIP_TASK_AFFINITY_CPU1 is not set
|
||||
|
||||
108
sdkconfig.old
108
sdkconfig.old
@@ -152,11 +152,19 @@ CONFIG_SNTP_TIMEZONE="UTC"
|
||||
CONFIG_SNTP_SERVER="pool.ntp.org"
|
||||
# end of SNTP Configuration
|
||||
|
||||
#
|
||||
# Example Connection Configuration
|
||||
#
|
||||
# CONFIG_EXAMPLE_CONNECT_WIFI is not set
|
||||
# CONFIG_EXAMPLE_CONNECT_ETHERNET is not set
|
||||
# CONFIG_EXAMPLE_CONNECT_IPV6 is not set
|
||||
# end of Example Connection Configuration
|
||||
|
||||
#
|
||||
# Wifi Configuration
|
||||
#
|
||||
CONFIG_ENABLE_WIFI_PROVISIONING=y
|
||||
CONFIG_WIFI_MAXIMUM_RETRY=5
|
||||
CONFIG_WIFI_MAXIMUM_RETRY=0
|
||||
# end of Wifi Configuration
|
||||
|
||||
#
|
||||
@@ -244,6 +252,7 @@ CONFIG_BT_CTRL_SLEEP_MODE_EFF=0
|
||||
CONFIG_BT_CTRL_SLEEP_CLOCK_EFF=0
|
||||
CONFIG_BT_CTRL_HCI_TL_EFF=1
|
||||
CONFIG_BT_RESERVE_DRAM=0
|
||||
CONFIG_BT_NIMBLE_USE_ESP_TIMER=y
|
||||
# end of Bluetooth
|
||||
|
||||
#
|
||||
@@ -270,9 +279,9 @@ CONFIG_ADC_DISABLE_DAC=y
|
||||
# SPI configuration
|
||||
#
|
||||
# CONFIG_SPI_MASTER_IN_IRAM is not set
|
||||
CONFIG_SPI_MASTER_ISR_IN_IRAM=y
|
||||
# CONFIG_SPI_MASTER_ISR_IN_IRAM is not set
|
||||
# CONFIG_SPI_SLAVE_IN_IRAM is not set
|
||||
CONFIG_SPI_SLAVE_ISR_IN_IRAM=y
|
||||
# CONFIG_SPI_SLAVE_ISR_IN_IRAM is not set
|
||||
# end of SPI configuration
|
||||
|
||||
#
|
||||
@@ -375,6 +384,7 @@ CONFIG_ESP32_XTAL_FREQ=40
|
||||
# CONFIG_ESP32_DISABLE_BASIC_ROM_CONSOLE is not set
|
||||
# CONFIG_ESP32_NO_BLOBS is not set
|
||||
# CONFIG_ESP32_COMPATIBLE_PRE_V2_1_BOOTLOADERS is not set
|
||||
# CONFIG_ESP32_COMPATIBLE_PRE_V3_1_BOOTLOADERS is not set
|
||||
# CONFIG_ESP32_USE_FIXED_STATIC_RAM_SIZE is not set
|
||||
CONFIG_ESP32_DPORT_DIS_INTERRUPT_LVL=5
|
||||
# end of ESP32-specific
|
||||
@@ -525,28 +535,33 @@ CONFIG_ESP_TIMER_IMPL_TG0_LAC=y
|
||||
#
|
||||
# Wi-Fi
|
||||
#
|
||||
CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=6
|
||||
CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=24
|
||||
CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=25
|
||||
CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=128
|
||||
# CONFIG_ESP32_WIFI_STATIC_TX_BUFFER is not set
|
||||
CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER=y
|
||||
CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1
|
||||
CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=18
|
||||
CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=16
|
||||
# CONFIG_ESP32_WIFI_CSI_ENABLED is not set
|
||||
CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y
|
||||
CONFIG_ESP32_WIFI_TX_BA_WIN=12
|
||||
CONFIG_ESP32_WIFI_TX_BA_WIN=16
|
||||
CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y
|
||||
CONFIG_ESP32_WIFI_RX_BA_WIN=6
|
||||
CONFIG_ESP32_WIFI_RX_BA_WIN=25
|
||||
CONFIG_ESP32_WIFI_NVS_ENABLED=y
|
||||
CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0=y
|
||||
# CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1 is not set
|
||||
CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN=752
|
||||
CONFIG_ESP32_WIFI_MGMT_SBUF_NUM=32
|
||||
# CONFIG_ESP32_WIFI_DEBUG_LOG_ENABLE is not set
|
||||
CONFIG_ESP32_WIFI_IRAM_OPT=y
|
||||
CONFIG_ESP32_WIFI_RX_IRAM_OPT=y
|
||||
# CONFIG_WIFI_LOG_DEFAULT_LEVEL_NONE is not set
|
||||
# CONFIG_WIFI_LOG_DEFAULT_LEVEL_ERROR is not set
|
||||
# CONFIG_WIFI_LOG_DEFAULT_LEVEL_WARN is not set
|
||||
CONFIG_WIFI_LOG_DEFAULT_LEVEL_INFO=y
|
||||
# CONFIG_WIFI_LOG_DEFAULT_LEVEL_DEBUG is not set
|
||||
# CONFIG_WIFI_LOG_DEFAULT_LEVEL_VERBOSE is not set
|
||||
# CONFIG_ESP32_WIFI_IRAM_OPT is not set
|
||||
# CONFIG_ESP32_WIFI_RX_IRAM_OPT is not set
|
||||
CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE=y
|
||||
# CONFIG_ESP_WIFI_SLP_IRAM_OPT is not set
|
||||
CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE=y
|
||||
# CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE is not set
|
||||
# end of Wi-Fi
|
||||
|
||||
#
|
||||
@@ -662,7 +677,7 @@ CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0
|
||||
# CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS is not set
|
||||
CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y
|
||||
# CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set
|
||||
# CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH is not set
|
||||
CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y
|
||||
CONFIG_FREERTOS_DEBUG_OCDAWARE=y
|
||||
# CONFIG_FREERTOS_FPU_IN_ISR is not set
|
||||
# end of FreeRTOS
|
||||
@@ -702,8 +717,8 @@ CONFIG_LOG_DEFAULT_LEVEL_INFO=y
|
||||
# CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set
|
||||
CONFIG_LOG_DEFAULT_LEVEL=3
|
||||
CONFIG_LOG_COLORS=y
|
||||
CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y
|
||||
# CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM is not set
|
||||
# CONFIG_LOG_TIMESTAMP_SOURCE_RTOS is not set
|
||||
CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM=y
|
||||
# end of Log output
|
||||
|
||||
#
|
||||
@@ -718,7 +733,7 @@ CONFIG_LWIP_MAX_SOCKETS=6
|
||||
# CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set
|
||||
# CONFIG_LWIP_SO_LINGER is not set
|
||||
CONFIG_LWIP_SO_REUSE=y
|
||||
CONFIG_LWIP_SO_REUSE_RXTOALL=y
|
||||
# CONFIG_LWIP_SO_REUSE_RXTOALL is not set
|
||||
# CONFIG_LWIP_SO_RCVBUF is not set
|
||||
# CONFIG_LWIP_NETBUF_RECVINFO is not set
|
||||
CONFIG_LWIP_IP4_FRAG=y
|
||||
@@ -726,17 +741,19 @@ CONFIG_LWIP_IP6_FRAG=y
|
||||
# CONFIG_LWIP_IP4_REASSEMBLY is not set
|
||||
# CONFIG_LWIP_IP6_REASSEMBLY is not set
|
||||
# CONFIG_LWIP_IP_FORWARD is not set
|
||||
CONFIG_LWIP_STATS=y
|
||||
# CONFIG_LWIP_STATS is not set
|
||||
# CONFIG_LWIP_ETHARP_TRUST_IP_MAC is not set
|
||||
CONFIG_LWIP_ESP_GRATUITOUS_ARP=y
|
||||
CONFIG_LWIP_GARP_TMR_INTERVAL=60
|
||||
CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=12
|
||||
CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=64
|
||||
CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y
|
||||
# CONFIG_LWIP_DHCP_DISABLE_CLIENT_ID is not set
|
||||
# CONFIG_LWIP_DHCP_RESTORE_LAST_IP is not set
|
||||
|
||||
#
|
||||
# DHCP server
|
||||
#
|
||||
CONFIG_LWIP_DHCPS=y
|
||||
CONFIG_LWIP_DHCPS_LEASE_UNIT=60
|
||||
CONFIG_LWIP_DHCPS_MAX_STATION_NUM=8
|
||||
# end of DHCP server
|
||||
@@ -750,7 +767,7 @@ CONFIG_LWIP_LOOPBACK_MAX_PBUFS=8
|
||||
#
|
||||
# TCP
|
||||
#
|
||||
CONFIG_LWIP_MAX_ACTIVE_TCP=3
|
||||
CONFIG_LWIP_MAX_ACTIVE_TCP=6
|
||||
CONFIG_LWIP_MAX_LISTENING_TCP=3
|
||||
CONFIG_LWIP_TCP_HIGH_SPEED_RETRANSMISSION=y
|
||||
CONFIG_LWIP_TCP_MAXRTX=12
|
||||
@@ -758,11 +775,11 @@ CONFIG_LWIP_TCP_SYNMAXRTX=12
|
||||
CONFIG_LWIP_TCP_MSS=1460
|
||||
CONFIG_LWIP_TCP_TMR_INTERVAL=250
|
||||
CONFIG_LWIP_TCP_MSL=60000
|
||||
CONFIG_LWIP_TCP_SND_BUF_DEFAULT=5840
|
||||
CONFIG_LWIP_TCP_WND_DEFAULT=5840
|
||||
CONFIG_LWIP_TCP_RECVMBOX_SIZE=12
|
||||
CONFIG_LWIP_TCP_SND_BUF_DEFAULT=65534
|
||||
CONFIG_LWIP_TCP_WND_DEFAULT=65534
|
||||
CONFIG_LWIP_TCP_RECVMBOX_SIZE=64
|
||||
CONFIG_LWIP_TCP_QUEUE_OOSEQ=y
|
||||
# CONFIG_LWIP_TCP_SACK_OUT is not set
|
||||
CONFIG_LWIP_TCP_SACK_OUT=y
|
||||
# CONFIG_LWIP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES is not set
|
||||
CONFIG_LWIP_TCP_OVERSIZE_MSS=y
|
||||
# CONFIG_LWIP_TCP_OVERSIZE_QUARTER_MSS is not set
|
||||
@@ -785,7 +802,7 @@ CONFIG_LWIP_UDP_RECVMBOX_SIZE=6
|
||||
CONFIG_LWIP_CHECKSUM_CHECK_ICMP=y
|
||||
# end of Checksums
|
||||
|
||||
CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=2048
|
||||
CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=3072
|
||||
CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY=y
|
||||
# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0 is not set
|
||||
# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU1 is not set
|
||||
@@ -798,6 +815,7 @@ CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS=5
|
||||
#
|
||||
# ICMP
|
||||
#
|
||||
CONFIG_LWIP_ICMP=y
|
||||
# CONFIG_LWIP_MULTICAST_PING is not set
|
||||
# CONFIG_LWIP_BROADCAST_PING is not set
|
||||
# end of ICMP
|
||||
@@ -849,11 +867,7 @@ CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=4096
|
||||
#
|
||||
# Certificate Bundle
|
||||
#
|
||||
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y
|
||||
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y
|
||||
# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set
|
||||
# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE is not set
|
||||
# CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE is not set
|
||||
# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE is not set
|
||||
# end of Certificate Bundle
|
||||
|
||||
# CONFIG_MBEDTLS_ECP_RESTARTABLE is not set
|
||||
@@ -897,6 +911,8 @@ CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y
|
||||
# CONFIG_MBEDTLS_SSL_PROTO_DTLS is not set
|
||||
CONFIG_MBEDTLS_SSL_ALPN=y
|
||||
CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=y
|
||||
CONFIG_MBEDTLS_X509_CHECK_KEY_USAGE=y
|
||||
CONFIG_MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE=y
|
||||
CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS=y
|
||||
|
||||
#
|
||||
@@ -912,6 +928,7 @@ CONFIG_MBEDTLS_RC4_DISABLED=y
|
||||
# CONFIG_MBEDTLS_XTEA_C is not set
|
||||
CONFIG_MBEDTLS_CCM_C=y
|
||||
CONFIG_MBEDTLS_GCM_C=y
|
||||
# CONFIG_MBEDTLS_NIST_KW_C is not set
|
||||
# end of Symmetric Ciphers
|
||||
|
||||
# CONFIG_MBEDTLS_RIPEMD160_C is not set
|
||||
@@ -955,7 +972,7 @@ CONFIG_MBEDTLS_ECP_NIST_OPTIM=y
|
||||
#
|
||||
CONFIG_MDNS_MAX_SERVICES=10
|
||||
CONFIG_MDNS_TASK_PRIORITY=1
|
||||
CONFIG_MDNS_TASK_STACK_SIZE=2048
|
||||
CONFIG_MDNS_TASK_STACK_SIZE=2304
|
||||
CONFIG_MDNS_TASK_AFFINITY_NO_AFFINITY=y
|
||||
# CONFIG_MDNS_TASK_AFFINITY_CPU0 is not set
|
||||
# CONFIG_MDNS_TASK_AFFINITY_CPU1 is not set
|
||||
@@ -1089,7 +1106,13 @@ CONFIG_SPIFFS_USE_MTIME=y
|
||||
#
|
||||
# TCP Transport
|
||||
#
|
||||
|
||||
#
|
||||
# Websocket
|
||||
#
|
||||
CONFIG_WS_TRANSPORT=y
|
||||
CONFIG_WS_BUFFER_SIZE=1024
|
||||
# end of Websocket
|
||||
# end of TCP Transport
|
||||
|
||||
#
|
||||
@@ -1136,7 +1159,7 @@ CONFIG_WPA_MBEDTLS_CRYPTO=y
|
||||
# CONFIG_WPA_WAPI_PSK is not set
|
||||
# CONFIG_WPA_DEBUG_PRINT is not set
|
||||
# CONFIG_WPA_TESTING_OPTIONS is not set
|
||||
# CONFIG_WPA_WPS_WARS is not set
|
||||
# CONFIG_WPA_WPS_STRICT is not set
|
||||
# CONFIG_WPA_11KV_SUPPORT is not set
|
||||
# end of Supplicant
|
||||
|
||||
@@ -1166,6 +1189,19 @@ CONFIG_WEBSOCKET_SERVER_TASK_STACK_DEPTH=3000
|
||||
CONFIG_WEBSOCKET_SERVER_TASK_PRIORITY=5
|
||||
# CONFIG_WEBSOCKET_SERVER_PINNED is not set
|
||||
# end of WebSocket Server
|
||||
|
||||
#
|
||||
# WiFi Logger configuration
|
||||
#
|
||||
CONFIG_TRANSPORT_PROTOCOL_UDP=y
|
||||
# CONFIG_TRANSPORT_PROTOCOL_TCP is not set
|
||||
# CONFIG_TRANSPORT_PROTOCOL_WEBSOCKET is not set
|
||||
CONFIG_ROUTE_ESP_IDF_API_LOGS_TO_WIFI=y
|
||||
CONFIG_SERVER_IP_ADDRESS="192.168.0.10"
|
||||
CONFIG_SERVER_PORT=9999
|
||||
CONFIG_MESSAGE_QUEUE_SIZE=1000
|
||||
CONFIG_BUFFER_SIZE=512
|
||||
# end of WiFi Logger configuration
|
||||
# end of Component config
|
||||
|
||||
#
|
||||
@@ -1296,21 +1332,21 @@ CONFIG_TIMER_QUEUE_LENGTH=5
|
||||
# CONFIG_USE_ONLY_LWIP_SELECT is not set
|
||||
CONFIG_ESP_GRATUITOUS_ARP=y
|
||||
CONFIG_GARP_TMR_INTERVAL=60
|
||||
CONFIG_TCPIP_RECVMBOX_SIZE=12
|
||||
CONFIG_TCPIP_RECVMBOX_SIZE=64
|
||||
CONFIG_TCP_MAXRTX=12
|
||||
CONFIG_TCP_SYNMAXRTX=12
|
||||
CONFIG_TCP_MSS=1460
|
||||
CONFIG_TCP_MSL=60000
|
||||
CONFIG_TCP_SND_BUF_DEFAULT=5840
|
||||
CONFIG_TCP_WND_DEFAULT=5840
|
||||
CONFIG_TCP_RECVMBOX_SIZE=12
|
||||
CONFIG_TCP_SND_BUF_DEFAULT=65534
|
||||
CONFIG_TCP_WND_DEFAULT=65534
|
||||
CONFIG_TCP_RECVMBOX_SIZE=64
|
||||
CONFIG_TCP_QUEUE_OOSEQ=y
|
||||
# CONFIG_ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES is not set
|
||||
CONFIG_TCP_OVERSIZE_MSS=y
|
||||
# CONFIG_TCP_OVERSIZE_QUARTER_MSS is not set
|
||||
# CONFIG_TCP_OVERSIZE_DISABLE is not set
|
||||
CONFIG_UDP_RECVMBOX_SIZE=6
|
||||
CONFIG_TCPIP_TASK_STACK_SIZE=2048
|
||||
CONFIG_TCPIP_TASK_STACK_SIZE=3072
|
||||
CONFIG_TCPIP_TASK_AFFINITY_NO_AFFINITY=y
|
||||
# CONFIG_TCPIP_TASK_AFFINITY_CPU0 is not set
|
||||
# CONFIG_TCPIP_TASK_AFFINITY_CPU1 is not set
|
||||
|
||||
1330
sdkconfig_NO_SPI_RAM
1330
sdkconfig_NO_SPI_RAM
File diff suppressed because it is too large
Load Diff
1544
sdkconfig_SPI_RAM
1544
sdkconfig_SPI_RAM
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user