Skip to content

Commit

Permalink
removed Auth Header, removed SDCard
Browse files Browse the repository at this point in the history
  • Loading branch information
H3rmt committed Mar 18, 2024
1 parent 078a3c9 commit 6f596ad
Show file tree
Hide file tree
Showing 14 changed files with 217 additions and 217 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ jobs:
- linux/amd64
- linux/arm/v7
- linux/arm64
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -38,7 +44,7 @@ jobs:
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.TOKEN }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v5
Expand All @@ -64,6 +70,12 @@ jobs:
runs-on: ubuntu-latest
needs:
- build
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Download digests
uses: actions/download-artifact@v3
Expand All @@ -89,7 +101,7 @@ jobs:
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.TOKEN }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
Expand Down
10 changes: 5 additions & 5 deletions esp-32/include/defs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@

#define ledPin GPIO_NUM_33
#define flashPin GPIO_NUM_4
// active on pulling low
#define triggerPin GPIO_NUM_13

#define flashPower 200
#define flashPower 180
#define startDelay 1500
#define wifiDelay 2500
#define wifiDelay 1500

#define serverHost "192.168.187.32"
#define serverPort 8080
#define serverSecret "f348ahj235a124baa1a23"


#define ERROR_OK 1

// 500 ms blink
#define ERROR_SD_INIT_FAILED 2
#define ERROR_WIFI_FAILED 3
#define ERROR_SEND_START_FAILED 4
#define ERROR_CREATE_FOLDER_FAILED 5
// 750 ms blink
// 1000 ms blink
#define ERROR_CAM_INIT_FAILED 6 // 2
#define ERROR_CAM_GET_FAILED 7 // 3
#define ERROR_SAVE_IMG_FAILED 8 // 4
Expand Down
2 changes: 1 addition & 1 deletion esp-32/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ platform = espressif32
board = esp32cam
framework = arduino
monitor_speed = 115200
build_flags = -DCORE_DEBUG_LEVEL=3
build_flags = -DCORE_DEBUG_LEVEL=2
2 changes: 1 addition & 1 deletion esp-32/src/cam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void configSensor()
s->set_lenc(s, 1); // Lens correction 0 = disable , 1 = enable
s->set_hmirror(s, 0); // Horizontal flip image 0 = disable , 1 = enable
s->set_vflip(s, 0); // Vertical flip image 0 = disable , 1 = enable
s->set_colorbar(s, 0); // Colour Testbar 0 = disable , 1 = enable
s->set_colorbar(s, 1); // Colour Testbar 0 = disable , 1 = enable
s->set_raw_gma(s, 1); // 0 = disable , 1 = enable
s->set_dcw(s, 1); // 0 = disable , 1 = enable
}
Expand Down
78 changes: 50 additions & 28 deletions esp-32/src/esp32-cam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include <driver/rtc_io.h>
#include <WiFi.h>

#define USESD
// #define USEFLASH
// #define USESD
#define USEFLASH

#include "cam.hpp"
#include "eeprom.hpp"
Expand Down Expand Up @@ -32,6 +32,12 @@ void setup()

Serial.begin(115200);

#ifdef USEFLASH
initFlash();
#endif
// Disable any hold on pin 4 that was placed before ESP32 went to sleep
rtc_gpio_hold_dis(flashPin);

