arduino-audio-tools
All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Modules Pages
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
URLStreamESP32 Class Reference

URLStream using the ESP32 IDF API. More...

#include <URLStreamESP32.h>

Inheritance diagram for URLStreamESP32:
AbstractURLStream AudioStream BaseStream AudioInfoSupport AudioInfoSource Stream Print

Public Member Functions

 URLStreamESP32 (const char *ssid, const char *pwd)
 
virtual void addNotifyAudioChange (AudioInfoSupport &bi)
 Adds target to be notified about audio changes.
 
void addRequestHeader (const char *key, const char *value) override
 Adds/Updates a request header.
 
virtual AudioInfo audioInfo () override
 provides the actual input AudioInfo
 
virtual AudioInfo audioInfoOut ()
 
virtual int available () override
 
int availableForWrite () override
 Writes are not supported.
 
virtual bool begin ()
 
virtual bool begin (const char *urlStr, const char *acceptMime="", MethodID action=GET, const char *reqMime="", const char *reqData="")
 
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
 
int contentLength () override
 Provides the reported data size from the http reply.
 
virtual void end () override
 
virtual void flush () override
 
const char * getReplyHeader (const char *key) override
 Provides a header entry.
 
HttpRequesthttpRequest () override
 Used for request and reply header parameters.
 
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
 
virtual operator bool ()
 
size_t readBytes (uint8_t *data, size_t len) override
 
virtual size_t readSilence (uint8_t *buffer, size_t length)
 Source to generate silence: just sets the buffer to 0.
 
virtual bool removeNotifyAudioChange (AudioInfoSupport &bi)
 Removes a target in order not to be notified about audio changes.
 
virtual void setAudioInfo (AudioInfo newInfo) override
 Defines the input AudioInfo.
 
void setCACert (const char *cert) override
 
void setCACert (esp_err_t(*cb)(void *conf))
 
void setClient (Client &client) override
 Does nothing.
 
void setConnectionClose (bool flag) override
 Not used.
 
virtual bool setMetadataCallback (void(*fn)(MetaDataType info, const char *str, int len))
 
void setNotifyActive (bool flag)
 Deactivate/Reactivate automatic AudioInfo updates: (default is active)
 
virtual void setPassword (const char *password)
 Sets the password that will be used for logging in (when calling begin)
 
virtual void setPowerSave (bool ps)
 Sets the power save mode (default false)!
 
void setReadBufferSize (int size)
 Defines the read buffer size.
 
virtual void setSSID (const char *ssid)
 Sets the ssid that will be used for logging in (when calling begin)
 
size_t totalRead () override
 Total amout of data that was consumed so far.
 
const char * urlStr () override
 Provides the url as string.
 
virtual bool waitForData (int timeout) override
 Not used.
 
size_t write (const uint8_t *data, size_t len) override
 
virtual size_t write (uint8_t ch) override
 
virtual void writeSilence (size_t len)
 Writes len bytes of silence (=0).
 

Protected Member Functions

virtual int not_supported (int out, const char *msg="")
 
void notifyAudioChange (AudioInfo info)
 
void refillReadBuffer ()
 
void setCACert (const uint8_t *cert, int len)
 

Static Protected Member Functions

static esp_err_t http_event_handler (esp_http_client_event_t *evt)
 

Protected Attributes

int _timeout = 10
 
int buffer_size = DEFAULT_BUFFER_SIZE
 
esp_http_client_handle_t client_handle = nullptr
 
int content_length = 0
 
esp_err_t(* crt_bundle_attach )(void *conf) = nullptr
 
int id = 0
 
AudioInfo info
 
bool is_notify_active = true
 
bool is_power_save = false
 
Vector< AudioInfoSupport * > notify_vector
 
const char * password = nullptr
 
const uint8_t * pem_cert = nullptr
 
int pem_cert_len = 0
 
HttpRequest request
 
const char * ssid = nullptr
 
RingBuffer< uint8_t > tmp_in {0}
 
RingBuffer< uint8_t > tmp_out {0}
 
size_t total_read = 0
 
const char * url_str = nullptr
 

Detailed Description

URLStream using the ESP32 IDF API.

For Https you need to provide the certificate. Execute: openssl s_client -showcerts -connect www.howsmyssl.com:443 </dev/null

To completely disable the certificate check, you will need to go to ESP-TLS in menuconfig, enable "Allow potentially insecure options" and then enable "Skip server certificate verification by default" (accepting risks).

This is unfortunately not an option when using Arduino!

Author
Phil Schatzmann

Member Function Documentation

◆ addNotifyAudioChange()

virtual void addNotifyAudioChange ( AudioInfoSupport bi)
inlinevirtualinherited

