#include <Arduino.h>
#include "config.h"
#include "sdcard.h"
#include "ArduinoJson.h"
extern SdFs SD;
extern FsFile LOG_FILE;
extern byte SCSI_INFO_BUF[SCSI_INFO_BUF_SIZE];
// If config file exists, read the first three lines and copy the contents.
// File must be well formed or you will get junk in the SCSI Vendor fields.
void readSCSIDeviceConfig(uint8_t disc) {
  StaticJsonDocument<2048> config;
  FsFile config_file = SD.open("blacksasi.json", O_RDONLY);
  if (!config_file.isOpen()) {
    return;
  }
  
  DeserializationError error = deserializeJson(config, config_file);
  if (error){
    Serial.println(F("Failed to read file"));
    return;
  }
  String configx =config["config"];
  Serial.println(configx);
  /*
  char vendor[SCSI_INFO_VENDOR_SIZE];
  memset(vendor, 0, sizeof(vendor));
  config_file.readBytes(vendor, sizeof(vendor));
  LOG_FILE.print("SCSI VENDOR: ");
  LOG_FILE.println(vendor);
  memcpy(&(SCSI_INFO_BUF[8]), vendor, 8);

  char product[SCSI_INFO_PRODUCT_SIZE];
  memset(product, 0, sizeof(product));
  config_file.readBytes(product, sizeof(product));
  LOG_FILE.print("SCSI PRODUCT: ");
  LOG_FILE.println(product);
  memcpy(&(SCSI_INFO_BUF[16]), product, 16);

  char version[SCSI_INFO_VERSION_SIZE];
  memset(version, 0, sizeof(version));
  config_file.readBytes(version, sizeof(version));
  LOG_FILE.print("SCSI VERSION: ");
  LOG_FILE.println(version);
  memcpy(&(SCSI_INFO_BUF[32]), version, 4);
  config_file.close();
  */
}