Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
ESP32-audioI2S
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ESP32-audioI2S
Commits
3fdff865
Unverified
Commit
3fdff865
authored
Dec 20, 2022
by
Wolle
Committed by
GitHub
Dec 20, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added another level
parent
a80c6068
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
29 deletions
+48
-29
examples/DLNA/src/index.h
examples/DLNA/src/index.h
+35
-19
examples/DLNA/src/main.cpp
examples/DLNA/src/main.cpp
+13
-10
No files found.
examples/DLNA/src/index.h
View file @
3fdff865
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* index.h
* index.h
*
*
* Created on: 13.12.2022
* Created on: 13.12.2022
* Updated on:
* Updated on:
20.12.2022
* Author: Wolle
* Author: Wolle
*
*
* ESP32 - DLNA
* ESP32 - DLNA
...
@@ -107,7 +107,7 @@ function connect() {
...
@@ -107,7 +107,7 @@ function connect() {
if (n >= 0) {
if (n >= 0) {
var msg = socketMsg.substring(0, n)
var msg = socketMsg.substring(0, n)
var val = socketMsg.substring(n + 1)
var val = socketMsg.substring(n + 1)
//
console.log("
para
",msg, "
val
",val)
//
console.log("
para
",msg, "
val
",val)
}
}
else {
else {
msg = socketMsg
msg = socketMsg
...
@@ -118,14 +118,16 @@ function connect() {
...
@@ -118,14 +118,16 @@ function connect() {
break
break
case "
DLNA_Names
": showServer(val)
case "
DLNA_Names
": showServer(val)
break
break
case "
Level0
": show_DLNA_Content(val, 0)
break
case "
Level1
": show_DLNA_Content(val, 1)
case "
Level1
": show_DLNA_Content(val, 1)
break
break
case "
Level2
": show_DLNA_Content(val, 2)
case "
Level2
": show_DLNA_Content(val, 2)
break
break
case "
Level3
": show_DLNA_Content(val, 3)
case "
Level3
": show_DLNA_Content(val, 3)
break
break
case "
Level4
": show_DLNA_Content(val, 4)
break
case "
Level5
": show_DLNA_Content(val, 5)
break
default: console.log('unknown message', msg, val)
default: console.log('unknown message', msg, val)
}
}
}
}
...
@@ -167,10 +169,11 @@ function showServer(val){
...
@@ -167,10 +169,11 @@ function showServer(val){
function show_DLNA_Content(val, level){
function show_DLNA_Content(val, level){
var select
var select
if(level == 0) select = document.getElementById('level1')
if(level == 1) select = document.getElementById('level1')
if(level == 1) select = document.getElementById('level2')
if(level == 2) select = document.getElementById('level2')
if(level == 2) select = document.getElementById('level3')
if(level == 3) select = document.getElementById('level3')
if(level == 3) select = document.getElementById('level4')
if(level == 4) select = document.getElementById('level4')
if(level == 5) select = document.getElementById('level5')
content =JSON.parse(val)
content =JSON.parse(val)
//console.log(ct[1].name)
//console.log(ct[1].name)
select.options.length = 0;
select.options.length = 0;
...
@@ -184,11 +187,11 @@ function show_DLNA_Content(val, level){
...
@@ -184,11 +187,11 @@ function show_DLNA_Content(val, level){
var n
var n
var c
var c
if(content[i].isDir == true){
if(content[i].isDir == true){
n = content[i].name
+ ' <DIR>';
n = content[i].name
.concat('
\xa0\xa0
', '<DIR>'); // more than one space
c = 'D=' + content[i].id // is directory
c = 'D=' + content[i].id // is directory
}
}
else{
else{
n = content[i].name + '
' + content[i].size;
n = content[i].name + '
\xa0\xa0
' + content[i].size;
c = 'F=' + content[i].id // is file
c = 'F=' + content[i].id // is file
}
}
opt.value = c
opt.value = c
...
@@ -198,41 +201,51 @@ function show_DLNA_Content(val, level){
...
@@ -198,41 +201,51 @@ function show_DLNA_Content(val, level){
}
}
}
}
function selectserver (presctrl) { // preset, select a server
function selectserver (presctrl) { // preset, select a server
, root, level0
socket.send('DLNA_getContent0=' + presctrl.value)
socket.send('DLNA_getContent0=' + presctrl.value)
select = document.getElementById('level1'); select.options.length = 0; // clear next level
select = document.getElementById('level1'); select.options.length = 0; // clear next level
select = document.getElementById('level2'); select.options.length = 0;
select = document.getElementById('level2'); select.options.length = 0;
select = document.getElementById('level3'); select.options.length = 0;
select = document.getElementById('level3'); select.options.length = 0;
select = document.getElementById('level4'); select.options.length = 0;
select = document.getElementById('level4'); select.options.length = 0;
select = document.getElementById('level5'); select.options.length = 0;
console.log('DLNA_getContent0=' + presctrl.value)
console.log('DLNA_getContent0=' + presctrl.value)
}
}
function select_l
0
(presctrl) { // preset, select root
function select_l
1
(presctrl) { // preset, select root
socket.send('DLNA_getContent1=' + presctrl.value)
socket.send('DLNA_getContent1=' + presctrl.value)
select = document.getElementById('level2'); select.options.length = 0; // clear next level
select = document.getElementById('level2'); select.options.length = 0; // clear next level
select = document.getElementById('level3'); select.options.length = 0;
select = document.getElementById('level3'); select.options.length = 0;
select = document.getElementById('level4'); select.options.length = 0;
select = document.getElementById('level4'); select.options.length = 0;
select = document.getElementById('level5'); select.options.length = 0;
console.log('DLNA_getContent1=' + presctrl.value)
console.log('DLNA_getContent1=' + presctrl.value)
}
}
function select_l
1
(presctrl) { // preset, select level 1
function select_l
2
(presctrl) { // preset, select level 1
socket.send('DLNA_getContent2=' + presctrl.value)
socket.send('DLNA_getContent2=' + presctrl.value)
select = document.getElementById('level3'); select.options.length = 0;
select = document.getElementById('level3'); select.options.length = 0;
select = document.getElementById('level4'); select.options.length = 0;
select = document.getElementById('level4'); select.options.length = 0;
select = document.getElementById('level5'); select.options.length = 0;
console.log('DLNA_getContent2=' + presctrl.value)
console.log('DLNA_getContent2=' + presctrl.value)
}
}
function select_l
2
(presctrl) { // preset, select level 2
function select_l
3
(presctrl) { // preset, select level 2
socket.send('DLNA_getContent3=' + presctrl.value)
socket.send('DLNA_getContent3=' + presctrl.value)
select = document.getElementById('level4'); select.options.length = 0;
select = document.getElementById('level4'); select.options.length = 0;
select = document.getElementById('level5'); select.options.length = 0;
console.log('DLNA_getContent3=' + presctrl.value)
console.log('DLNA_getContent3=' + presctrl.value)
}
}
function select_l
3
(presctrl) { // preset, select level 3
function select_l
4
(presctrl) { // preset, select level 3
socket.send('DLNA_getContent4=' + presctrl.value)
socket.send('DLNA_getContent4=' + presctrl.value)
select = document.getElementById('level5'); select.options.length = 0;
console.log('DLNA_getContent4=' + presctrl.value)
console.log('DLNA_getContent4=' + presctrl.value)
}
}
function select_l5 (presctrl) { // preset, select level 4
socket.send('DLNA_getContent5=' + presctrl.value)
console.log('DLNA_getContent5=' + presctrl.value)
}
</script>
</script>
<body id="
BODY
">
<body id="
BODY
">
<!--==============================================================================================-->
<!--==============================================================================================-->
...
@@ -246,16 +259,19 @@ function select_l2 (presctrl) { // preset, select level 2
...
@@ -246,16 +259,19 @@ function select_l2 (presctrl) { // preset, select level 2
<select class="
boxstyle
" style="
width
:
100
%
;
" onchange="
selectserver
(
this
)
" id="
server
">
<select class="
boxstyle
" style="
width
:
100
%
;
" onchange="
selectserver
(
this
)
" id="
server
">
<option value="
-
1
">Select a DLNA Server here</option>
<option value="
-
1
">Select a DLNA Server here</option>
</select>
</select>
<select class="
boxstyle
" style="
width
:
100
%
;
margin
-
top
:
5
px
;
" onchange="
select_l
0
(
this
)
" id="
level1
">
<select class="
boxstyle
" style="
width
:
100
%
;
margin
-
top
:
5
px
;
" onchange="
select_l
1
(
this
)
" id="
level1
">
<option value="
-
1
"> </option>
<option value="
-
1
"> </option>
</select>
</select>
<select class="
boxstyle
" style="
width
:
100
%
;
margin
-
top
:
5
px
;
" onchange="
select_l1
(
this
)
" id="
level2
">
<select class="
boxstyle
" style="
width
:
100
%
;
margin
-
top
:
5
px
;
" onchange="
select_l2
(
this
)
" id="
level2
">
<option value="
-
1
"> </option>
</select>
<select class="
boxstyle
" style="
width
:
100
%
;
margin
-
top
:
5
px
;
" onchange="
select_l3
(
this
)
" id="
level3
">
<option value="
-
1
"> </option>
<option value="
-
1
"> </option>
</select>
</select>
<select class="
boxstyle
" style="
width
:
100
%
;
margin
-
top
:
5
px
;
" onchange="
select_l
2
(
this
)
" id="
level3
">
<select class="
boxstyle
" style="
width
:
100
%
;
margin
-
top
:
5
px
;
" onchange="
select_l
4
(
this
)
" id="
level4
">
<option value="
-
1
"> </option>
<option value="
-
1
"> </option>
</select>
</select>
<select class="
boxstyle
" style="
width
:
100
%
;
margin
-
top
:
5
px
;
" onchange="
select_l
3
(
this
)
" id="
level4
">
<select class="
boxstyle
" style="
width
:
100
%
;
margin
-
top
:
5
px
;
" onchange="
select_l
5
(
this
)
" id="
level5
">
<option value="
-
1
"> </option>
<option value="
-
1
"> </option>
</select>
</select>
</div>
</div>
...
...
examples/DLNA/src/main.cpp
View file @
3fdff865
...
@@ -14,8 +14,8 @@ using namespace std;
...
@@ -14,8 +14,8 @@ using namespace std;
#define I2S_LRC 26
#define I2S_LRC 26
char
SSID
[]
=
"
*****
"
;
char
SSID
[]
=
"
Wolles-FRITZBOX
"
;
char
PASS
[]
=
"
*****
"
;
char
PASS
[]
=
"
40441061073895958449
"
;
...
@@ -51,6 +51,7 @@ void DLNA_showServer(){ // Show connection details of all discovered, usable med
...
@@ -51,6 +51,7 @@ void DLNA_showServer(){ // Show connection details of all discovered, usable med
if
(
i
<
numServers
-
1
)
msg
+=
','
;
if
(
i
<
numServers
-
1
)
msg
+=
','
;
names
.
push_back
(
srv
.
friendlyName
);
names
.
push_back
(
srv
.
friendlyName
);
}
}
log_i
(
"msg %s"
,
msg
.
c_str
());
webSrv
.
send
(
msg
);
webSrv
.
send
(
msg
);
}
}
void
DLNA_browseServer
(
String
objectId
,
uint8_t
level
){
void
DLNA_browseServer
(
String
objectId
,
uint8_t
level
){
...
@@ -69,7 +70,7 @@ void DLNA_browseServer(String objectId, uint8_t level){
...
@@ -69,7 +70,7 @@ void DLNA_browseServer(String objectId, uint8_t level){
log_i
(
"no content!"
);
// then the directory is empty
log_i
(
"no content!"
);
// then the directory is empty
return
;
return
;
}
}
log_
i
(
"objectID: %s"
,
objectId
.
c_str
());
log_
v
(
"objectID: %s"
,
objectId
.
c_str
());
for
(
int
i
=
0
;
i
<
browseResult
.
size
();
i
++
){
for
(
int
i
=
0
;
i
<
browseResult
.
size
();
i
++
){
object
=
browseResult
[
i
];
object
=
browseResult
[
i
];
myObject
[
i
][
"name"
]
=
object
.
name
;
myObject
[
i
][
"name"
]
=
object
.
name
;
...
@@ -84,12 +85,13 @@ void DLNA_browseServer(String objectId, uint8_t level){
...
@@ -84,12 +85,13 @@ void DLNA_browseServer(String objectId, uint8_t level){
}
}
myObject
[
i
][
"size"
]
=
(
uint32_t
)
object
.
size
;
myObject
[
i
][
"size"
]
=
(
uint32_t
)
object
.
size
;
myObject
[
i
][
"uri"
]
=
object
.
id
;
myObject
[
i
][
"uri"
]
=
object
.
id
;
log_
i
(
"objectName %s"
,
browseResult
[
i
].
name
.
c_str
());
log_
v
(
"objectName %s"
,
browseResult
[
i
].
name
.
c_str
());
log_
i
(
"objectId %s"
,
browseResult
[
i
].
artist
.
c_str
());
log_
v
(
"objectId %s"
,
browseResult
[
i
].
artist
.
c_str
());
}
}
level
++
;
String
msg
=
"Level"
+
String
(
level
,
10
)
+
"="
+
JSON
.
stringify
(
myObject
);
String
msg
=
"Level"
+
String
(
level
,
10
)
+
"="
+
JSON
.
stringify
(
myObject
);
log_
i
(
"msg = %s"
,
msg
.
c_str
());
log_
v
(
"msg = %s"
,
msg
.
c_str
());
webSrv
.
send
(
msg
);
webSrv
.
send
(
msg
);
browseResult
.
clear
();
browseResult
.
clear
();
}
}
...
@@ -97,15 +99,15 @@ void DLNA_browseServer(String objectId, uint8_t level){
...
@@ -97,15 +99,15 @@ void DLNA_browseServer(String objectId, uint8_t level){
void
DLNA_getFileItems
(
String
uri
){
void
DLNA_getFileItems
(
String
uri
){
soapObjectVect_t
browseResult
;
soapObjectVect_t
browseResult
;
log_
i
(
"uri: %s"
,
uri
.
c_str
());
log_
v
(
"uri: %s"
,
uri
.
c_str
());
log_
w
(
"downloadIP: %s"
,
media_downloadIP
.
c_str
());
log_
v
(
"downloadIP: %s"
,
media_downloadIP
.
c_str
());
log_
w
(
"downloadport: %d"
,
media_downloadPort
);
log_
v
(
"downloadport: %d"
,
media_downloadPort
);
String
URL
=
"http://"
+
media_downloadIP
+
":"
+
media_downloadPort
+
"/"
+
uri
;
String
URL
=
"http://"
+
media_downloadIP
+
":"
+
media_downloadPort
+
"/"
+
uri
;
log_i
(
"URL=%s"
,
URL
.
c_str
());
log_i
(
"URL=%s"
,
URL
.
c_str
());
audio
.
connecttohost
(
URL
.
c_str
());
audio
.
connecttohost
(
URL
.
c_str
());
}
}
void
DLNA_showContent
(
String
objectId
,
uint8_t
level
){
void
DLNA_showContent
(
String
objectId
,
uint8_t
level
){
log_
i
(
"obkId=%s"
,
objectId
.
c_str
());
log_
v
(
"obkId=%s"
,
objectId
.
c_str
());
if
(
level
==
0
){
if
(
level
==
0
){
DLNA_browseServer
(
objectId
,
level
);
DLNA_browseServer
(
objectId
,
level
);
}
}
...
@@ -157,6 +159,7 @@ void WEBSRV_onCommand(const String cmd, const String param, const String arg){
...
@@ -157,6 +159,7 @@ void WEBSRV_onCommand(const String cmd, const String param, const String arg){
if
(
cmd
==
"DLNA_getContent2"
){
DLNA_showContent
(
param
,
2
);
return
;}
// search for level 2 content
if
(
cmd
==
"DLNA_getContent2"
){
DLNA_showContent
(
param
,
2
);
return
;}
// search for level 2 content
if
(
cmd
==
"DLNA_getContent3"
){
DLNA_showContent
(
param
,
3
);
return
;}
// search for level 3 content
if
(
cmd
==
"DLNA_getContent3"
){
DLNA_showContent
(
param
,
3
);
return
;}
// search for level 3 content
if
(
cmd
==
"DLNA_getContent4"
){
DLNA_showContent
(
param
,
4
);
return
;}
// search for level 4 content
if
(
cmd
==
"DLNA_getContent4"
){
DLNA_showContent
(
param
,
4
);
return
;}
// search for level 4 content
if
(
cmd
==
"DLNA_getContent5"
){
DLNA_showContent
(
param
,
5
);
return
;}
// search for level 5 content
log_e
(
"unknown HTMLcommand %s, param=%s"
,
cmd
.
c_str
(),
param
.
c_str
());
log_e
(
"unknown HTMLcommand %s, param=%s"
,
cmd
.
c_str
(),
param
.
c_str
());
}
}
void
WEBSRV_onRequest
(
const
String
request
,
uint32_t
contentLength
){
void
WEBSRV_onRequest
(
const
String
request
,
uint32_t
contentLength
){
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment