forked from gronod/squeezelite-esp32
chore: checkpoint current IDF 5.5 remediation state
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "esp_rom_gpio.h"
|
||||
#include <esp_log.h>
|
||||
|
||||
#include "gds.h"
|
||||
@@ -160,7 +161,7 @@ static bool Init( struct GDS_Device* Device ) {
|
||||
NullCheck( Device->Framebuffer, return false );
|
||||
|
||||
if (Private->ReadyPin >= 0) {
|
||||
gpio_pad_select_gpio( Private->ReadyPin );
|
||||
esp_rom_gpio_pad_select_gpio( Private->ReadyPin );
|
||||
gpio_set_pull_mode( Private->ReadyPin, GPIO_PULLUP_ONLY);
|
||||
gpio_set_direction( Private->ReadyPin, GPIO_MODE_INPUT );
|
||||
}
|
||||
@@ -251,4 +252,4 @@ struct GDS_Device* SSD1675_Detect(sys_display_config* Driver, struct GDS_Device*
|
||||
ESP_LOGI(TAG, "SSD1675 driver with ready GPIO %d", Private->ReadyPin);
|
||||
|
||||
return Device;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ void GDS_FontDrawString( struct GDS_Device* Display, int x, int y, const char* T
|
||||
void GDS_FontDrawAnchoredString( struct GDS_Device* Display, TextAnchor Anchor, const char* Text, int Color );
|
||||
void GDS_FontGetAnchoredStringCoords( struct GDS_Device* Display, int* OutX, int* OutY, TextAnchor Anchor, const char* Text );
|
||||
|
||||
struct GDS_FontDef * Font_droid_sans_fallback_11x13;
|
||||
extern struct GDS_FontDef * Font_droid_sans_fallback_11x13;
|
||||
// const struct GDS_FontDef * Font_droid_sans_fallback_15x17;
|
||||
// const struct GDS_FontDef * Font_droid_sans_fallback_24x28;
|
||||
|
||||
@@ -86,8 +86,8 @@ struct GDS_FontDef * Font_droid_sans_fallback_11x13;
|
||||
// const struct GDS_FontDef * Font_Tarable7Seg_16x32;
|
||||
// const struct GDS_FontDef * Font_Tarable7Seg_32x64;
|
||||
|
||||
struct GDS_FontDef * Font_line_1;
|
||||
struct GDS_FontDef * Font_line_2;
|
||||
extern struct GDS_FontDef * Font_line_1;
|
||||
extern struct GDS_FontDef * Font_line_2;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ static void displayer_task(void *args);
|
||||
static void display_sleep(void);
|
||||
|
||||
struct GDS_Device *display;
|
||||
bool (*display_bus)(void *from, enum display_bus_cmd_e cmd) = NULL;
|
||||
extern GDS_DetectFunc SSD1306_Detect, SSD132x_Detect, SH1106_Detect, SSD1675_Detect, SSD1322_Detect, SSD1351_Detect, ST77xx_Detect, ILI9341_Detect;
|
||||
GDS_DetectFunc *drivers[] = { SH1106_Detect, SSD1306_Detect, SSD132x_Detect, SSD1675_Detect, SSD1322_Detect, SSD1351_Detect, ST77xx_Detect, ILI9341_Detect, NULL };
|
||||
|
||||
@@ -245,8 +246,9 @@ static void displayer_task(void *args) {
|
||||
// when we have duration but no space, display remaining time
|
||||
if (displayer.duration.value && !displayer.duration.visible) elapsed = displayer.duration.value - elapsed;
|
||||
|
||||
if (elapsed < 3600) sprintf(_line, "%u:%02u", elapsed / 60, elapsed % 60);
|
||||
else sprintf(_line, "%u:%02u:%02u", (elapsed / 3600) % 100, (elapsed % 3600) / 60, elapsed % 60);
|
||||
if (elapsed < 3600) sprintf(_line, "%lu:%02lu", (unsigned long) (elapsed / 60), (unsigned long) (elapsed % 60));
|
||||
else sprintf(_line, "%lu:%02lu:%02lu", (unsigned long) ((elapsed / 3600) % 100),
|
||||
(unsigned long) ((elapsed % 3600) / 60), (unsigned long) (elapsed % 60));
|
||||
|
||||
// concatenate if we have room for elapsed / duration
|
||||
if (displayer.duration.visible) {
|
||||
@@ -408,9 +410,12 @@ void displayer_timer(enum displayer_time_e mode, int elapsed, int duration) {
|
||||
displayer.duration.visible = true;
|
||||
displayer.duration.value = duration / 1000;
|
||||
|
||||
if (displayer.duration.value > 3600) sprintf(displayer.duration.string, "%u:%02u:%02u", (displayer.duration.value / 3600) % 10,
|
||||
(displayer.duration.value % 3600) / 60, displayer.duration.value % 60);
|
||||
else sprintf(displayer.duration.string, "%u:%02u", displayer.duration.value / 60, displayer.duration.value % 60);
|
||||
if (displayer.duration.value > 3600) sprintf(displayer.duration.string, "%lu:%02lu:%02lu",
|
||||
(unsigned long) ((displayer.duration.value / 3600) % 10),
|
||||
(unsigned long) ((displayer.duration.value % 3600) / 60),
|
||||
(unsigned long) (displayer.duration.value % 60));
|
||||
else sprintf(displayer.duration.string, "%lu:%02lu", (unsigned long) (displayer.duration.value / 60),
|
||||
(unsigned long) (displayer.duration.value % 60));
|
||||
|
||||
char *buf;
|
||||
asprintf(&buf, "%s %s/%s", displayer.header, displayer.duration.string, displayer.duration.string);
|
||||
|
||||
@@ -31,7 +31,7 @@ enum displayer_cmd_e { DISPLAYER_SHUTDOWN, DISPLAYER_ACTIVATE, DISPLAYER_SUSPEN
|
||||
enum displayer_time_e { DISPLAYER_ELAPSED, DISPLAYER_REMAINING };
|
||||
|
||||
enum display_bus_cmd_e { DISPLAY_BUS_TAKE, DISPLAY_BUS_GIVE };
|
||||
bool (*display_bus)(void *from, enum display_bus_cmd_e cmd);
|
||||
extern bool (*display_bus)(void *from, enum display_bus_cmd_e cmd);
|
||||
|
||||
void displayer_scroll(char *string, int speed, int pause);
|
||||
void displayer_control(enum displayer_cmd_e cmd, ...);
|
||||
|
||||
@@ -60,7 +60,7 @@ static bool bt_app_send_msg(bt_app_msg_t *msg)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (xQueueSend(s_bt_app_task_queue, msg, 10 / portTICK_RATE_MS) != pdTRUE) {
|
||||
if (xQueueSend(s_bt_app_task_queue, msg, 10 / portTICK_PERIOD_MS) != pdTRUE) {
|
||||
ESP_LOGE(TAG,"%s xQueue send failed", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ static void bt_app_task_handler(void* arg);
|
||||
static bool bt_app_send_msg(bt_app_msg_t* msg);
|
||||
static void bt_app_work_dispatched(bt_app_msg_t* msg);
|
||||
|
||||
static xQueueHandle s_bt_app_task_queue;
|
||||
static QueueHandle_t s_bt_app_task_queue;
|
||||
static bool running;
|
||||
|
||||
bool bt_app_work_dispatch(bt_app_cb_t p_cback, uint16_t event, void* p_params, int param_len,
|
||||
@@ -59,7 +59,7 @@ static bool bt_app_send_msg(bt_app_msg_t* msg) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (xQueueSend(s_bt_app_task_queue, msg, 10 / portTICK_RATE_MS) != pdTRUE) {
|
||||
if (xQueueSend(s_bt_app_task_queue, msg, 10 / portTICK_PERIOD_MS) != pdTRUE) {
|
||||
ESP_LOGE(TAG, "%s xQueue send failed", __func__);
|
||||
return false;
|
||||
}
|
||||
@@ -122,7 +122,7 @@ static void bt_app_task_handler(void* arg) {
|
||||
running = true;
|
||||
|
||||
while (running) {
|
||||
if (pdTRUE == xQueueReceive(s_bt_app_task_queue, &msg, (portTickType)portMAX_DELAY)) {
|
||||
if (pdTRUE == xQueueReceive(s_bt_app_task_queue, &msg, portMAX_DELAY)) {
|
||||
ESP_LOGV(TAG, "%s, sig 0x%x, 0x%x", __func__, msg.sig, msg.event);
|
||||
|
||||
switch (msg.sig) {
|
||||
|
||||
@@ -745,7 +745,7 @@ static void bt_av_hdl_stack_evt(uint16_t event, void *p_param)
|
||||
|
||||
/* create and start heart beat timer */
|
||||
int tmr_id = 0;
|
||||
s_tmr = xTimerCreate("connTmr", ( prev_duration/ portTICK_RATE_MS),pdFALSE, (void *)tmr_id, a2d_app_heart_beat);
|
||||
s_tmr = xTimerCreate("connTmr", ( prev_duration/ portTICK_PERIOD_MS),pdFALSE, (void *)tmr_id, a2d_app_heart_beat);
|
||||
xTimerStart(s_tmr, portMAX_DELAY);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ static void bt_app_rc_ct_cb(esp_avrc_ct_cb_event_t event, esp_avrc_ct_cb_param_t
|
||||
static void bt_av_hdl_avrc_ct_evt(uint16_t event, void *p_param);
|
||||
|
||||
/// callback function for A2DP source audio data stream
|
||||
static void a2d_app_heart_beat(void *arg);
|
||||
static void a2d_app_heart_beat(TimerHandle_t timer);
|
||||
|
||||
/// A2DP application state machine
|
||||
static void bt_app_av_sm_hdlr(uint16_t event, void *param);
|
||||
@@ -365,12 +365,13 @@ int heart_beat_delay[] = {
|
||||
1000
|
||||
};
|
||||
|
||||
static void a2d_app_heart_beat(void *arg)
|
||||
static void a2d_app_heart_beat(TimerHandle_t timer)
|
||||
{
|
||||
(void)timer;
|
||||
bt_app_work_dispatch(bt_app_av_sm_hdlr, BT_APP_HEART_BEAT_EVT, NULL, 0, NULL);
|
||||
int tmrduration=heart_beat_delay[bt_app_source_a2d_state];
|
||||
if(prev_duration!=tmrduration){
|
||||
xTimerChangePeriod(s_tmr,tmrduration, portMAX_DELAY);
|
||||
xTimerChangePeriod(s_tmr, pdMS_TO_TICKS(tmrduration), portMAX_DELAY);
|
||||
ESP_LOGD(TAG,"New heartbeat is %u",tmrduration);
|
||||
prev_duration=tmrduration;
|
||||
}
|
||||
@@ -704,7 +705,7 @@ static void bt_av_hdl_stack_evt(uint16_t event, void *p_param)
|
||||
|
||||
/* create and start heart beat timer */
|
||||
int tmr_id = 0;
|
||||
s_tmr = xTimerCreate("connTmr", ( prev_duration/ portTICK_RATE_MS),pdFALSE, (void *)tmr_id, a2d_app_heart_beat);
|
||||
s_tmr = xTimerCreate("connTmr", pdMS_TO_TICKS(prev_duration), pdFALSE, (void *)tmr_id, a2d_app_heart_beat);
|
||||
xTimerStart(s_tmr, portMAX_DELAY);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@ idf_build_get_property(prefix IDF_PATH)
|
||||
string(CONCAT prefix "${prefix}" "/components/esp_http_server")
|
||||
|
||||
idf_component_register(
|
||||
SRC_DIRS "${prefix}/src" "${prefix}/src/util"
|
||||
INCLUDE_DIRS "${prefix}/include"
|
||||
PRIV_INCLUDE_DIRS "." "${prefix}/src/port/esp32" "${prefix}/src/util"
|
||||
REQUIRES nghttp # for http_parser.h
|
||||
PRIV_REQUIRES lwip mbedtls esp_timer
|
||||
SRC_DIRS "${prefix}/src" "${prefix}/src/util"
|
||||
INCLUDE_DIRS "${prefix}/include"
|
||||
PRIV_INCLUDE_DIRS "." "${prefix}/src/port/esp32" "${prefix}/src/util"
|
||||
REQUIRES http_parser esp_event
|
||||
PRIV_REQUIRES lwip mbedtls esp_timer
|
||||
)
|
||||
|
||||
@@ -33,13 +33,10 @@ typedef TaskHandle_t othread_t;
|
||||
static inline int httpd_os_thread_create(othread_t *thread,
|
||||
const char *name, uint16_t stacksize, int prio,
|
||||
void (*thread_routine)(void *arg), void *arg,
|
||||
BaseType_t core_id)
|
||||
BaseType_t core_id, uint32_t caps)
|
||||
{
|
||||
StaticTask_t *xTaskBuffer = (StaticTask_t*) heap_caps_malloc(sizeof(StaticTask_t), (MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT));
|
||||
StackType_t *xStack = heap_caps_malloc(stacksize,(MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT));
|
||||
|
||||
*thread = xTaskCreateStaticPinnedToCore(thread_routine, name, stacksize, arg, prio, xStack,xTaskBuffer,core_id);
|
||||
if (*thread) {
|
||||
int ret = xTaskCreatePinnedToCoreWithCaps(thread_routine, name, stacksize, arg, prio, thread, core_id, caps);
|
||||
if (ret == pdPASS) {
|
||||
return OS_SUCCESS;
|
||||
}
|
||||
return OS_FAIL;
|
||||
@@ -48,12 +45,12 @@ static inline int httpd_os_thread_create(othread_t *thread,
|
||||
/* Only self delete is supported */
|
||||
static inline void httpd_os_thread_delete(void)
|
||||
{
|
||||
vTaskDelete(xTaskGetCurrentTaskHandle());
|
||||
vTaskDeleteWithCaps(xTaskGetCurrentTaskHandle());
|
||||
}
|
||||
|
||||
static inline void httpd_os_thread_sleep(int msecs)
|
||||
{
|
||||
vTaskDelay(msecs / portTICK_RATE_MS);
|
||||
vTaskDelay(msecs / portTICK_PERIOD_MS);
|
||||
}
|
||||
|
||||
static inline othread_t httpd_os_thread_handle(void)
|
||||
|
||||
@@ -12,7 +12,7 @@ class Batch {
|
||||
private:
|
||||
std::list<Event> _events;
|
||||
bool _warned = false;
|
||||
std::string _metrics_uid = nullptr;
|
||||
std::string _metrics_uid;
|
||||
const char* _api_key = nullptr;
|
||||
const char* _url = nullptr;
|
||||
void build_guid();
|
||||
@@ -43,4 +43,4 @@ class Batch {
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
idf_component_register(SRC_DIRS .
|
||||
INCLUDE_DIRS .
|
||||
REQUIRES json tools platform_config wifi-manager esp-tls
|
||||
PRIV_REQUIRES esp32 freertos
|
||||
)
|
||||
REQUIRES json tools platform_config wifi-manager esp-tls esp_wifi
|
||||
PRIV_REQUIRES freertos
|
||||
)
|
||||
|
||||
@@ -719,7 +719,7 @@ void WifiList::PrintWifiSTAEntry(const sys_net_wifi_entry& entry) {
|
||||
printf("%-20s", entry.ssid);
|
||||
PrintString(entry.password, sizeof(entry.password), "%-25s");
|
||||
PrintString(entry.bssid, sizeof(entry.bssid), "%-20s");
|
||||
printf("%-4ddB", entry.rssi);
|
||||
printf("%-4lddB", static_cast<long>(entry.rssi));
|
||||
printf("%3u ", static_cast<unsigned>(entry.channel));
|
||||
printf("%-14s", sys_net_auth_types_name(entry.auth_type));
|
||||
printf("%-9s", formatRadioTypes(entry.radio_type, entry.radio_type_count).c_str());
|
||||
@@ -838,8 +838,20 @@ sys_net_auth_types WifiList::GetAuthType(const wifi_auth_mode_t mode) {
|
||||
return sys_net_auth_types_WPA2_WPA3_PSK;
|
||||
case WIFI_AUTH_WAPI_PSK:
|
||||
return sys_net_auth_types_WAPI_PSK;
|
||||
case WIFI_AUTH_MAX:
|
||||
case WIFI_AUTH_OWE:
|
||||
return sys_net_auth_types_OPEN;
|
||||
case WIFI_AUTH_WPA3_ENT_192:
|
||||
case WIFI_AUTH_WPA3_ENTERPRISE:
|
||||
case WIFI_AUTH_WPA2_WPA3_ENTERPRISE:
|
||||
case WIFI_AUTH_WPA_ENTERPRISE:
|
||||
return sys_net_auth_types_WPA2_ENTERPRISE;
|
||||
case WIFI_AUTH_WPA3_EXT_PSK:
|
||||
case WIFI_AUTH_WPA3_EXT_PSK_MIXED_MODE:
|
||||
return sys_net_auth_types_WPA3_PSK;
|
||||
case WIFI_AUTH_DPP:
|
||||
return sys_net_auth_types_AUTH_UNKNOWN;
|
||||
case WIFI_AUTH_MAX:
|
||||
return sys_net_auth_types_AUTH_UNKNOWN;
|
||||
}
|
||||
return sys_net_auth_types_AUTH_UNKNOWN;
|
||||
}
|
||||
|
||||
@@ -3,14 +3,13 @@ idf_component_register( SRCS
|
||||
cmd_ota.c
|
||||
cmd_system.c
|
||||
cmd_wifi.c
|
||||
platform_console.c
|
||||
platform_console.c
|
||||
cmd_config.c
|
||||
INCLUDE_DIRS .
|
||||
REQUIRES nvs_flash
|
||||
REQUIRES nvs_flash driver esp_wifi
|
||||
PRIV_REQUIRES console app_update tools services spi_flash tools platform_config vfs pthread wifi-manager newlib telnet display squeezelite metrics)
|
||||
|
||||
set_source_files_properties(cmd_config.c
|
||||
PROPERTIES COMPILE_FLAGS
|
||||
-Wno-unused-function
|
||||
)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
idf_component_register( SRC_DIRS .
|
||||
INCLUDE_DIRS .
|
||||
PRIV_REQUIRES bootloader_support json
|
||||
PRIV_REQUIRES bootloader_support esp_app_format json
|
||||
)
|
||||
|
||||
target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl,--undefined=esp_app_desc")
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "application_name.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_app_format.h"
|
||||
#include "esp_app_desc.h"
|
||||
#include "cJSON.h"
|
||||
#include "stdbool.h"
|
||||
extern esp_err_t process_recovery_ota(const char * bin_url, char * bin_buffer, uint32_t length);
|
||||
|
||||
@@ -120,7 +120,7 @@ bool is_i2c_started(i2c_port_t port) {
|
||||
ret = i2c_master_stop(cmd);
|
||||
}
|
||||
if (ret == ESP_OK) {
|
||||
ret = i2c_master_cmd_begin(port, cmd, 50 / portTICK_RATE_MS);
|
||||
ret = i2c_master_cmd_begin(port, cmd, 50 / portTICK_PERIOD_MS);
|
||||
}
|
||||
i2c_cmd_link_delete(cmd);
|
||||
ESP_LOGD(TAG, "i2c is %s. %s", ret != ESP_ERR_INVALID_STATE ? "started" : "not started",
|
||||
@@ -658,7 +658,7 @@ static int do_i2cdump_cmd(int argc, char** argv) {
|
||||
}
|
||||
i2c_master_read_byte(cmd, data + size - 1, NACK_VAL);
|
||||
i2c_master_stop(cmd);
|
||||
esp_err_t ret = i2c_master_cmd_begin(loc_i2c_port, cmd, 50 / portTICK_RATE_MS);
|
||||
esp_err_t ret = i2c_master_cmd_begin(loc_i2c_port, cmd, 50 / portTICK_PERIOD_MS);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
if (ret == ESP_OK) {
|
||||
for (int k = 0; k < size; k++) {
|
||||
@@ -729,7 +729,7 @@ static int do_i2cset_cmd(int argc, char** argv) {
|
||||
i2c_master_write_byte(cmd, i2cset_args.data->ival[i], ACK_CHECK_EN);
|
||||
}
|
||||
i2c_master_stop(cmd);
|
||||
esp_err_t ret = i2c_master_cmd_begin(loc_i2c_port, cmd, 1000 / portTICK_RATE_MS);
|
||||
esp_err_t ret = i2c_master_cmd_begin(loc_i2c_port, cmd, 1000 / portTICK_PERIOD_MS);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
if (ret == ESP_OK) {
|
||||
cmd_send_messaging(argv[0], MESSAGING_INFO, "i2c Write OK\n");
|
||||
@@ -786,7 +786,7 @@ static int do_i2cget_cmd(int argc, char** argv) {
|
||||
}
|
||||
i2c_master_read_byte(cmd, data + len - 1, NACK_VAL);
|
||||
i2c_master_stop(cmd);
|
||||
esp_err_t ret = i2c_master_cmd_begin(loc_i2c_port, cmd, 1000 / portTICK_RATE_MS);
|
||||
esp_err_t ret = i2c_master_cmd_begin(loc_i2c_port, cmd, 1000 / portTICK_PERIOD_MS);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
if (ret == ESP_OK) {
|
||||
for (int i = 0; i < len; i++) {
|
||||
@@ -861,7 +861,7 @@ esp_err_t cmd_i2ctools_scan_bus(FILE* f, int sda, int scl) {
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, (i << 1) | WRITE_BIT, ACK_CHECK_EN);
|
||||
i2c_master_stop(cmd);
|
||||
ret = i2c_master_cmd_begin(i2c_port, cmd, 50 / portTICK_RATE_MS);
|
||||
ret = i2c_master_cmd_begin(i2c_port, cmd, 50 / portTICK_PERIOD_MS);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
if (ret == ESP_OK) {
|
||||
#ifndef CONFIG_WITH_CONFIG_UI
|
||||
@@ -931,7 +931,7 @@ static int do_i2cdetect_cmd(int argc, char** argv) {
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, (address << 1) | WRITE_BIT, ACK_CHECK_EN);
|
||||
i2c_master_stop(cmd);
|
||||
ret = i2c_master_cmd_begin(loc_i2c_port, cmd, 50 / portTICK_RATE_MS);
|
||||
ret = i2c_master_cmd_begin(loc_i2c_port, cmd, 50 / portTICK_PERIOD_MS);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
if (ret == ESP_OK) {
|
||||
fprintf(f, "%02x ", address);
|
||||
|
||||
@@ -14,11 +14,13 @@
|
||||
#include "driver/rtc_io.h"
|
||||
#include "driver/uart.h"
|
||||
#include "esp_console.h"
|
||||
#include "esp_chip_info.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_ota_ops.h"
|
||||
#include "esp_partition.h"
|
||||
#include "esp_rom_uart.h"
|
||||
#include "esp_sleep.h"
|
||||
#include "esp_flash.h"
|
||||
#include "esp_spi_flash.h"
|
||||
#include "esp_system.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
@@ -121,7 +123,9 @@ FILE* system_open_memstream(const char* cmdname, char** buf, size_t* buf_size) {
|
||||
/* 'version' command */
|
||||
static int get_version(int argc, char** argv) {
|
||||
esp_chip_info_t info;
|
||||
uint32_t flash_size = 0;
|
||||
esp_chip_info(&info);
|
||||
esp_flash_get_size(NULL, &flash_size);
|
||||
cmd_send_messaging(argv[0], MESSAGING_INFO,
|
||||
"IDF Version:%s\r\n"
|
||||
"Chip info:\r\n"
|
||||
@@ -134,7 +138,7 @@ static int get_version(int argc, char** argv) {
|
||||
info.features & CHIP_FEATURE_BLE ? "/BLE" : "",
|
||||
info.features & CHIP_FEATURE_BT ? "/BT" : "",
|
||||
info.features & CHIP_FEATURE_EMB_FLASH ? "/Embedded-Flash:" : "/External-Flash:",
|
||||
spi_flash_get_chip_size() / (1024 * 1024), " MB", info.revision);
|
||||
flash_size / (1024 * 1024), " MB", info.revision);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -989,4 +993,4 @@ void register_system() {
|
||||
register_deep_sleep();
|
||||
register_light_sleep();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,8 +87,9 @@ static void initialise_wifi(void)
|
||||
led_blink(LED_GREEN, 250, 250);
|
||||
}
|
||||
|
||||
static void wifi_join(void *arg)
|
||||
static void wifi_join(TimerHandle_t timer)
|
||||
{
|
||||
(void)timer;
|
||||
const char *ssid = join_args.ssid->sval[0];
|
||||
const char *pass = join_args.password->sval[0];
|
||||
int timeout_ms = join_args.timeout->ival[0];
|
||||
|
||||
+44
-13
@@ -22,6 +22,7 @@
|
||||
#include "mdnssd-itf.h"
|
||||
#else
|
||||
#include "esp_pthread.h"
|
||||
#include "esp_random.h"
|
||||
#include "mdns.h"
|
||||
#include "mbedtls/version.h"
|
||||
#include <mbedtls/x509.h>
|
||||
@@ -110,6 +111,14 @@ extern char private_key[];
|
||||
enum { RSA_MODE_KEY, RSA_MODE_AUTH };
|
||||
|
||||
static void on_dmap_string(void *ctx, const char *code, const char *name, const char *buf, size_t len);
|
||||
|
||||
#ifndef WIN32
|
||||
static int raop_mbedtls_rng(void *ctx, unsigned char *output, size_t output_len) {
|
||||
(void) ctx;
|
||||
esp_fill_random(output, output_len);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
struct raop_ctx_s *raop_create(uint32_t host, char *name,
|
||||
@@ -626,8 +635,8 @@ static bool handle_rtsp(raop_ctx_t *ctx, int sock)
|
||||
struct metadata_s metadata;
|
||||
dmap_settings settings = {
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, on_dmap_string, NULL,
|
||||
NULL
|
||||
};
|
||||
NULL
|
||||
};
|
||||
|
||||
settings.ctx = &metadata;
|
||||
memset(&metadata, 0, sizeof(struct metadata_s));
|
||||
@@ -635,8 +644,8 @@ static bool handle_rtsp(raop_ctx_t *ctx, int sock)
|
||||
unsigned timestamp = 0;
|
||||
if ((p = kd_lookup(headers, "RTP-Info")) != NULL) sscanf(p, "%*[^=]=%u", ×tamp);
|
||||
LOG_INFO("[%p]: received metadata (ts: %d)\n\tartist: %s\n\talbum: %s\n\ttitle: %s",
|
||||
ctx, timestamp, metadata.artist ? metadata.artist : "", metadata.album ? metadata.album : "",
|
||||
metadata.title ? metadata.title : "");
|
||||
ctx, timestamp, metadata.artist ? metadata.artist : "", metadata.album ? metadata.album : "",
|
||||
metadata.title ? metadata.title : "");
|
||||
success = ctx->cmd_cb(RAOP_METADATA, metadata.artist, metadata.album, metadata.title, timestamp);
|
||||
free_metadata(&metadata);
|
||||
}
|
||||
@@ -823,6 +832,8 @@ static char *rsa_apply(unsigned char *input, int inlen, int *outlen, int mode)
|
||||
RSA_PKCS1_OAEP_PADDING);
|
||||
break;
|
||||
}
|
||||
|
||||
RSA_free(rsa);
|
||||
|
||||
return (char*) out;
|
||||
#else
|
||||
@@ -832,24 +843,45 @@ static char *rsa_apply(unsigned char *input, int inlen, int *outlen, int mode)
|
||||
size_t rsa_len;
|
||||
size_t olen;
|
||||
|
||||
/*
|
||||
we should do entropy initialization & pass a rng function but this
|
||||
/*
|
||||
we should do entropy initialization & pass a rng function but this
|
||||
consumes a ton of stack and there is no security concern here. Anyway,
|
||||
mbedtls takes a lot of stack, unfortunately ...
|
||||
*/
|
||||
|
||||
mbedtls_pk_init(&pkctx);
|
||||
ret = mbedtls_pk_parse_key(&pkctx, (unsigned char *)super_secret_key,
|
||||
sizeof(super_secret_key), NULL, 0, raop_mbedtls_rng, NULL);
|
||||
if (ret != 0 || !mbedtls_pk_can_do(&pkctx, MBEDTLS_PK_RSA)) {
|
||||
LOG_ERROR("unable to parse RAOP private RSA key (%d)", ret);
|
||||
mbedtls_pk_free(&pkctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
uint8_t *outbuf = NULL;
|
||||
trsa = mbedtls_pk_rsa(pkctx);
|
||||
uint8_t *outbuf = NULL;
|
||||
trsa = mbedtls_pk_rsa(pkctx);
|
||||
rsa_len = mbedtls_rsa_get_len(trsa);
|
||||
|
||||
switch (mode) {
|
||||
case RSA_MODE_AUTH:
|
||||
mbedtls_rsa_set_padding(trsa, MBEDTLS_RSA_PKCS_V15, MBEDTLS_MD_NONE);
|
||||
outbuf = malloc(rsa_len);
|
||||
if (!outbuf) break;
|
||||
ret = mbedtls_rsa_pkcs1_sign(trsa, raop_mbedtls_rng, NULL, MBEDTLS_MD_NONE,
|
||||
(unsigned int) inlen, input, outbuf);
|
||||
if (ret != 0) {
|
||||
LOG_ERROR("RSA auth sign failed (%d)", ret);
|
||||
free(outbuf);
|
||||
mbedtls_rsa_set_padding(trsa, MBEDTLS_RSA_PKCS_V15, MBEDTLS_MD_NONE);
|
||||
outbuf = malloc(trsa->len);
|
||||
mbedtls_rsa_pkcs1_encrypt(trsa, NULL, NULL, MBEDTLS_RSA_PRIVATE, inlen, input, outbuf);
|
||||
outbuf = NULL;
|
||||
break;
|
||||
}
|
||||
*outlen = (int) rsa_len;
|
||||
break;
|
||||
case RSA_MODE_KEY:
|
||||
mbedtls_rsa_set_padding(trsa, MBEDTLS_RSA_PKCS_V21, MBEDTLS_MD_SHA1);
|
||||
outbuf = malloc(rsa_len);
|
||||
if (!outbuf) break;
|
||||
ret = mbedtls_rsa_pkcs1_decrypt(trsa, raop_mbedtls_rng, NULL, &olen, input, outbuf, rsa_len);
|
||||
if (ret != 0) {
|
||||
LOG_ERROR("RSA key decrypt failed (%d)", ret);
|
||||
free(outbuf);
|
||||
@@ -972,4 +1004,3 @@ static void on_dmap_string(void *ctx, const char *code, const char *name, const
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static void on_dmap_string(void *ctx, const char *code, const char *name, const char *buf, size_t len) {
|
||||
|
||||
@@ -217,7 +217,7 @@ rtp_resp_t rtp_init(struct in_addr host, int latency, char *aeskey, char *aesiv,
|
||||
{
|
||||
int i = 0;
|
||||
char *arg;
|
||||
int fmtp[12];
|
||||
int fmtp[32];
|
||||
bool rc = true;
|
||||
rtp_t *ctx = calloc(1, sizeof(rtp_t));
|
||||
rtp_resp_t resp = { 0, 0, 0, NULL };
|
||||
@@ -834,4 +834,3 @@ static bool rtp_request_resend(rtp_t *ctx, seq_t first, seq_t last) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <iphlpapi.h>
|
||||
#else
|
||||
#include "esp_netif.h"
|
||||
#include "tcpip_adapter_compat.h"
|
||||
// IDF-V4++ #include "esp_netif.h"
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
@@ -603,4 +604,3 @@ int _fprintf(FILE *file, ...)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
idf_component_register(SRC_DIRS .
|
||||
INCLUDE_DIRS .
|
||||
REQUIRES json tools platform_config display wifi-manager esp-tls
|
||||
PRIV_REQUIRES soc esp32
|
||||
INCLUDE_DIRS .
|
||||
REQUIRES json tools platform_config display wifi-manager esp-tls driver esp_wifi
|
||||
PRIV_REQUIRES soc
|
||||
)
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "sdkconfig.h"
|
||||
#include "soc/efuse_periph.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/spi_common_internal.h"
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#include "esp32/rom/efuse.h"
|
||||
#endif
|
||||
@@ -96,7 +95,7 @@ const sys_i2c_bus* get_i2c_bus(i2c_port_t port){
|
||||
if(platform->dev.has_i2c && port == platform->dev.i2c.port-sys_i2c_port_PORT0 && platform->dev.i2c.scl>=0){
|
||||
return &platform->dev.i2c;
|
||||
}
|
||||
if(platform->dev.has_dac && platform->dev.dac.has_i2c && platform->dev.dac.i2c.port == port && platform->dev.dac.i2c.scl>=0){
|
||||
if(platform->dev.has_dac && platform->dev.dac.has_i2c && (platform->dev.dac.i2c.port - sys_i2c_port_PORT0) == port && platform->dev.dac.i2c.scl>=0){
|
||||
return &platform->dev.dac.i2c;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
@@ -119,7 +119,7 @@ esp_err_t actrls_init(const char* profile_name) {
|
||||
p = strchr(p, '=');
|
||||
|
||||
int double_press = dev_config->knobonly.delay_ms > 0 ? dev_config->knobonly.delay_ms : 350;
|
||||
rotary.timer = xTimerCreate("knobTimer", double_press / portTICK_RATE_MS, pdFALSE, NULL, rotary_timer);
|
||||
rotary.timer = xTimerCreate("knobTimer", double_press / portTICK_PERIOD_MS, pdFALSE, NULL, rotary_timer);
|
||||
longpress = 500;
|
||||
ESP_LOGI(TAG, "single knob navigation %d", double_press);
|
||||
} else {
|
||||
@@ -254,7 +254,7 @@ static void control_rotary_handler(void* client, rotary_event_e event, bool long
|
||||
// need to add a left button the first time
|
||||
if (rotary.left_count == 1) (*current_controls[sys_btns_actions_KNOB_LEFT])(true);
|
||||
}
|
||||
xTimerStart(rotary.timer, 20 / portTICK_RATE_MS);
|
||||
xTimerStart(rotary.timer, 20 / portTICK_PERIOD_MS);
|
||||
rotary.left_count++;
|
||||
} else if (rotary.long_state)
|
||||
action = sys_btns_actions_A_PREV;
|
||||
@@ -286,7 +286,7 @@ static void control_rotary_handler(void* client, rotary_event_e event, bool long
|
||||
action = sys_btns_actions_B_LEFT;
|
||||
xTimerStop(rotary.timer, 0);
|
||||
} else
|
||||
xTimerStart(rotary.timer, 20 / portTICK_RATE_MS);
|
||||
xTimerStart(rotary.timer, 20 / portTICK_PERIOD_MS);
|
||||
rotary.click_pending = !rotary.click_pending;
|
||||
} else if (long_press)
|
||||
rotary.long_state = !rotary.long_state;
|
||||
|
||||
@@ -80,7 +80,7 @@ void battery_svc_init(void) {
|
||||
adc1_config_channel_atten(BATTERY_CHANNEL(battery), ATTENUATION(battery));
|
||||
|
||||
battery.avg = adc1_get_raw(BATTERY_CHANNEL(battery)) * battery.scale / 4095.0;
|
||||
battery.timer = xTimerCreate("battery", BATTERY_TIMER / portTICK_RATE_MS, pdTRUE, NULL, battery_callback);
|
||||
battery.timer = xTimerCreate("battery", BATTERY_TIMER / portTICK_PERIOD_MS, pdTRUE, NULL, battery_callback);
|
||||
xTimerStart(battery.timer, portMAX_DELAY);
|
||||
|
||||
ESP_LOGI(TAG, "Battery measure channel: %u, scale %f, atten %d, cells %u, avg %.2fV", BATTERY_CHANNEL(battery), battery.scale, ATTENUATION(battery), battery.battery_config->cells, battery.avg);
|
||||
|
||||
@@ -151,7 +151,7 @@ static void buttons_handler(struct button_s* button, int level) {
|
||||
if (button->long_press && !button->long_timer && button->level == button->type) {
|
||||
// detect a long press, so hold event generation
|
||||
ESP_LOGD(TAG, "setting long timer gpio:%u level:%u", button->gpio, button->level);
|
||||
xTimerChangePeriod(button->timer, button->long_press / portTICK_RATE_MS, 0);
|
||||
xTimerChangePeriod(button->timer, button->long_press / portTICK_PERIOD_MS, 0);
|
||||
button->long_timer = true;
|
||||
} else {
|
||||
// send a button pressed/released event (content is copied in queue)
|
||||
@@ -279,7 +279,7 @@ void button_create(void* client, int gpio, int type, bool pull, int debounce, bu
|
||||
buttons[n_buttons].shifter_gpio = shifter_gpio;
|
||||
buttons[n_buttons].type = type;
|
||||
buttons[n_buttons].timer =
|
||||
xTimerCreate("buttonTimer", buttons[n_buttons].debounce / portTICK_RATE_MS, pdFALSE, (void*)&buttons[n_buttons], buttons_timer_handler);
|
||||
xTimerCreate("buttonTimer", buttons[n_buttons].debounce / portTICK_PERIOD_MS, pdFALSE, (void*)&buttons[n_buttons], buttons_timer_handler);
|
||||
buttons[n_buttons].self = buttons + n_buttons;
|
||||
|
||||
for (int i = 0; i < n_buttons; i++) {
|
||||
@@ -318,7 +318,7 @@ void button_create(void* client, int gpio, int type, bool pull, int debounce, bu
|
||||
for (int i = 0; polled_gpio[i].gpio != -1; i++)
|
||||
if (polled_gpio[i].gpio == gpio) {
|
||||
if (!polled_timer) {
|
||||
polled_timer = xTimerCreate("buttonsPolling", 100 / portTICK_RATE_MS, pdTRUE, polled_gpio, buttons_polling);
|
||||
polled_timer = xTimerCreate("buttonsPolling", 100 / portTICK_PERIOD_MS, pdTRUE, polled_gpio, buttons_polling);
|
||||
xTimerStart(polled_timer, portMAX_DELAY);
|
||||
}
|
||||
|
||||
|
||||
@@ -198,14 +198,14 @@ gpio_exp_t* gpio_exp_create(const gpio_exp_config_t *config) {
|
||||
}
|
||||
if(config->phy.ena_pin>=0){
|
||||
ESP_LOGD(TAG,"Enabling expander with pin %d level %d",config->phy.ena_pin,config->phy.ena_lvl);
|
||||
gpio_pad_select_gpio(config->phy.ena_pin);
|
||||
esp_rom_gpio_pad_select_gpio(config->phy.ena_pin);
|
||||
gpio_set_direction(config->phy.ena_pin, GPIO_MODE_DEF_OUTPUT);
|
||||
gpio_set_level(config->phy.ena_pin, config->phy.ena_lvl);
|
||||
}
|
||||
|
||||
// set interrupt if possible
|
||||
if (config->intr >= 0) {
|
||||
gpio_pad_select_gpio(config->intr);
|
||||
esp_rom_gpio_pad_select_gpio(config->intr);
|
||||
gpio_set_direction(config->intr, GPIO_MODE_INPUT);
|
||||
|
||||
switch (expander->model->trigger) {
|
||||
@@ -702,7 +702,7 @@ static esp_err_t i2c_write(uint8_t port, uint8_t addr, uint8_t reg, uint32_t dat
|
||||
else i2c_master_write_byte(cmd, data, I2C_MASTER_NACK);
|
||||
|
||||
i2c_master_stop(cmd);
|
||||
esp_err_t ret = i2c_master_cmd_begin(port, cmd, 100 / portTICK_RATE_MS);
|
||||
esp_err_t ret = i2c_master_cmd_begin(port, cmd, 100 / portTICK_PERIOD_MS);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
|
||||
if (ret != ESP_OK) {
|
||||
@@ -737,7 +737,7 @@ static uint32_t i2c_read(uint8_t port, uint8_t addr, uint8_t reg, int len) {
|
||||
else i2c_master_read_byte(cmd, (uint8_t*) &data, I2C_MASTER_NACK);
|
||||
|
||||
i2c_master_stop(cmd);
|
||||
esp_err_t ret = i2c_master_cmd_begin(port, cmd, 100 / portTICK_RATE_MS);
|
||||
esp_err_t ret = i2c_master_cmd_begin(port, cmd, 100 / portTICK_PERIOD_MS);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
|
||||
if (ret != ESP_OK) {
|
||||
|
||||
@@ -62,4 +62,4 @@ esp_err_t gpio_isr_handler_add_x(int gpio, gpio_isr_t isr_handler, void* args)
|
||||
esp_err_t gpio_isr_handler_remove_x(int gpio);
|
||||
#define gpio_set_intr_type_x(gpio, type) do { if (gpio < GPIO_NUM_MAX) gpio_set_intr_type(gpio, type); } while (0)
|
||||
#define gpio_intr_enable_x(gpio) do { if (gpio < GPIO_NUM_MAX) gpio_intr_enable(gpio); } while (0)
|
||||
#define gpio_pad_select_gpio_x(gpio) do { if (gpio < GPIO_NUM_MAX) gpio_pad_select_gpio(gpio); } while (0)
|
||||
#define gpio_pad_select_gpio_x(gpio) do { if (gpio < GPIO_NUM_MAX) esp_rom_gpio_pad_select_gpio(gpio); } while (0)
|
||||
|
||||
@@ -450,7 +450,7 @@ err:
|
||||
*/
|
||||
bool infrared_receive(RingbufHandle_t rb, infrared_handler handler) {
|
||||
size_t rx_size = 0;
|
||||
rmt_item32_t* item = (rmt_item32_t*) xRingbufferReceive(rb, &rx_size, 10 / portTICK_RATE_MS);
|
||||
rmt_item32_t* item = (rmt_item32_t*) xRingbufferReceive(rb, &rx_size, 10 / portTICK_PERIOD_MS);
|
||||
bool decoded = false;
|
||||
|
||||
if (item) {
|
||||
|
||||
@@ -130,7 +130,7 @@ static void vCallbackFunction(TimerHandle_t xTimer) {
|
||||
|
||||
// regular blinking
|
||||
xTimerChangePeriod(
|
||||
xTimer, (led->on ? led->ontime : led->offtime) / portTICK_RATE_MS, BLOCKTIME);
|
||||
xTimer, (led->on ? led->ontime : led->offtime) / portTICK_PERIOD_MS, BLOCKTIME);
|
||||
}
|
||||
|
||||
/****************************************************************************************
|
||||
@@ -170,7 +170,7 @@ bool led_blink_core(int idx, int ontime, int offtime, bool pushed) {
|
||||
} else {
|
||||
if (!leds[idx].timer) {
|
||||
ESP_LOGD(TAG, "led %d, Creating timer", idx);
|
||||
leds[idx].timer = xTimerCreate("ledTimer", ontime / portTICK_RATE_MS, pdFALSE,
|
||||
leds[idx].timer = xTimerCreate("ledTimer", ontime / portTICK_PERIOD_MS, pdFALSE,
|
||||
(void*)&leds[idx], vCallbackFunction);
|
||||
}
|
||||
leds[idx].on = true;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
*
|
||||
*/
|
||||
#include "config.h"
|
||||
#include "esp_app_trace.h"
|
||||
#include "esp_attr.h"
|
||||
#include "stdbool.h"
|
||||
#include <errno.h>
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/timers.h"
|
||||
#include "esp_system.h"
|
||||
@@ -69,10 +70,10 @@ static void task_stats( cJSON* top ) {
|
||||
for(int i = 0, n = 0; i < current.n; i++ ) {
|
||||
for (int j = 0; j < previous.n; j++) {
|
||||
if (current.tasks[i].xTaskNumber == previous.tasks[j].xTaskNumber) {
|
||||
n += snprintf(scratch + n, SCRATCH_SIZE - n, "%16s (%u) %2u%% s:%5u", current.tasks[i].pcTaskName,
|
||||
current.tasks[i].eCurrentState,
|
||||
100 * (current.tasks[i].ulRunTimeCounter - previous.tasks[j].ulRunTimeCounter) / elapsed,
|
||||
current.tasks[i].usStackHighWaterMark);
|
||||
n += snprintf(scratch + n, SCRATCH_SIZE - n, "%16s (%u) %2" PRIu32 "%% s:%5" PRIu32, current.tasks[i].pcTaskName,
|
||||
(unsigned) current.tasks[i].eCurrentState,
|
||||
(uint32_t) (100 * (current.tasks[i].ulRunTimeCounter - previous.tasks[j].ulRunTimeCounter) / elapsed),
|
||||
(uint32_t) current.tasks[i].usStackHighWaterMark);
|
||||
cJSON * t=cJSON_CreateObject();
|
||||
cJSON_AddNumberToObject(t,"cpu",100 * (current.tasks[i].ulRunTimeCounter - previous.tasks[j].ulRunTimeCounter) / elapsed);
|
||||
cJSON_AddNumberToObject(t,"minstk",current.tasks[i].usStackHighWaterMark);
|
||||
@@ -94,7 +95,7 @@ static void task_stats( cJSON* top ) {
|
||||
#pragma message("Compiled WITHOUT runtime stats")
|
||||
|
||||
for (int i = 0, n = 0; i < current.n; i ++) {
|
||||
n += sprintf(scratch + n, "%16s s:%5u\t", current.tasks[i].pcTaskName, current.tasks[i].usStackHighWaterMark);
|
||||
n += sprintf(scratch + n, "%16s s:%5" PRIu32 "\t", current.tasks[i].pcTaskName, (uint32_t) current.tasks[i].usStackHighWaterMark);
|
||||
cJSON * t=cJSON_CreateObject();
|
||||
cJSON_AddNumberToObject(t,"minstk",current.tasks[i].usStackHighWaterMark);
|
||||
cJSON_AddNumberToObject(t,"bprio",current.tasks[i].uxBasePriority);
|
||||
@@ -233,4 +234,4 @@ void monitor_svc_init(void) {
|
||||
static EXT_RAM_ATTR StackType_t xStack[PSEUDO_IDLE_STACK_SIZE] __attribute__ ((aligned (4)));
|
||||
xTaskCreateStatic( (TaskFunction_t) pseudo_idle, "pseudo_idle", PSEUDO_IDLE_STACK_SIZE,
|
||||
NULL, ESP_TASK_PRIO_MIN, xStack, xTaskBuffer );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "driver/rmt.h"
|
||||
#include "driver/rtc_io.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_rom_gpio.h"
|
||||
#include "esp_sleep.h"
|
||||
#include "globdefs.h"
|
||||
#include "gpio_exp.h"
|
||||
@@ -59,6 +60,11 @@ static EXT_RAM_ATTR struct {
|
||||
|
||||
static const char* TAG = "services";
|
||||
|
||||
static void deep_sleep_timer_cb(TimerHandle_t timer) {
|
||||
(void)timer;
|
||||
esp_deep_sleep_start();
|
||||
}
|
||||
|
||||
bool are_GPIOExp_equal(const sys_exp_config* exp1, const sys_exp_config* exp2) {
|
||||
if (exp1 == NULL || exp2 == NULL) {
|
||||
return false; // Safeguard against NULL pointers
|
||||
@@ -135,7 +141,7 @@ void set_gpio_level(sys_gpio_config* gpio, const char* name, gpio_mode_t mode) {
|
||||
ESP_LOGW(TAG, "Invalid gpio %d for %s", gpio->pin, name);
|
||||
return;
|
||||
}
|
||||
gpio_pad_select_gpio(gpio->pin);
|
||||
esp_rom_gpio_pad_select_gpio(gpio->pin);
|
||||
gpio_set_direction(gpio->pin, mode);
|
||||
gpio_set_level(gpio->pin, gpio->level);
|
||||
}
|
||||
@@ -350,7 +356,7 @@ void services_sleep_activate(sleep_cause_e cause) {
|
||||
// we need to use a timer in case the same button is used for sleep and wake-up and it's
|
||||
// "pressed" vs "released" selected
|
||||
if (cause == SLEEP_ONKEY)
|
||||
xTimerStart(xTimerCreate("sleepTimer", pdMS_TO_TICKS(1000), pdFALSE, NULL, (void (*)(void*))esp_deep_sleep_start), 0);
|
||||
xTimerStart(xTimerCreate("sleepTimer", pdMS_TO_TICKS(1000), pdFALSE, NULL, deep_sleep_timer_cb), 0);
|
||||
else
|
||||
esp_deep_sleep_start();
|
||||
}
|
||||
|
||||
@@ -347,15 +347,39 @@ foreach(FIL ${_nanopb_hdrs})
|
||||
endforeach()
|
||||
|
||||
# Find the protoc Executable
|
||||
# Prefer project-bundled protoc when available.
|
||||
if(EXISTS "${CMAKE_SOURCE_DIR}/tools/protobuf/linux-x86_64/bin/protoc")
|
||||
set(_NANOPB_PROTOC_HINTS "${CMAKE_SOURCE_DIR}/tools/protobuf/linux-x86_64/bin")
|
||||
elseif(EXISTS "${CMAKE_SOURCE_DIR}/tools/protobuf/win64/bin/protoc.exe")
|
||||
set(_NANOPB_PROTOC_HINTS "${CMAKE_SOURCE_DIR}/tools/protobuf/win64/bin")
|
||||
endif()
|
||||
|
||||
find_program(PROTOBUF_PROTOC_EXECUTABLE
|
||||
NAMES protoc
|
||||
NAMES protoc protoc.exe
|
||||
DOC "The Google Protocol Buffers Compiler"
|
||||
HINTS
|
||||
${_NANOPB_PROTOC_HINTS}
|
||||
PATHS
|
||||
${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/Release
|
||||
${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/Debug
|
||||
${NANOPB_SRC_ROOT_FOLDER}/generator-bin
|
||||
${NANOPB_SRC_ROOT_FOLDER}/generator
|
||||
)
|
||||
|
||||
# Older configurations may cache nanopb's python wrapper (".../generator/protoc"),
|
||||
# which is not a real protoc binary and produces incompatible *_pb2.py output.
|
||||
if(PROTOBUF_PROTOC_EXECUTABLE MATCHES "/generator/protoc(\\.exe)?$")
|
||||
unset(PROTOBUF_PROTOC_EXECUTABLE CACHE)
|
||||
find_program(PROTOBUF_PROTOC_EXECUTABLE
|
||||
NAMES protoc protoc.exe
|
||||
DOC "The Google Protocol Buffers Compiler"
|
||||
HINTS
|
||||
${_NANOPB_PROTOC_HINTS}
|
||||
PATHS
|
||||
${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/Release
|
||||
${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/Debug
|
||||
${NANOPB_SRC_ROOT_FOLDER}/generator-bin
|
||||
)
|
||||
endif()
|
||||
mark_as_advanced(PROTOBUF_PROTOC_EXECUTABLE)
|
||||
|
||||
# Find nanopb generator source dir
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "URLParser.h"
|
||||
#include <cstring>
|
||||
|
||||
namespace bell {
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ extern "C" {
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_netif.h"
|
||||
#include "tcpip_adapter_compat.h"
|
||||
// IDF-V4++ #include "esp_netif.h"
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_CONNECT_ETHERNET
|
||||
|
||||
@@ -323,6 +323,9 @@ esp_err_t _http_event_handler(esp_http_client_event_t *evt)
|
||||
case HTTP_EVENT_DISCONNECTED:
|
||||
ESP_LOGD(TAG, "HTTP_EVENT_DISCONNECTED");
|
||||
break;
|
||||
case HTTP_EVENT_REDIRECT:
|
||||
ESP_LOGD(TAG, "HTTP_EVENT_REDIRECT");
|
||||
break;
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -785,4 +788,4 @@ void cb_handle_ota(nm_state_t new_state, int sub_state) {
|
||||
ESP_LOGE(TAG, "Restarted to application partition. We're not going to perform OTA!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "esp_image_format.h"
|
||||
#include "esp_ota_ops.h"
|
||||
#include "network_services.h"
|
||||
#include <netinet/in.h>
|
||||
|
||||
// ERASE BLOCK needs to be a multiple of sector size. If a different multiple is passed
|
||||
// the OTA process will adjust. Here, we need to strike the balance between speed and
|
||||
@@ -34,4 +35,4 @@ esp_err_t start_ota(const char * bin_url, char * bin_buffer, uint32_t length);
|
||||
in_addr_t discover_ota_server(int max);
|
||||
|
||||
// Callback to handle ota when an IP address is obtained
|
||||
void cb_handle_ota(nm_state_t new_state, int sub_state);
|
||||
void cb_handle_ota(nm_state_t new_state, int sub_state);
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
# for the forgetful, REQUIRES cannot use CONFIG_XXX due to parsing order
|
||||
if(IDF_TARGET STREQUAL "esp32")
|
||||
set(target_requires "driver_bt" "platform_config")
|
||||
if(IDF_VERSION_MAJOR EQUAL 4 AND IDF_VERSION_MINOR LESS 4)
|
||||
list(APPEND target_requires "_override")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
idf_component_register( SRC_DIRS . external ac101 tas57xx wm8978 cs4265
|
||||
@@ -16,11 +19,10 @@ idf_component_register( SRC_DIRS . external ac101 tas57xx wm8978 cs4265
|
||||
spotify
|
||||
raop
|
||||
display
|
||||
audio
|
||||
led_strip
|
||||
_override
|
||||
${target_requires}
|
||||
EMBED_FILES vu_s.data arrow.data
|
||||
audio
|
||||
led_strip
|
||||
${target_requires}
|
||||
EMBED_FILES vu_s.data arrow.data
|
||||
)
|
||||
|
||||
set_source_files_properties(mad.c pcm.c flac.c alac.c helix-aac.c vorbis.c opus.c
|
||||
|
||||
@@ -79,7 +79,7 @@ esp_err_t adac_write_byte(int i2c_addr,uint8_t reg, uint8_t val) {
|
||||
i2c_master_write_byte(cmd, val, I2C_MASTER_NACK);
|
||||
|
||||
i2c_master_stop(cmd);
|
||||
esp_err_t ret = i2c_master_cmd_begin(i2c_port, cmd, 100 / portTICK_RATE_MS);
|
||||
esp_err_t ret = i2c_master_cmd_begin(i2c_port, cmd, 100 / portTICK_PERIOD_MS);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
|
||||
if (ret != ESP_OK) {
|
||||
@@ -106,7 +106,7 @@ uint8_t adac_read_byte(int i2c_addr, uint8_t reg) {
|
||||
i2c_master_read_byte(cmd, &data, I2C_MASTER_NACK);
|
||||
|
||||
i2c_master_stop(cmd);
|
||||
esp_err_t ret = i2c_master_cmd_begin(i2c_port, cmd, 100 / portTICK_RATE_MS);
|
||||
esp_err_t ret = i2c_master_cmd_begin(i2c_port, cmd, 100 / portTICK_PERIOD_MS);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
|
||||
if (ret != ESP_OK) {
|
||||
@@ -133,7 +133,7 @@ uint16_t adac_read_word(int i2c_addr, uint8_t reg) {
|
||||
i2c_master_read(cmd, data, 2, I2C_MASTER_NACK);
|
||||
|
||||
i2c_master_stop(cmd);
|
||||
esp_err_t ret = i2c_master_cmd_begin(i2c_port, cmd, 100 / portTICK_RATE_MS);
|
||||
esp_err_t ret = i2c_master_cmd_begin(i2c_port, cmd, 100 / portTICK_PERIOD_MS);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
|
||||
if (ret != ESP_OK) {
|
||||
@@ -156,7 +156,7 @@ esp_err_t adac_write_word(int i2c_addr, uint8_t reg, uint16_t val) {
|
||||
i2c_master_write(cmd, data, 4, I2C_MASTER_NACK);
|
||||
|
||||
i2c_master_stop(cmd);
|
||||
esp_err_t ret = i2c_master_cmd_begin(i2c_port, cmd, 100 / portTICK_RATE_MS);
|
||||
esp_err_t ret = i2c_master_cmd_begin(i2c_port, cmd, 100 / portTICK_PERIOD_MS);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
|
||||
if (ret != ESP_OK) {
|
||||
@@ -178,7 +178,7 @@ esp_err_t adac_write(int i2c_addr, uint8_t reg, uint8_t *data, size_t count) {
|
||||
i2c_master_write(cmd, data, count, I2C_MASTER_NACK);
|
||||
|
||||
i2c_master_stop(cmd);
|
||||
esp_err_t ret = i2c_master_cmd_begin(i2c_port, cmd, 200 / portTICK_RATE_MS);
|
||||
esp_err_t ret = i2c_master_cmd_begin(i2c_port, cmd, 200 / portTICK_PERIOD_MS);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
|
||||
if (ret != ESP_OK) {
|
||||
|
||||
@@ -260,8 +260,10 @@ static int read_mp4_header(void) {
|
||||
}
|
||||
if (!memcmp(ptr + 4, "data", 4) && remain > 16 + 48) {
|
||||
// data is stored as hex strings: 0 start end samples
|
||||
u32_t b, c; u64_t d;
|
||||
if (sscanf((const char *)(ptr + 16), "%x %x %x " FMT_x64, &b, &b, &c, &d) == 4) {
|
||||
unsigned b_tmp, c_tmp;
|
||||
u64_t d;
|
||||
if (sscanf((const char *)(ptr + 16), "%x %x %x " FMT_x64, &b_tmp, &b_tmp, &c_tmp, &d) == 4) {
|
||||
u32_t b = b_tmp, c = c_tmp;
|
||||
LOG_DEBUG("iTunSMPB start: %u end: %u samples: " FMT_u64, b, c, d);
|
||||
if (l->sttssamples && l->sttssamples < b + c + d) {
|
||||
LOG_DEBUG("reducing samples as stts count is less");
|
||||
@@ -317,7 +319,8 @@ static decode_state alac_decode(void) {
|
||||
size_t bytes;
|
||||
bool endstream;
|
||||
u8_t *iptr;
|
||||
u32_t frames, block_size;
|
||||
unsigned frames;
|
||||
u32_t block_size;
|
||||
|
||||
LOCK_S;
|
||||
|
||||
|
||||
@@ -403,7 +403,7 @@ static bool init(sys_dac_config * config, i2s_config_t* i2s_config, bool* mck) {
|
||||
}
|
||||
|
||||
i2c_master_stop(i2c_cmd);
|
||||
esp_err_t res = i2c_master_cmd_begin(cs4265.port, i2c_cmd, 500 / portTICK_RATE_MS);
|
||||
esp_err_t res = i2c_master_cmd_begin(cs4265.port, i2c_cmd, 500 / portTICK_PERIOD_MS);
|
||||
i2c_cmd_link_delete(i2c_cmd);
|
||||
if (res != ESP_OK) {
|
||||
ESP_LOGE(TAG, "could not intialize cs4265 %d", res);
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "squeezelite.h"
|
||||
|
||||
log_level loglevel;
|
||||
extern log_level loglevel;
|
||||
|
||||
extern struct buffer *streambuf;
|
||||
extern struct buffer *outputbuf;
|
||||
@@ -316,4 +316,3 @@ void codec_open(u8_t format, u8_t sample_size, u8_t sample_rate, u8_t channels,
|
||||
|
||||
LOG_ERROR("codec not found");
|
||||
}
|
||||
|
||||
|
||||
@@ -208,7 +208,7 @@ static bool bt_sink_cmd_handler(bt_sink_cmd_t cmd, va_list args) {
|
||||
* raop sink data handler
|
||||
*/
|
||||
#if CONFIG_AIRPLAY_SINK
|
||||
static void raop_sink_data_handler(const uint8_t* data, uint32_t len, u32_t playtime) {
|
||||
static void raop_sink_data_handler(const uint8_t* data, size_t len, u32_t playtime) {
|
||||
|
||||
raop_sync.playtime = playtime;
|
||||
raop_sync.len = len;
|
||||
@@ -363,7 +363,7 @@ static bool raop_sink_cmd_handler(raop_event_t event, va_list args) {
|
||||
* cspot sink data handler
|
||||
*/
|
||||
#if CONFIG_CSPOT_SINK
|
||||
static uint32_t cspot_sink_data_handler(const uint8_t* data, uint32_t len) {
|
||||
static uint32_t cspot_sink_data_handler(const uint8_t* data, size_t len) {
|
||||
return sink_data_handler(data, len, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "squeezelite.h"
|
||||
#include "pthread.h"
|
||||
#include "esp_pthread.h"
|
||||
#include "esp_mac.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_timer.h"
|
||||
#include "esp_wifi.h"
|
||||
|
||||
@@ -100,8 +100,8 @@ void output_visu_init(log_level level);
|
||||
void output_visu_close(void);
|
||||
|
||||
// optional, please chain if used
|
||||
bool (*slimp_handler)(u8_t *data, int len);
|
||||
void (*slimp_loop)(void);
|
||||
void (*server_notify)(in_addr_t ip, u16_t hport, u16_t cport);
|
||||
extern bool (*slimp_handler)(u8_t *data, int len);
|
||||
extern void (*slimp_loop)(void);
|
||||
extern void (*server_notify)(in_addr_t ip, u16_t hport, u16_t cport);
|
||||
|
||||
#endif // EMBEDDED_H
|
||||
|
||||
@@ -292,8 +292,10 @@ static int read_mp4_header(unsigned long *samplerate_p, unsigned char *channels_
|
||||
}
|
||||
if (!memcmp(ptr + 4, "data", 4) && remain > 16 + 48) {
|
||||
// data is stored as hex strings: 0 start end samples
|
||||
u32_t b, c; u64_t d;
|
||||
if (sscanf((const char *)(ptr + 16), "%x %x %x " FMT_x64, &b, &b, &c, &d) == 4) {
|
||||
unsigned b_tmp, c_tmp;
|
||||
u64_t d;
|
||||
if (sscanf((const char *)(ptr + 16), "%x %x %x " FMT_x64, &b_tmp, &b_tmp, &c_tmp, &d) == 4) {
|
||||
u32_t b = b_tmp, c = c_tmp;
|
||||
LOG_DEBUG("iTunSMPB start: %u end: %u samples: " FMT_u64, b, c, d);
|
||||
if (a->sttssamples && a->sttssamples < b + c + d) {
|
||||
LOG_DEBUG("reducing samples as stts count is less");
|
||||
|
||||
@@ -215,8 +215,8 @@ static decode_state mad_decode(void) {
|
||||
|
||||
while (true) {
|
||||
size_t frames;
|
||||
s32_t *iptrl;
|
||||
s32_t *iptrr;
|
||||
mad_fixed_t *iptrl;
|
||||
mad_fixed_t *iptrr;
|
||||
unsigned max_frames;
|
||||
|
||||
if (MAD(m, frame_decode, &m->frame, &m->stream) == -1) {
|
||||
@@ -417,4 +417,3 @@ struct codec *register_mad(void) {
|
||||
LOG_INFO("using mad to decode mp3");
|
||||
return &ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ sure that using rate_delay would fix that
|
||||
#include "driver/i2c.h"
|
||||
#include "driver/i2s.h"
|
||||
#include "equalizer.h"
|
||||
#include "esp_rom_gpio.h"
|
||||
#include "esp_pthread.h"
|
||||
#include "globdefs.h"
|
||||
#include "gpio_exp.h"
|
||||
@@ -367,7 +368,7 @@ void output_init_i2s() {
|
||||
res |= i2s_set_pin(CONFIG_I2S_NUM, &i2s_dac_pin);
|
||||
|
||||
if (res == ESP_OK && mute_control.gpio >= 0) {
|
||||
gpio_pad_select_gpio(mute_control.gpio);
|
||||
esp_rom_gpio_pad_select_gpio(mute_control.gpio);
|
||||
gpio_set_direction(mute_control.gpio, GPIO_MODE_OUTPUT);
|
||||
gpio_set_level(mute_control.gpio, mute_control.active);
|
||||
}
|
||||
@@ -384,7 +385,7 @@ void output_init_i2s() {
|
||||
|
||||
// turn off GPIO than is not used (SPDIF of DAC DO when shared)
|
||||
if (silent_do >= 0) {
|
||||
gpio_pad_select_gpio(silent_do);
|
||||
esp_rom_gpio_pad_select_gpio(silent_do);
|
||||
gpio_set_direction(silent_do, GPIO_MODE_OUTPUT);
|
||||
gpio_set_level(silent_do, 0);
|
||||
}
|
||||
|
||||
@@ -46,6 +46,9 @@ static in_addr_t slimproto_ip = 0;
|
||||
static u16_t slimproto_hport = 9000;
|
||||
static u16_t slimproto_cport = 9090;
|
||||
static u8_t player_id;
|
||||
bool (*slimp_handler)(u8_t *data, int len) = NULL;
|
||||
void (*slimp_loop)(void) = NULL;
|
||||
void (*server_notify)(in_addr_t ip, u16_t hport, u16_t cport) = NULL;
|
||||
|
||||
extern struct buffer *streambuf;
|
||||
extern struct buffer *outputbuf;
|
||||
|
||||
@@ -93,7 +93,7 @@ static bool init(sys_dac_config *config, i2s_config_t *i2s_config, bool *mck) {
|
||||
}
|
||||
|
||||
i2c_master_stop(i2c_cmd);
|
||||
esp_err_t res = i2c_master_cmd_begin(config->i2c.port-sys_i2c_port_PORT0, i2c_cmd, 500 / portTICK_RATE_MS);
|
||||
esp_err_t res = i2c_master_cmd_begin(config->i2c.port-sys_i2c_port_PORT0, i2c_cmd, 500 / portTICK_PERIOD_MS);
|
||||
i2c_cmd_link_delete(i2c_cmd);
|
||||
|
||||
if (res != ESP_OK) {
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "accessors.h"
|
||||
#include "config.h"
|
||||
#include "driver/uart.h"
|
||||
#include "esp_app_trace.h"
|
||||
#include "esp_attr.h"
|
||||
#include "esp_vfs.h"
|
||||
#include "esp_vfs_dev.h"
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "esp_attr.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_ota_ops.h"
|
||||
#include "esp_spi_flash.h"
|
||||
#include "messaging.h"
|
||||
#include "tools.h"
|
||||
static const char* TAG = "bootstate";
|
||||
@@ -140,4 +139,4 @@ void simple_restart() {
|
||||
});
|
||||
xTimerStart(timer, portMAX_DELAY);
|
||||
}
|
||||
bool is_restarting() { return restarting; }
|
||||
bool is_restarting() { return restarting; }
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
|
||||
#include "esp_netif.h"
|
||||
#include "esp_idf_version.h"
|
||||
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
|
||||
typedef enum {
|
||||
TCPIP_ADAPTER_IF_STA = 0,
|
||||
TCPIP_ADAPTER_IF_AP = 1,
|
||||
TCPIP_ADAPTER_IF_ETH = 2,
|
||||
TCPIP_ADAPTER_IF_MAX
|
||||
} tcpip_adapter_if_t;
|
||||
|
||||
typedef esp_netif_ip_info_t tcpip_adapter_ip_info_t;
|
||||
typedef esp_netif_dhcp_status_t tcpip_adapter_dhcp_status_t;
|
||||
|
||||
static inline esp_netif_t *tcpip_adapter_get_netif(tcpip_adapter_if_t tcpip_if)
|
||||
{
|
||||
switch (tcpip_if) {
|
||||
case TCPIP_ADAPTER_IF_STA:
|
||||
return esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
|
||||
case TCPIP_ADAPTER_IF_AP:
|
||||
return esp_netif_get_handle_from_ifkey("WIFI_AP_DEF");
|
||||
case TCPIP_ADAPTER_IF_ETH:
|
||||
return esp_netif_get_handle_from_ifkey("ETH_DEF");
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static inline esp_err_t tcpip_adapter_get_hostname(tcpip_adapter_if_t tcpip_if, const char **hostname)
|
||||
{
|
||||
esp_netif_t *netif = tcpip_adapter_get_netif(tcpip_if);
|
||||
if (!netif) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
return esp_netif_get_hostname(netif, hostname);
|
||||
}
|
||||
|
||||
static inline bool tcpip_adapter_is_netif_up(tcpip_adapter_if_t tcpip_if)
|
||||
{
|
||||
esp_netif_t *netif = tcpip_adapter_get_netif(tcpip_if);
|
||||
return netif ? esp_netif_is_netif_up(netif) : false;
|
||||
}
|
||||
|
||||
static inline esp_err_t tcpip_adapter_get_ip_info(tcpip_adapter_if_t tcpip_if, tcpip_adapter_ip_info_t *ip_info)
|
||||
{
|
||||
esp_netif_t *netif = tcpip_adapter_get_netif(tcpip_if);
|
||||
if (!netif) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
return esp_netif_get_ip_info(netif, ip_info);
|
||||
}
|
||||
#endif
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "tools.h"
|
||||
#include "esp_heap_caps.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_mac.h"
|
||||
#include "esp_task.h"
|
||||
|
||||
#include <ctype.h>
|
||||
@@ -365,11 +366,11 @@ char* alloc_get_fallback_unique_name() {
|
||||
#endif
|
||||
}
|
||||
|
||||
#define LOCAL_MAC_SIZE 20
|
||||
#define FORMATTED_MAC_SIZE 20
|
||||
char* alloc_get_formatted_mac_string(uint8_t mac[6]) {
|
||||
char* macStr = malloc_init_external(LOCAL_MAC_SIZE);
|
||||
char* macStr = malloc_init_external(FORMATTED_MAC_SIZE);
|
||||
if (macStr) {
|
||||
snprintf(macStr, LOCAL_MAC_SIZE, MACSTR, MAC2STR(mac));
|
||||
snprintf(macStr, FORMATTED_MAC_SIZE, MACSTR, MAC2STR(mac));
|
||||
}
|
||||
return macStr;
|
||||
}
|
||||
|
||||
@@ -257,9 +257,9 @@ void listFiles(const char* path_requested_char) {
|
||||
printf("Total : %lu bytes in %d file(s)\n", (unsigned long)total, nfiles);
|
||||
}
|
||||
|
||||
uint32_t tot = 0, used = 0;
|
||||
size_t tot = 0, used = 0;
|
||||
esp_spiffs_info(NULL, &tot, &used);
|
||||
printf("SPIFFS: free %d KB of %d KB\n", (tot - used) / 1024, tot / 1024);
|
||||
printf("SPIFFS: free %zu KB of %zu KB\n", (tot - used) / 1024, tot / 1024);
|
||||
printf("---------------------------------------------------------------------------------------"
|
||||
"---------------\n");
|
||||
}
|
||||
@@ -380,4 +380,4 @@ bool dump_structure(const pb_msgdesc_t* fields, const void* src_struct) {
|
||||
ESP_LOGE(TAG, "Error in dump_structure: %s", e.what());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "esp_system.h"
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <sys/queue.h>
|
||||
#include "esp_log.h"
|
||||
#include "freertos/xtensa_api.h"
|
||||
#include "freertos/FreeRTOSConfig.h"
|
||||
@@ -40,4 +41,3 @@ mem_usage_trace_for_thread_t* memtrace_get_thread_entry(TaskHandle_t task) {
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ endif()
|
||||
|
||||
idf_component_register( SRC_DIRS . UML-State-Machine-in-C/src
|
||||
INCLUDE_DIRS . UML-State-Machine-in-C/src
|
||||
REQUIRES squeezelite-ota json mdns
|
||||
REQUIRES squeezelite-ota json mdns esp_eth
|
||||
PRIV_REQUIRES tools services platform_config esp_common json newlib freertos spi_flash nvs_flash mdns pthread wpa_supplicant platform_console esp_http_server console ${target_requires}
|
||||
)
|
||||
|
||||
@@ -46,4 +46,4 @@ file(GLOB_RECURSE WEBAPP_FILES
|
||||
# # Ensure the destination directory exists
|
||||
# add_custom_command(TARGET copy_webapp PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${WEBAPP_DEST_DIR}" )
|
||||
|
||||
# add_dependencies(${COMPONENT_LIB} copy_webapp)
|
||||
# add_dependencies(${COMPONENT_LIB} copy_webapp)
|
||||
|
||||
@@ -97,7 +97,6 @@ char* http_alloc_get_socket_address(httpd_req_t* req, u8_t local, in_port_t* por
|
||||
socklen_t len;
|
||||
union sockaddr_aligned addr;
|
||||
len = sizeof(addr);
|
||||
ip_addr_t* ip_addr = NULL;
|
||||
char* ipstr = malloc_init_external(INET6_ADDRSTRLEN);
|
||||
typedef int (*getaddrname_fn_t)(int s, struct sockaddr* name, socklen_t* namelen);
|
||||
getaddrname_fn_t get_addr = NULL;
|
||||
@@ -114,19 +113,15 @@ char* http_alloc_get_socket_address(httpd_req_t* req, u8_t local, in_port_t* por
|
||||
ESP_LOGE_LOC(TAG, "Failed to retrieve socket address");
|
||||
sprintf(ipstr, "N/A (0.0.0.%u)", local);
|
||||
} else {
|
||||
if (addr.sin.sin_family != AF_INET) {
|
||||
ip_addr = (ip_addr_t*)&(addr.sin6.sin6_addr);
|
||||
inet_ntop(addr.sa.sa_family, ip_addr, ipstr, INET6_ADDRSTRLEN);
|
||||
if (addr.sin.sin_family == AF_INET6) {
|
||||
inet_ntop(AF_INET6, &addr.sin6.sin6_addr, ipstr, INET6_ADDRSTRLEN);
|
||||
ESP_LOGV_LOC(TAG, "Processing an IPV6 address : %s", ipstr);
|
||||
*portl = addr.sin6.sin6_port;
|
||||
unmap_ipv4_mapped_ipv6(ip_2_ip4(ip_addr), ip_2_ip6(ip_addr));
|
||||
} else {
|
||||
ip_addr = (ip_addr_t*)&(addr.sin.sin_addr);
|
||||
inet_ntop(addr.sa.sa_family, ip_addr, ipstr, INET6_ADDRSTRLEN);
|
||||
ESP_LOGV_LOC(TAG, "Processing an IPV6 address : %s", ipstr);
|
||||
inet_ntop(AF_INET, &addr.sin.sin_addr, ipstr, INET6_ADDRSTRLEN);
|
||||
ESP_LOGV_LOC(TAG, "Processing an IPV4 address : %s", ipstr);
|
||||
*portl = addr.sin.sin_port;
|
||||
}
|
||||
inet_ntop(AF_INET, ip_addr, ipstr, INET6_ADDRSTRLEN);
|
||||
ESP_LOGV_LOC(TAG, "Retrieved ip address:port = %s:%u", ipstr, *portl);
|
||||
}
|
||||
return ipstr;
|
||||
@@ -170,7 +165,7 @@ bool is_captive_portal_host_name(httpd_req_t* req) {
|
||||
memset(ap_ip_address, 0x00, IP4ADDR_STRLEN_MAX);
|
||||
if (ap_ip_address) {
|
||||
ESP_LOGD_LOC(TAG, "Converting soft ip address to string");
|
||||
ip4addr_ntoa_r(&ip_info.ip, ap_ip_address, IP4ADDR_STRLEN_MAX);
|
||||
esp_ip4addr_ntoa(&ip_info.ip, ap_ip_address, IP4ADDR_STRLEN_MAX);
|
||||
ESP_LOGD_LOC(
|
||||
TAG, "TCPIP_ADAPTER_IF_AP is up and has ip address %s ", ap_ip_address);
|
||||
}
|
||||
@@ -971,7 +966,7 @@ char* get_ap_ip_address() {
|
||||
ESP_LOGE_LOC(TAG, "Unable to get local AP ip address. Error: %s", esp_err_to_name(err));
|
||||
} else {
|
||||
ESP_LOGV_LOC(TAG, "Converting soft ip address to string");
|
||||
ip4addr_ntoa_r(&ip_info.ip, ap_ip_address, IP4ADDR_STRLEN_MAX);
|
||||
esp_ip4addr_ntoa(&ip_info.ip, ap_ip_address, IP4ADDR_STRLEN_MAX);
|
||||
ESP_LOGD_LOC(TAG, "TCPIP_ADAPTER_IF_AP is up and has ip address %s ", ap_ip_address);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -23,7 +23,9 @@ static esp_err_t start(spi_device_handle_t spi_handle, sys_dev_eth_config* ether
|
||||
#ifdef CONFIG_ETH_SPI_ETHERNET_DM9051
|
||||
eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
|
||||
eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
|
||||
eth_dm9051_config_t eth_config = ETH_DM9051_DEFAULT_CONFIG(spi_handle);
|
||||
spi_host_device_t spi_host = ethernet_config->ethType.spi.host - sys_dev_common_hosts_Host0;
|
||||
eth_dm9051_config_t eth_config = ETH_DM9051_DEFAULT_CONFIG(spi_host, &devcfg);
|
||||
(void)spi_handle;
|
||||
// we assume that isr has been installed already
|
||||
eth_config.int_gpio_num = ethernet_config->ethType.spi.intr;
|
||||
phy_config.phy_addr = -1;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "esp_eth.h"
|
||||
#include "esp_eth_mac_esp.h"
|
||||
#include "network_ethernet.h"
|
||||
|
||||
static EXT_RAM_ATTR network_ethernet_driver_t LAN8720;
|
||||
@@ -22,15 +23,17 @@ static esp_err_t start(spi_device_handle_t spi_handle, sys_dev_eth_config * ethe
|
||||
#ifdef CONFIG_ETH_PHY_INTERFACE_RMII
|
||||
eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
|
||||
eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
|
||||
eth_esp32_emac_config_t esp32_emac_config = ETH_ESP32_EMAC_DEFAULT_CONFIG();
|
||||
(void)spi_handle;
|
||||
|
||||
mac_config.smi_mdc_gpio_num = ethernet_config->ethType.rmii.mdc;
|
||||
mac_config.smi_mdio_gpio_num = ethernet_config->ethType.rmii.mdio;
|
||||
esp32_emac_config.smi_gpio.mdc_num = ethernet_config->ethType.rmii.mdc;
|
||||
esp32_emac_config.smi_gpio.mdio_num = ethernet_config->ethType.rmii.mdio;
|
||||
phy_config.phy_addr = 1;
|
||||
phy_config.reset_gpio_num = ethernet_config->common.rst;
|
||||
rst = phy_config.reset_gpio_num;
|
||||
|
||||
esp_eth_mac_t* mac = esp_eth_mac_new_esp32(&mac_config);
|
||||
esp_eth_phy_t* phy = esp_eth_phy_new_lan8720(&phy_config);
|
||||
esp_eth_mac_t* mac = esp_eth_mac_new_esp32(&esp32_emac_config, &mac_config);
|
||||
esp_eth_phy_t* phy = esp_eth_phy_new_lan87xx(&phy_config);
|
||||
phy->reset_hw = reset_hw;
|
||||
esp_eth_config_t config = ETH_DEFAULT_CONFIG(mac, phy);
|
||||
return esp_eth_driver_install(&config, &LAN8720.handle);
|
||||
|
||||
@@ -21,9 +21,11 @@ static esp_err_t reset_hw(esp_eth_phy_t *phy)
|
||||
|
||||
static esp_err_t start(spi_device_handle_t spi_handle, sys_dev_eth_config * ethernet_config) {
|
||||
#ifdef CONFIG_ETH_SPI_ETHERNET_W5500
|
||||
eth_w5500_config_t eth_config = ETH_W5500_DEFAULT_CONFIG(spi_handle);
|
||||
spi_host_device_t spi_host = ethernet_config->ethType.spi.host - sys_dev_common_hosts_Host0;
|
||||
eth_w5500_config_t eth_config = ETH_W5500_DEFAULT_CONFIG(spi_host, &devcfg);
|
||||
eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
|
||||
eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
|
||||
(void)spi_handle;
|
||||
|
||||
eth_config.int_gpio_num = ethernet_config->ethType.spi.intr;
|
||||
phy_config.phy_addr = -1; // let the system automatically find out the phy address
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "Config.h"
|
||||
#include "accessors.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_mac.h"
|
||||
#include "freertos/timers.h"
|
||||
#include "globdefs.h"
|
||||
#include "messaging.h"
|
||||
@@ -61,7 +62,7 @@ bool network_ethernet_wait_for_link(uint16_t max_wait_ms) {
|
||||
return link_up;
|
||||
}
|
||||
|
||||
static void ETH_Timeout(void* timer_id);
|
||||
static void ETH_Timeout(TimerHandle_t timer);
|
||||
void destroy_network_ethernet() {}
|
||||
|
||||
static void network_ethernet_print_config(const network_ethernet_driver_t* eth_config) {
|
||||
@@ -113,16 +114,7 @@ void init_network_ethernet() {
|
||||
esp_event_handler_register(ETH_EVENT, ESP_EVENT_ANY_ID, ð_event_handler, NULL);
|
||||
ethernet_event_group = xEventGroupCreate();
|
||||
xEventGroupClearBits(ethernet_event_group, LINK_UP_BIT);
|
||||
spi_device_handle_t spi_handle = NULL;
|
||||
if (sys_eth->which_ethType == sys_dev_eth_config_spi_tag) {
|
||||
err = spi_bus_add_device(sys_eth->ethType.spi.host - sys_dev_common_hosts_Host0, network_driver->devcfg, &spi_handle);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "SPI host failed : %s", esp_err_to_name(err));
|
||||
}
|
||||
}
|
||||
if (err == ESP_OK) {
|
||||
err = network_driver->start(spi_handle, sys_eth);
|
||||
}
|
||||
err = network_driver->start(NULL, sys_eth);
|
||||
if (err == ESP_OK) {
|
||||
uint8_t mac_address[6];
|
||||
esp_read_mac(mac_address, ESP_MAC_ETH);
|
||||
@@ -141,9 +133,6 @@ void init_network_ethernet() {
|
||||
}
|
||||
if (err != ESP_OK) {
|
||||
messaging_post_message(MESSAGING_ERROR, MESSAGING_CLASS_SYSTEM, "Configuring Ethernet failed: %s", esp_err_to_name(err));
|
||||
if (spi_handle) {
|
||||
spi_bus_remove_device(spi_handle);
|
||||
}
|
||||
network_driver->handle = NULL;
|
||||
}
|
||||
}
|
||||
@@ -184,4 +173,7 @@ static void eth_event_handler(void* arg, esp_event_base_t event_base, int32_t ev
|
||||
}
|
||||
}
|
||||
|
||||
static void ETH_Timeout(void* timer_id) { network_async_fail(); }
|
||||
static void ETH_Timeout(TimerHandle_t timer) {
|
||||
(void)timer;
|
||||
network_async_fail();
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ Copyright (c) 2017-2021 Sebastien L
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/queue.h>
|
||||
|
||||
#include "dns_server.h"
|
||||
#include "esp_log.h"
|
||||
@@ -69,7 +70,7 @@ network_t NM;
|
||||
|
||||
//! Create and initialize the array of state machines.
|
||||
state_machine_t* const SM[] = {(state_machine_t*)&NM};
|
||||
static void network_timer_cb(void* timer_id);
|
||||
static void network_timer_cb(TimerHandle_t timer_id);
|
||||
int get_root_id(const state_t* state);
|
||||
const state_t* get_root(const state_t* const state);
|
||||
static void network_task(void* pvParameters);
|
||||
@@ -590,7 +591,7 @@ void network_reboot_ota(char* url) {
|
||||
|
||||
network_t* network_get_state_machine() { return &NM; }
|
||||
|
||||
static void network_timer_cb(void* timer_id) { network_async_timer(); }
|
||||
static void network_timer_cb(TimerHandle_t timer_id) { network_async_timer(); }
|
||||
esp_netif_t* network_get_active_interface() {
|
||||
if (NM.wifi_ap_netif && (network_wifi_is_ap_mode() || network_wifi_is_ap_sta_mode())) {
|
||||
return NM.wifi_ap_netif;
|
||||
|
||||
@@ -236,14 +236,6 @@ void filter_unique( wifi_ap_record_t * aplist, uint16_t * ap_num);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief A standard wifi event handler as recommended by Espressif
|
||||
*/
|
||||
esp_err_t network_manager_event_handler(void *ctx, system_event_t *event);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Start the mDNS service
|
||||
*/
|
||||
@@ -306,4 +298,3 @@ void network_manager_format_state_machine(esp_log_level_t level, const char* pre
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "esp_netif.h"
|
||||
#include "tcpip_adapter_compat.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -94,5 +95,3 @@ esp_err_t network_get_ip_info(tcpip_adapter_ip_info_t* ipInfo);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user