import { useContext } from "react";
import { DeviceProviderContext } from "./DeviceProvider";
import { DeviceEntry } from "../ProtocolProvider/protocol/packets/packet.device.list";

export function useDevices() : DeviceEntry[] {
    const context = useContext(DeviceProviderContext);

    if(!context) {
        throw new Error("useDevices must be used within a DeviceProvider");
    }

    return context.devices;
}