summaryrefslogtreecommitdiffstats
path: root/polycom_xmit/mdns.c
diff options
context:
space:
mode:
authorroot <root@lamia.panaceas.james.local>2015-07-21 10:12:26 +0100
committerroot <root@lamia.panaceas.james.local>2015-07-21 10:12:26 +0100
commita98e5d802b071a240ba38dfa9b039fd3f7d47ffd (patch)
tree292ffdc875fb75bf413f070a58b84f74a911232b /polycom_xmit/mdns.c
parent16debdbce7a5d92167207c17f18406c6905eb9b5 (diff)
downloadpolycom-a98e5d802b071a240ba38dfa9b039fd3f7d47ffd.tar.gz
polycom-a98e5d802b071a240ba38dfa9b039fd3f7d47ffd.tar.bz2
polycom-a98e5d802b071a240ba38dfa9b039fd3f7d47ffd.zip
fish
Diffstat (limited to 'polycom_xmit/mdns.c')
-rw-r--r--polycom_xmit/mdns.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/polycom_xmit/mdns.c b/polycom_xmit/mdns.c
new file mode 100644
index 0000000..e01ba11
--- /dev/null
+++ b/polycom_xmit/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 = "polycom-2w";
+ info->ipAddr = last_ip.addr;
+ info->server_name = "leds";
+ 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);
+}