configuration
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
#include <config.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <config.h>
|
||||
#include <eeprom.h>
|
||||
|
||||
|
||||
t_configBlock defaultConfigBlock = {
|
||||
@ -12,9 +14,19 @@ t_configBlock defaultConfigBlock = {
|
||||
.statusTopic = "IoT/MBGW3/Status",
|
||||
.mbusDataTopic = "IoT/MBGW3/Measurement",
|
||||
.syslogServerName = "syslogserver",
|
||||
.filler = { 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
||||
t_configBlock mainConfigBlock;
|
||||
|
||||
|
||||
|
||||
t_configBlock* getConfig() {
|
||||
return &defaultConfigBlock;
|
||||
}
|
||||
|
||||
|
||||
void configInit() {
|
||||
eepromReadConfigBlock(0, &mainConfigBlock);
|
||||
}
|
@ -48,6 +48,8 @@ static t_deviceStatsBlock deviceStats;
|
||||
static const uint8_t NUM_OF_BLOCKS = 2;
|
||||
static const uint16_t BLOCK_ADDR[] = { 64, 4128 };
|
||||
|
||||
static const uint8_t EEPROM_WRITE_BLOCK_SIZE = 32;
|
||||
|
||||
|
||||
typedef union {
|
||||
struct __attribute__((__packed__)) s_spiMsg {
|
||||
@ -58,7 +60,6 @@ typedef union {
|
||||
uint8_t b[sizeof(struct s_spiMsg)];
|
||||
} t_spiMsg;
|
||||
|
||||
|
||||
t_deviceStats* getGlobalDeviceStats() {
|
||||
return &(deviceStats.s);
|
||||
}
|
||||
@ -126,6 +127,15 @@ static void eepromHourlyUpdateDeviceStats(void *handle) {
|
||||
eepromWrite(DEVICE_STATS_ADDR, deviceStats.b, sizeof(deviceStats));
|
||||
}
|
||||
|
||||
void eepromReadConfigBlock(uint8_t blockNum, t_configBlock *destConfigBlock) {
|
||||
uint8_t configBlockSizeMod = sizeof(*destConfigBlock) % EEPROM_WRITE_BLOCK_SIZE;
|
||||
if (configBlockSizeMod != 0) {
|
||||
coloredMsg(LOG_RED, false, "eeRCB, config block size must be dividable by 32");
|
||||
coloredMsg(LOG_RED, false, "eeRCB, current size is %d", sizeof(*destConfigBlock));
|
||||
coloredMsg(LOG_RED, false, "eeRCB, append %d filler octets", configBlockSizeMod);
|
||||
}
|
||||
}
|
||||
|
||||
// active waiting, use only during initialization!
|
||||
static void eepromActiveDelay(uint8_t delay_ms) {
|
||||
activeDelay(delay_ms);
|
||||
|
@ -20,11 +20,13 @@
|
||||
#include <mqttComm.h>
|
||||
#include <cmdHandler.h>
|
||||
#include <oled.h>
|
||||
#include <config.h>
|
||||
|
||||
|
||||
void my_setup_1() {
|
||||
schInit();
|
||||
logInit();
|
||||
configInit();
|
||||
showInit();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user