Skip to content

Url player stops playing music. #180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
podaen opened this issue Apr 25, 2022 · 121 comments
Closed

Url player stops playing music. #180

podaen opened this issue Apr 25, 2022 · 121 comments

Comments

@podaen
Copy link
Contributor

podaen commented Apr 25, 2022

Phill

I m investaging to work with arduino espressif 2.0.2 and look what could be the reason why the URL player does turn as not active. I found a something...

in AudioMozzi.h those files can not be found...

#include "mozzi_config.h"
#include "hardware_defines.h"
#include "mozzi_analog.h"
#include "Mozzi.h"

I did a lookup, but the are not in hierarchy

@podaen
Copy link
Contributor Author

podaen commented Apr 25, 2022

I suspect you have to define in the config whether it is used or not. However player.stop is referring to it soo please do.

ps: I am testing so the whole audio tools library soo please help! Because i make some extra logings and because there are a lot of classes that are inherted it is no easy task to do. And make on top of that with all notifications to make a pull request is unpossible...

@podaen
Copy link
Contributor Author

podaen commented Apr 25, 2022

these three links are remarkable...

http://icecast-servers.vrtcdn.be/mnm_urb-high.mp3
https://25493.live.streamtheworld.com:443/NOSTALGIEWAFNEWWAVE.mp3
https://25493.live.streamtheworld.com:443/NOSTALGIEWAFEXTRA.mp3

the player end

        virtual void end() {
            Serial.println("player end");
            LOGD(LOG_METHOD);
            active = false;
            p_out_decoding->end();
            meta_out.end();
        }

and sometimes the connection fails

Here the complete test resluts of 78 radio stations

70 audio
71 audio
72 audio
73 audio
74 haperd
75 audio
76 audio
77 audio

0 audio
1 audio
2 https no audio
[E] HttpRequest.h : 185 - Connect failed
player end

3 https no audio player not active
4 audio
5 audio
6 audio
7 audio
8 audio
9 audio
10 audio but stops http://icecast-servers.vrtcdn.be/ketnetradio-high.mp3
10. problems
11 audio
12 audio
13 audio
14 audio
15 audio
16 audio
17 audio
18 audio
19 audio
19 2x falters
20 audio stops http://icecast-servers.vrtcdn.be/mnm_urb-high.mp3
20 2x brownout
21 no audio https://25493.live.streamtheworld.com:443/NOSTALGIEWAFNEWWAVE.mp3
[W] HttpHeader.h : 231 - Waiting for data...
[W] HttpRequest.h : 145 - no CONTENT_LENGTH found in reply
waitForData
player end

22 no audio
https://25493.live.streamtheworld.com:443/NOSTALGIEWAFEXTRA.mp3
[E] HttpRequest.h : 185 - Connect failed
player end
No stream-Timout
player not active

23 audio
[W] HttpHeader.h : 231 - Waiting for data...
[W] HttpRequest.h : 145 - no CONTENT_LENGTH found in reply
waitForData
player end

24 no audio player end

25 audio
26 audio
27 audio
28 audio
29 audio
30 audio
31 audio
32 audio
33 audio
34 audio
35 audio
36 audio
37 no audio
Auto Next
write eeprom UrlSelector: 37
Vbro
http://stream.vbro.be:9100/vbro
[10114398][I][WiFiClient.cpp:252] connect(): select returned due to timeout 3000 ms for fd 48
[E] HttpRequest.h : 185 - Connect failed
player end
38 audio
39 audio failters
40 audio
41 no audio
[E] HttpRequest.h : 185 - Connect failed
player end

42 no audio
[E] HttpRequest.h : 185 - Connect failed
player end
No stream-Timout
player not active

44 audio
45 audio
46 audio
47 audio
48 audio
49 audio
50 audio
51 audio
52 audio
53 audio
54 no audio
[E] URLStream.h : 273 - Error code recieved ... stop waiting for reply
player end

55 falters
player end

56 audio
57 audio
58 audio
59 audio
60 audio
61 audio
62 audio
63 audio
64 audio
65 audio

66 no audio
[E] URLStream.h : 273 - Error code recieved ... stop waiting for reply
player end

67 no audio
[E] URLStream.h : 273 - Error code recieved ... stop waiting for reply
player end
No stream-Timout
player not active

68 audio
69 audio
70 audio
71 audio
72 haperd
73 haperd
74 haperd

All links that did work before and now they don't

http://22183.live.streamtheworld.com/JOE.mp3,
https://23623.live.streamtheworld.com:443/TOPRETRO.mp3,
http://icecast-servers.vrtcdn.be/stubru_untz-high.mp3,
http://icecast-servers.vrtcdn.be/mnm_hits-high.mp3,
http://icecast-servers.vrtcdn.be/mnm_urb-high.mp3,
https://25493.live.streamtheworld.com:443/NOSTALGIEWAFNEWWAVE.mp3,
https://25493.live.streamtheworld.com:443/NOSTALGIEWAFEXTRA.mp3,
http://stream.vbro.be:9400/evergreen,
http://versuzradio.live-streams.nl/live,
http://23553.live.streamtheworld.com:80/RADIO_2_WESTVL_128.mp3,
https://25633.live.streamtheworld.com:443/WILLY.mp3,

@podaen
Copy link
Contributor Author

podaen commented Apr 25, 2022

I once started with 250 links...

@podaen
Copy link
Contributor Author

podaen commented Apr 26, 2022

For debugging it would help a lot for debuging if I could see all the data that is comming in and going out.

image

That request we know

[I] HttpRequest.h : 182 - process connecting to host www.clubfmserver.be port 8000
[I] HttpRequest.h : 170 - connect www.clubfmserver.be
[I] HttpRequest.h : 193 - Free heap: 110976
[I] HttpHeader.h : 364 - HttpRequestHeader::setValues - path: /radioclubfm.mp3
[I] HttpHeader.h : 261 - HttpHeader::write
[I] HttpHeader.h : 373 - HttpRequestHeader::write1stLine
[I] HttpHeader.h : 388 - -> GET /radioclubfm.mp3 HTTP/1.1
[I] HttpHeader.h : 198 - -> Host: www.clubfmserver.be
[I] HttpHeader.h : 198 - -> Connection: close
[I] HttpHeader.h : 198 - -> Accept: audio/mp3
[I] HttpHeader.h : 304 - ->

The header of the respons we know

[I] HttpHeader.h : 168 - HttpHeader::readLine -> HTTP/1.0 200 OK
[I] HttpHeader.h : 168 - HttpHeader::readLine -> Server: Icecast 2.4.3
[I] HttpHeader.h : 168 - HttpHeader::readLine -> Date: Tue, 26 Apr 2022 00:55:15 GMT
[I] HttpHeader.h : 168 - HttpHeader::readLine -> Content-Type: audio/mpeg
[I] HttpHeader.h : 168 - HttpHeader::readLine -> Cache-Control: no-cache
[I] HttpHeader.h : 168 - HttpHeader::readLine -> Expires: Mon, 26 Jul 1997 05:00:00 GMT
[I] HttpHeader.h : 168 - HttpHeader::readLine -> Pragma: no-cache

The things I miss...

  • Content-Length
  • cookie+path

PS: I read once that for https the time on the machine needs to be time sync.

setup_wifi();
setDateTime();
espclient->setInsecure();
...
#include <time.h>
void setDateTime() {
    // You can use your own timezone, but the exact time is not used at all.
    // Only the date is needed for validating the certificates.
    configTime(TZ_Europe_Berlin, "pool.ntp.org", "time.nist.gov");

    Serial.print("Waiting for NTP time sync: ");
    time_t now = time(nullptr);
    while (now < 8 * 3600 * 2) {
        delay(100);
        Serial.print(".");
        now = time(nullptr);
    }
    Serial.println();

    struct tm timeinfo;
    gmtime_r(&now, &timeinfo);
    Serial.printf("%s %s", tzname[0], asctime(&timeinfo));
}

