// Path: hackadrone-utils/src/main/java/nl/ordina/jtech/hackadrone/utils/ByteUtils.java
// public final class ByteUtils {
// 
//     /**
//      * Generates bytes from numbers.
//      *
//      * @param values the values containing the numbers
//      * @return bytes containing the numbers
//      */
//     public static byte[] asUnsigned(int... values) {
//         byte[] bytes = new byte[values.length];
// 
//         for (int i = 0; i < values.length; i++) {
//             int value = values[i];
// 
//             if (value > Byte.MAX_VALUE) {
//                 bytes[i] = (byte) value;
//             } else {
//                 bytes[i] = (byte) (value & 0xff);
//             }
//         }
// 
//         return bytes;
//     }
// 
//     /**
//      * Loads message from a file.
//      *
//      * @param fileName the file name containing the message
//      * @return a bytes array containing the message
//      * @throws IOException if loading the message from the file failed
//      */
//     public static byte[] loadMessageFromFile(String fileName) throws IOException {
//         InputStream inputStream = ByteUtils.class.getResourceAsStream("/" + fileName);
//         ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
// 
//         int read;
//         byte[] data = new byte[4096];
// 
//         while ((read = inputStream.read(data, 0, data.length)) > 0) {
//             byteArrayOutputStream.write(data, 0, read);
//         }
// 
//         byteArrayOutputStream.flush();
// 
//         return byteArrayOutputStream.toByteArray();
//     }
// 
// }


import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import nl.ordina.jtech.hackadrone.utils.ByteUtils;
            socket = new Socket(host, port);
            super.start();
        } catch (IOException e) {
            System.err.println("Connection failed!");
        }
    }

    /**
     * Starts running the heartbeat.
     */
    @Override
    public void run() {
        while (!isInterrupted()) {
            try {
                sendHeartBeat();
                Thread.sleep(5000);
            } catch (IOException e) {
                System.err.println("Unable to send heartbeat");
            } catch (InterruptedException e) {
                System.err.println("Heartbeat interrupted");
            }
        }
    }

    /**
     * Sends a heartbeat to the drone.
     *
     * @throws IOException if sending the heartbeat to the drone failed
     */
    private void sendHeartBeat() throws IOException {
// Path: hackadrone-utils/src/main/java/nl/ordina/jtech/hackadrone/utils/ByteUtils.java
// public final class ByteUtils {
// 
//     /**
//      * Generates bytes from numbers.
//      *
//      * @param values the values containing the numbers
//      * @return bytes containing the numbers
//      */
//     public static byte[] asUnsigned(int... values) {
//         byte[] bytes = new byte[values.length];
// 
//         for (int i = 0; i < values.length; i++) {
//             int value = values[i];
// 
//             if (value > Byte.MAX_VALUE) {
//                 bytes[i] = (byte) value;
//             } else {
//                 bytes[i] = (byte) (value & 0xff);
//             }
//         }
// 
//         return bytes;
//     }
// 
//     /**
//      * Loads message from a file.
//      *
//      * @param fileName the file name containing the message
//      * @return a bytes array containing the message
//      * @throws IOException if loading the message from the file failed
//      */
//     public static byte[] loadMessageFromFile(String fileName) throws IOException {
//         InputStream inputStream = ByteUtils.class.getResourceAsStream("/" + fileName);
//         ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
// 
//         int read;
//         byte[] data = new byte[4096];
// 
//         while ((read = inputStream.read(data, 0, data.length)) > 0) {
//             byteArrayOutputStream.write(data, 0, read);
//         }
// 
//         byteArrayOutputStream.flush();
// 
//         return byteArrayOutputStream.toByteArray();
//     }
// 
// }


// Path: hackadrone-core/src/main/java/nl/ordina/jtech/hackadrone/io/Heartbeat.java
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import nl.ordina.jtech.hackadrone.utils.ByteUtils;

            socket = new Socket(host, port);
            super.start();
        } catch (IOException e) {
            System.err.println("Connection failed!");
        }
    }

    /**
     * Starts running the heartbeat.
     */
    @Override
    public void run() {
        while (!isInterrupted()) {
            try {
                sendHeartBeat();
                Thread.sleep(5000);
            } catch (IOException e) {
                System.err.println("Unable to send heartbeat");
            } catch (InterruptedException e) {
                System.err.println("Heartbeat interrupted");
            }
        }
    }

    /**
     * Sends a heartbeat to the drone.
     *
     * @throws IOException if sending the heartbeat to the drone failed
     */
    private void sendHeartBeat() throws IOException {
        byte[] heartbeatData = ByteUtils.loadMessageFromFile("bin/heartbeat.bin");