Added the option to run an AP from another port

This commit is contained in:
Jelmer
2023-05-07 15:42:49 +02:00
parent 9ccf3ab029
commit cfee590f01
5 changed files with 47 additions and 22 deletions

View File

@@ -5,10 +5,4 @@ bool checkForcedAPFlash();
bool doForcedAPFlash();
bool doAPFlash();
bool doAPUpdate(uint8_t type);
bool doTagFlash();
#define FLASHER_AP_PORT 0
#ifdef OPENEPAPERLINK_PCB
#define FLASHER_EXT_PORT 1
#define FLASHER_ALTRADIO_PORT 2
#endif
bool doTagFlash();

View File

@@ -1,5 +1,11 @@
#include <Arduino.h>
#define FLASHER_AP_PORT 0
#ifdef OPENEPAPERLINK_PCB
#define FLASHER_EXT_PORT 1
#define FLASHER_ALTRADIO_PORT 2
#endif
// how long the we should keep the transfer metadata
#define PENDING_TIMEOUT 24 * 3600
// this determines how long images will be cached;
@@ -7,6 +13,10 @@
// maximum time (in minutes) that a tag is put to sleep if no update is expected.
#define MIN_RESPONSE_TIME 10
// Which port we should use for the AP process
// (useful for testing, can only be FLASHER_AP_PORT for any other board than the OpenEPaperLinkPCB board)
#define AP_PROCESS_PORT FLASHER_AP_PORT
// flasher options
#define CUSTOM_MAC_HDR 0x0000

View File

@@ -119,7 +119,7 @@ bool flasher::connectTag(uint8_t port) {
Serial.printf("Tried to connect to port %d, but this port isn't available. Some dev borked it up, probably Jelmer.\n", port);
return false;
}
if (!result) Serial.printf("I tried connecting to port, but I couldn't establish a link to the tag. That's all I know.\n");
if (!result) Serial.printf("I tried connecting to port %d, but I couldn't establish a link to the tag. That's all I know.\n", port);
return result;
}
@@ -499,7 +499,7 @@ bool checkForcedAPFlash() {
bool doForcedAPFlash() {
Serial.printf("Doing a forced AP Flash!\n");
class flasher *f = new flasher();
if (!f->connectTag(0)) {
if (!f->connectTag(AP_PROCESS_PORT)) {
Serial.printf("Sorry, failed to connect to this tag...\n");
delete f;
return false;
@@ -525,7 +525,7 @@ bool doForcedAPFlash() {
bool doAPFlash() {
// This function expects a tag in stock configuration, to be used as an AP. It can also work with 'dead' AP's.
class flasher *f = new flasher();
if (!f->connectTag(0)) {
if (!f->connectTag(AP_PROCESS_PORT)) {
Serial.printf("Sorry, failed to connect to this tag...\n");
delete f;
return false;
@@ -557,7 +557,7 @@ bool doAPFlash() {
bool doAPUpdate(uint8_t type) {
// this function expects the tag to be already flashed with some version of the OpenEpaperLink Firmware, and that it correctly reported its type
class flasher *f = new flasher();
if (!f->connectTag(0)) {
if (!f->connectTag(AP_PROCESS_PORT)) {
Serial.printf("Sorry, failed to connect to this tag...\n");
delete f;
return false;
@@ -578,7 +578,6 @@ bool doAPUpdate(uint8_t type) {
f->findTagByType(type);
f->writeInfoBlock();
}
// TODO: DO THE ACTUAL FLASHING!
bool res = f->writeFlashFromPack("/AP_FW_Pack.bin", f->tagtype);
if(res)f->zbs->reset();
delete f;
@@ -588,7 +587,7 @@ bool doAPUpdate(uint8_t type) {
// perform device flash, save mac, everything
bool doTagFlash() {
class flasher *f = new flasher();
if (!f->connectTag(1)) {
if (!f->connectTag(FLASHER_EXT_PORT)) {
Serial.printf("Sorry, failed to connect to this tag...\n");
return false;
}

View File

@@ -2,10 +2,8 @@
#include <WiFi.h>
#include <WiFiManager.h>
#include <time.h>
#include "contentmanager.h"
#include "flasher.h"
// #include "hal/wdt_hal.h"
#include "makeimage.h"
#include "serialap.h"
#include "settings.h"

View File

@@ -108,17 +108,31 @@ bool waitCmdReply() {
return false;
}
#if (AP_PROCESS_PORT == FLASHER_AP_PORT)
#define AP_RESET_PIN FLASHER_AP_RESET
#define AP_POWER_PIN FLASHER_AP_POWER
#endif
#if (AP_PROCESS_PORT == FLASHER_EXT_PORT)
#define AP_RESET_PIN FLASHER_EXT_RESET
#define AP_POWER_PIN FLASHER_EXT_POWER
#endif
#if (AP_PROCESS_PORT == FLASHER_ALTRADIO_PORT)
#define AP_RESET_PIN FLASHER_ALT_RESET
#define AP_POWER_PIN FLASHER_ALT_POWER
#endif
// Reset the tag
void APTagReset() {
pinMode(FLASHER_AP_RESET, OUTPUT);
digitalWrite(FLASHER_AP_RESET, LOW);
pinMode(AP_RESET_PIN, OUTPUT);
digitalWrite(AP_RESET_PIN, LOW);
vTaskDelay(10 / portTICK_PERIOD_MS);
rampTagPower(FLASHER_AP_POWER, false);
rampTagPower(AP_POWER_PIN, false);
vTaskDelay(100 / portTICK_PERIOD_MS);
rampTagPower(FLASHER_AP_POWER, true);
rampTagPower(AP_POWER_PIN, true);
vTaskDelay(10 / portTICK_PERIOD_MS);
digitalWrite(FLASHER_AP_RESET, HIGH);
rampTagPower(FLASHER_AP_POWER, true);
digitalWrite(AP_RESET_PIN, HIGH);
rampTagPower(AP_POWER_PIN, true);
vTaskDelay(10 / portTICK_PERIOD_MS);
}
@@ -534,11 +548,21 @@ void APTask(void* parameter) {
xTaskCreate(rxCmdProcessor, "rxCmdProcessor", 10000, NULL, configMAX_PRIORITIES - 10, NULL);
xTaskCreate(rxSerialTask, "rxSerialTask", 4000, NULL, configMAX_PRIORITIES - 4, NULL);
#if (AP_PROCESS_PORT == FLASHER_AP_PORT)
AP_SERIAL_PORT.begin(115200, SERIAL_8N1, FLASHER_AP_RXD, FLASHER_AP_TXD);
#endif
#if (AP_PROCESS_PORT == FLASHER_EXT_PORT)
AP_SERIAL_PORT.begin(115200, SERIAL_8N1, FLASHER_EXT_RXD, FLASHER_EXT_TXD);
#endif
#if (AP_PROCESS_PORT == FLASHER_ALTRADIO_PORT)
AP_SERIAL_PORT.begin(115200, SERIAL_8N1, FLASHER_AP_RXD, FLASHER_AP_TXD);
#endif
vTaskDelay(3000 / portTICK_PERIOD_MS);
if(checkForcedAPFlash())doForcedAPFlash();
if (checkForcedAPFlash()){
doForcedAPFlash();
}
if (bringAPOnline()) {
// AP works