 
 
 static uint8_t node_id;
-static uint8_t pkt[64];
-static uint8_t have_data = 0;
+
+typedef struct {
+    uint8_t len;
+    uint8_t data[64];
+} buffer_t;
+
+static buffer_t buffers[9];
+
+static void fill_buffer(uint8_t to, uint8_t flags, uint8_t len, uint8_t *data)
+{
+    // select our own node buffer as send buffer
+    buffer_t *buf = &buffers[node_id];
+
+    // fill it
+    buf->len = 3 + len;
+    buf->data[0] = to;
+    buf->data[1] = node_id;
+    buf->data[2] = flags;
+    if (len > 0) {
+        memcpy(&buf->data[3], data, len);
+    }
+}
 
 void setup()
 {


    // SPI init
    spi_init(1000000L, 0);
    // TODO BSI move this to HAL
    SPI.setDataMode(SPI_MODE0);
    SPI.setBitOrder(MSBFIRST);
    SPI.setClockDivider(SPI_CLOCK_DIV8);
    SPI.begin();
    pinMode(10, OUTPUT);

    radio_init(node_id);
    Serial.print("radio_init = ");

    if (argc >= 2) {
        node = atoi(argv[1]);
    }

    // prepare ping message
    fill_buffer(node, 0x01, 0, NULL);

    Serial.print(argv[0]);
    Serial.print(" 00 ");
    Serial.println(node, HEX);
    return 0;
}

static const cmd_t commands[] = {
