Skip to content

Commit

Permalink
reword and fix littlefs define
Browse files Browse the repository at this point in the history
  • Loading branch information
openshwprojects committed Sep 29, 2023
1 parent 841aade commit 344251e
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/cmnds/cmd_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
int cmd_uartInitIndex = 0;


#ifdef ENABLE_LITTLEFS
#if ENABLE_LITTLEFS
#include "../littlefs/our_lfs.h"
#endif
#ifdef PLATFORM_BL602
Expand Down
2 changes: 1 addition & 1 deletion src/cmnds/cmd_newLEDDriver.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "../cJSON/cJSON.h"
#include <string.h>
#include <math.h>
#ifdef ENABLE_LITTLEFS
#if ENABLE_LITTLEFS
#include "../littlefs/our_lfs.h"
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/cmnds/cmd_newLEDDriver_colors.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "cmd_local.h"
#include "../mqtt/new_mqtt.h"
#include "../cJSON/cJSON.h"
#ifdef ENABLE_LITTLEFS
#if ENABLE_LITTLEFS
#include "../littlefs/our_lfs.h"
#endif

Expand Down
6 changes: 3 additions & 3 deletions src/cmnds/cmd_tasmota.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "cmd_local.h"
#include "../new_pins.h"
#include "../new_cfg.h"
#ifdef ENABLE_LITTLEFS
#if ENABLE_LITTLEFS
#include "../littlefs/our_lfs.h"
#endif

