ソースを参照

add debug options

Chris Mullins 8 年 前
コミット
e02b1b2bdd
共有2 個のファイルを変更した11 個の追加0 個の削除を含む
  1. 8 0
      lib/MiLight/MiLightUdpServer.cpp
  2. 3 0
      lib/MiLight/MiLightUdpServer.h

+ 8 - 0
lib/MiLight/MiLightUdpServer.cpp

@@ -25,6 +25,14 @@ void MiLightUdpServer::handleClient() {
   if (packetSize) {
     if (packetSize >= 2 && packetSize <= 3) {
       socket.read(packetBuffer, packetSize);
+      
+#ifdef MILIGHT_UDP_DEBUG
+      Serial.print("Handling command: ");
+      Serial.print(String(packetBuffer[0], HEX));
+      Serial.print(" ");
+      Serial.println(String(packetBuffer[1], HEX));
+#endif
+      
       handleCommand(packetBuffer[0], packetBuffer[1]);
     } else {
       Serial.print("Error, unexpected packet length (should always be 2-3, was: ");

+ 3 - 0
lib/MiLight/MiLightUdpServer.h

@@ -7,6 +7,9 @@
 
 #define MILIGHT_PACKET_BUFFER_SIZE 10
 
+// Uncomment to enable Serial printing of packets
+//#define MILIGHT_UDP_DEBUG
+
 #ifndef _MILIGHT_UDP_SERVER
 #define _MILIGHT_UDP_SERVER