From 3c116f45bd35a259f2c8c3ca109c696adc857d07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Fri, 24 Nov 2017 16:50:42 +0100 Subject: [PATCH] Add NetBIOS support --- code/espurna/config/general.h | 8 ++++++-- code/espurna/espurna.ino | 6 ++++++ code/espurna/netbios.ino | 20 ++++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 code/espurna/netbios.ino diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index 75cba492..c315146b 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -328,11 +328,15 @@ PROGMEM const char* const custom_reset_string[] = { // ----------------------------------------------------------------------------- #ifndef MDNS_SUPPORT -#define MDNS_SUPPORT 1 // Publish services using mDNS by default (1.09Kb) +#define MDNS_SUPPORT 1 // Publish services using mDNS by default (1.84Kb) #endif #ifndef LLMNR_SUPPORT -#define LLMNR_SUPPORT 0 // ublish device using LLMNR protocol by default (1.95Kb) - requires 2.4.0 +#define LLMNR_SUPPORT 0 // Publish device using LLMNR protocol by default (1.95Kb) - requires 2.4.0 +#endif + +#ifndef NETBIOS_SUPPORT +#define NETBIOS_SUPPORT 0 // Publish device using NetBIOS protocol by default (1.26Kb) - requires 2.4.0 #endif // ----------------------------------------------------------------------------- diff --git a/code/espurna/espurna.ino b/code/espurna/espurna.ino index 5316a992..5e8873e9 100644 --- a/code/espurna/espurna.ino +++ b/code/espurna/espurna.ino @@ -174,6 +174,9 @@ void welcome() { #if MDNS_SUPPORT DEBUG_MSG_P(PSTR(" MDNS")); #endif + #if NETBIOS_SUPPORT + DEBUG_MSG_P(PSTR(" NETBIOS")); + #endif #if NOFUSS_SUPPORT DEBUG_MSG_P(PSTR(" NOFUSS")); #endif @@ -274,6 +277,9 @@ void setup() { #if LLMNR_SUPPORT llmnrSetup(); #endif + #if NETBIOS_SUPPORT + netbiosSetup(); + #endif #if NTP_SUPPORT ntpSetup(); #endif diff --git a/code/espurna/netbios.ino b/code/espurna/netbios.ino new file mode 100644 index 00000000..478b81f9 --- /dev/null +++ b/code/espurna/netbios.ino @@ -0,0 +1,20 @@ +/* + +NETBIOS MODULE + +Copyright (C) 2017 by Xose PĂ©rez + +*/ + +#if NETBIOS_SUPPORT + +#include + +void netbiosSetup() { + static WiFiEventHandler _netbios_wifi_onSTA = WiFi.onStationModeGotIP([](WiFiEventStationModeGotIP ipInfo) { + NBNS.begin(getSetting("hostname").c_str()); + DEBUG_MSG_P(PSTR("[NETBIOS] Configured\n")); + }); +} + +#endif // NETBIOS_SUPPORT