mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-24 11:46:34 +00:00
Add pages.jsonl configuration option
This commit is contained in:
parent
df4714cfe5
commit
ac17ec87ff
@ -21,7 +21,14 @@
|
||||
#endif
|
||||
|
||||
#ifndef HASP_PAGES_JSONL
|
||||
#define HASP_PAGES_JSONL "{\"page\":1,\"id\":10,\"w\":240,\"obj\":\"label\",\"text\":\"%hostname%\"}"
|
||||
// #define HASP_PAGES_JSONL "{\"page\":1,\"id\":10,\"w\":240,\"obj\":\"label\",\"text\":\"%hostname%\"}"
|
||||
#if defined(PAGES_JSONL)
|
||||
extern const uint8_t PAGES_JSONL_START[] asm(QUOTE(PAGES_JSONL)"_start");
|
||||
extern const uint8_t PAGES_JSONL_END[] asm(QUOTE(PAGES_JSONL)"_end");
|
||||
#else
|
||||
extern const uint8_t PAGES_JSONL_START[] asm("_binary_data_pages_pages_jsonl_start");
|
||||
extern const uint8_t PAGES_JSONL_END[] asm("_binary_data_pages_pages_jsonl_end");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <Arduino.h>
|
||||
@ -240,7 +247,7 @@ String filesystem_list(fs::FS& fs, const char* dirname, uint8_t levels)
|
||||
}
|
||||
#endif
|
||||
|
||||
static void filesystem_write_file(const char* filename, const char* data)
|
||||
static void filesystem_write_file(const char* filename, const char* data, size_t len)
|
||||
{
|
||||
if(HASP_FS.exists(filename)) return;
|
||||
|
||||
@ -248,7 +255,7 @@ static void filesystem_write_file(const char* filename, const char* data)
|
||||
File file = HASP_FS.open(filename, "w");
|
||||
|
||||
if(file) {
|
||||
file.print(data);
|
||||
file.write((const uint8_t*)data, len);
|
||||
file.close();
|
||||
LOG_INFO(TAG_CONF, F(D_FILE_SAVED), filename);
|
||||
} else {
|
||||
@ -258,17 +265,21 @@ static void filesystem_write_file(const char* filename, const char* data)
|
||||
|
||||
void filesystemSetupFiles()
|
||||
{
|
||||
filesystem_write_file("/pages.jsonl", HASP_PAGES_JSONL);
|
||||
filesystem_write_file("/online.cmd", HASP_ONLINE_CMD);
|
||||
filesystem_write_file("/offline.cmd", HASP_OFFLINE_CMD);
|
||||
#ifdef HASP_PAGES_JSONL
|
||||
filesystem_write_file("/pages.jsonl", HASP_PAGES_JSONL, strlen(HASP_PAGES_JSONL));
|
||||
#else
|
||||
filesystem_write_file("/pages.jsonl", (const char*)PAGES_JSONL_START, PAGES_JSONL_END - PAGES_JSONL_START);
|
||||
#endif
|
||||
filesystem_write_file("/online.cmd", HASP_ONLINE_CMD, strlen(HASP_ONLINE_CMD));
|
||||
filesystem_write_file("/offline.cmd", HASP_OFFLINE_CMD, strlen(HASP_OFFLINE_CMD));
|
||||
#ifdef HASP_BOOT_CMD
|
||||
filesystem_write_file("/boot.cmd", HASP_BOOT_CMD);
|
||||
filesystem_write_file("/boot.cmd", HASP_BOOT_CMD, strlen(HASP_BOOT_CMD));
|
||||
#endif
|
||||
#ifdef HASP_MQTT_ON_CMD
|
||||
filesystem_write_file("/mqtt_on.cmd", HASP_MQTT_ON_CMD);
|
||||
filesystem_write_file("/mqtt_on.cmd", HASP_MQTT_ON_CMD, strlen(HASP_MQTT_ON_CMD));
|
||||
#endif
|
||||
#ifdef HASP_MQTT_OFF_CMD
|
||||
filesystem_write_file("/mqtt_off.cmd", HASP_MQTT_OFF_CMD);
|
||||
filesystem_write_file("/mqtt_off.cmd", HASP_MQTT_OFF_CMD, strlen(HASP_MQTT_OFF_CMD));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user