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

Conditional Compilation and Redefined 'strptime' #3

Merged
merged 5 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arch/nrf52/nrf52.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ build_flags =
-Isrc/platform/nrf52

build_src_filter =
${arduino_base.build_src_filter} -<platform/esp32/> -<platform/stm32wl> -<nimble/> -<mesh/wifi/> -<mesh/api/> -<mesh/http/> -<modules/esp32> -<platform/rp2040> -<mesh/eth/> -<mesh/raspihttp>
${arduino_base.build_src_filter} -<platform/esp32/> -<platform/stm32wl> -<nimble/> -<mesh/wifi/> -<mesh/api/> -<mesh/http/> -<mesh/blockchain/> -<modules/esp32> -<platform/rp2040> -<mesh/eth/> -<mesh/raspihttp>

lib_deps=
${arduino_base.lib_deps}
Expand Down
1 change: 1 addition & 0 deletions arch/portduino/portduino.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ build_src_filter =
-<platform/rp2040>
-<mesh/wifi/>
-<mesh/http/>
-<mesh/blockchain/>
+<mesh/raspihttp/>
-<mesh/eth/>
-<modules/esp32>
Expand Down
2 changes: 1 addition & 1 deletion arch/rp2040/rp2040.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ build_flags =
-D__PLAT_RP2040__
# -D _POSIX_THREADS
build_src_filter =
${arduino_base.build_src_filter} -<platform/esp32/> -<nimble/> -<modules/esp32> -<platform/nrf52/> -<platform/stm32wl> -<mesh/eth/> -<mesh/wifi/> -<mesh/http/> -<mesh/raspihttp>
${arduino_base.build_src_filter} -<platform/esp32/> -<nimble/> -<modules/esp32> -<platform/nrf52/> -<platform/stm32wl> -<mesh/eth/> -<mesh/wifi/> -<mesh/http/> -<mesh/blockchain/> -<mesh/raspihttp>

lib_ignore =
BluetoothOTA
Expand Down
2 changes: 1 addition & 1 deletion arch/stm32/stm32wl5e.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ build_flags =
-DVECT_TAB_OFFSET=0x08000000

build_src_filter =
${arduino_base.build_src_filter} -<platform/esp32/> -<nimble/> -<mesh/api/> -<mesh/wifi/> -<mesh/http/> -<modules/esp32> -<mesh/eth/> -<input> -<buzz> -<modules/Telemetry> -<platform/nrf52> -<platform/portduino> -<platform/rp2040> -<mesh/raspihttp>
${arduino_base.build_src_filter} -<platform/esp32/> -<nimble/> -<mesh/api/> -<mesh/wifi/> -<mesh/http/> -<mesh/blockchain/> -<modules/esp32> -<mesh/eth/> -<input> -<buzz> -<modules/Telemetry> -<platform/nrf52> -<platform/portduino> -<platform/rp2040> -<mesh/raspihttp>

board_upload.offset_address = 0x08000000
upload_protocol = stlink
Expand Down
1 change: 1 addition & 0 deletions src/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Turn off all optional modules
#ifdef MESHTASTIC_EXCLUDE_MODULES
#define MESHTASTIC_EXCLUDE_AUDIO 1
#define MESHTASTIC_EXCLUDE_CRANKK 1
#define MESHTASTIC_EXCLUDE_DETECTIONSENSOR 1
#define MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR 1
#define MESHTASTIC_EXCLUDE_EXTERNALNOTIFICATION 1
Expand Down
18 changes: 16 additions & 2 deletions src/mesh/blockchain/BlockchainHandler.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
#if !MESHTASTIC_EXCLUDE_WEBSERVER
#include "BlockchainHandler.h"
#include "FSCommon.h"
#include "HTTPClient.h"
#include "WiFi.h"
#include <cstdio>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <memory>
#include <sstream>

// Redefine strptime in your source to avoid IRAM issue
char *strptime(const char *str, const char *format, struct tm *tm)
{
if (sscanf(str, format, &tm->tm_year, &tm->tm_mon, &tm->tm_mday, &tm->tm_hour, &tm->tm_min, &tm->tm_sec) == 6) {
tm->tm_year -= 1900; // Adjust year to be relative to 1900
tm->tm_mon -= 1; // Adjust month to be 0-based
return (char *)(str + strlen(str));
}
return NULL;
}

