回答

收藏

【赚周年比】技术贴——Fireduino学习之DLNA

#线上活动 #线上活动 2209 人阅读 | 0 人回复 | 2017-01-12

       学习了如何播放TF卡上的音乐文件后,就要尝试通过WIFI播放音乐,但是对网络协议不懂,但是Fireduino支持DLNA播放,虽然用过DLNA,但是对于它 的实现是不懂的,所以就下载了官网提供的程序。
  1. #include <Arduino.h>
  2. #include "TF.h"
  3. #include "Audio.h"
  4. #include <WiFi.h>

  5. char ssid[] = "HiWiFi_37C468";     //  your network SSID (name)
  6. char pass[] = "";  // your network password
  7. int status = WL_IDLE_STATUS;


  8. void printWifiStatus();
  9. void setup() {
  10.   Serial.begin(115200);
  11.   Serial.print("\r\narduino setup ...\r\n");

  12.   if(!SD.begin())
  13.   {
  14.     Serial.println("sd init err\r\n");
  15.     while(1);
  16.   }

  17.   // check for the presence of the shield:
  18.   if (WiFi.status() == WL_NO_SHIELD) {
  19.     Serial.println("WiFi shield not present");
  20.     // don't continue:
  21.     while (true);
  22.   }

  23.   String fv = WiFi.firmwareVersion();
  24.   if (fv != "1.1.0") {
  25.     Serial.println("Please upgrade the firmware");
  26.   }

  27.   // attempt to connect to Wifi network:
  28.   while (status != WL_CONNECTED) {
  29.     Serial.print("Attempting to connect to SSID: ");
  30.     Serial.println(ssid);
  31.     // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
  32.     status = WiFi.begin(ssid, pass);

  33.     // wait 10 seconds for connection:
  34.     // delay(10000);
  35.   }
  36.   Serial.println("Connected to wifi");
  37.   printWifiStatus();


  38.   Audio.begin(AUDIO_DLNA);

  39. }

  40. void loop() {
  41.   Serial.println("loop");
  42.   delay(2000);

  43. }

  44. void printWifiStatus() {
  45.   // print the SSID of the network you're attached to:
  46.   Serial.print("SSID: ");
  47.   Serial.println(WiFi.SSID());

  48.   // print your WiFi shield's IP address:
  49.   IPAddress ip = WiFi.localIP();
  50.   Serial.print("IP Address: ");
  51.   Serial.println(ip);

  52.   // print the received signal strength:
  53.   long rssi = WiFi.RSSI();
  54.   Serial.print("signal strength (RSSI):");
  55.   Serial.print(rssi);
  56.   Serial.println(" dBm");
  57. }
复制代码
实际使用时发现Fireduino挑路由器,在实验室是用的是水星的路由器,重复多次下载,查看代码,都没发现问题,但就是不出声音,内心是郁闷的,难道官网提供的代码有错误,回到宿舍接着折腾,终于出声音了,还是一样的代码。只不过换了个路由,宿舍用的是极路由一代。
还有一个问题就是,我用的音乐软件是网易云音乐,多次使用后,手机客户端DLNA会显示多个Fireduino的名字,有时真不好分清楚哪个是现在使用的设备名字,也不太清楚怎么让客户端记住设备,而不重复显示。

dlna.zip

1018 Bytes, 下载次数: 0

评分

参与人数 1 +15 收起 理由
loveeeboard + 15

查看全部评分

分享到:
回复

使用道具 举报

您需要登录后才可以回帖 注册/登录

本版积分规则

关闭

站长推荐上一条 /3 下一条