Expand Down Expand Up @@ -140,7 +140,7 @@ static commandResult_t cmnd_backlog(const void * context, const char *cmd, const
// Returns a buffer created with malloc.
// You must free it later.
byte *LFS_ReadFile(const char *fname) {
#ifdef ENABLE_LITTLEFS
#if ENABLE_LITTLEFS
if (lfs_present()){
lfs_file_t file;
int lfsres;
Expand Down Expand Up @@ -219,7 +219,7 @@ byte *LFS_ReadFile(const char *fname) {
}

static commandResult_t cmnd_lfsexec(const void * context, const char *cmd, const char *args, int cmdFlags){
#ifdef ENABLE_LITTLEFS
#if ENABLE_LITTLEFS
ADDLOG_DEBUG(LOG_FEATURE_CMD, "exec %s", args);
if (lfs_present()){
lfs_file_t *file = os_malloc(sizeof(lfs_file_t));
Expand Down
6 changes: 3 additions & 3 deletions src/cmnds/cmd_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "../cJSON/cJSON.h"
#include <ctype.h>
#include "cmd_local.h"
#ifdef ENABLE_LITTLEFS
#if ENABLE_LITTLEFS
#include "../littlefs/our_lfs.h"
#endif

Expand Down Expand Up @@ -191,7 +191,7 @@ static commandResult_t testJSON(const void * context, const char *cmd, const cha

// Usage for continous test: addRepeatingEvent 1 -1 lfs_test1 ir.bat
static commandResult_t cmnd_lfs_test1(const void * context, const char *cmd, const char *args, int cmdFlags) {
#ifdef ENABLE_LITTLEFS
#if ENABLE_LITTLEFS
if (lfs_present()) {
lfs_file_t file;
int lfsres;
Expand Down Expand Up @@ -227,7 +227,7 @@ static commandResult_t cmnd_lfs_test1(const void * context, const char *cmd, con
}
// Usage for continous test: addRepeatingEvent 1 -1 lfs_test2 ir.bat
static commandResult_t cmnd_lfs_test2(const void * context, const char *cmd, const char *args, int cmdFlags) {
#ifdef ENABLE_LITTLEFS
#if ENABLE_LITTLEFS
if (lfs_present()) {
lfs_file_t *file;
int lfsres;
Expand Down
12 changes: 5 additions & 7 deletions src/httpserver/rest_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
#include "../ota/ota.h"
#include "../hal/hal_wifi.h"
#include "../hal/hal_flashVars.h"
#ifdef ENABLE_LITTLEFS
#include "../littlefs/our_lfs.h"
#endif
#include "lwip/sockets.h"

#if PLATFORM_XR809
Expand Down Expand Up @@ -81,7 +79,7 @@ static int http_rest_get_seriallog(http_request_t* request);
static int http_rest_post_logconfig(http_request_t* request);
static int http_rest_get_logconfig(http_request_t* request);

#ifdef ENABLE_LITTLEFS
#if ENABLE_LITTLEFS
static int http_rest_get_lfs_delete(http_request_t* request);
static int http_rest_get_lfs_file(http_request_t* request);
static int http_rest_post_lfs_file(http_request_t* request);
Expand Down Expand Up @@ -152,7 +150,7 @@ static int http_rest_get(http_request_t* request) {
return http_rest_get_seriallog(request);
}

#ifdef ENABLE_LITTLEFS
#if ENABLE_LITTLEFS
if (!strcmp(request->url, "api/fsblock")) {
uint32_t newsize = CFG_GetLFS_Size();
uint32_t newstart = (LFS_BLOCKS_END - newsize);
Expand All @@ -173,7 +171,7 @@ static int http_rest_get(http_request_t* request) {
}
#endif

#ifdef ENABLE_LITTLEFS
#if ENABLE_LITTLEFS
if (!strncmp(request->url, "api/lfs/", 8)) {
return http_rest_get_lfs_file(request);
}
Expand Down Expand Up @@ -254,7 +252,7 @@ static int http_rest_post(http_request_t* request) {
}


#ifdef ENABLE_LITTLEFS
#if ENABLE_LITTLEFS
if (!strcmp(request->url, "api/fsblock")) {
if (lfs_present()) {
release_lfs();
Expand Down Expand Up @@ -328,7 +326,7 @@ static int http_rest_app(http_request_t* request) {
return 0;
}

#ifdef ENABLE_LITTLEFS
#if ENABLE_LITTLEFS

int EndsWith(const char* str, const char* suffix)
{
Expand Down
2 changes: 1 addition & 1 deletion src/littlefs/our_lfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
//https://github.com/littlefs-project/littlefs


#ifdef ENABLE_LITTLEFS
#if ENABLE_LITTLEFS
// define the feature ADDLOGF_XXX will use
#define LOG_FEATURE LOG_FEATURE_LFS

Expand Down
3 changes: 2 additions & 1 deletion src/littlefs/our_lfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*****************************************************************************/

#include "../obk_config.h"
#include "lfs.h"

// we need that even if LFS is disabled

Expand All @@ -36,6 +35,8 @@

#if ENABLE_LITTLEFS

#include "lfs.h"

// 512k MAX - i.e. no more that 0x80000
// 0x8000 = 32k
#define LFS_BLOCKS_MIN_LEN 0x4000
Expand Down
4 changes: 2 additions & 2 deletions src/new_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "hal/hal_wifi.h"
#include "hal/hal_flashConfig.h"
#include "cmnds/cmd_public.h"
#ifdef ENABLE_LITTLEFS
#if ENABLE_LITTLEFS
#include "littlefs/our_lfs.h"
#endif

Expand Down Expand Up @@ -668,7 +668,7 @@ void CFG_SetButtonRepeatPressTime(int value) {
}
}

#ifdef ENABLE_LITTLEFS
#if ENABLE_LITTLEFS
void CFG_SetLFS_Size(uint32_t value) {
if(g_cfg.LFS_Size != value) {
g_cfg.LFS_Size = value;
Expand Down
5 changes: 2 additions & 3 deletions src/new_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,10 @@ void CFG_SetButtonLongPressTime(int value);
void CFG_SetButtonShortPressTime(int value);
void CFG_SetButtonRepeatPressTime(int value);

#ifdef ENABLE_LITTLEFS
#if ENABLE_LITTLEFS
void CFG_SetLFS_Size(uint32_t value);
uint32_t CFG_GetLFS_Size();
#endif

#endif

#endif

1 change: 1 addition & 0 deletions src/obk_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@

#elif PLATFORM_BEKEN

// set to 0 to disable
#define ENABLE_LITTLEFS 1
#define ENABLE_NTP 1
#define ENABLE_DRIVER_LED 1
Expand Down
6 changes: 3 additions & 3 deletions src/user_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "mqtt/new_mqtt.h"
#include "ota/ota.h"

#ifdef ENABLE_LITTLEFS
#if ENABLE_LITTLEFS
#include "littlefs/our_lfs.h"
#endif

Expand Down Expand Up @@ -887,7 +887,7 @@ void Main_Init_BeforeDelay_Unsafe(bool bAutoRunScripts) {
PIN_AddCommands();
ADDLOGF_DEBUG("Initialised pins\r\n");

#ifdef ENABLE_LITTLEFS
#if ENABLE_LITTLEFS
// initialise the filesystem, only if present.
// don't create if it does not mount
// do this for ST mode only, as it may be something in FS which is killing us,
Expand Down Expand Up @@ -1063,7 +1063,7 @@ void Main_Init_Before_Delay()
}
CFG_InitAndLoad();

#ifdef ENABLE_LITTLEFS
#if ENABLE_LITTLEFS
LFSAddCmds();
#endif

Expand Down

0 comments on commit 344251e

Please sign in to comment.