Skip to content

Commit

Permalink
Disable the Ledger on the Tracker and GCC platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeuz committed Jul 7, 2023
1 parent b05b0dc commit fece42c
Show file tree
Hide file tree
Showing 17 changed files with 98 additions and 21 deletions.
4 changes: 4 additions & 0 deletions hal/inc/hal_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
2 changes: 2 additions & 0 deletions hal/src/gcc/hal_platform_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,5 @@
#endif

#define HAL_PLATFORM_FREERTOS (0)

#define HAL_PLATFORM_LEDGER (0)
3 changes: 3 additions & 0 deletions hal/src/tracker/hal_platform_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
24 changes: 13 additions & 11 deletions modules/shared/nRF52840/inc/system-part1/module_system_part1.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
20 changes: 11 additions & 9 deletions modules/shared/rtl872x/inc/system-part1/module_system_part1.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion modules/tracker/system-part1/module_system_part1_export.ld
Original file line number Diff line number Diff line change
Expand Up @@ -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); */
6 changes: 6 additions & 0 deletions system/inc/system_dynalib_ledger.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

#pragma once

#include "hal_platform.h"

#if HAL_PLATFORM_LEDGER

#include "dynalib.h"

#ifdef DYNALIB_EXPORT
Expand All @@ -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
6 changes: 6 additions & 0 deletions system/inc/system_ledger.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

#pragma once

#include "hal_platform.h"

#if HAL_PLATFORM_LEDGER

#include <stddef.h>
#include <stdint.h>

Expand Down Expand Up @@ -301,3 +305,5 @@ int ledger_purge_all(void* reserved);
#ifdef __cplusplus
} // extern "C"
#endif

#endif // HAL_PLATFORM_LEDGER
6 changes: 6 additions & 0 deletions system/src/system_ledger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/

#include "hal_platform.h"

#if HAL_PLATFORM_LEDGER

#include <memory>
#include <mutex>

Expand Down Expand Up @@ -145,3 +149,5 @@ int ledger_purge_all(void* reserved) {
CHECK(LedgerManager::instance()->removeAllData());
return 0;
}

#endif // HAL_PLATFORM_LEDGER
6 changes: 6 additions & 0 deletions system/src/system_ledger_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/

#include "hal_platform.h"

#if HAL_PLATFORM_LEDGER

#include <algorithm>
#include <mutex>
#include <cstdio>
Expand Down Expand Up @@ -887,3 +891,5 @@ int LedgerWriter::close(bool discard) {
} // namespace system

} // namespace particle

#endif // HAL_PLATFORM_LEDGER
6 changes: 6 additions & 0 deletions system/src/system_ledger_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

#pragma once

#include "hal_platform.h"

#if HAL_PLATFORM_LEDGER

#include <optional>
#include <utility>
#include <memory>
Expand Down Expand Up @@ -385,3 +389,5 @@ inline void LedgerBase::release() const {
}

} // namespace particle::system

#endif // HAL_PLATFORM_LEDGER
6 changes: 6 additions & 0 deletions user/tests/wiring/ledger/ledger.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#include "hal_platform.h"

#if HAL_PLATFORM_LEDGER

#include "application.h"
#include "unit-test/unit-test.h"

Expand Down Expand Up @@ -184,3 +188,5 @@ test(08_purge) {
// Remove the test ledger files
assertEqual(ledger_purge("test", nullptr), 0);
}

#endif // HAL_PLATFORM_LEDGER
3 changes: 3 additions & 0 deletions wiring/inc/spark_wiring_cloud.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -432,13 +433,15 @@ class CloudClass {
*/
static int maxFunctionArgumentSize();

#if Wiring_Ledger
/**
* Get a ledger instance.
*
* @param name Ledger name.
* @return Ledger instance.
*/
static particle::Ledger ledger(const char* name);
#endif // Wiring_Ledger

private:

Expand Down
6 changes: 6 additions & 0 deletions wiring/inc/spark_wiring_ledger.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

#pragma once

#include "spark_wiring_platform.h"

#if Wiring_Ledger

#include <functional>
#include <initializer_list>
#include <utility>
Expand Down Expand Up @@ -601,3 +605,5 @@ inline bool operator!=(const Variant& var, const LedgerData& data) {
}

} // namespace particle

#endif // Wiring_Ledger
8 changes: 8 additions & 0 deletions wiring/inc/spark_wiring_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -166,5 +170,9 @@
#define Wiring_Watchdog 0
#endif // Wiring_Watchdog

#ifndef Wiring_Ledger
#define Wiring_Ledger 0
#endif

#endif /* SPARK_WIRING_PLATFORM_H */

4 changes: 4 additions & 0 deletions wiring/src/spark_wiring_cloud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -136,3 +138,5 @@ Ledger CloudClass::ledger(const char* name) {
}
return Ledger(instance, false /* addRef */);
}

#endif // Wiring_Ledger
6 changes: 6 additions & 0 deletions wiring/src/spark_wiring_ledger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/

#include "spark_wiring_platform.h"

#if Wiring_Ledger

#include <variant>
#include <memory>

Expand Down Expand Up @@ -296,3 +300,5 @@ int Ledger::onSync(OnSyncFunction callback) {
}

} // namespace particle

#endif // Wiring_Ledger

0 comments on commit fece42c

Please sign in to comment.