Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP8266 as DupleTX #1457

Merged
merged 17 commits into from Jun 3, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/OPTIONS/hardware.cpp
Expand Up @@ -3,7 +3,7 @@
#include "targets.h"
#include "helpers.h"
#include "logging.h"
#if defined(TARGET_UNIFIED_RX)
#if defined(PLATFORM_ESP8266)
#include <FS.h>
#else
#include <SPIFFS.h>
Expand Down
4 changes: 3 additions & 1 deletion src/lib/OPTIONS/options.cpp
Expand Up @@ -233,7 +233,7 @@ const char PROGMEM compile_options[] = {
#else // TARGET_UNIFIED_TX || TARGET_UNIFIED_RX

#include <ArduinoJson.h>
#if defined(TARGET_UNIFIED_RX)
#if defined(PLATFORM_ESP8266)
#include <FS.h>
#else
#include <SPIFFS.h>
Expand Down Expand Up @@ -300,12 +300,14 @@ bool options_init()
{
uint32_t partition_start = 0;
#if defined(PLATFORM_ESP32)
SPIFFS.begin(true);
const esp_partition_t *running = esp_ota_get_running_partition();
if (running) {
partition_start = running->address;
}
uint32_t location = partition_start + ESP.getSketchSize();
#else
SPIFFS.begin();
uint32_t location = partition_start + myGetSketchSize();
#endif
ESP.flashRead(location, buf, 2048);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/POWERMGNT/POWERMGNT.cpp
Expand Up @@ -253,7 +253,7 @@ void POWERMGNT::setPower(PowerLevels_e Power)
Radio.SetOutputPower(0b0000);
dacWrite(GPIO_PIN_RFamp_APC2, powerValues[Power - MinPower]);
#else
#if defined(TARGET_UNIFIED_TX)
#if defined(TARGET_UNIFIED_TX) && defined(PLATFORM_ESP32)
if (POWER_OUTPUT_DACWRITE)
{
Radio.SetOutputPower(0b0000);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/WIFI/devWIFI.cpp
Expand Up @@ -4,7 +4,7 @@

#if defined(TARGET_UNIFIED_TX) || defined(TARGET_UNIFIED_RX)
#include <ArduinoJson.h>
#if defined(TARGET_UNIFIED_RX)
#if defined(PLATFORM_ESP8266)
#include <FS.h>
#else
#include <SPIFFS.h>
Expand Down
5 changes: 0 additions & 5 deletions src/src/rx_main.cpp
Expand Up @@ -21,10 +21,6 @@
#include "devVTXSPI.h"
#include "devAnalogVbat.h"

#if defined(TARGET_UNIFIED_RX)
#include <FS.h>
#endif

///LUA///
#define LUA_MAX_PARAMS 32
////
Expand Down Expand Up @@ -1278,7 +1274,6 @@ void setup()
#if defined(TARGET_UNIFIED_RX)
Serial.begin(420000);
SerialLogger = &Serial;
SPIFFS.begin();
hardwareConfigured = options_init();
if (!hardwareConfigured)
{
Expand Down
36 changes: 19 additions & 17 deletions src/src/tx_main.cpp
Expand Up @@ -20,10 +20,6 @@
#include "devPDET.h"
#include "devBackpack.h"

#if defined(TARGET_UNIFIED_TX)
#include <SPIFFS.h>
#endif

//// CONSTANTS ////
#define MSP_PACKET_SEND_INTERVAL 10LU

Expand Down Expand Up @@ -540,7 +536,7 @@ void ICACHE_RAM_ATTR timerCallbackNormal()
NonceTX % ExpressLRS_currAirRate_Modparams->numOfSends == ExpressLRS_currAirRate_Modparams->numOfSends / 2) // Swicth in the middle of DVDA sends
{
switchDiversityAntennas();
}
}

// Nonce advances on every timer tick
if (!InBindingMode)
Expand Down Expand Up @@ -1027,16 +1023,19 @@ static void setupTarget()
setupTxBackpack();
}

void setup()
bool setupHardwareFromOptions()
{
bool hardware_success = true;
#if defined(TARGET_UNIFIED_TX)
TxBackpack = new HardwareSerial(1);
((HardwareSerial *)TxBackpack)->begin(460800, SERIAL_8N1, 3, 1);
SPIFFS.begin(true);
hardware_success = options_init();
if (!hardware_success)
if (!options_init())
{
#if defined(PLATFORM_ESP32)
TxBackpack = new HardwareSerial(1);
((HardwareSerial *)TxBackpack)->begin(460800, SERIAL_8N1, 3, 1);
#else
TxBackpack = new HardwareSerial(0);
((HardwareSerial *)TxBackpack)->begin(460800, SERIAL_8N1);
#endif

CapnBry marked this conversation as resolved.
Show resolved Hide resolved
// Register the WiFi with the framework
static device_affinity_t wifi_device[] = {
{&WIFI_device, 1}
Expand All @@ -1045,13 +1044,16 @@ void setup()
devicesInit();

connectionState = hardwareUndefined;
}
else
{
((HardwareSerial *)TxBackpack)->end();
CapnBry marked this conversation as resolved.
Show resolved Hide resolved
return false;
}
#endif
if (hardware_success)

return true;
}

void setup()
{
if (setupHardwareFromOptions())
{
initUID();
setupTarget();
Expand Down