This commit is contained in:
philippe44
2019-05-25 11:19:12 -07:00
parent 4e33d3fea4
commit ddfc03ea9b
11 changed files with 1109 additions and 22 deletions

View File

@@ -1,5 +1,33 @@
menu "Example Configuration"
menu "Squeezelite-ESP32"
menu "Logging"
config LOGGING_SLIMPROTO
string "logging level for slimproto "
default "info"
help
Set logging level info|debug|sdebug
config LOGGING_STREAM
string "logging level for stream "
default "info"
help
Set logging level info|debug|sdebug
config LOGGING_DECODE
string "logging level for decode"
default "info"
help
Set logging level info|debug|sdebug
config LOGGING_OUTPUT
string "logging level for output"
default "info"
help
Set logging level info|debug|sdebug
endmenu
config LOG_OPTION
string "squeezelite log option"
default "all=info"
help
log=level Set logging level, logs: all|slimproto|stream|decode|output, level: info|debug|sdebug
menu "Wifi Configuration"
config WIFI_SSID
string "WiFi SSID"
default "myssid"
@@ -11,7 +39,7 @@ menu "Example Configuration"
default "mypassword"
help
WiFi password (WPA or WPA2) for the example to use.
choice SCAN_METHOD
prompt "scan method"
default WIFI_FAST_SCAN
@@ -64,5 +92,61 @@ menu "Example Configuration"
config EXAMPLE_WPA2
bool "wpa2"
endchoice
endmenu
menu "Audio CODEC libraries"
config INCLUDE_FLAC
bool "FLAC"
default 1
help
Include FLAC library for flc decoding.
config INCLUDE_FAAD
bool "FAAD"
default 1
help
Include FAAD library for aac decoding.
config INCLUDE_MAD
depends on SPIRAM_SUPPORT
bool "MAD"
default 1
help
Include mad library for mp3 decoding.
config INCLUDE_VORBIS
bool "VORBIS"
default 1
help
Include vorbis/ogg library for ogg/vorbis decoding.
config INCLUDE_ALAC
bool "ALAC"
default 1
help
Include alac library for alac decoding.
endmenu
menu "Audio Output"
choice OUTPUT_TYPE
prompt "Output Type"
default DACAUDIO
help
Type of output for squeezelite to send audio to
config DACAUDIO
bool "DAC over I2S"
config BTAUDIO
bool "Bluetooth A2DP"
endchoice
config A2DP_SINK_NAME
string "Name of Bluetooth A2DP device"
depends on BTAUDIO
default "SMSL BT4.2"
help
This is the name of the bluetooth speaker that Squeezelite will try connecting to.
config A2DP_DEV_NAME
string "Name of Squeezelite device to use when connecting to A2DP device"
depends on BTAUDIO
default "Squeezelite"
help
This is the name of the device that the Bluetooth speaker will see when it is connected to.
endmenu
endmenu

View File

@@ -1,5 +1,6 @@
#include <signal.h>
#include "sdkconfig.h"
#include "esp_system.h"
#include "squeezelite.h"
@@ -22,24 +23,38 @@ struct codec *register_mpg(void) {
return NULL;
}
#ifndef CONFIG_AUDIO_FAAD
#if !CONFIG_INCLUDE_FAAD
struct codec *register_faad(void) {
LOG_INFO("aac unavailable");
return NULL;
}
#endif
#ifndef CONFIG_AUDIO_MAD
#if !CONFIG_INCLUDE_MAD
struct codec *register_mad(void) {
LOG_INFO("mad unavailable");
return NULL;
}
#endif
#ifndef CONFIG_AUDIO_FLAC
#if !CONFIG_INCLUDE_FLAC
struct codec *register_flac(void) {
LOG_INFO("flac unavailable");
return NULL;
}
#endif
#if !CONFIG_INCLUDE_VORBIS
struct codec *register_vorbis(void) {
LOG_INFO("vorbis unavailable");
return NULL;
}
#endif
#if !CONFIG_INCLUDE_ALAC
struct codec *register_alac(void) {
LOG_INFO("alac unavailable");
return NULL;
}
#endif

View File

