<commit_before>/*
      Copyright 2015-2016 <NAME> <<EMAIL>>
                          Stichting Makerspace Leiden, the Netherlands.

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

#define BUZZER    (4)   // GPIO pin count.
#define SOLENOID  (5)

#define RFID_SELECT_PIN (6)
#define RFID_RESET_PIN (7)

#include <ACNode.h>

ACNode node = ACNode(true); // Force wired PoE ethernet.

typedef enum {
  BOOTING, SWERROR, OUTOFORDER, NOCONN, // some error - machine disabLED.
  WAITINGFORCARD,             // waiting for card.
  CHECKINGCARD,
  BUZZING,
  REJECTED,
  NOTINUSE
} machinestates_t;

const char *machinestateName[NOTINUSE] = {
  "Software Error", "Out of order", "No network",
  "Waiting for card",
  "Buzzing door",
  "Rejecting noise",
  "== not in use == "
};

unsigned long laststatechange = 0;
static machinestates_t laststate = OUTOFORDER;
machinestates_t machinestate = BOOTING;

OTA ota = OTA("FooBar");
RFID reader(RFID_SELECT_PIN, RFID_RESET_PIN);
MSL msl = MSL();

void setup() {

  // Init the hardware and get it into a safe state.
  //
  pinMode(BUZZER, OUTPUT);
  digitalWrite(BUZZER, 0);
  pinMode(SOLENOID, OUTPUT);
  digitalWrite(SOLENOID, 0);

  node.onConnect([]() {
    Log.println("Connected");
    machinestate = WAITINGFORCARD;
  });
  node.onDisconnect([]() {
    Log.println("Disconnected");
    machinestate = NOCONN;
  });
  node.onError([](acnode_error_t err) {
    Log.printf("Error %d\n", err);
    machinestate = WAITINGFORCARD;
  });
  node.onValidatedCmd([](const char *cmd, const char *restl) {<commit_msg>Clarify handlers.<commit_after>/*
      Copyright 2015-2016 <NAME> <<EMAIL>>
                          Stichting Makerspace Leiden, the Netherlands.

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

#define BUZZER    (4)   // GPIO pin count.
#define SOLENOID  (5)

#define RFID_SELECT_PIN (6)
#define RFID_RESET_PIN (7)

#include <ACNode.h>

ACNode node = ACNode(true); // Force wired PoE ethernet.

typedef enum {
  BOOTING, SWERROR, OUTOFORDER, NOCONN, // some error - machine disabLED.
  WAITINGFORCARD,             // waiting for card.
  CHECKINGCARD,
  BUZZING,
  REJECTED,
  NOTINUSE
} machinestates_t;

const char *machinestateName[NOTINUSE] = {
  "Software Error", "Out of order", "No network",
  "Waiting for card",
  "Buzzing door",
  "Rejecting noise",
  "== not in use == "
};

unsigned long laststatechange = 0;
static machinestates_t laststate = OUTOFORDER;
machinestates_t machinestate = BOOTING;

OTA ota = OTA("FooBar");		// Over the air config, passowrd.
RFID reader(RFID_SELECT_PIN, RFID_RESET_PIN);
MSL msl = MSL();			// MSL `no security' handler as currently used for the doors.

void setup() {

  // Init the hardware and get it into a safe state.
  //
  pinMode(BUZZER, OUTPUT);
  digitalWrite(BUZZER, 0);
  pinMode(SOLENOID, OUTPUT);
  digitalWrite(SOLENOID, 0);

  node.onConnect([]() {
    Log.println("Connected");
    machinestate = WAITINGFORCARD;
  });
  node.onDisconnect([]() {
    Log.println("Disconnected");
    machinestate = NOCONN;
  });
  node.onError([](acnode_error_t err) {
    Log.printf("Error %d\n", err);
    machinestate = WAITINGFORCARD;
  });
  node.onValidatedCmd([](const char *cmd, const char *restl) {
{'fraction_non_alphanumeric': 0.10955655679392934, 'fraction_numerical': 0.009011145364002845, 'mean_word_length': 3.501600853788687, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '128593', 'n_tokens_mistral': 1447, 'n_tokens_neox': 1410, 'n_words': 440}