Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
gemu2015 committed Sep 8, 2024
1 parent 0d922fe commit b2f3e1c
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 76 deletions.
16 changes: 8 additions & 8 deletions lib/libesp32/berry/generate/be_const_bytes.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/* extern binary arrays */
extern const binstance_arg3 be_const_instance_;
extern const binstance_arg3 be_const_instance_0000000100020003FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_000000010002000300040005FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_0000FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_00030005000A000F00110012FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_00000001FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_0000000100020003FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_00030005000A000F00110012FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_0000FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_000000010002FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_000000020003000F0011FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_000000050007000A000B000D000E0017FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_00070008000F400B400CFFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_00000001000200080009FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_00000001000200030004FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_00030004FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_0000000100020003000400050006000700080009000A000F001100120013FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_000000010007FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_0000000100020008FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_000000010007FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_0000000200030004FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_0000000100020008FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_00030004FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_0000000100020003000400050006000700080009000A000F001100120013FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_00000001000200030004FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_000000050007000A000B000C000D000E000F0017FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_0000000100070008000F4001400AFFF8FFF9FFFAFFFBFFFCFFFD;
16 changes: 8 additions & 8 deletions lib/libesp32/berry/generate/be_const_bytes_def.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/* binary arrays */
be_define_const_bytes_empty();
be_define_const_bytes(0000000100020003FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(000000010002000300040005FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(0000FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(00030005000A000F00110012FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x03, 0x00, 0x05, 0x00, 0x0A, 0x00, 0x0F, 0x00, 0x11, 0x00, 0x12, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(00000001FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(0000000100020003FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(00030005000A000F00110012FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x03, 0x00, 0x05, 0x00, 0x0A, 0x00, 0x0F, 0x00, 0x11, 0x00, 0x12, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(0000FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(000000010002FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(000000020003000F0011FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x0F, 0x00, 0x11, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(000000050007000A000B000D000E0017FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x0A, 0x00, 0x0B, 0x00, 0x0D, 0x00, 0x0E, 0x00, 0x17, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(00070008000F400B400CFFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x07, 0x00, 0x08, 0x00, 0x0F, 0x40, 0x0B, 0x40, 0x0C, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(00000001000200080009FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x08, 0x00, 0x09, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(00000001000200030004FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(00030004FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x03, 0x00, 0x04, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(0000000100020003000400050006000700080009000A000F001100120013FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08, 0x00, 0x09, 0x00, 0x0A, 0x00, 0x0F, 0x00, 0x11, 0x00, 0x12, 0x00, 0x13, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(000000010007FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x07, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(FFF8FFF9FFFAFFFBFFFCFFFD, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(0000000100020008FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x08, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(000000010007FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x07, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(0000000200030004FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(0000000100020008FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x08, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(00030004FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x03, 0x00, 0x04, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(0000000100020003000400050006000700080009000A000F001100120013FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08, 0x00, 0x09, 0x00, 0x0A, 0x00, 0x0F, 0x00, 0x11, 0x00, 0x12, 0x00, 0x13, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(00000001000200030004FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(000000050007000A000B000C000D000E000F0017FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x0A, 0x00, 0x0B, 0x00, 0x0C, 0x00, 0x0D, 0x00, 0x0E, 0x00, 0x0F, 0x00, 0x17, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(0000000100070008000F4001400AFFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x07, 0x00, 0x08, 0x00, 0x0F, 0x40, 0x01, 0x40, 0x0A, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
3 changes: 2 additions & 1 deletion tasmota/Plugins/Audio/MP3/mp3_decoder_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -1854,7 +1854,8 @@ uint32_t MP3Decoder_AllocateBuffers(void) {
return 0;
}

MP3Decoder_ClearBuffer();
// not needed since memory is always cleared
//MP3Decoder_ClearBuffer();

uint32_t memory = 0;
memory += st[0];
Expand Down
41 changes: 24 additions & 17 deletions tasmota/Plugins/xdrv_42_i2s.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@

#ifdef ESP32
#define USE_MP3_PSRAM
//#define USE_MP3
//#define USE_WEBRADIO
#define USE_MP3
#define USE_WEBRADIO

// select a codec
#define USE_WM8960
Expand Down Expand Up @@ -249,11 +249,18 @@ int32_t I2SAudio_Init() {
const uint32_t *uicp = (const uint32_t *) ((uint8_t *)ui32_const+EXEC_OFFSET);

mt->mem_size += mp3mem;
m_outBuff = (int16_t*)calloc(uicp[0]/2, 2);
mt->mem_size += uicp[0];

#ifdef USE_MP3_PSRAM
m_inBuff = (uint8_t*)special_malloc(uicp[3]);
mt->mem_size += uicp[3];
#else
m_inBuff = (uint8_t*)calloc(uicp[3], 1);
mt->mem_size += uicp[3];
#endif

m_outBuff = (int16_t*)calloc(uicp[0]/2, 2);
mt->mem_size += uicp[0];

if (!mp3mem || !m_outBuff || !m_inBuff) {
I2SAudio_Deinit();
Response_P(GSTR(S_JSON_MEMERR));
Expand Down Expand Up @@ -758,7 +765,7 @@ const char head_2[] PROGMEM = "1";
const char hdr_1[] PROGMEM = "icy-metaint";
const char hdr_2[] PROGMEM = "icy-name";
const char hdr_3[] PROGMEM = "icy-genre";
const char hdr_4[] PROGMEM = "icy-br";
const char hdr_4[] PROGMEM = "icy-sr";

const uint32_t hdr[] PROGMEM = { (uint32_t)hdr_1, (uint32_t)hdr_2, (uint32_t)hdr_3, (uint32_t)hdr_4 };

Expand Down Expand Up @@ -961,31 +968,31 @@ void WebRadio(void) {
if (200 == code) {
volatile const int32_t *icp = (const int32_t *) ((uint8_t *)i32_const+EXEC_OFFSET);
srate = icp[6];
uint32_t has_bitrate;

if (http_hasHeader(http, PSTR("icy-br"))) {
char *ret = http_header(http, PSTR("icy-br"));
AddLog(LOG_LEVEL_INFO, PSTR("WR br = %s"),ret);
if (http_hasHeader(http, GSTR(hdr_4))) {
char *ret = http_header(http, GSTR(hdr_4));
AddLog(LOG_LEVEL_INFO, PSTR("WR sr = %s"), ret);
srate = strtol(ret, 0, 10);
free(ret);
has_bitrate = 1; // ret.toInt();
} else {
has_bitrate = 0;
srate = icp[6];
}

if (http_hasHeader(http, PSTR("icy-metaint"))) {
char *ret = http_header(http, PSTR("icy-metaint"));
AddLog(LOG_LEVEL_INFO, PSTR("ici metaint = %s"),ret);
if (http_hasHeader(http, GSTR(hdr_1))) {
char *ret = http_header(http, GSTR(hdr_1));
AddLog(LOG_LEVEL_INFO, PSTR("ici metaint = %s"), ret);
icyMetaInt = strtol(ret, 0, 10);
free(ret);
} else {
icyMetaInt = 0;
}

int32_t size = http_getSize(http);
//int32_t size = http_getSize(http);

busy = true;

#define URL_SIZE 256
// play webradio file
// play webradio stream
char *urlcopy = (char*)calloc(URL_SIZE, 1);
const uint32_t *uicp = (const uint32_t *) ((uint8_t *)ui32_const+EXEC_OFFSET);
TASKPARS tp;
Expand Down
54 changes: 12 additions & 42 deletions tasmota/tasmota_xdrv_driver/xdrv_123_plugins.ino
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ double tmod_long2double(int64_t in);
void *tmod_strncat(char *dst, char *src, uint32_t size);
const uint8_t tmod_pgm_read_byte(uint8_t *ptr);
const uint16_t tmod_pgm_read_word(uint16_t *ptr);
void *tmod_special_malloc(uint32_t size);

extern "C" {
extern void (* const MODULE_JUMPTABLE[])(void);
Expand Down Expand Up @@ -401,7 +402,7 @@ void (* const MODULE_JUMPTABLE[])(void) PROGMEM = {
#else
JMPTBL&tmod_strncmp_P,
#endif
JMPTBL&special_malloc,
JMPTBL&tmod_special_malloc,
JMPTBL&ResponseCmndChar,
JMPTBL&strtol,
JMPTBL&tmod_udp,
Expand Down Expand Up @@ -550,8 +551,6 @@ uint32_t tmod_dummy() {
return 0;
}

WiFiClient plugin_client;
HTTPClient plugin_http;

#if defined(ESP32) && defined(USE_TLS)
#include "WiFiClientSecureLightBearSSL.h"
Expand Down Expand Up @@ -682,7 +681,7 @@ uint32_t tmod_wifi(uint32_t sel, uint32_t p1, uint32_t p2, uint32_t p3, uint32_t
uint16_t len = strlen(sp);
if (len) {
cp = (char*)malloc(len + 2);
strlcpy(cp, sp, len);
strlcpy(cp, sp, len + 2);
return (uint32_t) cp;
} else {
return 0;
Expand All @@ -704,24 +703,10 @@ uint32_t tmod_wifi(uint32_t sel, uint32_t p1, uint32_t p2, uint32_t p3, uint32_t
}
break;
case 50:
{
bool res = plugin_http.begin(plugin_client, (char*)p2);
//bool res = plugin_http.begin(plugin_client, "http://wdr-wdr2-aachenundregion.icecastssl.wdr.de/wdr/wdr2/aachenundregion/mp3/128/stream.mp3");

if (!res) {
return 0;
}
static const char *hdr[] = { "icy-metaint", "icy-name", "icy-genre", "icy-br" };
plugin_http.addHeader("Icy-MetaData", "1");
plugin_http.collectHeaders( hdr, 4 );
plugin_http.setReuse(true);
plugin_http.setFollowRedirects(HTTPC_FORCE_FOLLOW_REDIRECTS);
return plugin_http.GET();
}
break;
case 51:
return (uint32_t)&plugin_http;
break;
case 52:
plugin_http.end();
break;
case 53:
Test_prog();
Expand Down Expand Up @@ -967,6 +952,13 @@ uint32_t tmod_udp(WiFiUDP *udp, uint32_t sel, uint32_t p1, uint32_t p2) {
return 0;
}

void *tmod_special_malloc(uint32_t size) {
void *ptr = special_malloc(size);
memset(ptr, 0, size);
return ptr;
};


int tmod_strncmp_P(const char * str1P, const char * str2P, size_t size) {
char *cp = copyStr(str2P);
int res = strncmp(str1P, cp, size);
Expand Down Expand Up @@ -2634,28 +2626,6 @@ void Module_dump(void) {

void Test_prog(void) {

#if 0
int32_t code = tmod_wifi(50, 0, (uint32_t)"http://wdr-wdr2-aachenundregion.icecastssl.wdr.de/wdr/wdr2/aachenundregion/mp3/128/stream.mp3", 0, 0);

AddLog(LOG_LEVEL_INFO,PSTR("result: %d"), code);

tmod_wifi(52, 0, 0, 0, 0);

#else
bool res = plugin_http.begin(plugin_client, "http://wdr-wdr2-aachenundregion.icecastssl.wdr.de/wdr/wdr2/aachenundregion/mp3/128/stream.mp3");
if (!res) {
AddLog(LOG_LEVEL_INFO,PSTR("could not connect"));
return;
}
static const char *hdr[] = { "icy-metaint", "icy-name", "icy-genre", "icy-br" };
plugin_http.addHeader("Icy-MetaData", "1");
plugin_http.collectHeaders( hdr, 4 );
plugin_http.setReuse(true);
plugin_http.setFollowRedirects(HTTPC_FORCE_FOLLOW_REDIRECTS);
int32_t code = plugin_http.GET();
AddLog(LOG_LEVEL_INFO,PSTR("result: %d"), code);
plugin_http.end();
#endif
}

#ifdef ESP8266
Expand Down

0 comments on commit b2f3e1c

Please sign in to comment.