@podaen
Copy link
Contributor Author

podaen commented Apr 26, 2022

@podaen
Copy link
Contributor Author

podaen commented Apr 26, 2022

The reason is the same as the correction we made before with the mbed. During the cleanup of the previous ssl connection, the new http connection that has ben made runs in timout. 3000ms is to low, It has to be much more.

http://eu2.radioboss.fm:8124/stream,
[130297][V][ssl_client.cpp:332] stop_ssl_socket(): Cleaning SSL connection.
Cleaning SSL connection.
[133806][I][WiFiClient.cpp:252] connect(): select returned due to timeout 3000 ms for fd 48
[E] HttpRequest.h : 185 - Connect failed

This is the solution for those five links. But when the links are not the same order (https and http scrambled) you will get a lot more connection fails! And eventually it will not make sens why sometimes it connects and sometimes it don't.

And if this happens there is a memorie issue. The timout connection stays in the memorie... Now every next https connection fails!!! Normaly I have more than 100.000 free hape available when I start with a http that doesn't run in to a timout. When I start with a https where the connection failed than I have 60000 left but the next https needs around 90000, so allocated memory fail. I think this has to be solved first before solving the other issue. otherwise you cover this error more and it will be harder to find.

I hope it cheered you all out.

@podaen
Copy link
Contributor Author

podaen commented Apr 26, 2022

OK. I setted the timout to 10000, but it dident work for this link. It is jus a bad link that diden't work before. But it's not bad to increase it the have less failures.

I am selecting the esp doit devkit board again and see what it does

The link I am now test should work, it worked before without a problem

http://23603.live.streamtheworld.com/JOE_80S.mp3

when there is audio output

[D] MetaDataFilter.h : 35 - size_t audio_tools::MetaDataFilter::write(uint8_t*, size_t) [with Decoder = libhelix::MP3DecoderHelix; size_t = unsigned int; uint8_t = unsigned char]
[D] AudioStreams.h : 716 - virtual size_t audio_tools::VolumeStream::write(const uint8_t*, size_t)
[D] AudioStreams.h : 716 - virtual size_t audio_tools::VolumeStream::write(const uint8_t*, size_t)
[D] I2SStream.h : 124 - virtual size_t audio_tools::I2SStream::write(const uint8_t*, size_t)
[D] I2SESP32.h : 75 - size_t audio_tools::I2SBase::writeBytes(const void*, size_t)
[D] I2SESP32.h : 82 - i2s_write 4608 -> 4608 bytes
[D] AudioStreams.h : 716 - virtual size_t audio_tools::VolumeStream::write(const uint8_t*, size_t)
[D] AudioStreams.h : 716 - virtual size_t audio_tools::VolumeStream::write(const uint8_t*, size_t)
[D] I2SStream.h : 124 - virtual size_t audio_tools::I2SStream::write(const uint8_t*, size_t)
[D] I2SESP32.h : 75 - size_t audio_tools::I2SBase::writeBytes(const void*, size_t)
[D] I2SESP32.h : 82 - i2s_write 4608 -> 4608 bytes
[D] AudioStreams.h : 716 - virtual size_t audio_tools::VolumeStream::write(const uint8_t*, size_t)
[D] AudioStreams.h : 716 - virtual size_t audio_tools::VolumeStream::write(const uint8_t*, size_t)
[D] I2SStream.h : 124 - virtual size_t audio_tools::I2SStream::write(const uint8_t*, size_t)
[D] I2SESP32.h : 75 - size_t audio_tools::I2SBase::writeBytes(const void*, size_t)
[D] I2SESP32.h : 82 - i2s_write 4608 -> 4608 bytes
[D] AudioStreams.h : 716 - virtual size_t audio_tools::VolumeStream::write(const uint8_t*, size_t)
[D] AudioStreams.h : 716 - virtual size_t audio_tools::VolumeStream::write(const uint8_t*, size_t)
[D] I2SStream.h : 124 - virtual size_t audio_tools::I2SStream::write(const uint8_t*, size_t)
[D] I2SESP32.h : 75 - size_t audio_tools::I2SBase::writeBytes(const void*, size_t)
[D] I2SESP32.h : 82 - i2s_write 4608 -> 4608 bytes
[D] AudioStreams.h : 716 - virtual size_t audio_tools::VolumeStream::write(const uint8_t*, size_t)
[D] AudioStreams.h : 716 - virtual size_t audio_tools::VolumeStream::write(const uint8_t*, size_t)
[D] I2SStream.h : 124 - virtual size_t audio_tools::I2SStream::write(const uint8_t*, size_t)
[D] I2SESP32.h : 75 - size_t audio_tools::I2SBase::writeBytes(const void*, size_t)
[D] I2SESP32.h : 82 - i2s_write 4608 -> 4608 bytes
[D] AudioPlayer.h : 797 - virtual void audio_tools::AudioPlayer::copy()
[D] AudioCopy.h : 91 - size_t audio_tools::StreamCopyT::copy() [with T = unsigned char; size_t = unsigned int]
[D] AudioOutput.h : 364 - virtual size_t audio_tools::EncodedAudioStream::write(const uint8_t*, size_t): 2048
[D] CodecMP3Helix.h : 107 - virtual size_t audio_tools::MP3DecoderHelix::write(const void*, size_t): 2048

when it stops playing music

[D] MetaDataFilter.h : 35 - size_t audio_tools::MetaDataFilter::write(uint8_t*, size_t) [with Decoder = libhelix::MP3DecoderHelix; size_t = unsigned int; uint8_t = unsigned char]
[D] AudioStreams.h : 716 - virtual size_t audio_tools::VolumeStream::write(const uint8_t*, size_t)
[D] AudioStreams.h : 716 - virtual size_t audio_tools::VolumeStream::write(const uint8_t*, size_t)
[D] I2SStream.h : 124 - virtual size_t audio_tools::I2SStream::write(const uint8_t*, size_t)
[D] I2SESP32.h : 75 - size_t audio_tools::I2SBase::writeBytes(const void*, size_t)
[D] I2SESP32.h : 82 - i2s_write 4608 -> 4608 bytes
[D] AudioStreams.h : 716 - virtual size_t audio_tools::VolumeStream::write(const uint8_t*, size_t)
[D] AudioStreams.h : 716 - virtual size_t audio_tools::VolumeStream::write(const uint8_t*, size_t)
[D] I2SStream.h : 124 - virtual size_t audio_tools::I2SStream::write(const uint8_t*, size_t)
[D] I2SESP32.h : 75 - size_t audio_tools::I2SBase::writeBytes(const void*, size_t)
[D] I2SESP32.h : 82 - i2s_write 4608 -> 4608 bytes
[D] AudioStreams.h : 716 - virtual size_t audio_tools::VolumeStream::write(const uint8_t*, size_t)
[D] AudioStreams.h : 716 - virtual size_t audio_tools::VolumeStream::write(const uint8_t*, size_t)
[D] I2SStream.h : 124 - virtual size_t audio_tools::I2SStream::write(const uint8_t*, size_t)
[D] I2SESP32.h : 75 - size_t audio_tools::I2SBase::writeBytes(const void*, size_t)
[D] I2SESP32.h : 82 - i2s_write 4608 -> 4608 bytes
[D] AudioStreams.h : 716 - virtual size_t audio_tools::VolumeStream::write(const uint8_t*, size_t)
[D] AudioStreams.h : 716 - virtual size_t audio_tools::VolumeStream::write(const uint8_t*, size_t)
[D] I2SStream.h : 124 - virtual size_t audio_tools::I2SStream::write(const uint8_t*, size_t)
[D] I2SESP32.h : 75 - size_t audio_tools::I2SBase::writeBytes(const void*, size_t)
[D] I2SESP32.h : 82 - i2s_write 4608 -> 4608 bytes
[D] AudioStreams.h : 716 - virtual size_t audio_tools::VolumeStream::write(const uint8_t*, size_t)
[D] AudioStreams.h : 716 - virtual size_t audio_tools::VolumeStream::write(const uint8_t*, size_t)
[D] I2SStream.h : 124 - virtual size_t audio_tools::I2SStream::write(const uint8_t*, size_t)
[D] I2SESP32.h : 75 - size_t audio_tools::I2SBase::writeBytes(const void*, size_t)
[D] I2SESP32.h : 82 - i2s_write 4608 -> 4608 bytes
[D] AudioPlayer.h : 797 - virtual void audio_tools::AudioPlayer::copy()
[D] AudioCopy.h : 91 - size_t audio_tools::StreamCopyT::copy() [with T = unsigned char; size_t = unsigned int]
[D] AudioOutput.h : 364 - virtual size_t audio_tools::EncodedAudioStream::write(const uint8_t*, size_t): 61
[D] CodecMP3Helix.h : 107 - virtual size_t audio_tools::MP3DecoderHelix::write(const void*, size_t): 61

