Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ATOMNFT committed Jun 26, 2024
2 parents 1c7abf0 + 4b19e1f commit 1fcce62
Show file tree
Hide file tree
Showing 16 changed files with 1,007 additions and 439 deletions.
59 changes: 43 additions & 16 deletions minigotchi-ESP32/channel.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Minigotchi: An even smaller Pwnagotchi
* Copyright (C) 2024 dj1ch
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* channel.cpp: handles channel switching
*/
Expand Down Expand Up @@ -28,8 +46,8 @@ void Channel::init(int initChannel) {
Serial.print("(-.-) Initializing on channel ");
Serial.println(initChannel);
Serial.println(" ");
Display::cleanDisplayFace("(-.-)");
Display::attachSmallText("Initializing on channel " + (String)initChannel);
Display::updateDisplay("(-.-)",
"Initializing on channel " + (String)initChannel);
delay(250);

// switch channel
Expand All @@ -40,14 +58,13 @@ void Channel::init(int initChannel) {
if (err == ESP_OK && initChannel == getChannel()) {
Serial.print("('-') Successfully initialized on channel ");
Serial.println(getChannel());
Display::cleanDisplayFace("('-')");
Display::attachSmallText("Successfully initialized on channel " +
(String)getChannel());
Display::updateDisplay("('-')", "Successfully initialized on channel " +
(String)getChannel());
delay(250);
} else {
Serial.println("(X-X) Channel initialization failed, try again?");
Display::cleanDisplayFace("(X-X)");
Display::attachSmallText("Channel initialization failed, try again?");
Display::updateDisplay("(X-X)",
"Channel initialization failed, try again?");
delay(250);
}
}
Expand All @@ -70,8 +87,7 @@ void Channel::switchChannel(int newChannel) {
Serial.print("(-.-) Switching to channel ");
Serial.println(newChannel);
Serial.println(" ");
Display::cleanDisplayFace("(-.-)");
Display::attachSmallText("Switching to channel " + (String)newChannel);
Display::updateDisplay("(-.-)", "Switching to channel " + (String)newChannel);
delay(250);

// monitor this one channel
Expand All @@ -83,10 +99,11 @@ void Channel::switchChannel(int newChannel) {
if (err == ESP_OK) {
checkChannel(newChannel);
} else {

Serial.println("(X-X) Failed to switch channel.");
Serial.println(" ");
Display::cleanDisplayFace("(X-X)");
Display::attachSmallText("Failed to switch channel.");
Display::updateDisplay("(X-X)", "Failed to switch channel.");
checkChannel(newChannel);
delay(250);
}
}
Expand All @@ -97,8 +114,8 @@ void Channel::checkChannel(int channel) {
if (channel == currentChannel) {
Serial.print("('-') Currently on channel ");
Serial.println(currentChannel);
Display::cleanDisplayFace("('-')");
Display::attachSmallText("Currently on channel " + (String)getChannel());
Display::updateDisplay("('-')",
"Currently on channel " + (String)getChannel());
Serial.println(" ");
delay(250);
} else {
Expand All @@ -109,13 +126,23 @@ void Channel::checkChannel(int channel) {
Serial.print(currentChannel);
Serial.println(" instead");
Serial.println(" ");
Display::cleanDisplayFace("(X-X)");
Display::attachSmallText("Channel switch to " + (String)channel +
" has failed");
Display::updateDisplay("(X-X)", "Channel switch to " + (String)channel +
" has failed");
delay(250);
}
}

bool Channel::isValidChannel(int channel) {
bool isValidChannel = false;
for (int i = 0; i < sizeof(channelList) / sizeof(channelList[0]); i++) {
if (channelList[i] == channel) {
isValidChannel = true;
break;
}
}
return isValidChannel;
}

int Channel::getChannel() {
uint8_t primary;
wifi_second_chan_t second;
Expand Down
20 changes: 20 additions & 0 deletions minigotchi-ESP32/channel.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Minigotchi: An even smaller Pwnagotchi
* Copyright (C) 2024 dj1ch
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* channel.h: header files for channel.cpp
*/
Expand All @@ -8,6 +26,7 @@
#include "config.h"
#include "display.h"
#include "minigotchi.h"
#include "parasite.h"
#include <WiFi.h>
#include <esp_wifi.h>

Expand All @@ -18,6 +37,7 @@ class Channel {
static void switchChannel(int newChannel);
static int getChannel();
static void checkChannel(int channel);
static bool isValidChannel(int channel);
static int channelList[13]; // 13 channels

private:
Expand Down
32 changes: 32 additions & 0 deletions minigotchi-ESP32/config.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Minigotchi: An even smaller Pwnagotchi
* Copyright (C) 2024 dj1ch
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* config.h: header files for config.cpp
*/
Expand All @@ -6,7 +24,9 @@
#define CONFIG_H

#include "minigotchi.h"
#include "parasite.h"
#include <Arduino.h>
#include <esp_wifi.h>
#include <iostream>
#include <random>
#include <string>
Expand All @@ -16,11 +36,22 @@ class Config {
public:
static bool deauth;
static bool advertise;
static int shortDelay;
static int longDelay;
static bool parasite;
static bool display;
static std::string screen;
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 face;
static std::string identity;
Expand All @@ -45,6 +76,7 @@ class Config {
static std::string session_id;
static int uptime;
static std::string version;
static wifi_init_config_t config;

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

0 comments on commit 1fcce62

Please sign in to comment.