diff --git a/hal/inc/hal_platform.h b/hal/inc/hal_platform.h index f0958c6b69..5a5f0b8d88 100644 --- a/hal/inc/hal_platform.h +++ b/hal/inc/hal_platform.h @@ -590,4 +590,8 @@ #define HAL_PLATFORM_SYSTEM_THREAD_TASK_NAME "systemsystem" #endif // HAL_PLATFORM_SYSTEM_THREAD_TASK_NAME +#ifndef HAL_PLATFORM_LEDGER +#define HAL_PLATFORM_LEDGER (1) +#endif // HAL_PLATFORM_LEDGER + #endif /* HAL_PLATFORM_H */ diff --git a/hal/src/gcc/hal_platform_config.h b/hal/src/gcc/hal_platform_config.h index 55cd21acf2..509a9939f1 100644 --- a/hal/src/gcc/hal_platform_config.h +++ b/hal/src/gcc/hal_platform_config.h @@ -65,3 +65,5 @@ #endif #define HAL_PLATFORM_FREERTOS (0) + +#define HAL_PLATFORM_LEDGER (0) diff --git a/hal/src/tracker/hal_platform_config.h b/hal/src/tracker/hal_platform_config.h index a0a11dea88..c0fe9d853e 100644 --- a/hal/src/tracker/hal_platform_config.h +++ b/hal/src/tracker/hal_platform_config.h @@ -62,3 +62,6 @@ #define HAL_PLATFORM_ETHERNET_WIZNETIF_RESET_PIN_DEFAULT (D6) #define HAL_PLATFORM_ETHERNET_WIZNETIF_INT_PIN_DEFAULT (D7) #endif // HAL_PLATFORM_ETHERNET + +// TODO: Enable the Ledger API when we have more flash space available on Tracker +#define HAL_PLATFORM_LEDGER 0 diff --git a/modules/shared/nRF52840/inc/system-part1/module_system_part1.inc b/modules/shared/nRF52840/inc/system-part1/module_system_part1.inc index dca5d78862..98c2a2f37e 100644 --- a/modules/shared/nRF52840/inc/system-part1/module_system_part1.inc +++ b/modules/shared/nRF52840/inc/system-part1/module_system_part1.inc @@ -90,34 +90,36 @@ extern "C" __attribute__((externally_visible)) const void* const system_part1_mo DYNALIB_TABLE_NAME(hal_inet), DYNALIB_TABLE_NAME(hal_netdb), DYNALIB_TABLE_NAME(hal_ifapi), - DYNALIB_TABLE_NAME(hal_resolvapi), + DYNALIB_TABLE_NAME(hal_resolvapi) #if HAL_PLATFORM_CELLULAR - DYNALIB_TABLE_NAME(hal_cellular), + , DYNALIB_TABLE_NAME(hal_cellular) #endif // HAL_PLATFORM_CELLULAR #if HAL_PLATFORM_WIFI && HAL_PLATFORM_WIFI_COMPAT - DYNALIB_TABLE_NAME(hal_wlan), + , DYNALIB_TABLE_NAME(hal_wlan) #endif // HAL_PLATFORM_WIFI && HAL_PLATFORM_WIFI_COMPAT #if HAL_PLATFORM_BLE - DYNALIB_TABLE_NAME(hal_ble), + , DYNALIB_TABLE_NAME(hal_ble) #endif // HAL_PLATFORM_BLE #if HAL_PLATFORM_NFC - DYNALIB_TABLE_NAME(hal_nfc), + , DYNALIB_TABLE_NAME(hal_nfc) #endif // HAL_PLATFORM_NFC #if HAL_PLATFORM_MESH_DEPRECATED - DYNALIB_TABLE_NAME(hal_mesh_deprecated), + , DYNALIB_TABLE_NAME(hal_mesh_deprecated) #endif // HAL_PLATFORM_MESH_DEPRECATED - DYNALIB_TABLE_NAME(hal_posix_syscall), + , DYNALIB_TABLE_NAME(hal_posix_syscall) #if HAL_PLATFORM_WIFI && !HAL_PLATFORM_WIFI_COMPAT // This is a minimal wlan_hal that is as of right now only used on Tracker // It exposes only necessary functionality for scanning and has to come at this position // in order not to introduce dynalib incompatibility. - DYNALIB_TABLE_NAME(hal_wlan), + , DYNALIB_TABLE_NAME(hal_wlan) #endif // HAL_PLATFORM_WIFI && !HAL_PLATFORM_WIFI_COMPAT - DYNALIB_TABLE_NAME(hal_storage), + , DYNALIB_TABLE_NAME(hal_storage) #if HAL_PLATFORM_HW_WATCHDOG - DYNALIB_TABLE_NAME(hal_watchdog), + , DYNALIB_TABLE_NAME(hal_watchdog) #endif // HAL_PLATFORM_HW_WATCHDOG - DYNALIB_TABLE_NAME(system_ledger) +#if HAL_PLATFORM_LEDGER + , DYNALIB_TABLE_NAME(system_ledger) +#endif }; #include "system_part1_loader.c" diff --git a/modules/shared/rtl872x/inc/system-part1/module_system_part1.inc b/modules/shared/rtl872x/inc/system-part1/module_system_part1.inc index c6f51e18de..4f65b625b1 100644 --- a/modules/shared/rtl872x/inc/system-part1/module_system_part1.inc +++ b/modules/shared/rtl872x/inc/system-part1/module_system_part1.inc @@ -82,23 +82,25 @@ extern "C" __attribute__((externally_visible)) const void* const system_part1_mo DYNALIB_TABLE_NAME(hal_inet), DYNALIB_TABLE_NAME(hal_netdb), DYNALIB_TABLE_NAME(hal_ifapi), - DYNALIB_TABLE_NAME(hal_resolvapi), + DYNALIB_TABLE_NAME(hal_resolvapi) #if HAL_PLATFORM_WIFI - DYNALIB_TABLE_NAME(hal_wlan), + , DYNALIB_TABLE_NAME(hal_wlan) #endif // HAL_PLATFORM_WIFI #if HAL_PLATFORM_BLE - DYNALIB_TABLE_NAME(hal_ble), + , DYNALIB_TABLE_NAME(hal_ble) #endif // HAL_PLATFORM_BLE - DYNALIB_TABLE_NAME(hal_posix_syscall), - DYNALIB_TABLE_NAME(hal_storage), + , DYNALIB_TABLE_NAME(hal_posix_syscall) + , DYNALIB_TABLE_NAME(hal_storage) #if HAL_PLATFORM_CELLULAR - DYNALIB_TABLE_NAME(hal_cellular), + , DYNALIB_TABLE_NAME(hal_cellular) #endif // HAL_PLATFORM_CELLULAR #if HAL_PLATFORM_HW_WATCHDOG - DYNALIB_TABLE_NAME(hal_watchdog), + , DYNALIB_TABLE_NAME(hal_watchdog) #endif // HAL_PLATFORM_HW_WATCHDOG - DYNALIB_TABLE_NAME(hal_backup_ram), - DYNALIB_TABLE_NAME(system_ledger) + , DYNALIB_TABLE_NAME(hal_backup_ram) +#if HAL_PLATFORM_LEDGER + , DYNALIB_TABLE_NAME(system_ledger) +#endif }; #include "system_part1_loader.c" diff --git a/modules/tracker/system-part1/module_system_part1_export.ld b/modules/tracker/system-part1/module_system_part1_export.ld index 7f8b7d122d..5ad722f8fb 100644 --- a/modules/tracker/system-part1/module_system_part1_export.ld +++ b/modules/tracker/system-part1/module_system_part1_export.ld @@ -30,4 +30,5 @@ PROVIDE (link_dynalib_location_hal_posix_syscall = platform_system_part1_dyna PROVIDE (link_dynalib_location_hal_wlan = platform_system_part1_dynalib_table_flash_start + 112); PROVIDE (link_dynalib_location_hal_storage = platform_system_part1_dynalib_table_flash_start + 116); PROVIDE (link_dynalib_location_hal_watchdog = platform_system_part1_dynalib_table_flash_start + 120); -PROVIDE (link_dynalib_location_system_ledger = platform_system_part1_dynalib_table_flash_start + 124); +/* TODO: TODO: Enable the Ledger API when we have more flash space available on Tracker */ +/* PROVIDE (link_dynalib_location_system_ledger = platform_system_part1_dynalib_table_flash_start + 124); */ diff --git a/system/inc/system_dynalib_ledger.h b/system/inc/system_dynalib_ledger.h index e1b47ce069..58bee41f09 100644 --- a/system/inc/system_dynalib_ledger.h +++ b/system/inc/system_dynalib_ledger.h @@ -17,6 +17,10 @@ #pragma once +#include "hal_platform.h" + +#if HAL_PLATFORM_LEDGER + #include "dynalib.h" #ifdef DYNALIB_EXPORT @@ -42,3 +46,5 @@ DYNALIB_FN(13, system_ledger, ledger_purge, int(const char*, void*)) DYNALIB_FN(14, system_ledger, ledger_purge_all, int(void*)) DYNALIB_END(system_ledger) + +#endif // HAL_PLATFORM_LEDGER diff --git a/system/inc/system_ledger.h b/system/inc/system_ledger.h index b83780a375..4349a3f777 100644 --- a/system/inc/system_ledger.h +++ b/system/inc/system_ledger.h @@ -17,6 +17,10 @@ #pragma once +#include "hal_platform.h" + +#if HAL_PLATFORM_LEDGER + #include #include @@ -301,3 +305,5 @@ int ledger_purge_all(void* reserved); #ifdef __cplusplus } // extern "C" #endif + +#endif // HAL_PLATFORM_LEDGER diff --git a/system/src/system_ledger.cpp b/system/src/system_ledger.cpp index 530ec7faab..8131b2a2b8 100644 --- a/system/src/system_ledger.cpp +++ b/system/src/system_ledger.cpp @@ -15,6 +15,10 @@ * License along with this library; if not, see . */ +#include "hal_platform.h" + +#if HAL_PLATFORM_LEDGER + #include #include @@ -145,3 +149,5 @@ int ledger_purge_all(void* reserved) { CHECK(LedgerManager::instance()->removeAllData()); return 0; } + +#endif // HAL_PLATFORM_LEDGER diff --git a/system/src/system_ledger_internal.cpp b/system/src/system_ledger_internal.cpp index e44f276404..682034f9bc 100644 --- a/system/src/system_ledger_internal.cpp +++ b/system/src/system_ledger_internal.cpp @@ -15,6 +15,10 @@ * License along with this library; if not, see . */ +#include "hal_platform.h" + +#if HAL_PLATFORM_LEDGER + #include #include #include @@ -887,3 +891,5 @@ int LedgerWriter::close(bool discard) { } // namespace system } // namespace particle + +#endif // HAL_PLATFORM_LEDGER diff --git a/system/src/system_ledger_internal.h b/system/src/system_ledger_internal.h index 35c9c52115..d5decf3cd7 100644 --- a/system/src/system_ledger_internal.h +++ b/system/src/system_ledger_internal.h @@ -17,6 +17,10 @@ #pragma once +#include "hal_platform.h" + +#if HAL_PLATFORM_LEDGER + #include #include #include @@ -385,3 +389,5 @@ inline void LedgerBase::release() const { } } // namespace particle::system + +#endif // HAL_PLATFORM_LEDGER diff --git a/user/tests/wiring/ledger/ledger.cpp b/user/tests/wiring/ledger/ledger.cpp index dbbaa782a6..fca2f67b27 100644 --- a/user/tests/wiring/ledger/ledger.cpp +++ b/user/tests/wiring/ledger/ledger.cpp @@ -1,3 +1,7 @@ +#include "hal_platform.h" + +#if HAL_PLATFORM_LEDGER + #include "application.h" #include "unit-test/unit-test.h" @@ -184,3 +188,5 @@ test(08_purge) { // Remove the test ledger files assertEqual(ledger_purge("test", nullptr), 0); } + +#endif // HAL_PLATFORM_LEDGER diff --git a/wiring/inc/spark_wiring_cloud.h b/wiring/inc/spark_wiring_cloud.h index d4733568f9..b397587653 100644 --- a/wiring/inc/spark_wiring_cloud.h +++ b/wiring/inc/spark_wiring_cloud.h @@ -34,6 +34,7 @@ #include "spark_wiring_watchdog.h" #include "spark_wiring_async.h" #include "spark_wiring_flags.h" +#include "spark_wiring_platform.h" #include "spark_wiring_global.h" #include "interrupts_hal.h" #include "system_mode.h" @@ -432,6 +433,7 @@ class CloudClass { */ static int maxFunctionArgumentSize(); +#if Wiring_Ledger /** * Get a ledger instance. * @@ -439,6 +441,7 @@ class CloudClass { * @return Ledger instance. */ static particle::Ledger ledger(const char* name); +#endif // Wiring_Ledger private: diff --git a/wiring/inc/spark_wiring_ledger.h b/wiring/inc/spark_wiring_ledger.h index 5958129870..3bd6dc5a35 100644 --- a/wiring/inc/spark_wiring_ledger.h +++ b/wiring/inc/spark_wiring_ledger.h @@ -17,6 +17,10 @@ #pragma once +#include "spark_wiring_platform.h" + +#if Wiring_Ledger + #include #include #include @@ -601,3 +605,5 @@ inline bool operator!=(const Variant& var, const LedgerData& data) { } } // namespace particle + +#endif // Wiring_Ledger diff --git a/wiring/inc/spark_wiring_platform.h b/wiring/inc/spark_wiring_platform.h index f044fbc86e..199672cd9d 100644 --- a/wiring/inc/spark_wiring_platform.h +++ b/wiring/inc/spark_wiring_platform.h @@ -72,6 +72,10 @@ #define Wiring_Watchdog 1 #endif // HAL_PLATFORM_HW_WATCHDOG +#if HAL_PLATFORM_LEDGER +#define Wiring_Ledger 1 +#endif + #ifndef Wiring_SPI1 #define Wiring_SPI1 0 #endif @@ -166,5 +170,9 @@ #define Wiring_Watchdog 0 #endif // Wiring_Watchdog +#ifndef Wiring_Ledger +#define Wiring_Ledger 0 +#endif + #endif /* SPARK_WIRING_PLATFORM_H */ diff --git a/wiring/src/spark_wiring_cloud.cpp b/wiring/src/spark_wiring_cloud.cpp index abeccd2a57..467809a783 100644 --- a/wiring/src/spark_wiring_cloud.cpp +++ b/wiring/src/spark_wiring_cloud.cpp @@ -127,6 +127,8 @@ int CloudClass::maxFunctionArgumentSize() { return size; } +#if Wiring_Ledger + Ledger CloudClass::ledger(const char* name) { ledger_instance* instance = nullptr; int r = ledger_get_instance(&instance, name, nullptr); @@ -136,3 +138,5 @@ Ledger CloudClass::ledger(const char* name) { } return Ledger(instance, false /* addRef */); } + +#endif // Wiring_Ledger diff --git a/wiring/src/spark_wiring_ledger.cpp b/wiring/src/spark_wiring_ledger.cpp index 0faa615893..dd5f62615d 100644 --- a/wiring/src/spark_wiring_ledger.cpp +++ b/wiring/src/spark_wiring_ledger.cpp @@ -15,6 +15,10 @@ * License along with this library; if not, see . */ +#include "spark_wiring_platform.h" + +#if Wiring_Ledger + #include #include @@ -296,3 +300,5 @@ int Ledger::onSync(OnSyncFunction callback) { } } // namespace particle + +#endif // Wiring_Ledger