◆ addRequestHeader()

void addRequestHeader ( const char *  key,
const char *  value 
)
inlineoverridevirtual

Adds/Updates a request header.

Implements AbstractURLStream.

◆ audioInfo()

virtual AudioInfo audioInfo ( )
inlineoverridevirtualinherited

◆ audioInfoOut()

virtual AudioInfo audioInfoOut ( )
inlinevirtualinherited

◆ available()

virtual int available ( )
inlineoverridevirtualinherited

◆ availableForWrite()

int availableForWrite ( )
inlineoverridevirtual

Writes are not supported.

Reimplemented from AbstractURLStream.

◆ begin() [1/2]

virtual bool begin ( )
inlinevirtualinherited

◆ begin() [2/2]

virtual bool begin ( const char *  urlStr,
const char *  acceptMime = "",
MethodID  action = GET,
const char *  reqMime = "",
const char *  reqData = "" 
)
inlinevirtual

Implements AbstractURLStream.

◆ contentLength()

int contentLength ( )
inlineoverridevirtual

Provides the reported data size from the http reply.

Implements AbstractURLStream.

◆ end()

virtual void end ( )
inlineoverridevirtual

Implements AbstractURLStream.

◆ flush()

virtual void flush ( )
inlineoverridevirtualinherited

Reimplemented from Print.

Reimplemented in ResampleStream, BufferedTaskStream, and BufferedStream.

◆ getReplyHeader()

const char * getReplyHeader ( const char *  key)
inlineoverridevirtual

Provides a header entry.

Implements AbstractURLStream.

◆ httpRequest()

HttpRequest & httpRequest ( )
inlineoverridevirtual

Used for request and reply header parameters.

Implements AbstractURLStream.

◆ operator bool()

virtual operator bool ( )
inlinevirtualinherited

Reimplemented in A2DPStream, Pipeline, I2SStream, and MemoryStream.

◆ readBytes()

size_t readBytes ( uint8_t *  data,
size_t  len 
)
inlineoverridevirtual

Reimplemented from AudioStream.

◆ setAudioInfo()

virtual void setAudioInfo ( AudioInfo  info)
inlineoverridevirtualinherited

◆ setCACert() [1/3]

void setCACert ( const char *  cert)
inlineoverridevirtual

Define the Root PEM Certificate for SSL: Method compatible with Arduino WiFiClientSecure API

Implements AbstractURLStream.

◆ setCACert() [2/3]

void setCACert ( const uint8_t *  cert,
int  len 
)
inlineprotected

Define the Root PEM Certificate for SSL: the last byte must be null, the len is including the ending null

◆ setCACert() [3/3]

void setCACert ( esp_err_t(*)(void *conf)  cb)
inline

Attach and enable use of a bundle for certificate verification e.g. esp_crt_bundle_attach or arduino_esp_crt_bundle_attach

◆ setClient()

void setClient ( Client client)
inlineoverridevirtual

Does nothing.

Implements AbstractURLStream.

◆ setConnectionClose()

void setConnectionClose ( bool  flag)
inlineoverridevirtual

Not used.

Implements AbstractURLStream.

◆ setMetadataCallback()

virtual bool setMetadataCallback ( void(*)(MetaDataType info, const char *str, int len)  fn)
inlinevirtualinherited

Reimplemented in ICYStreamT< T >.

◆ setPassword()

virtual void setPassword ( const char *  password)
inlinevirtual

Sets the password that will be used for logging in (when calling begin)

Implements AbstractURLStream.

◆ setPowerSave()

virtual void setPowerSave ( bool  ps)
inlinevirtual

Sets the power save mode (default false)!

Implements AbstractURLStream.

◆ setSSID()

virtual void setSSID ( const char *  ssid)
inlinevirtual

Sets the ssid that will be used for logging in (when calling begin)

Implements AbstractURLStream.

◆ totalRead()

size_t totalRead ( )
inlineoverridevirtual

Total amout of data that was consumed so far.

Implements AbstractURLStream.

◆ urlStr()

const char * urlStr ( )
inlineoverridevirtual

Provides the url as string.

Implements AbstractURLStream.

◆ waitForData()

virtual bool waitForData ( int  timeout)
inlineoverridevirtual

Not used.

Implements AbstractURLStream.

◆ write() [1/2]

size_t write ( const uint8_t *  data,
size_t  len 
)
inlineoverridevirtual

Reimplemented from AudioStream.

◆ write() [2/2]

virtual size_t write ( uint8_t  ch)
inlineoverridevirtualinherited

Reimplemented in BufferedTaskStream, and BufferedStream.


The documentation for this class was generated from the following file: