  * Takes action on a packet received over the network.
  * @param packet The packet received
  */
-void processPacket(packet_t packet) {
+void processNetworkPacket(packet_t packet) {
     if (packet.header != HEADER) {
-        //Invalid packet
+        // Invalid packet
         return;
     }
 
-    if ((packet.command == CMD_SET_RGB && packet.endpoint == endpointID) ||
-        packet.command == CMD_BROADCAST_RGB) {
-
-        setRGB(packet.rgb[0], packet.rgb[1], packet.rgb[2]);
-    } else if (packet.command == CMD_PING && packet.endpoint == endpointID) {
-        //Received a ping request. Respond with the endpoint ID and version.
-        packet_t response = {
-            HEADER,
-            CMD_PING_RESPONSE,
-            BASE_STATION_ID,
-            {endpointID, VERSION, 0}
-        };
-
-        radio.stopListening();
-        radio.openWritingPipe(NODE_RF_ADDRESS);
-        radio.write(&response, sizeof(response));
-        radio.openReadingPipe(0, NODE_RF_ADDRESS);
-    } else {
-        //Ignore packet
+    if (packet.endpoint != endpointID &&
+        packet.command != CMD_BROADCAST_RGB) {
+        // Packet was not meant for this endpoint
+        return;
+    }
+
+    switch (packet.command) {
+
+        case CMD_SET_RGB:
+        case CMD_BROADCAST_RGB: {
+            // The packet is intended for this endpoint, so update the color.
+            setRGB(packet.rgb[0], packet.rgb[1], packet.rgb[2]);
+            break;
+        }
+
+        case CMD_PING: {
+            // Received a ping request. Respond with the endpoint ID and version.
+            packet_t response = {
+                HEADER,
+                CMD_PING_RESPONSE,
+                BASE_STATION_ID,
+                {endpointID, VERSION, 0}
+            };
+
+            radio.stopListening();
+            radio.openWritingPipe(NODE_RF_ADDRESS);
+            radio.write(&response, sizeof(response));
+            radio.openReadingPipe(0, NODE_RF_ADDRESS);
+
+            break;
+        }
+
+        default:
+            // Ignore the packet
+            break;
     }
 }
 



//RGB pins
#define RED_PIN             9
#define GREEN_PIN           10
#define BLUE_PIN            11

//Radio pins
#define CE_PIN              2 //Radio chip enable pin
#define CSN_PIN             3 //Radio chip select pin

//Wireless protocol
#define NODE_RF_ADDRESS         ((uint64_t)'SIGMUSIC')
#define HEADER                  7446
#define BASE_STATION_ID         0x00

enum COMMANDS {
    CMD_SET_RGB       = 0x10,

    CMD_PING_RESPONSE = 0x21,
};

typedef struct packet_tag {
    uint16_t header;
    uint8_t command;
