 typedef struct packet_tag {
     uint16_t header;
     uint8_t command;
-    uint8_t endpoint;
-    uint8_t rgb[3];
+    uint8_t data[3];
 } packet_t;
 
-//Serial protocol
+// Serial protocol
 #define MAX_SERIAL_LINE_LEN 20
 
-//Firmware information
-#define VERSION                 0 //The firmware version number
-#define ENDPOINT_ID_LOCATION    0x000 //The address in EEPROM to store the ID
+// Firmware information
+#define VERSION                 0 // The firmware version number
+#define ENDPOINT_ID_LOCATION    0x000 // The address in EEPROM to store the ID
 
 
 void networkRead(void);

        return;
    }

    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;
        }

#include <EEPROM.h>


// RGB pins
// Note: pins 5 and 6 use the fast, inaccurate PWM timer. If this becomes
// an issue, look into software PWM implementations.
#define RED_PIN             3
#define GREEN_PIN           5
#define BLUE_PIN            6

// Radio pins
#define CE_PIN              9 // Radio chip enable pin
#define CSN_PIN             10 // Radio chip select pin

// Wireless protocol
#define RF_ADDRESS(endpoint)         (0x5349474D00LL | (endpoint & 0xFF)) // Generates a 40-bit nRF address
#define HEADER                  7446 // Must prefix every message
#define BASE_STATION_ID         0x00 // The endpoint ID of the base station
#define MULTICAST_ID            0xFF // The endpoint ID that all lights listen to

#define ENDPOINT_PIPE           1 // The pipe for messages for this endpoint
#define MULTICAST_PIPE          2 // The pipe for multicast messages

#define CHANNEL                 80 // Channel center frequency = 2.4005 GHz + (Channel# * 1 MHz)
#define NUM_RETRIES             5

enum COMMANDS {
    CMD_SET_RGB       = 0x10,
    CMD_PING          = 0x20,
    CMD_PING_RESPONSE = 0x21,
};
