summaryrefslogtreecommitdiffstats
path: root/polycom_recv/mdns.c
diff options
context:
space:
mode:
authorroot <root@no.no.james.local>2015-11-17 12:54:57 +0000
committerroot <root@no.no.james.local>2015-11-17 12:54:57 +0000
commitea4510dfe03f891340985594c4de15134e548853 (patch)
treee9f8df4d1c45a5781aea7d74b9973b5b92ca7d5f /polycom_recv/mdns.c
parent7059fd523d6514d04e232f1d0acbc983856bd2e6 (diff)
downloadpolycom-ea4510dfe03f891340985594c4de15134e548853.tar.gz
polycom-ea4510dfe03f891340985594c4de15134e548853.tar.bz2
polycom-ea4510dfe03f891340985594c4de15134e548853.zip
recvr
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);
+}