【赚周年比】技术贴——Fireduino学习之DLNA
#线上活动
2209 人阅读
|
0 人回复
|
2017-01-12
TA的每日心情 | 奋斗 2025-1-7 00:10 |
|---|
签到天数: 945 天 连续签到: 1 天 [LV.10]以坛为家III
状元
- 积分
- 5115
|
|
学习了如何播放TF卡上的音乐文件后,就要尝试通过WIFI播放音乐,但是对网络协议不懂,但是Fireduino支持DLNA播放,虽然用过DLNA,但是对于它 的实现是不懂的,所以就下载了官网提供的程序。- #include <Arduino.h>
- #include "TF.h"
- #include "Audio.h"
- #include <WiFi.h>
-
- char ssid[] = "HiWiFi_37C468"; // your network SSID (name)
- char pass[] = ""; // your network password
- int status = WL_IDLE_STATUS;
-
-
- void printWifiStatus();
- void setup() {
- Serial.begin(115200);
- Serial.print("\r\narduino setup ...\r\n");
-
- if(!SD.begin())
- {
- Serial.println("sd init err\r\n");
- while(1);
- }
-
- // check for the presence of the shield:
- if (WiFi.status() == WL_NO_SHIELD) {
- Serial.println("WiFi shield not present");
- // don't continue:
- while (true);
- }
-
- String fv = WiFi.firmwareVersion();
- if (fv != "1.1.0") {
- Serial.println("Please upgrade the firmware");
- }
-
- // attempt to connect to Wifi network:
- while (status != WL_CONNECTED) {
- Serial.print("Attempting to connect to SSID: ");
- Serial.println(ssid);
- // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
- status = WiFi.begin(ssid, pass);
-
- // wait 10 seconds for connection:
- // delay(10000);
- }
- Serial.println("Connected to wifi");
- printWifiStatus();
-
-
- Audio.begin(AUDIO_DLNA);
-
- }
-
- void loop() {
- Serial.println("loop");
- delay(2000);
-
- }
-
- void printWifiStatus() {
- // print the SSID of the network you're attached to:
- Serial.print("SSID: ");
- Serial.println(WiFi.SSID());
-
- // print your WiFi shield's IP address:
- IPAddress ip = WiFi.localIP();
- Serial.print("IP Address: ");
- Serial.println(ip);
-
- // print the received signal strength:
- long rssi = WiFi.RSSI();
- Serial.print("signal strength (RSSI):");
- Serial.print(rssi);
- Serial.println(" dBm");
- }
复制代码 实际使用时发现Fireduino挑路由器,在实验室是用的是水星的路由器,重复多次下载,查看代码,都没发现问题,但就是不出声音,内心是郁闷的,难道官网提供的代码有错误,回到宿舍接着折腾,终于出声音了,还是一样的代码。只不过换了个路由,宿舍用的是极路由一代。
还有一个问题就是,我用的音乐软件是网易云音乐,多次使用后,手机客户端DLNA会显示多个Fireduino的名字,有时真不好分清楚哪个是现在使用的设备名字,也不太清楚怎么让客户端记住设备,而不重复显示。
|
评分
-
查看全部评分
|
|
|
|
|
|
|
|