mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-10 21:47:04 +03:00
Additional messages added to messaging bus, increase dft size
This commit is contained in:
@@ -9,3 +9,4 @@
|
|||||||
|
|
||||||
COMPONENT_SRCDIRS := .
|
COMPONENT_SRCDIRS := .
|
||||||
COMPONENT_ADD_INCLUDEDIRS := .
|
COMPONENT_ADD_INCLUDEDIRS := .
|
||||||
|
CFLAGS += -D LOG_LOCAL_LEVEL=ESP_LOG_DEBUG
|
||||||
@@ -27,7 +27,7 @@ typedef struct {
|
|||||||
RingbufHandle_t buf_handle;
|
RingbufHandle_t buf_handle;
|
||||||
} messaging_list_t;
|
} messaging_list_t;
|
||||||
static messaging_list_t top;
|
static messaging_list_t top;
|
||||||
#define MSG_LENGTH_AVG 201
|
#define MSG_LENGTH_AVG 1024
|
||||||
|
|
||||||
messaging_list_t * get_struct_ptr(messaging_handle_t handle){
|
messaging_list_t * get_struct_ptr(messaging_handle_t handle){
|
||||||
return (messaging_list_t *)handle;
|
return (messaging_list_t *)handle;
|
||||||
@@ -176,21 +176,24 @@ esp_err_t messaging_post_to_queue(messaging_handle_t subscriber_handle, single_m
|
|||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
void * pItem=NULL;
|
void * pItem=NULL;
|
||||||
int passes=0;
|
|
||||||
UBaseType_t res=pdFALSE;
|
UBaseType_t res=pdFALSE;
|
||||||
while(passes++<3){
|
while(1){
|
||||||
res = xRingbufferSendAcquire(subscriber->buf_handle, &pItem, message_size, pdMS_TO_TICKS(100));
|
ESP_LOGD(tag,"Attempting to reserve %d bytes for %s",message_size, str_or_unknown(subscriber->subscriber_name));
|
||||||
|
res = xRingbufferSendAcquire(subscriber->buf_handle, &pItem, message_size, pdMS_TO_TICKS(50));
|
||||||
if(res == pdTRUE && pItem){
|
if(res == pdTRUE && pItem){
|
||||||
|
ESP_LOGD(tag,"Reserving complete for %s", str_or_unknown(subscriber->subscriber_name));
|
||||||
memcpy(pItem,message,message_size);
|
memcpy(pItem,message,message_size);
|
||||||
xRingbufferSendComplete(subscriber->buf_handle, pItem);
|
xRingbufferSendComplete(subscriber->buf_handle, pItem);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ESP_LOGD(tag,"messaged dropped for %s",str_or_unknown(subscriber->subscriber_name));
|
ESP_LOGD(tag,"Dropping for %s",str_or_unknown(subscriber->subscriber_name));
|
||||||
single_message_t * dummy = (single_message_t *)xRingbufferReceive(subscriber->buf_handle, &item_size, pdMS_TO_TICKS(50));
|
single_message_t * dummy = (single_message_t *)xRingbufferReceive(subscriber->buf_handle, &item_size, pdMS_TO_TICKS(50));
|
||||||
if (dummy== NULL) {
|
if (dummy== NULL) {
|
||||||
ESP_LOGE(tag,"receive from buffer failed");
|
ESP_LOGE(tag,"Dropping message failed");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
ESP_LOGD(tag,"Dropping message of %d bytes for %s",item_size, str_or_unknown(subscriber->subscriber_name));
|
||||||
vRingbufferReturnItem(subscriber->buf_handle, (void *)dummy);
|
vRingbufferReturnItem(subscriber->buf_handle, (void *)dummy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -216,7 +219,7 @@ void messaging_post_message(messaging_types type,messaging_classes msg_class, ch
|
|||||||
message->type = type;
|
message->type = type;
|
||||||
message->msg_class = msg_class;
|
message->msg_class = msg_class;
|
||||||
message->sent_time = esp_timer_get_time() / 1000;
|
message->sent_time = esp_timer_get_time() / 1000;
|
||||||
ESP_LOGI(tag,"Post: %s",message->message);
|
ESP_LOGD(tag,"Post: %s",message->message);
|
||||||
while(cur){
|
while(cur){
|
||||||
messaging_post_to_queue(get_handle_ptr(cur), message, msg_size);
|
messaging_post_to_queue(get_handle_ptr(cur), message, msg_size);
|
||||||
cur = get_struct_ptr(cur->next);
|
cur = get_struct_ptr(cur->next);
|
||||||
|
|||||||
@@ -46,13 +46,12 @@ bool spkfault_svc(void);
|
|||||||
/****************************************************************************************
|
/****************************************************************************************
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void task_stats( void ) {
|
static void task_stats( cJSON* top ) {
|
||||||
#ifdef CONFIG_FREERTOS_USE_TRACE_FACILITY
|
#ifdef CONFIG_FREERTOS_USE_TRACE_FACILITY
|
||||||
static struct {
|
static struct {
|
||||||
TaskStatus_t *tasks;
|
TaskStatus_t *tasks;
|
||||||
uint32_t total, n;
|
uint32_t total, n;
|
||||||
} current, previous;
|
} current, previous;
|
||||||
cJSON * top=cJSON_CreateObject();
|
|
||||||
cJSON * tlist=cJSON_CreateArray();
|
cJSON * tlist=cJSON_CreateArray();
|
||||||
current.n = uxTaskGetNumberOfTasks();
|
current.n = uxTaskGetNumberOfTasks();
|
||||||
current.tasks = malloc( current.n * sizeof( TaskStatus_t ) );
|
current.tasks = malloc( current.n * sizeof( TaskStatus_t ) );
|
||||||
@@ -80,11 +79,6 @@ static void task_stats( void ) {
|
|||||||
cJSON_AddNumberToObject(t,"st",current.tasks[i].eCurrentState);
|
cJSON_AddNumberToObject(t,"st",current.tasks[i].eCurrentState);
|
||||||
cJSON_AddNumberToObject(t,"num",current.tasks[i].xTaskNumber);
|
cJSON_AddNumberToObject(t,"num",current.tasks[i].xTaskNumber);
|
||||||
cJSON_AddItemToArray(tlist,t);
|
cJSON_AddItemToArray(tlist,t);
|
||||||
char * topsts = cJSON_PrintUnformatted(t);
|
|
||||||
if(topsts){
|
|
||||||
ESP_LOGI(TAG,"task detail: %s",topsts);
|
|
||||||
FREE_AND_NULL(topsts);
|
|
||||||
}
|
|
||||||
if (i % 3 == 2 || i == current.n - 1) {
|
if (i % 3 == 2 || i == current.n - 1) {
|
||||||
ESP_LOGI(TAG, "%s", scratch);
|
ESP_LOGI(TAG, "%s", scratch);
|
||||||
n = 0;
|
n = 0;
|
||||||
@@ -104,11 +98,6 @@ static void task_stats( void ) {
|
|||||||
cJSON_AddStringToObject(t,"st",current.tasks[i].eCurrentState);
|
cJSON_AddStringToObject(t,"st",current.tasks[i].eCurrentState);
|
||||||
cJSON_AddNumberToObject(t,"num",current.tasks[i].xTaskNumber);
|
cJSON_AddNumberToObject(t,"num",current.tasks[i].xTaskNumber);
|
||||||
cJSON_AddItemToArray(tlist,t);
|
cJSON_AddItemToArray(tlist,t);
|
||||||
char * topsts = cJSON_PrintUnformatted(t);
|
|
||||||
if(topsts){
|
|
||||||
ESP_LOGI(TAG,"task detail: %s",topsts);
|
|
||||||
FREE_AND_NULL(topsts);
|
|
||||||
}
|
|
||||||
if (i % 3 == 2 || i == current.n - 1) {
|
if (i % 3 == 2 || i == current.n - 1) {
|
||||||
ESP_LOGI(TAG, "%s", scratch);
|
ESP_LOGI(TAG, "%s", scratch);
|
||||||
n = 0;
|
n = 0;
|
||||||
@@ -116,12 +105,6 @@ static void task_stats( void ) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
cJSON_AddItemToObject(top,"tasks",tlist);
|
cJSON_AddItemToObject(top,"tasks",tlist);
|
||||||
char * top_a= cJSON_PrintUnformatted(top);
|
|
||||||
if(top_a){
|
|
||||||
messaging_post_message(MESSAGING_INFO, MESSAGING_CLASS_STATS,top_a);
|
|
||||||
FREE_AND_NULL(top_a);
|
|
||||||
}
|
|
||||||
cJSON_free(top);
|
|
||||||
if (previous.tasks) free(previous.tasks);
|
if (previous.tasks) free(previous.tasks);
|
||||||
previous = current;
|
previous = current;
|
||||||
#endif
|
#endif
|
||||||
@@ -131,13 +114,26 @@ static void task_stats( void ) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void monitor_callback(TimerHandle_t xTimer) {
|
static void monitor_callback(TimerHandle_t xTimer) {
|
||||||
|
cJSON * top=cJSON_CreateObject();
|
||||||
|
cJSON_AddNumberToObject(top,"free_iram",heap_caps_get_free_size(MALLOC_CAP_INTERNAL));
|
||||||
|
cJSON_AddNumberToObject(top,"min_free_iram",heap_caps_get_minimum_free_size(MALLOC_CAP_INTERNAL));
|
||||||
|
cJSON_AddNumberToObject(top,"free_spiram",heap_caps_get_free_size(MALLOC_CAP_SPIRAM));
|
||||||
|
cJSON_AddNumberToObject(top,"min_free_spiram",heap_caps_get_minimum_free_size(MALLOC_CAP_SPIRAM));
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Heap internal:%zu (min:%zu) external:%zu (min:%zu)",
|
ESP_LOGI(TAG, "Heap internal:%zu (min:%zu) external:%zu (min:%zu)",
|
||||||
heap_caps_get_free_size(MALLOC_CAP_INTERNAL),
|
heap_caps_get_free_size(MALLOC_CAP_INTERNAL),
|
||||||
heap_caps_get_minimum_free_size(MALLOC_CAP_INTERNAL),
|
heap_caps_get_minimum_free_size(MALLOC_CAP_INTERNAL),
|
||||||
heap_caps_get_free_size(MALLOC_CAP_SPIRAM),
|
heap_caps_get_free_size(MALLOC_CAP_SPIRAM),
|
||||||
heap_caps_get_minimum_free_size(MALLOC_CAP_SPIRAM));
|
heap_caps_get_minimum_free_size(MALLOC_CAP_SPIRAM));
|
||||||
|
|
||||||
task_stats();
|
task_stats(top);
|
||||||
|
char * top_a= cJSON_PrintUnformatted(top);
|
||||||
|
if(top_a){
|
||||||
|
messaging_post_message(MESSAGING_INFO, MESSAGING_CLASS_STATS,top_a);
|
||||||
|
FREE_AND_NULL(top_a);
|
||||||
|
}
|
||||||
|
cJSON_free(top);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************************
|
/****************************************************************************************
|
||||||
@@ -145,6 +141,7 @@ static void monitor_callback(TimerHandle_t xTimer) {
|
|||||||
*/
|
*/
|
||||||
static void jack_handler_default(void *id, button_event_e event, button_press_e mode, bool long_press) {
|
static void jack_handler_default(void *id, button_event_e event, button_press_e mode, bool long_press) {
|
||||||
ESP_LOGD(TAG, "Jack %s", event == BUTTON_PRESSED ? "inserted" : "removed");
|
ESP_LOGD(TAG, "Jack %s", event == BUTTON_PRESSED ? "inserted" : "removed");
|
||||||
|
messaging_post_message(MESSAGING_INFO, MESSAGING_CLASS_SYSTEM,"jack is %s",BUTTON_PRESSED ? "inserted" : "removed");
|
||||||
if (jack_handler_svc) (*jack_handler_svc)(event == BUTTON_PRESSED);
|
if (jack_handler_svc) (*jack_handler_svc)(event == BUTTON_PRESSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,8 +38,10 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "nvs_utilities.h"
|
#include "nvs_utilities.h"
|
||||||
#include "platform_esp32.h"
|
#include "platform_esp32.h"
|
||||||
|
#include "messaging.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
|
|
||||||
|
|
||||||
/************************************
|
/************************************
|
||||||
* Globals
|
* Globals
|
||||||
*/
|
*/
|
||||||
@@ -119,6 +121,8 @@ void init_telnet(){
|
|||||||
buf_handle = xRingbufferCreateStatic(log_buf_size, RINGBUF_TYPE_BYTEBUF, buffer_storage, buffer_struct);
|
buf_handle = xRingbufferCreateStatic(log_buf_size, RINGBUF_TYPE_BYTEBUF, buffer_storage, buffer_struct);
|
||||||
if (buf_handle == NULL) {
|
if (buf_handle == NULL) {
|
||||||
ESP_LOGE(TAG,"Failed to create ring buffer for telnet!");
|
ESP_LOGE(TAG,"Failed to create ring buffer for telnet!");
|
||||||
|
messaging_post_message(MESSAGING_ERROR,MESSAGING_CLASS_SYSTEM,"Failed to allocate memory for telnet buffer");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -683,8 +683,9 @@ function getMessages() {
|
|||||||
var stats_data = JSON.parse(msg["message"]);
|
var stats_data = JSON.parse(msg["message"]);
|
||||||
console.log(msg_time + " - Number of tasks on the ESP32: " + stats_data["ntasks"]);
|
console.log(msg_time + " - Number of tasks on the ESP32: " + stats_data["ntasks"]);
|
||||||
var stats_tasks = stats_data["tasks"];
|
var stats_tasks = stats_data["tasks"];
|
||||||
|
console.log(msg_time + '\tname' + '\tcpu' + '\tstate'+ '\tminstk'+ '\tbprio'+ '\tcprio'+ '\tnum' );
|
||||||
stats_tasks.forEach(function(task) {
|
stats_tasks.forEach(function(task) {
|
||||||
console.log(msg_time + " - " + task["nme"] + ' - '+ task["cpu"]);
|
console.log(msg_time + '\t' + task["nme"] + '\t'+ task["cpu"] + '\t'+ task_state_t[task["st"]]+ '\t'+ task["minstk"]+ '\t'+ task["bprio"]+ '\t'+ task["cprio"]+ '\t'+ task["num"]);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "MESSAGING_CLASS_SYSTEM":
|
case "MESSAGING_CLASS_SYSTEM":
|
||||||
|
|||||||
@@ -361,6 +361,7 @@ esp_err_t wifi_manager_save_sta_config(){
|
|||||||
esp_err = nvs_commit(handle);
|
esp_err = nvs_commit(handle);
|
||||||
if (esp_err != ESP_OK) {
|
if (esp_err != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "Unable to commit changes. Error %s", esp_err_to_name(esp_err));
|
ESP_LOGE(TAG, "Unable to commit changes. Error %s", esp_err_to_name(esp_err));
|
||||||
|
messaging_post_message(MESSAGING_ERROR,MESSAGING_CLASS_SYSTEM,"Unable to save wifi credentials. %s",esp_err_to_name(esp_err));
|
||||||
return esp_err;
|
return esp_err;
|
||||||
}
|
}
|
||||||
nvs_close(handle);
|
nvs_close(handle);
|
||||||
@@ -1335,6 +1336,8 @@ void wifi_manager( void * pvParameters ){
|
|||||||
else{
|
else{
|
||||||
/* lost connection ? */
|
/* lost connection ? */
|
||||||
ESP_LOGE(TAG, "WiFi Connection lost.");
|
ESP_LOGE(TAG, "WiFi Connection lost.");
|
||||||
|
messaging_post_message(MESSAGING_WARNING,MESSAGING_CLASS_SYSTEM,"WiFi Connection lost");
|
||||||
|
|
||||||
if(wifi_manager_lock_json_buffer( portMAX_DELAY )){
|
if(wifi_manager_lock_json_buffer( portMAX_DELAY )){
|
||||||
wifi_manager_generate_ip_info_json( UPDATE_LOST_CONNECTION );
|
wifi_manager_generate_ip_info_json( UPDATE_LOST_CONNECTION );
|
||||||
wifi_manager_unlock_json_buffer();
|
wifi_manager_unlock_json_buffer();
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "esp_pthread.h"
|
#include "esp_pthread.h"
|
||||||
#ifndef SQUEEZELITE_ESP32_RELEASE_URL
|
#ifndef SQUEEZELITE_ESP32_RELEASE_URL
|
||||||
#define SQUEEZELITE_ESP32_RELEASE_URL "https://github.com/sle118/squeezelite-esp32/releases"
|
#define SQUEEZELITE_ESP32_RELEASE_URL "https://github.com/sle118/squeezelite-esp32/releases"
|
||||||
|
|||||||
Reference in New Issue
Block a user