Compare commits

...

17 Commits

Author SHA1 Message Date
Sébastien
ede495a145 Added workflow build badge to readme - release 2020-11-17 14:27:48 -05:00
Sebastien
c82ae71726 Merge remote-tracking branch 'origin/master-cmake' into master-cmake 2020-11-17 14:00:57 -05:00
Sebastien
cd13577d93 Reduce system load when loading HTTP UI - release 2020-11-17 13:58:19 -05:00
Sébastien
1d24543359 Update Cross build with build-number@v3 - release 2020-11-17 13:42:34 -05:00
Sebastien
08f04187ae Reduce system load when loading HTTP UI - release 2020-11-17 11:41:03 -05:00
Sebastien
8fbe1159f5 Reworking BT output 2020-11-03 17:54:31 -05:00
philippe44
2c64f50093 Update README.md 2020-10-31 22:19:54 -07:00
philippe44
cb646284c6 Update README.md 2020-10-31 22:14:45 -07:00
Sébastien
72c4f810fb Release Philippe's BT fixes 2020-10-29 07:12:24 -04:00
Philippe G
6170f49673 Merge branch 'master-cmake' of https://github.com/sle118/squeezelite-esp32 into master-cmake 2020-10-28 22:38:49 -07:00
Philippe G
d486a99aa1 more BT fixes - release 2020-10-28 22:38:39 -07:00
Sébastien
f0bd81125b Update build badge-release 2020-10-28 21:12:41 -04:00
Philippe G
251882a400 Merge branch 'master-cmake' of https://github.com/sle118/squeezelite-esp32 into master-cmake 2020-10-28 17:46:55 -07:00
Philippe G
0503d03e64 fix BT source - release 2020-10-28 17:46:46 -07:00
Sebastien
fed98f470f Merge remote-tracking branch 'origin/master-cmake' into master-cmake 2020-10-28 20:40:07 -04:00
Sebastien
95d4dbc905 update Docker image for the build 2020-10-28 20:39:11 -04:00
Sebastien
54b9da287f update Docker image for the build 2020-10-28 18:23:22 -04:00
34 changed files with 3897 additions and 878 deletions

View File

@@ -17,7 +17,7 @@ jobs:
steps:
- name: Generate common build number
id: buildnumber
uses: einaregilsson/build-number@v2
uses: einaregilsson/build-number@v3
with:
token: ${{secrets.github_token}}
build:
@@ -38,9 +38,9 @@ jobs:
submodules: true
- name: Cache build
id: cache-build
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{github.workspace}}/build
path: build
key: ${{ runner.os }}-${{ matrix.node }}
- name: Set build parameters
run: |
@@ -49,11 +49,11 @@ jobs:
branch_name="${branch_name//[^a-zA-Z0-9\-~!@_\.]/}"
BUILD_NUMBER=${{ needs.job1.outputs.build_number }}
echo "BUILD_NUMBER=${BUILD_NUMBER}" >> $GITHUB_ENV
tag="${TARGET_BUILD_NAME}-development-${BUILD_NUMBER}-${branch_name}"
tag="${TARGET_BUILD_NAME}.${BUILD_NUMBER}.${branch_name}"
echo "tag=${tag}" >> $GITHUB_ENV
last_commit="$(git log --pretty=format:'%s' --max-count=1)"
if [[ "$last_commit" =~ .*"Release".* ]]; then echo "release_flag=1" >> $GITHUB_ENV; else echo "release_flag=0" >> $GITHUB_ENV; fi
name="development.${BUILD_NUMBER}#v4.0#${TARGET_BUILD_NAME}#${branch_name}"
name="dev.${BUILD_NUMBER}#v4.0#${TARGET_BUILD_NAME}#${branch_name}"
artifact_prefix="squeezelite-esp32-${branch_name}-${TARGET_BUILD_NAME}-${build_version_prefix}${BUILD_NUMBER}"
artifact_file_name="${artifact_prefix}.zip"
artifact_bin_file_name="${artifact_prefix}.bin"
@@ -80,7 +80,7 @@ jobs:
run: |
env | grep "artifact\|tag\|GITHUB\|version\|NUMBER\|TARGET" >${TARGET_BUILD_NAME}-env.txt
echo "${tag}" >version.txt
docker run --env-file=${TARGET_BUILD_NAME}-env.txt --rm -v $PWD:/project -w /project espressif/idf:release-v4.0 /bin/bash -c "cp build-scripts/${TARGET_BUILD_NAME}-sdkconfig.defaults sdkconfig && idf.py build && zip build/${artifact_file_name} partitions*.csv build/*.bin build/bootloader/bootloader.bin build/partition_table/partition-table.bin build/flash_project_args build/size_*.txt"
docker run --env-file=${TARGET_BUILD_NAME}-env.txt --rm -v $PWD:/project -w /project sle118/squeezelite-esp32:release-v4.0 /bin/bash -c "cp build-scripts/${TARGET_BUILD_NAME}-sdkconfig.defaults sdkconfig && idf.py build && zip build/${artifact_file_name} partitions*.csv build/*.bin build/bootloader/bootloader.bin build/partition_table/partition-table.bin build/flash_project_args build/size_*.txt"
# - name: Build Mock firmware
# run: |
# mkdir -p build
@@ -124,6 +124,7 @@ jobs:
draft: false
prerelease: true
- name: Upload Release Asset - Squeezelite binary file
if: env.release_flag == 1
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
@@ -134,6 +135,7 @@ jobs:
asset_name: ${{ env.artifact_bin_file_name }}
asset_content_type: application/octet-stream
- name: Upload Release Asset - Zip file
if: env.release_flag == 1
id: upload-release-asset-zip
uses: actions/upload-release-asset@v1
env:

2502
.gitignore vendored

File diff suppressed because it is too large Load Diff

View File

@@ -1,15 +1,11 @@
cmake_minimum_required(VERSION 3.5)
set(EXTRA_COMPONENT_DIRS components/platform_console/app_recovery components/platform_console/app_squeezelite )
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
add_definitions(-DbSqueezeESP32)
add_definitions(-DMODEL_NAME=SqueezeESP32)
message(STATUS "Building RECOVERY")
project(recovery)
set_property(TARGET recovery.elf PROPERTY RECOVERY_PREFIX app_recovery )
include(squeezelite.cmake)
set(PROJECT_VER $ENV{PROJECT_VER})
#target_compile_definitions(__idf_squeezelite-ota PRIVATE DLOG_LOCAL_LEVEL=ESP_LOG_VERBOSE)
#target_compile_definitions(__idf_driver_bt PRIVATE DLOG_LOCAL_LEVEL=ESP_LOG_VERBOSE)
#target_compile_definitions(__idf_squeezelite-ota PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_VERBOSE)
#target_compile_definitions(__idf_driver_bt PRIVATE -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG)

279
README.md
View File

