config
This commit is contained in:
parent
a625004729
commit
31962fc8f0
@ -5,12 +5,16 @@
|
|||||||
#include <spi.h>
|
#include <spi.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#define CONFIG_MAGIC 0xdead0004
|
#define CONFIG_MAGIC 0xdead0005
|
||||||
|
|
||||||
typedef struct __attribute__((__packed__)) s_configBlock {
|
typedef struct __attribute__((__packed__)) s_configBlock {
|
||||||
uint32_t configMagic;
|
uint32_t configMagic;
|
||||||
char deviceName[16];
|
char deviceName[16];
|
||||||
uint8_t macAddress[6];
|
uint8_t macAddress[6];
|
||||||
|
char ntpServer[48];
|
||||||
|
char deviceId[16];
|
||||||
|
char sharedSecret[32];
|
||||||
|
char location[48];
|
||||||
uint8_t filler[6];
|
uint8_t filler[6];
|
||||||
} t_configBlock;
|
} t_configBlock;
|
||||||
|
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
#define NTP_SERVER "0.de.pool.ntp.org"
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint64_t seconds;
|
uint64_t seconds;
|
||||||
uint32_t missedUpdates;
|
uint32_t missedUpdates;
|
||||||
|
@ -11,6 +11,10 @@ t_configBlock defaultConfigBlock = {
|
|||||||
.configMagic = CONFIG_MAGIC,
|
.configMagic = CONFIG_MAGIC,
|
||||||
.deviceName = "MainsCnt",
|
.deviceName = "MainsCnt",
|
||||||
.macAddress = { 0x00, 0xA0, 0x57, 0x05, 0x3E, 0x0F },
|
.macAddress = { 0x00, 0xA0, 0x57, 0x05, 0x3E, 0x0F },
|
||||||
|
.ntpServer = "0.de.pool.ntp.org",
|
||||||
|
.deviceId = "MainsCnt01",
|
||||||
|
.sharedSecret = "sharedSecretGanzGeheim",
|
||||||
|
.location = "Essen, DE",
|
||||||
.filler = { 0 }
|
.filler = { 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -46,5 +50,8 @@ void configInit() {
|
|||||||
mainConfigBlock.macAddress[3],
|
mainConfigBlock.macAddress[3],
|
||||||
mainConfigBlock.macAddress[4],
|
mainConfigBlock.macAddress[4],
|
||||||
mainConfigBlock.macAddress[5]);
|
mainConfigBlock.macAddress[5]);
|
||||||
|
coloredMsg(LOG_BLUE, "cfg ci ntp server: %s", mainConfigBlock.ntpServer);
|
||||||
|
coloredMsg(LOG_BLUE, "cfg ci deviceId: %s", mainConfigBlock.deviceId);
|
||||||
|
coloredMsg(LOG_BLUE, "cfg ci sharedSecret: %s", mainConfigBlock.sharedSecret);
|
||||||
|
coloredMsg(LOG_BLUE, "cfg ci location: %s", mainConfigBlock.location);
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ static void wizSNTPHandler(void *handle) {
|
|||||||
coloredMsg(LOG_BLUE, "wizsh, about to call SNTP");
|
coloredMsg(LOG_BLUE, "wizsh, about to call SNTP");
|
||||||
|
|
||||||
uint8_t ntpServer[4];
|
uint8_t ntpServer[4];
|
||||||
if (wizDnsQuery(NTP_SERVER, ntpServer)) {
|
if (wizDnsQuery(config->ntpServer, ntpServer)) {
|
||||||
SNTP_init(SNTP_SOCK, ntpServer, 0, sntpBuffer);
|
SNTP_init(SNTP_SOCK, ntpServer, 0, sntpBuffer);
|
||||||
bool updated = false;
|
bool updated = false;
|
||||||
for (uint8_t i = 0; i < 16; i++) {
|
for (uint8_t i = 0; i < 16; i++) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user