@@ -1,148 +0,0 @@
/* Scan Example
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.
*/
/*
This example shows how to use the All Channel Scan or Fast Scan to connect
to a Wi-Fi network.
In the Fast Scan mode, the scan will stop as soon as the first network matching
the SSID is found. In this mode, an application can set threshold for the
authentication mode and the Signal strength. Networks that do not meet the
threshold requirements will be ignored.
In the All Channel Scan mode, the scan will end only after all the channels
are scanned, and connection will start with the best network. The networks
can be sorted based on Authentication Mode or Signal Strength. The priority
for the Authentication mode is: WPA2 > WPA > WEP > Open
*/
#include "freertos/FreeRTOS.h"
#include "freertos/event_groups.h"
#include "esp_wifi.h"
#include "esp_log.h"
#include "esp_event.h"
#include "nvs_flash.h"
#include "sys/socket.h"
#include "string.h"
/*Set the SSID and Password via "make menuconfig"*/
#define DEFAULT_SSID CONFIG_WIFI_SSID
#define DEFAULT_PWD CONFIG_WIFI_PASSWORD
#if CONFIG_WIFI_ALL_CHANNEL_SCAN
#define DEFAULT_SCAN_METHOD WIFI_ALL_CHANNEL_SCAN
#elif CONFIG_WIFI_FAST_SCAN
#define DEFAULT_SCAN_METHOD WIFI_FAST_SCAN
#else
#define DEFAULT_SCAN_METHOD WIFI_FAST_SCAN
#endif /*CONFIG_SCAN_METHOD*/
#if CONFIG_WIFI_CONNECT_AP_BY_SIGNAL
#define DEFAULT_SORT_METHOD WIFI_CONNECT_AP_BY_SIGNAL
#elif CONFIG_WIFI_CONNECT_AP_BY_SECURITY
#define DEFAULT_SORT_METHOD WIFI_CONNECT_AP_BY_SECURITY
#else
#define DEFAULT_SORT_METHOD WIFI_CONNECT_AP_BY_SIGNAL
#endif /*CONFIG_SORT_METHOD*/
#if CONFIG_FAST_SCAN_THRESHOLD
#define DEFAULT_RSSI CONFIG_FAST_SCAN_MINIMUM_SIGNAL
#if CONFIG_EXAMPLE_OPEN
#define DEFAULT_AUTHMODE WIFI_AUTH_OPEN
#elif CONFIG_EXAMPLE_WEP
#define DEFAULT_AUTHMODE WIFI_AUTH_WEP
#elif CONFIG_EXAMPLE_WPA
#define DEFAULT_AUTHMODE WIFI_AUTH_WPA_PSK
#elif CONFIG_EXAMPLE_WPA2
#define DEFAULT_AUTHMODE WIFI_AUTH_WPA2_PSK
#else
#define DEFAULT_AUTHMODE WIFI_AUTH_OPEN
#endif
#else
#define DEFAULT_RSSI -127
#define DEFAULT_AUTHMODE WIFI_AUTH_OPEN
#endif /*CONFIG_FAST_SCAN_THRESHOLD*/
static const char *TAG = "scan";
static void event_handler(void* arg, esp_event_base_t event_base,
int32_t event_id, void* event_data)
{
if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) {
esp_wifi_connect();
} else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) {
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, "got ip: %s", ip4addr_ntoa(&event->ip_info.ip));
}
}
/* Initialize Wi-Fi as sta and set scan method */
static void wifi_scan(void)
{
tcpip_adapter_init();
ESP_ERROR_CHECK(esp_event_loop_create_default());
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
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));
wifi_config_t wifi_config = {
.sta = {
.ssid = DEFAULT_SSID,
.password = DEFAULT_PWD,
.scan_method = DEFAULT_SCAN_METHOD,
.sort_method = DEFAULT_SORT_METHOD,
.threshold.rssi = DEFAULT_RSSI,
.threshold.authmode = DEFAULT_AUTHMODE,
},
};
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());
}
int main(int argc, char**argv);
void app_main()
{
int i;
char **argv, *_argv[] = {
"squeezelite-esp32",
"-C",
"1",
"-n",
"ESP32",
"-d",
"all=info",
"-b",
"256:2000",
};
// can't do strtok on FLASH strings
argv = malloc(sizeof(_argv));
for (i = 0; i < sizeof(_argv)/sizeof(char*); i++) {
argv[i] = strdup(_argv[i]);
}
// Initialize NVS
esp_err_t ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
ESP_ERROR_CHECK( ret );
wifi_scan();
main(sizeof(_argv)/sizeof(char*), argv);
}

View File

@@ -270,7 +270,11 @@
#include <arpa/inet.h>
#include <sys/time.h>
#include <sys/socket.h>
#if POSIX
#include <sys/poll.h>
#else
#include <poll.h>
#endif
#if !LINKALL
#include <dlfcn.h>
#endif