move bmc handlers to bmc_hander.h,

add setting hostname for dhcp/dns
This commit is contained in:
Arthur Lu 2024-04-19 11:59:54 -07:00
parent 33aaa589f6
commit e743f56609
3 changed files with 14 additions and 3 deletions

View File

@ -1,5 +1,5 @@
#ifndef HANDLERS_H
#define HANDLERS_H
#ifndef BMC_HANDLER_H
#define BMC_HANDLER_H
#define PW_SWITCH_PIN 0
#define PW_SWITCH_DELAY_MS 100

12
main.c
View File

@ -2,10 +2,18 @@
#define DEBUG_printf printf
#include "pico_lib.h"
#include "handlers.h"
#include "bmc_handler.h"
#include "http_serv.h"
#include "secret.h"
void set_host_name(const char * hostname) {
cyw43_arch_lwip_begin();
struct netif *n = &cyw43_state.netif[CYW43_ITF_STA];
netif_set_hostname(n, hostname);
netif_set_up(n);
cyw43_arch_lwip_end();
}
int main() {
stdio_init_all();
@ -15,6 +23,8 @@ int main() {
}
cyw43_arch_enable_sta_mode();
set_host_name(BMC_HOSTNAME);
DEBUG_printf("[INIT] [OK ] Set hostname to %s\n", BMC_HOSTNAME);
if (cyw43_arch_wifi_connect_timeout_ms(WIFI_SSID, WIFI_PASS, CYW43_AUTH_WPA2_AES_PSK, 30000)){
DEBUG_printf("[INIT] [ERR] Wi-Fi failed to connect\n");

View File

@ -1,6 +1,7 @@
#ifndef SECRET_H
#define SECRET_H
const char BMC_HOSTNAME[] = "pico_bmc";
const char WIFI_SSID[] = "ssid";
const char WIFI_PASS[] = "pass";