bool isWIFIavailable()
{
return getValidTime(RTCQualityFromNet) != 0 && WiFi.status() == WL_CONNECTED;
Expand Down Expand Up @@ -157,7 +170,7 @@ JSONObject BlockchainHandler::createCommandObject(const String &command)
signers.push_back(new JSONValue(signerObject));
cmdObject["signers"] = new JSONValue(signers);

JSONObject metaObject = {{"creationTime", new JSONValue(getValidTime(RTCQualityFromNet))},
JSONObject metaObject = {{"creationTime", new JSONValue((uint)getValidTime(RTCQualityFromNet))},
{"ttl", new JSONValue(28800)},
{"chainId", new JSONValue("19")},
{"gasPrice", new JSONValue(0.00001)},
Expand Down Expand Up @@ -269,4 +282,5 @@ String BlockchainHandler::executeBlockchainCommand(String commandType, String co
} else {
return response.c_str();
}
}
}
#endif
2 changes: 1 addition & 1 deletion src/mesh/blockchain/BlockchainHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
#include "BLAKE2b.h"
#include "NodeDB.h"
#include "RTC.h"
#include "Router.h"
#include "concurrency/Periodic.h"
#include "configuration.h"
#include "mesh/NodeDB.h"
#include "mesh/http/ContentHandler.h"
#include "mqtt/JSON.h"
#include "router.h"
#include "target_specific.h"
#include <Crypto.h>
#include <memory>
Expand Down
8 changes: 6 additions & 2 deletions src/modules/Modules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#if !MESHTASTIC_EXCLUDE_REMOTEHARDWARE
#include "modules/RemoteHardwareModule.h"
#endif
#include "modules/CrankkModule.h"
#include "modules/RoutingModule.h"
#include "modules/TextMessageModule.h"
#if !MESHTASTIC_EXCLUDE_TRACEROUTE
Expand Down Expand Up @@ -59,6 +58,9 @@
#if !MESHTASTIC_EXCLUDE_STOREFORWARD
#include "modules/esp32/StoreForwardModule.h"
#endif
#if !MESHTASTIC_EXCLUDE_CRANKK
#include "modules/esp32/CrankkModule.h"
#endif
#endif
#if defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040)
#if !MESHTASTIC_EXCLUDE_EXTERNALNOTIFICATION
Expand Down Expand Up @@ -89,7 +91,6 @@ void setupModules()
waypointModule = new WaypointModule();
#endif
textMessageModule = new TextMessageModule();
crankkModule = new CrankkModule();
#if !MESHTASTIC_EXCLUDE_TRACEROUTE
traceRouteModule = new TraceRouteModule();
#endif
Expand Down Expand Up @@ -168,6 +169,9 @@ void setupModules()
#if !MESHTASTIC_EXCLUDE_PAXCOUNTER
paxcounterModule = new PaxcounterModule();
#endif
#if !MESHTASTIC_EXCLUDE_CRANKK
crankkModule = new CrankkModule();
#endif
#endif
#if defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040)
#if !MESHTASTIC_EXCLUDE_EXTERNALNOTIFICATION
Expand Down
1 change: 0 additions & 1 deletion src/modules/TextMessageModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "NodeDB.h"
#include "PowerFSM.h"
#include "configuration.h"
#include "mesh/blockchain/BlockchainHandler.h"

TextMessageModule *textMessageModule;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include "configuration.h"
#if defined(ARCH_ESP32) && !MESHTASTIC_EXCLUDE_CRANKK
#include "CrankkModule.h"
#include "MeshService.h"
#include "NodeDB.h"
#include "PowerFSM.h"
#include "configuration.h"
#include "mesh/blockchain/BlockchainHandler.h"

CrankkModule *crankkModule;
Expand Down Expand Up @@ -47,4 +48,5 @@ bool CrankkModule::wantPacket(const meshtastic_MeshPacket *p)
{
return p->decoded.portnum == meshtastic_PortNum_CRANKK_APP;
// return MeshService::isTextPayload(p);
}
}
#endif
File renamed without changes.
Loading