end last working cyclus: The output from the helix is 61 instead of my default buffer size (I will decrease it the next run)

[D] MetaDataFilter.h : 35 - size_t audio_tools::MetaDataFilter::write(uint8_t*, size_t) [with Decoder = libhelix::MP3DecoderHelix; size_t = unsigned int; uint8_t = unsigned char]
[D] AudioStreams.h : 716 - virtual size_t audio_tools::VolumeStream::write(const uint8_t*, size_t)
[D] AudioStreams.h : 716 - virtual size_t audio_tools::VolumeStream::write(const uint8_t*, size_t)
[D] I2SStream.h : 124 - virtual size_t audio_tools::I2SStream::write(const uint8_t*, size_t)
[D] I2SESP32.h : 75 - size_t audio_tools::I2SBase::writeBytes(const void*, size_t)
[D] I2SESP32.h : 82 - i2s_write 4608 -> 4608 bytes
[D] AudioPlayer.h : 797 - virtual void audio_tools::AudioPlayer::copy()
[D] AudioCopy.h : 91 - size_t audio_tools::StreamCopyT::copy() [with T = unsigned char; size_t = unsigned int]
[D] AudioPlayer.h : 797 - virtual void audio_tools::AudioPlayer::copy()
[D] AudioCopy.h : 91 - size_t audio_tools::StreamCopyT::copy() [with T = unsigned char; size_t = unsigned int]
[D] AudioPlayer.h : 797 - virtual void audio_tools::AudioPlayer::copy()

I2SStream.h : 124 is not called after I2SESP32.h : 82

Now what is actualy the problem... The input or the output? I think the input because when I change settings of the urlstream things run longer or shorter. And the timings!

I'm sorry I post a lot of working settings that later on seems to be not working for other streams that but, now I will test stream by stream and see what the ultimated settings are. These settings doesn't break the stream anymore, at leasted for one hour testing. Before changing the settings it was only a minute...

#define DEFAULT_BUFFER_SIZE 512//2048//1024//512
#define DEFAULT_SAMPLE_RATE 44100
#define DEFAULT_CHANNELS 2
#define DEFAULT_BITS_PER_SAMPLE 16
#define I2S_DEFAULT_PORT 0
#define I2S_BUFFER_SIZE 1024//512 voor het https breaks
#define I2S_BUFFER_COUNT 10//10
#define A2DP_BUFFER_SIZE 1280
#define A2DP_BUFFER_COUNT 50
#define CODEC_DELAY_MS 1//10//10//3
#define COPY_DELAY_ON_NODATA 5//10//10//5
#define COPY_RETRY_LIMIT 20

#define USE_HELIX
//#define USE_FDK
//#define USE_LAME
//#define USE_MAD

#if defined(ESP32) && !defined(ARDUINO_ESP32C3_DEV)
#include "esp32-hal-log.h"
// optional libraries
//#define USE_A2DP
//#define USE_ESP8266_AUDIO

//#define USE_PWM
#define USE_URL_ARDUINO
#define USE_I2S
//#define USE_AUDIO_SERVER
#define USE_URLSTREAM_TASK
//#define USE_TYPETRAITS
//#define USE_EFFECTS_SUITE
//#define USE_TIMER

#define PWM_FREQENCY 30000
#define PIN_PWM_START 12
#define PIN_I2S_BCK 26//14
#define PIN_I2S_WS 25//15
#define PIN_I2S_DATA_IN 32
#define PIN_I2S_DATA_OUT 27//22
#define I2S_USE_APLL false
#define PIN_I2S_MUTE 23
#define SOFT_MUTE_VALUE LOW
#define PIN_CS SS
#define PIN_ADC1 34
#define PIN_ADC2 14

#define I2S_AUTO_CLEAR true

// URLStream
#define URL_STREAM_CORE 0
#define URL_STREAM_PRIORITY 1//2
#define URL_STREAM_BUFFER_COUNT 20//10
#define STACK_SIZE 30000
#define URL_CLIENT_TIMEOUT 60000;
#define URL_HANDSHAKE_TIMEOUT 120000

@podaen
Copy link
Contributor Author

podaen commented Apr 26, 2022

The second link stops after a minute with the same working settings form the previous comment I have made here.

http://22183.live.streamtheworld.com/JOE.mp3

With //#define USE_URLSTREAM_TASK commented the link works for an halve an hour.

it has some difficulty some times. It falters... and than it stops

@podaen
Copy link
Contributor Author

podaen commented Apr 26, 2022

what I am thinking is that it can't handle the in input. I am testing now if I can get the right settings in #183

@podaen
Copy link
Contributor Author

podaen commented Apr 26, 2022

Doing the test now with one channel and double speed...

#define DEFAULT_SAMPLE_RATE 88200//44100
#define DEFAULT_CHANNELS 1//2

And I have still two channels... Now running for 10 minutes and still active. :-)

@podaen
Copy link
Contributor Author

podaen commented Apr 26, 2022

it still breaks :-/

@podaen
Copy link
Contributor Author

podaen commented Apr 26, 2022

it is very strang that it starts playing again after some time. It is like he has find its begin back...

@podaen
Copy link
Contributor Author

podaen commented Apr 27, 2022

Soo I set the settings back to the originals, and it's outputting sometimes empty pieces