#ifdef USESD
if (!openSD())
{
Expand All @@ -50,6 +56,16 @@ void setup()
{
Serial.println("START detected");

#ifdef USEFLASH
setFlash(flashPower / 2);
delay(600);
setFlash(0);
delay(600);
setFlash(flashPower / 2);
delay(600);
setFlash(0);
#endif

initWiFi();
if (!sendStart(ident))
{
Expand Down Expand Up @@ -87,12 +103,6 @@ void setup()

camera_config_t config = configCam();

#ifdef USEFLASH
initFlash();
#endif
// Disable any hold on pin 4 that was placed before ESP32 went to sleep
rtc_gpio_hold_dis(flashPin);

// Short pause helps to ensure the I2C interface has initialised properly before attempting to detect the camera
delay(150);

Expand All @@ -106,7 +116,7 @@ void setup()
return;
}

// configSensor();
configSensor();

#ifdef USEFLASH
setFlash(flashPower);
Expand All @@ -127,7 +137,7 @@ void setup()
sleep();
return;
}
Serial.println("Camera capture success");
Serial.println("Camera capture success /sleeping startDelay*3");

// check if print stopped
delay(startDelay * 3);
Expand Down Expand Up @@ -157,9 +167,19 @@ void setup()
Serial.println("SEND success");
#endif

if (finish) // IF LOW
if (finish == LOW) // IF LOW
{
Serial.println("DETECTED FINISH");
#ifdef USEFLASH
setFlash(flashPower / 2);
delay(400);
setFlash(0);
delay(300);
setFlash(flashPower / 2);
delay(400);
setFlash(0);
#endif

initWiFi();
#ifdef USESD
iterateFolder("/" + ident, [](String name, String content, String ident)
Expand All @@ -181,7 +201,7 @@ void setup()
sleep();
return;
}
Serial.println("FINISH success");
Serial.println("FINISH success /sleeping 10_000");
reset();

delay(10000); // wait for printer to move away
Expand All @@ -205,22 +225,24 @@ void errorLED(int code)
{
Serial.print("Error Code:");
Serial.println(code);
if (code <= 5)
for (size_t i = 0; i < code; i++)
{
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
}
else
for (size_t i = 0; i < code - 4; i++)
{
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
}

// indicate exit code
digitalWrite(ledPin, LOW);
delay(1500);
digitalWrite(ledPin, HIGH);
delay(500);

for (size_t i = 0; i < code; i++)
{
digitalWrite(ledPin, LOW);
// Serial.println("LED On");
delay(500);

digitalWrite(ledPin, HIGH);
// Serial.println("LED OFF");
delay(500);
}
Serial.println("Error code indicated");
}

void initWiFi()
Expand Down
3 changes: 2 additions & 1 deletion esp-32/src/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
bool openSD()
{
// if (!SD_MMC.begin("/imgs", true, false, SDMMC_FREQ_HIGHSPEED))
// if (!SD_MMC.begin("/sdcard", false, false, SDMMC_FREQ_DEFAULT))
// if (!SD_MMC.begin("/sdcard", true, true, SDMMC_FREQ_DEFAULT))
if (!SD_MMC.begin())
// int SD_CS_PIN = 19;
// SPI.begin(18, 36, 26, SD_CS_PIN);
Expand Down Expand Up @@ -77,7 +79,6 @@ void iterateFolder(String ident, void (*function)(String, String, String))
while (file)
{
Serial.println(file.name());
Serial.println(file.readString());
function(String(file.name()), file.readString(), ident);
file = root.openNextFile();
}
Expand Down
9 changes: 0 additions & 9 deletions esp-32/src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ bool sendPic(String pic, String pictureNumber, String ident)
{
HTTPClient http;
http.begin(serverHost, serverPort, String("/upload") + "?count=" + pictureNumber + "&identifier=" + ident);

http.setReuse(true);
http.setAuthorizationType("Bearer");
http.setAuthorization(serverSecret);

int connAttempts = 0;
Serial.println("Starting sendPic" + http.getLocation());
Expand All @@ -40,10 +37,7 @@ bool sendFinish(int pictureCount, String ident)
{
HTTPClient http;
http.begin(serverHost, serverPort, String("/finish") + "?count=" + pictureCount + "&identifier=" + ident);

http.setReuse(true);
http.setAuthorizationType("Bearer");
http.setAuthorization(serverSecret);

int connAttempts = 0;
Serial.println("Starting sendFinish" + http.getLocation());
Expand All @@ -70,10 +64,7 @@ bool sendStart(String &ident)
{
HTTPClient http;
http.begin(serverHost, serverPort, "/start");

http.setReuse(true);
http.setAuthorizationType("Bearer");
http.setAuthorization(serverSecret);

int connAttempts = 0;
Serial.println("Starting sendStart" + http.getLocation());
Expand Down
1 change: 1 addition & 0 deletions esp-32/src/sleep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ void sleep()
{
delay(3000); // wait for 3d printer to leave trigger
wifiOff();
Serial.println("Initiating deep sleep...");

// IMPORTANT - we define pin mode for the trigger pin at the end of setup, because most pins on the ESP32-CAM
// have dual functions, and may have previously been used by the camera or SD card access. So we overwrite them here
Expand Down
1 change: 1 addition & 0 deletions server/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target

/imgsOld
/imgs
Loading

0 comments on commit 6f596ad

Please sign in to comment.