aboutsummaryrefslogtreecommitdiff
path: root/main/init.cpp
blob: 425f5916591327e219588346189e73794caf4c36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "config.h"
#include "init.h"

#include <pico/stdio.h>
#include <pico/cyw43_arch.h>

static void init_stdio() {
	stdio_init_all();
}

static void init_cyw34() {
	if (cyw43_arch_init_with_country(CONF_NET_COUNTRY))
		panic("cyw43_arch_init_with_country failed\n");
}

static void init_wifi() {
	// enable 'station' mode (connect to an access point instead of acting like one)
	cyw43_arch_enable_sta_mode();

	if (cyw43_arch_wifi_connect_timeout_ms(CONF_NET_SSID, CONF_NET_PASS, CYW43_AUTH_WPA2_AES_PSK, CONF_NET_CONN_TIMEOUT))
		panic("cyw43_arch_wifi_connect failed\n");

	// TODO: announce hostname
}

void init() {
	init_stdio();
	init_cyw34();
	init_wifi();
	// TODO: initialize i2c
}