arduino-audio-tools
Loading...
Searching...
No Matches
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 MimeSource BaseStream AudioInfoSupport AudioInfoSource Stream Print

Public Member Functions

 URLStreamESP32 ()
 
 URLStreamESP32 (const char *ssid, const char *pwd)
 
 ~URLStreamESP32 ()
 
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 chargetReplyHeader (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.
 
const charmime () override
 Provides the MIME type for the current stream.
 
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)
 
void setWriteBufferSize (int size)
 
size_t totalRead () override
 Total amout of data that was consumed so far.
 
const charurlStr () 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 ()
 Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read()
 
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 charpassword = nullptr
 
const uint8_tpem_cert = nullptr
 
int pem_cert_len = 0
 
HttpRequest request
 
const charssid = nullptr
 
RingBuffer< uint8_ttmp_in {0}
 
RingBuffer< uint8_ttmp_out {0}
 
size_t total_read = 0
 
const charurl_str = nullptr
 
int write_buffer_size = MAX_SINGLE_CHARS
 

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

Constructor & Destructor Documentation

◆ URLStreamESP32() [1/2]

URLStreamESP32 ( const char ssid,
const char pwd 
)
inline

◆ URLStreamESP32() [2/2]

URLStreamESP32 ( )
inline

◆ ~URLStreamESP32()

~URLStreamESP32 ( )
inline

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.

◆ clearNotifyAudioChange()

virtual void clearNotifyAudioChange ( )
inlinevirtualinherited

Deletes all change notify subscriptions.

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ 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

◆ getReplyHeader()

const char * getReplyHeader ( const char key)
inlineoverridevirtual

Provides a header entry.

Implements AbstractURLStream.

◆ http_event_handler()

static esp_err_t http_event_handler ( esp_http_client_event_t evt)
inlinestaticprotected

◆ httpRequest()

HttpRequest & httpRequest ( )
inlineoverridevirtual

Used for request and reply header parameters.

Implements AbstractURLStream.

◆ isNotifyActive()

bool isNotifyActive ( )
inlineinherited

Checks if the automatic AudioInfo update is active.

◆ mime()

const char * mime ( )
inlineoverridevirtualinherited

Provides the MIME type for the current stream.

Implements MimeSource.

◆ not_supported()

virtual int not_supported ( int  out,
const char msg = "" 
)
inlineprotectedvirtualinherited

◆ notifyAudioChange()

void notifyAudioChange ( AudioInfo  info)
inlineprotectedinherited

◆ operator bool()

virtual operator bool ( )
inlinevirtualinherited

◆ readBytes()

size_t readBytes ( uint8_t data,
size_t  len 
)
inlineoverridevirtual

Reimplemented from AudioStream.

◆ readSilence()

virtual size_t readSilence ( uint8_t buffer,
size_t  length 
)
inlinevirtualinherited

Source to generate silence: just sets the buffer to 0.

◆ refillReadBuffer()

void refillReadBuffer ( )
inlineprotectedinherited

Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read()

◆ removeNotifyAudioChange()

virtual bool removeNotifyAudioChange ( AudioInfoSupport bi)
inlinevirtualinherited

Removes a target in order not to be notified about audio changes.

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ 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 ICYStreamBuffered, and ICYStreamT< T >.

◆ setNotifyActive()

void setNotifyActive ( bool  flag)
inlineinherited

Deactivate/Reactivate automatic AudioInfo updates: (default is active)

◆ 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.

◆ setReadBufferSize()

void setReadBufferSize ( int  size)
inline

Defines the read buffer size.

◆ setSSID()

virtual void setSSID ( const char ssid)
inlinevirtual

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

Implements AbstractURLStream.

◆ setWriteBufferSize()

void setWriteBufferSize ( int  size)
inlineinherited

◆ 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

◆ writeSilence()

virtual void writeSilence ( size_t  len)
inlinevirtualinherited

Writes len bytes of silence (=0).

Member Data Documentation

◆ _timeout

int _timeout = 10
protectedinherited

◆ buffer_size

int buffer_size = DEFAULT_BUFFER_SIZE
protected

◆ client_handle

esp_http_client_handle_t client_handle = nullptr
protected

◆ content_length

int content_length = 0
protected

◆ crt_bundle_attach

esp_err_t(* crt_bundle_attach) (void *conf) = nullptr
protected

◆ id

int id = 0
protected

◆ info

AudioInfo info
protectedinherited

◆ is_notify_active

bool is_notify_active = true
protectedinherited

◆ is_power_save

bool is_power_save = false
protected

◆ notify_vector

Vector<AudioInfoSupport*> notify_vector
protectedinherited

◆ password

const char* password = nullptr
protected

◆ pem_cert

const uint8_t* pem_cert = nullptr
protected

◆ pem_cert_len

int pem_cert_len = 0
protected

◆ request

HttpRequest request
protected

◆ ssid

const char* ssid = nullptr
protected

◆ tmp_in

RingBuffer<uint8_t> tmp_in {0}
protectedinherited

◆ tmp_out

RingBuffer<uint8_t> tmp_out {0}
protectedinherited

◆ total_read

size_t total_read = 0
protected

◆ url_str

const char* url_str = nullptr
protected

◆ write_buffer_size

int write_buffer_size = MAX_SINGLE_CHARS
protectedinherited

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