通过互联网发送通过Arduino Due播放语音备忘录

时间:2020-09-21 07:12:28

标签: audio arduino udp ethernet

我正试图让一个带有W5500以太网屏蔽的Arduino播放录制的语音备忘录,该备忘录通过UDP发送给它。 目前,我在C#中有一个WAV记录器。我的计划是将wav转换为字节数组并发送,但是我的Arduino将不会响应我发送的任何内容(通过Programm Packet Sender进行尝试)。通过串行监视器,我只能得到UDP Rdy返回。

我的Arduino暂时具有此代码

#include <Dhcp.h>
#include <Dns.h>
#include <Ethernet2.h>
#include <EthernetClient.h>
#include <EthernetServer.h>
#include <EthernetUdp2.h>
#include <util.h>




byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 200);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
unsigned int localPort = 2014;
EthernetUDP Udp;
char packetBuffer[UDP_TX_PACKET_MAX_SIZE];

void setup() {
  // put your setup code here, to run once:
  Ethernet.init(10);
  Serial.begin(115200);
  Ethernet.begin(mac,ip);
  Udp.begin(localPort);
  Udp.flush();
  Serial.print("UDP Rdy");
}

void checkUDP()
  {  
  int packetSize = Udp.parsePacket();
  if(packetSize>0)
  {
    Serial.print("Begin");
    Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE);
    
    Serial.print("Packet Content: ");
    Serial.println(packetBuffer);
    
    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
    Udp.write("ok");
    Udp.endPacket();
  }
  delay(10);
}

void loop() {
  // put your main code here, to run repeatedly:
 checkUDP();
   
}

0 个答案:

没有答案