|
|
@ -22,30 +22,35 @@ |
|
|
|
config_flash_write_start_address += 4; |
|
|
|
|
|
|
|
#define CONFIG_SIZE ((sizeof(config_t) / 4) + ((sizeof(config_t) % 4) > 0 ? 1 : 0)) |
|
|
|
#define COINFIG_WRITED_FLAG 0X88888888 |
|
|
|
|
|
|
|
static config_t s_config; |
|
|
|
static bool s_is_first_init = false; |
|
|
|
|
|
|
|
void config_init(void) |
|
|
|
{ |
|
|
|
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; // |
|
|
|
|
|
|
|
if (config_flash_write() < 0) |
|
|
|
{ |
|
|
|
printf("flash write config error\r\n"); |
|
|
|
} |
|
|
|
else |
|
|
|
config_flash_read(); |
|
|
|
|
|
|
|
if (s_config.config_writed_flag != COINFIG_WRITED_FLAG) |
|
|
|
{ |
|
|
|
printf("flash write config success\r\n"); |
|
|
|
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; // |
|
|
|
s_config.config_writed_flag = COINFIG_WRITED_FLAG; |
|
|
|
|
|
|
|
if (config_flash_write() < 0) |
|
|
|
{ |
|
|
|
printf("flash write config error\r\n"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
printf("flash write config success\r\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
config_flash_read(); |
|
|
|
|
|
|
|
/*dumpconfig*/ |
|
|
|
config_dump_config(); |
|
|
|
} |
|
|
@ -72,6 +77,7 @@ void config_flash_read(void) |
|
|
|
FLASH_READ(s_config.gw); |
|
|
|
FLASH_READ(s_config.netmask); |
|
|
|
FLASH_READ(s_config.localport); |
|
|
|
FLASH_READ(s_config.config_writed_flag); |
|
|
|
} |
|
|
|
|
|
|
|
config_t *config_get(void) { return &s_config; } |
|
|
@ -93,6 +99,7 @@ int8_t config_flash_write(void) |
|
|
|
FLASH_WRITE(s_config.gw); |
|
|
|
FLASH_WRITE(s_config.netmask); |
|
|
|
FLASH_WRITE(s_config.localport); |
|
|
|
FLASH_WRITE(s_config.config_writed_flag); |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |