-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwifi.c
More file actions
executable file
·33 lines (29 loc) · 841 Bytes
/
wifi.c
File metadata and controls
executable file
·33 lines (29 loc) · 841 Bytes
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
33
#include "osapi.h"
#include "user_interface.h"
#include "ssid.h"
#include "wifi.h"
#include "node.h"
#include "espmissingincludes.h"
static struct station_config wifi_config;
static void wifi_cb(System_Event_t * evt);
void ICACHE_FLASH_ATTR wifi_init(void)
{
os_printf("wifi_init: Setting up 802.11 to station mode ... ");
if (!wifi_set_opmode_current(1)) {
os_printf("Failed to set 802.11 station mode!\n");
}
os_memcpy(&wifi_config.ssid, SSID, 32);
os_memcpy(&wifi_config.password, PASSWORD, 64);
wifi_config.bssid_set = 0;
wifi_set_event_handler_cb(wifi_cb);
if (!wifi_station_set_config_current(&wifi_config)) {
os_printf("Failed to set 802.11 config!\n");
}
}
static void ICACHE_FLASH_ATTR wifi_cb(System_Event_t * evt)
{
if (evt->event == EVENT_STAMODE_GOT_IP) {
os_printf("Got IP!\n");
node_notify(GOT_IP);
}
}