@@ -1,13 +1,46 @@
![SqueezeAmp-master-cmake](https://github.com/sle118/squeezelite-esp32/workflows/SqueezeAmp/badge.svg?branch=master-cmake)
![I2S-4MFlash-master-cmake](https://github.com/sle118/squeezelite-esp32/workflows/I2S-4MFlash/badge.svg?branch=master-cmake)
![ESP32-A1S-master-cmake](https://github.com/sle118/squeezelite-esp32/workflows/ESP32-A1S/badge.svg?branch=master-cmake)
![Cross-Build](https://github.com/sle118/squeezelite-esp32/workflows/Cross-Build/badge.svg?branch=master-cmake)
# Squeezelite-esp32
## Supported Hardware
### SqueezeAMP
Works with the SqueezeAMP see [here](https://forums.slimdevices.com/showthread.php?110926-pre-ANNOUNCE-SqueezeAMP-and-SqueezeliteESP32) and [here](https://github.com/philippe44/SqueezeAMP/blob/master/README.md). Add repository https://raw.githubusercontent.com/sle118/squeezelite-esp32/master/plugin/repo.xml to LMS if you want to have a display
## What is this
Squeezelite-esp32 is an audio software suite made to run on espressif's ESP32 wifi (b/g/n) and bluetooth chipset. It offers the following capabilities
Use the `squeezelite-esp32-SqueezeAmp-sdkconfig.defaults` configuration file.
- Stream your local music and connect to all major on-line music providers (Spotify, Deezer, Tidal, Qobuz) using [Logitech Media Server - a.k.a LMS](https://forums.slimdevices.com/) and enjoy multi-room audio synchronization. LMS can be extended by numerous plugins and can be controlled using a Web browser or dedicated applications (iPhone, Android). It can also send audio to UPnP, Sonos, ChromeCast and AirPlay speakers/devices.
- Stream from a Bluetooth device (iPhone, Android)
- Stream from an AirPlay controller (iPhone, iTunes ...) and enjoy synchronization multiroom as well (although it's AirPlay 1 only)
Depending on the hardware connected to the ESP32, you can send audio to a local DAC, to SPDIF or to a Bluetooth speaker. The bare minimum required hardware is a WROVER module with 4MB of Flash and 4MB of PSRAM (https://www.espressif.com/en/products/modules/esp32). With that module standalone, just apply power and you can stream to a Bluetooth speaker. You can also send audio to most I2S DAC as well as to SPDIF receivers using just a cable or an optical transducer (you'll need *one* resistor...)
But squeezelite-esp32 is highly extensible and you can add
- Buttons and Rotary Encoder and map/combine them to various functions (play, pause, volume, next ...)
- IR receiver (no pullup resistor or capacitor needed, just the 38kHz receiver)
- Monochrome, GrayScale or Color displays using SPI or I2S (supported drivers are SH1106, SSD1306, SSD1322, SSD1326/7, SSD1351, ST7735 and ST7789).
Other features include
- Resampling
- 10-bands equalizer
- Automatic initial setup using any WiFi device
- Full web interface for further configuration/management
- Firmware over-the-air update
## Supported Hardware
Any esp32-based hardware with at least 4MB of flash and 4MB of PSRAM will be capable of running squeezelite-esp32 and there are various boards that include such chip. A few are mentionned below, but any should work.
### Raw WROVER module
Per above description, a [WROVER module](https://www.espressif.com/en/products/modules/esp32) is enough to run Squeezelite-esp32, but that requires a bit of tinkering to extend it to have analogue audio or hardware buttons (e.g.)
Please note that when sending to a Bluetooth speaker, then resampling *must* be enabled (using -R) option if you want to send audio with rate other than 44.1kHz. Similarly, when using SPDIF, only 44.1kHz and 48kHz are supported so you might have to enable resampling as well. If you connect a DAC, choice will depends on its capabilities. See below for more details.
Most DAC will work out-of-the-box with simply an I2S connection, but some require specific commands to be sent using I2C. See DAC option below to understand how to send these dedicated commands. There is build-in support for TAS575x, TAS5780, TAS5713 and AC101 DAC.
### SqueezeAMP
This is the main hardware companion of Squeezelite-esp32 and has been developped together. Details on capabilities can be found [here](https://forums.slimdevices.com/showthread.php?110926-pre-ANNOUNCE-SqueezeAMP-and-SqueezeliteESP32) and [here](https://github.com/philippe44/SqueezeAMP).
if you want to rebuild, use the `squeezelite-esp32-SqueezeAmp-sdkconfig.defaults` configuration file.
NB: You can use the pre-build binaries SqueezeAMP4MBFlash which has all the hardware I/O set properly. You can also use the generic binary I2S4MBFlash in which case the NVS parameters shall be set to get the exact same behavior
- set_GPIO: 12=green,13=red,34=jack,2=spkfault
- batt_config: channel=7,scale=20.24
- dac_config: model=TAS57xx,bck=33,ws=25,do=32,sda=27,scl=26,mute=14:0
- spdif_config: bck=33,ws=25,do=15
### ESP32-A1S
Works with [ESP32-A1S](https://docs.ai-thinker.com/esp32-a1s) module that includes audio codec and headset output. You still need to use a demo board like [this](https://www.aliexpress.com/item/4000765857347.html?spm=2114.12010615.8148356.11.5d963cd0j669ns) or an external amplifier if you want direct speaker connection.
@@ -22,11 +55,18 @@ The board showed above has the following IO set
So a possible config would be
- set_GPIO: 21=amp,22=green:0,39=jack:0
- dac_config: model=AC101,bck=27,ws=26,do=25,di=35,sda=33,scl=32
- a button mapping:
```
[{"gpio":5,"normal":{"pressed":"ACTRLS_TOGGLE"}},{"gpio":18,"pull":true,"shifter_gpio":5,"normal":{"pressed":"ACTRLS_VOLUP"}, "shifted":{"pressed":"ACTRLS_NEXT"}}, {"gpio":23,"pull":true,"shifter_gpio":5,"normal":{"pressed":"ACTRLS_VOLDOWN"},"shifted":{"pressed":"ACTRLS_PREV"}}]
```
### T-WATCH2020 by LilyGo
This is a fun [smartwatch](http://www.lilygo.cn/prod_view.aspx?TypeId=50036&Id=1290&FId=t3:50036:3) based on ESP32. It has a 240x240 ST7789 screen and onboard audio. Not very useful to listen to anything but it works. This is an example of a device that requires an I2C set of commands for its dac (see below). There is a build-option if you decide to rebuild everything by yourself, otherwise the I2S default option works with the following parameters
- dac_config: model=I2S,bck=26,ws=25,do=33,i2c=106,sda=21,scl=22
- dac_controlset: { "init": [ {"reg":41, "val":128}, {"reg":18, "val":255} ], "poweron": [ {"reg":18, "val":64, "mode":"or"} ], "poweroff": [ {"reg":18, "val":191, "mode":"and"} ] }
- spi_config: dc=27,data=19,clk=18
- display_config: SPI,driver=ST7789,width=240,height=240,cs=5,back=12,speed=16000000,HFlip,VFlip
### ESP32-WROVER + I2S DAC
Squeezelite-esp32 requires esp32 chipset and 4MB PSRAM. ESP32-WROVER meets these requirements. To get an audio output an I2S DAC can be used. Cheap PCM5102 I2S DACs work others may also work. PCM5012 DACs can be hooked up via:
@@ -45,6 +85,10 @@ XMT - 3.3V
Use the `squeezelite-esp32-I2S-4MFlash-sdkconfig.defaults` configuration file.
### SqueezeAmpToo !
And the super cool project https://github.com/rochuck/squeeze-amp-too
## Configuration
To access NVS, in the webUI, go to credits and select "shows nvs editor". Go into the NVS editor tab to change NFS parameters. In syntax description below \<\> means a value while \[\] describe optional parameters.
@@ -57,12 +101,23 @@ sda=<gpio>,scl=<gpio>[,port=0|1][,speed=<speed>]
The NVS parameter "spi_config" set the spi's gpio used for generic purpose (e.g. display). Leave it blank to disable SPI usage. The DC parameter is needed for displays. Syntax is
```
data=<gpio>,clk=<gpio>[,dc=<gpio>][,host=1|2]
```
```
### DAC/I2S
The NVS parameter "dac_config" set the gpio used for i2s communication with your DAC. You can define the defaults at compile time but nvs parameter takes precedence except for SqueezeAMP and A1S where these are forced at runtime. If your DAC also requires i2c, then you must go the re-compile route. Syntax is
```
bck=<gpio>,ws=<gpio>,do=<gpio>
bck=<gpio>,ws=<gpio>,do=<gpio>[,mute=<gpio>[:0|1][,model=TAS57xx|TAS5713|AC101|I2S][,sda=<gpio>,scl=gpio[,i2c=<addr>]]
```
if "model" is not set or is not recognized, then default "I2S" is used. I2C parameters are optional an only needed if your dac requires an I2C control (See 'dac_controlset' below). Note that "i2c" parameters are decimal, hex notation is not allowed.
The parameter "dac_controlset" allows definition of simple commands to be sent over i2c for init, power on and off using a JSON syntax:
```
{ init: [ {"reg":<register>,"val":<value>,"mode":<nothing>|"or"|"and"}, ... {{"reg":<register>,"val":<value>,"mode":<nothing>|"or"|"and"} ],
poweron: [ {"reg":<register>,"val":<value>,"mode":<nothing>|"or"|"and"}, ... {{"reg":<register>,"val":<value>,"mode":<nothing>|"or"|"and"} ],
poweroff: [ {"reg":<register>,"val":<value>,"mode":<nothing>|"or"|"and"}, ... {{"reg":<register>,"val":<value>,"mode":<nothing>|"or"|"and"} ] }
```
This is standard JSON notation, so if you are not familiar with it, Google is your best friend. Be aware that the '...' means you can have as many entries as you want, it's not part of the syntax. Every section is optional, but it does not make sense to set i2c in the 'dac_config' parameter and not setting anything here. The parameter 'mode' allows to *or* the register with the value or to *and* it. Don't set 'mode' if you simply want to write. **Note that all values must be decimal**. You can use a validator like [this](https://jsonlint.com) to verify your syntax
NB: For well-known configuration, this is ignored
### SPDIF
The NVS parameter "spdif_config" sets the i2s's gpio needed for SPDIF.
@@ -74,16 +129,29 @@ Leave it blank to disable SPDIF usage, you can also define them at compile time
```
bck=<gpio>,ws=<gpio>,do=<gpio>
```
NB: For well-known configuration, this is ignored
### Display
The NVS parameter "display_config" sets the parameters for an optional display. Syntax is
```
I2C,width=<pixels>,height=<pixels>[address=<i2c_address>][,HFlip][,VFlip][driver=SSD1306|SSD1326|SH1106]
SPI,width=<pixels>,height=<pixels>,cs=<gpio>[,speed=<speed>][,HFlip][,VFlip][driver=SSD1306|SSD1326|SH1106]
I2C,width=<pixels>,height=<pixels>[address=<i2c_address>][,reset=<gpio>][,HFlip][,VFlip][driver=SSD1306|SSD1326[:1|4]|SSD1327|SH1106]
SPI,width=<pixels>,height=<pixels>,cs=<gpio>[,back=<gpio>][,reset=<gpio>][,speed=<speed>][,HFlip][,VFlip][driver=SSD1306|SSD1322|SSD1326[:1|4]|SSD1327|SH1106|SSD1675|ST7735|ST7789[,rotate]]
```
- back: a LED backlight used by some older devices (ST7735). It is PWM controlled for brightness
- reset: some display have a reset pin that is should normally be pulled up if unused
- VFlip and HFlip are optional can be used to change display orientation
- rotate: for non-square *drivers*, move to portrait mode. Note that *width* and *height* must be inverted then
- Default speed is 8000000 (8MHz) but SPI can work up to 26MHz or even 40MHz
- SH1106 is 128x64 monochrome I2C/SPI [here]((https://www.waveshare.com/wiki/1.3inch_OLED_HAT))
- SSD1306 is 128x32 monochrome I2C/SPI [here](https://www.buydisplay.com/i2c-blue-0-91-inch-oled-display-module-128x32-arduino-raspberry-pi)
- SSD1322 is 128x128 16-level grayscale SPI [here](https://www.amazon.com/gp/product/B079N1LLG8/ref=ox_sc_act_title_1?smid=A1N6DLY3NQK2VM&psc=1) - artwork can be up to 96x96 with vertical vu-meter/spectrum
- SSD1351 is 128x128 65k/262k color SPI [here](https://www.waveshare.com/product/displays/lcd-oled/lcd-oled-3/1.5inch-rgb-oled-module.htm)
- SSD1326 is 256x32 monochrome or grayscale 16-levels SPI [here](https://www.aliexpress.com/item/32833603664.html?spm=a2g0o.productlist.0.0.2d19776cyQvsBi&algo_pvid=c7a3db92-e019-4095-8a28-dfdf0a087f98&algo_expid=c7a3db92-e019-4095-8a28-dfdf0a087f98-1&btsid=0ab6f81e15955375483301352e4208&ws_ab_test=searchweb0_0,searchweb201602_,searchweb201603_)
- SSD1327 is 256x64 grayscale 16-levels SPI in multiple sizes [here](https://www.buydisplay.com/oled-display/oled-display-module?resolution=159) - it is very nice
- SSD1675 is an e-ink paper and is experimental as e-ink is really not suitable for LMS du to its very low refresh rate
- ST7735 is a 128x160 65k color SPI [here](https://www.waveshare.com/product/displays/lcd-oled/lcd-oled-3/1.8inch-lcd-module.htm). This needs a backlight control
- ST7789 is a 240x320 65k (262k not enabled) color SPI [here](https://www.waveshare.com/product/displays/lcd-oled/lcd-oled-3/2inch-lcd-module.htm). It also exist with 240x240 displays. See **rotate** for use in portrait mode
Currently 128x32/64 I2C and SPI display like [this](https://www.buydisplay.com/i2c-blue-0-91-inch-oled-display-module-128x32-arduino-raspberry-pi) and [this](https://www.waveshare.com/wiki/1.3inch_OLED_HAT) are supported
To use the display on LMS, add repository https://raw.githubusercontent.com/sle118/squeezelite-esp32/master/plugin/repo.xml. You will then be able to tweak how the vu-meter and spectrum analyzer are displayed, as well as size of artwork. You can also install the excellent plugin "Music Information Screen" which is super useful to tweak the layout.
The NVS parameter "metadata_config" sets how metadata is displayed for AirPlay and Bluetooth. Syntax is
```
@@ -95,8 +163,6 @@ The NVS parameter "metadata_config" sets how metadata is displayed for AirPlay a
- 'format' can contain free text and any of the 3 keywords %artist%, %album%, %title%. Using that format string, the keywords are replaced by their value to build the string to be displayed. Note that the plain text following a keyword that happens to be empty during playback of a track will be removed. For example, if you have set format=%artist% - %title% and there is no artist in the metadata then only <title> will be displayed not " - <title>".
You can install the excellent plugin "Music Information Screen" which is super useful to tweak the layout for these small displays.
### Infrared
You can use any IR receiver compatible with NEC protocol (38KHz). Vcc, GND and output are the only pins that need to be connected, no pullup, no filtering capacitor, it's a straight connection.
@@ -107,11 +173,11 @@ In AirPlay and Bluetooth mode, only these native remotes are supported, I've not
See "set GPIO" below to set the GPIO associated to infrared receiver (option "ir").
### Set GPIO
The parameter "set_GPIO" is use to assign GPIO to various functions.
The parameter "set_GPIO" is used to assign GPIO to various functions.
GPIO can be set to GND provide or Vcc at boot. This is convenient to power devices that consume less than 40mA from the side connector. Be careful because there is no conflict checks being made wrt which GPIO you're changing, so you might damage your board or create a conflict here.
The \<amp\> parameter can use used to assign a GPIO that will be set to 1 when playback starts. It will be reset to 0 when squeezelite becomes idle. The idle timeout is set on the squeezelite command line through -C \<timeout\>
The \<amp\> parameter can use used to assign a GPIO that will be set to active level (default 1) when playback starts. It will be reset when squeezelite becomes idle. The idle timeout is set on the squeezelite command line through -C \<timeout\>
If you have an audio jack that supports insertion (use :0 or :1 to set the level when inserted), you can specify which GPIO it's connected to. Using the parameter jack_mutes_amp allows to mute the amp when headset (e.g.) is inserted.
@@ -122,23 +188,36 @@ The \<ir\> parameter set the GPIO associated to an IR receiver. No need to add p
Syntax is:
```
<gpio>=Vcc|GND|amp|ir|jack[:0|1]|green[:0|1]|red[:0|1]|spkfault[:0|1][,<repeated sequence for next GPIO>]
<gpio>=Vcc|GND|amp[:1|0]|ir|jack[:0|1]|green[:0|1]|red[:0|1]|spkfault[:0|1][,<repeated sequence for next GPIO>]
```
You can define the defaults for jack, spkfault leds at compile time but nvs parameter takes precedence except for SqueezeAMP where these are forced at runtime.
You can define the defaults for jack, spkfault leds at compile time but nvs parameter takes precedence except for well-known configurations where these are forced at runtime.
### LED
See §**set_GPIO** for how to set the green and red LEDs. In addition, their brightness can be controlled using the "led_brigthness" parameter. The syntax is
```
[green=0..100][,red=0..100]
```
NB: For well-known configuration, this is ignored
### Rotary Encoder
One rotary encoder is supported, quadrature shift with press. Such encoders usually have 2 pins for encoders (A and B), and common C that must be set to ground and an optional SW pin for press. A, B and SW must be pulled up, so automatic pull-up is provided by ESP32, but you can add your own resistors. A bit of filtering on A and B (~470nF) helps for debouncing which is not made by software.
Encoder is normally hard-coded to respectively knob left, right and push on LMS and to volume down/up/play toggle on BT and AirPlay. Using the option 'volume' makes it hard-coded to volume down/up/play toggle all the time (even in LMS). The option 'longpress' allows an alternate mode when SW is long-pressed. In that mode, left is previous, right is next and press is toggle. Every long press on SW alternates between modes.
Encoder is normally hard-coded to respectively knob left, right and push on LMS and to volume down/up/play toggle on BT and AirPlay. Using the option 'volume' makes it hard-coded to volume down/up/play toggle all the time (even in LMS). The option 'longpress' allows an alternate mode when SW is long-pressed. In that mode, left is previous, right is next and press is toggle. Every long press on SW alternates between modes (the main mode actual behavior depends on 'volume').
There is also the possibility to use 'knobonly' option (exclusive with 'volume' and 'longpress'). This mode attempts to offer a single knob full navigation which is a bit contorded due to LMS UI's principles. Left, Right and Press obey to LMS's navigation rules and especially Press always goes to lower submenu item, even when navigating in the Music Library. That causes a challenge as there is no 'Play', 'Back' or 'Pause' button. Workaround are as of below:
- longpress is 'Play'
- double press is 'Back' (Left in LMS's terminology).
- a quick left-right movement on the encoder is 'Pause'
The speed of double click (or left-right) can be set using the optional parameter of 'knobonly'. This is not a perfect solution, and other ideas are welcome. Be aware that the longer you set double click speed, the less responsive the interface will be. The reason is that I need to wait for that delay before deciding if it's a single or double click. It can also make menu navigation "hesitations" being easoly interpreted as 'Pause'
Use parameter rotary_config with the following syntax:
```
A=<gpio>,B=<gpio>[,SW=gpio>[,volume][,longpress]]
A=<gpio>,B=<gpio>[,SW=gpio>[[,knobonly[=<ms>]|[,volume][,longpress]]
```
HW note: all gpio used for rotary have internal pull-up so normally there is no need to provide Vcc to the encoder. Nevertheless if the encoder board you're using also has its own pull-up that are stronger than ESP32's ones (which is likely the case), then there will be crosstalk between gpio, so you must bring Vcc. Look at your board schematic and you'll understand that these board pull-up create a "winning" pull-down when any other pin is grounded.
See also the "IMPORTANT NOTE" on the "Buttons" section
See also the "IMPORTANT NOTE" on the "Buttons" section and remember that when 'lms_ctrls_raw' (see below) is activated, none of these knobonly,volume,longpress options apply, raw button codes (not actions) are simply sent to LMS
### Buttons
Buttons are described using a JSON string with the following syntax
@@ -234,73 +313,46 @@ There is no good or bad option, it's your choice. Use the NVS parameter "lms_ctr
### Battery / ADC
The NVS parameter "bat_config" sets the ADC1 channel used to measure battery/DC voltage. Scale is a float ratio applied to every sample of the 12 bits ADC. A measure is taken every 10s and an average is made every 5 minutes (not a sliding window). Syntax is
```
channel=0..7,scale=<scale>
channel=0..7,scale=<scale>,cells=<2|3>
```
NB: Set parameter to empty to disable battery reading
## Setting up ESP-IDF
### Docker
#### **************** todo: Docker scripts needs some rework.
You can use docker to build squeezelite-esp32
First you need to build the Docker container:
```
docker build -t esp-idf .
```
Then you need to run the container:
```
docker run -i -t -v `pwd`:/workspace/squeezelite-esp32 esp-idf
```
The above command will mount this repo into the docker container and start a bash terminal
for you to then follow the below build steps
### Manual Install of ESP-IDF
Follow the instructions from https://docs.espressif.com/projects/esp-idf/en/v4.0/get-started/index.html to install the esp-idf v4.0. This is the currently supported release of the espressif software development system.
## Building Squeezelite-esp32
MOST IMPORTANT: create the right default config file
- make defconfig
(Note: You can also copy over config files from the build-scripts folder to ./sdkconfig)
Then adapt the config file to your wifi/BT/I2C device (can also be done on the command line)
- make menuconfig
Then
```
idf.py -p PORT [-b BAUD] flash
idf.py -p PORT [-b BAUD] monitor
```
NB: Set parameter to empty to disable battery reading. For well-known configuration, this is ignored (except for SqueezeAMP where number of cells is required)
# Configuration
1/ setup WiFi
## Setup WiFi
- Boot the esp, look for a new wifi access point showing up and connect to it. Default build ssid and passwords are "squeezelite"/"squeezelite".
- Once connected, navigate to 192.168.4.1
- Wait for the list of access points visible from the device to populate in the web page.
- Choose an access point and enter any credential as needed
- Once connection is established, note down the address the device received; this is the address you will use to configure it going forward
2/ setup squeezelite command line (optional)
## Setup squeezelite command line (optional)
At this point, the device should have disabled its built-in access point and should be connected to a known WiFi network.
- navigate to the address that was noted in step #1
- Using the list of predefined options, hoose the mode in which you want squeezelite to start
- Using the list of predefined options, choose the mode in which you want squeezelite to start
- Generate the command
- Add or change any additional command line option (for example player name, etc)
- Activate squeezelite execution: this tells the device to automatiaclly run the command at start
- Update the configuration
- click on the "start toggle" button. This will force a reboot.
- The toggle switch should be set to 'ON' to ensure that squeezelite is active after booting
- The toggle switch should be set to 'ON' to ensure that squeezelite is active after booting (you might have to fiddle with it a few times)
- You can enable accessto NVS parameters under 'credits'
3/ Updating Squeezelite
## Monitor
In addition of the esp-idf serial link monitor option, you can also enable a telnet server (see NVS parameters) where you'll have access to a ton of logs of what's happening inside the WROVER.
## Update Squeezelite
- From the firmware tab, click on "Check for Updates"
- Look for updated binaries
- Select a line
- Click on "Flash!"
- The system will reboot into recovery mode (if not already in that mode), wipe the squeezelite partition and download/flash the selected version
- You can choose a local file or have a local webserver
3/ Recovery
## Recovery
- From the firmware tab, click on the "Recovery" button. This will reboot the ESP32 into recovery, where additional configuration options are available from the NVS editor
# Additional command line notes, configured from the http configuration
## Additional configuration notes (from the Web UI)
The squeezelite options are very similar to the regular Linux ones. Differences are :
- the output is -o ["BT -n '<sinkname>' "] | [I2S]
@@ -316,12 +368,88 @@ See squeezlite command line, but keys options are
- Z <rate> : tell LMS what is the max sample rate supported before LMS resamples
- R (see above)
- r "<minrate>-<maxrate>"
- C <sec> : set timeout to switch off amp gpio
- W : activate WAV and AIFF header parsing
# Building everything yourself
## Setting up ESP-IDF
### Docker
You can use docker to build squeezelite-esp32 (optional)
First you need to build the Docker container:
```
docker build -t esp-idf .
```
Then you need to run the container:
```
docker run -i -t -v `pwd`:/workspace/squeezelite-esp32 esp-idf
```
The above command will mount this repo into the docker container and start a bash terminal
for you to then follow the below build steps
## Additional misc notes to do you build
### Manual Install of ESP-IDF
<strong>Currently the master branch of this project requires this [IDF](https://github.com/espressif/esp-idf/tree/28f1cdf5ed7149d146ad5019c265c8bc3bfa2ac9) with gcc 5.2 (toolschain dated 20181001)
If you want to use a more recent version of gcc and IDF (4.0 stable), move to cmake-master branch</strong>
You can install IDF manually on Linux or Windows (using the Subsystem for Linux) following the instructions at: https://www.instructables.com/id/ESP32-Development-on-Windows-Subsystem-for-Linux/
And then copying the i2s.c patch file from this repo over to the esp-idf folder
You also need to use esp-dsp recent version or at least make sure you have this patch https://github.com/espressif/esp-dsp/pull/12/commits/8b082c1071497d49346ee6ed55351470c1cb4264. As of this writing (08.2020), espressif has patched esp-dsp so this is no more needed
## Building Squeezelite-esp32
Don't forget the to choose one of the config files in build_scripts/ and rename it sdkconfig.defaults or sdkconfig as many important WiFi/BT options are set there. The codecs libraries will not be rebuilt by these scripts (it's a tedious process - see below)
### Using make (deprecated)
MOST IMPORTANT: create the right default config file
- make defconfig
(Note: You can also copy over config files from the build-scripts folder to ./sdkconfig)
Then adapt the config file to your wifi/BT/I2C device (can also be done on the command line)
- make menuconfig
Then
```
# Build recovery.bin, bootloader.bin, ota_data_initial.bin, partitions.bin
# force appropriate rebuild by touching all the files which may have a RECOVERY_APPLICATION specific source compile logic
find . \( -name "*.cpp" -o -name "*.c" -o -name "*.h" \) -type f -print0 | xargs -0 grep -l "RECOVERY_APPLICATION" | xargs touch
export PROJECT_NAME="recovery"
make -j4 all EXTRA_CPPFLAGS='-DRECOVERY_APPLICATION=1'
make flash
#
# Build squeezelite.bin
# Now force a rebuild by touching all the files which may have a RECOVERY_APPLICATION specific source compile logic
find . \( -name "*.cpp" -o -name "*.c" -o -name "*.h" \) -type f -print0 | xargs -0 grep -l "RECOVERY_APPLICATION" | xargs touch
export PROJECT_NAME="squeezelite"
make -j4 app EXTRA_CPPFLAGS='-DRECOVERY_APPLICATION=0'
python ${IDF_PATH}/components/esptool_py/esptool/esptool.py --chip esp32 --port ${ESPPORT} --baud ${ESPBAUD} --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0x150000 ./build/squeezelite.bin
# monitor serial output
make monitor
```
You can also manually download the recovery & initial boot
```
python ${IDF_PATH}/components/esptool_py/esptool/esptool.py --chip esp32 --port ${ESPPORT} --baud ${ESPBAUD} --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0xd000 ./build/ota_data_initial.bin 0x1000 ./build/bootloader/bootloader.bin 0x10000 ./build/recovery.bin 0x8000 ./build/partitions.bin
```
### Using cmake
Create you config using 'idf.py menuconfig' then build binaries using 'idf.py all'. It will build the recovery and the application (squeezelite) itself. See the recommended command to upload everything. Otherwise, if you just want to download squeezelite, do
```
python.exe <idf_path>\components\esptool_py\esptool\esptool.py -p COM<n> -b 921600 --before default_reset --after hard_reset write_flash --flash_mode dio --flash_size detect --flash_freq 80m 0x150000 build\squeezelite.bin
```
Use 'idf monitor' to monitor the application (see esp-idf documentation)
## Additional misc notes to do you build (kitchen sink)
- don't forget to set IDF_PATH, ESPPORT and ESPBAUD
- When initially cloning the repo, make sure you do it recursively. For example:
- git clone --recursive https://github.com/sle118/squeezelite-esp32.git
- If you have already cloned the repository and you are getting compile errors on one of the submodules (e.g. telnet), run the following git command in the root of the repository location
- git submodule update --init --recursive
- as of this writing, ESP-IDF has a bug int he way the PLL values are calculated for i2s, so you *must* use the i2s.c file in the patch directory
- misc compiler #define
- use no resampling or set RESAMPLE (soxr - but overloads CPU) or set RESAMPLE16 for fast fixed 16 bits resampling
- use LOOPBACK (mandatory)
- use BYTES_PER_FRAME=4 (8 is not fully functionnal)
- LINKALL (mandatory)
- NO_FAAD unless you want to us faad, which currently overloads the CPU
- TREMOR_ONLY (mandatory)
### codecs
- for codecs libraries, add -mlongcalls if you want to rebuild them, but you should not (use the provided ones in codecs/lib). if you really want to rebuild them, open an issue
- libmad, libflac (no esp's version), libvorbis (tremor - not esp's version), alac work
- libfaad does not really support real time, but if you want to try
- libfaad does not really support real time, but if you want to try (but using helixaac is a better option)
- -O3 -DFIXED_POINT -DSMALL_STACK
- change ac_link in configure and case ac_files, remove ''
- compiler but in cfft.c and cffti1, must disable optimization using
@@ -334,21 +462,4 @@ See squeezlite command line, but keys options are
- change ac_files to remove ''
- add DEPS_CFLAGS and DEPS_LIBS to avoid pkg-config to be required
- stack consumption can be very high with some codec variants, so set NONTHREADSAFE_PSEUDOSTACK and GLOBAL_STACK_SIZE=32000 and unset VAR_ARRAYS in config.h
- better use helixaac
- set IDF_PATH=/home/esp-idf
- set ESPPORT=COM9
- update flash partition size
- other compiler #define
- use no resampling or set RESAMPLE (soxr) or set RESAMPLE16 for fast fixed 16 bits resampling
- use LOOPBACK (mandatory)
- use BYTES_PER_FRAME=4 (8 is not fully functionnal)
- LINKALL (mandatory)
- NO_FAAD unless you want to us faad, which currently overloads the CPU
- TREMOR_ONLY (mandatory)
- When initially cloning the repo, make sure you do it recursively. For example:
- git clone --recursive https://github.com/sle118/squeezelite-esp32.git
- If you have already cloned the repository and you are getting compile errors on one of the submodules (e.g. telnet), run the following git command in the root of the repository location
- git submodule update --init --recursive
## Additional notes
Build will start migrating to github workflows
- libmad has been patched to avoid using a lot of stack and is not provided here. There is an issue with sync detection in 1.15.1b from where the original stack patch was done but since a few fixes have been made wrt sync detection. This 1.15.1b-10 found on debian fixes the issue where mad thinks it has reached sync but has not and so returns a wrong sample rate. It comes at the expense of 8KB (!) of code where a simple check in squeezelite/mad.c that next_frame[0] is 0xff and next_frame[1] & 0xf0 is 0xf0 does the trick ...

View File

@@ -180,13 +180,9 @@ CONFIG_BT_A2DP_ENABLE=y
# CONFIG_BT_SPP_ENABLED is not set
# CONFIG_BT_HFP_ENABLE is not set
CONFIG_BT_SSP_ENABLED=y
<<<<<<< HEAD
# CONFIG_BT_BLE_ENABLED is not set
CONFIG_BT_STACK_NO_LOG=y
=======
CONFIG_BT_BLE_ENABLED=n
CONFIG_BT_BLE_SMP_ENABLE=y
CONFIG_BT_STACK_NO_LOG=n
@@ -356,7 +352,6 @@ CONFIG_BT_LOG_BLUFI_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_BLUFI_TRACE_LEVEL=2
>>>>>>> refs/remotes/origin/master
CONFIG_BT_ACL_CONNECTIONS=4
CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST=y
CONFIG_BT_BLE_DYNAMIC_ENV_MEMORY=y
@@ -630,19 +625,7 @@ CONFIG_LWIP_MAX_SOCKETS=16
# CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set
CONFIG_LWIP_SO_REUSE=y
CONFIG_LWIP_SO_REUSE_RXTOALL=y
<<<<<<< HEAD
# CONFIG_LWIP_SO_RCVBUF is not set
# CONFIG_LWIP_IP_REASSEMBLY is not set
# CONFIG_LWIP_IP_FRAG is not set
# CONFIG_LWIP_STATS is not set
# CONFIG_LWIP_ETHARP_TRUST_IP_MAC is not set
=======
CONFIG_LWIP_IP_REASSEMBLY=y
>>>>>>> refs/remotes/origin/master
#CONFIG_LWIP_IP_REASSEMBLY is not set
CONFIG_LWIP_ESP_GRATUITOUS_ARP=y
CONFIG_LWIP_GARP_TMR_INTERVAL=60
CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32

View File

@@ -179,183 +179,10 @@ CONFIG_BT_A2DP_ENABLE=y
# CONFIG_BT_SPP_ENABLED is not set
# CONFIG_BT_HFP_ENABLE is not set
CONFIG_BT_SSP_ENABLED=y
<<<<<<< HEAD
# CONFIG_BT_BLE_ENABLED is not set
CONFIG_BT_STACK_NO_LOG=y
=======
CONFIG_BT_BLE_ENABLED=n
CONFIG_BT_BLE_SMP_ENABLE=y
CONFIG_BT_LOG_HCI_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_HCI_TRACE_LEVEL=2
CONFIG_BT_LOG_BTM_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_BTM_TRACE_LEVEL=2
CONFIG_BT_LOG_L2CAP_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_L2CAP_TRACE_LEVEL=2
CONFIG_BT_LOG_RFCOMM_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_RFCOMM_TRACE_LEVEL=2
CONFIG_BT_LOG_SDP_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_SDP_TRACE_LEVEL=2
CONFIG_BT_LOG_GAP_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_GAP_TRACE_LEVEL=2
CONFIG_BT_LOG_BNEP_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_BNEP_TRACE_LEVEL=2
CONFIG_BT_LOG_PAN_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_PAN_TRACE_LEVEL=2
CONFIG_BT_LOG_A2D_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_A2D_TRACE_LEVEL=2
CONFIG_BT_LOG_AVDT_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_AVDT_TRACE_LEVEL=2
CONFIG_BT_LOG_AVCT_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_AVCT_TRACE_LEVEL=2
CONFIG_BT_LOG_AVRC_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_AVRC_TRACE_LEVEL=2
CONFIG_BT_LOG_MCA_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_MCA_TRACE_LEVEL=2
CONFIG_BT_LOG_HID_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_HID_TRACE_LEVEL=2
CONFIG_BT_LOG_APPL_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_APPL_TRACE_LEVEL=2
CONFIG_BT_LOG_GATT_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_GATT_TRACE_LEVEL=2
CONFIG_BT_LOG_SMP_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_SMP_TRACE_LEVEL=2
CONFIG_BT_LOG_BTIF_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_BTIF_TRACE_LEVEL=2
CONFIG_BT_LOG_BTC_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_BTC_TRACE_LEVEL=2
CONFIG_BT_LOG_OSI_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_OSI_TRACE_LEVEL=2
CONFIG_BT_LOG_BLUFI_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_BLUFI_TRACE_LEVEL=2
>>>>>>> refs/remotes/origin/master
CONFIG_BT_STACK_NO_LOG=n
CONFIG_BT_ACL_CONNECTIONS=4
CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST=y
CONFIG_BT_BLE_DYNAMIC_ENV_MEMORY=y
@@ -507,11 +334,6 @@ CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=40
CONFIG_ESP32_WIFI_STATIC_TX_BUFFER=y
CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=0
CONFIG_ESP32_WIFI_STATIC_TX_BUFFER_NUM=12
# CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED is not set
# CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED is not set
CONFIG_ESP32_WIFI_NVS_ENABLED=y
CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0=y
@@ -633,19 +455,11 @@ CONFIG_LWIP_MAX_SOCKETS=16
# CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set
CONFIG_LWIP_SO_REUSE=y
CONFIG_LWIP_SO_REUSE_RXTOALL=y
<<<<<<< HEAD
# CONFIG_LWIP_SO_RCVBUF is not set
# CONFIG_LWIP_IP_FRAG is not set
# CONFIG_LWIP_IP_REASSEMBLY is not set
#CONFIG_LWIP_IP_REASSEMBLY is not set
# CONFIG_LWIP_STATS is not set
# CONFIG_LWIP_ETHARP_TRUST_IP_MAC is not set
=======
CONFIG_LWIP_IP_REASSEMBLY=y
>>>>>>> refs/remotes/origin/master
CONFIG_LWIP_ESP_GRATUITOUS_ARP=y
CONFIG_LWIP_GARP_TMR_INTERVAL=60
CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32

View File

@@ -180,183 +180,10 @@ CONFIG_BT_A2DP_ENABLE=y
# CONFIG_BT_SPP_ENABLED is not set
# CONFIG_BT_HFP_ENABLE is not set
CONFIG_BT_SSP_ENABLED=y
<<<<<<< HEAD
# CONFIG_BT_BLE_ENABLED is not set
CONFIG_BT_STACK_NO_LOG=y
=======
CONFIG_BT_STACK_NO_LOG=n
CONFIG_BT_BLE_ENABLED=n
CONFIG_BT_BLE_SMP_ENABLE=y
CONFIG_BT_LOG_HCI_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_HCI_TRACE_LEVEL=2
CONFIG_BT_LOG_BTM_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_BTM_TRACE_LEVEL=2
CONFIG_BT_LOG_L2CAP_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_L2CAP_TRACE_LEVEL=2
CONFIG_BT_LOG_RFCOMM_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_RFCOMM_TRACE_LEVEL=2
CONFIG_BT_LOG_SDP_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_SDP_TRACE_LEVEL=2
CONFIG_BT_LOG_GAP_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_GAP_TRACE_LEVEL=2
CONFIG_BT_LOG_BNEP_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_BNEP_TRACE_LEVEL=2
CONFIG_BT_LOG_PAN_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_PAN_TRACE_LEVEL=2
CONFIG_BT_LOG_A2D_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_A2D_TRACE_LEVEL=2
CONFIG_BT_LOG_AVDT_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_AVDT_TRACE_LEVEL=2
CONFIG_BT_LOG_AVCT_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_AVCT_TRACE_LEVEL=2
CONFIG_BT_LOG_AVRC_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_AVRC_TRACE_LEVEL=2
CONFIG_BT_LOG_MCA_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_MCA_TRACE_LEVEL=2
CONFIG_BT_LOG_HID_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_HID_TRACE_LEVEL=2
CONFIG_BT_LOG_APPL_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_APPL_TRACE_LEVEL=2
CONFIG_BT_LOG_GATT_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_GATT_TRACE_LEVEL=2
CONFIG_BT_LOG_SMP_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_SMP_TRACE_LEVEL=2
CONFIG_BT_LOG_BTIF_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_BTIF_TRACE_LEVEL=2
CONFIG_BT_LOG_BTC_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_BTC_TRACE_LEVEL=2
CONFIG_BT_LOG_OSI_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_OSI_TRACE_LEVEL=2
CONFIG_BT_LOG_BLUFI_TRACE_LEVEL_WARNING=y
CONFIG_BT_LOG_BLUFI_TRACE_LEVEL=2
>>>>>>> refs/remotes/origin/master
CONFIG_BT_ACL_CONNECTIONS=4
CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST=y
CONFIG_BT_BLE_DYNAMIC_ENV_MEMORY=y
@@ -630,19 +457,7 @@ CONFIG_LWIP_MAX_SOCKETS=16
# CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set
CONFIG_LWIP_SO_REUSE=y
CONFIG_LWIP_SO_REUSE_RXTOALL=y
<<<<<<< HEAD
# CONFIG_LWIP_SO_RCVBUF is not set
# CONFIG_LWIP_IP_FRAG is not set
# CONFIG_LWIP_IP_REASSEMBLY is not set
# CONFIG_LWIP_STATS is not set
# CONFIG_LWIP_ETHARP_TRUST_IP_MAC is not set
=======
CONFIG_LWIP_IP_REASSEMBLY=y
>>>>>>> refs/remotes/origin/master
#CONFIG_LWIP_IP_REASSEMBLY is not set
CONFIG_LWIP_ESP_GRATUITOUS_ARP=y
CONFIG_LWIP_GARP_TMR_INTERVAL=60
CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32

View File

@@ -7,7 +7,6 @@
*/
#include "bt_app_core.h"
#include <stdint.h>
#include "esp_system.h"
#include <string.h>

View File

@@ -15,9 +15,29 @@
#include <stdio.h>
#define BT_APP_CORE_TAG "BT_APP_CORE"
#define BT_APP_SIG_WORK_DISPATCH (0x01)
/* A2DP global state */
enum {
APP_AV_STATE_IDLE,
APP_AV_STATE_DISCOVERING,
APP_AV_STATE_DISCOVERED,
APP_AV_STATE_UNCONNECTED,
APP_AV_STATE_CONNECTING,
APP_AV_STATE_CONNECTED,
APP_AV_STATE_DISCONNECTING,
};
/* sub states of APP_AV_STATE_CONNECTED */
enum {
APP_AV_MEDIA_STATE_IDLE,
APP_AV_MEDIA_STATE_STARTING,
APP_AV_MEDIA_STATE_STARTED,
APP_AV_MEDIA_STATE_STOPPING,
APP_AV_MEDIA_STATE_WAIT_DISCONNECT
};
extern int bt_app_source_get_a2d_state();
extern int bt_app_source_get_media_state();
/**
* @brief handler for the dispatched work
*/

View File

@@ -63,6 +63,7 @@ static void bt_av_hdl_avrc_ct_evt(uint16_t event, void *p_param);
/* avrc TG event handler */
static void bt_av_hdl_avrc_tg_evt(uint16_t event, void *p_param);
static void volume_set_by_local_host(uint8_t volume);
static void bt_av_notify_evt_handler(uint8_t event_id, esp_avrc_rn_param_t *event_parameter);
static const char *s_a2d_conn_state_str[] = {"Disconnected", "Connecting", "Connected", "Disconnecting"};
static const char *s_a2d_audio_state_str[] = {"Suspended", "Stopped", "Started"};
@@ -378,7 +379,7 @@ static void bt_av_play_pos_changed(void)
}
}
void bt_av_notify_evt_handler(uint8_t event_id, esp_avrc_rn_param_t *event_parameter)
static void bt_av_notify_evt_handler(uint8_t event_id, esp_avrc_rn_param_t *event_parameter)
{
switch (event_id) {
case ESP_AVRC_RN_TRACK_CHANGE:

File diff suppressed because it is too large Load Diff

View File

@@ -23,6 +23,7 @@ const char * desc_squeezelite ="Squeezelite Options";
const char * desc_dac= "DAC Options";
const char * desc_spdif= "SPDIF Options";
const char * desc_audio= "General Audio Options";
const char * desc_bt_source= "Bluetooth Audio Output Options";
#define CODECS_BASE "flac|pcm|mp3|ogg"
@@ -59,7 +60,14 @@ const char * desc_audio= "General Audio Options";
#define CODECS CODECS_BASE CODECS_AAC CODECS_FF CODECS_DSD CODECS_MP3
#define NOT_OUTPUT "has input capabilities only"
#define NOT_GPIO "is not a GPIO"
typedef enum {
SEARCHING_FOR_BT,
SEARCHING_FOR_NAME,
SEARCHING_FOR_NAME_START,
SEARCHING_FOR_NAME_END,
SEARCHING_FOR_BT_CMD_END,
FINISHING
} parse_state_t;
static const char *TAG = "cmd_config";
extern struct arg_end *getParmsEnd(struct arg_hdr * * argtable);
//bck=<gpio>,ws=<gpio>,do=<gpio>[,mute=<gpio>[:0|1][,model=TAS57xx|TAS5713|AC101|I2S][,sda=<gpio>,scl=gpio[,i2c=<addr>]]
@@ -76,6 +84,15 @@ static struct {
struct arg_lit *clear;
struct arg_end *end;
} i2s_args;
static struct{
struct arg_str *sink_name;
struct arg_str *pin_code;
// struct arg_dbl *connect_timeout_delay;
// struct arg_dbl *control_delay;
struct arg_end *end;
} bt_source_args;
static struct {
struct arg_int *clock;
struct arg_int *wordselect;
@@ -155,7 +172,224 @@ int check_missing_parm(struct arg_int * int_parm, FILE * f){
}
return res;
}
char * strip_bt_name(char * opt_str)
{
char *result = malloc(strlen(opt_str)+1);
memset(result, 0x00, strlen(opt_str)+1);
char *str = strdup(opt_str);
const char * output_marker=" -o";
if(!result ){
ESP_LOGE(TAG,"Error allocating memory for result.");
return opt_str;
}
if(!str){
ESP_LOGE(TAG,"Error duplicating command line string.");
return opt_str;
}
bool quoted=false;
parse_state_t state = SEARCHING_FOR_BT;
char *start = strstr(str, output_marker);
if (start)
{
ESP_LOGV(TAG,"Found output option : %s\n",start);
start+=strlen(output_marker);
strncpy(result, str, (size_t)(start - str));
char * pch=strtok(start," ");
while(pch){
ESP_LOGV(TAG,"Current output: %s\n[%s]",result,pch);
switch (state)
{
case SEARCHING_FOR_BT:
if (strcasestr(pch, "BT") )
{
state = SEARCHING_FOR_NAME;
quoted=strcasestr(pch, "BT")!=NULL;
ESP_LOGV(TAG," - fount BT Start %s", quoted?"quoted":"");
}
else
{
ESP_LOGV(TAG," - Searching for BT, Ignoring");
}
strcat(result, " ");
strcat(result, pch);
break;
case SEARCHING_FOR_NAME:
if (strcasestr(pch, "name") || strcasestr(pch, "n"))
{
ESP_LOGV(TAG," - Found name tag");
state = SEARCHING_FOR_NAME_START;
}
else
{
strcat(result, " ");
strcat(result, pch);
ESP_LOGV(TAG," - Searching for name - added ");;
}
break;
case SEARCHING_FOR_NAME_START:
ESP_LOGV(TAG," - Name start");
state = SEARCHING_FOR_NAME_END;
break;
case SEARCHING_FOR_NAME_END:
if (strcasestr(pch, "\"")){
ESP_LOGV(TAG," - got quoted string");
state = FINISHING;
}
else if(pch[0]== '-'){
strcat(result, " ");
strcat(result, pch);
ESP_LOGV(TAG," - got parameter marker");
state = quoted?SEARCHING_FOR_BT_CMD_END:FINISHING;
}
else {
ESP_LOGV(TAG," - name continued");
}
break;
case SEARCHING_FOR_BT_CMD_END:
ESP_LOGV(TAG," - looking for quoted BT cmd end");
if (strcasestr(pch, "\"")){
ESP_LOGV(TAG," - got quote termination");
state = FINISHING;
}
strcat(result, " ");
strcat(result, pch);
break;
case FINISHING:
strcat(result, " ");
strcat(result, pch);
break;
default:
break;
}
pch = strtok(NULL, " ");
ESP_LOGV(TAG,"\n");
}
}
else
{
ESP_LOGE(TAG,"output option not found in %s\n",str);
strcpy(result,str);
}
ESP_LOGV(TAG,"Result commmand : %s\n", result);
free(str);
return result;
}
static int do_bt_source_cmd(int argc, char **argv){
esp_err_t err=ESP_OK;
int nerrors = arg_parse(argc, argv,(void **)&bt_source_args);
char *buf = NULL;
size_t buf_size = 0;
// char value[100] ={0};
FILE *f = open_memstream(&buf, &buf_size);
if (f == NULL) {
cmd_send_messaging(argv[0],MESSAGING_ERROR,"Unable to open memory stream.\n");
return 1;
}
if(nerrors >0){
arg_print_errors(f,bt_source_args.end,desc_bt_source);
return 1;
}
if(bt_source_args.sink_name->count >0){
err = config_set_value(NVS_TYPE_STR, "a2dp_sink_name", bt_source_args.sink_name->sval[0]);
if(err!=ESP_OK){
nerrors++;
fprintf(f,"Error setting Bluetooth audio device name %s. %s\n",bt_source_args.sink_name->sval[0], esp_err_to_name(err));
}
else {
fprintf(f,"Bluetooth audio device name changed to %s\n",bt_source_args.sink_name->sval[0]);
}
char * squeezelite_cmd = config_alloc_get_default(NVS_TYPE_STR, "autoexec1", NULL, 0);
if( squeezelite_cmd && strstr(squeezelite_cmd," -o ") ){
char * new_cmd = strip_bt_name(squeezelite_cmd);
if(strcmp(new_cmd,squeezelite_cmd)!=0){
fprintf(f,"Replacing old squeezelite command [%s] with [%s].\n",squeezelite_cmd,new_cmd);
config_set_value(NVS_TYPE_STR, "autoexec1", new_cmd);
if(err!=ESP_OK){
nerrors++;
fprintf(f,"Error updating squeezelite command line options . %s\n", esp_err_to_name(err));
}
}
free(squeezelite_cmd);
free(new_cmd);
}
}
if(bt_source_args.pin_code->count >0){
const char * v=bt_source_args.pin_code->sval[0];
bool bInvalid=false;
for(int i=0;i<strlen(v) && !bInvalid;i++){
if(v[i]<'0' || v[i]>'9'){
bInvalid=true;
}
}
if(bInvalid || strlen(bt_source_args.pin_code->sval[0])>16 || strlen(bt_source_args.pin_code->sval[0])<4){
nerrors++;
fprintf(f,"Pin code %s invalid. Should be numbers only with length between 4 and 16 characters. \n",bt_source_args.pin_code->sval[0]);
}
else {
err = config_set_value(NVS_TYPE_STR, "a2dp_spin", bt_source_args.pin_code->sval[0]);
if(err!=ESP_OK){
nerrors++;
fprintf(f,"Error setting Bluetooth source pin to %s. %s\n",bt_source_args.pin_code->sval[0], esp_err_to_name(err));
}
else {
fprintf(f,"Bluetooth source pin changed to %s\n",bt_source_args.pin_code->sval[0]);
}
}
}
// if(bt_source_args.connect_timeout_delay->count >0){
// snprintf(value,sizeof(value),"%d",(int)(bt_source_args.connect_timeout_delay->dval[0]*1000.0));
// if(bt_source_args.connect_timeout_delay->dval[0] <0.5 || bt_source_args.connect_timeout_delay->dval[0] >5.0){
// nerrors++;
// fprintf(f,"Invalid connection timeout %0.0f (%s milliseconds). Value must be between 0.5 sec and 5 sec.\n", bt_source_args.connect_timeout_delay->dval[0], value );
// }
// else {
// err = config_set_value(NVS_TYPE_STR, "a2dp_ctmt", value);
// if(err!=ESP_OK){
// nerrors++;
// fprintf(f,"Error setting connection timeout %0.0f sec (%s milliseconds). %s\n", bt_source_args.connect_timeout_delay->dval[0],value, esp_err_to_name(err));
// }
// else {
// fprintf(f,"Connection timeout changed to %0.0f sec (%s milliseconds)\n",bt_source_args.connect_timeout_delay->dval[0],value);
// }
// }
// }
// if(bt_source_args.control_delay->count >0){
// snprintf(value,sizeof(value),"%d",(int)(bt_source_args.control_delay->dval[0]*1000.0));
// if(bt_source_args.control_delay->dval[0] <0.1 || bt_source_args.control_delay->dval[0] >2.0){
// nerrors++;
// fprintf(f,"Invalid control delay %0.0f (%s milliseconds). Value must be between 0.1s and 2s.\n", bt_source_args.control_delay->dval[0], value );
// }
// else {
// err = config_set_value(NVS_TYPE_STR, "a2dp_ctrld", value);
// if(err!=ESP_OK){
// nerrors++;
// fprintf(f,"Error setting control delay to %0.0f sec (%s milliseconds). %s\n",bt_source_args.control_delay->dval[0],value, esp_err_to_name(err));
// }
// else {
// fprintf(f,"Control delay changed to %0.0f sec (%s milliseconds)\n",bt_source_args.control_delay->dval[0],value);
// }
// }
// }
if(!nerrors ){
fprintf(f,"Done.\n");
}
fflush (f);
cmd_send_messaging(argv[0],nerrors>0?MESSAGING_ERROR:MESSAGING_INFO,"%s", buf);
fclose(f);
FREE_AND_NULL(buf);
return (nerrors==0 && err==ESP_OK)?0:1;
}
static int do_audio_cmd(int argc, char **argv){
esp_err_t err=ESP_OK;
int nerrors = arg_parse(argc, argv,(void **)&audio_args);
@@ -399,6 +633,30 @@ cJSON * audio_cb(){
FREE_AND_NULL(p);
return values;
}
cJSON * bt_source_cb(){
cJSON * values = cJSON_CreateObject();
char * p = config_alloc_get_default(NVS_TYPE_STR, "a2dp_sink_name", NULL, 0);
if(p){
cJSON_AddStringToObject(values,"sink_name",p);
}
FREE_AND_NULL(p);
// p = config_alloc_get_default(NVS_TYPE_STR, "a2dp_ctmt", NULL, 0);
// if(p){
// cJSON_AddNumberToObject(values,"connect_timeout_delay",((double)atoi(p)/1000.0));
// }
// FREE_AND_NULL(p);
p = config_alloc_get_default(NVS_TYPE_STR, "a2dp_spin", "0000", 0);
if(p){
cJSON_AddStringToObject(values,"pin_code",p);
}
FREE_AND_NULL(p);
// p = config_alloc_get_default(NVS_TYPE_STR, "a2dp_ctrld", NULL, 0);
// if(p){
// cJSON_AddNumberToObject(values,"control_delay",((double)atoi(p)/1000.0));
// }
// FREE_AND_NULL(p);
return values;
}
void get_str_parm_json(struct arg_str * parm, cJSON * entry){
@@ -541,6 +799,24 @@ static void register_i2s_config(void){
ESP_ERROR_CHECK(esp_console_cmd_register(&cmd));
}
static void register_bt_source_config(void){
bt_source_args.sink_name= arg_str1("n","sink_name", "name","Bluetooth audio device name. This applies when output mode is Bluetooth");
bt_source_args.pin_code= arg_str1("p","pin_code", "pin","Bluetooth security/pin code. Usually 0000. This applies when output mode is Bluetooth");
// bt_source_args.control_delay= arg_dbl0("d","control_delay","seconds","Control response delay, in seconds. This determines the response time of the system Bluetooth events. The default value should work for the majority of cases and changing this could lead to instabilities.");
// bt_source_args.connect_timeout_delay= arg_dbl0("t","connect_timeout_delay","seconds","Connection timeout. Determines the maximum amount of time, in seconds, that the system will wait when connecting to a bluetooth device. Beyond this delay, a new connect attempt will be made.");
bt_source_args.end= arg_end(1);
const esp_console_cmd_t cmd = {
.command = CFG_TYPE_AUDIO("bt_source"),
.help = desc_bt_source,
.hint = NULL,
.func = &do_bt_source_cmd,
.argtable = &bt_source_args
};
cmd_to_json_with_cb(&cmd,&bt_source_cb);
ESP_ERROR_CHECK(esp_console_cmd_register(&cmd));
}
static void register_audio_config(void){
audio_args.jack_behavior = arg_str0("j", "jack_behavior","Headphones|Subwoofer","On supported DAC, determines the audio jack behavior. Selecting headphones will cause the external amp to be muted on insert, while selecting Subwoofer will keep the amp active all the time.");
@@ -616,6 +892,7 @@ static void register_squeezelite_config(void){
void register_config_cmd(void){
register_audio_config();
// register_squeezelite_config();
register_bt_source_config();
register_i2s_config();
register_spdif_config();
}

View File

@@ -33,7 +33,10 @@
#include "platform_console.h"
#include "trace.h"
#ifdef CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
#pragma message("Runtime stats enabled")
#define WITH_TASKS_INFO 1
#else
#pragma message("Runtime stats disabled")
#endif
static struct {
struct arg_str *scanmode;

View File

@@ -38,7 +38,7 @@
static const char *TAG = "services";
const char *i2c_name_type="I2C";
const char *spi_name_type="SPI";
static cJSON * gpio_list=NULL;
cJSON * gpio_list=NULL;
#define min(a,b) (((a) < (b)) ? (a) : (b))
#ifndef QUOTE
#define QUOTE(name) #name
@@ -392,6 +392,80 @@ const i2c_config_t * config_i2c_get(int * i2c_port) {
return &i2c;
}
/****************************************************************************************
*
*/
const gpio_with_level_t * get_gpio_struct_member(const char * nvs_item, const char * name){
static gpio_with_level_t gpio_member={
.gpio=-1,
.level=0
};
if(!nvs_item) return &gpio_member;
const char * p=nvs_item;
char type[20]={0};
int match=0;
do {
if ((match=sscanf(p, "%d=%19[^,:]:%d", &gpio_member.gpio, type,&gpio_member.level)) >0 && (GPIO_IS_VALID_GPIO(gpio_member.gpio) || gpio_member.gpio==GPIO_NUM_NC) && strcasestr(type,name)){
return &gpio_member;
}
p = strchr(p, ',');
} while (p++);
gpio_member.gpio=-1;
gpio_member.level=0;
return &gpio_member;
}
#define HANDLE_GPIO_STRUCT_MEMBER(name,fixval) memcpy(&gpio_struct.name, get_gpio_struct_member(nvs_item, QUOTE(name)), sizeof(gpio_struct.name)); gpio_struct.name.fixed=fixval
#define ADD_GPIO_STRUCT_MEMBER_TO_ARRAY(array,structvar,name,type) if(((set_GPIO_struct_t *)structvar)->name.gpio>=0){cJSON_AddItemToArray(array,get_gpio_entry(QUOTE(name),type,((set_GPIO_struct_t *)structvar)->name.gpio, ((set_GPIO_struct_t *)structvar)->name.fixed));}
/****************************************************************************************
*
*/
const set_GPIO_struct_t * get_gpio_struct(){
static set_GPIO_struct_t gpio_struct;
char * nvs_item=config_alloc_get(NVS_TYPE_STR, "set_GPIO");
#ifdef CONFIG_LED_GREEN_GPIO_LEVEL
gpio_struct.green.level = CONFIG_LED_GREEN_GPIO_LEVEL;
#endif
#ifdef CONFIG_LED_GREEN_GPIO
gpio_struct.green.gpio = CONFIG_LED_GREEN_GPIO;
#endif
#ifdef CONFIG_LED_RED_GPIO_LEVEL
gpio_struct.green.level = CONFIG_LED_RED_GPIO_LEVEL;
#endif
#ifdef CONFIG_LED_RED_GPIO
gpio_struct.red.gpio = CONFIG_LED_RED_GPIO;
#endif
if(nvs_item){
HANDLE_GPIO_STRUCT_MEMBER(amp,false);
#ifndef CONFIG_LED_LOCKED
HANDLE_GPIO_STRUCT_MEMBER(green,false);
HANDLE_GPIO_STRUCT_MEMBER(red,false);
#endif
HANDLE_GPIO_STRUCT_MEMBER(jack,false);
HANDLE_GPIO_STRUCT_MEMBER(spkfault,false);
HANDLE_GPIO_STRUCT_MEMBER(vcc,false);
HANDLE_GPIO_STRUCT_MEMBER(gnd,false);
HANDLE_GPIO_STRUCT_MEMBER(ir,false);
free(nvs_item);
}
#ifdef CONFIG_LED_LOCKED
gpio_struct.red.fixed=true;
gpio_struct.green.fixed=true;
#endif
#ifdef CONFIG_JACK_LOCKED
gpio_struct.jack.gpio=CONFIG_JACK_GPIO;
gpio_struct.jack.fixed=true;
gpio_struct.jack.level=CONFIG_JACK_GPIO_LEVEL;
#endif
#ifdef CONFIG_SPKFAULT_LOCKED
gpio_struct.spkfault.gpio=CONFIG_SPKFAULT_GPIO;
gpio_struct.spkfault.fixed=true;
gpio_struct.spkfault.level=CONFIG_SPKFAULT_GPIO_LEVEL;
#endif
return &gpio_struct;
}
/****************************************************************************************
*
*/
@@ -448,55 +522,34 @@ cJSON * get_gpio_entry(const char * name, const char * prefix, int gpio, bool fi
return entry;
}
/****************************************************************************************
*
*/
cJSON * add_gpio_for_name(cJSON * list,const char * nvs_entry,const char * name, const char * prefix, bool fixed){
cJSON * llist = list?list:cJSON_CreateArray();
char *p;
int gpioNum=0;
if ((p = strcasestr(nvs_entry, name)) != NULL) {
gpioNum = atoi(strchr(p, '=') + 1);
cJSON_AddItemToArray(llist,get_gpio_entry(name,prefix,gpioNum,fixed));
}
return llist;
}
/****************************************************************************************
*
*/
cJSON * get_GPIO_nvs_list(cJSON * list) {
cJSON * ilist = list?list:cJSON_CreateArray();
char *nvs_item, *p, type[16];
int gpio;
bool fixed=false;
#ifdef CONFIG_JACK_LOCKED
bool bFoundJack=false;
#endif
#ifdef CONFIG_SPKFAULT_LOCKED
bool bFoundSpkFault = false;
#endif
if ((nvs_item = config_alloc_get(NVS_TYPE_STR, "set_GPIO")) == NULL) return ilist;
p = nvs_item;
do {
fixed=false;
if (sscanf(p, "%d=%15[^,]", &gpio, type) > 0 && (GPIO_IS_VALID_GPIO(gpio) || gpio==GPIO_NUM_NC)){
#ifdef CONFIG_JACK_LOCKED
if(strcasecmp(type,"jack")==0){
fixed=true;
bFoundJack=true;
}
#endif
#ifdef CONFIG_SPKFAULT_LOCKED
if(strcasecmp(type,"spkfault")==0){
fixed=true;
bFoundSpkFault=true;
}
#endif
cJSON_AddItemToArray(ilist,get_gpio_entry(type,"gpio", gpio, fixed));
}
p = strchr(p, ',');
} while (p++);
#ifdef CONFIG_JACK_LOCKED
if(!bFoundJack){
monitor_gpio_t *jack= get_jack_insertion_gpio();
cJSON_AddItemToArray(list,get_gpio_entry("jack", "other", jack->gpio, true));
}
#endif
#ifdef CONFIG_SPKFAULT_LOCKED
if(!bFoundSpkFault){
monitor_gpio_t *jack= get_spkfault_gpio();
cJSON_AddItemToArray(list,get_gpio_entry("spkfault", "other", jack->gpio, true));
}
#endif
free(nvs_item);
const set_GPIO_struct_t * gpios = get_gpio_struct();
ADD_GPIO_STRUCT_MEMBER_TO_ARRAY(ilist,gpios,vcc,"other");
ADD_GPIO_STRUCT_MEMBER_TO_ARRAY(ilist,gpios,gnd,"other");
ADD_GPIO_STRUCT_MEMBER_TO_ARRAY(ilist,gpios,amp,"other");
ADD_GPIO_STRUCT_MEMBER_TO_ARRAY(ilist,gpios,ir,"other");
ADD_GPIO_STRUCT_MEMBER_TO_ARRAY(ilist,gpios,jack,"other");
ADD_GPIO_STRUCT_MEMBER_TO_ARRAY(ilist,gpios,green,"other");
ADD_GPIO_STRUCT_MEMBER_TO_ARRAY(ilist,gpios,red,"other");
ADD_GPIO_STRUCT_MEMBER_TO_ARRAY(ilist,gpios,spkfault,"other");
return ilist;
}
@@ -585,47 +638,30 @@ cJSON * get_SPI_GPIO(cJSON * list){
/****************************************************************************************
*
*/
cJSON * get_GPIO_from_string(const char * nvs_item, const char * prefix, cJSON * list, bool fixed){
cJSON * llist = list;
int gpio=0,offset=0,soffset=0,ret1=0,sret=0;
if(!llist){
llist = cJSON_CreateArray();
}
const char *p=NULL;
char type[16];
int slen=strlen(nvs_item)+1;
char * buf1=malloc(slen);
char * buf2=malloc(slen);
ESP_LOGD(TAG,"Parsing string %s",nvs_item);
p = strchr(nvs_item, ':');
p=p?p+1:nvs_item;
while((((ret1=sscanf(p, "%[^=]=%d%n", type,&gpio,&offset)) ==2) || ((sret=sscanf(p, "%[^=]=%[^, ],%n", buf1,buf2,&soffset)) > 0 )) && (offset || soffset)){
if(ret1==2 && (GPIO_IS_VALID_GPIO(gpio) || gpio==GPIO_NUM_NC)){
if(gpio>0){
cJSON_AddItemToArray(llist,get_gpio_entry(type,prefix,gpio,fixed));
}
p+=offset;
} else {
p+=soffset;
}
while(*p==' ' || *p==',') p++;
gpio=-1;
}
free(buf1);
free(buf2);
cJSON * get_SPDIF_GPIO(cJSON * list, bool fixed){
cJSON * llist = list?list:cJSON_CreateArray();
char * spdif_config = config_spdif_get_string();
if(spdif_config){
llist = add_gpio_for_name(llist,spdif_config,"bck", "spdif", fixed);
llist = add_gpio_for_name(llist,spdif_config,"ws", "spdif", fixed);
llist = add_gpio_for_name(llist,spdif_config,"do", "spdif", fixed);
free(spdif_config);
}
return llist;
}
/****************************************************************************************
*
*/
cJSON * get_GPIO_from_nvs(const char * item, const char * prefix, cJSON * list, bool fixed){
char * nvs_item=NULL;
cJSON * llist=list;
if ((nvs_item = config_alloc_get(NVS_TYPE_STR, item)) == NULL) return list;
llist = get_GPIO_from_string(nvs_item,prefix,list, fixed);
free(nvs_item);
cJSON * get_Rotary_GPIO(cJSON * list){
cJSON * llist = list?list:cJSON_CreateArray();
char *config = config_alloc_get_default(NVS_TYPE_STR, "rotary_config", NULL, 0);
if(config){
llist = add_gpio_for_name(llist,config,"A", "rotary", false);
llist = add_gpio_for_name(llist,config,"B", "rotary", false);
llist = add_gpio_for_name(llist,config,"SW", "rotary", false);
free(config);
}
return llist;
}
@@ -687,9 +723,7 @@ esp_err_t free_gpio_entry( gpio_entry_t ** gpio) {
gpio_entry_t * get_gpio_by_no(int gpionum, bool refresh){
cJSON * gpio_header=NULL;
gpio_entry_t * gpio=NULL;
if(refresh){
get_gpio_list();
}
get_gpio_list(refresh);
cJSON_ArrayForEach(gpio_header,gpio_list)
{
if(get_gpio_structure(gpio_header, &gpio)==ESP_OK && gpio->gpio==gpionum){
@@ -704,10 +738,8 @@ gpio_entry_t * get_gpio_by_no(int gpionum, bool refresh){
*/
gpio_entry_t * get_gpio_by_name(char * name,char * group, bool refresh){
cJSON * gpio_header=NULL;
if(refresh){
get_gpio_list();
}
gpio_entry_t * gpio=NULL;
get_gpio_list(refresh);
cJSON_ArrayForEach(gpio_header,gpio_list)
{
if(get_gpio_structure(gpio_header, &gpio)==ESP_OK && strcasecmp(gpio->name,name)&& strcasecmp(gpio->group,group)){
@@ -809,12 +841,17 @@ cJSON * get_psram_gpio_list(cJSON * list){
/****************************************************************************************
*
*/
cJSON * get_gpio_list() {
cJSON * get_gpio_list(bool refresh) {
gpio_num_t gpio_num;
if(gpio_list && !refresh){
return gpio_list;
}
if(gpio_list){
cJSON_Delete(gpio_list);
}
gpio_list = cJSON_CreateArray();
gpio_list= cJSON_CreateArray();
#ifndef CONFIG_BAT_LOCKED
char *bat_config = config_alloc_get_default(NVS_TYPE_STR, "bat_config", NULL, 0);
if (bat_config) {
@@ -835,10 +872,9 @@ cJSON * get_gpio_list() {
cJSON_AddItemToArray(gpio_list,get_gpio_entry("bat","other",gpio_num,true));
}
#endif
gpio_list = get_GPIO_nvs_list(gpio_list);
char * spdif_config = config_spdif_get_string();
gpio_list=get_GPIO_from_string(spdif_config,"spdif", gpio_list, is_spdif_config_locked());
free(spdif_config);
gpio_list=get_GPIO_nvs_list(gpio_list);
gpio_list=get_SPDIF_GPIO(gpio_list,is_spdif_config_locked());
gpio_list=get_Rotary_GPIO(gpio_list);
gpio_list=get_Display_GPIO(gpio_list);
gpio_list=get_SPI_GPIO(gpio_list);
gpio_list=get_I2C_GPIO(gpio_list);

View File

@@ -39,6 +39,24 @@ typedef struct {
int sda;
int scl;
} i2s_platform_config_t;
typedef struct {
int gpio;
int level;
bool fixed;
} gpio_with_level_t;
typedef struct {
gpio_with_level_t vcc;
gpio_with_level_t gnd;
gpio_with_level_t amp;
gpio_with_level_t ir;
gpio_with_level_t jack;
gpio_with_level_t green;
gpio_with_level_t red;
gpio_with_level_t spkfault;
} set_GPIO_struct_t;
typedef struct {
bool fixed;
char * name;
@@ -61,6 +79,6 @@ bool is_spdif_config_locked();
esp_err_t free_gpio_entry( gpio_entry_t ** gpio);
gpio_entry_t * get_gpio_by_name(char * name,char * group, bool refresh);
gpio_entry_t * get_gpio_by_no(int gpionum, bool refresh);
cJSON * get_gpio_list();
cJSON * get_gpio_list(bool refresh);
bool is_dac_config_locked();
bool are_statistics_enabled();

View File

@@ -40,6 +40,8 @@ static struct {
.cells = 2,
};
extern void wifi_manager_update_status();
/****************************************************************************************
*
*/
@@ -64,6 +66,7 @@ static void battery_callback(TimerHandle_t xTimer) {
battery.avg = battery.sum / battery.count;
battery.sum = battery.count = 0;
ESP_LOGI(TAG, "Voltage %.2fV", battery.avg);
wifi_manager_update_status();
}
}

View File

@@ -12,7 +12,8 @@ typedef enum {
MESSAGING_CLASS_OTA,
MESSAGING_CLASS_SYSTEM,
MESSAGING_CLASS_STATS,
MESSAGING_CLASS_CFGCMD
MESSAGING_CLASS_CFGCMD,
MESSAGING_CLASS_BT
} messaging_classes;
typedef struct messaging_list_t *messaging_handle_t;

View File

@@ -41,11 +41,14 @@ bool jack_inserted_svc(void);
void (*spkfault_handler_svc)(bool inserted);
bool spkfault_svc(void);
extern void wifi_manager_update_status();
/****************************************************************************************
*
*/
static void task_stats( cJSON* top ) {
#ifdef CONFIG_FREERTOS_USE_TRACE_FACILITY
#pragma message("Compiled with trace facility")
static struct {
TaskStatus_t *tasks;
uint32_t total, n;
@@ -60,6 +63,7 @@ static void task_stats( cJSON* top ) {
*scratch = '\0';
#ifdef CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
#pragma message("Compiled with runtime stats")
uint32_t elapsed = current.total - previous.total;
for(int i = 0, n = 0; i < current.n; i++ ) {
@@ -87,6 +91,8 @@ static void task_stats( cJSON* top ) {
}
}
#else
#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);
cJSON * t=cJSON_CreateObject();
@@ -106,6 +112,8 @@ static void task_stats( cJSON* top ) {
cJSON_AddItemToObject(top,"tasks",tlist);
if (previous.tasks) free(previous.tasks);
previous = current;
#else
#pragma message("Compiled WITHOUT trace facility")
#endif
}
@@ -140,6 +148,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) {
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");
wifi_manager_update_status();
if (jack_handler_svc) (*jack_handler_svc)(event == BUTTON_PRESSED);
}

View File

@@ -76,7 +76,7 @@ void equalizer_update(s8_t *gain) {
* process equalizer
*/
void equalizer_process(u8_t *buf, u32_t bytes, u32_t sample_rate) {
// don't want to process with output locked, so tak ethe small risk to miss one parametric update
// don't want to process with output locked, so take the small risk to miss one parametric update
if (equalizer.update) {
equalizer_close();
equalizer_open(sample_rate);

View File

@@ -115,12 +115,14 @@ static int _write_frames(frames_t out_frames, bool silence, s32_t gainL, s32_t g
}
output_visu_export((s16_t*) (btout + oframes * BYTES_PER_FRAME), out_frames, output.current_sample_rate, silence, (gainL + gainR) / 2);
oframes += out_frames;
return (int)out_frames;
}
int32_t output_bt_data(uint8_t *data, int32_t len) {
int32_t avail_data = 0, wanted_len = 0, start_timer = 0;
int32_t iframes = len / BYTES_PER_FRAME, start_timer = 0;
if (len < 0 || data == NULL || !running) {
return 0;
@@ -131,32 +133,25 @@ int32_t output_bt_data(uint8_t *data, int32_t len) {
// This is how the BTC layer calculates the number of bytes to
// for us to send. (BTC_SBC_DEC_PCM_DATA_LEN * sizeof(OI_INT16) - availPcmBytes
wanted_len=len;
SET_MIN_MAX(len,req);
TIME_MEASUREMENT_START(start_timer);
LOCK;
output.device_frames = 0; // todo: check if this is the right way do to this.
SET_MIN_MAX_SIZED(_buf_used(outputbuf),bt,outputbuf->size);
LOCK;
output.device_frames = 0;
output.updated = gettime_ms();
output.frames_played_dmp = output.frames_played;
SET_MIN_MAX_SIZED(_buf_used(outputbuf),bt,outputbuf->size);
do {
avail_data = _output_frames( wanted_len/BYTES_PER_FRAME )*BYTES_PER_FRAME; // Keep the transfer buffer full
wanted_len-=avail_data;
} while (wanted_len > 0 && avail_data != 0);
if (wanted_len > 0) {
SET_MIN_MAX(wanted_len, under);
}
output.frames_in_process = len-wanted_len;
equalizer_process(data, (len - wanted_len) * BYTES_PER_FRAME, output.current_sample_rate);
_output_frames(iframes);
output.frames_in_process = oframes;
UNLOCK;
equalizer_process(data, oframes * BYTES_PER_FRAME, output.current_sample_rate);
SET_MIN_MAX(TIME_MEASUREMENT_GET(start_timer),lock_out_time);
SET_MIN_MAX((len-wanted_len), rec);
SET_MIN_MAX((len-oframes*BYTES_PER_FRAME), rec);
TIME_MEASUREMENT_START(start_timer);
return len-wanted_len;
return oframes * BYTES_PER_FRAME;
}
void output_bt_tick(void) {

View File

@@ -78,7 +78,7 @@ void output_init_embedded(log_level level, char *device, unsigned output_buf_siz
output.start_frames = FRAME_BLOCK;
output.rate_delay = rate_delay;
if (strcasestr(device, "BT ")) {
if (strcasestr(device, "BT ") || !strcasecmp(device, "BT")) {
LOG_INFO("init Bluetooth");
close_cb = &output_close_bt;
output_init_bt(level, device, output_buf_size, params, rates, rate_delay, idle);

View File

@@ -1,7 +1,7 @@
idf_component_register( SRC_DIRS .
INCLUDE_DIRS . ${IDF_PATH}/components/esp_http_server/src ${IDF_PATH}/components/esp_http_server/src/port/esp32 ${IDF_PATH}/components/esp_http_server/src/util ${IDF_PATH}/components/esp_http_server/src/
REQUIRES squeezelite-ota json mdns
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
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 driver_bt
EMBED_FILES res/style.css.gz res/code.js.gz index.html res/bootstrap.css.gz res/yeti/bootstrap.css.gz res/jquery.js.gz res/bootstrap.js.gz res/favicon.ico
)

View File

@@ -548,7 +548,7 @@ esp_err_t ap_get_handler(httpd_req_t *req){
}
/* if we can get the mutex, write the last version of the AP list */
esp_err_t err = set_content_type_from_req(req);
if( err == ESP_OK && wifi_manager_lock_json_buffer(( TickType_t ) 10)){
if( err == ESP_OK && wifi_manager_lock_json_buffer(( TickType_t ) 200/portTICK_PERIOD_MS)){
char *buff = wifi_manager_alloc_get_ap_list_json();
wifi_manager_unlock_json_buffer();
if(buff!=NULL){
@@ -584,7 +584,7 @@ esp_err_t config_get_handler(httpd_req_t *req){
}
else {
ESP_LOGD_LOC(TAG, "config json : %s",json );
cJSON * gplist=get_gpio_list();
cJSON * gplist=get_gpio_list(false);
char * gpliststr=cJSON_PrintUnformatted(gplist);
httpd_resp_sendstr_chunk(req,"{ \"gpio\":");
httpd_resp_sendstr_chunk(req,gpliststr);
@@ -1168,7 +1168,7 @@ esp_err_t status_get_handler(httpd_req_t *req){
return err;
}
if(wifi_manager_lock_json_buffer(( TickType_t ) 10)) {
if(wifi_manager_lock_json_buffer(( TickType_t ) 200/portTICK_PERIOD_MS)) {
char *buff = wifi_manager_alloc_get_ip_info_json();
wifi_manager_unlock_json_buffer();
if(buff) {

View File

@@ -20,21 +20,18 @@
<path d="m 16.074253,15.636738 v -1.05413 h 5.893274 c 1.16249,0 2.108261,-0.855111 2.108261,-1.906183 0,-1.051073 -0.945771,-1.906236 -2.108261,-1.906236 H 16.074253 V 9.7160604 c 0,-0.5812492 -0.472879,-1.0541321 -1.054131,-1.0541321 H 6.7847349 c -1.256731,0 -2.301908,0.9212057 -2.496867,2.1237027 h -0.451896 c -0.540407,0 -1.001317,0.349129 -1.173459,0.835611 H 0.47312787 c -0.23285,0 -0.42164599,0.188794 -0.42164599,0.421651 v 1.251779 c 0,0.232857 0.18879599,0.421652 0.42164599,0.421652 H 2.6550809 c 0.165919,0.497866 0.632365,0.857588 1.180831,0.857588 h 0.45312 c 0.19781,1.199177 1.241345,2.116956 2.495659,2.116956 h 8.2353861 c 0.581297,0 1.054176,-0.472883 1.054176,-1.05413 z m 5.060935,-4.023245 v 2.125811 h -0.844935 v -2.125811 z m 2.097293,1.062932 c 0,0.582933 -0.561524,1.057661 -1.253986,1.062668 v -2.125337 c 0.692462,0.0049 1.253986,0.47963 1.253986,1.062669 z m -3.785535,-1.062932 v 2.125811 h -3.372693 v -2.125811 z m -18.55215712,0.851 H 2.5901939 v 0.408475 H 0.89478888 Z m 2.94118302,1.266114 c -0.221897,0 -0.40247,-0.185737 -0.40247,-0.414062 v -1.273547 c 0,-0.228271 0.180573,-0.41401 0.40247,-0.41401 h 0.418855 v 2.101671 h -0.418855 z m 2.948763,2.116956 c -0.929997,0 -1.6866,-0.756601 -1.6866,-1.686608 v -0.0087 -2.944976 -0.01545 c 0,-0.930006 0.756603,-1.6866072 1.6866,-1.6866072 h 8.2353871 c 0.114313,0 0.210838,0.096554 0.210838,0.2108266 v 5.9206786 c 0,0.114268 -0.09656,0.210824 -0.210838,0.210824 z" />
</g>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" id="output" width="24" height="24" viewBox="0 0 24 24">
<span data-toggle="tooltip" id="o_type" data-placement="top" title=""><svg xmlns="http://www.w3.org/2000/svg" id="output" width="24" height="24" viewBox="0 0 24 24">
<g id="o_i2s" display="none">
<path d="M2 7L2 8L2 9L2 10L2 11L2 12L2 13L2 14L2 15L2 16L2 17L3 17L3 16L3 15L3 14L3 13L3 12L3 11L3 10L3 9L3 8L2 7M6 7L6 8L6 9L7 9L7 8L8 8L9 8L10 8L10 9L11 9L11 10L11 11L10 11L10 12L9 12L9 13L8 13L8 14L7 14L7 15L6 15L6 16L6 17L7 17L8 17L9 17L10 17L11 17L12 17L12 16L11 16L10 16L9 16L8 16L8 15L9 15L9 14L10 14L10 13L11 13L11 12L12 12L12 11L12 10L12 9L12 8L11 8L11 7L10 7L9 7L8 7L6 7M16 7L16 8L15 8L15 9L15 10L15 11L16 11L16 12L17 12L18 12L18 13L19 13L20 13L21 13L21 14L21 15L20 15L20 16L19 16L18 16L17 16L16 16L16 15L15 15L15 16L15 17L16 17L17 17L18 17L19 17L20 17L21 17L21 16L22 16L22 15L22 14L22 13L21 13L21 12L20 12L20 11L19 11L18 11L17 11L16 11L16 10L16 9L17 9L17 8L18 8L19 8L20 8L21 8L21 9L22 9L22 8L22 7L21 7L20 7L19 7L18 7L16 7z"/>
</g>
<g id="o_bt" display="none">
<path d="M3 7L3 8L3 9L3 10L3 11L3 12L3 13L3 14L3 15L3 16L3 17L4 17L5 17L6 17L7 17L8 17L9 17L9 16L10 16L10 15L10 14L10 13L10 12L9 12L9 11L10 11L10 10L10 9L10 8L9 8L9 7L8 7L7 7L6 7L5 7L3 7M12 7L12 8L13 8L14 8L15 8L16 8L16 9L16 10L16 11L16 12L16 13L16 14L16 15L16 16L16 17L17 17L17 16L17 15L17 14L17 13L17 12L17 11L17 10L17 9L17 8L18 8L19 8L20 8L21 8L21 7L20 7L19 7L18 7L17 7L16 7L15 7L14 7L12 7z"/>
<path style="fill:#272B30;" d="M4 8L4 9L4 10L4 11L5 11L6 11L7 11L8 11L8 10L9 10L9 9L9 8L8 8L7 8L6 8L4 8M4 12L4 13L4 14L4 15L4 16L5 16L6 16L7 16L8 16L8 15L9 15L9 14L9 13L8 13L8 12L7 12L6 12L4 12z"/>
</g>
<g id="o_bt" stroke="currentColor" stroke-width="1" fill="none" fill-rule="evenodd" display="none"></g>
<g id="o_spdif" display="none">
<path d="M3 1L3 2L2 2L2 3L2 4L2 5L3 5L3 6L4 6L5 6L5 7L6 7L7 7L8 7L8 8L8 9L7 9L7 10L6 10L5 10L4 10L3 10L3 9L2 9L2 10L2 11L3 11L4 11L5 11L6 11L7 11L8 11L8 10L9 10L9 9L9 8L9 7L8 7L8 6L7 6L7 5L6 5L5 5L4 5L3 5L3 4L3 3L4 3L4 2L5 2L6 2L7 2L8 2L8 3L9 3L9 2L9 1L8 1L7 1L6 1L5 1L3 1M13 1L13 2L13 3L13 4L12 4L12 5L12 6L12 7L12 8L11 8L11 9L11 10L11 11L10 11L10 12L10 13L11 13L11 12L11 11L12 11L12 10L12 9L12 8L13 8L13 7L13 6L13 5L14 5L14 4L14 3L14 2L15 2L15 1L13 1M16 1L16 2L16 3L16 4L16 5L16 6L16 7L16 8L16 9L16 10L16 11L17 11L17 10L17 9L17 8L17 7L18 7L19 7L20 7L21 7L21 6L22 6L22 5L22 4L22 3L22 2L21 2L21 1L20 1L19 1L18 1L16 1z"/>
<path style="fill:#272B30;" d="M17 2L17 3L17 4L17 5L17 6L18 6L19 6L20 6L20 5L21 5L21 4L21 3L20 3L20 2L19 2L17 2z"/>
<path d="M2 13L2 14L2 15L2 16L2 17L2 18L2 19L2 20L2 21L2 22L2 23L3 23L4 23L5 23L6 23L7 23L8 23L8 22L9 22L9 21L10 21L10 20L10 19L10 18L10 17L10 16L10 15L9 15L9 14L8 14L7 14L7 13L6 13L5 13L4 13L2 13M13 13L13 14L13 15L13 16L13 17L13 18L13 19L13 20L13 21L13 22L13 23L14 23L14 22L14 21L14 20L14 19L14 18L14 17L14 16L14 15L14 14L13 13M17 13L17 14L17 15L17 16L17 17L17 18L17 19L17 20L17 21L17 22L17 23L18 23L18 22L18 21L18 20L18 19L18 18L19 18L20 18L21 18L22 18L22 17L21 17L20 17L19 17L18 17L18 16L18 15L18 14L19 14L20 14L21 14L22 14L22 13L21 13L20 13L19 13L17 13z"/>
<path style="fill:#272B30;" d="M3 14L3 15L3 16L3 17L3 18L3 19L3 20L3 21L3 22L4 22L5 22L6 22L7 22L7 21L8 21L8 20L9 20L9 19L9 18L9 17L9 16L8 16L8 15L7 15L7 14L6 14L5 14L3 14z"/>
</g>
</svg>
</svg></span>
<svg xmlns="http://www.w3.org/2000/svg" id="battery" width="24" height="24" viewBox="0 0 24 24">
<g id="bat0" display="none">
<path d="M19 8v8h-17v-8h17zm2-2h-21v12h21v-12zm1 9h.75c.69 0 1.25-.56 1.25-1.25v-3.5c0-.69-.56-1.25-1.25-1.25h-.75v6z"/>
@@ -322,7 +319,6 @@
</div>
</fieldset>
<div class="form-group"><label for="player">Player Name</label><input type="text" class="form-control " placeholder="Squeezelite" id="player" ></div>
<div class="form-group" style="display: none;"><label for="btsinkdiv">Bluetooth Speaker Name To Connect To</label><input type="text" class="form-control" id="btsinkdiv" ></div>
<div class="form-group"><label for="optional">Optional setting (e.g. for LMS IP address)</label><input type="text" class="form-control" id="optional" ></div>
<div class="form-group"><div class="form-check">
<label class="form-check-label">

File diff suppressed because one or more lines are too long

View File

@@ -41,6 +41,31 @@ var nvs_type_t = {
/*!< Type blob */
NVS_TYPE_ANY: 0xff /*!< Must be last */
};
var bt_icons = {
'bt_playing':'<path d="M15.98,10.28 L14.6,11.66 C14.4,11.86 14.4,12.17 14.6,12.37 L15.98,13.75 C16.26,14.03 16.73,13.9 16.83,13.52 C16.94,13.02 17,12.52 17,12 C17,11.49 16.94,10.99 16.82,10.52 C16.73,10.14 16.26,10 15.98,10.28 Z M20.1,7.78 C19.85,7.23 19.12,7.11 18.7,7.54 C18.44,7.8 18.39,8.18 18.53,8.52 C18.99,9.59 19.25,10.76 19.25,11.99 C19.25,13.23 18.99,14.41 18.52,15.48 C18.38,15.8 18.43,16.17 18.68,16.42 C19.09,16.83 19.78,16.71 20.03,16.19 C20.66,14.89 21.01,13.43 21.01,11.89 C21,10.44 20.68,9.04 20.1,7.78 Z M11.39,12 L14.98,8.42 C15.37,8.03 15.37,7.4 14.98,7 L10.69,2.71 C10.06,2.08 8.98,2.53 8.98,3.42 L8.98,9.6 L5.09,5.7 C4.7,5.31 4.07,5.31 3.68,5.7 C3.29,6.09 3.29,6.72 3.68,7.11 L8.57,12 L3.68,16.89 C3.29,17.28 3.29,17.91 3.68,18.3 C4.07,18.69 4.7,18.69 5.09,18.3 L8.98,14.41 L8.98,20.59 C8.98,21.48 10.06,21.93 10.69,21.3 L14.99,17 C15.38,16.61 15.38,15.98 14.99,15.58 L11.39,12 Z M10.98,5.83 L12.86,7.71 L10.98,9.59 L10.98,5.83 Z M10.98,18.17 L10.98,14.41 L12.86,16.29 L10.98,18.17 Z" id="🔹-Icon-Color" fill="#1D1D1D"></path>',
'bt_disconnected':'<path d="M13.41,12l3.8-3.79a1,1,0,0,0,0-1.42l-4.5-4.5a1,1,0,0,0-.33-.21,1,1,0,0,0-.76,0,1,1,0,0,0-.54.54A1,1,0,0,0,11,3V9.59L8.21,6.79A1,1,0,1,0,6.79,8.21L10.59,12l-3.8,3.79a1,1,0,1,0,1.42,1.42L11,14.41V21a1,1,0,0,0,.08.38,1,1,0,0,0,.54.54.94.94,0,0,0,.76,0,1,1,0,0,0,.33-.21l4.5-4.5a1,1,0,0,0,0-1.42ZM13,5.41,15.09,7.5,13,9.59Zm0,13.18V14.41l2.09,2.09Z"/>',
'bt_neutral':'<path d="M17.71 7.71L12 2h-1v7.59L6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 11 14.41V22h1l5.71-5.71-4.3-4.29 4.3-4.29zM13 5.83l1.88 1.88L13 9.59V5.83zm1.88 10.46L13 18.17v-3.76l1.88 1.88z"/>',
'bt_connected':'<path d="M7 12l-2-2-2 2 2 2 2-2zm10.71-4.29L12 2h-1v7.59L6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 11 14.41V22h1l5.71-5.71-4.3-4.29 4.3-4.29zM13 5.83l1.88 1.88L13 9.59V5.83zm1.88 10.46L13 18.17v-3.76l1.88 1.88zM19 10l-2 2 2 2 2-2-2-2z"/>',
'bt_disabled':'<path d="M13 5.83l1.88 1.88-1.6 1.6 1.41 1.41 3.02-3.02L12 2h-1v5.03l2 2v-3.2zM5.41 4L4 5.41 10.59 12 5 17.59 6.41 19 11 14.41V22h1l4.29-4.29 2.3 2.29L20 18.59 5.41 4zM13 18.17v-3.76l1.88 1.88L13 18.17z"/>',
'bt_searching':'<path d="M14.24 12.01l2.32 2.32c.28-.72.44-1.51.44-2.33 0-.82-.16-1.59-.43-2.31l-2.33 2.32zm5.29-5.3l-1.26 1.26c.63 1.21.98 2.57.98 4.02s-.36 2.82-.98 4.02l1.2 1.2c.97-1.54 1.54-3.36 1.54-5.31-.01-1.89-.55-3.67-1.48-5.19zm-3.82 1L10 2H9v7.59L4.41 5 3 6.41 8.59 12 3 17.59 4.41 19 9 14.41V22h1l5.71-5.71-4.3-4.29 4.3-4.29zM11 5.83l1.88 1.88L11 9.59V5.83zm1.88 10.46L11 18.17v-3.76l1.88 1.88z"/>',
'play_circle_outline':'<path d="M10 16.5l6-4.5-6-4.5v9zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/>',
'play_circle_filled':'<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 14.5v-9l6 4.5-6 4.5z"/>',
'play_arrow':'<path d="M0 0h24v24H0z" fill="none"/><path d="M8 5v14l11-7z"/>',
'pause':'<path d="M0 0h24v24H0z" fill="none"/><path d="M6 19h4V5H6v14zm8-14v14h4V5h-4z"/>',
'stop':'<path d="M0 0h24v24H0z" fill="none"/><path d="M6 6h12v12H6z"/>',
'':''
};
var bt_state_icon = [
{"desc":"Idle", "sub":["bt_neutral"]},
{"desc":"Discovering","sub":["bt_searching"]},
{"desc":"Discovered","sub":["bt_searching"]},
{"desc":"Unconnected","sub":["bt_disabled"]},
{"desc":"Connecting","sub":["bt_disabled"]},
{"desc":"Connected","sub":["bt_connected", "play_circle_outline", "bt_playing", "pause", "stop"]},
{"desc":"Disconnecting","sub":["bt_neutral"]},
];
pillcolors = {
'MESSAGING_INFO' : 'badge-success',
'MESSAGING_WARNING' : 'badge-warning',
@@ -72,6 +97,24 @@ var escapeHTML = function(unsafe) {
}
});
};
function handlebtstate(data){
var icon = '';
var tt='';
if (data['bt_status']!=undefined && data['bt_sub_status']!=undefined) {
var iconsvg=bt_state_icon[data['bt_status']]?.sub[data['bt_sub_status']];
if(iconsvg){
icon = bt_icons[iconsvg];
tt=bt_state_icon[data['bt_status']]?.desc;
}
else {
icon = bt_icons.bt_connected;
tt='Output status';
}
}
o_type.title=tt;
$('#o_bt').html(icon);
}
function setNavColor(stylename){
$('[name=secnav]').removeClass('bg-secondary bg-warning');
$("footer.footer").removeClass('bg-secondary bg-warning');
@@ -84,24 +127,18 @@ function setNavColor(stylename){
}
function handleTemplateTypeRadio(outtype){
if (outtype == 'bt') {
$("#btsinkdiv").parent().show(200);
$("#btsinkdiv").show();
$('#bt').prop('checked',true);
o_bt.setAttribute("display", "inline");
o_bt.setAttribute("display", "inline");
o_spdif.setAttribute("display", "none");
o_i2s.setAttribute("display", "none");
output = 'bt';
} else if (outtype == 'spdif') {
$("#btsinkdiv").parent().hide(200);
$("#btsinkdiv").show();
$('#spdif').prop('checked',true);
o_bt.setAttribute("display", "none");
o_spdif.setAttribute("display", "inline");
o_i2s.setAttribute("display", "none");
output = 'spdif';
} else {
$("#btsinkdiv").parent().hide(200);
$("#btsinkdiv").show();
$('#i2s').prop('checked',true);
o_bt.setAttribute("display", "none");
o_spdif.setAttribute("display", "none");
@@ -326,13 +363,8 @@ function save_autoexec1(apply){
showCmdMessage('cfg-audio-tmpl','MESSAGING_INFO',"Saving.\n",false);
var commandLine = commandHeader + ' -n "' + $("#player").val() + '"';
if (output == 'bt') {
if($("#btsinkdiv").val()?.length!=0){
commandLine += ' -o "BT -n \'' + $("#btsinkdiv").val() + '\'" -Z 192000';
}
else {
showCmdMessage('cfg-audio-tmpl','MESSAGING_ERROR',"BT Sink Name required for output bluetooth.\n",true);
return;
}
commandLine += ' -o "BT" -R -Z 192000';
showCmdMessage('cfg-audio-tmpl','MESSAGING_INFO',"Remember to configure the Bluetooth audio device name.\n",true);
} else if (output == 'spdif') {
commandLine += ' -o SPDIF -Z 192000';
} else {
@@ -939,6 +971,8 @@ function handleRecoveryMode(data){
setNavColor('bg-warning');
$("#boot-button").html('Reboot');
$("#boot-form").attr('action', '/reboot_ota.json');
$("flashfilename").show();
$("fwUpload").show();
} else {
recovery = false;
$("#reboot_ota_nav").hide();
@@ -949,6 +983,8 @@ function handleRecoveryMode(data){
$("footer.footer").addClass('sl');
$("#boot-button").html('Recovery');
$("#boot-form").attr('action', '/recovery.json');
$("flashfilename").hide();
$("fwUpload").hide();
}
}
}
@@ -1029,6 +1065,7 @@ function checkStatus() {
$.getJSON("/status.json", function(data) {
handleRecoveryMode(data);
handleWifiStatus(data);
handlebtstate(data);
if (data.hasOwnProperty('project_name') && data['project_name'] != '') {
pname = data['project_name'];
}
@@ -1066,7 +1103,7 @@ function checkStatus() {
}
if (data.hasOwnProperty('Jack')) {
var jack = data['Jack'];
if (jack == '1') {
if (jack) {
o_jack.setAttribute("display", "inline");
}
}
@@ -1253,11 +1290,6 @@ function getConfig() {
handleTemplateTypeRadio('spdif');
} else if (m[1].toUpperCase().startsWith('"BT')) {
handleTemplateTypeRadio('bt');
var re2=/["]BT\s*-n\s*'([^"]+)'/g;
var m2=re2.exec(m[1]);
if(m2.length>=2){
$("#btsinkdiv").val(m2[1]);
}
}
} else if (key == 'host_name') {
val = val.replaceAll('"', '');

View File

@@ -1 +1,16 @@
{"project_name":"recovery","version":"custom.build","recovery":1,"Jack":"1","Voltage":0,"disconnect_count":0,"avg_conn_time":0,"is_i2c_locked":false,"urc":0,"ssid":"MyTestSSID","ip":"192.168.10.225","netmask":"255.255.255.0","gw":"192.168.10.1"}
{
"project_name": "recovery",
"version": "custom.build",
"recovery": 1,
"Jack": "1",
"Voltage": 0,
"disconnect_count": 0,
"avg_conn_time": 0,
"is_i2c_locked": false,
"urc": 0,
"bt_status": 0,
"ssid": "MyTestSSID",
"ip": "192.168.10.225",
"netmask": "255.255.255.0",
"gw": "192.168.10.1"
}

View File

@@ -8,6 +8,7 @@
"avg_conn_time": 0,
"is_i2c_locked": false,
"urc": 0,
"bt_status": 0,
"ssid": "MyTestSSID",
"ip": "192.168.10.225",
"netmask": "255.255.255.0",

View File

@@ -63,6 +63,7 @@ Contains the freeRTOS task and all necessary support
#include "trace.h"
#include "cmd_system.h"
#include "messaging.h"
#include "bt_app_core.h"
#include "http_server_handlers.h"
#include "monitor.h"
@@ -188,6 +189,9 @@ char * get_disconnect_code_desc(uint8_t reason){
}
return "";
}
void wifi_manager_update_status(){
wifi_manager_send_message(ORDER_UPDATE_STATUS,NULL);
}
void set_host_name(){
esp_err_t err;
ESP_LOGD(TAG, "Retrieving host name from nvs");
@@ -458,6 +462,38 @@ cJSON * wifi_manager_get_new_array_json(cJSON **old){
ESP_LOGV(TAG, "wifi_manager_get_new_array_json done");
return cJSON_CreateArray();
}
void wifi_manager_update_basic_info(){
if(wifi_manager_lock_json_buffer( portMAX_DELAY )){
monitor_gpio_t *mgpio= get_jack_insertion_gpio();
cJSON * voltage = cJSON_GetObjectItemCaseSensitive(ip_info_cjson, "Voltage");
if(voltage){
cJSON_SetNumberValue(voltage, battery_value_svc());
}
cJSON * bt_status = cJSON_GetObjectItemCaseSensitive(ip_info_cjson, "bt_status");
if(bt_status){
cJSON_SetNumberValue(bt_status, bt_app_source_get_a2d_state());
}
cJSON * bt_sub_status = cJSON_GetObjectItemCaseSensitive(ip_info_cjson, "bt_sub_status");
if(bt_sub_status){
cJSON_SetNumberValue(bt_sub_status, bt_app_source_get_media_state());
}
cJSON * jack = cJSON_GetObjectItemCaseSensitive(ip_info_cjson, "Jack");
if(jack){
jack->type=mgpio->gpio>=0 && jack_inserted_svc()?cJSON_True:cJSON_False;
}
cJSON * disconnect_count = cJSON_GetObjectItemCaseSensitive(ip_info_cjson, "disconnect_count");
if(disconnect_count){
cJSON_SetNumberValue(disconnect_count, num_disconnect);
}
cJSON * avg_conn_time = cJSON_GetObjectItemCaseSensitive(ip_info_cjson, "avg_conn_time");
if(avg_conn_time){
cJSON_SetNumberValue(avg_conn_time, num_disconnect>0?(total_connected_time/num_disconnect):0);
}
wifi_manager_unlock_json_buffer();
}
}
cJSON * wifi_manager_get_basic_info(cJSON **old){
monitor_gpio_t *mgpio= get_jack_insertion_gpio();
const esp_app_desc_t* desc = esp_ota_get_app_description();
@@ -467,10 +503,12 @@ cJSON * wifi_manager_get_basic_info(cJSON **old){
cJSON_AddItemToObject(root, "version", cJSON_CreateString(desc->version));
if(release_url !=NULL) cJSON_AddItemToObject(root, "release_url", cJSON_CreateString(release_url));
cJSON_AddNumberToObject(root,"recovery", is_recovery_running?1:0);
cJSON_AddItemToObject(root, "Jack", cJSON_CreateString(mgpio->gpio>=0 && jack_inserted_svc() ? "1" : "0"));
cJSON_AddBoolToObject(root, "Jack", mgpio->gpio>=0 && jack_inserted_svc() );
cJSON_AddNumberToObject(root,"Voltage", battery_value_svc());
cJSON_AddNumberToObject(root,"disconnect_count", num_disconnect );
cJSON_AddNumberToObject(root,"avg_conn_time", num_disconnect>0?(total_connected_time/num_disconnect):0 );
cJSON_AddNumberToObject(root,"bt_status", bt_app_source_get_a2d_state());
cJSON_AddNumberToObject(root,"bt_sub_status", bt_app_source_get_media_state());
#if CONFIG_I2C_LOCKED
cJSON_AddTrueToObject(root, "is_i2c_locked");
#else
@@ -1537,6 +1575,9 @@ void wifi_manager( void * pvParameters ){
ESP_LOGD(TAG, "Calling simple_restart.");
simple_restart();
break;
case ORDER_UPDATE_STATUS:
wifi_manager_update_basic_info();
break;
default:
break;

View File

@@ -191,7 +191,8 @@ typedef enum message_code_t {
ORDER_RESTART_RECOVERY = 16,
ORDER_RESTART_OTA_URL = 17,
ORDER_RESTART = 18,
MESSAGE_CODE_COUNT = 19 /* important for the callback array */
ORDER_UPDATE_STATUS = 19,
MESSAGE_CODE_COUNT = 20 /* important for the callback array */
}message_code_t;
@@ -202,7 +203,7 @@ typedef enum reboot_type_t{
} reboot_type_t;
void wifi_manager_reboot(reboot_type_t rtype);
void wifi_manager_reboot_ota(char * url);
void wifi_manager_update_status();
/**

View File

@@ -437,14 +437,16 @@ void app_main()
bypass_wifi_manager=(strcmp(bypass_wm,"1")==0 ||strcasecmp(bypass_wm,"y")==0);
}
ESP_LOGD(TAG,"Getting audio control mapping ");
char *actrls_config = config_alloc_get_default(NVS_TYPE_STR, "actrls_config", NULL, 0);
if (actrls_init(actrls_config) == ESP_OK) {
ESP_LOGD(TAG,"Initializing audio control buttons type %s", actrls_config);
} else {
ESP_LOGD(TAG,"No audio control buttons");
if(!is_recovery_running){
ESP_LOGD(TAG,"Getting audio control mapping ");
char *actrls_config = config_alloc_get_default(NVS_TYPE_STR, "actrls_config", NULL, 0);
if (actrls_init(actrls_config) == ESP_OK) {
ESP_LOGD(TAG,"Initializing audio control buttons type %s", actrls_config);
} else {
ESP_LOGD(TAG,"No audio control buttons");
}
if (actrls_config) free(actrls_config);
}
if (actrls_config) free(actrls_config);
/* start the wifi manager */
ESP_LOGD(TAG,"Blinking led");

View File

@@ -609,7 +609,7 @@ CONFIG_LWIP_MAX_SOCKETS=16
CONFIG_LWIP_SO_REUSE=y
CONFIG_LWIP_SO_REUSE_RXTOALL=y
CONFIG_LWIP_IP_REASSEMBLY=y
#CONFIG_LWIP_IP_REASSEMBLY is not set

View File

@@ -321,7 +321,7 @@ CONFIG_BT_A2DP_ENABLE=y
# CONFIG_BT_HFP_ENABLE is not set
CONFIG_BT_SSP_ENABLED=y
# CONFIG_BT_BLE_ENABLED is not set
CONFIG_BT_STACK_NO_LOG=y
CONFIG_BT_STACK_NO_LOG=n
CONFIG_BT_ACL_CONNECTIONS=4
CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST=y
CONFIG_BT_BLE_DYNAMIC_ENV_MEMORY=y
@@ -773,8 +773,8 @@ CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0
CONFIG_FREERTOS_USE_TRACE_FACILITY=y
CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS=y
CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID=y
CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y
CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER=y
#CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y
#CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER=y
# CONFIG_FREERTOS_RUN_TIME_STATS_USING_CPU_CLK is not set
CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y
# CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set