You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
#include "config.h"
#include <lwip/sockets.h>
#include "lwip/api.h"
#include "lwip/opt.h"
#include "lwip/sys.h"
#include "zflash.h"
#include "zboard.h"
#define CONFIG_SIZE ((sizeof(config_t) / 4) + ((sizeof(config_t) % 4) > 0 ? 1 : 0))
static config_t s_config;
static bool s_is_first_init = false;
void config_init(void) { #if 1
IP4_ADDR((ip4_addr_t *)&s_config.ip, 192, 168, 8, 10); IP4_ADDR((ip4_addr_t *)&s_config.gw, 192, 168, 8, 1); IP4_ADDR((ip4_addr_t *)&s_config.netmask, 255, 255, 255, 0); s_config.localport = SERVICE_PORT; s_config.obtaining_ip_mode = OBTAINING_IP_MODE_DHCP; // dhcp
s_config.mask = 1; //
#endif
// if (stmflash_write(FLASH_START_ADDRESS, (uint32_t *)&s_config, CONFIG_SIZE) < 0)
// {
// printf("flash write config error\r\n");
// }
// config_flash_read();
/*dumpconfig*/ config_dump_config(); } bool config_is_first_init(void) { return s_is_first_init; } void config_dump_config(void) { printf("=================config================\r\n"); printf("= config obtaining_ip_mode %u\r\n", s_config.obtaining_ip_mode); printf("= config ip %s\r\n", inet_ntoa(s_config.ip)); printf("= config gw: %s\r\n", inet_ntoa(s_config.gw)); printf("= config netmask: %s\r\n", inet_ntoa(s_config.netmask)); printf("= config localport: %u\r\n", s_config.localport); }
bool config_update(void) { // if (stmflash_write(FLASH_SAVE_ADDR, (uint32_t *)&s_config, CONFIG_SIZE) < 0)
// {
// printf("flash write config error\r\n");
// return false;
// }
// config_dump_config();
return true; }
void config_flash_read(void) { //
// stmflash_read(FLASH_SAVE_ADDR, (uint32_t *)&s_config, CONFIG_SIZE);
}
config_t *config_get(void) { return &s_config; }
|