esp-idf-lib/devtools/spec/metadata.rb

Wed, 12 Apr 2023 16:23:02 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 12 Apr 2023 16:23:02 +0200
changeset 24
74609f70411e
parent 1
1c9894662795
permissions
-rw-r--r--

Reduced I2C master speed from 400 to 100 Khz. Hope to get power-on init for BMP280 more reliable. Added warnings for I2C devices that are missing. Some logmessages reduced to debug log messages. Added extra 10 mSec delays before read shunt voltage in the INA219 task. Removed and reduced log levels in the MQTT task. Show received data events. Remove WiFi total time debug logging, it's ok now.

# frozen_string_literal: true

require_relative "component"

# A class that represents metadaata, `.eil.yml`
class Metadata
  # path: path to component root directory
  def initialize(path)
    raise ArgumentError, "path is missing" unless path

    @path = path
    @name = File.basename(path)
    raise ArgumentError, "path `#{path}` does not have basename" if @name.empty?

    metadata
  end

  attr_reader :path, :name

  def metadata
    return @metadata if @metadata

    file = File.join(path, ".eil.yml")
    @metadata = YAML.safe_load(File.read(file))
  rescue StandardError => e
    warn "failed to open `#{file}`. does component `#{File.basename(path)}` have `.eil.yml` file?"
    raise e
  end

  def components?
    metadata.key?("components")
  end

  def components
    metadata["components"].map { |c| Component.new(c) }
  end

  def to_s
    name
  end
end

mercurial