blob: 51d1b48976ed49b25b0f4c014e36a37977f0748a (
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#include "project.h"
static os_timer_t mdns_timer;
static struct mdns_info *info;
static void ICACHE_FLASH_ATTR
check_connexion (void *arg)
{
struct ip_info ipconfig;
static ip_addr_t last_ip;
wifi_get_ip_info (STATION_IF, &ipconfig);
if (wifi_station_get_connect_status () != STATION_GOT_IP)
return;
if (ipconfig.ip.addr == last_ip.addr)
return;
last_ip.addr = ipconfig.ip.addr;
if (info)
{
espconn_mdns_close ();
os_free (info);
}
info = (struct mdns_info *) os_zalloc (sizeof (struct mdns_info));
if (!info)
{
last_ip.addr = 0;
return;
}
info->host_name = "lights";
info->ipAddr = last_ip.addr;
info->server_name = "lights";
info->server_port = 80;
info->txt_data[0] = "version = 1.0.1";
espconn_mdns_init (info);
}
void ICACHE_FLASH_ATTR
mdns_start (void)
{
os_timer_disarm (&mdns_timer);
os_timer_setfn (&mdns_timer, (os_timer_func_t *) check_connexion, NULL);
os_timer_arm (&mdns_timer, 10000, 1);
}
|