From ea4510dfe03f891340985594c4de15134e548853 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 17 Nov 2015 12:54:57 +0000 Subject: recvr --- polycom_recv/mdns.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 polycom_recv/mdns.c (limited to 'polycom_recv/mdns.c') diff --git a/polycom_recv/mdns.c b/polycom_recv/mdns.c new file mode 100644 index 0000000..51d1b48 --- /dev/null +++ b/polycom_recv/mdns.c @@ -0,0 +1,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); +} -- cgit v1.2.3