<commit_before>require 'farmbot-serial'
require 'meshruby'
require_relative 'lib/messaging/credentials'
require_relative 'lib/messaging/messagehandler'
require 'pry'

class FarmBotPi
  attr_accessor :mesh, :bot, :credentials, :handler

  def initialize
    @credentials = Credentials.new
    @mesh        = EM::MeshRuby.new(@credentials.uuid, @credentials.token)
    @bot         = FB::Arduino.new
    @handler     = MessageHandler
  end

  def incoming_message(msg)
    handler.call(msg, bot, mesh)
  end

  def start
    mesh.toggle_debug!

    EM.run do
      mesh.connect
      mesh.onmessage { |msg| incoming_message(msg) }

      FB::ArduinoEventMachine.connect(bot)
        bot.onmessage { |msg| bot.log "BOT MSG: #{msg}"}
        bot.onchange { |diff| bot.log "BOT DIF: #{diff}"}
        bot.onclose { puts 'Disconnected'; EM.stop }
    end
  end
end

FarmBotPi.new.start
<commit_msg>Print UUID/Token whilst debugging<commit_after>require 'farmbot-serial'
require 'meshruby'
require_relative 'lib/messaging/credentials'
require_relative 'lib/messaging/messagehandler'
require 'pry'

class FarmBotPi
  attr_accessor :mesh, :bot, :credentials, :handler

  def initialize
    @credentials = Credentials.new
    @mesh        = EM::MeshRuby.new(@credentials.uuid, @credentials.token)
    @bot         = FB::Arduino.new
    @handler     = MessageHandler
    puts "UUID / Token:", @credentials.uuid, @credentials.token
  end

  def incoming_message(msg)
    handler.call(msg, bot, mesh)
  end

  def start
    mesh.toggle_debug!

    EM.run do
      mesh.connect
        mesh.onmessage { |msg| incoming_message(msg) }

      FB::ArduinoEventMachine.connect(bot)
        bot.onmessage { |msg| bot.log "BOT MSG: #{msg}"}
        bot.onchange { |diff| bot.log "BOT DIF: #{diff}"}
        bot.onclose { puts 'Disconnected'; EM.stop }
    end
  end
end

FarmBotPi.new.start

{'fraction_non_alphanumeric': 0.1160427807486631, 'fraction_numerical': 0.0, 'mean_word_length': 3.195067264573991, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1898368', 'n_tokens_mistral': 653, 'n_tokens_neox': 625, 'n_words': 138}