[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
85 72 B8 18 38 70 F8 E7 - 6A 14 E8 41 7B B5 9D 50
86 31 58 B4 A3 23 E9 65 - 7B 35 A7 FF A3 91 5D 19
52 CF 6A 31 D2 97 DD 3B - 7E E8 88 B4 4B CC 9E 7D
94 E8 41 A2 E7 A6 40 D5 - 90 2D 60 3 82 F A4 F
48 81 E8 A7 5E AC 92 24 - 0 3 40 0 22 4D BF 44
B4 D2 38 F4 72 23 D6 47 - 97 C2 42 89 15 4D 0 E2
F4 A4 18 51 1D CD 26 31 - 99 5A B6 DE CA E9 63 AA
21 FC 7F C6 33 F8 9B FF - FE DA 5D E8 FF F5 4C 6E
0 4 E8 0 6 88 14 AB - DF B5 4A FF A1 2A E 6C
F0 5C 9D CA C1 EB 97 35 - AA 1B B B9 97 2E F3 E1
C5 BE 59 23 85 44 16 44 - F3 10 94 72 A 98 3 C1
53 CC BB 58 BB 74 C4 9A - D9 4E B4 8D 2A 45 6B 78
A0 22 C A2 0 87 7F A - 44 2 2D 88 A2 6E 65 BD
91 15 56 B4 33 F5 EA C6 - 28 36 2 A 24 D6 37 AB
3C B5 45 BD 9B 5E CB FF - AF FE 9D 11 4C 5F 75 21
50 C5 47 A E6 36 FA 12 - 10 1C 26 C1 1 40 FB 9C
4D 8C A5 B6 34 78 C4 2D - 25 EE 1C 39 61 AB D1 51
33 F6 F3 FC 1C A8 6 29 - 97 97 39 9C 94 77 EB 21
A4 CD 67 F1 5F 15 28 73 - CB 97 F A4 7 29 58 3E
FC B9 60 1A 62 A 6A 29 - 99 71 89 81 80 0 0 0
0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 FF FB
92 64 0 3 3 DA 2B 4B - C3 6 15 A2 34 20 8 D9
4 22 6E F AD 3F 20 AC - 24 73 18 F6 0 61 30 0
88 0 0 C 0 0 5F 0 - F9 88 E6 BD 24 4C F1 E2
71 A9 A5 AE 2C B9 BB E7 - E CA 99 D3 5B 59 61 41
83 A2 65 33 C1 1B B7 9C - 66 1 B0 D4 DD D9 B B5
F D5 8A 4B A 14 75 40 - 35 20 1 45 1D B2 23 7
0 A3 30 AE 4A 97 8D 28 - EB 23 2 2E 5B D5 58 4E
34 CB 36 96 32 6E 6C 52 - F6 FB 5F FD FC EB D9 A3
15 68 ED 4D DF 58 E9 D7 - E3 70 37 CE 43 A7 96 7F
A8 FF FE CC 61 2D 93 AB - F3 F6 74 AD 23 2 81 58
12 50 2 EA 7B CC A A4 - DD 67 A1 7A DC BA 15 D4
49 A 5B C8 99 31 7E D5 - 13 15 86 5D B 25 43 41
C6 A9 BF FF F2 BD 67 BF - FF FE 25 C D0 D9 B1 99
F3 21 40 2E 24 4A 2 24 - D8 90 11 50 55 C5 8C B9
2C 9 9D 35 E7 1A 5D 1A - 95 51 BB 33 F2 D8 5 21
5D 47 1A 66 32 8 85 84 - C2 11 2A C4 4D 92 8D 19
BC 5A 5B E9 16 7F E3 8B - 6C 64 B2 24 48 91 22 69
64 2C C5 8 95 55 91 99 - BE 6D D5 F6 6E 2A A9 55
55 E3 33 31 F1 B5 5F 55 - 55 6F FD BF 52 63 E7 B
6D 7F 5E 33 31 B3 31 6C - 61 40 45 1B BC 9E 36 FF
F9 75 C7 64 97 C2 82 8E - E9 A1 58 8A FC A6 C4 8
40 0 0 0 84 82 57 3D - C4 6B 5 65 44 47 84 A0
D5 47 84 2E A8 1A 5 4E - C4 47 A0 AB 95 9D E5 89
30 B0 34 78 A9 D5 84 87 - B8 3B 12 FF FF DF C7 FF
FF FC A9 D0 68 F0 34 F0 - E8 4B A 84 93 10 53 51
4C CB 8C 4C C 0 0 0 - 0 0 0 0 0 0 0 0
FF FB 92 64 0 F F2 6F - 64 B0 10 60 2E 32 2F 2
A4 A2 0 26 0 0 0 1 - A4 0 0 0 20 0 0 34
80 0 0 4 0 B B5 96 - 72 CF FC D5 A8 20 56 59
65 92 CB 2C B2 5F FF FC - C5 32 8C 1A 22 30 6A 28
C1 A3 2 C2 23 4 C4 14 - 60 D0 A0 98 D1 3 90 E4
52 3B EF FF D5 15 51 51 - 51 51 55 35 45 45 54 54
54 54 77 FD 4C 24 22 31 - 51 46 D 18 24 34 60 65
55 52 20 0 69 CD 3B 49 - A7 16 CE 51 65 16 59 47
C5 B3 B5 DC 6E 6C D4 9C - 70 19 96 86 99 FF FF FF
FF FF FF FF FF E2 C2 AC - 10 8A 8A B 45 85 85 45
52 98 82 9A 8A 66 5C 62 - 60 60 0 0 0 0 0 0
0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0
0 0 FF FB 92 64 0 0 - 3 1E 31 5E 69 EC 19 C0
57 83 BB BD 3D 82 2E D - 29 79 6F 7 98 B0 C1 48
D EE 70 C3 D 58 BE AE - FD 8E 24 6A 44 16 4 1
4 50 94 4 EC 33 C E - 3A 2D B0 32 0 75 2A E8
31 12 16 1E AE A0 0 B9 - 47 5A 8D B3 29 7A 85 FB
92 99 9F D8 5B 50 41 48 - D8 86 9 27 F7 F9 D2 EF
DA 5B 64 D5 8F 2B 44 2A - 66 B1 44 18 4 1B B7 6E
40 5B 3D 2A DA 44 8 48 - 5C EB D4 D4 8A 10 1A 2A
E 86 94 5 F B0 B7 3E - E8 6D C7 2C 71 44 89 84
12 56 CA 11 28 B6 B2 F8 - 2B 70 6B 3D 4E 22 17 2F
66 B 6 17 54 B9 D3 32 - C2 A4 FD 46 1E B2 31 8
3 87 2A 72 B3 E 9A 85 - 1B 9C 51 63 C0 C9 7A DC
C1 7D 7A 17 42 CA 2D CD - 5B 58 84 8 EC 77 6E 45
8F 4B 90 1A EE D1 29 85 - 15 50 D 6E 8A BC 90 57
E5 49 19 44 D0 A A0 E8 - 5B 46 17 23 F8 C1 A4 6D
30 A3 4F 78 FB 9D B4 FA - 9D A7 D4 10 95 90 DD DC
73 AF 9 25 F0 F2 2A AB - F0 73 EB 1A CD 35 9E BA
A3 92 91 AD 51 B4 95 5A - CB 70 7B B2 D 4B E3 5E
E7 44 6A BA A 2A B1 14 - 71 3E DA 3A AB 6F 51 68
D5 52 D9 59 50 41 35 69 - 15 C 99 AD 79 A8 9D D9
EA 8B 56 E2 11 74 DA E7 - 2E EE F0 54 75 94 0 12
21 F 68 91 36 2F 1F 0 - 62 51 42 D1 DC 9A 18 35
8F 82 49 2 41 E9 A1 CD - A6 B 3C 75 61 59 AE 54
DD 5A FF 50 C6 C2 4D 8A - B 9E AD F0 22 D6 84 D2
A4 8 E4 0 C3 98 36 F3 - 3 58 7F FD EB B6 A6 45
DF A9 1D 51 A9 2B 1A E2 - 81 C9 97 D0 84 C4 14 D4
50 0 0 0 FF FB 92 44 - 0 0 2 D9 29 5E 69 E8
13 C0 58 AA FB 9C 30 23 - BE C 8C 75 71 87 B0 C1
89 88 98 ED F0 C3 D C8 - 9E 5D AB 88 96 AB 4 94
27 40 1D 8C 31 71 3A B - 19 B8 DA 61 AC 29 C8 2A
25 A6 1C 9A 3F 54 2A C4 - 8E 1D C2 75 B6 C3 C6 DE
59 27 16 F9 6 32 E9 C - 7D A2 D2 AA 47 8E DB DE
C6 72 EC 19 F0 C6 31 8B - 18 D2 AF DE E2 47 3E 4A
CE 35 AA 66 86 5B 21 AE - A0 E3 99 3D 68 A0 48 52
B5 93 CB 8A 96 2C A0 51 - A1 5C 9E 1 C0 E8 37 1F
5D 1A 97 85 27 78 6E 5D - 41 6A A5 C4 68 67 8D BF
17 E3 51 63 F5 DE 8E 2B - CC C2 14 51 92 16 E1 5B
D2 C3 9 3C F6 49 B4 45 - F3 28 29 23 E0 AE 87 28
87 6A 24 6B FF 33 F3 A3 - 27 83 ED 64 BE CC C4 A3
9F 93 14 8A 87 5C E2 A5 - 38 9C 1B B0 95 33 65 12
8C 0 2D A2 CC 1F 40 55 - 2 20 F9 80 18 12 F C0
83 E1 17 44 3C 81 E5 8F - 4E 46 EE BD 95 CE CD 45
5 5E F2 B9 DF 23 14 65 - 3B E5 8E FD B0 A0 4A 9B
10 7F 3F F0 63 EC E7 49 - F5 44 53 31 DE E5 68 86
65 15 5F FE F6 F9 7B 99 - BF DD B9 FC FB 69 EA 9D
6D 2F BD F8 F5 3C CC 8F - FC 9C C9 AF 64 C7 BF 1D
4 17 64 22 4 94 48 4 - 83 42 68 1B B8 9A D 78
2A 54 57 1B 49 6A 63 6C - 5E 40 89 4 42 2D CF 11
A8 98 50 5B 7B 98 39 D - C1 12 94 28 6A 79 9E 24
E5 B9 E7 F1 1B F6 C9 B2 - 62 86 8C B2 BE 4A 70 18
95 55 B2 19 24 C5 B5 C2 - 83 8D 5 88 C8 39 4E B5
B5 E 4A CC 3C C3 C6 3 - EF 3E 5C BA 88 91 7A 54
B6 E4 93 10 53 40 FF FB - 92 64 0 0 2 C8 35 DC
59 EC 11 D0 5A 67 5B 8C - 30 62 8A C 28 C5 73 E6
3C 61 81 82 9C EE 70 F3 - 15 E0 A 3B 68 81 20 23

and it stops at 1min and 6 seconds, and a bit later it stops...

Now I am going to time it and watch the end

E2 7 D5 2E 73 42 1D 7D - D5 18 1A 1E 5B C5 D3 21
78 F1 29 72 6E 5 4A 75 - 7A 45 53 D8 DA C 19 7E
1B A2 40 F0 80 86 D0 3E - 4D 39 4C 68 26 BF B6 44
CE AB 76 51 5C E 67 28 - 21 47 9E 19 CC 80 D3 23
AB D5 B3 DA 2F 3C FB 9D - B4 F7 1B 5A B7 D7 33 A4
CD 59 BE 97 3B A9 B9 56 - F1 62 24 3 F 75 E3 59
A3 73 CC BE 5C FB 56 D7 - B5 89 6B C3 27 5 6 6
1A 5B D6 B 2F 73 4C CE - B2 4B 12 4E 97 43 18 B0
48 2C 46 8A F1 77 74 8C - 42 D5 88 71 E0 9C 51 CF
9 F4 76 FC AA E7 6D 4A - 17 CE 30 0 32 32 9E 4B
1C [I] AudioCopy.h : 121 - StreamCopy::copy 161 -> 161 -> 161 bytes - in 1 hops

This is not a random stop!

6B FE 7D 7F F4 D6 58 D - 25 73 37 8A 83 AA 31 15
28 E5 FA 91 47 50 82 D4 - 22 48 48 18 1A 48 74 A1
5 99 81 81 1C D4 ED B0 - 9D A5 CD 25 1D 20 2E B1
54 9 B1 2E E2 A4 2 6C - BB 60 EC 25 E9 1B 2C 17
64 68 82 B2 B5 EA 70 9A - 9B 70 84 5A D8 A9 86 80
81 ED 6C B2 F4 97 F1 33 - 2 D3 45 21 95 42 78 87
EA 32 19 5B FE A6 7F FF - 11 FF B BF FF FF F9 56
56 C7 58 F2 49 A8 9 7C - 35 89 DA 47 97 4A C1 A2
F4 96 20 96 8B 8E 17 DE - A7 30 71 DF A8 75 A7 51
9 4 6B A1 91 4B 47 A5 - EE 74 E4 97 3E 64 67 97
73 [I] AudioCopy.h : 121 - StreamCopy::copy 161 -> 161 -> 161 bytes - in 1 hops

The second test with same settings, the input stream cutoff at almost the same time it stops at exactly 161 bytes
The data it self is not the same. So just a cutoff after one minute or an amount of packages. I think that the server is just trowing me out for a reason. It sound like bad internet connection, firewall or just not fast enough... And I think I would be the last because it was working on 1.0.6. PS: it is a http link with a strong budget server (http://22183.live.streamtheworld.com/JOE.mp3)

And I did set the esp_wifi_set_ps(WIFI_PS_NONE); power mode to non sleep.

@podaen
Copy link
Contributor Author

podaen commented Apr 27, 2022

I found this in my header:

connection: close

But the server uses:

connection: keep-alive

I tried, but it keeps cutting off.

these I found In my browser

2022-04-27_061614

But some setting I can not find

Accept-Language
Upgrade-Insecure-Requests:1

The last one is a resent update of mozilla, This could be it... It apply to an insecure connection.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Upgrade-Insecure-Requests

@podaen
Copy link
Contributor Author

podaen commented Apr 27, 2022

The second test with same settings, the input stream cutoff at almost the same time

I did the test over and set the library power saving to true, but still it cuttoff.

Now I tried to set decrease the audio output in the serial monitor by comment this in the AudioOutput.h

        virtual size_t write(const uint8_t* data, size_t len) {   
            if (!active) return 0;
             LOGD(LOG_METHOD);
            //for (size_t j=0;j<len;j++){
            //    out_ptr->print(data[j], HEX);
            //    out_ptr->print(" ");
            //    pos++;
            //    if (pos == 8){
            //        Serial.print(" - ");
            //    }
            //    if (pos == 16){
            //        Serial.println();
            //        pos = 0;
            //    }
            //}
            return len;
        }

And now it still running after 10 minutes, I see some that the buffer isn't always full... But it keeps running.

[I] AudioCopy.h : 121 - StreamCopy::copy 164 -> 164 -> 164 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 164 -> 164 -> 164 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 956 -> 956 -> 956 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 681 -> 681 -> 681 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 560 -> 560 -> 560 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 328 -> 328 -> 328 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 52 -> 52 -> 52 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 690 -> 690 -> 690 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 164 -> 164 -> 164 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 164 -> 164 -> 164 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 717 -> 717 -> 717 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 164 -> 164 -> 164 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 164 -> 164 -> 164 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[I] AudioCopy.h : 121 - StreamCopy::copy 164 -> 164 -> 164 bytes - in 1 hops

I run an other shetch WITH audio autoput and it still breaks. Decreasing the buffersize to 512 does have also uncomplete buffers. The internet breaks are just to long.

@podaen
Copy link
Contributor Author

podaen commented Apr 27, 2022

Did you know there is a maximum on the header length

https://esp32.com/viewtopic.php?t=24750

@pschatzmann
Copy link
Owner

My current impression is this is an issue of your specific URL. I think after some time they start to send silence.
I changed the URLStream to ICYStream which is much more strict because it expects a metadata entry every n bytes (defined by metaint). I continue to get valid data - but just with no sound.

We could double check this by sending the data to a MultiOutput which consists of I2SStream and a VolumeStream. In the loop we can print the actual volume and I expect this to be 0 when we receive silence

@podaen
Copy link
Contributor Author

podaen commented Apr 27, 2022

I continue to get valid data - but just with no sound.

I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops

In the beginning yeah, but after a few seconds, those are in between

[I] AudioCopy.h : 121 - StreamCopy::copy 84 -> 84 -> 84 bytes - in 1 hops

I am going to see what a working link does but I think it is always the size of the default buffer

@pschatzmann
Copy link
Owner

pschatzmann commented Apr 27, 2022

OK - I have the issue with other URLs as well: Have you already tried to deactivate the USE_URLSTREAM_TASK?

@podaen
Copy link
Contributor Author

podaen commented Apr 27, 2022

yes, your links doing beter dan mine.

B4 C4 CE AC E9 88 8F F3 58 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
6C A1 23 FF D4 41 82 B1 D3 [I] AudioCopy.h : 121 - StreamCopy::copy 126 -> 126 -> 126 bytes - in 1 hops
FF FB 92 64 F5 80 83 53 3F [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
E7 56 F3 85 C5 29 F2 72 AF [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
6B 6 59 83 86 7 3 85 CE [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
A8 85 51 F2 E9 59 E8 50 7 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
2B FE 58 C6 B4 49 35 2 8 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
66 E2 30 E 31 AF 90 6 7E [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
DF 59 78 2B 72 D9 CD CF D [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
3D 7A AD 2 A8 B 10 48 C5 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
77 1A C2 12 E3 88 16 76 49 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
BA 50 E0 4D 69 3A BD 60 C2 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
CA 31 EE 50 7C 5A 2C 19 41 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
3A 58 55 34 28 44 29 63 36 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
EA FF FF F7 FB 7F EF FF FD [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
8 84 11 2 0 8C 9F B0 10 [I] AudioCopy.h : 121 - StreamCopy::copy 31 -> 31 -> 31 bytes - in 1 hops
FF FB 92 64 F2 80 3 26 39 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
FF FF FA B7 FF FA 3F DB 30 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
FE B3 90 C1 B 14 28 CB 6E [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
BF AF 5F FB FC B6 8A 61 6 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
67 A7 E9 FF 1C 50 0 F 52 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
44 C3 20 11 4C 31 0 50 C0 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
DB 5B 1 47 24 92 33 D0 6 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
D3 EB FB 7F FE B8 50 C6 23 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
0 60 B0 8E 60 79 4 62 E7 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
EB A3 3D 40 63 4C B9 15 73 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
E9 F9 BF A3 51 51 F2 8D FD [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
DB BD 93 29 B4 BE 9D F2 3F [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
F8 1 4 A7 4A 1A 89 B3 C7 [I] AudioCopy.h : 121 - StreamCopy::copy 125 -> 125 -> 125 bytes - in 1 hops
FF FB 92 64 E9 8 82 FD 3B [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
2B 66 2F 64 A1 4 C5 FE EC [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
55 3E 9C C8 6F 28 3E 48 B1 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
ED 90 21 82 5E 97 35 1D E [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
88 1 17 A6 40 67 9 45 5E [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
9C 20 7 96 E9 AF 62 C6 10 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
91 2 0 20 8 18 66 1C 94 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
6A 2D 2D C3 4F 89 5F DB 77 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
75 68 43 31 21 8 A2 89 30 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
F9 E6 2B C2 34 82 DB A 31 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
FF FD AA 35 9B D8 4C 40 57 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
43 3E F2 CA 35 CF A0 BA 37 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
FF 14 4E F5 1F A 9D DF 4F [I] AudioCopy.h : 121 - StreamCopy::copy 126 -> 126 -> 126 bytes - in 1 hops
FF FB 92 64 EE 80 2 DB 4D [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
BF D3 E8 A3 3 56 FC 68 1C [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
67 4F F5 FF FF 1D 20 E5 BF [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
FF FF 41 F2 FF 34 2E FD FF [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
25 9C E5 5C 2A 93 8D D9 BE [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
DC E8 67 75 A 6 F 9C 3E [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
6F FE EC 94 74 42 27 59 CE [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
A2 50 3C 54 5E 65 1C 25 FF [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
2D 4D 96 EA A1 D1 B5 32 EE [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
54 3D 64 79 8B BA 3D 6D 45 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
72 35 1C 1E 49 CA 51 A3 E4 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
9E 92 E6 2 A 2A 7E B1 AE [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
80 2 2 BB 65 8E 35 48 7D [I] AudioCopy.h : 121 - StreamCopy::copy 125 -> 125 -> 125 bytes - in 1 hops
FF FB 92 64 C 0 3 61 62 [I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops

@pschatzmann
Copy link
Owner

Did you already check that the issue is not a broken I2S functionality: Is the player from files working stable ?

@podaen
Copy link
Contributor Author

podaen commented Apr 27, 2022

I m using no output to the I2S

URLStream url;
HexDumpStream out;
StreamCopy copier(out, url);

Is the player from files working stable ?

Diden't test it yet.

@podaen
Copy link
Contributor Author

podaen commented Apr 27, 2022

I think my link is a DAB+ radio. and with a leak of performance during the update it slowed down. Even with improved setting we won't get there. Is there a we have to give priority to the input to get default buffer full.

I don' t see a way to test the sd player without outputting something to the i2s.

@podaen
Copy link
Contributor Author

podaen commented Apr 27, 2022

Is there a we have to give priority to the input to get default buffer full.

I think I misstaking here because I don't outputing something. Only to my serial monitor.

@podaen
Copy link
Contributor Author

podaen commented Apr 27, 2022

#include "AudioTools.h"

using namespace audio_tools;

const char* startFilePath = "/";
const char* ext = "mp3";
AudioSourceSdFat source(startFilePath, ext, SD_CS_PIN, 5);//16
HexDumpStream out;
StreamCopy copier(out, source);

C++ no instance of constructor matches the argument list argument types are: (audio_tools::MetaDataPrint, audio_tools::AudioSourceSdFat)

HexDumpStream doesn't accept in streamcopy

@pschatzmann
Copy link
Owner

I deactivated the task and added the MeasuringStream on the receiving side with the following result:
With audible audio: 15:54:15.025 -> [I] AudioStreams.h : 959 - Bytes per second: 15000
When audio is breaking up 15:54:19.814 -> [I] AudioStreams.h : 959 - Bytes per second: 88000
So the issue is not that the data is coming too slow...

I have more the impression now that the I2S functionality is broken because it should stall the processing.

I will play some music from the SD card to double check.

@podaen
Copy link
Contributor Author

podaen commented Apr 27, 2022

How do you you know that 15kbs-88kbs is enough? I suspect that the input is between 128 and 192kb/s...

But yeah, I think also that the I2S breaks. Because I still see there is audio, but won't come out.

@pschatzmann
Copy link
Owner

15000 is enough because if you monitor the data consumption that's the value that is constantly used.
Anything much higher means that the values are not decoded and played correctly any more

@pschatzmann
Copy link
Owner

pschatzmann commented Apr 27, 2022

I think we have the issue also playing files: after some (long) time we have the same effect. Just with the difference that we reach the end of the file quickly and when we switch to the next file the error is corrected by the file change logic, so the next file is playing fine again...

@podaen
Copy link
Contributor Author

podaen commented Apr 27, 2022

diden' t see anything that was higher. I let you do now and I would happy to test it.

Yes switching between url-streams makes a difference. That I can tell.

@pschatzmann
Copy link
Owner

My mistake, I was mixing is up with WifiClient...

@podaen
Copy link
Contributor Author

podaen commented May 12, 2022

I left the httpclient and setup my own client. Same results

  WiFiClient client;
  const char host[] = "22183.live.streamtheworld.com";
  String url = "http://22183.live.streamtheworld.com/JOE.mp3";
  const int httpPort = 80;
  if (!client.connect(host, httpPort)) {
  	Serial.println("connection failed");
  	return;
  }
  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
  	"Host: " + host + "\r\n" +
  	"Connection: close\r\n\r\n");
  while (!client.available()) {
  	Serial.println(".");
  	delay(1000);
  }
                uint8_t buffer[512] = { 0 };
          int buffer_size = 512;
  size_t result = client.available();
  if (result > 0) {
  	while (client.connected()) {
  		size_t size = min(result, static_cast<size_t>(buffer_size));
  		//Serial.print("size: ");
  		//Serial.println(size);
  		size_t read = client.readBytes((uint8_t*)buffer, size);
  		if (read > 0) {
  			Serial.print("read: ");
  			Serial.println(read);
  		}
  	}
  }

res read wificlient: 1
size in read: 1
a begin: 325
_size Buffer: 1336
_fill: 466
_pos: 141
len=1

I notest that in the beginning of the url-player too, but than somehow it changes and the result start to come through.

@podaen
Copy link
Contributor Author

podaen commented May 12, 2022

This is how it changes

es read wificlient: 1
size in read: 1
a begin: 660
_size Buffer: 1336
_fill: 1336
_pos: 676
len=1
_pos: 677
len: 1

res read wificlient: 1
[I] HttpHeader.h : 161 - HttpHeader::readLine -> Server: MediaGateway 5.7.2-0453.el6
size in read: 1
a begin: 659
_size Buffer: 1336
_fill: 1336
_pos: 677
len=1
_pos: 678
len: 1

res read wificlient: 1
size in read: 1
a begin: 658
_size Buffer: 1336
_fill: 1336
_pos: 678
len=1
_pos: 679
len: 1

res read wificlient: 1
[I] HttpHeader.h : 161 - HttpHeader::readLine ->
[W] HttpRequest.h : 145 - no CONTENT_LENGTH found in reply
[I] URLStream.h : 85 - size: 0
[I] AudioCopy.h : 66 - buffer_size=512
RSSI: -78

size in read: 512
a begin: 393
_size Buffer: 1336
_fill: 1336
_pos: 943
toRead: 393
_pos: 943
left: 119
_fill: 0
_size: 1336
[I] AudioCopy.h : 121 - StreamCopy::copy 512 -> 512 -> 512 bytes - in 1 hops
received size: 1336
New_fill size: 1336
toRead: 119
_pos: 0

res read wificlient: 512
size in read: 512
a begin: 1217
_size Buffer: 1336
_fill: 1336
_pos: 119
_pos: 631
len: 512

res read wificlient: 512
size in read: 512
a begin: 705
_size Buffer: 1336
_fill: 1336
_pos: 631
_pos: 1143
len: 512

[I] HttpHeader.h : 161 - HttpHeader::readLine -> Server: MediaGateway 5.7.2-0453.el6
This says it reading one line, but it only reading one byte at the untill it sets this [I] AudioCopy.h : 66 - buffer_size=512

@podaen
Copy link
Contributor Author

podaen commented May 12, 2022

Stupid of me, think I have found it.

//size_t read = stream->readBytes(buffer, size);
size_t read = stream->read(buffer, size);

Still reading one byte before it's connected, but after that it reads the package size I have set.. Now I starting to interpreter the data.

res read wificlient: 1
[ 8761][V][HTTPClient.cpp:1250] handleHeaderResponse(): RX: 'Server: MediaGateway 5.7.2-0453.el6'
size in read: 1
a begin: 659
_size Buffer: 1336
_fill: 1336
_pos: 677
len=1
_pos: 678
len: 1

res read wificlient: 1
size in read: 1
a begin: 658
_size Buffer: 1336
_fill: 1336
_pos: 678
len=1
_pos: 679
len: 1

res read wificlient: 1
[ 8768][V][HTTPClient.cpp:1250] handleHeaderResponse(): RX: ''
[ 8769][D][HTTPClient.cpp:1307] handleHeaderResponse(): code: 200
[ 8770][D][HTTPClient.cpp:628] sendRequest(): sendRequest code=200

[HTTP] GET... code: 200
HTTP_CODE_OK: 200
read bytes
size in read: 512
a begin: 657
_size Buffer: 1336
_fill: 1336
_pos: 679
_pos: 1191
len: 512

res read wificlient: 512
read: 512

size in read: 512
a begin: 145
_size Buffer: 1336
_fill: 1336
_pos: 1191
toRead: 145
_pos: 1191
left: 367
_fill: 0
_size: 1336
received size: 1336
New_fill size: 1336
toRead: 367
_pos: 0

@podaen
Copy link
Contributor Author

podaen commented May 12, 2022

Phil could you please see what's wrong? I'm using now your link but data comes in slowly after some time... It is my shetch because with the url-player it doesn't happen.

#include <WiFi.h>
#include <WiFiClient.h>
#include <HTTPClient.h>
#include <WiFiClientSecure.h>
#include <esp_bt_main.h>//power saving bluetooth
#include <esp_bt.h>//power saving bluetooth

const char* ssid = "PODAEN";
const char* password = "elena2012";
#define BUFFER_SIZE 512

// the setup function runs once when you press reset or power the board
void setup() {
	Serial.begin(500000);
	while (!Serial);

	WiFi.mode(WIFI_MODE_STA);
	WiFi.begin(ssid, password);
	while (WiFi.status() != WL_CONNECTED) {
		delay(1000);
		// Serial.println("Connecting to WiFi..");
	}
    Serial.println("Connected");
	WiFi.setSleep(false);

	esp_bluedroid_disable();
	esp_bluedroid_deinit();
	esp_bt_controller_disable();
	esp_bt_controller_deinit();
    Serial.println("end setup");

}

// the loop function runs over and over again until power down or reset
void loop() {
	if (WiFi.status() == WL_CONNECTED) {
		HTTPClient http;
        //http = new HTTPClient;
		//http.begin("http://22183.live.streamtheworld.com/JOE.mp3");
        http.begin("http://sunshineradio.ice.infomaniak.ch/sunshineradio-128.mp3");
		Serial.println("[HTTP] begin...\n");

        http.addHeader("Host", "sunshineradio.ice.infomaniak.ch");
        //http.addHeader("Host", "22183.live.streamtheworld.com");
        http.addHeader("Connection", "close");
        http.addHeader("Accept-Encoding", "");
        http.addHeader("Accept", "*/*");
        http.setUserAgent("Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)");
        
        //client.println("GET " + PATH_NAME + queryString + " HTTP/1.1");
        //client.println("Host: " + String(HOST_NAME));
        //client.println("Connection: close");
        //client.println(); // end HTTP header

        //http.setReuse(true);
        http.setTimeout(30000);
        int httpCode = http.GET();
        if (httpCode > 0) {
            // HTTP header has been send and Server response header has been handled
            Serial.printf("[HTTP] GET... code: %d\n", httpCode);

            // file found at server
            if (httpCode == HTTP_CODE_OK) {
                Serial.print("HTTP_CODE_OK: ");
                Serial.println(HTTP_CODE_OK);

                //int buffer_size = BUFFER_SIZE;
                //uint8_t* buffer = nullptr;;
               // int buffer_size = 512;
                //buffer = new uint8_t[buffer_size];
                uint8_t buffer[512] = { 0 };
                int buffer_size = 512;

                WiFiClient* stream = http.getStreamPtr();
                //stream* stream = http.getStreamPtr();
                delay(5000);
                size_t result = stream->available();
                //int result = stream->available();
                Serial.println("read bytes");
                if (result > 0) {
                    while (http.connected()) {
                        size_t size = min(result, static_cast<size_t>(buffer_size));
                        //Serial.print("size: ");
                        //Serial.println(size);
                        //size_t read = stream->read(buffer, size);
                        size_t read = stream->read((uint8_t*)buffer, size);
                        
                        if (read > 0) {
                            Serial.print("read: ");
                            Serial.println(read);
                            Serial.println("");
                        }
                    }
                }

                Serial.println();
                Serial.print("[HTTP] connection closed or file end.\n");
            }
        }
        else {
            Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
        }

        http.end();
    }
    delay(10000);
}

@pschatzmann
Copy link
Owner

Not sure if it related to this but it is a bad idea to do result = stream->available(); before the loop. It should really be in the loop...

@podaen
Copy link
Contributor Author

podaen commented May 12, 2022

it keeps running now but it isn't stable. the buffer isn't allways filled. I think it is because it is emptyted to quick. When I put a delay in it it crashes after some time. How could this be handled that the buffer is always full but doesn't slow down so much?

received size: 1336
New_fill size: 1336

read: 512

read: 512

read: 512

received size: 1336
New_fill size: 1336

read: 512

read: 512

received size: 286
New_fill size: 286

read: 512

read: 114

Sounds like a task. But not sure how we could check this, because it would be allready be filled if checking. Complete or not complete...

@podaen
Copy link
Contributor Author

podaen commented May 12, 2022

oh maybe with availible like you said maybe. The RX buffer need to be two times the size of the default buffer, because it runs the read two times before complete. I'm going to try something see how it works...

@podaen
Copy link
Contributor Author

podaen commented May 12, 2022

I am confused now, because we add this to the player and it diden't end up wel sometimes. I cam out with the righbuffer, but we steped off of that... Not sure what the reason was but I think it had something to do with the application or the output to the I2S.

Three things to do... If the buffer not empty in time data is missing. if we don't do the application in time, thinks don't get further and if we don't output it, we don't have sound...

I thinks the task have to comunicate with eachother to know that we could proceed. This can only be done in the shetch... is this somehow possible?

@podaen
Copy link
Contributor Author

podaen commented May 12, 2022

I was thinking out loud. For the simple shetch I had to check if there was two times the size of the buffer availible and now it is allways filled.

The timeout in the player is for the stream to get empty and that's allready there... The timeout in the copy would say we don't receive anything in time and just bailout.

There could be still in bug in the uncompleted receive of the arduino-esp, but avoiding it will cause a lot less trouble.

@pschatzmann
Copy link
Owner

I don't think this is an issue: we just need to receive data in a speed where the decoded result is catching up with the playing: Maybe you should even change you sketch to receive the full buffer size - and not check for the available bytes...

@podaen
Copy link
Contributor Author

podaen commented May 12, 2022

Can the data outputed directly to a spreaker with the internal dac? Or need it to be converted some how...

@pschatzmann
Copy link
Owner

If it is mp3 it needs to be decoded into PCM

@pschatzmann
Copy link
Owner

pschatzmann commented May 13, 2022

I think I found the issue: I completely forgot that I have added a metadata filter to libhelix which might be the source of the trouble. I deactivated the functionality and so far it's looking good.

Can you verify ?

ps. my using #define CHECK_MEMORY() checkMemory(true) - in the AudioConfig.h - you can activate additional memory checks and logging

@DrJaymz
Copy link

DrJaymz commented May 13, 2022

I think I found the issue: I completely forgot that I have added a metadata filter to libhelix which might be the source of the trouble. I deactivated the functionality and so far it's looking good.

Can you verify ?

ps. my using #define CHECK_MEMORY() checkMemory(true) - in the AudioConfig.h - you can activate additional memory checks and logging

Wait - what? I have been monitoring the conversation but got a bit lost in the fragments.

@pschatzmann
Copy link
Owner

pschatzmann commented May 13, 2022

Me as well: I propose to close this issue and if it is not resolved to open a new one which only contains the relevant information. After all it this one is starting with AudioMozzi...

I was testing with one of the mentioned links: https://25493.live.streamtheworld.com:443/NOSTALGIEWAFEXTRA.mp3

@podaen
Copy link
Contributor Author

podaen commented May 13, 2022

I have added a metadata filter to libhelix which might be the source of the trouble.

I don't think this is it, because the last time I test it, I didn't activate //#define USE_HELIX...

I'm creating now a library so they can test and I countering a few issues to make it work. but I still need to add the to simple pcm decoder so I could hear that data is stil valid.

What I learned for now it that I used the wrong datatypes for the included library of ESP. But there is still a variation in response of the read function.

@pschatzmann
Copy link
Owner

We are starting to get lost on this one, so I guess there is no agreement what the issue exactly is: I propose to open a new one with a description and a example sketch, so that we can reproduce it.

@DrJaymz
Copy link

DrJaymz commented May 17, 2022

I am lost, so which issue should I be following to get music to play without stopping?

@pschatzmann
Copy link
Owner

Do you have any such case with the latest corrections ?

@DrJaymz
Copy link

DrJaymz commented May 18, 2022

I'm trying but can't check out the latest for some reason.

Cloning into 'C:\Users\james.platformio.cache\tmp\pkg-installing-p6ncwnrg'...
error: invalid path 'examples/sandbox/streams-url_opus-i2s /README.md'

there is a space at the end of the filename in the repo which is invalid. So the error is correct. But I don't know a quick way to fix.

@podaen
Copy link
Contributor Author

podaen commented May 18, 2022

You can't. I am not a member of this repo so I can't help you. You need to wait untill the owner delete the blank space of that directory.

@pschatzmann
Copy link
Owner

Oops, I didn't notice: I just committed the correction

@DrJaymz
Copy link

DrJaymz commented May 18, 2022

I broke my project now. :(
I will have to actually do actual work, but I will have a look a little later.

@DrJaymz
Copy link

DrJaymz commented May 18, 2022

OK, I builds now.... I will test it in a bit

@pschatzmann
Copy link
Owner

pschatzmann commented May 18, 2022

Please note that the biggest change is that I have commented out USE_URLSTREAM_TASK in AudioConfig.h as default setting. I came to the conclusion that this is leaner and better and leaves more free RAM...

@DrJaymz
Copy link

DrJaymz commented May 23, 2022

Left it playing all weekend, it didn't stop playing.
It does glitch a little bit every now and then with a squeak which I think is probably a buffer underrun. But I'd say thats ok now. Certainly no sign of memory leaks over that period.

@pschatzmann
Copy link
Owner

Cool, this is matching with the results of my tests

@podaen
Copy link
Contributor Author

podaen commented Oct 21, 2022

Update:

I had an power suffering issue that has been solved now. I detected that the protocol that was selected was B, that limits the data transfer to 10Mbs and that was maybe been flashed and restored. At least we did more here brothers J and H :-) Now I have the latest for my board N.

Here is my code to test it. Be sure you place this after esp_wifi_start();

#include "esp_wifi.h"
#include "esp_log.h"

    uint8_t getprotocol;
    err = esp_wifi_get_protocol(WIFI_IF_STA, &getprotocol);
    if (err != ESP_OK) {
        Serial.println("Could not get protocol!");
        //log_e("Could not get protocol! %d", err);
        return false;
    }
    if (getprotocol & WIFI_PROTOCOL_11N) {
        Serial.println("WiFi_Protocol_11n");
    }
    if (getprotocol & WIFI_PROTOCOL_11G) {
        Serial.println("WiFi_Protocol_11g");
    }
    if (getprotocol & WIFI_PROTOCOL_11B) {//worst, but dificuld to set else
        Serial.println("WiFi_Protocol_11b");
    }

    wifi_bandwidth_t wifi_bandwidth;
    err = esp_wifi_get_bandwidth(WIFI_IF_STA, &wifi_bandwidth);
    if (err != ESP_OK) {
        Serial.println("Could not get bandwide!");
        //log_e("Could not get protocol! %d", err);
        return false;
    }
    if (wifi_bandwidth & WIFI_BW_HT20) {
        Serial.println("WiFi_Bandwide_WIFI_BW_HT20");
    }
    if (wifi_bandwidth & WIFI_BW_HT40) {
        //WIFI_BW_HT40 is supported only when the interface support 11N
        Serial.println("WiFi_Bandwide_WIFI_BW_HT40");
    }

    uint8_t primary;
    wifi_second_chan_t second;
    err = esp_wifi_get_channel(&primary, &second);
    if (err != ESP_OK) {
        Serial.println("Could not get channel!");
        //log_e("Could not get protocol! %d", err);
        return false;
    }
    else
    {
        Serial.print("primairy channel: ");
        Serial.println(primary);
    }
    if (second & WIFI_SECOND_CHAN_NONE) {//Doesn't print???
        Serial.println("WiFi_WIFI_SECOND_CHAN_NONE");
    }
    if (second & WIFI_SECOND_CHAN_ABOVE) {
        Serial.println("WiFi_WIFI_SECOND_CHAN_ABOVE");
    }
    if (second & WIFI_SECOND_CHAN_BELOW) {
        Serial.println("WiFi_WIFI_SECOND_CHAN_BELOW");
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants