summaryrefslogtreecommitdiffstats
path: root/polycom_recv/mdns.c
diff options
context:
space:
mode:
Diffstat (limited to 'polycom_recv/mdns.c')
-rw-r--r--polycom_recv/mdns.c57
1 files changed, 57 insertions, 0 deletions
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);
+}