Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #183 from dj1ch/development
Browse files Browse the repository at this point in the history
setup webui + mood system + even more stuff
  • Loading branch information
dj1ch authored Aug 20, 2024
2 parents e7f9c33 + 4fe9b0f commit 65feae6
Show file tree
Hide file tree
Showing 18 changed files with 1,063 additions and 329 deletions.
6 changes: 3 additions & 3 deletions .vscode/arduino.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"configuration": "xtal=80,vt=flash,exception=disabled,stacksmash=disabled,ssl=all,mmu=3232,non32xfer=fast,FlashMode=dout,FlashFreq=40,eesz=4M2M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=921600",
"board": "esp8266:esp8266:d1_mini_clone",
"configuration": "deauther_config=d1mini,eesz=1M64,wipe=all,baud=921600",
"board": "deauther:esp8266:d1_mini",
"sketch": "minigotchi\\minigotchi.ino",
"port": "COM9"
"port": "COM11"
}
317 changes: 115 additions & 202 deletions .vscode/c_cpp_properties.json

Large diffs are not rendered by default.

22 changes: 14 additions & 8 deletions minigotchi/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@
*/

/**
* Channels to use, matching the config
* Gets first instance of mood class
*/
Mood &Channel::mood = Mood::getInstance();

/**
* Channels to use, matching the config
*/
int Channel::channelList[13] = {
Config::channels[0], Config::channels[1], Config::channels[2],
Config::channels[3], Config::channels[4], Config::channels[5],
Expand All @@ -32,10 +36,10 @@ void Channel::init(int initChannel) {
// start on user specified channel
delay(Config::shortDelay);
Serial.println(" ");
Serial.print("(-.-) Initializing on channel ");
Serial.print(mood.getSleeping() + " Initializing on channel ");
Serial.println(initChannel);
Serial.println(" ");
Display::updateDisplay("(-.-)",
Display::updateDisplay(mood.getSleeping(),
"Initializing on channel " + (String)initChannel);
delay(Config::shortDelay);

Expand All @@ -45,14 +49,16 @@ void Channel::init(int initChannel) {
Minigotchi::monStart();

if (initChannel == getChannel()) {
Serial.print("('-') Successfully initialized on channel ");
Serial.print(mood.getNeutral() + " Successfully initialized on channel ");
Serial.println(getChannel());
Display::updateDisplay("('-')", "Successfully initialized on channel " +
(String)getChannel());
Display::updateDisplay(mood.getNeutral(),
"Successfully initialized on channel " +
(String)getChannel());
delay(Config::shortDelay);
} else {
Serial.print("(X-X) Channel initialization failed, try again?");
Display::updateDisplay("(X-X)",
Serial.println(mood.getBroken() +
" Channel initialization failed, try again?");
Display::updateDisplay(mood.getBroken(),
"Channel initialization failed, try again?");
delay(Config::shortDelay);
}
Expand Down
4 changes: 4 additions & 0 deletions minigotchi/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
#ifndef CHANNEL_H
#define CHANNEL_H

#include "mood.h"
#include "config.h"
#include "minigotchi.h"
#include <ESP8266WiFi.h>

class Mood;

class Channel {
public:
static void init(int initChannel);
Expand All @@ -20,6 +23,7 @@ class Channel {
static int channelList[13]; // 13 channels

private:
static Mood &mood;
static int randomIndex;
static int numChannels;
static int currentChannel;
Expand Down
67 changes: 66 additions & 1 deletion minigotchi/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ bool Config::deauth = true;
bool Config::advertise = true;
bool Config::scan = true;

// define access point ssid and password
const char *Config::ssid = "minigotchi";
const char *Config::pass = "dj1ch-minigotchi";

// define universal delays
int Config::shortDelay = 500;
int Config::longDelay = 5000;
Expand All @@ -38,6 +42,16 @@ int Config::channel = 1;
// define whitelist
std::vector<std::string> Config::whitelist = {"SSID", "SSID", "SSID"};

// define faces
String Config::happy = "(^-^)";
String Config::sad = "(;-;)";
String Config::broken = "(X-X)";
String Config::intense = "(>-<)";
String Config::looking1 = "(0-o)";
String Config::looking2 = "(o-0)";
String Config::neutral = "('-')";
String Config::sleeping = "(-.-)";

// json config
int Config::epoch = Minigotchi::currentEpoch;
std::string Config::face = "(^-^)";
Expand Down Expand Up @@ -70,7 +84,58 @@ std::string Config::session_id = "84:f3:eb:58:95:bd";
int Config::uptime = Config::time();

// define version(please do not change, this should not be changed)
std::string Config::version = "3.2.2-beta";
std::string Config::version = "3.3.2-beta";

// configured flag which only the WebUI changes
bool Config::configured = false;

/**
* Loads configuration values from EEPROM
*/
void Config::loadConfig() {
EEPROM.begin(512); // Initialize EEPROM with size 512 bytes

// load Config::configured
Config::configured = EEPROM.read(0) == 1;

// load Config::whitelist
for (int i = 0; i < 10; ++i) {
char ssid[33] = {0};
for (int j = 0; j < 32; ++j) {
ssid[j] = EEPROM.read(1 + i * 32 + j);
}
if (ssid[0] != '\0') {
whitelist.push_back(ssid);
}
}
EEPROM.end();
}

/**
* Saves configuration to EEPROM
*/
void Config::saveConfig() {
EEPROM.begin(512);

// save Config::configured
EEPROM.write(0, Config::configured ? 1 : 0);

// save Config::whitelist
for (int i = 0; i < 10; ++i) {
if (i < whitelist.size()) {
const char* ssid = whitelist[i].c_str();
for (int j = 0; j < 32; ++j) {
EEPROM.write(1 + i * 32 + j, ssid[j]);
}
} else {
for (int j = 0; j < 32; ++j) {
EEPROM.write(1 + i * 32 + j, 0);
}
}
}
EEPROM.commit();
EEPROM.end();
}

/** developer note:
*
Expand Down
14 changes: 14 additions & 0 deletions minigotchi/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "minigotchi.h"
#include <Arduino.h>
#include <EEPROM.h>
#include <iostream>
#include <random>
#include <string>
Expand All @@ -17,6 +18,8 @@ class Config {
static bool deauth;
static bool advertise;
static bool scan;
static const char *ssid;
static const char *pass;
static int shortDelay;
static int longDelay;
static bool parasite;
Expand All @@ -25,6 +28,14 @@ class Config {
static int baud;
static int channel;
static std::vector<std::string> whitelist;
static String happy;
static String sad;
static String broken;
static String intense;
static String looking1;
static String looking2;
static String neutral;
static String sleeping;
static int epoch;
static std::string grid_version;
static std::string face;
Expand All @@ -51,6 +62,9 @@ class Config {
static int timestamp;
static int uptime;
static std::string version;
static bool configured;
static void loadConfig();
static void saveConfig();

private:
static int random(int min, int max);
Expand Down
Loading

0 comments on commit 65feae6

Please sign in to comment.